mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-24 23:33:50 +02:00
Track.cpp does not depend directly on its subclasses
This commit is contained in:
@@ -248,9 +248,14 @@ std::unique_ptr<Mixer> ExportPlugin::CreateMixer(const TrackList &tracks,
|
||||
double outRate, sampleFormat outFormat,
|
||||
bool highQuality, MixerSpec *mixerSpec)
|
||||
{
|
||||
const WaveTrackConstArray inputTracks =
|
||||
tracks.GetWaveTrackConstArray(selectionOnly, false);
|
||||
const TimeTrack *timeTrack = tracks.GetTimeTrack();
|
||||
WaveTrackConstArray inputTracks;
|
||||
auto range = tracks.Any< const WaveTrack >()
|
||||
+ (selectionOnly ? &Track::IsSelected : &Track::Any )
|
||||
- &WaveTrack::GetMute;
|
||||
for (auto pTrack: range)
|
||||
inputTracks.push_back(
|
||||
pTrack->SharedPointer< const WaveTrack >() );
|
||||
const auto timeTrack = *tracks.Any<const TimeTrack>().begin();
|
||||
auto envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
|
||||
// MB: the stop time should not be warped, this was a bug.
|
||||
return std::make_unique<Mixer>(inputTracks,
|
||||
|
||||
@@ -646,6 +646,57 @@ bool ExportMultiple::DirOk()
|
||||
return fn.Mkdir(0777, wxPATH_MKDIR_FULL);
|
||||
}
|
||||
|
||||
static unsigned GetNumExportChannels( const TrackList &tracks )
|
||||
{
|
||||
/* counters for tracks panned different places */
|
||||
int numLeft = 0;
|
||||
int numRight = 0;
|
||||
//int numMono = 0;
|
||||
/* track iteration kit */
|
||||
|
||||
// Want only unmuted wave tracks.
|
||||
for (auto tr :
|
||||
tracks.Any< const WaveTrack >() - &WaveTrack::GetMute
|
||||
) {
|
||||
// Found a left channel
|
||||
if (tr->GetChannel() == Track::LeftChannel) {
|
||||
numLeft++;
|
||||
}
|
||||
|
||||
// Found a right channel
|
||||
else if (tr->GetChannel() == Track::RightChannel) {
|
||||
numRight++;
|
||||
}
|
||||
|
||||
// Found a mono channel, but it may be panned
|
||||
else if (tr->GetChannel() == Track::MonoChannel) {
|
||||
float pan = tr->GetPan();
|
||||
|
||||
// Figure out what kind of channel it should be
|
||||
if (pan == -1.0) { // panned hard left
|
||||
numLeft++;
|
||||
}
|
||||
else if (pan == 1.0) { // panned hard right
|
||||
numRight++;
|
||||
}
|
||||
else if (pan == 0) { // panned dead center
|
||||
// numMono++;
|
||||
}
|
||||
else { // panned somewhere else
|
||||
numLeft++;
|
||||
numRight++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there is stereo content, report 2, else report 1
|
||||
if (numRight > 0 || numLeft > 0) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO: JKC July2016: Merge labels/tracks duplicated export code.
|
||||
// TODO: JKC Apr2019: Doubly so merge these! Too much duplication.
|
||||
ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
@@ -664,7 +715,7 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
}
|
||||
|
||||
// Figure out how many channels we should export.
|
||||
auto channels = mTracks->GetNumExportChannels(false);
|
||||
auto channels = GetNumExportChannels( *mTracks );
|
||||
|
||||
FilePaths otherNames; // keep track of file names we will use, so we
|
||||
// don't duplicate them
|
||||
|
||||
Reference in New Issue
Block a user