Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_region.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_MIDI_REGION_H__
11#define __AUDIO_MIDI_REGION_H__
12
13#include <cstddef>
14#include <cstdint>
15
16#include "utils/types.h"
17
18typedef struct Track Track;
19typedef struct Position Position;
20typedef struct MidiNote MidiNote;
21typedef struct Region Region;
22typedef struct MidiEvents MidiEvents;
23typedef struct ChordDescriptor ChordDescriptor;
24typedef struct Velocity Velocity;
25typedef void MIDI_FILE;
26
36Region *
38 const Position * start_pos,
39 const Position * end_pos,
40 unsigned int track_name_hash,
41 int lane_pos,
42 int idx_inside_lane);
43
53Region *
55 const Position * start_pos,
56 const char * abs_path,
57 unsigned int track_name_hash,
58 int lane_pos,
59 int idx_inside_lane,
60 int idx);
61
68Region *
70 const Position * pos,
71 ChordDescriptor * descr,
72 unsigned int track_name_hash,
73 int lane_pos,
74 int idx_inside_lane);
75
81#define midi_region_add_midi_note(region, midi_note, pub_events) \
82 midi_region_insert_midi_note ( \
83 region, midi_note, ((Region *) (region))->num_midi_notes, pub_events)
84
91void
93 Region * region,
95 int idx,
96 int pub_events);
97
105void
107 Region * self,
108 Position * start_pos,
110 int pitch,
111 int vel,
112 int pub_events);
113
124MidiNote *
126
142OPTIMIZE_O3
143REALTIME
144void
146 Region * self,
147 const EngineProcessTimeInfo * const time_nfo,
148 bool note_off_at_end,
149 bool is_note_off_for_loop_or_region_end,
150 MidiEvents * midi_events);
151
157void
159
163MidiNote *
165
169MidiNote *
171
175MidiNote *
177
181MidiNote *
183
190void
192 Region * region,
194 int free,
195 int pub_event);
196
201void
203
223NONNULL_ARGS (1, 2)
225 const Region * self,
226 MIDI_FILE * mf,
227 const bool add_region_start,
228 bool export_full);
229
239NONNULL void
241 const Region * self,
242 const char * full_path,
243 int midi_version,
244 const bool export_full);
245
250uint8_t
252
257bool
259
274void
276 const Region * self,
277 MidiEvents * events,
278 const Position * start,
279 const Position * end,
280 const bool add_region_start,
281 const bool full);
282
291void
293 const Region * self,
294 const Position * start_pos,
295 const Position * end_pos,
296 Velocity *** velocities,
297 int * num_velocities,
298 size_t * velocities_size,
299 int inside);
300
306void
308
313#endif // __AUDIO_MIDI_REGION_H__
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
void midi_region_write_to_midi_file(const Region *self, MIDI_FILE *mf, const bool add_region_start, bool export_full)
Exports the Region to an existing MIDI file instance.
MidiNote * midi_region_get_lowest_midi_note(Region *region)
Gets lowest midi note.
void midi_region_add_events(const Region *self, MidiEvents *events, const Position *start, const Position *end, const bool add_region_start, const bool full)
Adds the contents of the region converted into events.
void midi_region_free_members(Region *self)
Frees members only but not the midi region itself.
NONNULL void midi_region_export_to_midi_file(const Region *self, const char *full_path, int midi_version, const bool export_full)
Exports the Region to a specified MIDI file.
MidiNote * midi_region_get_last_midi_note(Region *region)
Gets last midi note.
MidiNote * midi_region_get_first_midi_note(Region *region)
Gets first midi note.
Region * midi_region_new_from_midi_file(const Position *start_pos, const char *abs_path, unsigned int track_name_hash, int lane_pos, int idx_inside_lane, int idx)
Creates a MIDI region from the given MIDI file path, starting at the given Position.
void midi_region_start_unended_note(Region *self, Position *start_pos, Position *end_pos, int pitch, int vel, int pub_events)
Starts an unended note with the given pitch and velocity and adds it to Region::midi_notes.
void midi_region_remove_all_midi_notes(Region *region)
Removes all MIDI ntoes and their components completely.
Region * midi_region_new(const Position *start_pos, const Position *end_pos, unsigned int track_name_hash, int lane_pos, int idx_inside_lane)
Creates a new Region for MIDI notes.
void midi_region_insert_midi_note(Region *region, MidiNote *midi_note, int idx, int pub_events)
Inserts the MidiNote to the given Region.
uint8_t midi_region_get_midi_ch(const Region *self)
Returns the MIDI channel that this region should be played on, starting from 1.
void midi_region_print_midi_notes(Region *self)
Prints the MidiNotes in the Region.
void midi_region_remove_midi_note(Region *region, MidiNote *midi_note, int free, int pub_event)
Removes the MIDI note from the Region.
MidiNote * midi_region_pop_unended_note(Region *self, int pitch)
Returns the midi note with the given pitch from the unended notes.
bool midi_region_is_note_playable(const Region *self, const MidiNote *midi_note)
Returns whether the given note is not muted and starts within any playable part of the region.
OPTIMIZE_O3 REALTIME void midi_region_fill_midi_events(Region *self, const EngineProcessTimeInfo *const time_nfo, bool note_off_at_end, bool is_note_off_for_loop_or_region_end, MidiEvents *midi_events)
Fills MIDI event queue from the region.
MidiNote * midi_region_get_highest_midi_note(Region *region)
Gets highest midi note.
Region * midi_region_new_from_chord_descr(const Position *pos, ChordDescriptor *descr, unsigned int track_name_hash, int lane_pos, int idx_inside_lane)
Create a region from the chord descriptor.
void midi_region_get_velocities_in_range(const Region *self, const Position *start_pos, const Position *end_pos, Velocity ***velocities, int *num_velocities, size_t *velocities_size, int inside)
Fills in the array with all the velocities in the project that are within or outside the range given.
Position end_pos
End Position, if the object has one.
Position pos
Position (or start Position if the object has length).
A ChordDescriptor describes a chord and is not linked to any specific object by itself.
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition types.h:142
Container for passing midi events through ports.
Definition midi_event.h:62
A MIDI note inside a Region shown in the piano roll.
Definition midi_note.h:49
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:124
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72
Track to be inserted into the Project's Tracklist.
Definition track.h:177
The MidiNote velocity.
Definition velocity.h:41
MidiNote * midi_note
Pointer back to the MIDI note.
Definition velocity.h:53
uint8_t vel
Velocity value (0-127).
Definition velocity.h:46
Custom types.