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
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
250
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
コーディングエージェントでM5Stack系の開発を少し試した時の話 / M5 Japan Tour 2026 Autumn 東京
you
PRO
0
150
WAF 運用改善の承認サイクル/SRE_BizReach_MIXI_1
visional_engineering_and_design
2
420
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1.1k
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/6 - 2026/8
oracle4engineer
PRO
0
150
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
180
生成AIのテナント制御とシャドーMCP対策 | AIを"止めずに"、情報を守る
yukun
0
150
家のリアーキテクト・リファクタリング
suguruooki
0
110
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
260
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
4
390
クロスボーダーM&AのValue Upを支えるプロダクト開発。日米チームのハブになったプロダクトエンジニアの実践 / Product Engineering Conference 2026
genda
0
110
DEFCON_CHV_CTF_Write-up.pdf
bata_24
0
140
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
1
1.4k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Curious Case for Waylosing
cassininazir
1
500
Bash Introduction
62gerente
615
220k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
350
Ruling the World: When Life Gets Gamed
codingconduct
0
330
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
210
Raft: Consensus for Rubyists
vanstee
141
7.7k
GitHub's CSS Performance
jonrohan
1033
470k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
690
Abbi's Birthday
coloredviolet
3
9.9k
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/