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
Getting Started Web Audio API
Search
hiro-tan
November 25, 2016
Technology
190
0
Share
Getting Started Web Audio API
Web Audio APIを使って音を出して、簡単なピアノ作ってみるところまで。
Meguro.es #5にて発表した内容です。
hiro-tan
November 25, 2016
More Decks by hiro-tan
See All by hiro-tan
party-night-with-webaudio-api
hirotan
0
250
音色と波形の話
hirotan
0
190
chiptune by web audio api
hirotan
0
170
Web Audio API でお手軽10バンドイコライザー
hirotan
1
700
Other Decks in Technology
See All in Technology
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
230
BigQuery の Cross-cloud Lakehouse への歩み
phaya72
2
550
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
210
Databricks における 生成AIガバナンスの実践
taka_aki
1
310
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
500
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
50k
生成 AI × MCP で切り拓く次世代 SRE!自律型運用への挑戦と開発者体験の進化
_awache
0
150
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
250
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.8k
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
18
9.9k
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
2.7k
[モダンアプリ勉強会]今更聞けないGit/GitHub入門
tsukuboshi
0
260
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6k
Embracing the Ebb and Flow
colly
88
5.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Crafting Experiences
bethany
1
170
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The agentic SEO stack - context over prompts
schlessera
0
790
Are puppies a ranking factor?
jonoalderson
1
3.5k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Transcript
Getting Started Web Audio API 廣田 洋平 @Drecom
We are hiring!
自己紹介 廣田 洋平 (Yohei Hirota) ドリコム16 新卒入社 「 ちょこっとファー ム」
サー バー サイド
アジェンダ Web Audio API でピアノを作る Web Audio API で音を鳴らす テンポを変えて音を鳴らす
音の高さを変える UI コンポー ネントから音を鳴らす DEMO: https://hiro-tan.github.io/
Web Audio API で音を鳴らす DEMO: https://hiro-tan.github.io/osc.html // AudioContext のインスタンス生成 window.AudioContext
= window.AudioContext || window.webkitAudioContext; var audioContext = new AudioContext(); // oscillator の設定 oscillator = audioContext.createOscillator(); oscillator.connect(audioContext.destination); oscillator.start(0);
テンポについて DEMO: https://hiro-tan.github.io/tempo.html ♩=120 1 分間に4 分音符が120 個 4 分音符1
個当たりの時間 = 0.5 秒 tempo = 120; crotchet = 60 / 120; // 4 分音符の長さ semibreve = crotchet * 4; // 全音符の長さ quaver = crotchet / 2; // 8 分音符の長さ // 8 分音符を鳴らす oscillator.start(0); oscillator.stop(audioContext.currentTime + quaver);
音の高さを変える DEMO: https://hiro-tan.github.io/freq.html 音の基準 = 440Hz = ピアノの" ラ" //
整数を周波数に置き換える公式 function CaluculateFrequency(value) { return 440 * Math.pow(2, value / 12); } value = 0 ピアノの" ラ" value = -9 真ん中の" ド" value = 3 1 オクター ブ上の" ド"
音の高さを変える DEMO: https://hiro-tan.github.io/freq.html oscillator = audioContext.createOscillator(); oscillator.frequency.value = 440; //
default oscillator.connect(audioContext.destination); oscillator.start(0); oscillator.frequency.value = 261.63; // 再生中にも変更できる
Web Audio API でピアノを作る UI コンポー ネント: https://github.com/WebMusicDevelopersJP/webaud io-controls <webaudio-keyboard
keys="25"></webaudio-keyboard>
Web Audio API でピアノを作る DEMO: https://hiro-tan.github.io/piano.html keyboard.addEventListener('change', function(e) { if(e.note[0])
{ // 鍵盤が押された時の処理 console.log(e.note); // [1, 60] } else { // 鍵盤から離れた時の処理 console.log(e.note); // [0, 60] } }); 注意点 oscillator は一度stop すると削除される使い捨て仕様 和音などを表現するには鍵盤の数だけ変数が必要
今日話さなかったこと ボリュー ムの変更 外部音声ファイルの読み込み フィルタ
Web Audio API のための勉強会 WebAudio.tokyo #1 @Drecom 9/6(Tue)