本文整理汇总了Java中com.jsyn.unitgen.Multiply类的典型用法代码示例。如果您正苦于以下问题:Java Multiply类的具体用法?Java Multiply怎么用?Java Multiply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Multiply类属于com.jsyn.unitgen包,在下文中一共展示了Multiply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FrequencyModulator
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public FrequencyModulator(String name, IComponent component, PotentiometerType potentiometerType) {
super(name, component);
multiplyFunction = new Multiply();
setPotentiometer(new Potentiometer(
"Frequency",
multiplyFunction.inputB,
potentiometerType,
2.0D,
0.5D,
1.0D
));
// Declare the relation to the mapping
Register.declare(component, this.multiplyFunction);
input = Factory.createInput(name + "::freqIn", component, multiplyFunction.inputA);
output = Factory.createOutput(name + "::freqOut", component, multiplyFunction.output);
}
示例2: AmplitudeModulator
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public AmplitudeModulator(String name, IComponent component, PotentiometerType potentiometerType) {
super(name, component);
multiply = new Multiply();
// Declare the relation to the mapping
Register.declare(component, this.multiply);
input = Factory.createInput(name + "::ampIn", component, multiply.inputA);
output = Factory.createOutput(name + "::ampOut", component, multiply.output);
setPotentiometer(new Potentiometer("Amplitude", multiply.inputB, potentiometerType,
1, 0, 1
));
// WARNING :
// By setting the initial value of the amplitude Modulator, you are modifying the initial value
// of TWO modulator on any component, at both sourceAm and output (which is also using
// an amplitudeModulator
}
示例3: JsynMultiply
import com.jsyn.unitgen.Multiply; //导入依赖的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);
}
示例4: PolyphonicInstrument
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public PolyphonicInstrument(UnitVoice[] voices) {
this.voices = voices;
voiceAllocator = new VoiceAllocator(voices);
add(mixer = new Multiply());
// Mix all the voices to one output.
for (UnitVoice voice : voices) {
UnitGenerator unit = voice.getUnitGenerator();
boolean wasEnabled = unit.isEnabled();
// This overrides the enabled property of the voice.
add(unit);
voice.getOutput().connect(mixer.inputA);
// restore
unit.setEnabled(wasEnabled);
}
addPort(amplitude = mixer.inputB, "Amplitude");
amplitude.setup(0.0001, 0.4, 2.0);
exportAllInputPorts();
}
示例5: SequencerModule
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public SequencerModule(IComponent component) {
this.ioMultiply = new Multiply();
this.inputSignal = new UnitInputPort("inputSignal");
this.inputSignal.setDefault(0.0);
addPort(this.inputSignal);
Register.declare(component, this);
Register.declare(component, this.ioMultiply);
this.output.connect(this.ioMultiply.inputB);
this.iInput = Factory.createInput("InputGate", component, this.inputSignal);
this.iOutput = Factory.createOutput("OutputPort", component, this.ioMultiply.output);
this.voltageProducer = new VoltageProducer();
this.voltageProducer.input.set(1.0/5);
this.voltageProducer.output.connect(this.ioMultiply.inputB);
// Start the gate
this.start();
this.currentStep = 1;
this.steps = new double[8];
for (int i = 0; i < this.steps.length; i++){
this.steps[i] = 0.0;
}
}
示例6: DrumWoodFM
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public DrumWoodFM() {
// Create unit generators.
add(carrierOsc = new SineOscillatorPhaseModulated());
add(freqDistributor = new PassThrough());
add(modSummer = new Add());
add(ampEnv = new EnvelopeAttackDecay());
add(modEnv = new EnvelopeAttackDecay());
add(modOsc = new SineOscillator());
add(frequencyMultiplier = new Multiply());
addPort(mcratio = frequencyMultiplier.inputB, "MCRatio");
addPort(index = modSummer.inputA, "Index");
addPort(modRange = modEnv.amplitude, "ModRange");
addPort(frequency = freqDistributor.input, "Frequency");
ampEnv.export(this, "Amp");
modEnv.export(this, "Mod");
freqDistributor.output.connect(carrierOsc.frequency);
freqDistributor.output.connect(frequencyMultiplier.inputA);
carrierOsc.output.connect(ampEnv.amplitude);
modEnv.output.connect(modSummer.inputB);
modSummer.output.connect(modOsc.amplitude);
modOsc.output.connect(carrierOsc.modulation);
frequencyMultiplier.output.connect(modOsc.frequency);
// Make the circuit turn off when the envelope finishes to reduce CPU load.
ampEnv.setupAutoDisable(this);
usePreset(0);
}
示例7: SubtractiveSynthVoice
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public SubtractiveSynthVoice() {
add(frequencyScaler = new Multiply());
// Add a tone generator.
add(osc = new SawtoothOscillatorBL());
// Use an envelope to control the amplitude.
add(ampEnv = new EnvelopeDAHDSR());
// Use an envelope to control the filter cutoff.
add(filterEnv = new EnvelopeDAHDSR());
add(filter = new FilterLowPass());
add(cutoffAdder = new Add());
filterEnv.output.connect(cutoffAdder.inputA);
cutoffAdder.output.connect(filter.frequency);
frequencyScaler.output.connect(osc.frequency);
osc.output.connect(filter.input);
filter.output.connect(ampEnv.amplitude);
addPort(amplitude = osc.amplitude, "Amplitude");
addPort(frequency = frequencyScaler.inputA, "Frequency");
addPort(pitchModulation = frequencyScaler.inputB, "PitchMod");
addPort(cutoff = cutoffAdder.inputB, "Cutoff");
addPort(cutoffRange = filterEnv.amplitude, "CutoffRange");
addPort(Q = filter.Q);
ampEnv.export(this, "Amp");
filterEnv.export(this, "Filter");
frequency.setup(osc.frequency);
pitchModulation.setup(0.2, 1.0, 4.0);
cutoff.setup(filter.frequency);
cutoffRange.setup(filter.frequency);
// Make the circuit turn off when the envelope finishes to reduce CPU load.
ampEnv.setupAutoDisable(this);
usePreset(0);
}
示例8: WaveShapingVoice
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public WaveShapingVoice() {
add(frequencyScaler = new Multiply());
add(osc = new SineOscillator());
add(waveShaper = new FunctionEvaluator());
add(rangeEnv = new EnvelopeDAHDSR());
add(ampEnv = new EnvelopeDAHDSR());
addPort(amplitude = ampEnv.amplitude);
addPort(range = osc.amplitude, "Range");
addPort(function = waveShaper.function);
addPort(frequency = frequencyScaler.inputA, "Frequency");
addPort(pitchModulation = frequencyScaler.inputB, "PitchMod");
ampEnv.export(this, "Amp");
rangeEnv.export(this, "Range");
function.set(chebyshevTable);
// Connect units.
osc.output.connect(rangeEnv.amplitude);
rangeEnv.output.connect(waveShaper.input);
ampEnv.output.connect(waveShaper.amplitude);
frequencyScaler.output.connect(osc.frequency);
// Set reasonable defaults for the ports.
pitchModulation.setup(0.1, 1.0, 10.0);
range.setup(0.1, 0.8, 1.0);
frequency.setup(osc.frequency);
amplitude.setup(0.0, 0.5, 1.0);
// Make the circuit turn off when the envelope finishes to reduce CPU load.
ampEnv.setupAutoDisable(this);
usePreset(2);
}
示例9: setup
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
void setup(ChannelGroupContext groupContext) {
this.groupContext = groupContext;
synth.add(pitchToLinear = new PowerOfTwo());
synth.add(lfo = new SineOscillator()); // TODO use a MorphingOscillator or switch
// between S&H etc.
// Use a ramp to smooth out the timbre changes.
// This helps reduce pops from changing filter cutoff too abruptly.
synth.add(timbreRamp = new LinearRamp());
timbreRamp.time.set(0.02);
synth.add(pressureRamp = new LinearRamp());
pressureRamp.time.set(0.02);
synth.add(volumeRamp = new ExponentialRamp());
volumeRamp.input.set(1.0);
volumeRamp.time.set(0.02);
synth.add(volumeMultiplier = new Multiply());
synth.add(panner = new Pan());
pitchToLinear.input.setValueAdded(true); // so we can sum pitch bend
lfo.output.connect(pitchToLinear.input);
lfo.amplitude.set(0.0);
lfo.frequency.set(vibratoRate);
volumeRamp.output.connect(volumeMultiplier.inputB);
volumeMultiplier.output.connect(panner.input);
panner.output.connect(0, outputUnit.inputA, 0); // Use MultiPassthrough
panner.output.connect(1, outputUnit.inputB, 0);
}
示例10: SynthCircuitBlaster
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public SynthCircuitBlaster()
{
add( frequencyPin = new PassThrough() );
add( modScaler = new Multiply() );
add( sweepScaler = new Multiply() );
add( edgeDetector = new EdgeDetector() );
add( latch = new Latch() );
add( samplee = new SineOscillator() );
//add( pulser = new PulseOscillator() );
add( lfo = new SineOscillator() );
add( osc = new SawtoothOscillatorDPW() );
add( filter = new FilterLowPass() );
// Use an envelope to control the amplitude.
add( ampEnv = new EnvelopeDAHDSR() );
samplee.output.connect( latch.input );
//pulser.output.connect( edgeDetector.input );
edgeDetector.input.set(1);
edgeDetector.output.connect( latch.gate );
latch.output.connect( osc.frequency );
frequencyPin.output.connect( osc.frequency );
frequencyPin.output.connect( modScaler.inputA );
modScaler.output.connect( lfo.amplitude );
frequencyPin.output.connect( sweepScaler.inputA );
sweepScaler.output.connect( samplee.amplitude );
lfo.output.connect( osc.frequency );
osc.output.connect( filter.input );
filter.output.connect( ampEnv.amplitude );
//pulser.output.connect( ampEnv.input );
ampEnv.input.set(1);
//ampEnv.
// Setup ports ---------------
addPort( amplitude = osc.amplitude, "amplitude" );
amplitude.set( 0.6 );
addPort( frequency = frequencyPin.input, "frequency" );
frequency.setup( 50.0, 800.0, 2000.0 );
addPort( modRate = lfo.frequency, "modRate" );
modRate.setup( 0.0, 12, 20.0 );
addPort( modDepth = modScaler.inputB, "modDepth" );
modDepth.setup( 0.0, 0.0, 0.5 );
addPort( cutoff = filter.frequency, "cutoff" );
cutoff.setup( 20.0, 2000.0, 5000.0 );
addPort( resonance = filter.Q, "Q" );
addPort( sweepDepth = sweepScaler.inputB, "sweepDepth" );
sweepDepth.setup( 0.0, 0.6, 1.0 );
addPort( sweepRate = samplee.frequency, "sweepRate" );
sweepRate.setup( 0.2, 5.9271, 20.0 );
/*addPort( pulseRate = pulser.frequency, "pulseRate" );
pulseRate.setup( 0.2, 7.0, 20.0 );
addPort( pulseWidth = pulser.width, "pulseWidth" );
pulseWidth.setup( -0.9, 0.9, 0.9 );*/
edgeDetector.input.setup( 0.2, 7.0, 20.0 );
addPort( attack = ampEnv.attack, "attack" );
attack.setup( 0.001, 0.001, 2.0 );
addPort( decay = ampEnv.decay, "decay" );
decay.setup( 0.001, 0.26, 2.0 );
addPort( sustain = ampEnv.sustain, "sustain" );
sustain.setup( 0.000, 0.24, 1.0 );
addPort( release = ampEnv.release, "release" );
release.setup( 0.001, 0.2, 2.0 );
addPort( output = ampEnv.output );
}
示例11: start
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
@Override
public void start()
{
synth = JSyn.createSynthesizer();
// Use a multiplier for gain control and so we can hook up to the scope
// from a single unit.
synth.add( oscGain = new Multiply() );
oscGain.inputB.setup( 0.02, 0.5, 1.0 );
oscGain.inputB.setName( "Amplitude" );
synth.add( freqRamp = new LinearRamp() );
freqRamp.input.setup( 50.0, 300.0, 20000.0 );
freqRamp.input.setName( "Frequency" );
freqRamp.time.set( 0.1 );
// Add an output so we can hear the oscillators.
synth.add( lineOut = new LineOut() );
oscGain.output.connect( lineOut.input );
setupGUI();
buttonGroup = new ButtonGroup();
addOscillator( new SineOscillator(), "Sine" );
addOscillator( new TriangleOscillator(), "Triangle" );
addOscillator( new SawtoothOscillator(), "Sawtooth" );
addOscillator( new SawtoothOscillatorBL(), "SawBL" );
addOscillator( new SawtoothOscillatorDPW(), "SawDPW" );
addOscillator( new RedNoise(), "RedNoise" );
addOscillator( new SquareOscillator(), "Square" );
addOscillator( new SquareOscillatorBL(), "SquareBL" );
addOscillator( new PulseOscillator(), "Pulse" );
addOscillator( new PulseOscillatorBL(), "PulseBL" );
addOscillator( new ImpulseOscillator(), "Impulse" );
addOscillator( new ImpulseOscillatorBL(), "ImpulseBL" );
// Start synthesizer using default stereo output at 44100 Hz.
synth.start();
// Start lineOut so it can pull data from other units.
lineOut.start();
// We only need to start the LineOut. It will pull data from the
// oscillator.
lineOut.start();
}
示例12: test
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
private void test()
{
// Create a context for the synthesizer.
synth = JSyn.createSynthesizer();
// Start synthesizer using default stereo output at 44100 Hz.
synth.start();
// Add a stereo audio output unit.
synth.add( lineOut = new LineOut() );
synth.add( ramp = new LinearRamp() );
// Add a tone generator.
osc = new SineOscillator[amps.length];
multipliers = new Multiply[ratios.length];
for( int i = 0; i < osc.length; i++ )
{
// Create unit generators and store them in arrays.
synth.add( osc[i] = new SineOscillator() );
synth.add( multipliers[i] = new Multiply() );
// Connect each oscillator to both channels of the output.
// They will be mixed automatically.
osc[i].output.connect( 0, lineOut.input, 0 );
osc[i].output.connect( 0, lineOut.input, 1 );
// Use a multiplier to scale the output of the ramp.
// output = inputA * inputB
ramp.output.connect( multipliers[i].inputA );
multipliers[i].output.connect( osc[i].frequency );
multipliers[i].inputB.set( ratios[i] );
osc[i].amplitude.set( amps[i] );
}
// start ramping up
ramp.current.set( 100.0);
ramp.time.set(3.0);
ramp.input.set( 700.0 );
// We only need to start the LineOut. It will pull data from the
// oscillator.
lineOut.start();
System.out.println( "You should now be hearing a sine wave. ---------" );
// Sleep while the sound is generated in the background.
try
{
// Sleep for a few seconds.
synth.sleepFor( 4.0 );
// ramp down
ramp.input.set( 100.0 );
synth.sleepFor( 4.0 );
} catch( InterruptedException e )
{
e.printStackTrace();
}
System.out.println( "Stop playing. -------------------" );
// Stop everything.
synth.stop();
}
示例13: SampleHoldNoteBlaster
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public SampleHoldNoteBlaster()
{
add( frequencyPin = new PassThrough() );
add( modScaler = new Multiply() );
add( sweepScaler = new Multiply() );
add( edgeDetector = new EdgeDetector() );
add( latch = new Latch() );
add( samplee = new SineOscillator() );
add( pulser = new PulseOscillator() );
add( lfo = new SineOscillator() );
add( osc = new SawtoothOscillatorDPW() );
add( filter = new FilterLowPass() );
// Use an envelope to control the amplitude.
add( ampEnv = new EnvelopeDAHDSR() );
samplee.output.connect( latch.input );
pulser.output.connect( edgeDetector.input );
edgeDetector.output.connect( latch.gate );
latch.output.connect( osc.frequency );
frequencyPin.output.connect( osc.frequency );
frequencyPin.output.connect( modScaler.inputA );
modScaler.output.connect( lfo.amplitude );
frequencyPin.output.connect( sweepScaler.inputA );
sweepScaler.output.connect( samplee.amplitude );
lfo.output.connect( osc.frequency );
osc.output.connect( filter.input );
filter.output.connect( ampEnv.amplitude );
pulser.output.connect( ampEnv.input );
// Setup ports ---------------
addPort( amplitude = osc.amplitude, "amplitude" );
amplitude.set( 0.6 );
addPort( frequency = frequencyPin.input, "frequency" );
frequency.setup( 50.0, 800.0, 2000.0 );
addPort( modRate = lfo.frequency, "modRate" );
modRate.setup( 0.0, 12, 20.0 );
addPort( modDepth = modScaler.inputB, "modDepth" );
modDepth.setup( 0.0, 0.0, 0.5 );
addPort( cutoff = filter.frequency, "cutoff" );
cutoff.setup( 20.0, 2000.0, 5000.0 );
addPort( resonance = filter.Q, "Q" );
addPort( sweepDepth = sweepScaler.inputB, "sweepDepth" );
sweepDepth.setup( 0.0, 0.6, 1.0 );
addPort( sweepRate = samplee.frequency, "sweepRate" );
sweepRate.setup( 0.2, 5.9271, 20.0 );
addPort( pulseRate = pulser.frequency, "pulseRate" );
pulseRate.setup( 0.2, 7.0, 20.0 );
addPort( pulseWidth = pulser.width, "pulseWidth" );
pulseWidth.setup( -0.9, 0.9, 0.9 );
addPort( attack = ampEnv.attack, "attack" );
attack.setup( 0.001, 0.001, 2.0 );
addPort( decay = ampEnv.decay, "decay" );
decay.setup( 0.001, 0.26, 2.0 );
addPort( sustain = ampEnv.sustain, "sustain" );
sustain.setup( 0.000, 0.24, 1.0 );
addPort( release = ampEnv.release, "release" );
release.setup( 0.001, 0.2, 2.0 );
addPort( output = ampEnv.output );
}
示例14: DualOscillatorSynthVoice
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
public DualOscillatorSynthVoice() {
add(frequencyMultiplier = new Multiply());
add(amplitudeMultiplier = new Multiply());
add(amplitudeBoost = new Multiply());
add(detuneScaler1 = new Multiply());
add(detuneScaler2 = new Multiply());
// Add tone generators.
add(osc1 = new MorphingOscillatorBL());
add(osc2 = new MorphingOscillatorBL());
// Use an envelope to control the amplitude.
add(ampEnv = new EnvelopeDAHDSR());
// Use an envelope to control the filter cutoff.
add(filterEnv = new EnvelopeDAHDSR());
add(filter = new FilterFourPoles());
add(cutoffAdder = new Add());
filterEnv.output.connect(cutoffAdder.inputA);
cutoffAdder.output.connect(filter.frequency);
frequencyMultiplier.output.connect(detuneScaler1.inputA);
frequencyMultiplier.output.connect(detuneScaler2.inputA);
detuneScaler1.output.connect(osc1.frequency);
detuneScaler2.output.connect(osc2.frequency);
osc1.output.connect(amplitudeMultiplier.inputA); // mix oscillators
osc2.output.connect(amplitudeMultiplier.inputA);
amplitudeMultiplier.output.connect(filter.input);
filter.output.connect(amplitudeBoost.inputA);
amplitudeBoost.output.connect(ampEnv.amplitude);
addPort(amplitude = amplitudeMultiplier.inputB, PORT_NAME_AMPLITUDE);
addPort(frequency = frequencyMultiplier.inputA, PORT_NAME_FREQUENCY);
addPort(oscShape1 = osc1.shape, "OscShape1");
addPort(oscShape2 = osc2.shape, "OscShape2");
// addPort(oscDetune1 = osc1.shape, "OscDetune1");
// addPort(oscDetune2 = osc2.shape, "OscDetune2");
addPort(cutoff = cutoffAdder.inputB, PORT_NAME_CUTOFF);
addPortAlias(cutoff, PORT_NAME_TIMBRE);
addPort(Q = filter.Q);
addPort(frequencyScaler = frequencyMultiplier.inputB, PORT_NAME_FREQUENCY_SCALER);
addPort(filterEnvDepth = filterEnv.amplitude, "FilterEnvDepth");
filterEnv.export(this, "Filter");
ampEnv.export(this, "Amp");
frequency.setup(osc1.frequency);
frequencyScaler.setup(0.2, 1.0, 4.0);
cutoff.setup(filter.frequency);
// Allow negative filter sweeps
filterEnvDepth.setup(-4000.0, 2000.0, 4000.0);
// set amplitudes slightly different so that they never entirely cancel
osc1.amplitude.set(0.5);
osc2.amplitude.set(0.4);
// Make the circuit turn off when the envelope finishes to reduce CPU load.
ampEnv.setupAutoDisable(this);
// Add named port for mapping pressure.
amplitudeBoost.inputB.setup(1.0, 1.0, 4.0);
addPortAlias(amplitudeBoost.inputB, PORT_NAME_PRESSURE);
usePreset(0);
}
示例15: start
import com.jsyn.unitgen.Multiply; //导入依赖的package包/类
@Override
public void start() {
synth = JSyn.createSynthesizer();
// Use a multiplier for gain control and so we can hook up to the scope
// from a single unit.
synth.add(oscGain = new Multiply());
oscGain.inputB.setup(0.02, 0.5, 1.0);
oscGain.inputB.setName("Amplitude");
synth.add(freqRamp = new LinearRamp());
freqRamp.input.setup(50.0, 300.0, 20000.0);
freqRamp.input.setName("Frequency");
freqRamp.time.set(0.1);
synth.add(widthRamp = new LinearRamp());
widthRamp.input.setup(-1.0, 0.0, 1.0);
widthRamp.input.setName("Width");
widthRamp.time.set(0.1);
synth.add(shapeRamp = new LinearRamp());
shapeRamp.input.setup(-1.0, 0.0, 1.0);
shapeRamp.input.setName("Shape");
shapeRamp.time.set(0.1);
// Add an output so we can hear the oscillators.
synth.add(lineOut = new LineOut());
oscGain.output.connect(0, lineOut.input, 0);
oscGain.output.connect(0, lineOut.input, 1);
setupGUI();
buttonGroup = new ButtonGroup();
addOscillator(new SineOscillator(), "Sine");
addOscillator(new TriangleOscillator(), "Triangle");
addOscillator(new SawtoothOscillator(), "Sawtooth");
addOscillator(new SawtoothOscillatorBL(), "SawBL");
addOscillator(new SawtoothOscillatorDPW(), "SawDPW");
addOscillator(new RedNoise(), "RedNoise");
addOscillator(new SquareOscillator(), "Square");
addOscillator(new SquareOscillatorBL(), "SquareBL");
addOscillator(new PulseOscillator(), "Pulse");
addOscillator(new PulseOscillatorBL(), "PulseBL");
addOscillator(new MorphingOscillatorBL(), "MorphBL");
addOscillator(new ImpulseOscillator(), "Impulse");
addOscillator(new ImpulseOscillatorBL(), "ImpulseBL");
// Start synthesizer using default stereo output at 44100 Hz.
synth.start();
// Start lineOut so it can pull data from other units.
lineOut.start();
// We only need to start the LineOut. It will pull data from the
// oscillator.
lineOut.start();
}