美文网首页
Processing声音交互-声音可视化及处理

Processing声音交互-声音可视化及处理

作者: 思求彼得赵 | 来源:发表于2022-04-18 00:08 被阅读0次

2022-04-17
1.这个例子接收声音输入,然后可视化之。
2.用到极坐标,不断转动画圆。
如果不喊叫的话,外界没有影响。基本是圆形。
3,这里用了音量。后续练习一下频率分析。


image.png

但喊叫的话,影响就大起来了。


image.png
3.这个要用到声音处理的函数库。所以需要在最前边导入函数库。具体用法应该查阅函数库的方法说明。
import ddf.minim.*;
Minim minim;
AudioInput in;  
void setup() {
  size(800, 600, P2D);
  background(0);
  stroke(255);
  minim = new Minim(this);
  in = minim.getLineIn();
}

void draw() {
  float a = 0;
  float angle = (2*PI) /100;
  int step = in.bufferSize() / 100;
  for (int i=0; i < in.bufferSize()-step; i+=step) {
    float x1 = width/2 + cos(a) * (1000 * in.mix.get(i) + 100);
    float y1 = height/2 + sin(a) * (1000 * in.mix.get(i) + 100);
    float x2 = width/2 + cos(a + angle) * (1000 * in.mix.get(i+step) + 100);
    float y2 = height/2 + sin(a + angle) * (1000 * in.mix.get(i+step) + 100);
    stroke(random(255), 100,100);
    line(x1, y1, x2, y2);
    a += angle;
  }
}

如果加上渐变的效果,应该更好看。


  • 3.体验回声效果。当你喊叫时,计算机会有你的回声,仿佛到了山里或某个空阔的空间的感觉。试试吧!
import processing.sound.*;

AudioIn in;
Reverb reverb;

void setup() {
  size(640,360);
  background(255);
        
  // create the input stream
  in = new AudioIn(this, 0);
    
  // create a reverb effect
  reverb = new Reverb(this);
    
  // start the input stream
  in.play();

  // Patch the reverb
  reverb.process(in);
  reverb.room(0.5);
}      

void draw() {
}

相关文章

网友评论

      本文标题:Processing声音交互-声音可视化及处理

      本文链接:https://www.haomeiwen.com/subject/orwlertx.html