Note that there are some explanatory texts on larger screens.

plurals
  1. POJSyn, siren sound using oscillator fed/controlled/inputInto/daisy-chainedTo by another oscillator and a constant...and generating more than one sound
    primarykey
    data
    text
    <p>I have been trying to follow the example here, but it is not working, and I have not been able to find any other sources: [ <a href="http://www.softsynth.com/jsyn/tutorial/osc_control.php" rel="nofollow">http://www.softsynth.com/jsyn/tutorial/osc_control.php</a> ][1]</p> <p>As far as I can tell, I have followed this sample code snippet exactly (except that I found out that <code>AddUnit</code> changed to <code>Add</code> sometime since that webpage was updated):</p> <blockquote> <p>[...]make the frequency to waver slightly about a central frequency that is in a more useful range. We can do this by using an AddUnit to add the output of an oscillator to a constant value that we can set. We can also reduce the amplitude of the first oscillator to be within a smaller range.</p> </blockquote> <pre><code>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 </code></pre> <blockquote> <p>Thus the frequency of sineOsc2 will be sineOsc1.output plus inputB.</p> </blockquote> <p>Can anybody see what is wrong with my code (below)? I already have a simple oscillator sound working. I just can't hear this second, more complicated sound, which is supposed to be siren-like.</p> <p>It may be a problem with my coding of the siren sound, or it may just be a problem with my coding of generating two sounds. (Are 2 <code>Synthesizers</code> required? I have tried it with 1 and 2 <code>Synthesizers</code>.) (Are 2 lineOuts required? Other web sources say "no".)</p> <p>Here is my code with 2 <code>synthesizers</code> and 1 output:</p> <p>(Comments in quotes are from other sample code. I only understand a little of what those comments are getting at.)</p> <pre><code>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(); </code></pre> <p>How many people out there know and use <code>JSyn</code>? How about <code>meta-oscillators</code>?</p> <p>If you have ever connected different <code>JSyn</code> parts together, or even just got it to output more than one sound at once, you know more than I do...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload