clang-tidy: Apply modernize-loop-convert everywhere (#6481)

Co-authored-by: allejok96 <allejok96@gmail.com>
Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
This commit is contained in:
saker
2022-09-27 04:27:35 -04:00
committed by GitHub
parent e407e73e24
commit 2f7a6558a1
67 changed files with 441 additions and 598 deletions

View File

@@ -82,7 +82,7 @@ private:
InstrumentTrack* m_instrumentTrack;
MidiEventProcessor* m_midiEvProc;
bool m_pressedKeys[NumKeys];
std::array<bool, NumKeys> m_pressedKeys = {};
} ;

View File

@@ -355,10 +355,9 @@ void GigInstrument::play( sampleFrame * _working_buffer )
it->state = PlayingKeyUp;
// Notify each sample that the key has been released
for( QList<GigSample>::iterator sample = it->samples.begin();
sample != it->samples.end(); ++sample )
for (auto& sample : it->samples)
{
sample->adsr.keyup();
sample.adsr.keyup();
}
// Add release samples if available
@@ -408,22 +407,17 @@ void GigInstrument::play( sampleFrame * _working_buffer )
}
// Fill buffer with portions of the note samples
for( QList<GigNote>::iterator it = m_notes.begin(); it != m_notes.end(); ++it )
for (auto& note : m_notes)
{
// Only process the notes if we're in a playing state
if( !( it->state == PlayingKeyDown ||
it->state == PlayingKeyUp ) )
if (!(note.state == PlayingKeyDown || note.state == PlayingKeyUp ))
{
continue;
}
for( QList<GigSample>::iterator sample = it->samples.begin();
sample != it->samples.end(); ++sample )
for (auto& sample : note.samples)
{
if( sample->sample == nullptr || sample->region == nullptr )
{
continue;
}
if (sample.sample == nullptr || sample.region == nullptr) { continue; }
// Will change if resampling
bool resample = false;
@@ -434,18 +428,15 @@ void GigInstrument::play( sampleFrame * _working_buffer )
// Resample to be the correct pitch when the sample provided isn't
// solely for this one note (e.g. one or two samples per octave) or
// we are processing at a different sample rate
if( sample->region->PitchTrack == true || rate != sample->sample->SamplesPerSecond )
if (sample.region->PitchTrack == true || rate != sample.sample->SamplesPerSecond)
{
resample = true;
// Factor just for resampling
freq_factor = 1.0 * rate / sample->sample->SamplesPerSecond;
freq_factor = 1.0 * rate / sample.sample->SamplesPerSecond;
// Factor for pitch shifting as well as resampling
if( sample->region->PitchTrack == true )
{
freq_factor *= sample->freqFactor;
}
if (sample.region->PitchTrack == true) { freq_factor *= sample.freqFactor; }
// We need a bit of margin so we don't get glitching
samples = frames / freq_factor + MARGIN[m_interpolation];
@@ -453,11 +444,11 @@ void GigInstrument::play( sampleFrame * _working_buffer )
// Load this note's data
sampleFrame sampleData[samples];
loadSample( *sample, sampleData, samples );
loadSample(sample, sampleData, samples);
// Apply ADSR using a copy so if we don't use these samples when
// resampling, the ADSR doesn't get messed up
ADSR copy = sample->adsr;
ADSR copy = sample.adsr;
for( f_cnt_t i = 0; i < samples; ++i )
{
@@ -472,8 +463,7 @@ void GigInstrument::play( sampleFrame * _working_buffer )
sampleFrame convertBuf[frames];
// Only output if resampling is successful (note that "used" is output)
if( sample->convertSampleRate( *sampleData, *convertBuf, samples, frames,
freq_factor, used ) )
if (sample.convertSampleRate(*sampleData, *convertBuf, samples, frames, freq_factor, used))
{
for( f_cnt_t i = 0; i < frames; ++i )
{
@@ -492,8 +482,8 @@ void GigInstrument::play( sampleFrame * _working_buffer )
}
// Update note position with how many samples we actually used
sample->pos += used;
sample->adsr.inc( used );
sample.pos += used;
sample.adsr.inc(used);
}
}
@@ -689,13 +679,12 @@ void GigInstrument::deleteNotePluginData( NotePlayHandle * _n )
// Mark the note as being released, but only if it was playing or was just
// pressed (i.e., not if the key was already released)
for( QList<GigNote>::iterator i = m_notes.begin(); i != m_notes.end(); ++i )
for (auto& note : m_notes)
{
// Find the note by matching pointers to the plugin data
if( i->handle == pluginData &&
( i->state == KeyDown || i->state == PlayingKeyDown ) )
if (note.handle == pluginData && (note.state == KeyDown || note.state == PlayingKeyDown))
{
i->state = KeyUp;
note.state = KeyUp;
}
}

View File

@@ -72,15 +72,13 @@ LadspaDescription::LadspaDescription( QWidget * _parent,
}
QList<QString> pluginNames;
for( l_sortable_plugin_t::iterator it = plugins.begin();
it != plugins.end(); ++it )
for (const auto& plugin : plugins)
{
if( _type != VALID ||
manager->getDescription( ( *it ).second )->inputChannels
<= Engine::audioEngine()->audioDev()->channels() )
{
pluginNames.push_back( ( *it ).first );
m_pluginKeys.push_back( ( *it ).second );
ch_cnt_t audioDeviceChannels = Engine::audioEngine()->audioDev()->channels();
if (_type != VALID || manager->getDescription(plugin.second)->inputChannels <= audioDeviceChannels)
{
pluginNames.push_back(plugin.first);
m_pluginKeys.push_back(plugin.second);
}
}

View File

@@ -69,11 +69,10 @@ LadspaControlDialog::LadspaControlDialog( LadspaControls * _ctl ) :
void LadspaControlDialog::updateEffectView( LadspaControls * _ctl )
{
QList<QGroupBox *> list = findChildren<QGroupBox *>();
for( QList<QGroupBox *>::iterator it = list.begin(); it != list.end();
++it )
QList<QGroupBox *> groupBoxes = findChildren<QGroupBox *>();
for (const auto& groupBox : groupBoxes)
{
delete *it;
delete groupBox;
}
m_effectControls = _ctl;
@@ -105,12 +104,11 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl )
grouper->setLayout( gl );
grouper->setAlignment( Qt::Vertical );
for( control_list_t::iterator it = controls.begin();
it != controls.end(); ++it )
for (const auto& control : controls)
{
if( (*it)->port()->proc == proc )
if (control->port()->proc == proc)
{
buffer_data_t this_port = (*it)->port()->data_type;
buffer_data_t this_port = control->port()->data_type;
if( last_port != NONE &&
( this_port == TOGGLED || this_port == ENUM ) &&
( last_port != TOGGLED && last_port != ENUM ) )
@@ -118,13 +116,13 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl )
++row;
col = 0;
}
gl->addWidget( new LadspaControlView( grouper, *it ), row, col );
gl->addWidget(new LadspaControlView(grouper, control), row, col);
if( ++col == cols )
{
++row;
col = 0;
}
last_port = (*it)->port()->data_type;
last_port = control->port()->data_type;
}
}

View File

@@ -53,20 +53,19 @@ LadspaControls::LadspaControls( LadspaEffect * _eff ) :
const bool linked_control = ( m_processors > 1 && proc == 0 );
for( multi_proc_t::Iterator it = controls.begin(); it != controls.end(); it++ )
for (const auto& control : controls)
{
if( (*it)->proc == proc )
if (control->proc == proc)
{
(*it)->control = new LadspaControl( this, *it,
linked_control );
control->control = new LadspaControl(this, control, linked_control);
p.append( (*it)->control );
p.append(control->control);
if( linked_control )
if (linked_control)
{
connect( (*it)->control, SIGNAL( linkChanged( int, bool ) ),
this, SLOT( linkPort( int, bool ) ),
Qt::DirectConnection );
connect(control->control, SIGNAL(linkChanged(int, bool)),
this, SLOT(linkPort(int, bool)),
Qt::DirectConnection);
}
}
}
@@ -77,12 +76,11 @@ LadspaControls::LadspaControls( LadspaEffect * _eff ) :
// now link all controls
if( m_processors > 1 )
{
for( multi_proc_t::Iterator it = controls.begin();
it != controls.end(); it++ )
for (const auto& control : controls)
{
if( (*it)->proc == 0 )
if (control->proc == 0)
{
linkPort( ( *it )->control_id, true );
linkPort(control->control_id, true);
}
}
}
@@ -112,12 +110,10 @@ void LadspaControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
multi_proc_t controls = m_effect->getPortControls();
_this.setAttribute( "ports", controls.count() );
for( multi_proc_t::Iterator it = controls.begin();
it != controls.end(); it++ )
for (const auto& control : controls)
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->saveSettings( _doc, _this, n );
QString n = "port" + QString::number(control->proc) + QString::number(control->port_id);
control->control->saveSettings(_doc, _this, n);
}
}
@@ -132,12 +128,10 @@ void LadspaControls::loadSettings( const QDomElement & _this )
}
multi_proc_t controls = m_effect->getPortControls();
for( multi_proc_t::Iterator it = controls.begin();
it != controls.end(); it++ )
for (const auto& control : controls)
{
QString n = "port" + QString::number( (*it)->proc ) +
QString::number( (*it)->port_id );
(*it)->control->loadSettings( _this, n );
QString n = "port" + QString::number(control->proc) + QString::number(control->port_id);
control->control->loadSettings(_this, n);
}
}

View File

