當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Processing AudioSample.resize()用法及代碼示例

Processing, 類AudioSample中的resize()用法介紹。

用法

  • .resize(frames)
  • .resize(frames, stereo)

參數

  • frames (int) 此音頻樣本所需的幀數
  • stereo (boolean) 是否將音頻樣本視為 2 聲道(立體聲)(默認值:false)

返回

  • void

說明

將音頻樣本的底層緩衝區調整為給定的幀數。調用此方法會分配一個全新的緩衝區,因此任何正在進行的播放都將停止,並且當前存儲在樣本中的所有數據都將丟失。

例子

import processing.sound.*;
AudioSample sample;

void setup() {
  size(640, 360);
  background(255);

  // Create a new audiosample
  sample = new AudioSample(this, 100000, 22050);

  // ... do something with the audiosample ...

  // Change to a 100.000 frames but in stereo
  file.resize(100000, true);
}      

void draw() {
}

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 AudioSample.resize()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。