Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
chiptune by web audio api
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
hiro-tan
October 13, 2016
Technology
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
chiptune by web audio api
hiro-tan
October 13, 2016
More Decks by hiro-tan
See All by hiro-tan
party-night-with-webaudio-api
hirotan
0
260
Getting Started Web Audio API
hirotan
0
190
音色と波形の話
hirotan
0
190
Web Audio API でお手軽10バンドイコライザー
hirotan
1
710
Other Decks in Technology
See All in Technology
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
5
5.4k
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
自作バイナリを動かす「入口」8選
puhitaku
1
1.2k
ハードウェアコンペでもAI駆動開発が進んでいる話
iotengineer22
1
630
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
120
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
6
2.3k
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
160
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
180
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
4
4.2k
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
0
640
メルペイ 会計システム概要と歴史
mewuto
0
200
MCPゲートウェイを作って運用してわかったこと — Agent時代の権限管理の現在地
mtpooh
10
3.2k
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
A Tale of Four Properties
chriscoyier
163
24k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Scaling GitHub
holman
464
140k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
870
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Building Applications with DynamoDB
mza
96
7.2k
Design in an AI World
tapps
1
350
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
Transcript
Web Audio API を使って FC 音源を再現してみる 廣田洋平 @DRECOM
自己紹介 廣田洋平 a.k.a ひろたん ドリコム16 新卒入社 「 ちょこっとファー ム」 サー
バー サイド 好きなジャンルはチップチュー ンとハピコア Web Audio の人と呼ばれるのを目指して修行中
Join us! #2 11/8(tue) @Drecom
Join us! Web Audio API 初心者向けハンズオン 11/6(sun) @ 渋谷ヒカリエ
アジェンダ Web Audio API を使った音作り 波形を選択して音色を変える エンベロー プジェネレー ター を実装する
スイー プを実装する
波形を選択して音色を変える サイン波、 矩形波、 のこぎり波、 三角波の4 種 var audioContext = new
AudioContext(); var oscillator = audioContext.createOscillator(); oscillator.type = "sine" //square, sawtooth, triangle oscillator.connect(audioContext.desination); oscillator.start(0); 簡単に音色を変えられる 4 種以外の波形は選べないほか、4 種の波形も デフォルトから変化させることはできない
ScriptProcessorNode の利用 JavaScript で音声デー タを編集できるノー ド var processor = audioContext.createScriptProcessor(1024);
oscillator.connect(processor); // for iOS processor.onaudioprocess = function(event) { var buffer1 = event.outputBuffer.getChannelData(0); var buffer2 = event.outputBuffer.getChannelData(1); for(var i = 0; i < 1024; i++) { buffer[0] = buffer[1] = (Math.random() - 0.5) * 2; } }); processor.connect(audioContext.destination); onaudioprocess はdestination に接続すると発生
ScriptProceossorNode は廃止予定 代わりにAudioWorker が提案されたが… 実装されているブラウザはない 9 月の初めに仕様から削除 AudioWorklet に置き換えられる予定 しばらくはScriptProcessorNode
を使いましょう
エンベロー プジェネレー ター を実装 エンベロー プジェネレー ター とは? 音量の時間変化を作り出す機能 Attack
, Decay , Sutain , Release の4 つを設定 Attack : 音が鳴り始めかてら最大音量になるまで Decay : 最大音量からSustain までの減衰 Sustain : 音がなっているときの音量レベル Release : 音が鳴り止むまでの減衰 Duration : 音がなっている時間
エンベロー プジェネレー ター を実装 oscillator にgain ノー ドを接続 gain ノー
ドのパラメー ター を時間変化させる setValueAtTime(value, startTime) : startTime にパラメー ター をvalue に設定 linearRampToValueAtTime(value, endTime) : endTime にパラメー ター がvalue になるよう パラメー ター を線形変化 setTargetAtTime(target, startTime, timeConstant) : startTime からtimeConstant 分時間をかけて パラメー ター をtarget に変化
エンベロー プジェネレー ター を実装
エンベロー プジェネレー ター を実装 var t0 = audioContext.currentTime(); var t1
= t0 + attack; var t3 = t0 + duration - release; var envelope = audioContext.createGain(); oscillator.connect(envelope); envelope.connect(audioContext.destination); oscillator.start(t0); envelope.gain.setValueAtTime(0, t0); envelope.gain.linearRampToValueAtTime(1.0, t1); envelope.gain.setTargetAtTime(sustain, t1, decay); envelope.gain.setTargetAtTime(0, t3, release); oscillator.stop(t0 + duration);
スイー プを実装 スイー プとは? 周波数を一定速度で変化させること SweepSwitch : off , positive
, negative の3 種 SweepTime : 周波数を変化させる時間 バスドラムの音を再現するには 急激に周波数を上下させる
スイー プを実装 周波数はoscillator ノー ドのパラメー ター で設定 var current =
oscillator.frequency.value; switch (sweepSwitch) { case positive: oscillator.frequency.setValueAtTime(current * 1.8, sweepTime); break; case negative: oscillator.frequency.setValueAtTime(current * 0.2, sweepTime); break; default: }
参考資料 チップチュー ンを作ってみよう! ドラム音色エディット編 -- くりおぺ http://www.tsurishi.info/chiptune-neiro-edit-drum/ WEB SOUNDER http://curtaincall.weblike.jp/portfolio-web-sounder/