mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 17:17:40 +02:00
Clarify the logic for drop of channels during playback
This commit is contained in:
parent
35f5555216
commit
bba16b3b37
@ -4872,47 +4872,31 @@ int AudioIO::AudioCallback(const void *inputBuffer, void *outputBuffer,
|
|||||||
numSolo++;
|
numSolo++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
auto dropTrack = [&] ( const WaveTrack &wt ) {
|
||||||
// MOVE_TO: CountDroppedTracks() function
|
return mPaused || (!wt.GetSolo() && (
|
||||||
bool dropAllQuickly = true; //i.e. drop all channels, without any fade out.
|
|
||||||
for (unsigned t = 0; t < numPlaybackTracks; t++)
|
|
||||||
{
|
|
||||||
WaveTrack *vt = mPlaybackTracks[t].get();
|
|
||||||
bool drop = false;
|
|
||||||
bool dropQuickly = false;
|
|
||||||
bool linkFlag = false;
|
|
||||||
|
|
||||||
if (linkFlag) {
|
|
||||||
linkFlag = false;
|
|
||||||
if (vt->GetChannelIgnoringPan() == Track::LeftChannel)
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(0) == 0.0);
|
|
||||||
if (vt->GetChannelIgnoringPan() == Track::RightChannel )
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(1) == 0.0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
drop = mPaused;
|
|
||||||
dropQuickly = false;
|
|
||||||
|
|
||||||
// Cut if somebody else is soloing
|
// Cut if somebody else is soloing
|
||||||
if (numSolo>0 && !vt->GetSolo())
|
numSolo > 0 ||
|
||||||
drop = true;
|
// Cut if we're muted (and not soloing)
|
||||||
|
wt.GetMute()
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
// Cut if we're muted (unless we're soloing)
|
auto doneMicrofading = [&] ( const WaveTrack &wt ) {
|
||||||
if (vt->GetMute() && !vt->GetSolo())
|
const auto channel = wt.GetChannelIgnoringPan();
|
||||||
drop = true;
|
if ((channel == Track::LeftChannel || channel == Track::MonoChannel) &&
|
||||||
|
wt.GetOldChannelGain(0) != 0.0)
|
||||||
|
return false;
|
||||||
|
if ((channel == Track::RightChannel || channel == Track::MonoChannel) &&
|
||||||
|
wt.GetOldChannelGain(1) != 0.0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
linkFlag = vt->GetLinked();
|
const bool dropAllQuickly = std::all_of(
|
||||||
|
mPlaybackTracks.begin(), mPlaybackTracks.end(),
|
||||||
dropQuickly = drop;
|
[&]( const std::shared_ptr< WaveTrack > &vt )
|
||||||
if (vt->GetChannelIgnoringPan() == Track::LeftChannel ||
|
{ return dropTrack( *vt ) && doneMicrofading( *vt ); }
|
||||||
vt->GetChannelIgnoringPan() == Track::MonoChannel )
|
);
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(0) == 0.0);
|
|
||||||
if (vt->GetChannelIgnoringPan() == Track::RightChannel ||
|
|
||||||
vt->GetChannelIgnoringPan() == Track::MonoChannel )
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(1) == 0.0);
|
|
||||||
}
|
|
||||||
dropAllQuickly = dropAllQuickly && dropQuickly;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a quick route, when paused and already at zero level on all channels.
|
// This is a quick route, when paused and already at zero level on all channels.
|
||||||
// However, we always fade-out into a pause, hence the 'dropAllQuickly' test
|
// However, we always fade-out into a pause, hence the 'dropAllQuickly' test
|
||||||
@ -4960,9 +4944,6 @@ int AudioIO::AudioCallback(const void *inputBuffer, void *outputBuffer,
|
|||||||
// - Applying a linearly interpolated gain.
|
// - Applying a linearly interpolated gain.
|
||||||
// I would expect us not to need the fast paths, since linearly interpolated gain
|
// I would expect us not to need the fast paths, since linearly interpolated gain
|
||||||
// is very cheap to process.
|
// is very cheap to process.
|
||||||
bool drop = false;
|
|
||||||
bool dropQuickly = false;
|
|
||||||
bool linkFlag = false;
|
|
||||||
|
|
||||||
float *outputFloats = (float *)outputBuffer;
|
float *outputFloats = (float *)outputBuffer;
|
||||||
for( unsigned i = 0; i < framesPerBuffer*numPlaybackChannels; i++)
|
for( unsigned i = 0; i < framesPerBuffer*numPlaybackChannels; i++)
|
||||||
@ -5009,50 +4990,32 @@ int AudioIO::AudioCallback(const void *inputBuffer, void *outputBuffer,
|
|||||||
const auto toGet =
|
const auto toGet =
|
||||||
std::min<size_t>(framesPerBuffer, GetCommonlyReadyPlayback());
|
std::min<size_t>(framesPerBuffer, GetCommonlyReadyPlayback());
|
||||||
|
|
||||||
|
bool drop = false;
|
||||||
|
bool dropQuickly = false;
|
||||||
|
bool linkFlag = false;
|
||||||
for (unsigned t = 0; t < numPlaybackTracks; t++)
|
for (unsigned t = 0; t < numPlaybackTracks; t++)
|
||||||
{
|
{
|
||||||
WaveTrack *vt = mPlaybackTracks[t].get();
|
WaveTrack *vt = mPlaybackTracks[t].get();
|
||||||
|
|
||||||
chans[chanCnt] = vt;
|
chans[chanCnt] = vt;
|
||||||
|
|
||||||
if (linkFlag) {
|
if ( linkFlag ) {
|
||||||
linkFlag = false;
|
linkFlag = false;
|
||||||
if (vt->GetChannelIgnoringPan() == Track::LeftChannel)
|
dropQuickly = dropQuickly && doneMicrofading( *vt );
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(0) == 0.0);
|
|
||||||
if (vt->GetChannelIgnoringPan() == Track::RightChannel )
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(1) == 0.0);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drop = mPaused;
|
drop = dropTrack( *vt );
|
||||||
dropQuickly = false;
|
|
||||||
|
|
||||||
// Cut if somebody else is soloing
|
|
||||||
if (numSolo>0 && !vt->GetSolo())
|
|
||||||
drop = true;
|
|
||||||
|
|
||||||
// Cut if we're muted (unless we're soloing)
|
|
||||||
if (vt->GetMute() && !vt->GetSolo())
|
|
||||||
drop = true;
|
|
||||||
|
|
||||||
linkFlag = vt->GetLinked();
|
linkFlag = vt->GetLinked();
|
||||||
selected = vt->GetSelected();
|
selected = vt->GetSelected();
|
||||||
|
|
||||||
// If we have a mono track, clear the right channel
|
// If we have a mono track, clear the right channel
|
||||||
if (!linkFlag)
|
if (!linkFlag)
|
||||||
{
|
|
||||||
memset(tempBufs[1], 0, framesPerBuffer * sizeof(float));
|
memset(tempBufs[1], 0, framesPerBuffer * sizeof(float));
|
||||||
}
|
|
||||||
|
|
||||||
dropQuickly = drop;
|
dropQuickly = drop && doneMicrofading( *vt );
|
||||||
if (vt->GetChannelIgnoringPan() == Track::LeftChannel ||
|
|
||||||
vt->GetChannelIgnoringPan() == Track::MonoChannel )
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(0) == 0.0);
|
|
||||||
if (vt->GetChannelIgnoringPan() == Track::RightChannel ||
|
|
||||||
vt->GetChannelIgnoringPan() == Track::MonoChannel )
|
|
||||||
dropQuickly = dropQuickly && (vt->GetOldChannelGain(1) == 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define ORIGINAL_DO_NOT_PLAY_ALL_MUTED_TRACKS_TO_END
|
#define ORIGINAL_DO_NOT_PLAY_ALL_MUTED_TRACKS_TO_END
|
||||||
#ifdef ORIGINAL_DO_NOT_PLAY_ALL_MUTED_TRACKS_TO_END
|
#ifdef ORIGINAL_DO_NOT_PLAY_ALL_MUTED_TRACKS_TO_END
|
||||||
decltype(framesPerBuffer) len = 0;
|
decltype(framesPerBuffer) len = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user