Search in sources :

Example 1 with BiquadFilter

use of net.beadsproject.beads.ugens.BiquadFilter in project narchy by automenta.

the class drum_machine_01 method setup.

// construct the synthesizer
public void setup() {
    AudioContext ac = new AudioContext();
    // set up the envelope for kick gain
    kickGainEnvelope = new Envelope(ac, 0.0f);
    // construct the kick WavePlayer
    kick = new WavePlayer(ac, 100.0f, WaveFactory.SINE);
    // set up the filters
    kickFilter = new BiquadFilter(ac, BiquadFilter.BESSEL_LP, 500.0f, 1.0f);
    kickFilter.in(kick);
    // set up the Gain
    kickGain = new Gain(ac, 1, kickGainEnvelope);
    kickGain.in(kickFilter);
    // connect the gain to the main out
    ac.out.in(kickGain);
    // set up the snare envelope
    snareGainEnvelope = new Envelope(ac, 0.0f);
    // set up the snare WavePlayers
    snareNoise = new WavePlayer(ac, 1.0f, WaveFactory.NOISE);
    snareTone = new WavePlayer(ac, 200.0f, WaveFactory.SINE);
    // set up the filters
    snareFilter = new BiquadFilter(ac, BiquadFilter.BP_SKIRT, 2500.0f, 1.0f);
    snareFilter.in(snareNoise);
    snareFilter.in(snareTone);
    // set up the Gain
    snareGain = new Gain(ac, 1, snareGainEnvelope);
    snareGain.in(snareFilter);
    // connect the gain to the main out
    ac.out.in(snareGain);
    // set up the keyboard input
    // MidiKeyboard keys = new MidiKeyboard();
    // keys.addActionListener(new ActionListener(){
    // @Override
    // public void actionPerformed(ActionEvent e)
    // {
    // // if the event is not null
    // if( e != null )
    // {
    // // if the event is a MIDI event
    // if( e.getSource() instanceof ShortMessage)
    // {
    // // get the MIDI event
    // ShortMessage sm = (ShortMessage)e.getSource();
    // 
    // // if the event is a key down
    // if( sm.getCommand() == MidiKeyboard.NOTE_ON && sm.getData2() > 1 )
    // keyDown(sm.getData1());
    // // if the event is a key up
    // else if( sm.getCommand() == MidiKeyboard.NOTE_OFF )
    // keyUp(sm.getData1());
    // }
    // }
    // }
    // });
    ac.start();
    Util.sleep(100000L);
}
Also used : Envelope(net.beadsproject.beads.ugens.Envelope) BiquadFilter(net.beadsproject.beads.ugens.BiquadFilter) AudioContext(net.beadsproject.beads.core.AudioContext) WavePlayer(net.beadsproject.beads.ugens.WavePlayer) Gain(net.beadsproject.beads.ugens.Gain)

Aggregations

AudioContext (net.beadsproject.beads.core.AudioContext)1 BiquadFilter (net.beadsproject.beads.ugens.BiquadFilter)1 Envelope (net.beadsproject.beads.ugens.Envelope)1 Gain (net.beadsproject.beads.ugens.Gain)1 WavePlayer (net.beadsproject.beads.ugens.WavePlayer)1