本文整理汇总了Java中com.jsyn.unitgen.SineOscillator类的典型用法代码示例。如果您正苦于以下问题:Java SineOscillator类的具体用法?Java SineOscillator怎么用?Java SineOscillator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SineOscillator类属于com.jsyn.unitgen包,在下文中一共展示了SineOscillator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void setUp() throws Exception {
// Create a synthesizer
synth = JSyn.createSynthesizer();
passThrough = new PassThrough();
// Prepare a SineOscillator (its amplitude will be modulated by the envelope)
sineOsc = new SineOscillator();
sineOsc.amplitude.set(1.0);
sineOsc.frequency.set(320.0);
// LineOut
out1 = new LineOut();
out2 = new LineOut();
out3 = new LineOut();
synth.add(out1);
synth.add(out2);
synth.add(out3);
synth.add(passThrough);
synth.add(sineOsc);
}
示例2: SimpleTest
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void SimpleTest() throws InterruptedException {
// Create a synthesizer
synth = JSyn.createSynthesizer();
// Prepare a SineOscillator (its amplitude will be modulated by the envelope)
sineOsc = new SineOscillator();
sineOsc.amplitude.set(1.0);
sineOsc.frequency.set(320.0);
synth.add(sineOsc);
synth.start();
sineOsc.start();
int n = 30;
while (n > 0){
n--;
System.out.println(sineOsc.output.getValue());
synth.sleepFor(0.1);
}
}
示例3: setUp
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void setUp() throws Exception {
// Create a synthesizer
synth = JSyn.createSynthesizer();
// Prepare a squareOscillator (it produce a binary signal !)
// Needed for an envelope generator
squareOsc = new SquareOscillator();
squareOsc.amplitude.set(1.0);
squareOsc.frequency.set(80.0);
// Prepare a SineOscillator (its amplitude will be modulated by the envelope)
sineOsc = new SineOscillator();
sineOsc.amplitude.set(1.0);
sineOsc.frequency.set(320.0);
// LineOut
out = new LineOut();
synth.add(squareOsc);
synth.add(out);
synth.add(sineOsc);
}
示例4: JSynSynchronizeTesting
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public JSynSynchronizeTesting() throws InterruptedException {
synth = JSyn.createSynthesizer();
sin = new SineOscillator();
sin.amplitude.set(1.0);
sin.frequency.set(320.0);
synth.add(sin);
out = new LineOut();
synth.add(out);
sin.output.connect(out.getInput());
synth.start();
out.start();
ThreadUpdater tu = new ThreadUpdater(sin);
Thread t = new Thread(tu);
t.start();
synth.sleepFor(10000.0);
}
示例5: JsynMultiply
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public JsynMultiply() throws InterruptedException {
synth = JSyn.createSynthesizer();
lineOut = new LineOut();
sine = new SineOscillator();
multiply = new Multiply();
synth.add(lineOut);
synth.add(sine);
synth.add(multiply);
sine.frequency.set(320.0);
sine.amplitude.set(1.0);
sine.output.connect(multiply.inputA);
multiply.inputB.set(0.0);
multiply.output.connect(lineOut.input);
lineOut.start();
multiply.start();
synth.start();
synth.sleepFor(5.0);
}
示例6: init
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void init()
{
synth = JSyn.createSynthesizer();
// Add a tone generator.
synth.add( modulator = new SineOscillator() );
// Add a trigger.
synth.add( carrier = new SineOscillatorPhaseModulated() );
// Add an output mixer.
synth.add( lineOut = new LineOut() );
modulator.output.connect( carrier.modulation );
carrier.output.connect( 0, lineOut.input, 0 );
carrier.output.connect( 0, lineOut.input, 1 );
modulator.amplitude.setup( 0.0, 1.0, 10.0 );
carrier.amplitude.setup( 0.0, 1.0, 1.0 );
setupGUI();
}
示例7: init
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
@Override
public void init()
{
synth = JSyn.createSynthesizer();
// Add a tone generator.
synth.add( modulator = new SineOscillator() );
// Add a trigger.
synth.add( carrier = new SineOscillatorPhaseModulated() );
// Add an output mixer.
synth.add( lineOut = new LineOut() );
modulator.output.connect( carrier.modulation );
carrier.output.connect( 0, lineOut.input, 0 );
carrier.output.connect( 0, lineOut.input, 1 );
modulator.amplitude.setup( 0.0, 1.0, 10.0 );
carrier.amplitude.setup( 0.0, 1.0, 1.0 );
setupGUI();
}
示例8: createUnits
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
private void createUnits()
{
// Add a tone generators.
synth.add( osc = new SineOscillator() );
// Add a controller that will sweep the envelope rate up.
synth.add( envSweeper = new ExponentialRamp() );
// Add a controller that will sweep the oscillator down.
synth.add( oscSweeper = new ExponentialRamp() );
synth.add( latch = new LatchZeroCrossing() );
// Add an output unit.
synth.add( lineOut = new LineOut() );
// Add an envelope player.
synth.add( envelopePlayer = new VariableRateMonoReader() );
}
示例9: init
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
@Override
public void init() {
synth = JSyn.createSynthesizer();
// Add a tone generator.
synth.add(modulator = new SineOscillator());
// Add a trigger.
synth.add(carrier = new SineOscillatorPhaseModulated());
// Add an output mixer.
synth.add(lineOut = new LineOut());
modulator.output.connect(carrier.modulation);
carrier.output.connect(0, lineOut.input, 0);
carrier.output.connect(0, lineOut.input, 1);
modulator.amplitude.setup(0.0, 1.0, 10.0);
carrier.amplitude.setup(0.0, 0.25, 1.0);
setupGUI();
}
示例10: testMixedAdding
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void testMixedAdding() {
boolean gotCaught = false;
SynthesisEngine synthesisEngine1 = new SynthesisEngine();
synthesisEngine1.setRealTime(false);
synthesisEngine1.setPullDataEnabled(true);
SynthesisEngine synthesisEngine2 = new SynthesisEngine();
synthesisEngine2.setRealTime(false);
synthesisEngine2.setPullDataEnabled(true);
// Create a sineOscillator but do not add it to the synth!
SineOscillator sineOscillator = new SineOscillator();
LineOut lineOut = new LineOut();
synthesisEngine1.add(lineOut);
synthesisEngine2.add(sineOscillator);
try {
sineOscillator.output.connect(0, lineOut.input, 0);
} catch (RuntimeException e) {
gotCaught = true;
assertTrue("informative MPE message", e.getMessage().contains("different synths"));
}
assertTrue("caught NPE caused by forgetting synth.add", gotCaught);
}
示例11: benchmark
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
private void benchmark() throws InstantiationException, IllegalAccessException,
InterruptedException {
double realTime = 10.0;
int count = 40;
// benchFFTDouble();
// benchFFTFloat();
/*
* realTime = 20.0; benchmarkOscillator(SawtoothOscillator.class, count, realTime);
* benchmarkOscillator(SawtoothOscillatorDPW.class, count, realTime);
* benchmarkOscillator(SawtoothOscillatorBL.class, count, realTime);
*/
benchmarkOscillator(SquareOscillator.class, count, realTime);
benchmarkOscillator(SquareOscillatorBL.class, count, realTime);
benchmarkOscillator(SineOscillator.class, count, realTime);
benchmarkPitchDetector(count, realTime);
}
示例12: SineEnvelope
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public SineEnvelope() {
// Create unit generators.
add(mFrequencyPassThrough = new PassThrough());
addPort(frequency = mFrequencyPassThrough.input, "frequency");
add(mAmplitudePassThrough = new PassThrough());
addPort(amplitude = mAmplitudePassThrough.input, "amplitude");
add(mOutputPassThrough = new PassThrough());
addPort( output = mOutputPassThrough.output, "output");
add(mSineOsc = new SineOscillator());
add(mDAHDSR = new EnvelopeDAHDSR());
// Connect units and ports.
mFrequencyPassThrough.output.connect(mSineOsc.frequency);
mAmplitudePassThrough.output.connect(mSineOsc.amplitude);
mSineOsc.output.connect(mDAHDSR.amplitude);
mDAHDSR.output.connect(mOutputPassThrough.input);
// Setup
frequency.setup(40.0, 698.4584691287101, 8000.0);
amplitude.setup(0.0, 0.999969482421875, 1.0);
mDAHDSR.input.set(0.0);
// Sum of these times should not exceed MIN_TIME_VALUE_CHANGE_MS
mDAHDSR.delay.set(0.01);
mDAHDSR.attack.set(0.01);
mDAHDSR.hold.set(0.04);
mDAHDSR.decay.set(0.01);
mDAHDSR.sustain.set(0.045);
mDAHDSR.release.set(0.01);
}
示例13: init
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void init()
{
synth = JSyn.createSynthesizer();
// Add a tone generator.
synth.add( osc = new SineOscillator() );
// Add a trigger.
synth.add( gatingOsc = new SquareOscillator() );
// Use an envelope to control the amplitude.
synth.add( dahdsr = new EnvelopeDAHDSR() );
// Add an output mixer.
synth.add( lineOut = new LineOut() );
//e/xit1.add();
gatingOsc.output.connect( dahdsr.input );
dahdsr.output.connect( osc.amplitude );
dahdsr.attack.setup( 0.001, 0.01, 2.0 );
osc.output.connect( 0, lineOut.input, 0 );
osc.output.connect( 0, lineOut.input, 1 );
gatingOsc.frequency.setup( 0.001, 0.5, 10.0 );
gatingOsc.frequency.setName("Rate");
osc.frequency.setup( 50.0, 440.0, 2000.0 );
osc.frequency.setName("Freq");
// Arrange the knob in a row.
setLayout( new GridLayout( 1, 0 ) );
setupPortKnob( osc.frequency );
setupPortKnob( gatingOsc.frequency );
setupPortKnob( dahdsr.attack );
setupPortKnob( dahdsr.hold );
setupPortKnob( dahdsr.decay );
setupPortKnob( dahdsr.sustain );
setupPortKnob( dahdsr.release );
validate();
}
示例14: initSynthetizer
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
public void initSynthetizer() {
synth = JSyn.createSynthesizer();
synth.add(oscillo = new SineOscillator());
synth.add(lineOut = new LineOut());
synth.add(frequencyRamp = makeFrequencyRamp(oscillo.frequency));
synth.add(amplitudeRamp = makeAmplitudeRamp(oscillo.amplitude));
}
示例15: start
import com.jsyn.unitgen.SineOscillator; //导入依赖的package包/类
@Override
public void start()
{
synth = JSyn.createSynthesizer();
// Add an LFO.
synth.add( lfo = new SineOscillator() );
synth.add( adder = new Add() );
// Add an output so we can hear the oscillators.
synth.add( lineOut = new LineOut() );
lfo.frequency.set( 0.1 );
lfo.amplitude.set( 200.0 );
adder.inputB.set( 400.0 );
lfo.output.connect( adder.inputA );
oscillators.add( new SawtoothOscillatorBL() );
oscillators.add( new SineOscillator() );
oscillators.add( new TriangleOscillator() );
for( UnitOscillator osc : oscillators)
{
synth.add( osc);
adder.output.connect( osc.frequency );
osc.output.connect( 0, lineOut.input, 0 );
osc.amplitude.set( 0.2 );
}
// Start synthesizer using default stereo output at 44100 Hz.
synth.start();
// Start lineOut so it can pull data from other units.
lineOut.start();
setupGUI();
// We only need to start the LineOut. It will pull data from the
// oscillator.
lineOut.start();
}