Package wellen

Class BeatMIDI

java.lang.Object
wellen.BeatMIDI
All Implemented Interfaces:
MidiInListener

public class BeatMIDI extends Object implements MidiInListener
similar to Beat except that beat events are triggered by an external MIDI clock signal.

the method beat(int) of the listener is called for every MIDI clock pulse ( 24 pulses per quarter note ). the first pulse after a MIDI start message is beat 0. after a song position pointer message the next pulse is the beat at that position ( one sixteenth note = 6 pulses ).

by default beat(int) is called on the MIDI thread. use dispatch_on_draw_thread(boolean) to call it on the processing animation thread instead.

  • Field Details

    • VERBOSE

      public static boolean VERBOSE
    • LEGACY_BEAT_COUNT

      @Deprecated public static boolean LEGACY_BEAT_COUNT
      Deprecated.
      only use this to keep old sketches working that rely on the old ( wrong ) counting.
      if true the beat counter behaves like before v0.14: the first beat after a MIDI start message is 1 instead of 0.
  • Method Details

    • start

      public static BeatMIDI start(Object pListener, String pMidiInput)
      Parameters:
      pListener - object which implements the method `beat(int beatCounter)`
      pMidiInput - MIDI input device to listen to
      Returns:
      BeatMIDI
    • start

      public static BeatMIDI start(Object listener, int midi_input_device_ID)
      Parameters:
      listener - object which implements the method `beat(int beatCounter)`
      midi_input_device_ID - ID of MIDI input device as listed by Wellen.dumpMidiInputDevices()
      Returns:
      BeatMIDI
    • start

      public static BeatMIDI start(Object listener, MidiIn midi_in)
      Parameters:
      listener - object which implements the method `beat(int beatCounter)`
      midi_in - existing MIDI input ( e.g shared with an EventReceiverMIDI ). it is not closed by close().
      Returns:
      BeatMIDI
    • reset_beat_counter_at_stop

      public void reset_beat_counter_at_stop(boolean pResetBeatCounterAtStop)
      Parameters:
      pResetBeatCounterAtStop - if `true` the beat counter is reset to `0` when the MIDI clock signal stops.
    • dispatch_on_draw_thread

      public BeatMIDI dispatch_on_draw_thread(boolean dispatch_on_draw_thread)
      Parameters:
      dispatch_on_draw_thread - if true beat(int) is queued and called on the processing animation thread right before draw(). this is safer when drawing or changing sketch state in beat(int) but beats are delivered in batches once per frame. requires the listener to be a PApplet.
      Returns:
      BeatMIDI
    • close

      public void close()
      stops listening to the MIDI input and releases the MIDI device ( if it was opened by this instance ).
    • running

      public boolean running()
      Returns:
      true if beat is running
    • beat_count

      public int beat_count()
      Returns:
      count of the last delivered beat in pulses per quarter notes (PPQN)
    • bpm

      public float bpm()
      returns an estimate of the current BPM deduced from the duration between ticks ( or pulses )
      Returns:
      estimated BPM ( 0 until two ticks were received )
    • clock_tick

      public void clock_tick()
      Description copied from interface: MidiInListener
      called for every MIDI clock pulse ( 24 pulses per quarter note )
      Specified by:
      clock_tick in interface MidiInListener
    • clock_start

      public void clock_start()
      Specified by:
      clock_start in interface MidiInListener
    • clock_continue

      public void clock_continue()
      Specified by:
      clock_continue in interface MidiInListener
    • clock_stop

      public void clock_stop()
      Specified by:
      clock_stop in interface MidiInListener
    • clock_song_position_pointer

      public void clock_song_position_pointer(int offset_16th)
      Specified by:
      clock_song_position_pointer in interface MidiInListener
      Parameters:
      offset_16th - song position in sixteenth notes ( one sixteenth = 6 clock pulses )
    • stop

      public void stop()
    • start

      public void start()