Search in sources :

Example 1 with Auvent

use of net.beadsproject.beads.core.Auvent in project narchy by automenta.

the class arpeggiator_01 method setup.

// construct the synthesizer
public void setup() {
    AudioContext ac = new AudioContext();
    // the gain envelope
    gainEnvelope = new Envelope(ac, 0.0f);
    // set up a custom function to arpeggiate the pitch
    arpeggiator = new FuncGen(gainEnvelope) {

        @Override
        public float floatValueOf(float[] anObject) {
            return frequency * (1 + tick);
        }

        @Override
        public void on(Auvent msg) {
            tick++;
            if (tick >= 4)
                tick = 0;
        }
    };
    // add arpeggiator as a dependent to the AudioContext
    ac.out(arpeggiator);
    // the square generator
    square = new WavePlayer(ac, arpeggiator, WaveFactory.SQUARE);
    // set up a clock to keep time
    beatClock = new Clock(ac, 500.0f);
    beatClock.setTicksPerBeat(4);
    beatClock.on(arpeggiator);
    ac.out.dependsOn(beatClock);
    // set up the Gain and connect it to the main output
    gain = new Gain(ac, 1, gainEnvelope);
    gain.in(square);
    ac.out.in(gain);
    // 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());
    // }
    // }
    // }
    // });
    keyDown(79);
    beatClock.start();
    Util.sleep(100000L);
}
Also used : Auvent(net.beadsproject.beads.core.Auvent) AudioContext(net.beadsproject.beads.core.AudioContext)

Aggregations

AudioContext (net.beadsproject.beads.core.AudioContext)1 Auvent (net.beadsproject.beads.core.Auvent)1