は、誰もが自分のキーボードで正弦波を再生する方法を見つけ出すことができるはずです、そこから基本的な例である:
<script type="text/javascript">
//WARNING: VERY LOUD. TURN DOWN YOUR SPEAKERS BEFORE TESTING
// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// create Oscillator node
var oscillator = audioCtx.createOscillator();
oscillator.type = 'sine';
oscillator.frequency.value = 750; // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();
//uncomment for fun
// setInterval(changeFreq, 100);
//choose a random interval from a list of consonant ratios
var intervals = [1.0, 0.5, 0.3333, 1.5, 1.3333, 2.0, 2.25]
function changeFreq() {
var intervalIndex = ~~(Math.random() * intervals.length);
var noteFreq = oscillator.frequency.value * intervals[intervalIndex];
//because this is random, make an effort to keep it in comfortable frequency range.
if(noteFreq > 1600)
noteFreq *= 0.5;
else if(noteFreq < 250)
noteFreq *= 2;
oscillator.frequency.value = noteFreq;
}
</script>
<body>
<button onclick="changeFreq()">Change Places!</button>
</body>
う[本](https://developer.mozilla.org/en- US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API)が正しい方向を指していますか?おそらく – bvx89
。私もちょうどこれを見つけた:http://stackoverflow.com/questions/30019666/web-audio-synthesis-how-to-handle-changing-the-filter-cutoff-during-the-attack?rq=1 私は最終的にSO上の検索バーが質問ではなくタグ用であることが分かりました。 –
はい。これは正しい方向に私を指摘した。他の誰かが最初にしなければ、少しは投稿に答えます。 –