processing.orgのサンプルファイル(Win8)を使用して、「マイクから録音」を取得してサウンドを再生しました。私は一度に10〜30秒を記録するだけです。しかし、現在、既存の録音を閉じて新しい録音を録音する方法はありません。
私はすでにあらゆる方法を試みました。私は別のキーを押すことができるようにしたい、 "r"をもう一度押して、語彙の練習などのようにもう数秒を記録したい。
私はcompartmental.net/minimの最小サンプルコードを使用しています。公式ドキュメントにはbeginRecord/endRecordのリストがありますが、既存の録音を閉じて別の録音を開始する方法はありません。 recorder.closeとしてはそのようなものはありません()または.RESET /再起動などマイクからの録音は終了しましたが、録音を終了することはできません
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
// for recording
AudioInput in;
AudioRecorder recorder;
boolean recorded;
// for playing back
AudioOutput out;
FilePlayer player;
void setup()
{ size(512, 200, P3D);
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 2048);
// create an AudioRecorder
recorder = minim.createRecorder(in, "myrecording.wav");
// get an output
out = minim.getLineOut(Minim.STEREO);
textFont(createFont("Arial", 24));
}
void draw()
{ background(255,240,128);
stroke(32);
if (recorder.isRecording())
{ text("Now recording, press the r key to stop recording.", 5, 15); }
else if (!recorded)
{ text("Press the R key to start recording.", 5, 15); }
else
{ text("Press the S key to save the recording to disk and play it back in the sketch.", 5, 15); }
}
//end draw
void keyReleased()
{
if (!recorded && key == 'r')
{ // to indicate that you want to start or stop capturing audio data,
if (recorder.isRecording() )
{ recorder.endRecord();
recorded = true; }
else
{ recorder.beginRecord(); }
}
if (recorded && key == 's')
{ // now write it to file
// case of buffered recording, will freeze sketch for a bit if buffer is large
// case of streamed recording, will not freeze all that is being done
// all that is being done is closing the file.
// save returns the recorded audio in an AudioRecordingStream,
// which we can then play with a FilePlayer
if (player != null)
{ player.unpatch(out);
player.close(); }
player = new FilePlayer(recorder.save());
player.patch(out);
player.play();
}
// my addition — this works for play-again
if (recorded && key == 'p')
{ player.rewind();
player.play();
}
私はミニムをクローズして再起動しますが、それは文句を言うてみましたがそうのような「ローカル変数xxxが使用されていません」 : 動作しません。
if (key == 'x')
{ minim.stop();
minim = new Minim(this);
AudioInput in;
AudioRecorder recorder;
AudioOutput out;
FilePlayer player; }
私たち自身を実行するためにコピー&ペーストできる小さなサンプルプログラムに問題を示す[mcve]を投稿してください。 –