tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_MidiNote.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
15{
16public:
17 enum NoteEdge
18 {
19 startEdge,
20 endEdge
21 };
22
23 static juce::ValueTree createNote (const MidiNote&, BeatPosition newStart, BeatDuration newLength);
24
26 MidiNote (MidiNote&&) = default;
27
28 bool operator== (const MidiNote& other) const noexcept { return state == other.state; }
29 bool operator!= (const MidiNote& other) const noexcept { return state != other.state; }
30
31 //==============================================================================
33 BeatPosition getBeatPosition() const noexcept { return startBeat; }
34 BeatPosition getStartBeat() const noexcept { return startBeat; }
35 BeatPosition getEndBeat() const noexcept { return startBeat + lengthInBeats; }
36 BeatDuration getLengthBeats() const noexcept { return lengthInBeats; }
37 BeatRange getRangeBeats() const noexcept { return { getStartBeat(), getEndBeat() }; }
38
39 TimePosition getPlaybackTime (NoteEdge, const MidiClip&, const GrooveTemplate*) const;
40 BeatPosition getPlaybackBeats (NoteEdge, const MidiClip&, const GrooveTemplate*) const;
41
43 BeatPosition getQuantisedStartBeat (const MidiClip&) const;
44 BeatPosition getQuantisedStartBeat (const MidiClip*) const;
45
46 BeatPosition getQuantisedEndBeat (const MidiClip&) const;
47 BeatPosition getQuantisedEndBeat (const MidiClip*) const;
48
49 BeatDuration getQuantisedLengthBeats (const MidiClip&) const;
50 BeatDuration getQuantisedLengthBeats (const MidiClip*) const;
51
55 TimePosition getEditStartTime (const MidiClip&) const;
56 TimePosition getEditEndTime (const MidiClip&) const;
57
58 TimeDuration getLengthSeconds (const MidiClip&) const;
59 TimeRange getEditTimeRange (const MidiClip&) const;
60
61 void setStartAndLength (BeatPosition newStartBeat, BeatDuration newLengthInBeats, juce::UndoManager*);
62
63 int getNoteNumber() const noexcept { return (int) noteNumber; }
64 void setNoteNumber (int newNoteNumber, juce::UndoManager*);
65
66 int getVelocity() const noexcept { return (int) velocity; }
67 void setVelocity (int newVelocity, juce::UndoManager*);
68
69 int getColour() const noexcept { return (int) colour; }
70 void setColour (int newColourIndex, juce::UndoManager*);
71
72 bool isMute() const noexcept { return mute != 0; }
73 void setMute (bool shouldMute, juce::UndoManager*);
74
75 //==============================================================================
76 juce::ValueTree state;
77
78private:
79 //==============================================================================
80 friend class MidiList;
81 friend struct NoteChannelAssigner;
82
83 BeatPosition startBeat;
84 BeatDuration lengthInBeats;
85 uint8_t noteNumber, velocity, colour, mute;
86
87 void updatePropertiesFromState();
88
89 MidiNote() = delete;
90 MidiNote (const MidiNote&) = delete;
91
92 JUCE_LEAK_DETECTOR (MidiNote)
93};
94
95}} // namespace tracktion { inline namespace engine
BeatPosition getBeatPosition() const noexcept
Start pos, in beats, from the start of the clip.
BeatPosition getQuantisedStartBeat(const MidiClip &) const
Returns the start, quantised according to the clip's settings.
TimePosition getEditStartTime(const MidiClip &) const
Gets the start of this note in terms of edit time, taking into account quantising,...
#define JUCE_LEAK_DETECTOR(OwnerClass)
RangeType< BeatPosition > BeatRange
A RangeType based on beats.
RangeType< TimePosition > TimeRange
A RangeType based on real time (i.e.
typedef uint8_t
Represents a duration in beats.
Represents a position in beats.