12namespace tracktion {
inline namespace engine
47 return static_cast<LaunchQType
> (index);
54 assert (t >= LaunchQType::none || t <= LaunchQType::sixtyFourthD);
60 assert (q >= LaunchQType::none || q <= LaunchQType::sixtyFourthD);
62 constexpr auto dot = 1.5;
63 constexpr auto triplet = 2.0 / 3.0;
67 case LaunchQType::eightBars:
return 8.0;
68 case LaunchQType::fourBars:
return 4.0;
69 case LaunchQType::twoBars:
return 2.0;
70 case LaunchQType::bar:
return 1.0;
71 case LaunchQType::halfT:
return 1.0 / 2.0 * triplet;
72 case LaunchQType::half:
return 1.0 / 2.0;
73 case LaunchQType::halfD:
return 1.0 / 2.0 * dot;
74 case LaunchQType::quarterT:
return 1.0 / 4.0 * triplet;
75 case LaunchQType::quarter:
return 1.0 / 4.0;
76 case LaunchQType::quarterD:
return 1.0 / 4.0 * dot;
77 case LaunchQType::eighthT:
return 1.0 / 8.0 * triplet;
78 case LaunchQType::eighth:
return 1.0 / 8.0;
79 case LaunchQType::eighthD:
return 1.0 / 8.0 * dot;
80 case LaunchQType::sixteenthT:
return 1.0 / 16.0 * triplet;
81 case LaunchQType::sixteenth:
return 1.0 / 16.0;
82 case LaunchQType::sixteenthD:
return 1.0 / 16.0 * dot;
83 case LaunchQType::thirtySecondT:
return 1.0 / 32.0 * triplet;
84 case LaunchQType::thirtySecond:
return 1.0 / 32.0;
85 case LaunchQType::thirtySecondD:
return 1.0 / 32.0 * dot;
86 case LaunchQType::sixtyFourthT:
return 1.0 / 64.0 * triplet;
87 case LaunchQType::sixtyFourth:
return 1.0 / 64.0;
88 case LaunchQType::sixtyFourthD:
return 1.0 / 64.0 * dot;
89 case LaunchQType::none:
return 0.0;
98 auto ret = LaunchQType::bar;
100 magic_enum::enum_for_each<LaunchQType> ([f, &ret] (
auto t)
114 constexpr auto adjustment = 1.0 - 1.0e-10;
116 if (q == LaunchQType::none)
120 auto barsBeats = ts.toBarsAndBeats (ts.toTime (pos));
122 if (q <= LaunchQType::bar)
124 auto barsPlusBeats = barsBeats.bars + (barsBeats.beats.inBeats() / barsBeats.numerator);
126 barsBeats.bars =
static_cast<int> (qFraction * (
int)
std::floor (barsPlusBeats / qFraction + adjustment));
127 barsBeats.beats = {};
131 barsBeats.beats = BeatDuration::fromBeats (qFraction *
std::floor ((barsBeats.beats.inBeats() / qFraction) + adjustment));
133 return ts.toBeats (barsBeats);
138 return getNext (q, ts.getInternalSequence(), pos);
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
The Tracktion Edit class!
juce::UndoManager & getUndoManager() noexcept
Returns the juce::UndoManager used for this Edit.
LaunchQuantisation(juce::ValueTree &, Edit &)
Creates a LaunchQuantisation property on a given state tree.
BeatPosition getNext(BeatPosition) const noexcept
Returns the next beat quantised to the current type.
juce::CachedValue< LaunchQType > type
The current type property.
Holds a list of TempoSetting objects, to form a sequence of tempo changes.
#define NEEDS_TRANS(stringLiteral)
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
bool isPositiveAndNotGreaterThan(Type1 valueToTest, Type2 upperLimit) noexcept
juce::String getName(LaunchQType t)
Retuns the name of a LaunchQType for display purposes.
double toBarFraction(LaunchQType q) noexcept
Returns the fraction of a bar to be used for a given rate type.
BeatPosition getNext(LaunchQType q, const tempo::Sequence &ts, BeatPosition pos) noexcept
Returns the next quantised position.
std::optional< LaunchQType > launchQTypeFromName(const juce::String &name)
Returns a the launch Q from a string returned from getLaunchQTypeChoices().
LaunchQType fromBarFraction(double f) noexcept
Returns the fraction of a bar to be used for a given rate type.
juce::StringArray getLaunchQTypeChoices()
Returns a list of quantisation type options in the order of LaunchQType.
Represents a position in beats.