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
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
530
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
310
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
100
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
EventSourcingの理想と現実
wenas
6
2.3k
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
190
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
870
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Producing Creativity
orderedlist
PRO
341
39k
A Philosophy of Restraint
colly
203
16k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Speed Design
sergeychernyshev
24
610
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Writing Fast Ruby
sferik
627
61k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
A Tale of Four Properties
chriscoyier
156
23k
Scaling GitHub
holman
458
140k
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 ΦʔσΟΦͷεϨου͕ϩοΫͯ͠͠·Θͳ͍Α͏ʹؾΛ͚Δ