-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for stem in the engine #13070
Changes from 3 commits
584a6b6
db5a9c7
f69d191
bc852a8
690fa3d
905bce1
ccd8a22
f340b1b
d006b4b
9e13271
400d49e
0e61fec
2d831ae
f23f1b2
aebc327
991ee9e
329d89a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,16 +35,19 @@ class FramePos final { | |
/// Return a `FramePos` from a given engine sample position. To catch | ||
/// "invalid" positions (e.g. when parsing values from control objects), | ||
/// use `FramePos::fromEngineSamplePosMaybeInvalid` instead. | ||
static constexpr FramePos fromEngineSamplePos(double engineSamplePos) { | ||
return FramePos(engineSamplePos / mixxx::kEngineChannelCount); | ||
static constexpr FramePos fromEngineSamplePos(double engineSamplePos, | ||
mixxx::audio::ChannelCount channelCount = | ||
mixxx::kEngineChannelOutputCount) { | ||
return FramePos(engineSamplePos / channelCount); | ||
} | ||
|
||
/// Return an engine sample position. The `FramePos` is expected to be | ||
/// valid. If invalid positions are possible (e.g. for control object | ||
/// values), use `FramePos::toEngineSamplePosMaybeInvalid` instead. | ||
double toEngineSamplePos() const { | ||
double toEngineSamplePos(mixxx::audio::ChannelCount channelCount = | ||
mixxx::kEngineChannelOutputCount) const { | ||
DEBUG_ASSERT(isValid()); | ||
double engineSamplePos = value() * mixxx::kEngineChannelCount; | ||
double engineSamplePos = value() * channelCount; | ||
// In the rare but possible instance that the position is valid but | ||
// the engine sample position is exactly -1.0, we nudge the position | ||
// because otherwise fromEngineSamplePosMaybeInvalid() will think | ||
|
@@ -63,11 +66,14 @@ class FramePos final { | |
/// for compatibility with our control objects and legacy parts of the code | ||
/// base. Using a different code path based on the output of `isValid()` is | ||
/// preferable. | ||
static constexpr FramePos fromEngineSamplePosMaybeInvalid(double engineSamplePos) { | ||
static constexpr FramePos fromEngineSamplePosMaybeInvalid( | ||
double engineSamplePos, | ||
mixxx::audio::ChannelCount channelCount = | ||
mixxx::kEngineChannelOutputCount) { | ||
if (engineSamplePos == kLegacyInvalidEnginePosition) { | ||
return {}; | ||
} | ||
return fromEngineSamplePos(engineSamplePos); | ||
return fromEngineSamplePos(engineSamplePos, channelCount); | ||
} | ||
|
||
/// Return an engine sample position. If the `FramePos` is invalid, | ||
|
@@ -77,11 +83,13 @@ class FramePos final { | |
/// for compatibility with our control objects and legacy parts of the code | ||
/// base. Using a different code path based on the output of `isValid()` is | ||
/// preferable. | ||
double toEngineSamplePosMaybeInvalid() const { | ||
double toEngineSamplePosMaybeInvalid( | ||
mixxx::audio::ChannelCount channelCount = | ||
mixxx::kEngineChannelOutputCount) const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same here. pleas remove the parameter and probably introduce a new function for your use case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have introduced |
||
if (!isValid()) { | ||
return kLegacyInvalidEnginePosition; | ||
} | ||
return toEngineSamplePos(); | ||
return toEngineSamplePos(channelCount); | ||
} | ||
|
||
/// Return true if the frame position is valid. Any finite value is | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EngineSamplePos is the term for the fixes stereo assumption that is part of the database and the CO interface. This must not change and therefore this function must not have parameter.
Under the light of this PR, we may consider a new name for the function and a different name for the new use case.