@@ -356,8 +356,9 @@ Lb302Synth::Lb302Synth( InstrumentTrack * _instrumentTrack ) :
Lb302Synth::~Lb302Synth()
{
for (int i=0; i<NUM_FILTERS; ++i) {
delete vcfs[i];
for (const auto& vcf : vcfs)
{
delete vcf;
}
}

View File

@@ -78,9 +78,6 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg,
{
if (Lv2ControlBase::isValid())
{
#ifdef LV2_INSTRUMENT_USE_MIDI
for (int i = 0; i < NumKeys; ++i) { m_runningNotes[i] = 0; }
#endif
connect(instrumentTrack()->pitchRangeModel(), SIGNAL(dataChanged()),
this, SLOT(updatePitchRange()), Qt::DirectConnection);
connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged,

View File

@@ -101,7 +101,7 @@ private:
void setNameFromFile(const QString &name) override;
#ifdef LV2_INSTRUMENT_USE_MIDI
int m_runningNotes[NumKeys];
std::array<int, NumKeys> m_runningNotes = {};
#endif
friend class gui::Lv2InsView;

View File

@@ -216,27 +216,28 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
int len = n.toElement().attribute("steps", "1").toInt() * 12;
// for each pattern clip of the current pattern track (in song editor)
for (auto it = plist.begin(); it != plist.end(); ++it)
for (const auto& position : plist)
{
while (!st.empty() && st.back().second <= it->first)
const auto& [start, end] = position;
while (!st.empty() && st.back().second <= start)
{
writePatternClip(midiClip, nv, len, st.back().first, pos, st.back().second);
pos = st.back().second;
st.pop_back();
}
if (!st.empty() && st.back().second <= it->second)
if (!st.empty() && st.back().second <= end)
{
writePatternClip(midiClip, nv, len, st.back().first, pos, it->first);
pos = it->first;
while (!st.empty() && st.back().second <= it->second)
writePatternClip(midiClip, nv, len, st.back().first, pos, start);
pos = start;
while (!st.empty() && st.back().second <= end)
{
st.pop_back();
}
}
st.push_back(*it);
pos = it->first;
st.push_back(position);
pos = start;
}
while (!st.empty())
@@ -286,9 +287,9 @@ void MidiExport::writeMidiClip(MidiNoteVector &midiClip, const QDomNode& n,
void MidiExport::writeMidiClipToTrack(MTrack &mtrack, MidiNoteVector &nv)
{
for (auto it = nv.begin(); it != nv.end(); ++it)
for (const auto& note : nv)
{
mtrack.addNote(it->pitch, it->volume, it->time / 48.0, it->duration / 48.0);
mtrack.addNote(note.pitch, note.volume, note.time / 48.0, note.duration / 48.0);
}
}
@@ -301,16 +302,15 @@ void MidiExport::writePatternClip(MidiNoteVector& src, MidiNoteVector& dst,
start -= base;
end -= base;
std::sort(src.begin(), src.end());
for (auto it = src.begin(); it != src.end(); ++it)
for (const auto& srcNote : src)
{
for (int time = it->time + ceil((start - it->time) / len)
* len; time < end; time += len)
for (int time = srcNote.time + ceil((start - srcNote.time) / len) * len; time < end; time += len)
{
MidiNote note;
note.duration = it->duration;
note.pitch = it->pitch;
note.duration = srcNote.duration;
note.pitch = srcNote.pitch;
note.time = base + time;
note.volume = it->volume;
note.volume = srcNote.volume;
dst.push_back(note);
}
}

View File

@@ -401,9 +401,9 @@ bool MidiImport::readSMF( TrackContainer* tc )
Alg_track_ptr trk = seq->track( t );
pd.setValue( t + preTrackSteps );
for( int c = 0; c < MIDI_CC_COUNT; c++ )
for (auto& cc : ccs)
{
ccs[c].clear();
cc.clear();
}
// Now look at events

View File

@@ -399,16 +399,16 @@ void PatmanInstrument::selectSample( NotePlayHandle * _n )
float min_dist = HUGE_VALF;
SampleBuffer* sample = nullptr;
for( QVector<SampleBuffer *>::iterator it = m_patchSamples.begin(); it != m_patchSamples.end(); ++it )
for (const auto& patchSample : m_patchSamples)
{
float patch_freq = ( *it )->frequency();
float patch_freq = patchSample->frequency();
float dist = freq >= patch_freq ? freq / patch_freq :
patch_freq / freq;
if( dist < min_dist )
{
min_dist = dist;
sample = *it;
sample = patchSample;
}
}

View File

@@ -115,10 +115,6 @@ Sf2Instrument::Sf2Instrument( InstrumentTrack * _instrument_track ) :
m_chorusSpeed( FLUID_CHORUS_DEFAULT_SPEED, 0.29, 5.0, 0.01, this, tr( "Chorus speed" ) ),
m_chorusDepth( FLUID_CHORUS_DEFAULT_DEPTH, 0, 46.0, 0.05, this, tr( "Chorus depth" ) )
{
for( int i = 0; i < 128; ++i )
{
m_notesRunning[i] = 0;
}
#if QT_VERSION_CHECK(FLUIDSYNTH_VERSION_MAJOR, FLUIDSYNTH_VERSION_MINOR, FLUIDSYNTH_VERSION_MICRO) >= QT_VERSION_CHECK(1,1,9)
@@ -1194,7 +1190,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * )
{
return new Sf2Instrument( static_cast<InstrumentTrack *>( m ) );
}
}

View File

@@ -135,7 +135,7 @@ private:
QMutex m_synthMutex;
QMutex m_loadMutex;
int m_notesRunning[128];
std::array<int, 128> m_notesRunning = {};
sample_rate_t m_internalSampleRate;
int m_lastMidiPitch;
int m_lastMidiPitchRange;

View File

@@ -140,11 +140,12 @@ void SfxrSynth::resetSample( bool restart )
if(s->m_phaserSweepModel.value()<0.0f) fdphase=-fdphase;
iphase=abs((int)fphase);
ipp=0;
for(int i=0;i<1024;i++)
phaser_buffer[i]=0.0f;
for(int i=0;i<32;i++)
noise_buffer[i]=frnd(2.0f)-1.0f;
phaser_buffer.fill(0.0f);
for (auto& noiseSample : noise_buffer)
{
noiseSample = frnd(2.0f) - 1.0f;
}
rep_time=0;
rep_limit=(int)(pow(1.0f-s->m_repeatSpeedModel.value(), 2.0f)*20000+32);
@@ -239,8 +240,10 @@ void SfxrSynth::update( sampleFrame * buffer, const int32_t frameNum )
// phase=0;
phase%=period;
if(s->m_waveFormModel.value()==3)
for(int i=0;i<32;i++)
noise_buffer[i]=frnd(2.0f)-1.0f;
for (auto& noiseSample : noise_buffer)
{
noiseSample = frnd(2.0f) - 1.0f;
}
}
// base waveform
float fp=(float)phase/period;

View File

@@ -105,7 +105,7 @@ private:
float fphase;
float fdphase;
int iphase;
float phaser_buffer[1024];
std::array<float, 1024> phaser_buffer;
int ipp;
float noise_buffer[32];
float fltp;

View File

@@ -227,10 +227,10 @@ f_cnt_t SidInstrument::desiredReleaseFrames() const
{
const float samplerate = Engine::audioEngine()->processingSampleRate();
int maxrel = 0;
for( int i = 0 ; i < 3 ; ++i )
for (const auto& voice : m_voice)
{
if( maxrel < m_voice[i]->m_releaseModel.value() )
maxrel = (int)m_voice[i]->m_releaseModel.value();
if( maxrel < voice->m_releaseModel.value() )
maxrel = (int)voice->m_releaseModel.value();
}
return f_cnt_t( float(relTime[maxrel])*samplerate/1000.0 );
@@ -320,9 +320,9 @@ void SidInstrument::playNote( NotePlayHandle * _n,
auto buf = reinterpret_cast<short*>(_working_buffer + offset);
unsigned char sidreg[NUMSIDREGS];
for (int c = 0; c < NUMSIDREGS; c++)
for (auto& reg : sidreg)
{
sidreg[c] = 0x00;
reg = 0x00;
}
if( (ChipModel)m_chipModel.value() == sidMOS6581 )
@@ -749,20 +749,14 @@ void SidInstrumentView::modelChanged()
&k->m_voice[i]->m_testModel );
}
for( int i = 0; i < 3; ++i )
for (const auto& voice : k->m_voice)
{
connect( &k->m_voice[i]->m_attackModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobHint() ) );
connect( &k->m_voice[i]->m_decayModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobHint() ) );
connect( &k->m_voice[i]->m_releaseModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobHint() ) );
connect( &k->m_voice[i]->m_pulseWidthModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobHint() ) );
connect( &k->m_voice[i]->m_sustainModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobToolTip() ) );
connect( &k->m_voice[i]->m_coarseModel, SIGNAL( dataChanged() ),
this, SLOT( updateKnobToolTip() ) );
connect(&voice->m_attackModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint()));
connect(&voice->m_decayModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint()));
connect(&voice->m_releaseModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint()));
connect(&voice->m_pulseWidthModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint()));
connect(&voice->m_sustainModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip()));
connect(&voice->m_coarseModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip()));
}
connect( &k->m_volumeModel, SIGNAL( dataChanged() ),

View File

@@ -409,10 +409,10 @@ gui::PluginView* TripleOscillator::instantiateView( QWidget * _parent )
void TripleOscillator::updateAllDetuning()
{
for( int i = 0; i < NUM_OF_OSCILLATORS; ++i )
for (const auto& osc : m_osc)
{
m_osc[i]->updateDetuningLeft();
m_osc[i]->updateDetuningRight();
osc->updateDetuningLeft();
osc->updateDetuningRight();
}
}

View File

@@ -375,15 +375,12 @@ void VstPlugin::setParameterDump( const QMap<QString, QString> & _pdump )
{
message m( IdVstSetParameterDump );
m.addInt( _pdump.size() );
for( QMap<QString, QString>::ConstIterator it = _pdump.begin();
it != _pdump.end(); ++it )
for (const auto& str : _pdump)
{
const VstParameterDumpItem item =
{
( *it ).section( ':', 0, 0 ).toInt(),
"",
LocaleHelper::toFloat((*it).section(':', 2, -1))
} ;
str.section(':', 0, 0).toInt(), "", LocaleHelper::toFloat(str.section(':', 2, -1))
};
m.addInt( item.index );
m.addString( item.shortLabel );
m.addFloat( item.value );

View File

@@ -377,13 +377,13 @@ public:
{}
~ExprFrontData()
{
for (int i = 0; i < m_cyclics.size() ; ++i)
for (const auto& cyclic : m_cyclics)
{
delete m_cyclics[i];
delete cyclic;
}
for (int i = 0; i < m_cyclics_interp.size() ; ++i)
for (const auto& cyclic : m_cyclics_interp)
{
delete m_cyclics_interp[i];
delete cyclic;
}
if (m_integ_func)
{

View File

@@ -51,11 +51,6 @@ LocalZynAddSubFx::LocalZynAddSubFx() :
m_master( nullptr ),
m_ioEngine( nullptr )
{
for( int i = 0; i < NumKeys; ++i )
{
m_runningNotes[i] = 0;
}
if( s_instanceCount == 0 )
{
#ifdef LMMS_BUILD_WIN32
@@ -182,14 +177,14 @@ void LocalZynAddSubFx::loadPreset( const std::string & _filename, int _part )
void LocalZynAddSubFx::setPresetDir( const std::string & _dir )
{
m_presetsDir = _dir;
for( int i = 0; i < MAX_BANK_ROOT_DIRS; ++i )
for (auto& bankRootDir : config.cfg.bankRootDirList)
{
if( config.cfg.bankRootDirList[i].empty() )
if (bankRootDir.empty())
{
config.cfg.bankRootDirList[i] = m_presetsDir;
bankRootDir = m_presetsDir;
break;
}
else if( config.cfg.bankRootDirList[i] == m_presetsDir )
else if (bankRootDir == m_presetsDir)
{
break;
}
@@ -214,9 +209,9 @@ void LocalZynAddSubFx::setLmmsWorkingDir( const std::string & _dir )
void LocalZynAddSubFx::setPitchWheelBendRange( int semitones )
{
for( int i = 0; i < NUM_MIDI_PARTS; ++i )
for (const auto& part : m_master->part)
{
m_master->part[i]->ctl.setpitchwheelbendrange( semitones * 100 );
part->ctl.setpitchwheelbendrange(semitones * 100);
}
}

View File

@@ -72,7 +72,7 @@ protected:
std::string m_presetsDir;
int m_runningNotes[NumKeys];
std::array<int, NumKeys> m_runningNotes = {};
Master * m_master;
NulEngine* m_ioEngine;

View File

@@ -90,10 +90,10 @@ int RemotePluginBase::sendMessage( const message & _m )
writeInt( _m.id );
writeInt( _m.data.size() );
int j = 8;
for( unsigned int i = 0; i < _m.data.size(); ++i )
for (const auto& str : _m.data)
{
writeString( _m.data[i] );
j += 4 + _m.data[i].size();
writeString(str);
j += 4 + str.size();
}
pthread_mutex_unlock( &m_sendMutex );
#endif

View File

@@ -188,9 +188,9 @@ AudioEngine::~AudioEngine()
MemoryHelper::alignedFree(m_outputBufferRead);
MemoryHelper::alignedFree(m_outputBufferWrite);
for( int i = 0; i < 2; ++i )
for (const auto& input : m_inputBuffer)
{
delete[] m_inputBuffer[i];
delete[] input;
}
}

View File

@@ -305,13 +305,13 @@ void AutomatableModel::setValue( const float value )
addJournalCheckPoint();
// notify linked models
for( AutoModelVector::Iterator it = m_linkedModels.begin(); it != m_linkedModels.end(); ++it )
for (const auto& linkedModel : m_linkedModels)
{
if( (*it)->m_setValueDepth < 1 && (*it)->fittedValue( value ) != (*it)->m_value )
if (linkedModel->m_setValueDepth < 1 && linkedModel->fittedValue(value) != linkedModel->m_value)
{
bool journalling = (*it)->testAndSetJournalling( isJournalling() );
(*it)->setValue( value );
(*it)->setJournalling( journalling );
bool journalling = linkedModel->testAndSetJournalling(isJournalling());
linkedModel->setValue(value);
linkedModel->setJournalling(journalling);
}
}
m_valueChanged = true;
@@ -388,13 +388,12 @@ void AutomatableModel::setAutomatedValue( const float value )
if( oldValue != m_value )
{
// notify linked models
for (AutoModelVector::Iterator it = m_linkedModels.begin();
it != m_linkedModels.end(); ++it)
for (const auto& linkedModel : m_linkedModels)
{
if (!((*it)->controllerConnection()) && (*it)->m_setValueDepth < 1 &&
(*it)->fittedValue(m_value) != (*it)->m_value)
if (!(linkedModel->controllerConnection()) && linkedModel->m_setValueDepth < 1 &&
linkedModel->fittedValue(m_value) != linkedModel->m_value)
{
(*it)->setAutomatedValue(value);
linkedModel->setAutomatedValue(value);
}
}
m_valueChanged = true;
@@ -733,11 +732,11 @@ float AutomatableModel::globalAutomationValueAt( const TimePos& time )
// of those clips:
// find the clips which overlap with the time position
QVector<AutomationClip *> clipsInRange;
for( QVector<AutomationClip *>::ConstIterator it = clips.begin(); it != clips.end(); it++ )
for (const auto& clip : clips)
{
int s = ( *it )->startPosition();
int e = ( *it )->endPosition();
if( s <= time && e >= time ) { clipsInRange += ( *it ); }
int s = clip->startPosition();
int e = clip->endPosition();
if (s <= time && e >= time) { clipsInRange += clip; }
}
AutomationClip * latestClip = nullptr;
@@ -753,13 +752,13 @@ float AutomatableModel::globalAutomationValueAt( const TimePos& time )
{
int latestPosition = 0;
for( QVector<AutomationClip *>::ConstIterator it = clips.begin(); it != clips.end(); it++ )
for (const auto& clip : clips)
{
int e = ( *it )->endPosition();
if( e <= time && e > latestPosition )
int e = clip->endPosition();
if (e <= time && e > latestPosition)
{
latestPosition = e;
latestClip = ( *it );
latestClip = clip;
}
}
}

View File

@@ -786,15 +786,13 @@ void AutomationClip::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.appendChild( element );
}
for( objectVector::const_iterator it = m_objects.begin();
it != m_objects.end(); ++it )
for (const auto& object : m_objects)
{
if( *it )
if (object)
{
QDomElement element = _doc.createElement( "object" );
element.setAttribute( "id",
ProjectJournal::idToSave( ( *it )->id() ) );
_this.appendChild( element );
element.setAttribute("id", ProjectJournal::idToSave(object->id()));
_this.appendChild(element);
}
}
}
@@ -895,20 +893,18 @@ bool AutomationClip::isAutomated( const AutomatableModel * _m )
l += Engine::patternStore()->tracks();
l += Engine::getSong()->globalAutomationTrack();
for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it )
for (const auto& track : l)
{
if( ( *it )->type() == Track::AutomationTrack ||
( *it )->type() == Track::HiddenAutomationTrack )
if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack)
{
const Track::clipVector & v = ( *it )->getClips();
for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j )
for (const auto& clip : track->getClips())
{
const auto a = dynamic_cast<const AutomationClip*>(*j);
const auto a = dynamic_cast<const AutomationClip*>(clip);
if( a && a->hasAutomation() )
{
for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k )
for (const auto& object : a->m_objects)
{
if( *k == _m )
if (object == _m)
{
return true;
}
@@ -927,34 +923,31 @@ bool AutomationClip::isAutomated( const AutomatableModel * _m )
*/
QVector<AutomationClip *> AutomationClip::clipsForModel( const AutomatableModel * _m )
{
QVector<AutomationClip *> clips;
TrackContainer::TrackList l;
l += Engine::getSong()->tracks();
l += Engine::patternStore()->tracks();
l += Engine::getSong()->globalAutomationTrack();
QVector<AutomationClip*> clips;
TrackContainer::TrackList tracks;
tracks += Engine::getSong()->tracks();
tracks += Engine::patternStore()->tracks();
tracks += Engine::getSong()->globalAutomationTrack();
// go through all tracks...
for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it )
for (const auto& track : tracks)
{
// we want only automation tracks...
if( ( *it )->type() == Track::AutomationTrack ||
( *it )->type() == Track::HiddenAutomationTrack )
if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack )
{
// get clips in those tracks....
const Track::clipVector & v = ( *it )->getClips();
// go through all the clips...
for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j )
for (const auto& trackClip : track->getClips())
{
auto a = dynamic_cast<AutomationClip*>(*j);
auto a = dynamic_cast<AutomationClip*>(trackClip);
// check that the clip has automation
if( a && a->hasAutomation() )
{
// now check is the clip is connected to the model we want by going through all the connections
// of the clip
bool has_object = false;
for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k )
for (const auto& object : a->m_objects)
{
if( *k == _m )
if (object == _m)
{
has_object = true;
}
@@ -974,19 +967,14 @@ AutomationClip * AutomationClip::globalAutomationClip(
AutomatableModel * _m )
{
AutomationTrack * t = Engine::getSong()->globalAutomationTrack();
Track::clipVector v = t->getClips();
for( Track::clipVector::const_iterator j = v.begin(); j != v.end(); ++j )
for (const auto& clip : t->getClips())
{
auto a = dynamic_cast<AutomationClip*>(*j);
auto a = dynamic_cast<AutomationClip*>(clip);
if( a )
{
for( objectVector::const_iterator k = a->m_objects.begin();
k != a->m_objects.end(); ++k )
for (const auto& object : a->m_objects)
{
if( *k == _m )
{
return a;
}
if (object == _m) { return a; }
}
}
}
@@ -1004,24 +992,18 @@ void AutomationClip::resolveAllIDs()
TrackContainer::TrackList l = Engine::getSong()->tracks() +
Engine::patternStore()->tracks();
l += Engine::getSong()->globalAutomationTrack();
for( TrackContainer::TrackList::iterator it = l.begin();
it != l.end(); ++it )
for (const auto& track : l)
{
if( ( *it )->type() == Track::AutomationTrack ||
( *it )->type() == Track::HiddenAutomationTrack )
if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack)
{
Track::clipVector v = ( *it )->getClips();
for( Track::clipVector::iterator j = v.begin();
j != v.end(); ++j )
for (const auto& clip : track->getClips())
{
auto a = dynamic_cast<AutomationClip*>(*j);
auto a = dynamic_cast<AutomationClip*>(clip);
if( a )
{
for( QVector<jo_id_t>::Iterator k = a->m_idsToResolve.begin();
k != a->m_idsToResolve.end(); ++k )
for (const auto& id : a->m_idsToResolve)
{
JournallingObject * o = Engine::projectJournal()->
journallingObject( *k );
JournallingObject* o = Engine::projectJournal()->journallingObject(id);
if( o && dynamic_cast<AutomatableModel *>( o ) )
{
a->addObject( dynamic_cast<AutomatableModel *>( o ), false );
@@ -1030,7 +1012,7 @@ void AutomationClip::resolveAllIDs()
{
// FIXME: Remove this block once the automation system gets fixed
// This is a temporary fix for https://github.com/LMMS/lmms/issues/3781
o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(*k));
o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(id));
if( o && dynamic_cast<AutomatableModel *>( o ) )
{
a->addObject( dynamic_cast<AutomatableModel *>( o ), false );
@@ -1039,7 +1021,7 @@ void AutomationClip::resolveAllIDs()
{
// FIXME: Remove this block once the automation system gets fixed
// This is a temporary fix for https://github.com/LMMS/lmms/issues/4781
o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(*k));
o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(id));
if( o && dynamic_cast<AutomatableModel *>( o ) )
{
a->addObject( dynamic_cast<AutomatableModel *>( o ), false );

View File

@@ -339,13 +339,11 @@ const QString & ConfigManager::value(const QString & cls,
{
if(m_settings.contains(cls))
{
for(stringPairVector::const_iterator it =
m_settings[cls].begin();
it != m_settings[cls].end(); ++it)
for (const auto& setting : m_settings[cls])
{
if((*it).first == attribute)
if (setting.first == attribute)
{
return (*it).second ;
return setting.second;
}
}
}
@@ -609,25 +607,22 @@ void ConfigManager::saveConfigFile()
lmms_config.setAttribute("configversion", m_configVersion);
doc.appendChild(lmms_config);
for(settingsMap::iterator it = m_settings.begin();
it != m_settings.end(); ++it)
for (auto it = m_settings.begin(); it != m_settings.end(); ++it)
{
QDomElement n = doc.createElement(it.key());
for(stringPairVector::iterator it2 = (*it).begin();
it2 != (*it).end(); ++it2)
for (const auto& [first, second] : *it)
{
n.setAttribute((*it2).first, (*it2).second);
n.setAttribute(first, second);
}
lmms_config.appendChild(n);
}
QDomElement recent_files = doc.createElement("recentfiles");
for(QStringList::iterator it = m_recentlyOpenedProjects.begin();
it != m_recentlyOpenedProjects.end(); ++it)
for (const auto& recentlyOpenedProject : m_recentlyOpenedProjects)
{
QDomElement n = doc.createElement("file");
n.setAttribute("path", *it);
n.setAttribute("path", recentlyOpenedProject);
recent_files.appendChild(n);
}
lmms_config.appendChild(recent_files);

View File

@@ -533,9 +533,9 @@ bool DataFile::hasLocalPlugins(QDomElement parent /* = QDomElement()*/, bool fir
bool skipNode = false;
// Skip the nodes allowed to have "local:" attributes, but
// still check its children
for (auto it = ELEMENTS_WITH_RESOURCES.begin(); it != ELEMENTS_WITH_RESOURCES.end(); ++it)
for (const auto& element : ELEMENTS_WITH_RESOURCES)
{
if (childElement.tagName() == it->first)
if (childElement.tagName() == element.first)
{
skipNode = true;
break;

View File

@@ -66,11 +66,11 @@ Effect::Effect( const Plugin::Descriptor * _desc,
Effect::~Effect()
{
for( int i = 0; i < 2; ++i )
for (const auto& state : m_srcState)
{
if( m_srcState[i] != nullptr )
if (state != nullptr)
{
src_delete( m_srcState[i] );
src_delete(state);
}
}
}
@@ -175,17 +175,15 @@ gui::PluginView * Effect::instantiateView( QWidget * _parent )
void Effect::reinitSRC()
{
for( int i = 0; i < 2; ++i )
for (auto& state : m_srcState)
{
if( m_srcState[i] != nullptr )
if (state != nullptr)
{
src_delete( m_srcState[i] );
src_delete(state);
}
int error;
if( ( m_srcState[i] = src_new(
Engine::audioEngine()->currentQualitySettings().
libsrcInterpolation(),
DEFAULT_CHANNELS, &error ) ) == nullptr )
const int currentInterpolation = Engine::audioEngine()->currentQualitySettings().libsrcInterpolation();
if((state = src_new(currentInterpolation, DEFAULT_CHANNELS, &error)) == nullptr)
{
qFatal( "Error: src_new() failed in effect.cpp!\n" );
}

View File

@@ -191,12 +191,12 @@ bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, b
MixHelpers::sanitize( _buf, _frames );
bool moreEffects = false;
for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); ++it )
for (const auto& effect : m_effects)
{
if( hasInputNoise || ( *it )->isRunning() )
if (hasInputNoise || effect->isRunning())
{
moreEffects |= ( *it )->processAudioBuffer( _buf, _frames );
MixHelpers::sanitize( _buf, _frames );
moreEffects |= effect->processAudioBuffer(_buf, _frames);
MixHelpers::sanitize(_buf, _frames);
}
}
@@ -213,10 +213,9 @@ void EffectChain::startRunning()
return;
}
for( EffectList::Iterator it = m_effects.begin();
it != m_effects.end(); it++ )
for (const auto& effect : m_effects)
{
( *it )->startRunning();
effect->startRunning();
}
}

View File

@@ -47,11 +47,10 @@ EnvelopeAndLfoParameters::LfoInstances * EnvelopeAndLfoParameters::s_lfoInstance
void EnvelopeAndLfoParameters::LfoInstances::trigger()
{
QMutexLocker m( &m_lfoListMutex );
for( LfoList::Iterator it = m_lfos.begin();
it != m_lfos.end(); ++it )
for (const auto& lfo : m_lfos)
{
( *it )->m_lfoFrame += Engine::audioEngine()->framesPerPeriod();
( *it )->m_bad_lfoShapeData = true;
lfo->m_lfoFrame += Engine::audioEngine()->framesPerPeriod();
lfo->m_bad_lfoShapeData = true;
}
}
@@ -61,11 +60,10 @@ void EnvelopeAndLfoParameters::LfoInstances::trigger()
void EnvelopeAndLfoParameters::LfoInstances::reset()
{
QMutexLocker m( &m_lfoListMutex );
for( LfoList::Iterator it = m_lfos.begin();
it != m_lfos.end(); ++it )
for (const auto& lfo : m_lfos)
{
( *it )->m_lfoFrame = 0;
( *it )->m_bad_lfoShapeData = true;
lfo->m_lfoFrame = 0;
lfo->m_bad_lfoShapeData = true;
}
}

View File

@@ -179,11 +179,9 @@ bool InstrumentFunctionNoteStacking::Chord::hasSemiTone( int8_t semi_tone ) cons
InstrumentFunctionNoteStacking::ChordTable::ChordTable() :
QVector<Chord>()
{
for( int i = 0;
i < static_cast<int>( sizeof s_initTable / sizeof *s_initTable );
i++ )
for (const auto& chord : s_initTable)
{
push_back( Chord( s_initTable[i].m_name, s_initTable[i].m_semiTones ) );
push_back(Chord(chord.m_name, chord.m_semiTones));
}
}

View File

@@ -125,11 +125,11 @@ void Keymap::saveSettings(QDomDocument &document, QDomElement &element)
element.setAttribute("base_key", m_baseKey);
element.setAttribute("base_freq", m_baseFreq);
for (int i = 0; i < m_map.size(); i++)
for (int value : m_map)
{
QDomElement degree = document.createElement("degree");
element.appendChild(degree);
degree.setAttribute("value", m_map[i]);
degree.setAttribute("value", value);
}
}

View File

@@ -35,10 +35,9 @@ Ladspa2LMMS::Ladspa2LMMS()
{
l_sortable_plugin_t plugins = getSortedPlugins();
for( l_sortable_plugin_t::iterator it = plugins.begin();
it != plugins.end(); ++it )
for (const auto& plugin : plugins)
{
ladspa_key_t key = (*it).second;
ladspa_key_t key = plugin.second;
LadspaManagerDescription * desc = getDescription( key );
if( desc->type == SOURCE )

View File

@@ -59,19 +59,15 @@ LadspaManager::LadspaManager()
ladspaDirectories.push_back( "/Library/Audio/Plug-Ins/LADSPA" );
#endif
for( QStringList::iterator it = ladspaDirectories.begin();
it != ladspaDirectories.end(); ++it )
for (const auto& ladspaDirectory : ladspaDirectories)
{
// Skip empty entries as QDir will interpret it as the working directory
if ((*it).isEmpty()) { continue; }
QDir directory( ( *it ) );
if (ladspaDirectory.isEmpty()) { continue; }
QDir directory(ladspaDirectory);
QFileInfoList list = directory.entryInfoList();
for( QFileInfoList::iterator file = list.begin();
file != list.end(); ++file )
for (const auto& f : list)
{
const QFileInfo & f = *file;
if( !f.isFile() ||
f.fileName().right( 3 ).toLower() !=
if(!f.isFile() || f.fileName().right( 3 ).toLower() !=
#ifdef LMMS_BUILD_WIN32
"dll"
#else
@@ -101,10 +97,9 @@ LadspaManager::LadspaManager()
}
l_ladspa_key_t keys = m_ladspaManagerMap.keys();
for( l_ladspa_key_t::iterator it = keys.begin();
it != keys.end(); ++it )
for (const auto& key : keys)
{
m_sortedPlugins.append( qMakePair( getName( *it ), *it ) );
m_sortedPlugins.append(qMakePair(getName(key), key));
}
std::sort( m_sortedPlugins.begin(), m_sortedPlugins.end() );
}

View File

@@ -387,15 +387,13 @@ void Mixer::moveChannelLeft( int index )
TrackContainer::TrackList songTrackList = Engine::getSong()->tracks();
TrackContainer::TrackList patternTrackList = Engine::patternStore()->tracks();
TrackContainer::TrackList trackLists[] = {songTrackList, patternTrackList};
for(int tl=0; tl<2; ++tl)
for (const auto& trackList : {songTrackList, patternTrackList})
{
TrackContainer::TrackList trackList = trackLists[tl];
for(int i=0; i<trackList.size(); ++i)
for (const auto& track : trackList)
{
if( trackList[i]->type() == Track::InstrumentTrack )
if (track->type() == Track::InstrumentTrack)
{
auto inst = (InstrumentTrack*)trackList[i];
auto inst = (InstrumentTrack*)track;
int val = inst->mixerChannelModel()->value(0);
if( val == a )
{
@@ -406,9 +404,9 @@ void Mixer::moveChannelLeft( int index )
inst->mixerChannelModel()->setValue(a);
}
}
else if( trackList[i]->type() == Track::SampleTrack )
else if (track->type() == Track::SampleTrack)
{
auto strk = (SampleTrack*)trackList[i];
auto strk = (SampleTrack*)track;
int val = strk->mixerChannelModel()->value(0);
if( val == a )
{
@@ -447,13 +445,13 @@ MixerRoute * Mixer::createChannelSend( mix_ch_t fromChannel, mix_ch_t toChannel,
MixerChannel * from = m_mixerChannels[fromChannel];
MixerChannel * to = m_mixerChannels[toChannel];
for( int i=0; i<from->m_sends.size(); ++i )
for (const auto& send : from->m_sends)
{
if( from->m_sends[i]->receiver() == to )
if (send->receiver() == to)
{
// simply adjust the amount
from->m_sends[i]->amount()->setValue( amount );
return from->m_sends[i];
send->amount()->setValue(amount);
return send;
}
}
@@ -493,11 +491,11 @@ void Mixer::deleteChannelSend( mix_ch_t fromChannel, mix_ch_t toChannel )
MixerChannel * to = m_mixerChannels[toChannel];
// find and delete the send entry
for( int i = 0; i < from->m_sends.size(); ++i )
for (const auto& send : from->m_sends)
{
if( from->m_sends[i]->receiver() == to )
if (send->receiver() == to)
{
deleteChannelSend( from->m_sends[i] );
deleteChannelSend(send);
break;
}
}
@@ -544,9 +542,9 @@ bool Mixer::checkInfiniteLoop( MixerChannel * from, MixerChannel * to )
// follow sendTo's outputs recursively looking for something that sends
// to sendFrom
for( int i=0; i < to->m_sends.size(); ++i )
for (const auto& send : to->m_sends)
{
if( checkInfiniteLoop( from, to->m_sends[i]->receiver() ) )
if (checkInfiniteLoop(from, send->receiver()))
{
return true;
}
@@ -744,13 +742,13 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
if( ch->m_hasColor ) mixch.setAttribute( "color", ch->m_color.name() );
// add the channel sends
for( int si = 0; si < ch->m_sends.size(); ++si )
for (const auto& send : ch->m_sends)
{
QDomElement sendsDom = _doc.createElement( QString( "send" ) );
mixch.appendChild( sendsDom );
sendsDom.setAttribute( "channel", ch->m_sends[si]->receiverIndex() );
ch->m_sends[si]->amount()->saveSettings( _doc, sendsDom, "amount" );
sendsDom.setAttribute("channel", send->receiverIndex());
send->amount()->saveSettings(_doc, sendsDom, "amount");
}
}
}

View File

@@ -443,9 +443,9 @@ float NotePlayHandle::volumeLevel( const f_cnt_t _frame )
void NotePlayHandle::mute()
{
// mute all sub-notes
for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it )
for (const auto& subNote : m_subNotes)
{
( *it )->mute();
subNote->mute();
}
m_muted = true;
}
@@ -457,9 +457,9 @@ int NotePlayHandle::index() const
{
const PlayHandleList & playHandles = Engine::audioEngine()->playHandles();
int idx = 0;
for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it )
for (const auto& playHandle : playHandles)
{
const auto nph = dynamic_cast<const NotePlayHandle*>(*it);
const auto nph = dynamic_cast<const NotePlayHandle*>(playHandle);
if( nph == nullptr || nph->m_instrumentTrack != m_instrumentTrack || nph->isReleased() || nph->hasParent() )
{
continue;
@@ -481,9 +481,9 @@ ConstNotePlayHandleList NotePlayHandle::nphsOfInstrumentTrack( const InstrumentT
const PlayHandleList & playHandles = Engine::audioEngine()->playHandles();
ConstNotePlayHandleList cnphv;
for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it )
for (const auto& playHandle : playHandles)
{
const auto nph = dynamic_cast<const NotePlayHandle*>(*it);
const auto nph = dynamic_cast<const NotePlayHandle*>(playHandle);
if( nph != nullptr && nph->m_instrumentTrack == _it && ( ( nph->isReleased() == false && nph->hasParent() == false ) || _all_ph == true ) )
{
cnphv.push_back( nph );
@@ -589,9 +589,9 @@ void NotePlayHandle::resize( const bpm_t _new_tempo )
m_frames = (f_cnt_t)new_frames;
m_totalFramesPlayed = (f_cnt_t)( completed * new_frames );
for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it )
for (const auto& subNote : m_subNotes)
{
( *it )->resize( _new_tempo );
subNote->resize(_new_tempo);
}
}

View File

@@ -67,11 +67,6 @@ Piano::Piano( InstrumentTrack* track ) :
m_instrumentTrack( track ),
m_midiEvProc( track ) /*!< the InstrumentTrack Model */
{
for( int i = 0; i < NumKeys; ++i )
{
m_pressedKeys[i] = false;
}
}
/*! \brief Turn a key on or off

View File

@@ -100,9 +100,8 @@ void RenderManager::renderTracks()
const TrackContainer::TrackList & tl = Engine::getSong()->tracks();
// find all currently unnmuted tracks -- we want to render these.
for( auto it = tl.begin(); it != tl.end(); ++it )
for (const auto& tk : tl)
{
Track* tk = (*it);
Track::TrackTypes type = tk->type();
// Don't render automation tracks
@@ -114,9 +113,8 @@ void RenderManager::renderTracks()
}
const TrackContainer::TrackList t2 = Engine::patternStore()->tracks();
for( auto it = t2.begin(); it != t2.end(); ++it )
for (const auto& tk : t2)
{
Track* tk = (*it);
Track::TrackTypes type = tk->type();
// Don't render automation tracks

View File

@@ -99,7 +99,7 @@ Song::Song() :
m_loopRenderRemaining(1),
m_oldAutomatedValues()
{
for(int i = 0; i < Mode_Count; ++i) m_elapsedMilliSeconds[i] = 0;
for (double& millisecondsElapsed : m_elapsedMilliSeconds) { millisecondsElapsed = 0; }
connect( &m_tempoModel, SIGNAL(dataChanged()),
this, SLOT(setTempo()), Qt::DirectConnection );
connect( &m_tempoModel, SIGNAL(dataUnchanged()),
@@ -119,8 +119,8 @@ Song::Song() :
qRegisterMetaType<Note>( "Note" );
setType( SongContainer );
for (int i = 0; i < MaxScaleCount; i++) {m_scales[i] = std::make_shared<Scale>();}
for (int i = 0; i < MaxKeymapCount; i++) {m_keymaps[i] = std::make_shared<Keymap>();}
for (auto& scale : m_scales) {scale = std::make_shared<Scale>();}
for (auto& keymap : m_keymaps) {keymap = std::make_shared<Keymap>();}
}
@@ -148,10 +148,9 @@ void Song::setTempo()
Engine::audioEngine()->requestChangeInModel();
const auto tempo = (bpm_t)m_tempoModel.value();
PlayHandleList & playHandles = Engine::audioEngine()->playHandles();
for( PlayHandleList::Iterator it = playHandles.begin();
it != playHandles.end(); ++it )
for (const auto& playHandle : playHandles)
{
auto nph = dynamic_cast<NotePlayHandle*>(*it);
auto nph = dynamic_cast<NotePlayHandle*>(playHandle);
if( nph && !nph->isReleased() )
{
nph->lock();
@@ -1310,9 +1309,9 @@ void Song::saveControllerStates( QDomDocument & doc, QDomElement & element )
// save settings of controllers
QDomElement controllersNode = doc.createElement( "controllers" );
element.appendChild( controllersNode );
for( int i = 0; i < m_controllers.size(); ++i )
for (const auto& controller : m_controllers)
{
m_controllers[i]->saveState( doc, controllersNode );
controller->saveState(doc, controllersNode);
}
}
@@ -1356,9 +1355,9 @@ void Song::saveScaleStates(QDomDocument &doc, QDomElement &element)
QDomElement scalesNode = doc.createElement("scales");
element.appendChild(scalesNode);
for (int i = 0; i < MaxScaleCount; i++)
for (const auto& scale : m_scales)
{
m_scales[i]->saveState(doc, scalesNode);
scale->saveState(doc, scalesNode);
}
}
@@ -1381,9 +1380,9 @@ void Song::saveKeymapStates(QDomDocument &doc, QDomElement &element)
QDomElement keymapsNode = doc.createElement("keymaps");
element.appendChild(keymapsNode);
for (int i = 0; i < MaxKeymapCount; i++)
for (const auto& keymap : m_keymaps)
{
m_keymaps[i]->saveState(doc, keymapsNode);
keymap->saveState(doc, keymapsNode);
}
}

View File

@@ -226,10 +226,9 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element )
}
// now save settings of all Clip's
for( clipVector::const_iterator it = m_clips.begin();
it != m_clips.end(); ++it )
for (const auto& clip : m_clips)
{
( *it )->saveState( doc, element );
clip->saveState(doc, element);
}
}
@@ -512,13 +511,11 @@ void Track::insertBar( const TimePos & pos )
{
// we'll increase the position of every Clip, positioned behind pos, by
// one bar
for( clipVector::iterator it = m_clips.begin();
it != m_clips.end(); ++it )
for (const auto& clip : m_clips)
{
if( ( *it )->startPosition() >= pos )
if (clip->startPosition() >= pos)
{
( *it )->movePosition( (*it)->startPosition() +
TimePos::ticksPerBar() );
clip->movePosition(clip->startPosition() + TimePos::ticksPerBar());
}
}
}
@@ -534,11 +531,11 @@ void Track::removeBar( const TimePos & pos )
{
// we'll decrease the position of every Clip, positioned behind pos, by
// one bar
for( clipVector::iterator it = m_clips.begin(); it != m_clips.end(); ++it )
for (const auto& clip : m_clips)
{
if( ( *it )->startPosition() >= pos )
if (clip->startPosition() >= pos)
{
(*it)->movePosition((*it)->startPosition() - TimePos::ticksPerBar());
clip->movePosition(clip->startPosition() - TimePos::ticksPerBar());
}
}
}
@@ -556,15 +553,14 @@ bar_t Track::length() const
{
// find last end-position
tick_t last = 0;
for( clipVector::const_iterator it = m_clips.begin(); it != m_clips.end(); ++it )
for (const auto& clip : m_clips)
{
if( Engine::getSong()->isExporting() &&
( *it )->isMuted() )
if (Engine::getSong()->isExporting() && clip->isMuted())
{
continue;
}
const tick_t cur = ( *it )->endPosition();
const tick_t cur = clip->endPosition();
if( cur > last )
{
last = cur;
@@ -587,12 +583,11 @@ void Track::toggleSolo()
const TrackContainer::TrackList & tl = m_trackContainer->tracks();
bool soloBefore = false;
for( TrackContainer::TrackList::const_iterator it = tl.begin();
it != tl.end(); ++it )
for (const auto& track : tl)
{
if( *it != this )
if (track != this)
{
if( ( *it )->m_soloModel.value() )
if (track->m_soloModel.value())
{
soloBefore = true;
break;
@@ -604,37 +599,36 @@ void Track::toggleSolo()
// Should we use the new behavior of solo or the older/legacy one?
const bool soloLegacyBehavior = ConfigManager::inst()->value("app", "sololegacybehavior", "0").toInt();
for( TrackContainer::TrackList::const_iterator it = tl.begin();
it != tl.end(); ++it )
for (const auto& track : tl)
{
if( solo )
if (solo)
{
// save mute-state in case no track was solo before
if( !soloBefore )
if (!soloBefore)
{
( *it )->m_mutedBeforeSolo = ( *it )->isMuted();
track->m_mutedBeforeSolo = track->isMuted();
}
// Don't mute AutomationTracks (keep their original state) unless we are on the sololegacybehavior mode
if( *it == this )
if (track == this)
{
( *it )->setMuted( false );
track->setMuted(false);
}
else if( soloLegacyBehavior || ( *it )->type() != AutomationTrack )
else if (soloLegacyBehavior || track->type() != AutomationTrack)
{
( *it )->setMuted( true );
track->setMuted(true);
}
if( *it != this )
if (track != this)
{
( *it )->m_soloModel.setValue( false );
track->m_soloModel.setValue(false);
}
}
else if( !soloBefore )
else if (!soloBefore)
{
// Unless we are on the sololegacybehavior mode, only restores the
// mute state if the track isn't an Automation Track
if( soloLegacyBehavior || ( *it )->type() != AutomationTrack )
if (soloLegacyBehavior || track->type() != AutomationTrack)
{
( *it )->setMuted( ( *it )->m_mutedBeforeSolo );
track->setMuted(track->m_mutedBeforeSolo);
}
}
}

View File

@@ -71,9 +71,9 @@ void TrackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this )
// save settings of each track
m_tracksMutex.lockForRead();
for( int i = 0; i < m_tracks.size(); ++i )
for (const auto& track : m_tracks)
{
m_tracks[i]->saveState( _doc, _this );
track->saveState(_doc, _this);
}
m_tracksMutex.unlock();
}
@@ -160,9 +160,9 @@ int TrackContainer::countTracks( Track::TrackTypes _tt ) const
{
int cnt = 0;
m_tracksMutex.lockForRead();
for( int i = 0; i < m_tracks.size(); ++i )
for (const auto& track : m_tracks)
{
if( m_tracks[i]->type() == _tt || _tt == Track::NumTrackTypes )
if (track->type() == _tt || _tt == Track::NumTrackTypes)
{
++cnt;
}
@@ -238,10 +238,9 @@ void TrackContainer::clearAllTracks()
bool TrackContainer::isEmpty() const
{
for( TrackList::const_iterator it = m_tracks.begin();
it != m_tracks.end(); ++it )
for (const auto& track : m_tracks)
{
if( !( *it )->getClips().isEmpty() )
if (!track->getClips().isEmpty())
{
return false;
}

View File

@@ -60,10 +60,9 @@ AudioSampleRecorder::~AudioSampleRecorder()
f_cnt_t AudioSampleRecorder::framesRecorded() const
{
f_cnt_t frames = 0;
for( BufferList::ConstIterator it = m_buffers.begin();
it != m_buffers.end(); ++it )
for (const auto& buffer : m_buffers)
{
frames += ( *it ).second;
frames += buffer.second;
}
return frames;
}

View File

@@ -111,7 +111,7 @@ const LinkedModelGroup *Lv2ControlBase::getGroup(std::size_t idx) const
void Lv2ControlBase::copyModelsFromLmms() {
for (auto& c : m_procs) { c->copyModelsFromCore(); }
for (const auto& c : m_procs) { c->copyModelsFromCore(); }
}
@@ -119,7 +119,7 @@ void Lv2ControlBase::copyModelsFromLmms() {
void Lv2ControlBase::copyModelsToLmms() const
{
for (auto& c : m_procs) { c->copyModelsToCore(); }
for (const auto& c : m_procs) { c->copyModelsToCore(); }
}
@@ -127,7 +127,8 @@ void Lv2ControlBase::copyModelsToLmms() const
void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) {
unsigned firstChan = 0; // tell the procs which channels they shall read from
for (auto& c : m_procs) {
for (const auto& c : m_procs)
{
c->copyBuffersFromCore(buf, firstChan, m_channelsPerProc, frames);
firstChan += m_channelsPerProc;
}
@@ -148,7 +149,7 @@ void Lv2ControlBase::copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const {
void Lv2ControlBase::run(fpp_t frames) {
for (auto& c : m_procs) { c->run(frames); }
for (const auto& c : m_procs) { c->run(frames); }
}
@@ -211,7 +212,7 @@ bool Lv2ControlBase::hasNoteInput() const
void Lv2ControlBase::handleMidiInputEvent(const MidiEvent &event,
const TimePos &time, f_cnt_t offset)
{
for (auto& c : m_procs) { c->handleMidiInputEvent(event, time, offset); }
for (const auto& c : m_procs) { c->handleMidiInputEvent(event, time, offset); }
}

View File

@@ -87,9 +87,9 @@ void Lv2Features::createFeatureVectors()
// create pointer vector (for lilv_plugin_instantiate)
m_featurePointers.reserve(m_features.size() + 1);
for(std::size_t i = 0; i < m_features.size(); ++i)
for (const auto& feature : m_features)
{
m_featurePointers.push_back(&m_features[i]);
m_featurePointers.push_back(&feature);
}
m_featurePointers.push_back(nullptr);
}

View File

@@ -237,9 +237,9 @@ void MidiClientRaw::parseData( const unsigned char c )
void MidiClientRaw::processParsedEvent()
{
for( int i = 0; i < m_midiPorts.size(); ++i )
for (const auto& midiPort : m_midiPorts)
{
m_midiPorts[i]->processInEvent( m_midiParseData.m_midiEvent );
midiPort->processInEvent(m_midiParseData.m_midiEvent);
}
}

View File

@@ -378,9 +378,9 @@ void MidiPort::updateReadablePorts()
m_readablePorts.clear();
const QStringList& wp = m_midiClient->readablePorts();
// now insert new ports and restore selections
for( QStringList::ConstIterator it = wp.begin(); it != wp.end(); ++it )
for (const auto& port : wp)
{
m_readablePorts[*it] = ( selectedPorts.indexOf( *it ) != -1 );
m_readablePorts[port] = (selectedPorts.indexOf(port) != -1);
}
emit readablePortsChanged();
@@ -404,9 +404,9 @@ void MidiPort::updateWritablePorts()
m_writablePorts.clear();
const QStringList & wp = m_midiClient->writablePorts();
// now insert new ports and restore selections
for( QStringList::ConstIterator it = wp.begin(); it != wp.end(); ++it )
for (const auto& port : wp)
{
m_writablePorts[*it] = ( selectedPorts.indexOf( *it ) != -1 );
m_writablePorts[port] = (selectedPorts.indexOf(port) != -1);
}
emit writablePortsChanged();

View File

@@ -155,14 +155,12 @@ void EffectRackView::update()
QVector<bool> view_map( qMax<int>( fxChain()->m_effects.size(),
m_effectViews.size() ), false );
for( QVector<Effect *>::Iterator it = fxChain()->m_effects.begin();
it != fxChain()->m_effects.end(); ++it )
for (const auto& effect : fxChain()->m_effects)
{
int i = 0;
for( QVector<EffectView *>::Iterator vit = m_effectViews.begin();
vit != m_effectViews.end(); ++vit, ++i )
for (const auto& effectView : m_effectViews)
{
if( ( *vit )->model() == *it )
if (effectView->model() == effect)
{
view_map[i] = true;
break;
@@ -170,7 +168,7 @@ void EffectRackView::update()
}
if( i >= m_effectViews.size() )
{
auto view = new EffectView(*it, w);
auto view = new EffectView(effect, w);
connect( view, SIGNAL(moveUp(lmms::gui::EffectView*)),
this, SLOT(moveUp(lmms::gui::EffectView*)));
connect( view, SIGNAL(moveDown(lmms::gui::EffectView*)),
@@ -238,13 +236,11 @@ void EffectRackView::addEffect()
update();
// Find the effectView, and show the controls
for( QVector<EffectView *>::Iterator vit = m_effectViews.begin();
vit != m_effectViews.end(); ++vit )
for (const auto& effectView : m_effectViews)
{
if( ( *vit )->effect() == fx )
if (effectView->effect() == fx)
{
( *vit )->editControls();
effectView->editControls();
break;
}
}

View File

@@ -217,9 +217,9 @@ void FileBrowser::reloadTree()
if (!paths.isEmpty())
{
for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it)
for (const auto& path : paths)
{
addItems(*it);
addItems(path);
}
}
expandItems(nullptr, expandedDirs);
@@ -979,13 +979,10 @@ void Directory::update()
{
m_dirCount = 0;
// for all paths leading here, add their items
for( QStringList::iterator it = m_directories.begin();
it != m_directories.end(); ++it )
for (const auto& directory : m_directories)
{
int filesBeforeAdd = childCount() - m_dirCount;
if( addItems( fullName( *it ) ) &&
( *it ).contains(
ConfigManager::inst()->dataDir() ) )
if(addItems(fullName(directory)) && directory.contains(ConfigManager::inst()->dataDir()))
{
// factory file directory is added
// note: those are always added last

View File

@@ -71,9 +71,10 @@ QLinearGradient getGradient( const QColor & _col, const QRectF & _rect )
QLinearGradient darken( const QLinearGradient & _gradient )
{
QGradientStops stops = _gradient.stops();
for (int i = 0; i < stops.size(); ++i) {
QColor color = stops.at(i).second;
stops[i].second = color.lighter(133);
for (auto& stop : stops)
{
QColor color = stop.second;
stop.second = color.lighter(133);
}
QLinearGradient g = _gradient;

View File

@@ -286,9 +286,9 @@ void MicrotunerConfig::updateKeymapForm()
m_keymapTextEdit->setPlainText("");
const std::vector<int> &map = newMap->getMap();
for (std::size_t i = 0; i < map.size(); i++)
for (int value : map)
{
if (map[i] >= 0) {m_keymapTextEdit->appendPlainText(QString::number(map[i]));}
if (value >= 0) {m_keymapTextEdit->appendPlainText(QString::number(value));}
else {m_keymapTextEdit->appendPlainText("x");}
}
QTextCursor tmp = m_keymapTextEdit->textCursor();

View File

@@ -168,9 +168,9 @@ MixerView::MixerView() :
MixerView::~MixerView()
{
for (int i=0; i<m_mixerChannelViews.size(); i++)
for (auto mixerChannelView : m_mixerChannelViews)
{
delete m_mixerChannelViews.at(i);
delete mixerChannelView;
}
}
@@ -239,21 +239,19 @@ void MixerView::updateMaxChannelSelector()
TrackContainer::TrackList songTracks = Engine::getSong()->tracks();
TrackContainer::TrackList patternStoreTracks = Engine::patternStore()->tracks();
TrackContainer::TrackList trackLists[] = {songTracks, patternStoreTracks};
for(int tl=0; tl<2; ++tl)
for (const auto& trackList : {songTracks, patternStoreTracks})
{
TrackContainer::TrackList trackList = trackLists[tl];
for(int i=0; i<trackList.size(); ++i)
for (const auto& track : trackList)
{
if( trackList[i]->type() == Track::InstrumentTrack )
if (track->type() == Track::InstrumentTrack)
{
auto inst = (InstrumentTrack*)trackList[i];
auto inst = (InstrumentTrack*)track;
inst->mixerChannelModel()->setRange(0,
m_mixerChannelViews.size()-1,1);
}
else if( trackList[i]->type() == Track::SampleTrack )
else if (track->type() == Track::SampleTrack)
{
auto strk = (SampleTrack*)trackList[i];
auto strk = (SampleTrack*)track;
strk->mixerChannelModel()->setRange(0,
m_mixerChannelViews.size()-1,1);
}

View File

@@ -195,15 +195,12 @@ void AutomationClipView::constructContextMenu( QMenu * _cm )
{
_cm->addSeparator();
auto m = new QMenu(tr("%1 Connections").arg(m_clip->m_objects.count()), _cm);
for( AutomationClip::objectVector::iterator it =
m_clip->m_objects.begin();
it != m_clip->m_objects.end(); ++it )
for (const auto& object : m_clip->m_objects)
{
if( *it )
if (object)
{
a = new QAction( tr( "Disconnect \"%1\"" ).
arg( ( *it )->fullDisplayName() ), m );
a->setData( ( *it )->id() );
a = new QAction(tr("Disconnect \"%1\"").arg(object->fullDisplayName()), m);
a->setData(object->id());
m->addAction( a );
}
}

View File

@@ -538,18 +538,16 @@ DataFile ClipView::createClipDataFiles(
DataFile dataFile( DataFile::DragNDropData );
QDomElement clipParent = dataFile.createElement("clips");
using clipViewVector = QVector<ClipView*>;
for( clipViewVector::const_iterator it = clipViews.begin();
it != clipViews.end(); ++it )
for (const auto& clipView : clipViews)
{
// Insert into the dom under the "clips" element
Track* clipTrack = ( *it )->m_trackView->getTrack();
Track* clipTrack = clipView->m_trackView->getTrack();
int trackIndex = tc->tracks().indexOf( clipTrack );
QDomElement clipElement = dataFile.createElement("clip");
clipElement.setAttribute( "trackIndex", trackIndex );
clipElement.setAttribute( "trackType", clipTrack->type() );
clipElement.setAttribute( "trackName", clipTrack->name() );
( *it )->m_clip->saveState( dataFile, clipElement );
clipView->m_clip->saveState(dataFile, clipElement);
clipParent.appendChild( clipElement );
}
@@ -796,9 +794,9 @@ void ClipView::mouseMoveEvent( QMouseEvent * me )
// Collect all selected Clips
QVector<selectableObject *> so =
m_trackView->trackContainerView()->selectedObjects();
for( auto it = so.begin(); it != so.end(); ++it )
for (const auto& selectedClip : so)
{
auto clipv = dynamic_cast<ClipView*>(*it);
auto clipv = dynamic_cast<ClipView*>(selectedClip);
if( clipv != nullptr )
{
clipViews.push_back( clipv );
@@ -1336,10 +1334,9 @@ void ClipView::setInitialOffsets()
{
QVector<selectableObject *> so = m_trackView->trackContainerView()->selectedObjects();
QVector<TimePos> offsets;
for( QVector<selectableObject *>::iterator it = so.begin();
it != so.end(); ++it )
for (const auto& selectedClip : so)
{
auto clipv = dynamic_cast<ClipView*>(*it);
auto clipv = dynamic_cast<ClipView*>(selectedClip);
if( clipv == nullptr )
{
continue;

View File

@@ -71,12 +71,11 @@ void PatternEditor::removeSteps()
{
TrackContainer::TrackList tl = model()->tracks();
for( TrackContainer::TrackList::iterator it = tl.begin();
it != tl.end(); ++it )
for (const auto& track : tl)
{
if( ( *it )->type() == Track::InstrumentTrack )
if (track->type() == Track::InstrumentTrack)
{
auto p = static_cast<MidiClip*>((*it)->getClip(m_ps->currentPattern()));
auto p = static_cast<MidiClip*>(track->getClip(m_ps->currentPattern()));
p->removeSteps();
}
}
@@ -179,12 +178,11 @@ void PatternEditor::makeSteps( bool clone )
{
TrackContainer::TrackList tl = model()->tracks();
for( TrackContainer::TrackList::iterator it = tl.begin();
it != tl.end(); ++it )
for (const auto& track : tl)
{
if( ( *it )->type() == Track::InstrumentTrack )
if (track->type() == Track::InstrumentTrack)
{
auto p = static_cast<MidiClip*>((*it)->getClip(m_ps->currentPattern()));
auto p = static_cast<MidiClip*>(track->getClip(m_ps->currentPattern()));
if( clone )
{
p->cloneSteps();

View File

@@ -393,7 +393,10 @@ PianoRoll::PianoRoll() :
// Set up key selection dropdown
m_keyModel.addItem(tr("No key"));
// Use piano roll note strings for key dropdown
for (int i = 0; i < 12; i++) { m_keyModel.addItem(s_noteStrings[i]); }
for (const auto& noteString : s_noteStrings)
{
m_keyModel.addItem(noteString);
}
m_keyModel.setValue(0); // start with "No key"
connect(&m_keyModel, &ComboBoxModel::dataChanged, this, &PianoRoll::keyChanged);
@@ -558,9 +561,9 @@ void PianoRoll::markSemiTone(int i, bool fromMenu)
{
// lets erase all of the ones that match this by octave
QList<int>::iterator i;
for (int ix = 0; ix < aok.size(); ++ix)
for (int octave : aok)
{
i = std::find(m_markedSemiTones.begin(), m_markedSemiTones.end(), aok.at(ix));
i = std::find(m_markedSemiTones.begin(), m_markedSemiTones.end(), octave);
if (i != m_markedSemiTones.end())
{
m_markedSemiTones.erase(i);
@@ -5159,10 +5162,10 @@ void PianoRollWindow::saveSettings( QDomDocument & doc, QDomElement & de )
if (m_editor->m_markedSemiTones.length() > 0)
{
QDomElement markedSemiTonesRoot = doc.createElement("markedSemiTones");
for (int ix = 0; ix < m_editor->m_markedSemiTones.size(); ++ix)
for (int markedSemiTone : m_editor->m_markedSemiTones)
{
QDomElement semiToneNode = doc.createElement("semiTone");
semiToneNode.setAttribute("key", m_editor->m_markedSemiTones.at(ix));
semiToneNode.setAttribute("key", markedSemiTone);
markedSemiTonesRoot.appendChild(semiToneNode);
}
de.appendChild(markedSemiTonesRoot);

View File

@@ -77,10 +77,9 @@ QVector<selectableObject *> RubberBand::selectableObjects() const
QList<selectableObject *> l =
parentWidget()->findChildren<selectableObject *>();
for( QList<selectableObject *>::iterator it = l.begin(); it != l.end();
++it )
for (const auto& obj : l)
{
so.push_back( *it );
so.push_back(obj);
}
return( so );
}

View File

@@ -507,10 +507,9 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )
else if( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace )
{
QVector<selectableObject *> so = selectedObjects();
for( QVector<selectableObject *>::iterator it = so.begin();
it != so.end(); ++it )
for (const auto& selectedClip : so)
{
auto clipv = dynamic_cast<ClipView*>(*it);
auto clipv = dynamic_cast<ClipView*>(selectedClip);
clipv->remove();
}
}

View File

@@ -258,11 +258,10 @@ void TrackContainerView::realignTracks()
m_scrollArea->widget()->setFixedHeight(
m_scrollArea->widget()->minimumSizeHint().height());
for( trackViewList::iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
for (const auto& trackView : m_trackViews)
{
( *it )->show();
( *it )->update();
trackView->show();
trackView->update();
}
}
@@ -274,10 +273,9 @@ TrackView * TrackContainerView::createTrackView( Track * _t )
//m_tc->addJournalCheckPoint();
// Avoid duplicating track views
for( trackViewList::iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
for (const auto& trackView : m_trackViews)
{
if ( ( *it )->getTrack() == _t ) { return ( *it ); }
if (trackView->getTrack() == _t) { return trackView; }
}
return _t->createView( this );
@@ -310,15 +308,11 @@ const TrackView * TrackContainerView::trackViewAt( const int _y ) const
// debug code
// qDebug( "abs_y %d", abs_y );
for( trackViewList::const_iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
for (const auto& trackView : m_trackViews)
{
const int y_cnt1 = y_cnt;
y_cnt += ( *it )->height();
if( abs_y >= y_cnt1 && abs_y < y_cnt )
{
return( *it );
}
y_cnt += trackView->height();
if (abs_y >= y_cnt1 && abs_y < y_cnt) { return trackView; }
}
return( nullptr );
}
@@ -347,10 +341,9 @@ void TrackContainerView::setPixelsPerBar( int ppb )
m_ppb = ppb;
// tell all TrackContentWidgets to update their background tile pixmap
for( trackViewList::Iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
for (const auto& trackView : m_trackViews)
{
( *it )->getTrackContentWidget()->updateBackground();
trackView->getTrackContentWidget()->updateBackground();
}
}

View File

@@ -174,11 +174,10 @@ void TrackContentWidget::removeClipView( ClipView * clipv )
*/
void TrackContentWidget::update()
{
for( clipViewVector::iterator it = m_clipViews.begin();
it != m_clipViews.end(); ++it )
for (const auto& clipView : m_clipViews)
{
( *it )->setFixedHeight( height() - 1 );
( *it )->update();
clipView->setFixedHeight(height() - 1);
clipView->update();
}
QWidget::update();
}
@@ -200,28 +199,20 @@ void TrackContentWidget::changePosition( const TimePos & newPos )
setUpdatesEnabled( false );
// first show clip for current pattern...
for( clipViewVector::iterator it = m_clipViews.begin();
it != m_clipViews.end(); ++it )
for (const auto& clipView : m_clipViews)
{
if ((*it)->getClip()->startPosition().getBar() == curPattern)
if (clipView->getClip()->startPosition().getBar() == curPattern)
{
( *it )->move( 0, ( *it )->y() );
( *it )->raise();
( *it )->show();
}
else
{
( *it )->lower();
clipView->move(0, clipView->y());
clipView->raise();
clipView->show();
}
else { clipView->lower(); }
}
// ...then hide others to avoid flickering
for( clipViewVector::iterator it = m_clipViews.begin();
it != m_clipViews.end(); ++it )
for (const auto& clipView : m_clipViews)
{
if ((*it)->getClip()->startPosition().getBar() != curPattern)
{
( *it )->hide();
}
if (clipView->getClip()->startPosition().getBar() != curPattern) { clipView->hide(); }
}
setUpdatesEnabled( true );
return;
@@ -238,11 +229,9 @@ void TrackContentWidget::changePosition( const TimePos & newPos )
const float ppb = m_trackView->trackContainerView()->pixelsPerBar();
setUpdatesEnabled( false );
for( clipViewVector::iterator it = m_clipViews.begin();
it != m_clipViews.end(); ++it )
for (const auto& clipView : m_clipViews)
{
ClipView * clipv = *it;
Clip * clip = clipv->getClip();
Clip* clip = clipView->getClip();
clip->changeLength( clip->length() );
@@ -252,17 +241,15 @@ void TrackContentWidget::changePosition( const TimePos & newPos )
( te >= begin && te <= end ) ||
( ts <= begin && te >= end ) )
{
clipv->move( static_cast<int>( ( ts - begin ) * ppb /
TimePos::ticksPerBar() ),
clipv->y() );
if( !clipv->isVisible() )
clipView->move(static_cast<int>((ts - begin) * ppb / TimePos::ticksPerBar()), clipView->y());
if (!clipView->isVisible())
{
clipv->show();
clipView->show();
}
}
else
{
clipv->move( -clipv->width()-10, clipv->y() );
clipView->move(-clipView->width() - 10, clipView->y());
}
}
setUpdatesEnabled( true );
@@ -456,10 +443,9 @@ bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md,
// Unselect the old group
const QVector<selectableObject *> so =
m_trackView->trackContainerView()->selectedObjects();
for( QVector<selectableObject *>::const_iterator it = so.begin();
it != so.end(); ++it )
for (const auto& obj : so)
{
( *it )->setSelected( false );
obj->setSelected(false);
}

View File

@@ -104,9 +104,9 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) :
m_track, SLOT(toggleSolo()), Qt::DirectConnection );
// create views for already existing clips
for( Track::clipVector::iterator it = m_track->m_clips.begin(); it != m_track->m_clips.end(); ++it )
for (const auto& clip : m_track->m_clips)
{
createClipView( *it );
createClipView(clip);
}
m_trackContainerView->addTrackView( this );

View File

@@ -192,10 +192,9 @@ automatableButtonGroup::automatableButtonGroup( QWidget * _parent,
automatableButtonGroup::~automatableButtonGroup()
{
for( QList<AutomatableButton *>::iterator it = m_buttons.begin();
it != m_buttons.end(); ++it )
for (const auto& button : m_buttons)
{
( *it )->m_group = nullptr;
button->m_group = nullptr;
}
}

View File

@@ -164,13 +164,12 @@ void LcdWidget::paintEvent( QPaintEvent* )
}
// Digits
for( int i=0; i < m_display.length(); i++ )
for (const auto& digit : m_display)
{
int val = m_display[i].digitValue();
int val = digit.digitValue();
if( val < 0 )
{
if( m_display[i] == '-' )
val = 11;
if (digit == '-') val = 11;
else
val = 10;
}

View File

@@ -200,10 +200,9 @@ void TabWidget::resizeEvent( QResizeEvent * )
{
if (!m_resizable)
{
for ( widgetStack::iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
for (const auto& widget : m_widgets)
{
( *it ).w->setFixedSize( width() - 4, height() - m_tabbarHeight );
widget.w->setFixedSize(width() - 4, height() - m_tabbarHeight);
}
}
}
@@ -320,11 +319,10 @@ QSize TabWidget::minimumSizeHint() const
if (m_resizable)
{
int maxWidth = 0, maxHeight = 0;
for ( widgetStack::const_iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
for (const auto& widget : m_widgets)
{
maxWidth = std::max(maxWidth, it->w->minimumSizeHint().width());
maxHeight = std::max(maxHeight, it->w->minimumSizeHint().height());
maxWidth = std::max(maxWidth, widget.w->minimumSizeHint().width());
maxHeight = std::max(maxHeight, widget.w->minimumSizeHint().height());
}
// "-1" :
// in "addTab", under "Position tab's window", the widget is
@@ -342,11 +340,10 @@ QSize TabWidget::sizeHint() const
if (m_resizable)
{
int maxWidth = 0, maxHeight = 0;
for ( widgetStack::const_iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
for (const auto& widget : m_widgets)
{
maxWidth = std::max(maxWidth, it->w->sizeHint().width());
maxHeight = std::max(maxHeight, it->w->sizeHint().height());
maxWidth = std::max(maxWidth, widget.w->sizeHint().width());
maxHeight = std::max(maxHeight, widget.w->sizeHint().height());
}
// "-1" :
// in "addTab", under "Position tab's window", the widget is

View File

@@ -621,10 +621,9 @@ void InstrumentTrack::setName( const QString & _new_name )
void InstrumentTrack::updateBaseNote()
{
Engine::audioEngine()->requestChangeInModel();
for( NotePlayHandleList::Iterator it = m_processHandles.begin();
it != m_processHandles.end(); ++it )
for (const auto& processHandle : m_processHandles)
{
( *it )->setFrequencyUpdate();
processHandle->setFrequencyUpdate();
}
Engine::audioEngine()->doneChangeInModel();
}
@@ -711,10 +710,9 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames,
}
// Handle automation: detuning
for( NotePlayHandleList::Iterator it = m_processHandles.begin();
it != m_processHandles.end(); ++it )
for (const auto& processHandle : m_processHandles)
{
( *it )->processTimePos( _start );
processHandle->processTimePos(_start);
}
if ( clips.size() == 0 )
@@ -725,14 +723,12 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames,
bool played_a_note = false; // will be return variable
for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it )
for (const auto& clip : clips)
{
auto c = dynamic_cast<MidiClip*>(*it);
auto c = dynamic_cast<MidiClip*>(clip);
// everything which is not a MIDI clip won't be played
// A MIDI clip playing in the Piano Roll window will always play
if(c == nullptr ||
(Engine::getSong()->playMode() != Song::Mode_PlayMidiClip
&& (*it)->isMuted()))
if (c == nullptr || (Engine::getSong()->playMode() != Song::Mode_PlayMidiClip && clip->isMuted()))
{
continue;
}

View File

@@ -68,9 +68,9 @@ MidiClip::MidiClip( const MidiClip& other ) :
m_clipType( other.m_clipType ),
m_steps( other.m_steps )
{
for( NoteVector::ConstIterator it = other.m_notes.begin(); it != other.m_notes.end(); ++it )
for (const auto& note : other.m_notes)
{
m_notes.push_back( new Note( **it ) );
m_notes.push_back(new Note(*note));
}
init();
@@ -93,10 +93,9 @@ MidiClip::~MidiClip()
{
emit destroyedMidiClip( this );
for( NoteVector::Iterator it = m_notes.begin();
it != m_notes.end(); ++it )
for (const auto& note : m_notes)
{
delete *it;
delete note;
}
m_notes.clear();
@@ -110,16 +109,16 @@ void MidiClip::resizeToFirstTrack()
// Resize this track to be the same as existing tracks in the pattern
const TrackContainer::TrackList & tracks =
m_instrumentTrack->trackContainer()->tracks();
for(unsigned int trackID = 0; trackID < tracks.size(); ++trackID)
for (const auto& track : tracks)
{
if(tracks.at(trackID)->type() == Track::InstrumentTrack)
if (track->type() == Track::InstrumentTrack)
{
if(tracks.at(trackID) != m_instrumentTrack)
if (track != m_instrumentTrack)
{
unsigned int currentClip = m_instrumentTrack->
getClips().indexOf(this);
m_steps = static_cast<MidiClip *>
(tracks.at(trackID)->getClip(currentClip))
(track->getClip(currentClip))
->m_steps;
}
break;
@@ -154,13 +153,11 @@ void MidiClip::updateLength()
tick_t max_length = TimePos::ticksPerBar();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
for (const auto& note : m_notes)
{
if( ( *it )->length() > 0 )
if (note->length() > 0)
{
max_length = qMax<tick_t>( max_length,
( *it )->endPos() );
max_length = qMax<tick_t>(max_length, note->endPos());
}
}
changeLength( TimePos( max_length ).nextFullBar() *
@@ -175,13 +172,11 @@ TimePos MidiClip::beatClipLength() const
{
tick_t max_length = TimePos::ticksPerBar();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
for (const auto& note : m_notes)
{
if( ( *it )->length() < 0 )
if (note->length() < 0)
{
max_length = qMax<tick_t>( max_length,
( *it )->pos() + 1 );
max_length = qMax<tick_t>(max_length, note->pos() + 1);
}
}
@@ -247,13 +242,11 @@ void MidiClip::removeNote( Note * _note_to_del )
Note * MidiClip::noteAtStep( int _step )
{
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end();
++it )
for (const auto& note : m_notes)
{
if( ( *it )->pos() == TimePos::stepPosition( _step )
&& ( *it )->length() < 0 )
if (note->pos() == TimePos::stepPosition(_step) && note->length() < 0)
{
return *it;
return note;
}
}
return nullptr;
@@ -272,10 +265,9 @@ void MidiClip::rearrangeAllNotes()
void MidiClip::clearNotes()
{
instrumentTrack()->lock();
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end();
++it )
for (const auto& note : m_notes)
{
delete *it;
delete note;
}
m_notes.clear();
instrumentTrack()->unlock();
@@ -322,10 +314,8 @@ void MidiClip::splitNotes(NoteVector notes, TimePos pos)
addJournalCheckPoint();
for (int i = 0; i < notes.size(); ++i)
for (const auto& note : notes)
{
Note* note = notes.at(i);
int leftLength = pos.getTicks() - note->pos();
int rightLength = note->length() - leftLength;
@@ -405,10 +395,9 @@ void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "steps", m_steps );
// now save settings of all notes
for( NoteVector::Iterator it = m_notes.begin();
it != m_notes.end(); ++it )
for (const auto& note : m_notes)
{
( *it )->saveState( _doc, _this );
note->saveState( _doc, _this );
}
}
@@ -582,10 +571,9 @@ void MidiClip::updatePatternTrack()
bool MidiClip::empty()
{
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
for (const auto& note : m_notes)
{
if( ( *it )->length() != 0 )
if (note->length() != 0)
{
return false;
}
@@ -599,13 +587,11 @@ bool MidiClip::empty()
void MidiClip::changeTimeSignature()
{
TimePos last_pos = TimePos::ticksPerBar() - 1;
for( NoteVector::ConstIterator cit = m_notes.begin();
cit != m_notes.end(); ++cit )
for (const auto& note : m_notes)
{
if( ( *cit )->length() < 0 && ( *cit )->pos() > last_pos )
if (note->length() < 0 && note->pos() > last_pos)
{
last_pos = ( *cit )->pos()+TimePos::ticksPerBar() /
TimePos::stepsPerBar();
last_pos = note->pos() + TimePos::ticksPerBar() / TimePos::stepsPerBar();
}
}
last_pos = last_pos.nextFullBar() * TimePos::ticksPerBar();

View File

@@ -109,13 +109,12 @@ bool PatternTrack::play( const TimePos & _start, const fpp_t _frames,
TimePos lastPosition;
TimePos lastLen;
for( clipVector::iterator it = clips.begin(); it != clips.end(); ++it )
for (const auto& clip : clips)
{
if( !( *it )->isMuted() &&
( *it )->startPosition() >= lastPosition )
if (!clip->isMuted() && clip->startPosition() >= lastPosition)
{
lastPosition = ( *it )->startPosition();
lastLen = ( *it )->length();
lastPosition = clip->startPosition();
lastLen = clip->length();
}
}
@@ -181,15 +180,11 @@ void PatternTrack::loadTrackSpecificSettings(const QDomElement& _this)
{
const int src = _this.attribute("sourcepattern").toInt();
const int dst = s_infoMap[this];
TrackContainer::TrackList tl =
Engine::patternStore()->tracks();
// copy clips of all tracks from source pattern (at bar "src") to destination
// clips (which are created if they do not exist yet)
for( TrackContainer::TrackList::iterator it = tl.begin();
it != tl.end(); ++it )
for (const auto& track : Engine::patternStore()->tracks())
{
Clip::copyStateTo( ( *it )->getClip( src ),
( *it )->getClip( dst ) );
Clip::copyStateTo(track->getClip(src), track->getClip(dst));
}
setName( tr( "Clone of %1" ).arg(
_this.parentNode().toElement().attribute( "name" ) ) );

View File

@@ -135,9 +135,9 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames,
setPlaying(nowPlaying);
}
for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it )
for (const auto& clip : clips)
{
auto st = dynamic_cast<SampleClip*>(*it);
auto st = dynamic_cast<SampleClip*>(clip);
if( !st->isMuted() )
{
PlayHandle* handle;