>這篇文章探討了幾個利用HTML5音頻API和HTML5音頻元素的JavaScript庫,並提供了各種在網絡遊戲和應用程序中進行聲音操作的方法。 圖書館展示了各種特徵和復雜性,滿足了不同的項目需求。
關鍵要點:
// after including the webaudiox library var context = new AudioContext() // Create lineOut var lineOut = new WebAudiox.LineOut(context) // load a sound and play it immediately WebAudiox.loadBuffer(context, 'sound.wav', function(buffer){ // init AudioBufferSourceNode var source = context.createBufferSource(); source.buffer = buffer source.connect(lineOut.destination) // start the sound now source.start(0); });
analyser2canvas
howler.js
多格式支持
>多軌播放
// after including the webaudiox library var context = new AudioContext() // Create lineOut var lineOut = new WebAudiox.LineOut(context) // load a sound and play it immediately WebAudiox.loadBuffer(context, 'sound.wav', function(buffer){ // init AudioBufferSourceNode var source = context.createBufferSource(); source.buffer = buffer source.connect(lineOut.destination) // start the sound now source.start(0); });
> pedalboard.js專注於創建音頻效果,尤其是使用Web Audio API來創建吉他。 其面向對象的結構簡化了效應鏈的創建。 踏板.io示例其功能。
>示例:
var sound = new Howl({ urls: ['sounds.mp3', 'sounds.ogg'], sprite: { blast: [0, 1000], laser: [2000, 3000], winner: [4000, 7500] } }); // shoot the laser! sound.play('laser');
雖然可以超越其核心功能,但可以使用專門的創意應用程序。
>// initialize the stage and get the context var stage = new pb.Stage(); var ctx = stage.getContext(); // initialize the board and pedals var board = new pb.Board(ctx); var od = new pb.stomp.Overdrive(ctx); var reverb = new pb.stomp.Reverb(ctx); var vol = new pb.stomp.Volume(ctx); // add pedals to board board.addPedals([od, reverb]); board.addPedalsAt(1, vol); // tweak pedal settings od.setDrive(0.7); od.setLevel(0.7); reverb.setLevel(0.3); vol.setLevel(0.2); // set the board on stage and start playing! stage.setBoard(board);
>功能包括平移,3D平板,過濾器,混響和麥克風輸入。 但是,它目前缺乏firefox的支持。
fifer
它的主要優勢是通過Flash後備。
常見問題(常見問題解答):(省略了此部分,因為它包含與重寫/釋義任務無關的信息,並增加了長度。如果需要,可以重新添加。) 以上是5個庫和API,用於操縱HTML5音頻的詳細內容。更多資訊請關注PHP中文網其他相關文章!var piano = new Wad({
source : 'square',
env : {
attack : .01,
decay : .005,
sustain : .2,
hold : .015,
release : .3
},
filter : {
type : 'lowpass',
frequency : 1200,
q : 8.5,
env : {
attack : .2,
frequency : 600
}
}
})
piano.play({ pitch : 'C5' })
piano.play({ pitch : 'Eb5', filter : { q : 15 } })
piano.play({ pitch : 'F5', env : { release : .2 } })