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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_QuantisationType.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
14//==============================================================================
18{
19public:
20 //==============================================================================
23 ~QuantisationType() override;
24
26 QuantisationType& operator= (const QuantisationType&);
27 bool operator== (const QuantisationType&) const;
28
29 void applyQuantisationToSequence (juce::MidiMessageSequence&, Edit&, TimePosition sequenceStartOffset);
30
31 //==============================================================================
33 bool isEnabled() const;
34
35 static juce::StringArray getAvailableQuantiseTypes (bool translated);
36 static juce::String getDefaultType (bool translated);
37
38 void setType (const juce::String& newTypeName) { typeName = newTypeName; }
39 juce::String getType (bool translated) const;
40
45 int getTimecodeSnapTypeLevel (bool& isTriplet) const noexcept;
46
48 float getProportion() const { return proportion; }
49 void setProportion (float prop);
50
54 bool isQuantisingNoteOffs() const { return quantiseNoteOffs; }
55 void setIsQuantisingNoteOffs (bool isQuantising) { quantiseNoteOffs = isQuantising; }
56
57 //==============================================================================
58 BeatPosition roundBeatToNearest (BeatPosition beatNumber) const;
59 BeatPosition roundBeatUp (BeatPosition beatNumber) const;
60 BeatPosition roundBeatToNearestNonZero (BeatPosition beatNumber) const;
61
62 TimePosition roundToNearest (TimePosition, const Edit&) const;
63 TimePosition roundUp (TimePosition, const Edit&) const;
64
65 juce::ValueTree state;
67 juce::CachedValue<float> proportion;
68 juce::CachedValue<bool> quantiseNoteOffs;
69
70private:
71 int typeIndex = 0;
72 double fractionOfBeat = 0;
73
74 void initialiseCachedValues (juce::UndoManager*);
75
76 void updateType();
77 void updateFraction();
78 TimePosition roundTo (TimePosition, double adjustment, const Edit&) const;
79 BeatPosition roundToBeat (BeatPosition beatNumber, double adjustment) const;
80
81 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
82 void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override {}
83 void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override {}
84 void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override {}
85 void valueTreeParentChanged (juce::ValueTree&) override {}
86};
87
88}} // namespace tracktion { inline namespace engine
The Tracktion Edit class!
bool isEnabled() const
this type may represent "no quantising"
float getProportion() const
the proportion 0..1 of the amount to quantise stuff by.
int getTimecodeSnapTypeLevel(bool &isTriplet) const noexcept
Returns the TimecodeSnapType level for the current quantisation type.
bool isQuantisingNoteOffs() const
If false, quantising a note on will keep the note its original length.
Represents a position in beats.
Represents a position in real-life time.