void FxMixer::clearChannel(fx_ch_t index) { FxChannel * ch = m_fxChannels[index]; ch->m_fxChain.clear(); ch->m_volumeModel.setValue( 1.0f ); ch->m_muteModel.setValue( false ); ch->m_soloModel.setValue( false ); ch->m_name = ( index == 0 ) ? tr( "Master" ) : tr( "FX %1" ).arg( index ); ch->m_volumeModel.setDisplayName( ch->m_name ); // send only to master if( index > 0) { // delete existing sends while( ! ch->m_sends.isEmpty() ) { deleteChannelSend( ch->m_sends.first() ); } // add send to master createChannelSend( index, 0 ); } // delete receives while( ! ch->m_receives.isEmpty() ) { deleteChannelSend( ch->m_receives.first() ); } }
// make sure we have at least num channels void FxMixer::allocateChannelsTo(int num) { while( num > m_fxChannels.size() - 1 ) { createChannel(); // delete the default send to master deleteChannelSend( m_fxChannels.size()-1, 0 ); } }
FxMixer::~FxMixer() { while( ! m_fxRoutes.isEmpty() ) { deleteChannelSend( m_fxRoutes.first() ); } for( int i = 0; i < m_fxChannels.size(); ++i ) { delete m_fxChannels[i]; } }
FxMixer::~FxMixer() { while( ! m_fxRoutes.isEmpty() ) { deleteChannelSend( m_fxRoutes.first() ); } while( m_fxChannels.size() ) { FxChannel * f = m_fxChannels[m_fxChannels.size() - 1]; m_fxChannels.pop_back(); delete f; } }
// delete the connection made by createChannelSend void FxMixer::deleteChannelSend( fx_ch_t fromChannel, fx_ch_t toChannel ) { // delete the send FxChannel * from = m_fxChannels[fromChannel]; FxChannel * to = m_fxChannels[toChannel]; // find and delete the send entry for( int i = 0; i < from->m_sends.size(); ++i ) { if( from->m_sends[i]->receiver() == to ) { deleteChannelSend( from->m_sends[i] ); break; } } }
void FxMixer::deleteChannel( int index ) { m_fxChannels[index]->m_lock.lock(); FxChannel * ch = m_fxChannels[index]; // go through every instrument and adjust for the channel index change TrackContainer::TrackList tracks; tracks += Engine::getSong()->tracks(); tracks += Engine::getBBTrackContainer()->tracks(); for( Track* t : tracks ) { if( t->type() == Track::InstrumentTrack ) { InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>( t ); 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 while( ! ch->m_sends.isEmpty() ) { deleteChannelSend( ch->m_sends.first() ); } while( ! ch->m_receives.isEmpty() ) { deleteChannelSend( ch->m_receives.first() ); } // actually delete the channel delete m_fxChannels[index]; m_fxChannels.remove(index); for( int i = index; i < m_fxChannels.size(); ++i ) { validateChannelName( i, i + 1 ); // set correct channel index m_fxChannels[i]->m_channelIndex = i; // now check all routes and update names of the send models for( FxRoute * r : m_fxChannels[i]->m_sends ) { r->updateName(); } for( FxRoute * r : m_fxChannels[i]->m_receives ) { r->updateName(); } } }