私はここの例に従おうとしましたが、うまくいきませんでした。他のソースを見つけることができませんでした: [ http://www.softsynth.com/jsyn/tutorial/osc_control.php ][1]
私が知る限り、私はこのサンプル コード スニペットに正確に従いました (ただし、その Web ページが更新されてから、いつかAddUnit
変更されたことがわかりました)。Add
[...]周波数を、より有用な範囲にある中心周波数についてわずかに揺らします。これを行うには、AddUnit を使用してオシレータの出力を設定可能な定数値に追加します。また、最初のオシレーターの振幅をより小さな範囲内に減らすこともできます。
AddUnit freqAdder = new AddUnit();
sineOsc1.output.connect( freqAdder.inputA ); // pass through adder
freqAdder.output.connect( sineOsc2.frequency ); // control second oscillator freq
freqAdder.inputB.set( 500.0 ); // add constant that will center us at 500 Hz
sineOsc1.amplitude.set( 100.0 ); // reduce offset to +/- 100 Hz
したがって、sineOsc2 の周波数は、sineOsc1.output に inputB を加えたものになります。
私のコード(以下)の何が問題なのか誰にもわかりますか?私はすでにシンプルなオシレーターサウンドを動作させています。サイレンに似ているはずの、この 2 番目のより複雑な音が聞こえません。
サイレン音のコーディングの問題かもしれませんし、2 つの音を生成するコーディングの問題かもしれません。(2 つSynthesizers
必要ですか? 1 と 2 で試しましたSynthesizers
。) (2 つの lineOuts は必要ですか? 他の Web ソースは「いいえ」と言っています。)
synthesizers
2と 1 の出力を持つ私のコードは次のとおりです。
(引用符内のコメントは他のサンプル コードからのものです。私はそれらのコメントが何を求めているのかを少ししか理解していません。)
import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.Add;
import com.jsyn.unitgen.LineOut;
import com.jsyn.unitgen.SineOscillator;
[...]
com.jsyn.Synthesizer synthPCMSonification = JSyn.createSynthesizer();
com.jsyn.Synthesizer synthPCMAlarm = JSyn.createSynthesizer();
// "an instance of Synthesizer"
com.jsyn.unitgen.SineOscillator oscData = new SineOscillator();
SineOscillator oscAlarmWaverEnvelope = new SineOscillator();
SineOscillator oscAlarmComplete = new SineOscillator();
// "a unit"
com.jsyn.unitgen.LineOut oscsLineOut = new LineOut();
// "a unit"
[...]
// "start synthesis engine"
synthPCMSonification.start();
synthPCMAlarm.start();
// "build unit generators"
synthPCMSonification.add(oscData);
//synthPCM.add(oscAlarmWaverEnvelope); //TODO: Figure out if need line
synthPCMAlarm.add(oscAlarmComplete);
synthPCMSonification.add(oscsLineOut);
synthPCMAlarm.add(oscsLineOut);
oscData.frequency.set(LOWEST_FREQUENCY_C);
oscData.amplitude.set(volSonification);
//create a frequency adder for a siren-like alarm
com.jsyn.unitgen.Add oscAlarmFreqAdder = new Add(); //used to be AddUnit
//set the alarm centre frequency
alarmCentreFreq = (LOWEST_FREQUENCY_C
* Math.pow(2, OCTAVES_SPANNED_C + 1));
//This formula centres the alarm one octave
//above the threshold's sonification freqency
alarmWaverFreq = alarmCentreFreq / 10;
//This sets the waver at one tenth of the centre freq
//Unfortunately, the waver appears to need to be the
//same amount above and below the centre
//(linear, vice perceptually-linear (exponential))
System.out.println(alarmCentreFreq + "-Hz alarm centre frequency");
oscAlarmFreqAdder.inputB.set(alarmCentreFreq);
//set the alarm waver envelope
//(alarm will range between centre-waver and centre+waver)
oscAlarmWaverEnvelope.frequency.set(alarmCentreFreq / 10);
//"pass through adder" (??)
oscAlarmWaverEnvelope.output.connect(oscAlarmFreqAdder.inputA);
//(entered this with by starting to type, then hitting [Ctrl]+[Space]!)
//"control the 2nd oscillator frequency" (?)
oscAlarmFreqAdder.output.connect(oscAlarmComplete.frequency);
//set alarm volume
oscAlarmComplete.amplitude.set(volAlarm);
// "connect unit generators"
// connect oscillator to both channels of stereo player
oscAlarmComplete.output.connect(0, oscsLineOut.input, 0);
oscAlarmComplete.output.connect(0, oscsLineOut.input, 1);
// "startUnitGenerators"
// "start execution of units. JSyn 'pulls' data so the only unit
// you have to start() is the last one, in this case our LineOut"
oscsLineOut.start();
を知っていて使っている人はどれくらいいるJSyn
でしょうか?どうmeta-oscillators
ですか?
さまざまなパーツを接続JSyn
したり、一度に複数のサウンドを出力したりしたことがあるなら、私よりも多くのことを知っているでしょう...