-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Audio types / stream properties / cue import #2601
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
829ec47
Add types for properties of PCM audio signals and streams
uklotzde b384921
Use new PCM audio property types
uklotzde dadc2ca
Get rid of the Janus-headed AudioSignal base class
uklotzde 64c884c
Defer import of CueInfo until stream properties are known
uklotzde c598edd
Fix wrong channel count for dual mono layout
uklotzde 32ef6c8
Add samples/frames/seconds/milliseconds conversion functions
uklotzde a166aa2
Improve documentation of basic audio types
uklotzde 3a1fcb3
Merge branch 'master' into audio_types
uklotzde 3a40b0a
Merge branch 'master' into audio_types
uklotzde 5407844
Clarify function usage comments
uklotzde c2bba36
Delete invalid debug assertion
uklotzde 2a44461
Move debug assertion into base class
uklotzde ffc51f1
Add typedefs for value_t
uklotzde 02e206c
Use "left-side const" according to coding style
uklotzde fed9a73
Set properties efficiently by passing a universal reference
uklotzde c8653f8
Merge branch 'master' of git@github.com:mixxxdj/mixxx.git into audio_…
uklotzde 2e00d5e
Merge branch 'master' into audio_types
uklotzde cfc3fa3
Fix wrong debug assertion
uklotzde 6d158e1
Merge branch 'master' of git@github.com:mixxxdj/mixxx.git into audio_…
uklotzde a3db3a3
Avoid string conversion for debug formatting
uklotzde 8b88fb3
Rename getter and corresponding member
uklotzde 2fec68c
Restore binding of replaygain_peak column
uklotzde 0a2b1cd
Initialize Rubberband internals in constructor
uklotzde 57cfe1e
Remove unused template declaration
uklotzde e3bd165
Replace template integer frame/sample counts with SINT
uklotzde 6d4160c
Add remarks about frame boundary alignment requirement
uklotzde 9c2e38c
Pre-allocate internal SoundTouch buffers in constructor
uklotzde 55c760e
Delete error prone and ambiguous legacy sample conversion funcs
uklotzde de3ed12
Update comment and add warning
uklotzde ceb4a6b
Fix typo
uklotzde e0e0d14
Add const/non-const ptr property accessors
uklotzde 23e6a11
Rename functions and members for importing CueInfos
uklotzde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include "audio/signalinfo.h" | ||
|
|
||
| namespace mixxx { | ||
|
|
||
| namespace audio { | ||
|
|
||
| bool operator==( | ||
| const SignalInfo& lhs, | ||
| const SignalInfo& rhs) { | ||
| return lhs.getChannelCount() == rhs.getChannelCount() && | ||
| lhs.getSampleLayout() == rhs.getSampleLayout() && | ||
| lhs.getSampleRate() == rhs.getSampleRate(); | ||
| } | ||
|
|
||
| QDebug | ||
| operator<<(QDebug dbg, const SignalInfo& arg) { | ||
| dbg << "SignalInfo{"; | ||
| arg.dbgChannelCount(dbg); | ||
| arg.dbgSampleLayout(dbg); | ||
| arg.dbgSampleRate(dbg); | ||
| dbg << '}'; | ||
| return dbg; | ||
| } | ||
|
|
||
| } // namespace audio | ||
|
|
||
| } // namespace mixxx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #pragma once | ||
|
|
||
| #include "audio/types.h" | ||
| #include "util/assert.h" | ||
| #include "util/macros.h" | ||
| #include "util/optional.h" | ||
|
|
||
| namespace mixxx { | ||
|
|
||
| namespace audio { | ||
|
|
||
| // Properties that characterize an uncompressed PCM audio signal. | ||
| class SignalInfo final { | ||
| // Properties | ||
| PROPERTY_SET_BYVAL_GET_BYREF(ChannelCount, channelCount, ChannelCount) | ||
| PROPERTY_SET_BYVAL_GET_BYREF(SampleRate, sampleRate, SampleRate) | ||
| PROPERTY_SET_BYVAL_GET_BYREF(OptionalSampleLayout, sampleLayout, SampleLayout) | ||
|
|
||
| public: | ||
| constexpr SignalInfo() = default; | ||
| constexpr explicit SignalInfo( | ||
| OptionalSampleLayout sampleLayout) | ||
| : m_sampleLayout(sampleLayout) { | ||
| } | ||
| SignalInfo( | ||
| ChannelCount channelCount, | ||
| SampleRate sampleRate, | ||
| OptionalSampleLayout sampleLayout = std::nullopt) | ||
| : m_channelCount(channelCount), | ||
| m_sampleRate(sampleRate), | ||
| m_sampleLayout(sampleLayout) { | ||
| } | ||
| SignalInfo(SignalInfo&&) = default; | ||
| SignalInfo(const SignalInfo&) = default; | ||
| /*non-virtual*/ ~SignalInfo() = default; | ||
|
|
||
| constexpr bool isValid() const { | ||
| return getChannelCount().isValid() && | ||
| getSampleLayout() && | ||
| getSampleRate().isValid(); | ||
| } | ||
|
|
||
| SignalInfo& operator=(SignalInfo&&) = default; | ||
| SignalInfo& operator=(const SignalInfo&) = default; | ||
|
|
||
| // Conversion: #samples / sample offset -> #frames / frame offset | ||
| // Only works for integer sample offsets on frame boundaries! | ||
| SINT samples2frames(SINT samples) const { | ||
| DEBUG_ASSERT(getChannelCount().isValid()); | ||
| DEBUG_ASSERT(0 == (samples % getChannelCount())); | ||
| return samples / getChannelCount(); | ||
| } | ||
|
|
||
| // Conversion: #frames / frame offset -> #samples / sample offset | ||
| SINT frames2samples(SINT frames) const { | ||
| DEBUG_ASSERT(getChannelCount().isValid()); | ||
| return frames * getChannelCount(); | ||
| } | ||
|
|
||
| // Conversion: #frames / frame offset -> second offset | ||
| double frames2secs(SINT frames) const { | ||
| DEBUG_ASSERT(getSampleRate().isValid()); | ||
| return static_cast<double>(frames) / getSampleRate(); | ||
| } | ||
|
|
||
| // Conversion: second offset -> #frames / frame offset | ||
| double secs2frames(double seconds) const { | ||
| DEBUG_ASSERT(getSampleRate().isValid()); | ||
| return seconds * getSampleRate(); | ||
| } | ||
|
|
||
| // Conversion: #frames / frame offset -> millisecond offset | ||
| double frames2millis(SINT frames) const { | ||
| return frames2secs(frames) * 1000; | ||
| } | ||
|
|
||
| // Conversion: millisecond offset -> #frames / frame offset | ||
| double millis2frames(double milliseconds) const { | ||
| return secs2frames(milliseconds / 1000); | ||
| } | ||
| }; | ||
|
|
||
| bool operator==( | ||
| const SignalInfo& lhs, | ||
| const SignalInfo& rhs); | ||
|
|
||
| inline bool operator!=( | ||
| const SignalInfo& lhs, | ||
| const SignalInfo& rhs) { | ||
| return !(lhs == rhs); | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug dbg, const SignalInfo& arg); | ||
|
|
||
| } // namespace audio | ||
|
|
||
| } // namespace mixxx | ||
|
|
||
| Q_DECLARE_METATYPE(mixxx::audio::SignalInfo) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include "audio/streaminfo.h" | ||
|
|
||
| namespace mixxx { | ||
|
|
||
| namespace audio { | ||
|
|
||
| bool operator==( | ||
| const StreamInfo& lhs, | ||
| const StreamInfo& rhs) { | ||
| return lhs.getSignalInfo() == rhs.getSignalInfo() && | ||
| lhs.getBitrate() == rhs.getBitrate() && | ||
| lhs.getDuration() == rhs.getDuration(); | ||
| } | ||
|
|
||
| QDebug | ||
| operator<<(QDebug dbg, const StreamInfo& arg) { | ||
|
uklotzde marked this conversation as resolved.
|
||
| dbg << "StreamInfo{"; | ||
| arg.dbgSignalInfo(dbg); | ||
| arg.dbgBitrate(dbg); | ||
| arg.dbgDuration(dbg); | ||
| dbg << '}'; | ||
| return dbg; | ||
| } | ||
|
|
||
| } // namespace audio | ||
|
|
||
| } // namespace mixxx | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #pragma once | ||
|
|
||
| #include "audio/signalinfo.h" | ||
| #include "util/duration.h" | ||
|
|
||
| namespace mixxx { | ||
|
|
||
| namespace audio { | ||
|
|
||
| // Properties that characterize a (compressed) PCM audio stream. | ||
| // | ||
| // Currently we assume that every stream has a finite duration | ||
| // that is known upfront! | ||
| class StreamInfo final { | ||
| // Properties | ||
| PROPERTY_SET_BYVAL_GET_BYREF(SignalInfo, signalInfo, SignalInfo) | ||
| PROPERTY_SET_BYVAL_GET_BYREF(Bitrate, bitrate, Bitrate) | ||
| PROPERTY_SET_BYVAL_GET_BYREF(Duration, duration, Duration) | ||
|
|
||
| public: | ||
| constexpr StreamInfo() = default; | ||
| constexpr explicit StreamInfo( | ||
| const SignalInfo& signalInfo) | ||
| : m_signalInfo(signalInfo) { | ||
| } | ||
| constexpr StreamInfo( | ||
| const SignalInfo& signalInfo, | ||
| Bitrate bitrate, | ||
| Duration duration) | ||
| : m_signalInfo(signalInfo), | ||
| m_bitrate(bitrate), | ||
| m_duration(duration) { | ||
| } | ||
| StreamInfo(StreamInfo&&) = default; | ||
| StreamInfo(const StreamInfo&) = default; | ||
| /*non-virtual*/ ~StreamInfo() = default; | ||
|
|
||
| constexpr bool isValid() const { | ||
| return getSignalInfo().isValid() && | ||
| getBitrate().isValid() && | ||
| (getDuration() > Duration::empty()); | ||
| } | ||
|
|
||
| StreamInfo& operator=(StreamInfo&&) = default; | ||
| StreamInfo& operator=(const StreamInfo&) = default; | ||
| }; | ||
|
|
||
| bool operator==( | ||
| const StreamInfo& lhs, | ||
| const StreamInfo& rhs); | ||
|
|
||
| inline bool operator!=( | ||
| const StreamInfo& lhs, | ||
| const StreamInfo& rhs) { | ||
| return !(lhs == rhs); | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug dbg, const StreamInfo& arg); | ||
|
|
||
| } // namespace audio | ||
|
|
||
| } // namespace mixxx | ||
|
|
||
| Q_DECLARE_METATYPE(mixxx::audio::StreamInfo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include "audio/types.h" | ||
|
|
||
| namespace mixxx { | ||
|
|
||
| namespace audio { | ||
|
|
||
| QDebug operator<<(QDebug dbg, ChannelLayout arg) { | ||
| switch (arg) { | ||
| case ChannelLayout::Mono: | ||
| return dbg << "Mono"; | ||
| case ChannelLayout::DualMono: | ||
| return dbg << "DualMono"; | ||
| case ChannelLayout::Stereo: | ||
| return dbg << "Stereo"; | ||
| } | ||
| DEBUG_ASSERT(!"unreachable code"); | ||
| return dbg; | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug dbg, SampleLayout arg) { | ||
| switch (arg) { | ||
| case SampleLayout::Planar: | ||
| return dbg << "Planar"; | ||
| case SampleLayout::Interleaved: | ||
| return dbg << "Interleaved"; | ||
| } | ||
| DEBUG_ASSERT(!"unreachable code"); | ||
| return dbg; | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug dbg, SampleRate arg) { | ||
| return dbg | ||
| << static_cast<SampleRate::value_t>(arg) | ||
| << SampleRate::unit(); | ||
| } | ||
|
|
||
| QDebug operator<<(QDebug dbg, Bitrate arg) { | ||
| return dbg | ||
| << static_cast<Bitrate::value_t>(arg) | ||
| << Bitrate::unit(); | ||
| } | ||
|
|
||
| } // namespace audio | ||
|
|
||
| } // namespace mixxx |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.