Skip to content

Commit

Permalink
Fix crash if stereo mixing was interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
kryksyh committed Oct 24, 2024
1 parent f7af870 commit 63e79a8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &)
(WaveChannelView::GetFirst(*left).GetHeight() +
WaveChannelView::GetFirst(*right).GetHeight()) / 2;

float origPanLeft = left->GetPan();
float origPanRight = right->GetPan();

left->SetPan(-1.0f);
right->SetPan(1.0f);
auto mix = MixAndRender(
Expand All @@ -824,6 +827,13 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &)
std::max(left->GetSampleFormat(), right->GetSampleFormat()),
0.0, 0.0);

if (!mix)
{
left->SetPan(origPanLeft);
right->SetPan(origPanRight);
return;
}

tracks.Insert(*first, mix);
tracks.Remove(*left);
tracks.Remove(*right);
Expand Down

0 comments on commit 63e79a8

Please sign in to comment.