Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webで音楽を奏でる

nishaya
September 04, 2017

 Webで音楽を奏でる

Reactでパターンシーケンサを作った話

nishaya

September 04, 2017
Tweet

More Decks by nishaya

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • ೋࣾ୩ ߉༎ • GitHub: @nishaya • WebΞϓϦέʔγϣϯΤϯδχΞ •

    (ג) Speee ϓϩδΣΫτਪਐࣨ • React͸2016೥຤ʙ 2
  2. ೚ҙͷλΠϛϯάͰԻΛ໐Β͢ • Ұ൪࠷ॳʹࢥ͍ු͔Ϳͷ͸ setInterval() ΍ setTimeout() Ͱϧʔϓ͢Δํ๏ • ਫ਼౓͕଍Γͳ͍ •

    OscillatorNode.start() ΍ AudioBufferSourceNode.start() ʹɺൃԻλΠϛϯάΛε έδϡʔϦϯά͢Δ 8
  3. λΠϛϯά੍ޚͷ࿩ • ϧʔϓ͝ͱʹɺݱࡏͷ࣌ࠁ͔Β࣍ʹstepΛ໐Β͢·ͰͷΦϑ ηοτΛࢉग़ t1 • ֤AudioNodeͷ start() ʹ͸ઈର࣌ࠁΛ౉͢ඞཁ͕͋Δͨ Ίɺࢉग़ͨ͠Φϑηοτʹ

    AudioContext.currentTime Λ ଍ͨ͠΋ͷΛൃԻ։࢝λΠϛϯάͱͯ͠εέδϡʔϦϯά͢ Δ t1 ϧʔϓࣗମ͸ setTimeout() Ͱ੍ޚ 10
  4. 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
  5. αϯϓϦϯάσʔλ(flowtype) // @flow export type Sample = { buffer: AudioBuffer,

    id: string, name: string, offset: number, loop: boolean, loopStart: number, loopEnd: number, transpose: number, } 22