>这篇文章探讨了几个利用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 } })