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
690
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
490
モーダルの遷移を理解する
objectiveaudio
4
1.7k
オーディオ波形を表示するために知っておくべきこと
objectiveaudio
0
850
リファクタリング・チャレンジ リバーシ編
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
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Outline View in SwiftUI
1024jp
1
330
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
CSC509 Lecture 12
javiergs
PRO
0
160
Ethereum_.pdf
nekomatu
0
470
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
200
CSC509 Lecture 13
javiergs
PRO
0
110
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Quine, Polyglot, 良いコード
qnighy
4
650
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
110
Featured
See All Featured
How GitHub (no longer) Works
holman
310
140k
Become a Pro
speakerdeck
PRO
25
5k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Building Applications with DynamoDB
mza
90
6.1k
Visualization
eitanlees
145
15k
Producing Creativity
orderedlist
PRO
341
39k
Designing Experiences People Love
moore
138
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Thoughts on Productivity
jonyablonski
67
4.3k
Building an army of robots
kneath
302
43k
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 ΦʔσΟΦͷεϨου͕ϩοΫͯ͠͠·Θͳ͍Α͏ʹؾΛ͚Δ