channels()函數是p5.js庫中的內置函數。此函數用於顯示當時正在網絡上播放的頻道數。現在有六種類型的聲音通道,如下所述:
- 單聲道
- Sterio
- 準立體聲
- 4.1環繞聲
- 5.1環繞聲
- 7.1環繞聲
用法:
channels()
注意:僅當index.html文件的開頭部分中包含聲音庫時,所有與聲音相關的函數才起作用。
參數:該函數不接受任何參數。
下麵的示例說明了JavaScript中的p5.js channels()函數:示例:
var sound;  
var chnnl; 
      
function preload() {  
      
    // Initialize sound  
    sound = loadSound("pfivesound.mp3");  
}  
      
function setup() {  
      
    // Playing the preloaded sound  
    sound.play(); 
       
    // checking channels of the audio 
    chnnl = sound.channels(); 
    console.log(chnnl); 
   
} 支持的瀏覽器:下麵列出了p5.js channels()函數支持的瀏覽器:
- 穀歌瀏覽器
- IE瀏覽器
- 火狐瀏覽器
- 蘋果瀏覽器
- Opera
相關用法
- p5.js day()用法及代碼示例
- CSS url()用法及代碼示例
- CSS var()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js value()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- p5.js pow()用法及代碼示例
- PHP next()用法及代碼示例
- p5.js hue()用法及代碼示例
- PHP pow( )用法及代碼示例
- d3.js d3.set.add()用法及代碼示例
注:本文由純淨天空篩選整理自skyridetim大神的英文原創作品 p5.js | channels() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
