我正在尝试使用Processing和Minim Library将wav文件加载到FilePlayer中(稍后我想在其上修补Delay)。但是,我给出的wav文件播放速度太快,至少是它应该达到的速度的两倍,并且音调非常高。如果我在VLC媒体播放器或WMP中播放,该文件听起来应该是这样的。比特率为20kbps时长5秒,但打印出的代码长度为2299ms。
代码:
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.spi.*;
Minim minim;
AudioOutput out;
FilePlayer filePlayer;
Delay myDelay;
void setup() {
size(100, 100);
minim = new Minim(this);
AudioRecordingStream myFile = minim.loadFileStream( "audio1.wav", 1024, true);
filePlayer = new FilePlayer( myFile );
filePlayer.play();
filePlayer.loop();
out = minim.getLineOut();
// patch the file player to the output
filePlayer.patch(out);
println(filePlayer.length()); //This prints out 2299
}
void draw()
{
background( 0 );
}
答案 0 :(得分:0)
请尝试使用音频文件:
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
FilePlayer filePlayer;
AudioOutput out;
Delay delay;
void setup(){
size(640, 240);
minim = new Minim(this);
AudioRecordingStream file = minim.loadFileStream( "marcus_kellis_theme.mp3",1024,true);
filePlayer = new FilePlayer( file );
filePlayer.loop(1);//play forever
delay = new Delay( 0.4, .9, true, true );
out = minim.getLineOut();
filePlayer.patch(delay).patch(out);
}
void mousePressed(){
delay.setDelAmp(0);
}
void mouseReleased(){
delay.setDelAmp(.9);
}
void draw(){
background( 0 );
stroke( 255 );
beginShape(LINES);
for( int i = 0; i < out.bufferSize() - 1; i++ ){
// find the x position of each buffer value
float x1 = map( i, 0, out.bufferSize(), 0, width );
float x2 = map( i+1, 0, out.bufferSize(), 0, width );
// draw a line from one buffer position to the next for both channels
vertex( x1, 50 + out.left.get(i)*50);vertex(x2, 50 + out.left.get(i+1)*50);
vertex( x1, 150 + out.right.get(i)*50);vertex( x2, 150 + out.right.get(i+1)*50);
}
endShape();
}
如果没有正确播放,请尝试在Audacity中打开它并将其导出为16位签名的wav。