我正在使用处理程序和最小库,并尝试为实时音频输入创建3D实时可视化。
我已画出框,并且正在响应音频输入的反冲,军鼓和踩hat。我希望使这些盒子也能响应踢动而旋转。我怎样才能使这些盒子旋转?
if ( beat.isKick() ) kickSize = 200;
if ( beat.isSnare() ) snareSize = 250;
if ( beat.isHat() ) hatSize = 200;
translate ( width/4, height/4);
box(kickSize);
translate( - width/4, - height/4);
translate ( width/2, height/3);
sphere(snareSize);
translate( - width/2, - height/3);
translate ( 3*width/4, height/4);
box(hatSize);
translate( - 3*width/4, - height/4);
kickSize = constrain(kickSize * 0.95, 1, 32);
snareSize = constrain(snareSize * 0.95, 1, 32);
hatSize = constrain(hatSize * 0.95, 1, 32);
最佳答案
使用pushMatrix();popMatrix();
调用为每个对象隔离坐标系:
pushMatrix();
translate ( width/4, height/4);
box(kickSize);
popMatrix();
pushMatrix();
translate ( width/2, height/3);
sphere(snareSize);
popMatrix();
pushMatrix();
translate ( 3*width/4, height/4);
box(hatSize);
popMatrix();
查看2D transformations Processing tutorial了解更多详细信息。
同样的原则适用于3D
关于audio - 处理节拍检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42102119/