Webで音楽を奏でる
by
nishaya
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
ϒϥβͰԻָΛͰΔ ɹ SpeeeKaigi 2017/08/25 ೋࣾ୩ ߉༎ @nishaya 1
Slide 2
Slide 2 text
ࣗݾհ • ೋࣾ୩ ߉༎ • GitHub: @nishaya • WebΞϓϦέʔγϣϯΤϯδχΞ • (ג) Speee ϓϩδΣΫτਪਐࣨ • React2016ʙ 2
Slide 3
Slide 3 text
લճ·Ͱͷ͋Β͢͡ React/ReduxͰγϯηαΠβʔΛ࡞ͬͨ2 • ԻΛग़͍ͨ͠ͱ͍͏ڧ͍Ϟνϕʔγ ϣϯ • React/Redux৯Θͣݏ͍Λࠀ͢Δ • ࣄલʹ͓͍ͬͯͨ͜ͱͰϓϩδΣ ΫτͰͷ໎͍͕ܰݮ͞Εͨ 2 ReactͰγϯηαΠβʔΛ࡞ͬͨ - Speee DEVELOPER BLOG http://tech.speee.jp/entry/2017/04/06/100000 3
Slide 4
Slide 4 text
ղܾ͍ͨ͠՝ • ָث͕͚ͳ͍ • Իָཧ͕Θ͔Βͳ͍ • ͍Ζ͍ΖͳԻΛ͍͍ͨ ...͚ͲɺԻָΛͰ͍ͨ 4
Slide 5
Slide 5 text
Reaktion Multi Track Web Sequencer 5
Slide 6
Slide 6 text
ָث͕͚ͳ͍ • ָثΛ࡞͍͍͕ͬͨɺ͚ͳ͍ͷͰԻָ͕Ͱ͖ͳ͔ͬͨ • ϒϥβʹࣗಈԋͤ͞Ε͍͍ • ҙͷλΠϛϯάͰԻΛ໐Β͢Έ͕ඞཁ 6
Slide 7
Slide 7 text
DEMO #1 7
Slide 8
Slide 8 text
ҙͷλΠϛϯάͰԻΛ໐Β͢ • Ұ൪࠷ॳʹࢥ͍ු͔Ϳͷ setInterval() setTimeout() Ͱϧʔϓ͢Δํ๏ • ਫ਼͕Γͳ͍ • OscillatorNode.start() AudioBufferSourceNode.start() ʹɺൃԻλΠϛϯάΛε έδϡʔϦϯά͢Δ 8
Slide 9
Slide 9 text
λΠϛϯά੍ޚͷ • ൃԻλΠϛϯάͷσʔλʮstep = 16Իූ1ͭʯͱ͍͏ ୯ҐͰཧ 9
Slide 10
Slide 10 text
λΠϛϯά੍ޚͷ • ϧʔϓ͝ͱʹɺݱࡏͷ࣌ࠁ͔Β࣍ʹstepΛ໐Β͢·ͰͷΦϑ ηοτΛࢉग़ t1 • ֤AudioNodeͷ start() ʹઈର࣌ࠁΛ͢ඞཁ͕͋Δͨ Ίɺࢉग़ͨ͠Φϑηοτʹ AudioContext.currentTime Λ ͨ͠ͷΛൃԻ։࢝λΠϛϯάͱͯ͠εέδϡʔϦϯά͢ Δ t1 ϧʔϓࣗମ setTimeout() Ͱ੍ޚ 10
Slide 11
Slide 11 text
✅ λΠϛϯά੍ޚ 11
Slide 12
Slide 12 text
Իָཧ͕Θ͔Βͳ͍ • ԻָΛਅ໘ʹษڧͯ͜͠ͳ͔ͬͨͷͰͲ͏ͬͯۂΛߏ ͨ͠Β͍͍͔Θ͔Βͳ͍ • ੜ͞ΕͨύλʔϯΛΈ߹ΘͤΔํ๏ͳΒ͍͚Δ͔ 12
Slide 13
Slide 13 text
DEMO #2 13
Slide 14
Slide 14 text
มԽͷ࿈ʹΑͬͯύλʔϯΛੜ͢Δ • ύλʔϯΛड͚ͯɺ৽͍͠ύλʔϯΛฦ͢ύʔπΛfragment ͱͯ͠ఆٛ • fragmentʹ܁Γฦ͠ɺ֊ஈঢ়ͷมԽɺԻఔͷ্ԼͳͲ͞· ͟·ͳछྨΛ༻ҙ • fragmentΛचͭͳ͗ʹ͢Δ͜ͱͰɺ࠷ॳͷύλʔϯ͔Βେ ͖͘มԽͤ͞Δ͜ͱͰ͖Δ 14
Slide 15
Slide 15 text
fragmentͷதͰ͍ͬͯΔ͜ͱ transform(steps: Steps): Steps { const newList = steps.list.map((step) => { const note = step.note + this.state.transpose return { ...step, note } }) return { ...steps, list: newList } } 15
Slide 16
Slide 16 text
✅ ύλʔϯੜ 16
Slide 17
Slide 17 text
͍Ζ͍ΖͳԻΛ͍͍ͨ • γϯηαΠβʔΛ࡞ͬͨͱ͖oscillatorͱݺΕΔجຊܗ ͔Β͍Ζ͍ΖͳԻ৭Λ࡞͕ͬͨɺγϯηαΠζ͕͍͠Ի(ε τϦϯάͱ͔ɺͱ͔)͍͍ͨ • Իͨ͠Ի͕ͦͷͰ͑ͨΒָͦ͠͏ 17
Slide 18
Slide 18 text
DEMO #3 18
Slide 19
Slide 19 text
MediaDevices, MediaRecorderΛ͏ PCʹଓ͞ΕͨϚΠΫΧϝϥΛར༻͢ΔͨΊͷAPI • navigator.mediaDevices.getUserMedia({ audio: true, video: false }) Λݺͼग़͢ͱϚΠΫ༻ͷڐՄΛٻΊΔμ ΠΞϩά͕දࣔ͞ΕΔ 19
Slide 20
Slide 20 text
MediaDevices, MediaRecorderΛ͏ • Ϣʔβ͕ڐՄ͢ΔͱϚΠΫೖྗ͕ MediaStream ͱͯ͠ಘΒΕ ΔͷͰɺ new MediaRecorder(stream) ΛͬͯԻΛߦ͏ 20
Slide 21
Slide 21 text
Ի৭ͱͯ͠͏ͨΊͷ • ϊʔϚϥΠζͰԻྔΛ࠷దԽ • ಄ग़͠ͱϧʔϓ • Իఔมߋ(υͷ伴൫Λԡͨ͠ΒυͷԻ Ͱ໐ΔΑ͏ʹௐ͢Δ) 21
Slide 22
Slide 22 text
αϯϓϦϯάσʔλ(flowtype) // @flow export type Sample = { buffer: AudioBuffer, id: string, name: string, offset: number, loop: boolean, loopStart: number, loopEnd: number, transpose: number, } 22
Slide 23
Slide 23 text
✅ αϯϓϦϯά 23
Slide 24
Slide 24 text
https://reaktion.synthesizer.tokyo/ 3 3 FirebaseͰϗεςΟϯάͯ͠·͢ɻূ໌ॻઃఆͯ͘͠Εͯศར 24
Slide 25
Slide 25 text
·ͱΊ • ࠷ऴతʹѻ͏ཁૉ͕ଟ͘ͳ͕ͬͨɺReactͱFlowtypeʹॿ͚ ΒΕͨ • (Ұൠతʹ)ϒϥβͰΒͳ͍Α͏ͳࣄΛ͢Δͱɺීஈ ͍ͬͯͳ͍APIʹ৮ΕΒΕָ͍ͯ͠ • ͦ͜Ͱಘͨܦݧ͕ϓϩμΫτʹؐݩͰ͖ͨΒૉఢ 25