1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

Remove SetLinked() and SetChannel() from importers

This commit is contained in:
Paul Licameli 2018-09-19 14:13:24 -04:00
parent 7e6a543473
commit 894f6f4f63
9 changed files with 13 additions and 125 deletions

View File

@ -4177,10 +4177,17 @@ AudacityProject::AddImportedTracks(const wxString &fileName,
// Must add all tracks first (before using Track::IsLeader)
for (auto &group : newTracks) {
if (group.empty()) {
wxASSERT(false);
continue;
}
auto first = group.begin()->get();
auto nChannels = group.size();
for (auto &uNewTrack : group) {
auto newTrack = mTracks->Add(std::move(uNewTrack));
results.push_back(Track::Pointer(newTrack));
}
mTracks->GroupChannels(*first, nChannels);
}
newTracks.clear();

View File

@ -523,31 +523,8 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
// There is a possibility that number of channels will change over time, but we do not have WaveTracks for NEW channels. Remember the number of channels and stick to it.
sc->m_initialchannels = sc->m_stream->codec->channels;
stream.resize(sc->m_stream->codec->channels);
int c = -1;
for (auto &channel : stream)
{
++c;
channel = trackFactory->NewWaveTrack(sc->m_osamplefmt, sc->m_stream->codec->sample_rate);
if (sc->m_stream->codec->channels == 2)
{
switch (c)
{
case 0:
channel->SetChannel(Track::LeftChannel);
channel->SetLinked(true);
break;
case 1:
channel->SetChannel(Track::RightChannel);
break;
}
}
else
{
channel->SetChannel(Track::MonoChannel);
}
}
}
// Handles the start_time by creating silence. This may or may not be correct.

View File

@ -455,25 +455,9 @@ ProgressResult FLACImportFileHandle::Import(TrackFactory *trackFactory,
mChannels.resize(mNumChannels);
auto iter = mChannels.begin();
for (size_t c = 0; c < mNumChannels; ++iter, ++c) {
for (size_t c = 0; c < mNumChannels; ++iter, ++c)
*iter = trackFactory->NewWaveTrack(mFormat, mSampleRate);
if (mNumChannels == 2) {
switch (c) {
case 0:
iter->get()->SetChannel(Track::LeftChannel);
iter->get()->SetLinked(true);
break;
case 1:
iter->get()->SetChannel(Track::RightChannel);
break;
}
}
else {
iter->get()->SetChannel(Track::MonoChannel);
}
}
//Start OD
bool useOD = false;

View File

@ -789,14 +789,6 @@ GStreamerImportFileHandle::OnNewSample(GStreamContext *c, GstSample *sample)
return;
}
}
// Set to stereo if there's exactly 2 channels
if (c->mNumChannels == 2)
{
c->mChannels[0]->SetChannel(Track::LeftChannel);
c->mChannels[1]->SetChannel(Track::RightChannel);
c->mChannels[0]->SetLinked(true);
}
}
// Get the buffer for the sample...no need to release

View File

@ -503,17 +503,9 @@ enum mad_flow output_cb(void *_data,
auto format = QualityPrefs::SampleFormatChoice();
for(auto &channel: data->channels) {
for(auto &channel: data->channels)
channel = data->trackFactory->NewWaveTrack(format, samplerate);
channel->SetChannel(Track::MonoChannel);
}
/* special case: 2 channels is understood to be stereo */
if(channels == 2) {
data->channels.begin()->get()->SetChannel(Track::LeftChannel);
data->channels.rbegin()->get()->SetChannel(Track::RightChannel);
data->channels.begin()->get()->SetLinked(true);
}
data->numChannels = channels;
}
else {

View File

@ -259,27 +259,8 @@ ProgressResult OggImportFileHandle::Import(
link.resize(vi->channels);
int c = -1;
for (auto &channel : link) {
++c;
for (auto &channel : link)
channel = trackFactory->NewWaveTrack(mFormat, vi->rate);
if (vi->channels == 2) {
switch (c) {
case 0:
channel->SetChannel(Track::LeftChannel);
channel->SetLinked(true);
break;
case 1:
channel->SetChannel(Track::RightChannel);
break;
}
}
else {
channel->SetChannel(Track::MonoChannel);
}
}
}
/* The number of bytes to get from the codec in each run */

View File

@ -367,26 +367,9 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory,
NewChannelGroup channels(mInfo.channels);
auto iter = channels.begin();
for (int c = 0; c < mInfo.channels; ++iter, ++c) {
for (int c = 0; c < mInfo.channels; ++iter, ++c)
*iter = trackFactory->NewWaveTrack(mFormat, mInfo.samplerate);
if (mInfo.channels > 1)
switch (c) {
case 0:
iter->get()->SetChannel(Track::LeftChannel);
break;
case 1:
iter->get()->SetChannel(Track::RightChannel);
break;
default:
iter->get()->SetChannel(Track::MonoChannel);
}
}
if (mInfo.channels == 2) {
channels.begin()->get()->SetLinked(true);
}
auto fileTotalFrames =
(sampleCount)mInfo.frames; // convert from sf_count_t
auto maxBlockSize = channels.begin()->get()->GetMaxBlockSize();

View File

@ -352,16 +352,6 @@ ProgressResult QTImportFileHandle::Import(TrackFactory *trackFactory,
channel = trackFactory->NewWaveTrack( format );
channel->SetRate( desc.mSampleRate );
if (numchan == 2) {
if (c == 0) {
channel->SetChannel(Track::LeftChannel);
channel->SetLinked(true);
}
else if (c == 1) {
channel->SetChannel(Track::RightChannel);
}
}
}
do {

View File

@ -205,28 +205,10 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
channels.resize(numChannels);
auto iter = channels.begin();
for (decltype(numChannels) c = 0; c < numChannels; ++iter, ++c) {
const auto channel =
(*iter = trackFactory->NewWaveTrack(format, rate)).get();
if (numChannels > 1)
switch (c) {
case 0:
channel->SetChannel(Track::LeftChannel);
break;
case 1:
channel->SetChannel(Track::RightChannel);
break;
default:
channel->SetChannel(Track::MonoChannel);
}
}
for (decltype(numChannels) c = 0; c < numChannels; ++iter, ++c)
*iter = trackFactory->NewWaveTrack(format, rate);
const auto firstChannel = channels.begin()->get();
if (numChannels == 2) {
firstChannel->SetLinked(true);
}
auto maxBlockSize = firstChannel->GetMaxBlockSize();
SampleBuffer srcbuffer(maxBlockSize * numChannels, format);