播放样本时似乎无法更改TickRate,当使用's'或'd'键播放样本时,两者都以相同的速率播放,尝试使其在播放不同的键时播放录制声音的不同音高,如某种钢琴键盘。这可能是一个愚蠢的错误,但任何帮助将不胜感激谢谢。 :)
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.signals.*;
import ddf.minim.ugens.*;
import ddf.minim.spi.*;
Minim minim;
AudioOutput out;
AudioSample sample1;
AudioInput in;
AudioRecorder recorder;
boolean recorded;
FilePlayer player;
TickRate rateControl;
float rate =2;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 512);
recorder = minim.createRecorder(in, "myrecording.wav");
rateControl = new TickRate(1.f);
out = minim.getLineOut(Minim.STEREO, 512);
player = new FilePlayer(minim.loadFileStream("myrecording.wav") );
player.patch(rateControl).patch(out);
}
void draw()
{
}
void keyReleased()
{
if ( !recorded && key == 'r' )
{
if ( recorder.isRecording() )
{
recorder.endRecord();
recorded = true;
}
else
{
recorder.beginRecord();
}
}
if ( recorded && key == 'q' )
{
player = new FilePlayer( recorder.save() );
sample1 = minim.loadSample( "myrecording.wav" , 512 );
if ( sample1 == null ) println("didn't get sample");
}
}
void keyPressed()
{
if ( key == 's' )
{
sample1.trigger();
}
else if ( key == 'd' )
{
rateControl.value.setLastValue(rate);
sample1.trigger();
}
}