setBuffer()函數是p5.js庫中的內置函數。該函數用於用當前緩衝區複位緩衝區。
用法:
setBuffer( buf )
注意:僅當index.html文件的開頭部分中包含聲音庫時,所有與聲音相關的函數才起作用。
參數:該函數接受上述和以下描述的單個參數:
- buf:此參數包含一個數組,該數組將由2個Float32 Arrays創建立體聲源。 1將創建一個單聲道源。
下麵的示例說明了JavaScript中的p5.setBuffer()函數:
例:
var sound;
function preload() {
// Initialize sound
sound = loadSound("pfivesound.mp3");
}
function setup() {
// reversebyffering the source
sound.setBuffer(1);
// Playing the preloaded sound
sound.play();
}
在線編輯: https://editor.p5js.org/
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
支持的瀏覽器:下麵列出了p5.js setBuffer()函數支持的瀏覽器:
- 穀歌瀏覽器
- IE瀏覽器
- Firefox
- Safari
- Opera
相關用法
- p5.js hex()用法及代碼示例
- PHP Ds\Set contains()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP sin( )用法及代碼示例
- d3.js d3.max()用法及代碼示例
- CSS url()用法及代碼示例
- PHP abs()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- PHP pow( )用法及代碼示例
- PHP ord()用法及代碼示例
- p5.js tan()用法及代碼示例
注:本文由純淨天空篩選整理自skyridetim大神的英文原創作品 p5.js | setBuffer() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。