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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
hiro-tan
November 25, 2016
Technology
0
180
Getting Started Web Audio API
Web Audio APIを使って音を出して、簡単なピアノ作ってみるところまで。
Meguro.es #5にて発表した内容です。
hiro-tan
November 25, 2016
Tweet
Share
More Decks by hiro-tan
See All by hiro-tan
party-night-with-webaudio-api
hirotan
0
250
音色と波形の話
hirotan
0
180
chiptune by web audio api
hirotan
0
160
Web Audio API でお手軽10バンドイコライザー
hirotan
1
680
Other Decks in Technology
See All in Technology
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
430
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
880
Context Engineeringの取り組み
nutslove
0
330
20260204_Midosuji_Tech
takuyay0ne
1
140
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
160
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.3k
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
350
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.3k
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
220
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Designing Powerful Visuals for Engaging Learning
tmiket
0
230
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
430
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
57
[SF Ruby Conf 2025] Rails X
palkan
1
740
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
120
The Limits of Empathy - UXLibs8
cassininazir
1
210
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
49
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
110
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)