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 <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
16
17#include "utils/types.h"
18
19typedef struct Track Track;
20typedef struct Position Position;
21typedef struct MidiNote MidiNote;
22typedef struct ZRegion ZRegion;
23typedef struct MidiEvents MidiEvents;
24typedef struct ChordDescriptor ChordDescriptor;
25typedef struct Velocity Velocity;
26typedef void MIDI_FILE;
27
37ZRegion *
39 const Position * start_pos,
40 const Position * end_pos,
41 unsigned int track_name_hash,
42 int lane_pos,
43 int idx_inside_lane);
44
54ZRegion *
56 const Position * start_pos,
57 const char * abs_path,
58 unsigned int track_name_hash,
59 int lane_pos,
60 int idx_inside_lane,
61 int idx);
62
69ZRegion *
71 const Position * pos,
72 ChordDescriptor * descr,
73 unsigned int track_name_hash,
74 int lane_pos,
75 int idx_inside_lane);
76
82#define midi_region_add_midi_note(region, midi_note, pub_events) \
83 midi_region_insert_midi_note ( \
84 region, midi_note, ((ZRegion *) (region))->num_midi_notes, pub_events)
85
92void
94 ZRegion * region,
96 int idx,
97 int pub_events);
98
106void
108 ZRegion * self,
109 Position * start_pos,
111 int pitch,
112 int vel,
113 int pub_events);
114
125MidiNote *
127
143OPTIMIZE_O3
144REALTIME
145void
147 ZRegion * self,
148 const EngineProcessTimeInfo * const time_nfo,
149 bool note_off_at_end,
150 bool is_note_off_for_loop_or_region_end,
151 MidiEvents * midi_events);
152
158void
160
164MidiNote *
166
170MidiNote *
172
176MidiNote *
178
182MidiNote *
184
191void
193 ZRegion * region,
195 int free,
196 int pub_event);
197
202void
204
224NONNULL_ARGS (1, 2)
226 const ZRegion * self,
227 MIDI_FILE * mf,
228 const bool add_region_start,
229 bool export_full);
230
240NONNULL void
242 const ZRegion * self,
243 const char * full_path,
244 int midi_version,
245 const bool export_full);
246
251uint8_t
253
258bool
260
275void
277 const ZRegion * self,
278 MidiEvents * events,
279 const Position * start,
280 const Position * end,
281 const bool add_region_start,
282 const bool full);
283
292void
294 const ZRegion * self,
295 const Position * start_pos,
296 const Position * end_pos,
297 Velocity *** velocities,
298 int * num_velocities,
299 size_t * velocities_size,
300 int inside);
301
307void
309
314#endif // __AUDIO_MIDI_REGION_H__
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
ZRegion * 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.
MidiNote * midi_region_get_lowest_midi_note(ZRegion *region)
Gets lowest midi note.
OPTIMIZE_O3 REALTIME void midi_region_fill_midi_events(ZRegion *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.
void midi_region_start_unended_note(ZRegion *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 ZRegion::midi_notes.
void midi_region_get_velocities_in_range(const ZRegion *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.
void midi_region_remove_midi_note(ZRegion *region, MidiNote *midi_note, int free, int pub_event)
Removes the MIDI note from the Region.
MidiNote * midi_region_get_last_midi_note(ZRegion *region)
Gets last midi note.
uint8_t midi_region_get_midi_ch(const ZRegion *self)
Returns the MIDI channel that this region should be played on, starting from 1.
MidiNote * midi_region_pop_unended_note(ZRegion *self, int pitch)
Returns the midi note with the given pitch from the unended notes.
NONNULL void midi_region_export_to_midi_file(const ZRegion *self, const char *full_path, int midi_version, const bool export_full)
Exports the ZRegion to a specified MIDI file.
void midi_region_free_members(ZRegion *self)
Frees members only but not the midi region itself.
void midi_region_insert_midi_note(ZRegion *region, MidiNote *midi_note, int idx, int pub_events)
Inserts the MidiNote to the given ZRegion.
MidiNote * midi_region_get_first_midi_note(ZRegion *region)
Gets first midi note.
void midi_region_print_midi_notes(ZRegion *self)
Prints the MidiNotes in the Region.
void midi_region_add_events(const ZRegion *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.
MidiNote * midi_region_get_highest_midi_note(ZRegion *region)
Gets highest midi note.
void midi_region_remove_all_midi_notes(ZRegion *region)
Removes all MIDI ntoes and their components completely.
void midi_region_write_to_midi_file(const ZRegion *self, MIDI_FILE *mf, const bool add_region_start, bool export_full)
Exports the ZRegion to an existing MIDI file instance.
bool midi_region_is_note_playable(const ZRegion *self, const MidiNote *midi_note)
Returns whether the given note is not muted and starts within any playable part of the region.
ZRegion * 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.
ZRegion * 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 ZRegion for MIDI notes.
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:138
Container for passing midi events through ports.
Definition midi_event.h:68
A MIDI note inside a ZRegion shown in the piano roll.
Definition midi_note.h:49
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:126
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
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72
Custom types.