Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AVAudioEngineでリアルタイムレンダリング
Search
Yuki Yasoshima
September 20, 2020
Programming
1
710
AVAudioEngineでリアルタイムレンダリング
iOSDC Japan 2020
Yuki Yasoshima
September 20, 2020
Tweet
Share
More Decks by Yuki Yasoshima
See All by Yuki Yasoshima
Swift Concurrencyとレースコンディション
objectiveaudio
1
510
モーダルの遷移を理解する
objectiveaudio
4
1.8k
オーディオ波形を表示するために知っておくべきこと
objectiveaudio
0
860
リファクタリング・チャレンジ リバーシ編
objectiveaudio
0
130
UIKitは2度ベルを鳴らす
objectiveaudio
0
280
iOSDC2018.pdf
objectiveaudio
1
2k
Objective-C++を使ってMRCで快適に開発する
objectiveaudio
0
22k
Other Decks in Programming
See All in Programming
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
760
Haze - Real time background blurring
chrisbanes
1
500
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
720
return文におけるstd::moveについて
onihusube
1
610
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
Jakarta EE meets AI
ivargrimstad
0
230
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Go の GC の不得意な部分を克服したい
taiyow
2
760
MCP with Cloudflare Workers
yusukebe
2
220
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
KATA
mclloyd
29
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Transcript
:VLJ:BTPTIJNB!ZBTP@TBO "7"VEJP&OHJOFͰ ϦΞϧλΠϜϨϯμϦϯά J04%$+BQBO
༰ ΦʔσΟΦೖग़ྗͷΈ J04ͷΦʔσΟΦ"1* ҆ఆͯ͠ϦΞϧλΠϜʹϨϯμϦϯάΛ͢Δʹ IUUQTHJUIVCDPNPCKFDUJWFBVEJP"VEJP6OJU3FOEFSJOH&YBNQMF αϯϓϧίʔυ
ΦʔσΟΦೖग़ྗͷΈ
ίʔϧόοΫ ΦʔσΟΦೖग़ྗͷΈ ΦʔσΟΦॲཧΛ։࢝͢Δͱઐ༻ͷεϨουͰ܁Γฦ͠ίʔϧόοΫ͕ݺΕΔ ʢඵʹ͖ͭेճҎ্ʣ
ίʔϧόοΫ ग़ྗ ΦʔσΟΦೖग़ྗͷΈ ίʔϧόοΫͰσʔλΛ͢ͱԻ͕ग़ྗ͞ΕΔ
ίʔϧόοΫ ग़ྗ ೖྗ ΦʔσΟΦೖग़ྗͷΈ ίʔϧόοΫʹೖྗ͞ΕͨԻͷσʔλ͕ͬͯ͘Δ
ίʔϧόοΫ ग़ྗ ೖྗ ΦʔσΟΦೖग़ྗͷΈ ❌ ίʔϧόοΫͷॲཧʹ͕͔͔࣌ؒΔͱɺԻ్͕ΕͨΓऔΓ͜΅ͨ͠Γ͢Δ͜ ͱʹͳΔ
"7"VEJP1MBZFSɾ"7"VEJP3FDPSEFSͳͲͷߴϨϕϧͳ"1*ɺ͜ͷΑ͏ͳϨ ϕϧॲཧΛؾʹ͠ͳͯ͘؆୯ʹ͑ΔΑ͏ʹͳ͍ͬͯΔ ϦΞϧλΠϜʹࣗ༝ʹԻΛѻ͍͍ͨ߹ɺϨϕϧͳॲཧΛ͢Δඞཁ͕͋Δ ΦʔσΟΦೖग़ྗͷΈ
J04ͷΦʔσΟΦ"1*
J04ॳظͷࠒ͔Β͋Δ$ݴޠͷ"1* $BSCPODPNQPOFOUCBTFE"VEJP6OJUT "6(SBQI "VEJP2VFVF4FSWJDFT
ඇਪʹͳͬͨ"1* J043FMFBTF/PUFTΑΓ "6(SBQIʢʙJ04ʣ *OUFS"QQBVEJPʢʙJ04ʣ $BSCPODPNQPOFOUCBTFE"VEJP6OJUTʢ͍ۙ͏ͪʹ͑ͳ͘ͳΔʣ
Ճ͞Εͨ"1* "7"VEJP&OHJOFʢJ04ʙʣ "VEJP6OJU7"VEJP6OJU&YUFOTJPOTʢJ04ʙʣ "7"VEJP4PVSDF/PEF"7"VEJP4JOL/PEFʢJ04ʙʣ
J04ҎલͷϦΞϧλΠϜϨϯμϦϯά $ݴޠͷ"VEJP6OJU "6"VEJP6OJUΛܧঝ͢Δ͜ͱͰ"7"VEJP&OHJOFͰՄೳʹͳΔʢϓϥάΠϯ ͷΈͰ࡞ΔͷͰɺηοτΞοϓ͕໘Ͱෳࡶʣ
"7"VEJP4PVSDF/PEF"7"VEJP4JOL/PEF͕ొ ϓϥάΠϯͱൺͯηοτΞοϓ͕༰қʹͳͬͨ J04Ҏ߱ͷϦΞϧλΠϜϨϯμϦϯά
"7"VEJP4PVSDF/PEF ΦʔσΟΦΛग़ྗ͢ΔσʔλΛ͢ 4PVSDF/PEF 0VUQVU/PEF "7"VEJP&OHJOF 3FOEFS #MPDL @interface AVAudioSourceNode :
AVAudioNode <AVAudioMixing> - (instancetype)initWithRenderBlock:(AVAudioSourceNodeRenderBlock)block; - (instancetype)initWithFormat:(AVAudioFormat *)format renderBlock:(AVAudioSourceNodeRenderBlock)block; @end
"7"VEJP4JOL/PEF ΦʔσΟΦͷೖྗ͞ΕͨσʔλΛड͚औΔ *OQVU/PEF 4JOL/PEF "7"VEJP&OHJOF 3FDFJWFS #MPDL @interface AVAudioSinkNode :
AVAudioNode - (instancetype)initWithReceiverBlock:(AVAudioSinkNodeReceiverBlock)block; @end
҆ఆͨ͠ϨϯμϦϯάΛߦ͏
ΦʔσΟΦ*0ͷεϨουʹ͓͍ͯ ϝϞϦͷ֬อΛ͠ͳ͍ MJCEJTQBUDIΘͳ͍ $$ ͰॲཧΛॻ͘ "DDFMFSBUF'SBNFXPSLΛ׆༻͢Δ ଞͷεϨουͱͷϩοΫΛආ͚Δʢ4XJGU0CKFDUJWF$ͷݺͼग़͠ɺϑΝΠϧ ೖग़ྗͷதʹ͋Δʣ IUUQTQPTUEDDGPVSDPNNPONJTUBLFTJOBVEJPEFWFMPQNFOU
αϯϓϧίʔυ "7"VEJP4PVSDF/PEFαΠϯͷ࠶ੜ ʲ%JSFDUʳपͷૢ࡞Λ͙͢ʹө ʲ%FGFSSFEʳཷΊ͍ͯΔόοϑΝʹରͯ͠पͷૢ࡞Λө "7"VEJP4JOL/PEFೖྗԻͷϝʔλʔදࣔ IUUQTHJUIVCDPNPCKFDUJWFBVEJP"VEJP6OJU3FOEFSJOH&YBNQMF
αϯϓϧίʔυͷݴޠߏ 3FOEFS#MPDL3FDFJWFS#MPDLͷத$ Ͱهड़ 0CKFDUJWF$Ͱϥοϓͯ͠/PEFΛฦ͢ "7"VEJP&OHJOFͷߏங6*4XJGUͰهड़
εϨουؒͷΓͱΓ
TUEBUPNJD ಛ ܕɾුಈখܕɾϙΠϯλܕΛεϨουηʔϑʹѻ͑ΔΫϥε JT@MPDL@GSFF ؔͰϩοΫ͞ΕΔ͔औಘͰ͖Δʢࠓ࣌ͷσόΠεͳΒ·ͣ USVFʣ
ෳͷΛΞτϛοΫʹ͢Δ ڞ༻ମͰTUEBUPNJDͷܕͱTUSVDUΛม union Value { void *v; struct { float
const level; float const peak; }; }; static_assert(sizeof(Value) == sizeof(void *), "");
ෳͷΛΞτϛοΫʹ͢Δ ڞ༻ମͰTUEBUPNJDͷܕͱTUSVDUΛม std::atomic<void *> atomicValue; // atomicͷʹηοτ͢Δ Value setValue{.level =
0.0f, .peak = 0.0f}; atomicValue = setValue.v; // atomicͷ͔Βήοτ͢Δ Value getValue{.v = atomicValue};
TUETIBSFE@QUS ಛ $ ͷΫϥεΛࢀরΧϯτํࣜͰอ࣋͢Δ ࢀরΧϯλεϨουηʔϑ ϨϯμϦϯάதʹίϐʔ͠ͳ͍Α͏ʹؾΛ͚ͭΔ
TUETIBSFE@QUS ίϐʔͯ͠͠·͏ॻ͖ํ void sample(std::shared_ptr<SineData> data) { auto localData = data;
} ίϐʔ͞ΕΔ ͭղ์͞ΕΔ ίϐʔ͞ΕΔ
TUETIBSFE@QUS ίϐʔ͞Εͳ͍ॻ͖ํ void sample(std::shared_ptr<SineData> const &data) { auto const &localData
= data; } ίϐʔ͞Εͳ͍ ίϐʔ͞Εͳ͍ Կى͖ͳ͍
ͭͷεϨου͔Βಉ͡σʔλʹॻ͖ࠐΉ %FGFSSFEͷαϯϓϧ
ͭͷεϨου͔Βಉ͡σʔλΛѻ͏ %FGFSSFEͷαϯϓϧ αΠϯੜεϨου αΠϯΛ ॻ͖ࠐΈ ग़ྗόοϑΝʹ ಡΈࠐΈ ڞ༗͢Δσʔλ ͭ ࠷ޙ·ͰಡΈࠐΜͩΒ
ಡΈࠐΈݩΛΓସ͑ αΠϯͷ ॻ͖ࠐΈΛࢦࣔ ඵؒͷ ΦʔσΟΦσʔλ ग़ྗεϨου
ͭͷεϨου͔Βಉ͡σʔλΛѻ͏ %FGFSSFEͷαϯϓϧ αΠϯੜεϨου 8SJUJOH 3FBEJOH ΞτϛοΫͳϑϥά 8SJUJOHͳΒ αΠϯΛॻ͖ࠐΜͰ 3FBEJOHʹ͢Δ 3FBEJOHͳΒ
ग़ྗόοϑΝʹ σʔλΛಡΈࠐΜͰ ࠷ޙ·ͰߦͬͨΒ 8SJUJOHʹ͢Δ ڞ༗͢Δσʔλ ͭ ඵؒͷ ΦʔσΟΦσʔλ ग़ྗεϨου
·ͱΊ $ݴޠͷ"1*ඇਪɻ࣌"7"VEJP&OHJOF ΦʔσΟΦͷεϨου͕ϩοΫͯ͠͠·Θͳ͍Α͏ʹؾΛ͚Δ