Skip to content

Commit

Permalink
Automatic mixer strip management LMMS#1215 - applied review recommend…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
spechtstatt committed Jun 23, 2022
1 parent ebb01c0 commit 9a2f342
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
18 changes: 6 additions & 12 deletions src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ void Mixer::deleteChannel( int index )
Engine::audioEngine()->requestChangeInModel();


processAssignedTracks( [index](Track * track, IntModel * model, MixerChannel * channel)
processAssignedTracks( [index](Track *, IntModel * model, MixerChannel * )
{
(void) track;
(void) channel;
int curIndex = model->value(0);
if( curIndex == index )
{
Expand Down Expand Up @@ -369,7 +367,7 @@ IntModel * Mixer::getChannelModelByTrack(Track * track)
SampleTrack * strk = (SampleTrack *) track;
return strk->mixerChannelModel();
}
return NULL;
return nullptr;
}

bool Mixer::isAutoTrackLinkToggleAllowed(int index)
Expand All @@ -390,8 +388,8 @@ void Mixer::processAssignedTracks(std::function<void(Track * track, IntModel * m
for (Track* track: trackList)
{
IntModel * model = getChannelModelByTrack(track);
MixerChannel * channel = NULL;
if (model != NULL)
MixerChannel * channel = nullptr;
if (model != nullptr)
{
int channelIndex = model->value();
if (channelIndex > 0 && channelIndex < m_mixerChannels.size() )
Expand All @@ -406,10 +404,8 @@ void Mixer::processAssignedTracks(std::function<void(Track * track, IntModel * m
std::vector<int> Mixer::getUsedChannelCounts()
{
std::vector<int> used(m_mixerChannels.size(), 0);
processAssignedTracks([&used](Track * track, IntModel * model, MixerChannel * channel)
processAssignedTracks([&used](Track *, IntModel * model, MixerChannel *)
mutable {
(void) track;
(void) channel;
++used[model->value()];
});

Expand All @@ -435,10 +431,8 @@ void Mixer::swapChannels(int indexA, int indexB)
else if (m_lastSoloed == b) { m_lastSoloed = a; }

// go through every instrument and adjust for the channel index change
processAssignedTracks( [a,b](Track * track, IntModel * model, MixerChannel * channel)
processAssignedTracks( [a,b](Track *, IntModel * model, MixerChannel *)
{
(void) track;
(void) channel;
int curIndex = model->value(0);
if( curIndex == a )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MixerLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void MixerLine::mouseDoubleClickEvent( QMouseEvent * )
void MixerLine::contextMenuEvent( QContextMenuEvent * )
{
Mixer * mix = Engine::mixer();
QPointer<CaptionMenu> contextMenu = new CaptionMenu( mix->mixerChannel( m_channelIndex )->m_name, this );
CaptionMenu* contextMenu = new CaptionMenu( mix->mixerChannel( m_channelIndex )->m_name, this );
bool autoTrackLink = mix->mixerChannel( m_channelIndex )->m_autoTrackLinkModel.value();
if( m_channelIndex != 0 ) // no move-options in master
{
Expand Down
34 changes: 15 additions & 19 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void MixerView::updateAfterTrackAdd(Track * track, QString name)
// TODO: check if an autotrack mode is enabled (still missing)
Mixer * mix = Engine::mixer();
IntModel * model = mix->getChannelModelByTrack(track);
if ( model != NULL)
if ( model != nullptr)
{
int channelIndex = addNewChannel();
model->setValue( channelIndex );
Expand All @@ -196,7 +196,7 @@ void MixerView::updateAfterTrackStyleModify(Track * track)
{
Mixer * mix = Engine::mixer();
IntModel * model = mix->getChannelModelByTrack(track);
if (model != NULL)
if (model != nullptr)
{
int channelIndex = model->value();
if (channelIndex>0)
Expand All @@ -216,14 +216,14 @@ void MixerView::updateAfterTrackMixerLineModify(Track * track)
{
Mixer * mix = Engine::mixer();
IntModel * model = mix->getChannelModelByTrack(track);
if (model != NULL)
if (model != nullptr)
{
// check if there are more than one track pointing to the same mixer channel
// if yes disable the autotracklink
std::vector<bool> used(m_mixerChannelViews.size(), false);
bool needUpdate = false;
std::vector<int> usedChannelCounts = mix->getUsedChannelCounts();
for(unsigned long i = 0; i< usedChannelCounts.size();i++)
for(unsigned long i = 0; i < usedChannelCounts.size(); i++)
{
if (usedChannelCounts[i] == 0 || usedChannelCounts[i] > 1)
{
Expand All @@ -238,8 +238,8 @@ void MixerView::updateAfterTrackMixerLineModify(Track * track)
void MixerView::updateAfterTrackMove(Track * track)
{
Mixer * mix = Engine::mixer();
IntModel * model = Engine::mixer()->getChannelModelByTrack(track);
if (model != NULL)
IntModel * model = mix->getChannelModelByTrack(track);
if (model != nullptr)
{
int channelIndex = model->value();
if (channelIndex>0)
Expand All @@ -257,7 +257,7 @@ void MixerView::updateAfterTrackDelete(Track * track)
{
Mixer * mix = Engine::mixer();
IntModel * model = mix->getChannelModelByTrack(track);
if ( model != NULL)
if ( model != nullptr)
{
int channelIndex = model->value();
if (channelIndex>0)
Expand Down Expand Up @@ -308,10 +308,9 @@ void MixerView::updateAutoTrackSortOrder()
}

// add auto tracks in the order of the song tracks
mix->processAssignedTracks([&, list](Track * track, IntModel * model, MixerChannel * channel)
mix->processAssignedTracks([&, list](Track *, IntModel * model, MixerChannel * channel)
mutable {
(void) track;
if (channel == NULL) return;
if (channel == nullptr) return;
if (channel->m_autoTrackLinkModel.value())
{
list->append(model->value());
Expand Down Expand Up @@ -384,10 +383,8 @@ void MixerView::refreshDisplay()
void MixerView::updateMaxChannelSelector()
{
Mixer * mix = Engine::mixer();
mix->processAssignedTracks([this](Track * track, IntModel * model, MixerChannel * channel)
mix->processAssignedTracks([this](Track *, IntModel * model, MixerChannel *)
{
(void) track;
(void) channel;
model->setRange(0,m_mixerChannelViews.size()-1,1);
});
}
Expand Down Expand Up @@ -492,7 +489,7 @@ void MixerView::updateMixerLine(int index)
// does current channel send to this channel?
int selIndex = m_currentMixerLine->channelIndex();
MixerLine * thisLine = m_mixerChannelViews[index]->m_mixerLine;
thisLine->setToolTip( Engine::mixer()->mixerChannel( index )->m_name );
thisLine->setToolTip( mix->mixerChannel( index )->m_name );

FloatModel * sendModel = mix->channelSendModel(selIndex, index);
if( sendModel == nullptr )
Expand Down Expand Up @@ -579,7 +576,7 @@ void MixerView::deleteUnusedChannels()
//Check all channels except master, delete those with no incoming sends
for(int i = m_mixerChannelViews.size()-1; i > 0; --i)
{
if ((inUse[i]==0) && Engine::mixer()->mixerChannel(i)->m_receives.isEmpty())
if ((inUse[i]==0) && mix->mixerChannel(i)->m_receives.isEmpty())
{
deleteChannelInternal(i);
needUpdateMax = true;
Expand All @@ -596,17 +593,16 @@ void MixerView::toggleAutoTrackLink(int index)
MixerChannel * channel = mix->mixerChannel(index);
if (!channel->m_autoTrackLinkModel.value()) return;

Track * trackFound = NULL;
mix->processAssignedTracks([&trackFound, index](Track * track, IntModel * model, MixerChannel * channel)
Track * trackFound = nullptr;
mix->processAssignedTracks([&trackFound, index](Track * track, IntModel * model, MixerChannel *)
mutable {
(void) channel;
if (model->value() == index)
{
trackFound = track;
}
});

if (trackFound != NULL)
if (trackFound != nullptr)
{
updateAutoTrackSortOrder();
updateAfterTrackStyleModify(trackFound);
Expand Down

0 comments on commit 9a2f342

Please sign in to comment.