Ability to delete mixer channels in the FX Mixer

Users can now delete mixer channels from the FX mixer, and it
doesn't mess up the instrument send channels.
This commit is contained in:
Andrew Kelley
2009-09-30 03:45:08 -07:00
parent 147844b388
commit e09c12687a
5 changed files with 161 additions and 8 deletions

View File

@@ -30,6 +30,9 @@
#include "Effect.h"
#include "song.h"
#include "InstrumentTrack.h"
#include "bb_track_container.h"
FxChannel::FxChannel( Model * _parent ) :
m_fxChain( NULL ),
@@ -97,6 +100,98 @@ int FxMixer::createChannel()
}
void FxMixer::deleteChannel(int index)
{
// go through every instrument and adjust for the channel index change
QVector<track *> songTrackList = engine::getSong()->tracks();
QVector<track *> bbTrackList = engine::getBBTrackContainer()->tracks();
QVector<track *> trackLists[] = {songTrackList, bbTrackList};
for(int tl=0; tl<2; ++tl)
{
QVector<track *> trackList = trackLists[tl];
for(int i=0; i<trackList.size(); ++i)
{
if( trackList[i]->type() == track::InstrumentTrack )
{
InstrumentTrack * inst = (InstrumentTrack *) trackList[i];
int val = inst->effectChannelModel()->value(0);
if( val == index )
{
// we are deleting this track's fx send
// send to master
inst->effectChannelModel()->setValue(0);
}
else if( val > index )
{
// subtract 1 to make up for the missing channel
inst->effectChannelModel()->setValue(val-1);
}
}
}
}
// delete all of this channel's sends and receives
for(int i=0; i<m_fxChannels[index]->m_sends.size(); ++i)
{
deleteChannelSend(index, m_fxChannels[index]->m_sends[i]);
}
for(int i=0; i<m_fxChannels[index]->m_receives.size(); ++i)
{
deleteChannelSend(m_fxChannels[index]->m_receives[i], index);
}
for(int i=0; i<m_fxChannels.size(); ++i)
{
// for every send/receive, adjust for the channel index change
for(int j=0; j<m_fxChannels[i]->m_sends.size(); ++j)
{
if( m_fxChannels[i]->m_sends[j] > index )
{
// subtract 1 to make up for the missing channel
--m_fxChannels[i]->m_sends[j];
}
}
for(int j=0; j<m_fxChannels[i]->m_receives.size(); ++j)
{
if( m_fxChannels[i]->m_receives[j] > index )
{
// subtract 1 to make up for the missing channel
--m_fxChannels[i]->m_receives[j];
}
}
}
// actually delete the channel
m_fxChannels.remove(index);
}
void FxMixer::moveChannelLeft(int index)
{
// can't move master or first channel
if( index <= 1 )
{
return;
}
// channels to swap
int a = index - 1, b = index;
// go through every instrument and adjust for the channel index change
}
void FxMixer::moveChannelRight(int index)
{
moveChannelLeft(index+1);
}
void FxMixer::createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel,
float amount)

View File

@@ -24,6 +24,7 @@
#include <QtGlobal>
#include <QDebug>
#include <QKeyEvent>
#include <QtGui/QButtonGroup>
#include <QtGui/QInputDialog>
@@ -63,9 +64,6 @@ FxMixerView::FxMixerView() :
// main-layout
QHBoxLayout * ml = new QHBoxLayout;
//ml->setMargin( 0 );
//ml->setSpacing( 0 );
//ml->addSpacing( 6 );
// Channel area
m_channelAreaWidget = new QWidget;
@@ -237,6 +235,56 @@ void FxMixerView::updateFxLine(int index)
}
void FxMixerView::deleteChannel(int index)
{
// remember selected line
int selLine = m_currentFxLine->channelIndex();
// can't delete master
if( index == 0 )
return;
// delete the real channel
engine::fxMixer()->deleteChannel(index);
// delete the view
chLayout->removeWidget(m_fxChannelViews[index]->m_fxLine);
delete m_fxChannelViews[index]->m_fader;
delete m_fxChannelViews[index]->m_muteBtn;
delete m_fxChannelViews[index]->m_fxLine;
delete m_fxChannelViews[index];
// make sure every channel knows what index it is
for(int i=0; i<m_fxChannelViews.size(); ++i)
{
if( i > index )
{
m_fxChannelViews[i]->m_fxLine->setChannelIndex(i-1);
}
}
m_fxChannelViews.remove(index);
// select the next channel
if( selLine >= m_fxChannelViews.size() )
{
selLine = m_fxChannelViews.size()-1;
}
setCurrentFxLine(selLine);
}
void FxMixerView::keyPressEvent(QKeyEvent * e)
{
switch(e->key())
{
case Qt::Key_Delete:
deleteChannel(m_currentFxLine->channelIndex());
break;
}
}
void FxMixerView::setCurrentFxLine( int _line )
{
@@ -245,7 +293,6 @@ void FxMixerView::setCurrentFxLine( int _line )
void FxMixerView::clear()
{
m_rackView->clearViews();