1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00

Revert "Change procedure to choose append-record tracks once again..."

This reverts commit bbcd924371326692d849480895dfa83171b17515.
This commit is contained in:
Paul Licameli 2018-04-09 22:33:03 -04:00
parent bbcd924371
commit 1c751fd863

View File

@ -1023,11 +1023,12 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
double allt0 = t0; double allt0 = t0;
using Candidates = std::vector<WaveTrack*>; using Candidates = std::vector<WaveTrack*>;
Candidates *candidates{}; Candidates candidates, selectedCandidates;
Candidates greedy, best; auto addCandidates = [&](Candidates &candidates, WaveTrack *candidate){
Candidates selectedGreedy, selectedBest; if (candidates.size() == recordingChannels)
auto addCandidates = [&](Candidates &greedy, Candidates &best, // nothing left to do
WaveTrack *candidate){ return;
if (candidate->GetLink() && !candidate->GetLinked()) if (candidate->GetLink() && !candidate->GetLinked())
return; return;
@ -1041,25 +1042,18 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
? static_cast<WaveTrack*>(channel->GetLink()) : nullptr) ? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
++nChannels; ++nChannels;
// Greedy looks either for a single best-fit or for enough mono // Accumulate consecutive single channel tracks, or else one track of
// channels, even if we choose more // the exact number of channels
// than one and they are not successive, but this partially accumulated if (nChannels > 1)
// result might not become complete candidates.clear();
if (greedy.size() + nChannels <= recordingChannels &&
( nChannels == 1 || nChannels == recordingChannels )) {
for (auto channel = candidate; channel;
channel = channel->GetLinked()
? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
greedy.push_back(channel);
}
// Best-fit looks for the exact number of channels in one place if (nChannels == 1 || // <- comment this out to disallow recording
if (best.empty() && // stereo into two adjacent mono tracks
nChannels == recordingChannels) { nChannels == recordingChannels) {
for (auto channel = candidate; channel; for (auto channel = candidate; channel;
channel = channel->GetLinked() channel = channel->GetLinked()
? static_cast<WaveTrack*>(channel->GetLink()) : nullptr) ? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
best.push_back(channel); candidates.push_back(channel);
} }
}; };
if (appendRecord) { if (appendRecord) {
@ -1074,9 +1068,9 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
if (wt->GetEndTime() > allt0) { if (wt->GetEndTime() > allt0) {
allt0 = wt->GetEndTime(); allt0 = wt->GetEndTime();
} }
addCandidates( greedy, best, wt ); addCandidates( candidates, wt );
if (wt->GetSelected()) if (wt->GetSelected())
addCandidates( selectedGreedy, selectedBest, wt ); addCandidates( selectedCandidates, wt );
if (wt->GetSelected()) { if (wt->GetSelected()) {
if (wt->GetEndTime() > t0) { if (wt->GetEndTime() > t0) {
t0 = wt->GetEndTime(); t0 = wt->GetEndTime();
@ -1085,40 +1079,26 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
} }
} }
// Which tracks will be appended? // candidate null implies selectedCandidate also null
// First, prefer selected to non-selected if we can. Then, if( candidates.empty() )
// if enough were found the "greedy" way, and they may begin earlier
// in the track list than the "best," prefer them
if (selectedGreedy.size() == recordingChannels)
candidates = &selectedGreedy;
else if (!selectedBest.empty())
candidates = &selectedBest;
if (!candidates) {
// if (greedy.size() == recordingChannels)
// candidates = &greedy;
// else
if (!best.empty())
candidates = &best;
if (candidates) {
// t0 is now: max(selection-start, end-of-selected-wavetracks)
// allt0 is: max(selection-start, end-of-all-tracks)
// Use end time of all wave tracks if none selected
t0 = allt0;
}
}
if( !candidates )
appendRecord = false; appendRecord = false;
} }
if (appendRecord) { if (appendRecord) {
// t0 is now: max(selection-start, end-of-selected-wavetracks)
// allt0 is: max(selection-start, end-of-all-tracks)
// Use end time of all wave tracks if none selected
if (selectedCandidates.empty()) {
t0 = allt0;
}
// Append recording: // Append recording:
// Pad selected/all wave tracks to make them all the same length // Pad selected/all wave tracks to make them all the same length
// Remove recording tracks from the list of tracks for duplex ("overdub") // Remove recording tracks from the list of tracks for duplex ("overdub")
// playback. // playback.
for (auto channel : *candidates) for (auto channel :
selectedCandidates.empty() ? candidates : selectedCandidates)
{ {
auto wt = Track::Pointer<WaveTrack>(channel); auto wt = Track::Pointer<WaveTrack>(channel);