10#ifndef __AUDIO_MIDI_EVENT_H__
11#define __AUDIO_MIDI_EVENT_H__
13#include "zrythm-config.h"
23# include "weak_libjack.h"
28#include "ext/midilib/src/midifile.h"
39#define MAX_MIDI_EVENTS 2560
83 int num_queued_events;
127PURE
static inline bool
136midi_events_print (
MidiEvents * self,
const int queued);
252midi_events_has_any (
MidiEvents * self,
bool check_queued)
254 return (check_queued ? self->num_queued_events : self->num_events) > 0;
308 int64_t total_sixteenths,
336midi_events_add_channel_pressure (
366midi_events_write_to_midi_file (
413midi_events_copy_to_jack (
437midi_events_delete_event (
void midi_events_clear(MidiEvents *midi_events, int queued)
Clears midi events.
void midi_events_add_control_change(MidiEvents *self, midi_byte_t channel, midi_byte_t controller, midi_byte_t control, midi_time_t time, int queued)
Adds a control event to the given MidiEvents.
MidiEvents * midi_events_new(void)
Allocates and inits a MidiEvents struct.
int midi_events_delete_note_on(MidiEvents *midi_events, int note, int queued)
Deletes the midi event with a note on signal from the queue, and returns if it deleted or not.
void midi_events_append(MidiEvents *dest, MidiEvents *src, const nframes_t local_offset, const nframes_t nframes, bool queued)
Appends the events from src to dest.
void midi_events_sort(MidiEvents *self, const bool queued)
Sorts the MidiEvents by time.
NONNULL void midi_events_panic_without_lock(MidiEvents *self, bool queued)
Adds a note off message to every MIDI channel.
void midi_events_panic_all(const bool queued)
Queues MIDI note off to event queues.
void midi_events_free(MidiEvents *self)
Frees the MIDI events.
void midi_events_add_note_offs_from_chord_descr(MidiEvents *self, const ChordDescriptor *descr, midi_byte_t channel, midi_time_t time, bool queued)
Adds a note off for each note in the chord.
void midi_events_clear_duplicates(MidiEvents *midi_events, const int queued)
Clears duplicates.
int midi_events_has_note_on(MidiEvents *self, int check_main, int check_queued)
Returrns if the MidiEvents have any note on events.
void midi_events_add_event_from_buf(MidiEvents *self, midi_time_t time, midi_byte_t *buf, int buf_size, int queued)
Parses a MidiEvent from a raw MIDI buffer.
NONNULL void midi_events_panic(MidiEvents *self, bool queued)
Must only be called from the UI thread.
void midi_events_init(MidiEvents *self)
Inits the MidiEvents struct.
void midi_events_transform_chord_and_append(MidiEvents *dest, MidiEvents *src, const nframes_t local_offset, const nframes_t nframes, bool queued)
Transforms the given MIDI input to the MIDI notes of the corresponding chord.
void midi_events_add_note_ons_from_chord_descr(MidiEvents *self, const ChordDescriptor *descr, midi_byte_t channel, midi_byte_t velocity, midi_time_t time, bool queued)
Adds a note on for each note in the chord.
int midi_events_check_for_note_on(MidiEvents *midi_events, int note, int queued)
Returns if a note on event for the given note exists in the given events.
#define MAX_MIDI_EVENTS
Max events to hold in queues.
void midi_events_add_cc_volume(MidiEvents *self, midi_byte_t channel, midi_byte_t volume, midi_time_t time, bool queued)
Add CC volume event.
void midi_events_add_note_off(MidiEvents *self, midi_byte_t channel, midi_byte_t note_pitch, midi_time_t time, int queued)
Adds a note off event to the given MidiEvents.
void midi_events_dequeue(MidiEvents *midi_events)
Copies the queue contents to the original struct.
void midi_events_add_pitchbend(MidiEvents *self, midi_byte_t channel, uint32_t pitchbend, midi_time_t time, bool queued)
Adds a control event to the given MidiEvents.
OPTIMIZE_O3 void midi_events_append_w_filter(MidiEvents *dest, MidiEvents *src, int *channels, const nframes_t start_frame, const nframes_t nframes, bool queued)
Appends the events from src to dest.
void midi_events_add_all_notes_off(MidiEvents *self, midi_byte_t channel, midi_time_t time, bool queued)
Queues MIDI note off to event queue.
void midi_events_add_note_on(MidiEvents *self, midi_byte_t channel, midi_byte_t note_pitch, midi_byte_t velocity, midi_time_t time, int queued)
Adds a note on event to the given MidiEvents.
void midi_events_add_song_pos(MidiEvents *self, int64_t total_sixteenths, midi_time_t time, bool queued)
Adds a song position event to the queue.
void midi_events_set_channel(MidiEvents *self, const int queued, const midi_byte_t channel)
Sets the given MIDI channel on all applicable MIDI events.
uint32_t nframes_t
Frame count.
uint32_t midi_time_t
MIDI time in global frames.
uint8_t midi_byte_t
MIDI byte.
A ChordDescriptor describes a chord and is not linked to any specific object by itself.
midi_byte_t raw_buffer[3]
Raw MIDI data.
gint64 systime
Time using g_get_monotonic_time ().
midi_time_t time
Time of the MIDI event, in frames from the start of the current cycle.
Container for passing midi events through ports.
int num_events
Event count.
MidiEvent events[MAX_MIDI_EVENTS]
Events to use in this cycle.
ZixSem access_sem
Semaphore for exclusive read/write.
MidiEvent queued_events[MAX_MIDI_EVENTS]
For queueing events from the GUI or from hardware, since they run in different threads.
Must ONLY be created via port_new()