LoginSignup
4
4

More than 5 years have passed since last update.

ProcessingライブラリBeadsを使ってサウンドエフェクトをしてみた

Last updated at Posted at 2015-12-10

目的

Processingで音源を加工して再生したかったのですが、普段使っているminimではできなかったのでBeadsというライブラリを使ってみました。
Processingの公式ページで紹介されてたので多分便利だと思います。

導入

Beads公式でProcessingのライブラリをDL。
その後Processingのライブラリフォルダに追加してProcessingを再起動。

コード

processing.pde
import beads.*;
import org.jaudiolibs.beads.*;

AudioContext ac;
SamplePlayer sp;
Gain sampleGain;
Glide rateValue;
void setup(){
  size(500, 500);
  ac = new AudioContext();
  try{
    sp = new SamplePlayer(ac, new Sample(sketchPath("") +"sound1.wav"));
    rateValue = new Glide(ac, 0.8);
    sp.setRate(rateValue);
    rateValue = new Glide(ac, 1.5);
    sp.setPitch(rateValue);
    rateValue = new Glide(ac, 1.5);
    sp.setValue(0.5);
    sp.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);

    sp.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
    sp.start();
    sampleGain = new Gain(ac, 1);
    sampleGain.addInput(sp);
    ac.out.addInput(sampleGain);
    ac.start();
  }catch(Exception e){
    println("Error");
  }
}
void draw(){
}

解説

今回はsound1.wavという音を加工している。
sound1.wavはprocessing.pdeと同じ階層のディレクトリに配置している。

注意点としてはSamplePlayerの読み込み時にtry catchを書かなければならないこと。これを知らなくてかなり困ってた。

基本的な使い方はAudioContextを作成し、その中にSamplePlayerから作成したSampleGainを追加していく。
SamplePlayerの中でRate, Pitch, Value, Loopの値を編集することができる。

参考

公式API
processing beads library

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4