Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_note.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_MIDI_NOTE_H__
11#define __AUDIO_MIDI_NOTE_H__
12
13#include <stdint.h>
14
15#include "dsp/midi_region.h"
16#include "dsp/position.h"
17#include "dsp/velocity.h"
19
20typedef struct _MidiNoteWidget MidiNoteWidget;
21typedef struct Channel Channel;
22typedef struct Track Track;
23typedef struct MidiEvents MidiEvents;
24typedef struct Position Position;
25typedef struct Velocity Velocity;
26typedef enum PianoRollNoteNotation PianoRollNoteNotation;
27
34#define MIDI_NOTE_SCHEMA_VERSION 1
35
36#define MIDI_NOTE_MAGIC 3588791
37#define IS_MIDI_NOTE(tr) \
38 ((MidiNote *) tr && ((MidiNote *) tr)->magic == MIDI_NOTE_MAGIC)
39
40#define midi_note_is_selected(r) \
41 arranger_object_is_selected ((ArrangerObject *) r)
42
48typedef struct MidiNote
49{
52
55
57 uint8_t val;
58
60 uint8_t cache_val;
61
63 int muted;
64
68
72
74 int pos;
75
76 int magic;
77
79 PangoLayout * layout;
80} MidiNote;
81
88void
90
96 RegionIdentifier * region_id,
97 Position * start_pos,
98 Position * end_pos,
99 uint8_t val,
100 uint8_t vel);
101
105void
107
108void
109midi_note_set_cache_val (MidiNote * self, const uint8_t val);
110
114NONNULL PURE int
116
123void
125 const MidiNote * self,
126 char * buf,
127 PianoRollNoteNotation notation,
128 const int use_markup);
129
133void
135
142void
143midi_note_listen (MidiNote * mn, bool listen);
144
150void
151midi_note_shift_pitch (MidiNote * self, const int delta);
152
156int
157midi_note_hit (MidiNote * self, const signed_frame_t gframes);
158
167void
169 MidiNote ** midi_notes,
170 int num_notes,
171 Position * pos,
172 MidiEvents * events);
173
178void
179midi_note_set_val (MidiNote * midi_note, const uint8_t val);
180
181ZRegion *
182midi_note_get_region (MidiNote * self);
183
188#endif // __AUDIO_MIDI_NOTE_H__
Macros for arranger object backends.
Velocities for MidiNote's.
void midi_note_listen(MidiNote *mn, bool listen)
Listen to the given MidiNote.
int midi_note_hit(MidiNote *self, const signed_frame_t gframes)
Returns if the MIDI note is hit at given pos (in the timeline).
void midi_note_notes_to_events(MidiNote **midi_notes, int num_notes, Position *pos, MidiEvents *events)
Converts an array of MIDI notes to MidiEvents.
NONNULL PURE int midi_note_is_equal(MidiNote *src, MidiNote *dest)
Returns 1 if the MidiNotes match, 0 if not.
void midi_note_shift_pitch(MidiNote *self, const int delta)
Shifts MidiNote's position and/or value.
MidiNote * midi_note_new(RegionIdentifier *region_id, Position *start_pos, Position *end_pos, uint8_t val, uint8_t vel)
Creates a new MidiNote.
void midi_note_set_region_and_index(MidiNote *self, ZRegion *region, int idx)
Sets the region the MidiNote belongs to.
void midi_note_get_val_as_string(const MidiNote *self, char *buf, PianoRollNoteNotation notation, const int use_markup)
Gets the MIDI note's value as a string (eg "C#4").
void midi_note_print(MidiNote *mn)
For debugging.
void midi_note_get_global_start_pos(MidiNote *self, Position *pos)
Gets the global Position of the MidiNote's start_pos.
void midi_note_set_val(MidiNote *midi_note, const uint8_t val)
Sends a note off if currently playing and sets the pitch of the MidiNote.
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:55
API for Region's specific to instrument Track's.
Position struct and API.
Base struct for arranger objects.
A Channel is part of a Track (excluding Tracks that don't have Channels) and contains information rel...
Definition channel.h:61
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
uint8_t last_listened_val
The note/pitch that is currently playing, if MidiNote::currently_listened is true.
Definition midi_note.h:71
Velocity * vel
Velocity.
Definition midi_note.h:54
int muted
Muted or not.
Definition midi_note.h:63
uint8_t cache_val
Cached note, for live operations.
Definition midi_note.h:60
uint8_t val
The note/pitch, (0-127).
Definition midi_note.h:57
PangoLayout * layout
Cache layout for drawing the name.
Definition midi_note.h:79
int pos
Index in the parent region.
Definition midi_note.h:74
ArrangerObject base
Base struct.
Definition midi_note.h:51
int currently_listened
Whether or not this note is currently listened to.
Definition midi_note.h:67
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:129
Index/identifier for a Region, so we can get Region objects quickly with it without searching by name...
Track to be inserted into the Project's Tracklist.
Definition track.h:186
The MidiNote velocity.
Definition velocity.h:43
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:77