diff --git a/include/DataFile.h b/include/DataFile.h index 5eb61a93297..fb8b2ae3e0a 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -143,14 +143,6 @@ class LMMS_EXPORT DataFile : public QDomDocument void loadData( const QByteArray & _data, const QString & _sourceFile ); - - struct LMMS_EXPORT typeDescStruct - { - Type m_type; - QString m_name; - } ; - static typeDescStruct s_types[TypeCount]; - QString m_fileName; //!< The origin file name or "" if this DataFile didn't originate from a file QDomElement m_content; QDomElement m_head; diff --git a/include/InstrumentFunctions.h b/include/InstrumentFunctions.h index a349ddf9ccf..5dcb1114b65 100644 --- a/include/InstrumentFunctions.h +++ b/include/InstrumentFunctions.h @@ -52,6 +52,7 @@ class InstrumentFunctionNoteStacking : public Model, public JournallingObject public: static const int MAX_CHORD_POLYPHONY = 13; + static const int NUM_CHORD_TABLES = 95; private: using ChordSemiTones = std::array; @@ -129,7 +130,7 @@ class InstrumentFunctionNoteStacking : public Model, public JournallingObject ChordSemiTones m_semiTones; }; - static Init s_initTable[]; + static std::array s_initTable; public: static const ChordTable & getInstance() diff --git a/include/Oscillator.h b/include/Oscillator.h index e9f64008cc3..8727ee39cc0 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -255,7 +255,7 @@ class LMMS_EXPORT Oscillator static fftwf_plan s_fftPlan; static fftwf_plan s_ifftPlan; static fftwf_complex * s_specBuf; - static float s_sampleBuffer[OscillatorConstants::WAVETABLE_LENGTH]; + static std::array s_sampleBuffer; static void generateSawWaveTable(int bands, sample_t* table, int firstBand = 1); static void generateTriangleWaveTable(int bands, sample_t* table, int firstBand = 1); diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 60cf01e1ddd..c1973f407b7 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -343,7 +343,7 @@ protected slots: static QPixmap * s_toolOpen; static QPixmap* s_toolKnife; - static PianoRollKeyTypes prKeyOrder[]; + static std::array prKeyOrder; static TextFloat * s_textFloat; diff --git a/include/ProjectRenderer.h b/include/ProjectRenderer.h index 75537ed69a9..2ca20569b51 100644 --- a/include/ProjectRenderer.h +++ b/include/ProjectRenderer.h @@ -76,7 +76,7 @@ class LMMS_EXPORT ProjectRenderer : public QThread static QString getFileExtensionFromFormat( ExportFileFormats fmt ); - static const FileEncodeDevice fileEncodeDevices[]; + static const std::array fileEncodeDevices; public slots: void startProcessing(); diff --git a/plugins/Amplifier/Amplifier.cpp b/plugins/Amplifier/Amplifier.cpp index 3fb03d3d94e..9344807c49c 100644 --- a/plugins/Amplifier/Amplifier.cpp +++ b/plugins/Amplifier/Amplifier.cpp @@ -74,7 +74,7 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - + const ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer(); const ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer(); const ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer(); @@ -83,8 +83,8 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( fpp_t f = 0; f < frames; ++f ) { // qDebug( "offset %d, value %f", f, m_ampControls.m_volumeModel.value( f ) ); - - sample_t s[2] = { buf[f][0], buf[f][1] }; + + auto s = std::array{buf[f][0], buf[f][1]}; // vol knob if( volBuf ) @@ -99,8 +99,8 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) } // convert pan values to left/right values - const float pan = panBuf - ? panBuf->value( f ) + const float pan = panBuf + ? panBuf->value( f ) : m_ampControls.m_panModel.value(); const float left1 = pan <= 0 ? 1.0 @@ -111,12 +111,12 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) // second stage amplification const float left2 = leftBuf - ? leftBuf->value( f ) + ? leftBuf->value( f ) : m_ampControls.m_leftModel.value(); const float right2 = rightBuf - ? rightBuf->value( f ) + ? rightBuf->value( f ) : m_ampControls.m_rightModel.value(); - + s[0] *= left1 * left2 * 0.01; s[1] *= right1 * right2 * 0.01; diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index 77667c12191..48e26591193 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -102,7 +102,7 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames m_bbFX.leftFX().setGain( gain ); m_bbFX.rightFX().setGain( gain); - sample_t s[2] = { buf[f][0], buf[f][1] }; + auto s = std::array{buf[f][0], buf[f][1]}; m_bbFX.nextSample( s[0], s[1] ); buf[f][0] = d * buf[f][0] + w * s[0]; diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 68724eccde3..963e970db10 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -35,8 +35,8 @@ const int OS_RATE = 5; const float OS_RATIO = 1.0f / OS_RATE; const float CUTOFF_RATIO = 0.353553391f; const int SILENCEFRAMES = 10; -const float OS_RESAMPLE [5] = { 0.0001490062883964112, 0.1645978376763992, 0.6705063120704088, - 0.1645978376763992, 0.0001490062883964112 }; +const auto OS_RESAMPLE = std::array{0.0001490062883964112f, 0.1645978376763992f, 0.6705063120704088f, + 0.1645978376763992f, 0.0001490062883964112f }; extern "C" { @@ -65,13 +65,13 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu m_buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() * OS_RATE ); m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) ); m_needsUpdate = true; - + m_bitCounterL = 0.0f; m_bitCounterR = 0.0f; - + m_left = 0.0f; m_right = 0.0f; - + m_silenceCounter = 0; } @@ -125,7 +125,7 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_rateCoeffL = ( m_sampleRate * OS_RATE ) / ( rate - diff ); m_rateCoeffR = ( m_sampleRate * OS_RATE ) / ( rate + diff ); - + m_bitCounterL = 0.0f; m_bitCounterR = 0.0f; } @@ -147,9 +147,9 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_outClip = dbfsToAmp( m_controls.m_outClip.value() ); } m_needsUpdate = false; - + const float noiseAmt = m_controls.m_inNoise.value() * 0.01f; - + // read input buffer and write it to oversampled buffer if( m_rateEnabled ) // rate crushing enabled so do that { @@ -164,15 +164,15 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) if( m_bitCounterL > m_rateCoeffL ) { m_bitCounterL -= m_rateCoeffL; - m_left = m_depthEnabled - ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) + m_left = m_depthEnabled + ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) : buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ); } if( m_bitCounterR > m_rateCoeffR ) { m_bitCounterR -= m_rateCoeffR; - m_right = m_depthEnabled - ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) + m_right = m_depthEnabled + ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) : buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ); } } @@ -185,17 +185,17 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( int o = 0; o < OS_RATE; ++o ) { m_buffer[f * OS_RATE + o][0] = m_depthEnabled - ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) + ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) : buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ); m_buffer[f * OS_RATE + o][1] = m_depthEnabled - ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) + ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) : buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ); } } } - + // the oversampled buffer is now written, so filter it to reduce aliasing - + for( int f = 0; f < frames * OS_RATE; ++f ) { if( qMax( qAbs( m_buffer[f][0] ), qAbs( m_buffer[f][1] ) ) >= 1.0e-10f ) @@ -218,10 +218,10 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) } } } - - + + // now downsample and write it back to main buffer - + double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); @@ -238,7 +238,7 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) buf[f][1] = d * buf[f][1] + w * qBound( -m_outClip, rsum, m_outClip ) * m_outGain; outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; } - + checkGate( outSum / frames ); return isRunning(); diff --git a/plugins/Compressor/Compressor.cpp b/plugins/Compressor/Compressor.cpp index 312a40d3d50..92123ffd91f 100755 --- a/plugins/Compressor/Compressor.cpp +++ b/plugins/Compressor/Compressor.cpp @@ -276,7 +276,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) float rOutPeak = 0.0; float lInPeak = 0.0; float rInPeak = 0.0; - + const bool midside = m_compressorControls.m_midsideModel.value(); const bool peakmode = m_compressorControls.m_peakmodeModel.value(); const float inBalance = m_compressorControls.m_inBalanceModel.value(); @@ -292,8 +292,8 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) for(fpp_t f = 0; f < frames; ++f) { - sample_t drySignal[2] = {buf[f][0], buf[f][1]}; - sample_t s[2] = {drySignal[0] * m_inGainVal, drySignal[1] * m_inGainVal}; + auto drySignal = std::array{buf[f][0], buf[f][1]}; + auto s = std::array{drySignal[0] * m_inGainVal, drySignal[1] * m_inGainVal}; // Calculate tilt filters, to bias the sidechain to the low or high frequencies if (m_tiltVal) @@ -512,7 +512,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) m_inputBufLoc = 0; } - const float temp[2] = {drySignal[0], drySignal[1]}; + const auto temp = std::array{drySignal[0], drySignal[1]}; s[0] = m_inputBuf[0][m_inputBufLoc]; s[1] = m_inputBuf[1][m_inputBufLoc]; @@ -525,8 +525,8 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) s[1] = drySignal[1]; } - float delayedDrySignal[2] = {s[0], s[1]}; - + auto delayedDrySignal = std::array{s[0], s[1]}; + if (midside)// Convert left/right to mid/side { const float temp = s[0]; diff --git a/plugins/Compressor/CompressorControlDialog.cpp b/plugins/Compressor/CompressorControlDialog.cpp index 2f9fed9c232..8c6f61bec88 100755 --- a/plugins/Compressor/CompressorControlDialog.cpp +++ b/plugins/Compressor/CompressorControlDialog.cpp @@ -206,7 +206,7 @@ CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : peakButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("peak_sel")); peakButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("peak_unsel")); peakButton->setToolTip(tr("Use absolute value of the input")); - + rmsPeakGroup = new automatableButtonGroup(this); rmsPeakGroup->addButton(rmsButton); rmsPeakGroup->addButton(peakButton); @@ -221,7 +221,7 @@ CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : midSideButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("midside_sel")); midSideButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("midside_unsel")); midSideButton->setToolTip(tr("Compress mid and side audio")); - + leftRightMidSideGroup = new automatableButtonGroup(this); leftRightMidSideGroup->addButton(leftRightButton); leftRightMidSideGroup->addButton(midSideButton); @@ -514,8 +514,8 @@ void CompressorControlDialog::redrawKnee() { m_p.setPen(QPen(m_kneeColor2, 3)); - float prevPoint[2] = {kneePoint1, kneePoint1}; - float newPoint[2] = {0, 0}; + auto prevPoint = std::array{kneePoint1, kneePoint1}; + auto newPoint = std::array{0.f, 0.f}; // Draw knee curve using many straight lines. for (int i = 0; i < COMP_KNEE_LINES; ++i) @@ -542,7 +542,7 @@ void CompressorControlDialog::redrawKnee() m_p.end(); m_p.begin(&m_kneePixmap2); - + m_p.setCompositionMode(QPainter::CompositionMode_Source); m_p.fillRect(0, 0, m_windowSizeX, m_kneeWindowSizeY, QColor("transparent")); m_p.setCompositionMode(QPainter::CompositionMode_SourceOver); diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 1c6a74b8635..6db2f38e387 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -91,7 +91,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) const float sr = Engine::audioEngine()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); - sample_t dryS[2]; + auto dryS = std::array{}; float lPeak = 0.0; float rPeak = 0.0; float length = m_delayControls.m_delayTimeModel.value(); diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index 75a2ab532c7..e510109e998 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -134,8 +134,8 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames const bool enabled1 = m_dfControls.m_enabled1Model.value(); const bool enabled2 = m_dfControls.m_enabled2Model.value(); - - + + // buffer processing loop for( fpp_t f = 0; f < frames; ++f ) @@ -145,9 +145,9 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames const float mix1 = 1.0f - mix2; const float gain1 = *gain1Ptr * 0.01f; const float gain2 = *gain2Ptr * 0.01f; - sample_t s[2] = { 0.0f, 0.0f }; // mix - sample_t s1[2] = { buf[f][0], buf[f][1] }; // filter 1 - sample_t s2[2] = { buf[f][0], buf[f][1] }; // filter 2 + auto s = std::array{0.0f, 0.0f}; // mix + auto s1 = std::array{buf[f][0], buf[f][1]}; // filter 1 + auto s2 = std::array{buf[f][0], buf[f][1]}; // filter 2 // update filter 1 if( enabled1 ) diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.cpp b/plugins/DynamicsProcessor/DynamicsProcessor.cpp index c8ad9a029ce..54f1f0c509c 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessor.cpp @@ -105,17 +105,17 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, // variables for effect int i = 0; - float sm_peak[2] = { 0.0f, 0.0f }; + auto sm_peak = std::array{0.0f, 0.0f}; float gain; double out_sum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - + const int stereoMode = m_dpControls.m_stereomodeModel.value(); const float inputGain = m_dpControls.m_inputModel.value(); const float outputGain = m_dpControls.m_outputModel.value(); - + const float * samples = m_dpControls.m_wavegraphModel.samples(); // debug code @@ -143,7 +143,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - double s[2] = { _buf[f][0], _buf[f][1] }; + auto s = std::array{_buf[f][0], _buf[f][1]}; // apply input gain s[0] *= inputGain; @@ -211,7 +211,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, gain = samples[199]; }; - s[i] *= gain; + s[i] *= gain; s[i] /= sm_peak[i]; } } diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp b/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp index f4bd8c77a34..541031a3feb 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp @@ -116,7 +116,7 @@ void DynProcControls::saveSettings( QDomDocument & _doc, void DynProcControls::setDefaultShape() { - float shp [200] = { }; + auto shp = std::array{}; for ( int i = 0; i<200; i++) { shp[i] = ((float)i + 1.0f) / 200.0f; diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index be74defbaa4..eb168a9f9b5 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -71,7 +71,7 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) //wet/dry controls const float dry = dryLevel(); const float wet = wetLevel(); - sample_t dryS[2]; + auto dryS = std::array{}; // setup sample exact controls float hpRes = m_eqControls.m_hpResModel.value(); float lowShelfRes = m_eqControls.m_lowShelfResModel.value(); diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index 982702ebe8a..562badc0a83 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -104,7 +104,7 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI ); m_lDelay->setFeedback( m_flangerControls.m_feedbackModel.value() ); m_rDelay->setFeedback( m_flangerControls.m_feedbackModel.value() ); - sample_t dryS[2]; + auto dryS = std::array{}; float leftLfo; float rightLfo; for( fpp_t f = 0; f < frames; ++f ) diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index e5ded87ee8f..0d639d3a691 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -311,7 +311,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, data = 128; papu->write_register( fakeClock(), 0xff1a, data ); - int ch3voldata[4] = { 0, 3, 2, 1 }; + auto ch3voldata = std::array{0, 3, 2, 1}; data = ch3voldata[(int)m_ch3VolumeModel.value()]; data = data<<5; papu->write_register( fakeClock(), 0xff1c, data ); @@ -388,7 +388,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, int const buf_size = 2048; int framesleft = frames; int datalen = 0; - blip_sample_t buf [buf_size*2]; + auto buf = std::array{}; while( framesleft > 0 ) { int avail = papu->samples_avail(); @@ -401,7 +401,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, datalen = framesleft>avail?avail:framesleft; datalen = datalen>buf_size?buf_size:datalen; - long count = papu->read_samples( buf, datalen*2)/2; + long count = papu->read_samples(buf.data(), datalen * 2) / 2; for( fpp_t frame = 0; frame < count; ++frame ) { diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index 572d60cd891..e5d1c5d69c5 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -130,7 +130,7 @@ void LadspaEffect::changeSampleRate() -bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, +bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { m_pluginMutex.lock(); @@ -154,7 +154,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } // Copy the LMMS audio buffer to the LADSPA input buffer and initialize - // the control ports. + // the control ports. ch_cnt_t channel = 0; for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { @@ -164,10 +164,10 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, switch( pp->rate ) { case CHANNEL_IN: - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { - pp->buffer[frame] = + pp->buffer[frame] = _buf[frame][channel]; } ++channel; @@ -181,15 +181,15 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } else { - pp->value = static_cast( + pp->value = static_cast( pp->control->value() / pp->scale ); // This only supports control rate ports, so the audio rates are // treated as though they were control rate by setting the // port buffer to all the same value. - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { - pp->buffer[frame] = + pp->buffer[frame] = pp->value; } } @@ -200,9 +200,9 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, { break; } - pp->value = static_cast( + pp->value = static_cast( pp->control->value() / pp->scale ); - pp->buffer[0] = + pp->buffer[0] = pp->value; break; case CHANNEL_OUT: @@ -239,7 +239,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, case CONTROL_RATE_INPUT: break; case CHANNEL_OUT: - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { _buf[frame][channel] = d * _buf[frame][channel] + w * pp->buffer[frame]; @@ -303,7 +303,7 @@ void LadspaEffect::pluginInstantiation() int inputch = 0; int outputch = 0; - LADSPA_Data * inbuf [2]; + std::array inbuf; inbuf[0] = nullptr; inbuf[1] = nullptr; for( ch_cnt_t proc = 0; proc < processorCount(); proc++ ) @@ -463,9 +463,9 @@ void LadspaEffect::pluginInstantiation() ports.append( p ); - // For convenience, keep a separate list of the ports that are used + // For convenience, keep a separate list of the ports that are used // to control the processors. - if( p->rate == AUDIO_RATE_INPUT || + if( p->rate == AUDIO_RATE_INPUT || p->rate == CONTROL_RATE_INPUT ) { p->control_id = m_portControls.count(); @@ -479,7 +479,7 @@ void LadspaEffect::pluginInstantiation() m_descriptor = manager->getDescriptor( m_key ); if( m_descriptor == nullptr ) { - QMessageBox::warning( 0, "Effect", + QMessageBox::warning( 0, "Effect", "Can't get LADSPA descriptor function: " + m_key.second, QMessageBox::Ok, QMessageBox::NoButton ); setOkay( false ); @@ -518,8 +518,8 @@ void LadspaEffect::pluginInstantiation() port, pp->buffer ) ) { - QMessageBox::warning( 0, "Effect", - "Failed to connect port: " + m_key.second, + QMessageBox::warning( 0, "Effect", + "Failed to connect port: " + m_key.second, QMessageBox::Ok, QMessageBox::NoButton ); setDontRun( true ); return; diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index cbbdc010055..0d18d8ae156 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -5,7 +5,7 @@ * Copyright (c) 2017 Hyunjin Song * * This file is part of LMMS - https://lmms.io - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either @@ -81,7 +81,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, int nTracks = 0; - uint8_t buffer[BUFFER_SIZE]; + auto buffer = std::array{}; uint32_t size; for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++; @@ -89,8 +89,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, // midi header MidiFile::MIDIHeader header(nTracks); - size = header.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = header.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); std::vector>> plists; @@ -139,8 +139,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, } processPatternNotes(midiClip, INT_MAX); writeMidiClipToTrack(mtrack, midiClip); - size = mtrack.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = mtrack.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); } if (track->type() == Track::PatternTrack) @@ -254,8 +254,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, ++itr; } } - size = mtrack.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = mtrack.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); } return true; diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index c669b02b703..6a0314966d9 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2005-2014 Tobias Doerffel * * This file is part of LMMS - https://lmms.io - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either @@ -152,17 +152,17 @@ class smfMidiCC ap( nullptr ), lastPos( 0 ) { } - + AutomationTrack * at; AutomationClip * ap; TimePos lastPos; - + smfMidiCC & create( TrackContainer* tc, QString tn ) { if( !at ) { - // Keep LMMS responsive, for now the import runs - // in the main thread. This should probably be + // Keep LMMS responsive, for now the import runs + // in the main thread. This should probably be // removed if that ever changes. qApp->processEvents(); at = dynamic_cast( Track::create( Track::AutomationTrack, tc ) ); @@ -195,7 +195,7 @@ class smfMidiCC lastPos = time; time = time - ap->startPosition(); ap->putValue( time, value, false ); - ap->changeLength( TimePos( time.getBar() + 1, 0 ) ); + ap->changeLength( TimePos( time.getBar() + 1, 0 ) ); return *this; } @@ -214,14 +214,14 @@ class smfMidiChannel isSF2( false ), hasNotes( false ) { } - + InstrumentTrack * it; MidiClip* p; Instrument * it_inst; - bool isSF2; + bool isSF2; bool hasNotes; QString trackName; - + smfMidiChannel * create( TrackContainer* tc, QString tn ) { if( !it ) { @@ -231,7 +231,7 @@ class smfMidiChannel #ifdef LMMS_HAVE_FLUIDSYNTH it_inst = it->loadInstrument( "sf2player" ); - + if( it_inst ) { isSF2 = true; @@ -242,7 +242,7 @@ class smfMidiChannel else { it_inst = it->loadInstrument( "patman" ); - } + } #else it_inst = it->loadInstrument( "patman" ); #endif @@ -315,9 +315,9 @@ bool MidiImport::readSMF( TrackContainer* tc ) pd.setMaximum( seq->tracks() + preTrackSteps ); pd.setValue( 1 ); - + // 128 CC + Pitch Bend - smfMidiCC ccs[MIDI_CC_COUNT]; + auto ccs = std::array{}; // channel to CC object for program changes std::unordered_map pcs; @@ -338,9 +338,9 @@ bool MidiImport::readSMF( TrackContainer* tc ) auto timeSigDenominatorPat = new AutomationClip(dt); timeSigDenominatorPat->setDisplayName(tr("Denominator")); timeSigDenominatorPat->addObject(&timeSigMM.denominatorModel()); - + // TODO: adjust these to Time.Sig changes - double beatsPerBar = 4; + double beatsPerBar = 4; double ticksPerBeat = DefaultTicksPerBar / beatsPerBar; // Time-sig changes @@ -389,7 +389,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) if( evt->is_update() ) { - printf("Unhandled SONG update: %d %f %s\n", + printf("Unhandled SONG update: %d %f %s\n", evt->get_type_code(), evt->time, evt->get_attribute() ); } } @@ -451,9 +451,9 @@ bool MidiImport::readSMF( TrackContainer* tc ) noteEvt->get_identifier(), noteEvt->get_loud() * (200.f / 127.f)); // Map from MIDI velocity to LMMS volume ch->addNote( n ); - + } - + else if( evt->is_update() ) { smfMidiChannel * ch = chs[evt->chan].create( tc, trackName ); @@ -499,7 +499,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) double cc = evt->get_real_value(); AutomatableModel * objModel = nullptr; - switch( ccid ) + switch( ccid ) { case 0: if( ch->isSF2 && ch->it_inst ) @@ -540,7 +540,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) if( ccs[ccid].at == nullptr ) { ccs[ccid].create( tc, trackName + " > " + ( objModel != nullptr ? - objModel->displayName() : + objModel->displayName() : QString("CC %1").arg(ccid) ) ); } ccs[ccid].putValue( time, objModel, cc ); @@ -549,7 +549,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) } } else { - printf("Unhandled update: %d %d %f %s\n", (int) evt->chan, + printf("Unhandled update: %d %d %f %s\n", (int) evt->chan, evt->get_type_code(), evt->time, evt->get_attribute() ); } } @@ -557,8 +557,8 @@ bool MidiImport::readSMF( TrackContainer* tc ) } delete seq; - - + + for( auto& c: chs ) { if (c.second.hasNotes) diff --git a/plugins/Monstro/Monstro.cpp b/plugins/Monstro/Monstro.cpp index 51205c660f6..3a9737fdb80 100644 --- a/plugins/Monstro/Monstro.cpp +++ b/plugins/Monstro/Monstro.cpp @@ -653,8 +653,8 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * // frames played before const f_cnt_t tfp = m_nph->totalFramesPlayed(); - float * lfo [2]; - float * env [2]; + auto lfo = std::array{}; + auto env = std::array{}; lfo[0] = lfo1; lfo[1] = lfo2; env[0] = env1; @@ -1694,8 +1694,8 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent ) m_lfo2WaveBox -> setGeometry( 127, LFOROW + 7, 42, ComboBox::DEFAULT_HEIGHT ); m_lfo2WaveBox->setFont( pointSize<8>( m_lfo2WaveBox->font() ) ); - maketsknob(m_lfo2AttKnob, LFOCOL4, LFOROW, tr("Attack"), " ms", "lfoKnob") - maketsknob(m_lfo2RateKnob, LFOCOL5, LFOROW, tr("Rate"), " ms", "lfoKnob") + maketsknob(m_lfo2AttKnob, LFOCOL4, LFOROW, tr("Attack"), " ms", "lfoKnob") + maketsknob(m_lfo2RateKnob, LFOCOL5, LFOROW, tr("Rate"), " ms", "lfoKnob") makeknob(m_lfo2PhsKnob, LFOCOL6, LFOROW, tr("Phase"), tr(" deg"), "lfoKnob") maketsknob(m_env1PreKnob, KNOBCOL1, E1ROW, tr("Pre-delay"), " ms", "envKnob") diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 67349e48ba8..3a18c1e3fd4 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -92,7 +92,7 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) QMutex OpulenzInstrument::emulatorMutex; // Weird ordering of voice parameters -const unsigned int adlib_opadd[OPL2_VOICES] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12}; +const auto adlib_opadd = std::array{0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12}; OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &opulenz_plugin_descriptor ), @@ -371,7 +371,7 @@ bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& } break; default: -#ifdef LMMS_DEBUG +#ifdef LMMS_DEBUG printf("Midi CC %02x %02x\n", event.controllerNumber(), event.controllerValue() ); #endif break; @@ -534,7 +534,7 @@ void OpulenzInstrument::loadGMPatch() { // Update patch from the models to the chip emulation void OpulenzInstrument::updatePatch() { - unsigned char inst[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + auto inst = std::array{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; inst[0] = ( op1_trem_mdl.value() ? 128 : 0 ) + ( op1_vib_mdl.value() ? 64 : 0 ) + ( op1_perc_mdl.value() ? 0 : 32 ) + // NB. This envelope mode is "perc", not "sus" @@ -583,7 +583,7 @@ void OpulenzInstrument::updatePatch() { #endif - loadPatch(inst); + loadPatch(inst.data()); } // Load an SBI file into the knob models @@ -763,7 +763,7 @@ OpulenzInstrumentView::OpulenzInstrumentView( Instrument * _instrument, setPalette( pal ); } OpulenzInstrumentView::~OpulenzInstrumentView() { - // Knobs are QWidgets and our children, so they're + // Knobs are QWidgets and our children, so they're // destroyed automagically } @@ -782,20 +782,20 @@ void OpulenzInstrumentView::updateKnobHints() { // Envelope times in ms: t[0] = 0, t[n] = ( 1<{ + 0.0, 0.2, 0.4, 0.9, 1.8, 3.7, 7.4, 15.0, 30.0, 60.0, 120.0, 240.0, 480.0, - 950.0, 1900.0, 3800.0 + 950.0, 1900.0, 3800.0 }; - const float dr_times[16] = { - 0.0, 1.2, 2.5, 5.0, 10.0, 20.0, 40.0, - 80.0, 160.0, 320.0, 640.0, 1300.0, 2600.0, - 5200.0, 10000.0, 20000.0 + const auto dr_times = std::array{ + 0.0, 1.2, 2.5, 5.0, 10.0, 20.0, 40.0, + 80.0, 160.0, 320.0, 640.0, 1300.0, 2600.0, + 5200.0, 10000.0, 20000.0 }; - - const int fmultipliers[16] = { - -12, 0, 12, 19, 24, 28, 31, 34, 36, 38, 40, 40, 43, 43, 47, 47 + + const auto fmultipliers = std::array{ + -12, 0, 12, 19, 24, 28, 31, 34, 36, 38, 40, 40, 43, 43, 47, 47 }; auto m = castModel(); @@ -863,11 +863,11 @@ void OpulenzInstrumentView::modelChanged() connect( &m->op1_d_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); connect( &m->op2_d_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op1_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op2_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op1_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op2_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op1_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op2_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op1_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op2_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); updateKnobHints(); diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index cd18fc5550c..6c2cde77337 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -2,7 +2,7 @@ * Organic.cpp - additive synthesizer for organ-like sounds * * Copyright (c) 2006-2008 Andreas Brandmaier - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -71,7 +71,7 @@ float * OrganicInstrument::s_harmonics = nullptr; * * class OrganicInstrument * -* lmms - plugin +* lmms - plugin * ***********************************************************************/ @@ -90,7 +90,7 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[i] = new OscillatorObject( this, i ); m_osc[i]->m_numOscillators = m_numOscillators; - // Connect events + // Connect events connect( &m_osc[i]->m_oscModel, SIGNAL( dataChanged() ), m_osc[i], SLOT ( oscButtonChanged() ) ); connect( &m_osc[i]->m_harmModel, SIGNAL( dataChanged() ), @@ -114,7 +114,7 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[5]->m_harmonic = log2f( 4.0f ); // . m_osc[6]->m_harmonic = log2f( 5.0f ); // . m_osc[7]->m_harmonic = log2f( 6.0f ); // .*/ - + if( s_harmonics == nullptr ) { s_harmonics = new float[ NUM_HARMONICS ]; @@ -142,10 +142,10 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[i]->updateVolume(); m_osc[i]->updateDetuning(); } - + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), - this, SLOT( updateAllDetuning() ) ); + this, SLOT( updateAllDetuning() ) ); } @@ -193,7 +193,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) m_osc[i]->m_volModel.loadSettings( _this, "vol" + is ); if( _this.hasAttribute( "detune" + is ) ) { - m_osc[i]->m_detuneModel.setValue( _this.attribute( "detune" ).toInt() * 12 ); + m_osc[i]->m_detuneModel.setValue( _this.attribute( "detune" ).toInt() * 12 ); } else { @@ -201,7 +201,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) } m_osc[i]->m_panModel.loadSettings( _this, "pan" + is ); m_osc[i]->m_oscModel.loadSettings( _this, "wavetype" + is ); - + if( _this.hasAttribute( "newharmonic" + is ) ) { m_osc[i]->m_harmModel.loadSettings( _this, "newharmonic" + is ); @@ -211,7 +211,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) m_osc[i]->m_harmModel.setValue( static_cast( i ) ); } } - + m_volModel.loadSettings( _this, "vol" ); m_fx1Model.loadSettings( _this, "foldback" ); } @@ -230,23 +230,23 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - + if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr ) { - Oscillator * oscs_l[NUM_OSCILLATORS]; - Oscillator * oscs_r[NUM_OSCILLATORS]; + auto oscs_l = std::array{}; + auto oscs_r = std::array{}; _n->m_pluginData = new oscPtr; for( int i = m_numOscillators - 1; i >= 0; --i ) { - static_cast( _n->m_pluginData )->phaseOffsetLeft[i] + static_cast( _n->m_pluginData )->phaseOffsetLeft[i] = rand() / ( RAND_MAX + 1.0f ); - static_cast( _n->m_pluginData )->phaseOffsetRight[i] + static_cast( _n->m_pluginData )->phaseOffsetRight[i] = rand() / ( RAND_MAX + 1.0f ); - + // initialise ocillators - + if( i == m_numOscillators - 1 ) { // create left oscillator @@ -287,8 +287,8 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, m_osc[i]->m_volumeRight, oscs_r[i + 1] ); } - - + + } static_cast( _n->m_pluginData )->oscLeft = oscs_l[0]; @@ -303,10 +303,10 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, // -- fx section -- - + // fxKnob is [0;1] float t = m_fx1Model.value(); - + for (int i=0 ; i < frames + offset ; i++) { _working_buffer[i][0] = waveshape( _working_buffer[i][0], t ) * @@ -314,7 +314,7 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, _working_buffer[i][1] = waveshape( _working_buffer[i][1], t ) * m_volModel.value() / 100.0f; } - + // -- -- instrumentTrack()->processAudioBuffer( _working_buffer, frames + offset, _n ); @@ -329,7 +329,7 @@ void OrganicInstrument::deleteNotePluginData( NotePlayHandle * _n ) _n->m_pluginData )->oscLeft ); delete static_cast( static_cast( _n->m_pluginData )->oscRight ); - + delete static_cast( _n->m_pluginData ); } @@ -388,7 +388,7 @@ void OrganicInstrument::updateAllDetuning() int OrganicInstrument::intRand( int min, int max ) { -// int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); +// int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); // cout << randn << endl; int randn = ( rand() % (max - min) ) + min; return( randn ); @@ -452,7 +452,7 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, "randomise_pressed" ) ); m_randBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "randomise" ) ); - + connect( m_randBtn, SIGNAL ( clicked() ), oi, SLOT( randomiseSettings() ) ); @@ -479,10 +479,10 @@ void OrganicInstrumentView::modelChanged() const float y=91.0f; const float rowHeight = 26.0f; const float x=53.0f; - const float colWidth = 24.0f; + const float colWidth = 24.0f; m_numOscillators = oi->m_numOscillators; - + m_fx1Knob->setModel( &oi->m_fx1Model ); m_volKnob->setModel( &oi->m_volModel ); @@ -490,7 +490,7 @@ void OrganicInstrumentView::modelChanged() { delete[] m_oscKnobs; } - + m_oscKnobs = new OscillatorKnobs[ m_numOscillators ]; // Create knobs, now that we know how many to make @@ -502,7 +502,7 @@ void OrganicInstrumentView::modelChanged() harmKnob->setObjectName( "harmKnob" ); connect( &oi->m_osc[i]->m_harmModel, SIGNAL( dataChanged() ), this, SLOT( updateKnobHint() ) ); - + // setup waveform-knob Knob * oscKnob = new OrganicKnob( this ); oscKnob->move( x + i * colWidth, y ); @@ -510,7 +510,7 @@ void OrganicInstrumentView::modelChanged() this, SLOT( updateKnobHint() ) ); oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( i + 1 ), QString() ); - + // setup volume-knob auto volKnob = new Knob(knobStyled, this); volKnob->setVolumeKnob( true ); @@ -518,13 +518,13 @@ void OrganicInstrumentView::modelChanged() volKnob->setFixedSize( 21, 21 ); volKnob->setHintText( tr( "Osc %1 volume:" ).arg( i + 1 ), "%" ); - + // setup panning-knob Knob * panKnob = new OrganicKnob( this ); panKnob->move( x + i * colWidth, y + rowHeight*2 ); panKnob->setHintText( tr("Osc %1 panning:").arg( i + 1 ), "" ); - + // setup knob for fine-detuning Knob * detuneKnob = new OrganicKnob( this ); detuneKnob->move( x + i * colWidth, y + rowHeight*3 ); @@ -552,7 +552,7 @@ void OrganicInstrumentView::updateKnobHint() { const float harm = oi->m_osc[i]->m_harmModel.value(); const float wave = oi->m_osc[i]->m_oscModel.value(); - + m_oscKnobs[i].m_harmKnob->setHintText( tr( "Osc %1 harmonic:" ).arg( i + 1 ), " (" + HARMONIC_NAMES[ static_cast( harm ) ] + ")" ); m_oscKnobs[i].m_oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( i + 1 ), " (" + @@ -575,7 +575,7 @@ OscillatorObject::OscillatorObject( Model * _parent, int _index ) : this, tr( "Osc %1 volume" ).arg( _index + 1 ) ), m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this, tr( "Osc %1 panning" ).arg( _index + 1 ) ), - m_detuneModel( 0.0f, -1200.0f, 1200.0f, 1.0f, + m_detuneModel( 0.0f, -1200.0f, 1200.0f, 1.0f, this, tr( "Osc %1 fine detuning left" ).arg( _index + 1 ) ) { } @@ -586,7 +586,7 @@ OscillatorObject::OscillatorObject( Model * _parent, int _index ) : void OscillatorObject::oscButtonChanged() { - static Oscillator::WaveShapes shapes[] = + static auto shapes = std::array { Oscillator::SineWave, Oscillator::SawWave, @@ -639,12 +639,12 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) /* * some notes & ideas for the future of this plugin: - * + * * - 32.692 Hz in the bass to 5919.85 Hz of treble in a Hammond organ * => implement harmonic foldback - * + * m_osc[i].m_oscModel->setInitValue( 0.0f ); - * - randomize preset + * - randomize preset */ diff --git a/plugins/Patman/Patman.cpp b/plugins/Patman/Patman.cpp index 34545f557b8..a8f75db6015 100644 --- a/plugins/Patman/Patman.cpp +++ b/plugins/Patman/Patman.cpp @@ -225,11 +225,11 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( return( LoadOpen ); } - unsigned char header[239]; + auto header = std::array{}; - if( fread( header, 1, 239, fd ) != 239 || - ( memcmp( header, "GF1PATCH110\0ID#000002", 22 ) - && memcmp( header, "GF1PATCH100\0ID#000002", 22 ) ) ) + if (fread(header.data(), 1, 239, fd ) != 239 || + (memcmp(header.data(), "GF1PATCH110\0ID#000002", 22) + && memcmp(header.data(), "GF1PATCH100\0ID#000002", 22))) { fclose( fd ); return( LoadNotGUS ); diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index a13f7eee8f8..e8dec8fd731 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -62,7 +62,7 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); } @@ -88,7 +88,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) SPFLOAT tmpL, tmpR; SPFLOAT dcblkL, dcblkR; - + ValueBuffer * inGainBuf = m_reverbSCControls.m_inputGainModel.valueBuffer(); ValueBuffer * sizeBuf = m_reverbSCControls.m_sizeModel.valueBuffer(); ValueBuffer * colorBuf = m_reverbSCControls.m_colorModel.valueBuffer(); @@ -96,7 +96,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( fpp_t f = 0; f < frames; ++f ) { - sample_t s[2] = { buf[f][0], buf[f][1] }; + auto s = std::array{buf[f][0], buf[f][1]}; const auto inGain = (SPFLOAT)DB2LIN((inGainBuf ? inGainBuf->values()[f] : m_reverbSCControls.m_inputGainModel.value())); @@ -105,12 +105,12 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) s[0] *= inGain; s[1] *= inGain; - revsc->feedback = (SPFLOAT)(sizeBuf ? - sizeBuf->values()[f] + revsc->feedback = (SPFLOAT)(sizeBuf ? + sizeBuf->values()[f] : m_reverbSCControls.m_sizeModel.value()); - revsc->lpfreq = (SPFLOAT)(colorBuf ? - colorBuf->values()[f] + revsc->lpfreq = (SPFLOAT)(colorBuf ? + colorBuf->values()[f] : m_reverbSCControls.m_colorModel.value()); @@ -128,7 +128,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) return isRunning(); } - + void ReverbSCEffect::changeSampleRate() { // Change sr variable in Soundpipe. does not need to be destroyed @@ -144,7 +144,7 @@ void ReverbSCEffect::changeSampleRate() sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); mutex.unlock(); @@ -156,9 +156,9 @@ extern "C" // necessary for getting instance out of shared lib PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { - return new ReverbSCEffect( - parent, - static_cast(data) + return new ReverbSCEffect( + parent, + static_cast(data) ); } diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index 73c571b72ca..6e747349264 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 2008 Csaba Hruska * Attila Herman - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -52,22 +52,22 @@ namespace lmms #define SIDWRITEDELAY 9 // lda $xxxx,x 4 cycles, sta $d400,x 5 cycles #define SIDWAVEDELAY 4 // and $xxxx,x 4 cycles extra -unsigned char sidorder[] = +auto sidorder = std::array {0x15,0x16,0x18,0x17, 0x05,0x06,0x02,0x03,0x00,0x01,0x04, 0x0c,0x0d,0x09,0x0a,0x07,0x08,0x0b, 0x13,0x14,0x10,0x11,0x0e,0x0f,0x12}; -static const char *attackTime[16] = { "2 ms", "8 ms", "16 ms", "24 ms", +static auto attackTime = std::array{ "2 ms", "8 ms", "16 ms", "24 ms", "38 ms", "56 ms", "68 ms", "80 ms", "100 ms", "250 ms", "500 ms", "800 ms", "1 s", "3 s", "5 s", "8 s" }; -static const char *decRelTime[16] = { "6 ms", "24 ms", "48 ms", "72 ms", +static auto decRelTime = std::array{ "6 ms", "24 ms", "48 ms", "72 ms", "114 ms", "168 ms", "204 ms", "240 ms", "300 ms", "750 ms", "1.5 s", "2.4 s", "3 s", "9 s", "15 s", "24 s" }; // release time time in ms -static const int relTime[16] = { 6, 24, 48, 72, 114, 168, 204, 240, 300, 750, +static const auto relTime = std::array{ 6, 24, 48, 72, 114, 168, 204, 240, 300, 750, 1500, 2400, 3000, 9000, 15000, 24000 }; @@ -118,11 +118,11 @@ VoiceObject::VoiceObject( Model * _parent, int _idx ) : SidInstrument::SidInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &sid_plugin_descriptor ), - // filter + // filter m_filterFCModel( 1024.0f, 0.0f, 2047.0f, 1.0f, this, tr( "Cutoff frequency" ) ), m_filterResonanceModel( 8.0f, 0.0f, 15.0f, 1.0f, this, tr( "Resonance" ) ), m_filterModeModel( LowPass, 0, NumFilterTypes-1, this, tr( "Filter type" )), - + // misc m_voice3OffModel( false, this, tr( "Voice 3 off" ) ), m_volumeModel( 15.0f, 0.0f, 15.0f, 1.0f, this, tr( "Volume" ) ), @@ -167,11 +167,11 @@ void SidInstrument::saveSettings( QDomDocument & _doc, _doc, _this, "test" + is ); } - // filter + // filter m_filterFCModel.saveSettings( _doc, _this, "filterFC" ); m_filterResonanceModel.saveSettings( _doc, _this, "filterResonance" ); m_filterModeModel.saveSettings( _doc, _this, "filterMode" ); - + // misc m_voice3OffModel.saveSettings( _doc, _this, "voice3Off" ); m_volumeModel.saveSettings( _doc, _this, "volume" ); @@ -200,12 +200,12 @@ void SidInstrument::loadSettings( const QDomElement & _this ) m_voice[i]->m_filteredModel.loadSettings( _this, "filtered" + is ); m_voice[i]->m_testModel.loadSettings( _this, "test" + is ); } - - // filter + + // filter m_filterFCModel.loadSettings( _this, "filterFC" ); m_filterResonanceModel.loadSettings( _this, "filterResonance" ); m_filterModeModel.loadSettings( _this, "filterMode" ); - + // misc m_voice3OffModel.loadSettings( _this, "voice3Off" ); m_volumeModel.loadSettings( _this, "volume" ); @@ -318,7 +318,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, int delta_t = clockrate * frames / samplerate + 4; // avoid variable length array for msvc compat auto buf = reinterpret_cast(_working_buffer + offset); - unsigned char sidreg[NUMSIDREGS]; + auto sidreg = std::array{}; for (auto& reg : sidreg) { @@ -354,7 +354,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, sidreg[base+1] = (data16>>8)&0x00FF; // pw data16 = (int)m_voice[i]->m_pulseWidthModel.value(); - + sidreg[base+2] = data16&0x00FF; sidreg[base+3] = (data16>>8)&0x000F; // control: wave form, (test), ringmod, sync, gate @@ -363,7 +363,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 += m_voice[i]->m_ringModModel.value()?4:0; data8 += m_voice[i]->m_testModel.value()?8:0; switch( m_voice[i]->m_waveFormModel.value() ) - { + { default: break; case VoiceObject::NoiseWave: data8 += 128; break; case VoiceObject::SquareWave: data8 += 64; break; @@ -394,7 +394,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data16 = (int)m_filterFCModel.value(); sidreg[21] = data16&0x0007; sidreg[22] = (data16>>3)&0x00FF; - + // res, filt ex,3,2,1 data16 = (int)m_filterResonanceModel.value(); data8 = (data16&0x000F)<<4; @@ -409,7 +409,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 += m_voice3OffModel.value()?128:0; switch( m_filterModeModel.value() ) - { + { default: break; case LowPass: data8 += 16; break; case BandPass: data8 += 32; break; @@ -417,8 +417,8 @@ void SidInstrument::playNote( NotePlayHandle * _n, } sidreg[24] = data8&0x00FF; - - int num = sid_fillbuffer(sidreg, sid,delta_t,buf, frames); + + int num = sid_fillbuffer(sidreg.data(), sid, delta_t, buf, frames); if(num!=frames) printf("!!!Not enough samples\n"); @@ -544,7 +544,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, m_sidTypeBtnGrp->addButton( mos6581_btn ); m_sidTypeBtnGrp->addButton( mos8580_btn ); - for( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { Knob *ak = new sidKnob( this ); ak->setHintText( tr("Attack:"), "" ); @@ -674,7 +674,7 @@ void SidInstrumentView::updateKnobHint() m_releaseModel.value()] ) + ")" ); m_voiceKnobs[i].m_relKnob->setToolTip( decRelTime[(int)k->m_voice[i]->m_releaseModel.value()]); - + m_voiceKnobs[i].m_pwKnob->setHintText( tr( "Pulse width:" )+ " ", " (" + QString::number( (double)k->m_voice[i]-> m_pulseWidthModel.value() / 40.95 ) + "%)" ); @@ -758,7 +758,7 @@ void SidInstrumentView::modelChanged() connect(&voice->m_sustainModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip())); connect(&voice->m_coarseModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip())); } - + connect( &k->m_volumeModel, SIGNAL( dataChanged() ), this, SLOT( updateKnobToolTip() ) ); connect( &k->m_filterResonanceModel, SIGNAL( dataChanged() ), diff --git a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp index 8c3d7a82d02..0d9c2af87a2 100644 --- a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp +++ b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp @@ -648,8 +648,8 @@ std::vector> SaSpectrumView::makeLogFreqTics(int low { std::vector> result; int i, j; - int a[] = {10, 20, 50}; // sparse series multipliers - int b[] = {14, 30, 70}; // additional (denser) series + auto a = std::array{10, 20, 50}; // sparse series multipliers + auto b = std::array{14, 30, 70}; // additional (denser) series // generate main steps (powers of 10); use the series to specify smaller steps for (i = 1; i <= high; i *= 10) diff --git a/plugins/StereoEnhancer/StereoEnhancer.cpp b/plugins/StereoEnhancer/StereoEnhancer.cpp index 1351ab8857f..01e55f2dee5 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.cpp +++ b/plugins/StereoEnhancer/StereoEnhancer.cpp @@ -85,15 +85,15 @@ StereoEnhancerEffect::~StereoEnhancerEffect() bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { - + // This appears to be used for determining whether or not to continue processing - // audio with this effect + // audio with this effect double out_sum = 0.0; - + float width; int frameIndex = 0; - - + + if( !isEnabled() || !isRunning() ) { return( false ); @@ -104,7 +104,7 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - + // copy samples into the delay buffer m_delayBuffer[m_currFrame][0] = _buf[f][0]; m_delayBuffer[m_currFrame][1] = _buf[f][1]; @@ -122,7 +122,7 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, } //sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla - sample_t s[2] = { _buf[f][0], m_delayBuffer[frameIndex][1] }; //Chocolate + auto s = std::array{_buf[f][0], m_delayBuffer[frameIndex][1]}; //Chocolate m_seFX.nextSample( s[0], s[1] ); diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index bbc95683b2d..25baea20858 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -21,7 +21,7 @@ * Boston, MA 02110-1301 USA. * */ - + #include @@ -81,10 +81,10 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : m_fineRightModel( 0.0f, -100.0f, 100.0f, 1.0f, this, tr( "Osc %1 fine detuning right" ).arg( _idx + 1 ) ), m_phaseOffsetModel( 0.0f, 0.0f, 360.0f, 1.0f, this, - tr( "Osc %1 phase-offset" ).arg( _idx+1 ) ), + tr( "Osc %1 phase-offset" ).arg( _idx+1 ) ), m_stereoPhaseDetuningModel( 0.0f, 0.0f, 360.0f, 1.0f, this, tr( "Osc %1 stereo phase-detuning" ).arg( _idx+1 ) ), - m_waveShapeModel( Oscillator::SineWave, 0, + m_waveShapeModel( Oscillator::SineWave, 0, Oscillator::NumWaveShapes-1, this, tr( "Osc %1 wave shape" ).arg( _idx+1 ) ), m_modulationAlgoModel( Oscillator::SignalMix, 0, @@ -220,7 +220,7 @@ void OscillatorObject::updateUseWaveTable() } - + TripleOscillator::TripleOscillator( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &tripleoscillator_plugin_descriptor ) @@ -310,8 +310,8 @@ void TripleOscillator::playNote( NotePlayHandle * _n, { if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr ) { - Oscillator * oscs_l[NUM_OF_OSCILLATORS]; - Oscillator * oscs_r[NUM_OF_OSCILLATORS]; + auto oscs_l = std::array{}; + auto oscs_r = std::array{}; for( int i = NUM_OF_OSCILLATORS - 1; i >= 0; --i ) { diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index 593712c143b..eab3693b8b2 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -221,16 +221,16 @@ void VestigeInstrument::loadSettings( const QDomElement & _this ) const QMap & dump = m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; for( int i = 0; i < paramCount; i++ ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); - knobFModel[i]->loadSettings( _this, paramStr ); + knobFModel[i]->loadSettings(_this, paramStr.data()); if( !( knobFModel[ i ]->isAutomated() || knobFModel[ i ]->controllerConnection() ) ) { @@ -286,12 +286,12 @@ void VestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) if (knobFModel != nullptr) { const QMap & dump = m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; for( int i = 0; i < paramCount; i++ ) { if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) { - sprintf( paramStr, "param%d", i); - knobFModel[i]->saveSettings( _doc, _this, paramStr ); + sprintf(paramStr.data(), "param%d", i); + knobFModel[i]->saveSettings(_doc, _this, paramStr.data()); } /* QDomElement me = _doc.createElement( paramStr ); @@ -938,7 +938,7 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume using ::operator|; #endif - + m_vi = m_vi2; m_vi->m_scrollArea = new QScrollArea( this ); widget = new QWidget(this); @@ -996,13 +996,13 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume hasKnobModel = false; } - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; for( int i = 0; i < m_vi->paramCount; i++ ) { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); vstKnobs[ i ] = new CustomTextKnob( knobBright_26, this, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); @@ -1010,9 +1010,9 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume if( !hasKnobModel ) { - sprintf( paramStr, "%d", i); - m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)), - 0.0f, 1.0f, 0.01f, castModel(), paramStr ); + sprintf(paramStr.data(), "%d", i); + m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)), + 0.0f, 1.0f, 0.01f, castModel(), paramStr.data()); } FloatModel * model = m_vi->knobFModel[i]; @@ -1063,7 +1063,7 @@ void ManageVestigeInstrumentView::closeWindow() void ManageVestigeInstrumentView::syncPlugin( void ) { - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; const QMap & dump = m_vi->m_plugin->parameterDump(); float f_value; @@ -1074,8 +1074,8 @@ void ManageVestigeInstrumentView::syncPlugin( void ) // those auto-setted values are not jurnaled, tracked for undo / redo if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); f_value = LocaleHelper::toFloat(s_dumpValues.at(2)); m_vi->knobFModel[ i ]->setAutomatedValue( f_value ); m_vi->knobFModel[ i ]->setInitValue( f_value ); diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index f35a1c00dd0..e73530a0924 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -83,16 +83,16 @@ void VstEffectControls::loadSettings( const QDomElement & _this ) const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; for( int i = 0; i < paramCount; i++ ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); - knobFModel[i]->loadSettings( _this, paramStr ); + knobFModel[i]->loadSettings(_this, paramStr.data()); if( !( knobFModel[ i ]->isAutomated() || knobFModel[ i ]->controllerConnection() ) ) @@ -134,12 +134,12 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this ) if (knobFModel != nullptr) { const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; for( int i = 0; i < paramCount; i++ ) { if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) { - sprintf( paramStr, "param%d", i); - knobFModel[i]->saveSettings( _doc, _this, paramStr ); + sprintf(paramStr.data(), "param%d", i); + knobFModel[i]->saveSettings(_doc, _this, paramStr.data()); } } } @@ -173,7 +173,7 @@ void VstEffectControls::managePlugin() auto tt = new gui::ManageVSTEffectView(m_effect, this); ctrHandle = (QObject *)tt; } else if (m_subWindow != nullptr) { - if (m_subWindow->widget()->isVisible() == false ) { + if (m_subWindow->widget()->isVisible() == false ) { m_scrollArea->show(); m_subWindow->show(); } else { @@ -371,13 +371,13 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * hasKnobModel = false; } - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; for( int i = 0; i < m_vi->paramCount; i++ ) { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); vstKnobs[ i ] = new CustomTextKnob( knobBright_26, widget, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); @@ -385,9 +385,9 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * if( !hasKnobModel ) { - sprintf( paramStr, "%d", i); - m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)), - 0.0f, 1.0f, 0.01f, _eff, paramStr ); + sprintf(paramStr.data(), "%d", i); + m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)), + 0.0f, 1.0f, 0.01f, _eff, paramStr.data()); } FloatModel * model = m_vi->knobFModel[i]; @@ -439,7 +439,7 @@ void ManageVSTEffectView::closeWindow() void ManageVSTEffectView::syncPlugin() { - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; const QMap & dump = m_effect->m_plugin->parameterDump(); float f_value; @@ -451,8 +451,8 @@ void ManageVSTEffectView::syncPlugin() if( !( m_vi2->knobFModel[ i ]->isAutomated() || m_vi2->knobFModel[ i ]->controllerConnection() ) ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); f_value = LocaleHelper::toFloat(s_dumpValues.at(2)); m_vi2->knobFModel[ i ]->setAutomatedValue( f_value ); m_vi2->knobFModel[ i ]->setInitValue( f_value ); @@ -477,7 +477,7 @@ void ManageVSTEffectView::displayAutomatedOnly() { vstKnobs[ i ]->hide(); m_displayAutomatedOnly->setText( "All" ); - } else { + } else { vstKnobs[ i ]->show(); m_displayAutomatedOnly->setText( "Automated" ); } @@ -534,7 +534,7 @@ void ManageVSTEffectView::syncParameterText() ManageVSTEffectView::~ManageVSTEffectView() { if( m_vi2->knobFModel != nullptr ) - { + { for( int i = 0; i < m_vi2->paramCount; i++ ) { delete m_vi2->knobFModel[ i ]; @@ -553,18 +553,18 @@ ManageVSTEffectView::~ManageVSTEffectView() delete [] m_vi2->knobFModel; m_vi2->knobFModel = nullptr; } - + if( m_vi2->m_scrollArea != nullptr ) { delete m_vi2->m_scrollArea; m_vi2->m_scrollArea = nullptr; } - + if( m_vi2->m_subWindow != nullptr ) { m_vi2->m_subWindow->setAttribute( Qt::WA_DeleteOnClose ); m_vi2->m_subWindow->close(); - + if( m_vi2->m_subWindow != nullptr ) { delete m_vi2->m_subWindow; diff --git a/plugins/WaveShaper/WaveShaper.cpp b/plugins/WaveShaper/WaveShaper.cpp index edbcb0ad8f0..94845e6726e 100644 --- a/plugins/WaveShaper/WaveShaper.cpp +++ b/plugins/WaveShaper/WaveShaper.cpp @@ -96,7 +96,7 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - float s[2] = { _buf[f][0], _buf[f][1] }; + auto s = std::array{_buf[f][0], _buf[f][1]}; // apply input gain s[0] *= *inputPtr; @@ -114,7 +114,7 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, for( i=0; i <= 1; ++i ) { const int lookup = static_cast( qAbs( s[i] ) * 200.0f ); - const float frac = fraction( qAbs( s[i] ) * 200.0f ); + const float frac = fraction( qAbs( s[i] ) * 200.0f ); const float posneg = s[i] < 0 ? -1.0f : 1.0f; if( lookup < 1 ) @@ -122,8 +122,8 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, s[i] = frac * samples[0] * posneg; } else if( lookup < 200 ) - { - s[i] = linearInterpolate( samples[ lookup - 1 ], + { + s[i] = linearInterpolate( samples[ lookup - 1 ], samples[ lookup ], frac ) * posneg; } diff --git a/plugins/WaveShaper/WaveShaperControls.cpp b/plugins/WaveShaper/WaveShaperControls.cpp index 40e20055af5..a03abc2efda 100644 --- a/plugins/WaveShaper/WaveShaperControls.cpp +++ b/plugins/WaveShaper/WaveShaperControls.cpp @@ -69,7 +69,7 @@ void WaveShaperControls::loadSettings( const QDomElement & _this ) //load input, output knobs m_inputModel.loadSettings( _this, "inputGain" ); m_outputModel.loadSettings( _this, "outputGain" ); - + m_clipModel.loadSettings( _this, "clipInput" ); //load waveshape @@ -105,7 +105,7 @@ void WaveShaperControls::saveSettings( QDomDocument & _doc, void WaveShaperControls::setDefaultShape() { - float shp [200] = { }; + auto shp = std::array{}; for ( int i = 0; i<200; i++) { shp[i] = ((float)i + 1.0f) / 200.0f; diff --git a/plugins/Xpressive/ExprSynth.cpp b/plugins/Xpressive/ExprSynth.cpp index 47b778ae00d..991e0d3e6b2 100644 --- a/plugins/Xpressive/ExprSynth.cpp +++ b/plugins/Xpressive/ExprSynth.cpp @@ -214,7 +214,7 @@ struct WaveValueFunctionInterpolate : public exprtk::ifunction const T *m_vec; const std::size_t m_size; }; -static const unsigned int random_data[257]={ +static const auto random_data = std::array{ 0xd76a33ec, 0x4a767724, 0xb34ebd08 ,0xf4024196, 0x17b426e2, 0x8dc6389a, 0x1b5dcb93 ,0xa771bd3f, 0x078d502e, 0x8980988a, 0x1f64f846 ,0xb5b48ed7, @@ -526,14 +526,14 @@ ExprFront::ExprFront(const char * expr, int last_func_samples) try { m_data = new ExprFrontData(last_func_samples); - + m_data->m_expression_string = expr; m_data->m_symbol_table.add_pi(); - + m_data->m_symbol_table.add_constant("e", F_E); m_data->m_symbol_table.add_constant("seed", SimpleRandom::generator() & max_float_integer_mask); - + m_data->m_symbol_table.add_function("sinew", sin_wave_func); m_data->m_symbol_table.add_function("squarew", square_wave_func); m_data->m_symbol_table.add_function("trianglew", triangle_wave_func); @@ -577,7 +577,7 @@ bool ExprFront::compile() sstore.disable_all_assignment_ops(); sstore.disable_all_control_structures(); parser_t parser(sstore); - + m_valid=parser.compile(m_data->m_expression_string, m_data->m_expression); } catch(...) @@ -600,7 +600,7 @@ float ExprFront::evaluate() WARN_EXPRTK; } return 0; - + } bool ExprFront::add_variable(const char* name, float& ref) { @@ -757,7 +757,7 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) const float new_freq = m_nph->frequency(); const float freq_inc = (new_freq - m_frequency) / frames; const bool is_released = m_nph->isReleased(); - + expression_t *o1_rawExpr = &(m_exprO1->getData()->m_expression); expression_t *o2_rawExpr = &(m_exprO2->getData()->m_expression); LastSampleFunction * last_func1 = &m_exprO1->getData()->m_last_func; @@ -791,7 +791,7 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) } else { - + if (o2_valid) { o1_rawExpr = o2_rawExpr; diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 635c4c6a460..b6b9452f52f 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -89,19 +89,27 @@ const std::vector DataFile::UPGRADE_VERSIONS = { "1.2.0-rc3" , "1.3.0" }; -DataFile::typeDescStruct - DataFile::s_types[DataFile::TypeCount] = +namespace { - { DataFile::UnknownType, "unknown" }, - { DataFile::SongProject, "song" }, - { DataFile::SongProjectTemplate, "songtemplate" }, - { DataFile::InstrumentTrackSettings, "instrumenttracksettings" }, - { DataFile::DragNDropData, "dnddata" }, - { DataFile::ClipboardData, "clipboard-data" }, - { DataFile::JournalData, "journaldata" }, - { DataFile::EffectSettings, "effectsettings" }, - { DataFile::MidiClip, "midiclip" } -} ; + struct TypeDescStruct + { + DataFile::Type m_type; + QString m_name; + }; + + const auto s_types = std::array + { + TypeDescStruct{ DataFile::UnknownType, "unknown" }, + TypeDescStruct{ DataFile::SongProject, "song" }, + TypeDescStruct{ DataFile::SongProjectTemplate, "songtemplate" }, + TypeDescStruct{ DataFile::InstrumentTrackSettings, "instrumenttracksettings" }, + TypeDescStruct{ DataFile::DragNDropData, "dnddata" }, + TypeDescStruct{ DataFile::ClipboardData, "clipboard-data" }, + TypeDescStruct{ DataFile::JournalData, "journaldata" }, + TypeDescStruct{ DataFile::EffectSettings, "effectsettings" }, + TypeDescStruct{ DataFile::MidiClip, "midiclip" } + }; +} diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index a7d3f73e85e..dde260fdc8e 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -90,7 +90,7 @@ bool Instrument::isFromTrack( const Track * _track ) const static int countZeroCrossings(sampleFrame *buf, fpp_t start, fpp_t frames) { // zero point crossing counts of all channels - int zeroCrossings[DEFAULT_CHANNELS] = {0}; + auto zeroCrossings = std::array{}; // maximum zero point crossing of all channels int maxZeroCrossings = 0; diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 4a5e29bd775..06e56666c41 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -34,9 +34,10 @@ namespace lmms { - -InstrumentFunctionNoteStacking::ChordTable::Init InstrumentFunctionNoteStacking::ChordTable::s_initTable[] = -{ +std::array + InstrumentFunctionNoteStacking::ChordTable::s_initTable = + std::array +{{ { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "octave" ), { 0, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Major" ), { 0, 4, 7, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Majb5" ), { 0, 4, 6, -1 } }, @@ -139,7 +140,7 @@ InstrumentFunctionNoteStacking::ChordTable::Init InstrumentFunctionNoteStacking: { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "5" ), { 0, 7, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Phrygian dominant" ), { 0, 1, 4, 5, 7, 8, 10, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Persian" ), { 0, 1, 4, 5, 6, 8, 11, -1 } } -} ; +}}; diff --git a/src/core/MixHelpers.cpp b/src/core/MixHelpers.cpp index 2b2b5952f02..02f3d8775eb 100644 --- a/src/core/MixHelpers.cpp +++ b/src/core/MixHelpers.cpp @@ -281,7 +281,7 @@ struct AddMultipliedStereoOp dst[1] += src[1] * m_coeffs[1]; } - float m_coeffs[2]; + std::array m_coeffs; } ; @@ -309,7 +309,7 @@ struct MultiplyAndAddMultipliedOp dst[1] = dst[1]*m_coeffs[0] + src[1]*m_coeffs[1]; } - float m_coeffs[2]; + std::array m_coeffs; } ; diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index 86a50c81448..189dede6e8d 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -178,7 +178,7 @@ void Oscillator::generateFromFFT(int bands, sample_t* table) //ifft fftwf_execute(s_ifftPlan); //normalize and copy to result buffer - normalize(s_sampleBuffer, table, OscillatorConstants::WAVETABLE_LENGTH, 2*OscillatorConstants::WAVETABLE_LENGTH + 1); + normalize(s_sampleBuffer.data(), table, OscillatorConstants::WAVETABLE_LENGTH, 2*OscillatorConstants::WAVETABLE_LENGTH + 1); } void Oscillator::generateAntiAliasUserWaveTable(SampleBuffer *sampleBuffer) @@ -205,15 +205,15 @@ sample_t Oscillator::s_waveTables fftwf_plan Oscillator::s_fftPlan; fftwf_plan Oscillator::s_ifftPlan; fftwf_complex * Oscillator::s_specBuf; -float Oscillator::s_sampleBuffer[OscillatorConstants::WAVETABLE_LENGTH]; +std::array Oscillator::s_sampleBuffer; void Oscillator::createFFTPlans() { Oscillator::s_specBuf = ( fftwf_complex * ) fftwf_malloc( ( OscillatorConstants::WAVETABLE_LENGTH * 2 + 1 ) * sizeof( fftwf_complex ) ); - Oscillator::s_fftPlan = fftwf_plan_dft_r2c_1d(OscillatorConstants::WAVETABLE_LENGTH, s_sampleBuffer, s_specBuf, FFTW_MEASURE ); - Oscillator::s_ifftPlan = fftwf_plan_dft_c2r_1d(OscillatorConstants::WAVETABLE_LENGTH, s_specBuf, s_sampleBuffer, FFTW_MEASURE); + Oscillator::s_fftPlan = fftwf_plan_dft_r2c_1d(OscillatorConstants::WAVETABLE_LENGTH, s_sampleBuffer.data(), s_specBuf, FFTW_MEASURE ); + Oscillator::s_ifftPlan = fftwf_plan_dft_c2r_1d(OscillatorConstants::WAVETABLE_LENGTH, s_specBuf, s_sampleBuffer.data(), FFTW_MEASURE); // initialize s_specBuf content to zero, since the values are used in a condition inside generateFromFFT() for (int i = 0; i < OscillatorConstants::WAVETABLE_LENGTH * 2 + 1; i++) { diff --git a/src/core/PathUtil.cpp b/src/core/PathUtil.cpp index 2999936737d..03ec465a929 100644 --- a/src/core/PathUtil.cpp +++ b/src/core/PathUtil.cpp @@ -9,7 +9,7 @@ namespace lmms::PathUtil { - Base relativeBases[] = { Base::ProjectDir, Base::FactorySample, Base::UserSample, Base::UserVST, Base::Preset, + auto relativeBases = std::array{ Base::ProjectDir, Base::FactorySample, Base::UserSample, Base::UserVST, Base::Preset, Base::UserLADSPA, Base::DefaultLADSPA, Base::UserSoundfont, Base::DefaultSoundfont, Base::UserGIG, Base::DefaultGIG, Base::LocalDir }; @@ -121,7 +121,7 @@ namespace lmms::PathUtil //Check if it's a factory sample QString factoryPath = baseLocation(Base::FactorySample) + input; QFileInfo factoryInfo(factoryPath); - if (factoryInfo.exists()) { assumedBase = Base::FactorySample; } + if (factoryInfo.exists()) { assumedBase = Base::FactorySample; } //Check if it's a VST QString vstPath = baseLocation(Base::UserVST) + input; diff --git a/src/core/Piano.cpp b/src/core/Piano.cpp index 21ef7217d9e..0f59dd9057c 100644 --- a/src/core/Piano.cpp +++ b/src/core/Piano.cpp @@ -47,7 +47,7 @@ namespace lmms /*! The black / white order of keys as they appear on the keyboard. */ -static const Piano::KeyTypes KEY_ORDER[] = +static const auto KEY_ORDER = std::array { // C CIS D DIS Piano::WhiteKey, Piano::BlackKey, Piano::WhiteKey, Piano::BlackKey, diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index ca553003d0f..da6c729c813 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -39,18 +39,18 @@ namespace lmms { -const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = +const std::array ProjectRenderer::fileEncodeDevices { - { ProjectRenderer::WaveFile, + FileEncodeDevice{ ProjectRenderer::WaveFile, QT_TRANSLATE_NOOP( "ProjectRenderer", "WAV (*.wav)" ), ".wav", &AudioFileWave::getInst }, - { ProjectRenderer::FlacFile, + FileEncodeDevice{ ProjectRenderer::FlacFile, QT_TRANSLATE_NOOP("ProjectRenderer", "FLAC (*.flac)"), ".flac", &AudioFileFlac::getInst }, - { ProjectRenderer::OggFile, + FileEncodeDevice{ ProjectRenderer::OggFile, QT_TRANSLATE_NOOP( "ProjectRenderer", "OGG (*.ogg)" ), ".ogg", #ifdef LMMS_HAVE_OGGVORBIS @@ -59,7 +59,7 @@ const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = nullptr #endif }, - { ProjectRenderer::MP3File, + FileEncodeDevice{ ProjectRenderer::MP3File, QT_TRANSLATE_NOOP( "ProjectRenderer", "MP3 (*.mp3)" ), ".mp3", #ifdef LMMS_HAVE_MP3LAME @@ -71,7 +71,7 @@ const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = // Insert your own file-encoder infos here. // Maybe one day the user can add own encoders inside the program. - { ProjectRenderer::NumFileFormats, nullptr, nullptr, nullptr } + FileEncodeDevice{ ProjectRenderer::NumFileFormats, nullptr, nullptr, nullptr } } ; @@ -224,8 +224,8 @@ void ProjectRenderer::updateConsoleProgress() { const int cols = 50; static int rot = 0; - char buf[80]; - char prog[cols+1]; + auto buf = std::array{}; + auto prog = std::array{}; for( int i = 0; i < cols; ++i ) { @@ -234,12 +234,12 @@ void ProjectRenderer::updateConsoleProgress() prog[cols] = 0; const auto activity = (const char*)"|/-\\"; - memset( buf, 0, sizeof( buf ) ); - sprintf( buf, "\r|%s| %3d%% %c ", prog, m_progress, + std::fill(buf.begin(), buf.end(), 0); + sprintf(buf.data(), "\r|%s| %3d%% %c ", prog.data(), m_progress, activity[rot] ); rot = ( rot+1 ) % 4; - fprintf( stderr, "%s", buf ); + fprintf( stderr, "%s", buf.data() ); fflush( stderr ); } diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index 92f3e215669..677366fdbf6 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -1067,7 +1067,7 @@ void SampleBuffer::visualize( float maxData = -1; float minData = 1; - float rmsData[2] = {0, 0}; + auto rmsData = std::array{}; // Find maximum and minimum samples within range for (int i = 0; i < fpp && frame + i <= last; ++i) diff --git a/src/core/audio/AudioFileFlac.cpp b/src/core/audio/AudioFileFlac.cpp index 4e40257cd7f..6af063683bd 100644 --- a/src/core/audio/AudioFileFlac.cpp +++ b/src/core/audio/AudioFileFlac.cpp @@ -96,7 +96,7 @@ void AudioFileFlac::writeBuffer(surroundSampleFrame const* _ab, fpp_t const fram if (depth == OutputSettings::Depth_24Bit || depth == OutputSettings::Depth_32Bit) // Float encoding { - std::unique_ptr buf{ new sample_t[frames*channels()] }; + auto buf = std::vector(frames * channels()); for(fpp_t frame = 0; frame < frames; ++frame) { for(ch_cnt_t channel=0; channel(buf.get()),frames); + sf_writef_float(m_sf, static_cast(buf.data()), frames); } else // integer PCM encoding { - std::unique_ptr buf{ new int_sample_t[frames*channels()] }; - convertToS16(_ab, frames, master_gain, buf.get(), !isLittleEndian()); - sf_writef_short(m_sf, static_cast(buf.get()), frames); + auto buf = std::vector(frames * channels()); + convertToS16(_ab, frames, master_gain, buf.data(), !isLittleEndian()); + sf_writef_short(m_sf, static_cast(buf.data()), frames); } } diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index f319f3b5725..cbb4be2d2a1 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -65,8 +65,8 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, { unsigned maxPorts = lilv_plugin_get_num_ports(plugin); enum { inCount, outCount, maxCount }; - unsigned audioChannels[maxCount] = { 0, 0 }; // audio input and output count - unsigned midiChannels[maxCount] = { 0, 0 }; // MIDI input and output count + auto audioChannels = std::array{}; // audio input and output count + auto midiChannels = std::array{}; // MIDI input and output count const char* pluginUri = lilv_node_as_uri(lilv_plugin_get_uri(plugin)); //qDebug() << "Checking plugin" << pluginUri << "..."; @@ -247,11 +247,11 @@ void Lv2Proc::copyModelsFromCore() ev.time.frames(Engine::framesPerTick()) + ev.offset; uint32_t type = Engine::getLv2Manager()-> uridCache()[Lv2UridCache::Id::midi_MidiEvent]; - uint8_t buf[4]; - std::size_t bufsize = writeToByteSeq(ev.ev, buf, sizeof(buf)); + auto buf = std::array{}; + std::size_t bufsize = writeToByteSeq(ev.ev, buf.data(), buf.size()); if(bufsize) { - lv2_evbuf_write(&iter, atomStamp, type, bufsize, buf); + lv2_evbuf_write(&iter, atomStamp, type, bufsize, buf.data()); } } } diff --git a/src/core/midi/MidiAlsaRaw.cpp b/src/core/midi/MidiAlsaRaw.cpp index 04ef5c1ced1..23364fc01ef 100644 --- a/src/core/midi/MidiAlsaRaw.cpp +++ b/src/core/midi/MidiAlsaRaw.cpp @@ -105,7 +105,7 @@ void MidiAlsaRaw::sendByte( unsigned char c ) void MidiAlsaRaw::run() { - unsigned char buf[128]; + auto buf = std::array{}; //int cnt = 0; while( m_quit == false ) { @@ -149,7 +149,7 @@ void MidiAlsaRaw::run() { continue; } - err = snd_rawmidi_read( m_input, buf, sizeof( buf ) ); + err = snd_rawmidi_read(m_input, buf.data(), buf.size()); if( err == -EAGAIN ) { continue; diff --git a/src/core/midi/MidiAlsaSeq.cpp b/src/core/midi/MidiAlsaSeq.cpp index b770d914cd6..760840c77c9 100644 --- a/src/core/midi/MidiAlsaSeq.cpp +++ b/src/core/midi/MidiAlsaSeq.cpp @@ -241,7 +241,7 @@ void MidiAlsaSeq::applyPortMode( MidiPort * _port ) m_seqMutex.lock(); // determine port-capabilities - unsigned int caps[2] = { 0, 0 }; + auto caps = std::array{}; switch( _port->mode() ) { diff --git a/src/core/midi/MidiClient.cpp b/src/core/midi/MidiClient.cpp index 5b008c54b92..78691de6fca 100644 --- a/src/core/midi/MidiClient.cpp +++ b/src/core/midi/MidiClient.cpp @@ -105,10 +105,10 @@ void MidiClientRaw::parseData( const unsigned char c ) /* 'Process' system real-time messages */ /*********************************************************************/ /* There are not too many real-time messages that are of interest here. - * They can occur anywhere, even in the middle of a noteon message! + * They can occur anywhere, even in the middle of a noteon message! * Real-time range: 0xF8 .. 0xFF * Note: Real-time does not affect (running) status. - */ + */ if( c >= 0xF8 ) { if( c == MidiSystemReset ) @@ -124,13 +124,13 @@ void MidiClientRaw::parseData( const unsigned char c ) /* 'Process' system common messages (again, just skip them) */ /*********************************************************************/ /* There are no system common messages that are of interest here. - * System common range: 0xF0 .. 0xF7 + * System common range: 0xF0 .. 0xF7 */ if( c > 0xF0 ) { /* MIDI spec say: To ignore a non-real-time message, just discard all * data up to the next status byte. And our parser will ignore data - * that is received without a valid status. + * that is received without a valid status. * Note: system common cancels running status. */ m_midiParseData.m_status = 0; return; @@ -186,14 +186,14 @@ void MidiClientRaw::parseData( const unsigned char c ) /*********************************************************************/ /* Send the event */ /*********************************************************************/ - /* The event is ready-to-go. About 'running status': - * + /* The event is ready-to-go. About 'running status': + * * The MIDI protocol has a built-in compression mechanism. If several * similar events are sent in-a-row, for example note-ons, then the * event type is only sent once. For this case, the last event type * (status) is remembered. * We simply keep the status as it is, just reset the parameter counter. - * If another status byte comes in, it will overwrite the status. + * If another status byte comes in, it will overwrite the status. */ m_midiParseData.m_midiEvent.setType(static_cast(m_midiParseData.m_status)); m_midiParseData.m_midiEvent.setChannel(m_midiParseData.m_channel); @@ -224,7 +224,7 @@ void MidiClientRaw::parseData( const unsigned char c ) m_midiParseData.m_midiEvent.setPitchBend((m_midiParseData.m_buffer[1] * 128) | m_midiParseData.m_buffer[0]); break; - default: + default: // Unlikely return; } @@ -271,7 +271,7 @@ void MidiClientRaw::processOutEvent(const MidiEvent& event, const TimePos&, cons // Taken from Nagano Daisuke's USB-MIDI driver -static const unsigned char REMAINS_F0F6[] = +static const auto REMAINS_F0F6 = std::array { 0, /* 0xF0 */ 2, /* 0XF1 */ @@ -282,7 +282,7 @@ static const unsigned char REMAINS_F0F6[] = 1 /* 0XF6 */ } ; -static const unsigned char REMAINS_80E0[] = +static const auto REMAINS_80E0 = std::array { 3, /* 0x8X Note Off */ 3, /* 0x9X Note On */ diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 64c1c1614d0..060a97811b5 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -23,6 +23,7 @@ * */ +#include #include #include @@ -71,7 +72,7 @@ QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) QLinearGradient darken( const QLinearGradient & _gradient ) { QGradientStops stops = _gradient.stops(); - for (auto& stop : stops) + for (auto& stop : stops) { QColor color = stop.second; stop.second = color.lighter(133); @@ -216,8 +217,8 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, int a50 = static_cast( a100 * .6 ); int a25 = static_cast( a100 * .33 ); - QLine lines[4]; - QPoint points[4]; + auto lines = std::array{}; + auto points = std::array{}; // black inside lines // 50% @@ -231,7 +232,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.left() + 1, rect.bottom() - 2); lines[3] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - painter->drawLines(lines, 4); + painter->drawLines(lines.data(), 4); // black inside dots black.setAlpha(a50); @@ -240,7 +241,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.left() + 2, rect.bottom() - 2); points[2] = QPoint(rect.right() - 2, rect.top() + 2); points[3] = QPoint(rect.right() - 2, rect.bottom() - 2); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); // outside lines - shadow @@ -251,7 +252,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.right() - 2, rect.top()); lines[1] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - painter->drawLines(lines, 2); + painter->drawLines(lines.data(), 2); // outside corner dots - shadow // 75% @@ -259,7 +260,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, painter->setPen(QPen(shadow, 0)); points[0] = QPoint(rect.left() + 1, rect.top() + 1); points[1] = QPoint(rect.right() - 1, rect.top() + 1); - painter->drawPoints(points, 2); + painter->drawPoints(points.data(), 2); // outside end dots - shadow // 50% @@ -269,7 +270,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.left(), rect.top() + 1); points[2] = QPoint(rect.right() - 1, rect.top()); points[3] = QPoint(rect.left(), rect.bottom() - 1); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); // outside lines - highlight @@ -280,7 +281,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.right() - 2, rect.bottom()); lines[1] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 2); + painter->drawLines(lines.data(), 2); // outside corner dots - highlight // 75% @@ -288,7 +289,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, painter->setPen(QPen(highlight, 0)); points[0] = QPoint(rect.left() + 1, rect.bottom() - 1); points[1] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 2); + painter->drawPoints(points.data(), 2); // outside end dots - highlight // 50% @@ -298,7 +299,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.right(), rect.bottom() - 1); points[2] = QPoint(rect.left() + 1, rect.bottom()); points[3] = QPoint(rect.right(), rect.top() + 1); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); } else { diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index e296301ec07..db56557a4d8 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -968,8 +968,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) { if( m_y_auto ) { - int y[] = { grid_bottom, TOP_MARGIN + font_height / 2 }; - float level[] = { m_minLevel, m_maxLevel }; + auto y = std::array{grid_bottom, TOP_MARGIN + font_height / 2}; + auto level = std::array{m_minLevel, m_maxLevel}; for( int i = 0; i < 2; ++i ) { const QString & label = m_clip->firstObject() diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 92c5ba72a1c..5f294d6e874 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -129,7 +129,7 @@ QPixmap* PianoRoll::s_toolKnife = nullptr; TextFloat * PianoRoll::s_textFloat = nullptr; -static QString s_noteStrings[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; +static std::array s_noteStrings {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; static QString getNoteString(int key) { @@ -137,7 +137,7 @@ static QString getNoteString(int key) } // used for drawing of piano -PianoRoll::PianoRollKeyTypes PianoRoll::prKeyOrder[] = +std::array PianoRoll::prKeyOrder { PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, PR_BLACK_KEY, PR_WHITE_KEY_SMALL, PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, @@ -369,10 +369,10 @@ PianoRoll::PianoRoll() : // Set up note length model m_noteLenModel.addItem( tr( "Last note" ), std::make_unique( "edit_draw" ) ); - const QString pixmaps[] = { "whole", "half", "quarter", "eighth", + const auto pixmaps = std::array{"whole", "half", "quarter", "eighth", "sixteenth", "thirtysecond", "triplethalf", "tripletquarter", "tripleteighth", - "tripletsixteenth", "tripletthirtysecond" } ; + "tripletsixteenth", "tripletthirtysecond"}; for( int i = 0; i < NUM_EVEN_LENGTHS; ++i ) { diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index a64b22095ac..7478c82049a 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -62,7 +62,7 @@ namespace lmms::gui /*! The scale of C Major - white keys only. */ -Keys WhiteKeys[] = +auto WhiteKeys = std::array { Key_C, Key_D, Key_E, Key_F, Key_G, Key_A, Key_H } ; diff --git a/src/gui/modals/ExportProjectDialog.cpp b/src/gui/modals/ExportProjectDialog.cpp index 7671e031ef3..1f937c37496 100644 --- a/src/gui/modals/ExportProjectDialog.cpp +++ b/src/gui/modals/ExportProjectDialog.cpp @@ -79,14 +79,14 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, cbIndex++; } } - + int const MAX_LEVEL=8; for(int i=0; i<=MAX_LEVEL; ++i) { QString info=""; if ( i==0 ){ info = tr( "( Fastest - biggest )" ); } else if ( i==MAX_LEVEL ){ info = tr( "( Slowest - smallest )" ); } - + compLevelCB->addItem( QString::number(i)+" "+info, QVariant(i/static_cast(MAX_LEVEL)) @@ -159,8 +159,8 @@ void ExportProjectDialog::startExport() static_cast(interpolationCB->currentIndex()), static_cast(oversamplingCB->currentIndex()) ); - const int samplerates[5] = { 44100, 48000, 88200, 96000, 192000 }; - const bitrate_t bitrates[6] = { 64, 128, 160, 192, 256, 320 }; + const auto samplerates = std::array{44100, 48000, 88200, 96000, 192000}; + const auto bitrates = std::array{64, 128, 160, 192, 256, 320}; bool useVariableBitRate = checkBoxVariableBitRate->isChecked(); diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index f31d03b2c43..1be07281577 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -35,7 +35,7 @@ namespace lmms::gui { -static const QString names[LedCheckBox::NumColors] = +static const auto names = std::array { "led_yellow", "led_green", "led_red" } ;