Package wellen
Class BeatMIDI
java.lang.Object
wellen.BeatMIDI
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic booleanDeprecated.only use this to keep old sketches working that rely on the old ( wrong ) counting.static boolean -
Method Summary
Modifier and TypeMethodDescriptionintfloatbpm()returns an estimate of the current BPM deduced from the duration between ticks ( or pulses )voidvoidclock_song_position_pointer(int offset_16th) voidvoidvoidcalled for every MIDI clock pulse ( 24 pulses per quarter note )voidclose()stops listening to the MIDI input and releases the MIDI device ( if it was opened by this instance ).dispatch_on_draw_thread(boolean dispatch_on_draw_thread) voidreset_beat_counter_at_stop(boolean pResetBeatCounterAtStop) booleanrunning()voidstart()static BeatMIDIstatic BeatMIDIstatic BeatMIDIvoidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface wellen.MidiInListener
receive_channel_pressure, receive_control_change, receive_note_off, receive_note_on, receive_pitch_bend, receive_poly_pressure, receive_program_change, receive_song_select, receive_sysex, receive_time_code_quarter_frame, receiveControlChange, receiveNoteOff, receiveNoteOn, receiveProgramChange
-
Field Details
-
VERBOSE
public static boolean VERBOSE -
LEGACY_BEAT_COUNT
Deprecated.only use this to keep old sketches working that rely on the old ( wrong ) counting.iftruethe beat counter behaves like before v0.14: the first beat after a MIDI start message is1instead of0.
-
-
Method Details
-
start
- Parameters:
pListener- object which implements the method `beat(int beatCounter)`pMidiInput- MIDI input device to listen to- Returns:
BeatMIDI
-
start
- Parameters:
listener- object which implements the method `beat(int beatCounter)`midi_input_device_ID- ID of MIDI input device as listed byWellen.dumpMidiInputDevices()- Returns:
BeatMIDI
-
start
- Parameters:
listener- object which implements the method `beat(int beatCounter)`midi_in- existing MIDI input ( e.g shared with anEventReceiverMIDI). it is not closed byclose().- 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
- Parameters:
dispatch_on_draw_thread- iftruebeat(int)is queued and called on the processing animation thread right beforedraw(). this is safer when drawing or changing sketch state inbeat(int)but beats are delivered in batches once per frame. requires the listener to be aPApplet.- 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 (
0until two ticks were received )
-
clock_tick
public void clock_tick()Description copied from interface:MidiInListenercalled for every MIDI clock pulse ( 24 pulses per quarter note )- Specified by:
clock_tickin interfaceMidiInListener
-
clock_start
public void clock_start()- Specified by:
clock_startin interfaceMidiInListener
-
clock_continue
public void clock_continue()- Specified by:
clock_continuein interfaceMidiInListener
-
clock_stop
public void clock_stop()- Specified by:
clock_stopin interfaceMidiInListener
-
clock_song_position_pointer
public void clock_song_position_pointer(int offset_16th) - Specified by:
clock_song_position_pointerin interfaceMidiInListener- Parameters:
offset_16th- song position in sixteenth notes ( one sixteenth = 6 clock pulses )
-
stop
public void stop() -
start
public void start()
-