mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-03 17:39:25 +02:00
Change procedure to choose append-record tracks once again...
... Allow recording stereo into non-adjacent mono tracks, if they are selected. Prefer the earliest-starting set of tracks in the track list, among either selected tracks, or else among all tracks. Therefore if selection contains a mono, a stereo, and a mono in that order, the two monos may be chosen to record new stereo.
This commit is contained in:
parent
473a92d28f
commit
bbcd924371
@ -1023,12 +1023,11 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
double allt0 = t0;
|
double allt0 = t0;
|
||||||
|
|
||||||
using Candidates = std::vector<WaveTrack*>;
|
using Candidates = std::vector<WaveTrack*>;
|
||||||
Candidates candidates, selectedCandidates;
|
Candidates *candidates{};
|
||||||
auto addCandidates = [&](Candidates &candidates, WaveTrack *candidate){
|
Candidates greedy, best;
|
||||||
if (candidates.size() == recordingChannels)
|
Candidates selectedGreedy, selectedBest;
|
||||||
// nothing left to do
|
auto addCandidates = [&](Candidates &greedy, Candidates &best,
|
||||||
return;
|
WaveTrack *candidate){
|
||||||
|
|
||||||
if (candidate->GetLink() && !candidate->GetLinked())
|
if (candidate->GetLink() && !candidate->GetLinked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1042,18 +1041,25 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
|
? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
|
||||||
++nChannels;
|
++nChannels;
|
||||||
|
|
||||||
// Accumulate consecutive single channel tracks, or else one track of
|
// Greedy looks either for a single best-fit or for enough mono
|
||||||
// the exact number of channels
|
// channels, even if we choose more
|
||||||
if (nChannels > 1)
|
// than one and they are not successive, but this partially accumulated
|
||||||
candidates.clear();
|
// result might not become complete
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (nChannels == 1 || // <- comment this out to disallow recording
|
// Best-fit looks for the exact number of channels in one place
|
||||||
// stereo into two adjacent mono tracks
|
if (best.empty() &&
|
||||||
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)
|
||||||
candidates.push_back(channel);
|
best.push_back(channel);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (appendRecord) {
|
if (appendRecord) {
|
||||||
@ -1068,9 +1074,9 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
if (wt->GetEndTime() > allt0) {
|
if (wt->GetEndTime() > allt0) {
|
||||||
allt0 = wt->GetEndTime();
|
allt0 = wt->GetEndTime();
|
||||||
}
|
}
|
||||||
addCandidates( candidates, wt );
|
addCandidates( greedy, best, wt );
|
||||||
if (wt->GetSelected())
|
if (wt->GetSelected())
|
||||||
addCandidates( selectedCandidates, wt );
|
addCandidates( selectedGreedy, selectedBest, wt );
|
||||||
if (wt->GetSelected()) {
|
if (wt->GetSelected()) {
|
||||||
if (wt->GetEndTime() > t0) {
|
if (wt->GetEndTime() > t0) {
|
||||||
t0 = wt->GetEndTime();
|
t0 = wt->GetEndTime();
|
||||||
@ -1079,26 +1085,40 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// candidate null implies selectedCandidate also null
|
// Which tracks will be appended?
|
||||||
if( candidates.empty() )
|
// First, prefer selected to non-selected if we can. Then,
|
||||||
|
// 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 :
|
for (auto channel : *candidates)
|
||||||
selectedCandidates.empty() ? candidates : selectedCandidates)
|
|
||||||
{
|
{
|
||||||
auto wt = Track::Pointer<WaveTrack>(channel);
|
auto wt = Track::Pointer<WaveTrack>(channel);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user