Revisit the initialization for local variables (#7143)
* clang-tidy: Apply cppcoreguidelines-init-variables everywhere (treating NaNs as zeros) * Initialize msec and tick outside switch * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/Vestige/Vestige.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/VstEffect/VstEffectControls.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Use initialization with = * Use tabs * Use static_cast * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Do not use tabs for alignment in src/core/DrumSynth.cpp Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com> * Move x variable inside loop * Use ternary operator for b variable * Revert "Use tabs" This reverts commit 07afd8a83f58b539c3673310b2aad4b63c9198a0. * Remove unnecessary variables in XpressiveView * Simplify initialization in Plugin * Combine declaration and initialization in EqCurve * Combine declaration and initialization in Song * Combine declaration and initialization in AudioAlsa * Combine declaration and initialization in EqCurve (again) * Missed some * Undo changes made to non-LMMS files * Undo indentation changes in SidInstrument.cpp * Combine declaration with assignment in IoHelper * Combine declaration with assignment using auto in Carla * Combine declaration with assignment * Combine declaration with assignment in BasicFilters * Simplify assignments in AudioFileProcessorWaveView::zoom * Simplify out sample variable in BitInvader * Remove sampleLength variable in DelayEffect * Move gain variable in DynamicsProcessor * Combine peak variable declaration with assignment in EqSpectrumView * Move left/right lfo variables in for loop in FlangerEffect * Use ternary operator for group variable in LadspaControlDialog * Combine declaration with assignment in Lb302 * Combine declaration with assignment in MidiExport * Combine declaration with assignment in MidiFile * Combine declaration with assignment in MidiImport * Use ternary operator for vel_adjusted variable in OpulenZ * Move tmpL and dcblkL variables in for loop in ReverbSC * Combine declaration with initialization in SlicerT * Combine declaration with assignment in SaSpectrumView * Combine declaration with assignment in SaWaterfallView * Combine declaration with assignment in StereoEnhancerEffect * Combine declaration with assignment in VibratingString * Combine declaration with assignment in VstEffectControls * Combine declaration with assignment in Xpressive * Combine declaration with assignment in AutomatableModel * Combine declaration with assignment in AutomationClip * Move sample variable in for loop in BandLimitedWave * Combine declaration with assignment in DataFile * Combine declaration with assignment in DrumSynth * Combine declaration with assignment in Effect * Remove redundant assignment to nphsLeft in InstrumentPlayHandle * Combine declaration with assignment in LadspaManager * Combine declaration with assignment in LinkedModelGroups * Combine declaration with assignment in MemoryHelper * Combine declaration with assignment in AudioAlsa * Combine declaration with assignment in AudioFileOgg * Combine declaration with assignment in AudioPortAudio * Combine declaration with assignment in AudioSoundIo * Combine declaration with assignment in Lv2Evbuf * Combine declaration with assignment in Lv2Proc * Combine declaration with assignment in main * Combine declaration with assignment in MidiAlsaRaw * Combine declaration with assignment in MidiAlsaSeq * Combine declaration with assignment in MidiController * Combine declaration with assignment in MidiJack * Combine declaration with assignment in MidiSndio * Combine declaration with assignment in ControlLayout * Combine declaration with assignment in MainWindow * Combine declaration with assignment in ProjectNotes * Use ternary operator for nextValue variable in AutomationClipView * Combine declaration with assignment in AutomationEditor * Move length variable in for-loop in PianoRoll * Combine declaration with assignment in ControllerConnectionDialog * Combine declaration with assignment in Graph * Combine declaration with assignment in LcdFloatSpinBox * Combine declaration with assignment in TimeDisplayWidget * Remove currentNote variable in InstrumentTrack * Combine declaration with assignment in DrumSynth (again) * Use ternary operator for factor variable in BitInvader * Use ternary operator for highestBandwich variable in EqCurve Bandwich? * Move sum variable into for loop in Graph * Fix format in MidiSndio * Fixup a few more * Cleanup error variables * Use ternary operators and combine declaration with initialization * Combine declaration with initialization * Update plugins/LadspaEffect/LadspaControlDialog.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/OpulenZ/OpulenZ.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update plugins/SpectrumAnalyzer/SaProcessor.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/midi/MidiAlsaRaw.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/MainWindow.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/clips/AutomationClipView.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/editors/AutomationEditor.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/widgets/Fader.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Move static_cast conversion into separate variable * Use real index when interpolating * Remove empty line * Make helpBtn a private member * Move controller type into separate variable * Fix format of DrumSynth::waveform function * Use tabs and static_cast * Remove redundant if branch * Refactor using static_cast/reinterpret_cast * Add std namespace prefix * Store repeated conditional into boolean variable * Cast to int before assigning to m_currentLength * Rename note_frames to noteFrames * Update src/core/Controller.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/core/DrumSynth.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Update src/gui/widgets/Graph.cpp Co-authored-by: Kevin Zander <veratil@gmail.com> * Revert changes that initialized variables redudantly For situations where the initialization is more complex or passed into a function by a pointer, we dont need to do initialization ourselves since it is already done for us, just in a different way. * Remove redundant err variable * Remove explicit check of err variable * Clean up changes and address review * Do not initialize to 0/nullptr when not needed * Wrap condition in parentheses for readability --------- Co-authored-by: Kevin Zander <veratil@gmail.com> Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
@@ -613,10 +613,9 @@ ValueBuffer * AutomatableModel::valueBuffer()
|
||||
|
||||
float val = m_value; // make sure our m_value doesn't change midway
|
||||
|
||||
ValueBuffer * vb;
|
||||
if (m_controllerConnection && m_useControllerValue && m_controllerConnection->getController()->isSampleExact())
|
||||
{
|
||||
vb = m_controllerConnection->valueBuffer();
|
||||
auto vb = m_controllerConnection->valueBuffer();
|
||||
if( vb )
|
||||
{
|
||||
float * values = vb->values();
|
||||
@@ -656,7 +655,7 @@ ValueBuffer * AutomatableModel::valueBuffer()
|
||||
if (lm && lm->controllerConnection() && lm->useControllerValue() &&
|
||||
lm->controllerConnection()->getController()->isSampleExact())
|
||||
{
|
||||
vb = lm->valueBuffer();
|
||||
auto vb = lm->valueBuffer();
|
||||
float * values = vb->values();
|
||||
float * nvalues = m_valueBuffer.values();
|
||||
for (int i = 0; i < vb->length(); i++)
|
||||
|
||||
@@ -1222,11 +1222,9 @@ void AutomationClip::generateTangents(timeMap::iterator it, int numToGenerate)
|
||||
// TODO: This behavior means that a very small difference between the inValue and outValue can
|
||||
// result in a big change in the curve. In the future, allowing the user to manually adjust
|
||||
// the tangents would be better.
|
||||
float inTangent;
|
||||
float outTangent;
|
||||
if (OFFSET(it) == 0)
|
||||
{
|
||||
inTangent = (INVAL(it + 1) - OUTVAL(it - 1)) / (POS(it + 1) - POS(it - 1));
|
||||
float inTangent = (INVAL(it + 1) - OUTVAL(it - 1)) / (POS(it + 1) - POS(it - 1));
|
||||
it.value().setInTangent(inTangent);
|
||||
// inTangent == outTangent in this case
|
||||
it.value().setOutTangent(inTangent);
|
||||
@@ -1234,9 +1232,9 @@ void AutomationClip::generateTangents(timeMap::iterator it, int numToGenerate)
|
||||
else
|
||||
{
|
||||
// Calculate the left side of the curve
|
||||
inTangent = (INVAL(it) - OUTVAL(it - 1)) / (POS(it) - POS(it - 1));
|
||||
float inTangent = (INVAL(it) - OUTVAL(it - 1)) / (POS(it) - POS(it - 1));
|
||||
// Calculate the right side of the curve
|
||||
outTangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it));
|
||||
float outTangent = (INVAL(it + 1) - OUTVAL(it)) / (POS(it + 1) - POS(it));
|
||||
it.value().setInTangent(inTangent);
|
||||
it.value().setOutTangent(outTangent);
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ QDataStream& operator<< ( QDataStream &out, WaveMipMap &waveMipMap )
|
||||
|
||||
QDataStream& operator>> ( QDataStream &in, WaveMipMap &waveMipMap )
|
||||
{
|
||||
sample_t sample;
|
||||
for( int tbl = 0; tbl <= MAXTBL; tbl++ )
|
||||
{
|
||||
for( int i = 0; i < TLENS[tbl]; i++ )
|
||||
{
|
||||
sample_t sample;
|
||||
in >> sample;
|
||||
waveMipMap.setSampleAt( tbl, i, sample );
|
||||
}
|
||||
@@ -67,9 +67,8 @@ void BandLimitedWave::generateWaves()
|
||||
// don't generate if they already exist
|
||||
if( s_wavesGenerated ) return;
|
||||
|
||||
int i;
|
||||
|
||||
// set wavetable directory
|
||||
// set wavetable directory
|
||||
s_wavetableDir = "data:wavetables/";
|
||||
|
||||
// set wavetable files
|
||||
@@ -89,7 +88,7 @@ void BandLimitedWave::generateWaves()
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i <= MAXTBL; i++ )
|
||||
for (int i = 0; i <= MAXTBL; i++)
|
||||
{
|
||||
const int len = TLENS[i];
|
||||
//const double om = 1.0 / len;
|
||||
@@ -131,7 +130,7 @@ void BandLimitedWave::generateWaves()
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i <= MAXTBL; i++ )
|
||||
for (int i = 0; i <= MAXTBL; i++)
|
||||
{
|
||||
const int len = TLENS[i];
|
||||
//const double om = 1.0 / len;
|
||||
@@ -172,7 +171,7 @@ void BandLimitedWave::generateWaves()
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i <= MAXTBL; i++ )
|
||||
for (int i = 0; i <= MAXTBL; i++)
|
||||
{
|
||||
const int len = TLENS[i];
|
||||
//const double om = 1.0 / len;
|
||||
@@ -215,7 +214,7 @@ void BandLimitedWave::generateWaves()
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i <= MAXTBL; i++ )
|
||||
for (int i = 0; i <= MAXTBL; i++)
|
||||
{
|
||||
const int len = TLENS[i];
|
||||
|
||||
|
||||
@@ -220,24 +220,12 @@ Controller * Controller::create( ControllerType _ct, Model * _parent )
|
||||
|
||||
Controller * Controller::create( const QDomElement & _this, Model * _parent )
|
||||
{
|
||||
Controller * c;
|
||||
if( static_cast<ControllerType>(_this.attribute( "type" ).toInt()) == ControllerType::Peak )
|
||||
{
|
||||
c = PeakController::getControllerBySetting( _this );
|
||||
}
|
||||
else
|
||||
{
|
||||
c = create(
|
||||
static_cast<ControllerType>( _this.attribute( "type" ).toInt() ),
|
||||
_parent );
|
||||
}
|
||||
|
||||
if( c != nullptr )
|
||||
{
|
||||
c->restoreState( _this );
|
||||
}
|
||||
|
||||
return( c );
|
||||
const auto controllerType = static_cast<ControllerType>(_this.attribute("type").toInt());
|
||||
auto controller = controllerType == ControllerType::Peak
|
||||
? PeakController::getControllerBySetting(_this)
|
||||
: create(controllerType, _parent);
|
||||
if (controller) { controller->restoreState(_this); }
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1194,12 +1194,11 @@ void DataFile::upgrade_1_2_0_rc3()
|
||||
"pattern" );
|
||||
for( int j = 0; !patterns.item( j ).isNull(); ++j )
|
||||
{
|
||||
int patternLength, steps;
|
||||
QDomElement el = patterns.item( j ).toElement();
|
||||
if( el.attribute( "len" ) != "" )
|
||||
{
|
||||
patternLength = el.attribute( "len" ).toInt();
|
||||
steps = patternLength / 12;
|
||||
int patternLength = el.attribute( "len" ).toInt();
|
||||
int steps = patternLength / 12;
|
||||
el.setAttribute( "steps", steps );
|
||||
}
|
||||
}
|
||||
@@ -1456,7 +1455,7 @@ void DataFile::upgrade_1_3_0()
|
||||
if(num == 4)
|
||||
{
|
||||
// don't modify port 4, but some other ones:
|
||||
int zoom_port;
|
||||
int zoom_port = 0;
|
||||
if (plugin == "Equalizer5Band")
|
||||
zoom_port = 36;
|
||||
else if (plugin == "Equalizer8Band")
|
||||
|
||||
@@ -69,16 +69,16 @@ float mem_t=1.0f, mem_o=1.0f, mem_n=1.0f, mem_b=1.0f, mem_tune=1.0f, mem_time=1.
|
||||
|
||||
int DrumSynth::LongestEnv()
|
||||
{
|
||||
long e, eon, p;
|
||||
float l=0.f;
|
||||
float l = 0.f;
|
||||
|
||||
for(e=1; e<7; e++) //3
|
||||
{
|
||||
eon = e - 1; if(eon>2) eon=eon-1;
|
||||
p = 0;
|
||||
while (envpts[e][0][p + 1] >= 0.f) p++;
|
||||
envData[e][MAX] = envpts[e][0][p] * timestretch;
|
||||
if(chkOn[eon]==1) if(envData[e][MAX]>l) l=envData[e][MAX];
|
||||
for (long e = 1; e < 7; e++) // 3
|
||||
{
|
||||
long eon = e - 1;
|
||||
if (eon > 2) { eon = eon - 1; }
|
||||
long p = 0;
|
||||
while (envpts[e][0][p + 1] >= 0.f) { p++; }
|
||||
envData[e][MAX] = envpts[e][0][p] * timestretch;
|
||||
if (chkOn[eon] == 1 && envData[e][MAX] > l) { l = envData[e][MAX]; }
|
||||
}
|
||||
//l *= timestretch;
|
||||
|
||||
@@ -102,16 +102,15 @@ float DrumSynth::LoudestEnv()
|
||||
|
||||
void DrumSynth::UpdateEnv(int e, long t)
|
||||
{
|
||||
float endEnv, dT;
|
||||
//0.2's added
|
||||
envData[e][NEXTT] = envpts[e][0][(long)(envData[e][PNT] + 1.f)] * timestretch; //get next point
|
||||
if(envData[e][NEXTT] < 0) envData[e][NEXTT] = 442000 * timestretch; //if end point, hold
|
||||
envData[e][ENV] = envpts[e][1][(long)(envData[e][PNT] + 0.f)] * 0.01f; //this level
|
||||
endEnv = envpts[e][1][(long)(envData[e][PNT] + 1.f)] * 0.01f; //next level
|
||||
dT = envData[e][NEXTT] - (float)t;
|
||||
if(dT < 1.0) dT = 1.0;
|
||||
envData[e][dENV] = (endEnv - envData[e][ENV]) / dT;
|
||||
envData[e][PNT] = envData[e][PNT] + 1.0f;
|
||||
// 0.2's added
|
||||
envData[e][NEXTT] = envpts[e][0][static_cast<long>(envData[e][PNT] + 1.f)] * timestretch; // get next point
|
||||
if (envData[e][NEXTT] < 0) { envData[e][NEXTT] = 442000 * timestretch; } // if end point, hold
|
||||
envData[e][ENV] = envpts[e][1][static_cast<long>(envData[e][PNT] + 0.f)] * 0.01f; // this level
|
||||
float endEnv = envpts[e][1][static_cast<long>(envData[e][PNT] + 1.f)] * 0.01f; // next level
|
||||
float dT = envData[e][NEXTT] - static_cast<float>(t);
|
||||
if (dT < 1.0) { dT = 1.0; }
|
||||
envData[e][dENV] = (endEnv - envData[e][ENV]) / dT;
|
||||
envData[e][PNT] = envData[e][PNT] + 1.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,34 +148,41 @@ void DrumSynth::GetEnv(int env, const char *sec, const char *key, QString ini)
|
||||
|
||||
float DrumSynth::waveform(float ph, int form)
|
||||
{
|
||||
float w;
|
||||
float w;
|
||||
|
||||
switch (form)
|
||||
{
|
||||
case 0: w = (float)sin(fmod(ph,TwoPi)); break; //sine
|
||||
case 1: w = (float)fabs(2.0f*(float)sin(fmod(0.5f*ph,TwoPi)))-1.f; break; //sine^2
|
||||
case 2: while(ph<TwoPi) ph+=TwoPi;
|
||||
w = 0.6366197f * (float)fmod(ph,TwoPi) - 1.f; //tri
|
||||
if(w>1.f) w=2.f-w;
|
||||
break;
|
||||
case 3: w = ph - TwoPi * (float)(int)(ph / TwoPi); //saw
|
||||
w = (0.3183098f * w) - 1.f; break;
|
||||
default: w = (sin(fmod(ph,TwoPi))>0.0)? 1.f: -1.f; break; //square
|
||||
}
|
||||
switch (form)
|
||||
{
|
||||
case 0:
|
||||
w = static_cast<float>(sin(fmod(ph, TwoPi)));
|
||||
break; // sine
|
||||
case 1:
|
||||
w = static_cast<float>(fabs(2.0f * static_cast<float>(sin(fmod(0.5f * ph, TwoPi))) - 1.f));
|
||||
break; // sine^2
|
||||
case 2:
|
||||
while (ph < TwoPi) { ph += TwoPi; }
|
||||
w = 0.6366197f * static_cast<float>(fmod(ph, TwoPi) - 1.f); // tri
|
||||
if (w > 1.f) { w = 2.f - w; }
|
||||
break;
|
||||
case 3:
|
||||
w = ph - TwoPi * static_cast<float>(static_cast<int>(ph / TwoPi)); // saw
|
||||
w = (0.3183098f * w) - 1.f;
|
||||
break;
|
||||
default:
|
||||
w = (sin(fmod(ph, TwoPi)) > 0.0) ? 1.f : -1.f;
|
||||
break; // square
|
||||
}
|
||||
|
||||
return w;
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, QString file)
|
||||
{
|
||||
stringstream is;
|
||||
bool inSection = false;
|
||||
char *line;
|
||||
char *k, *b;
|
||||
int len = 0;
|
||||
stringstream is;
|
||||
bool inSection = false;
|
||||
int len = 0;
|
||||
|
||||
line = (char*)malloc(200);
|
||||
char* line = static_cast<char*>(malloc(200));
|
||||
|
||||
// Use QFile to handle unicode file name on Windows
|
||||
// Previously we used ifstream directly
|
||||
@@ -201,8 +207,8 @@ int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const c
|
||||
if (line[0] == '[')
|
||||
break;
|
||||
|
||||
k = strtok(line, " \t=");
|
||||
b = strtok(nullptr, "\n\r\0");
|
||||
char* k = strtok(line, " \t=");
|
||||
char* b = strtok(nullptr, "\n\r\0");
|
||||
|
||||
if (k != 0 && strcasecmp(k, key)==0) {
|
||||
if (b==0) {
|
||||
|
||||
@@ -210,8 +210,8 @@ void Effect::resample( int _i, const sampleFrame * _src_buf,
|
||||
m_srcData[_i].data_out = _dst_buf[0].data ();
|
||||
m_srcData[_i].src_ratio = (double) _dst_sr / _src_sr;
|
||||
m_srcData[_i].end_of_input = 0;
|
||||
int error;
|
||||
if( ( error = src_process( m_srcState[_i], &m_srcData[_i] ) ) )
|
||||
|
||||
if (int error = src_process(m_srcState[_i], &m_srcData[_i]))
|
||||
{
|
||||
qFatal( "Effect::resample(): error while resampling: %s\n",
|
||||
src_strerror( error ) );
|
||||
|
||||
@@ -46,11 +46,10 @@ void InstrumentPlayHandle::play(sampleFrame * working_buffer)
|
||||
|
||||
// ensure that all our nph's have been processed first
|
||||
auto nphv = NotePlayHandle::nphsOfInstrumentTrack(instrumentTrack, true);
|
||||
|
||||
bool nphsLeft;
|
||||
|
||||
bool nphsLeft = false;
|
||||
do
|
||||
{
|
||||
nphsLeft = false;
|
||||
for (const NotePlayHandle * constNotePlayHandle : nphv)
|
||||
{
|
||||
if (constNotePlayHandle->state() != ThreadableJob::ProcessingState::Done &&
|
||||
|
||||
@@ -139,11 +139,7 @@ void LadspaManager::addPlugins(
|
||||
LADSPA_Descriptor_Function _descriptor_func,
|
||||
const QString & _file )
|
||||
{
|
||||
const LADSPA_Descriptor * descriptor;
|
||||
|
||||
for( long pluginIndex = 0;
|
||||
( descriptor = _descriptor_func( pluginIndex ) ) != nullptr;
|
||||
++pluginIndex )
|
||||
for (long pluginIndex = 0; const auto descriptor = _descriptor_func(pluginIndex); ++pluginIndex)
|
||||
{
|
||||
ladspa_key_t key( _file, QString( descriptor->Label ) );
|
||||
if( m_ladspaManagerMap.contains( key ) )
|
||||
|
||||
@@ -143,9 +143,7 @@ bool LinkedModelGroup::containsModel(const QString &name) const
|
||||
void LinkedModelGroups::linkAllModels()
|
||||
{
|
||||
LinkedModelGroup* first = getGroup(0);
|
||||
LinkedModelGroup* cur;
|
||||
|
||||
for (std::size_t i = 1; (cur = getGroup(i)); ++i)
|
||||
for (size_t i = 1; auto cur = getGroup(i); ++i)
|
||||
{
|
||||
first->linkControls(cur);
|
||||
}
|
||||
@@ -172,8 +170,7 @@ void LinkedModelGroups::saveSettings(QDomDocument& doc, QDomElement& that)
|
||||
void LinkedModelGroups::loadSettings(const QDomElement& that)
|
||||
{
|
||||
QDomElement models = that.firstChildElement("models");
|
||||
LinkedModelGroup* grp0;
|
||||
if (!models.isNull() && (grp0 = getGroup(0)))
|
||||
if (auto grp0 = getGroup(0); !models.isNull() && grp0)
|
||||
{
|
||||
// only load the first group, the others are linked to the first
|
||||
grp0->loadValues(models);
|
||||
|
||||
@@ -36,15 +36,14 @@ namespace lmms
|
||||
*/
|
||||
void* MemoryHelper::alignedMalloc( size_t byteNum )
|
||||
{
|
||||
char *ptr, *ptr2, *aligned_ptr;
|
||||
int align_mask = LMMS_ALIGN_SIZE - 1;
|
||||
|
||||
ptr = static_cast<char*>( malloc( byteNum + LMMS_ALIGN_SIZE + sizeof( int ) ) );
|
||||
char* ptr = static_cast<char*>(malloc(byteNum + LMMS_ALIGN_SIZE + sizeof(int)));
|
||||
|
||||
if( ptr == nullptr ) return nullptr;
|
||||
|
||||
ptr2 = ptr + sizeof( int );
|
||||
aligned_ptr = ptr2 + ( LMMS_ALIGN_SIZE - ( ( size_t ) ptr2 & align_mask ) );
|
||||
char* ptr2 = ptr + sizeof(int);
|
||||
char* aligned_ptr = ptr2 + (LMMS_ALIGN_SIZE - ((size_t)ptr2 & align_mask));
|
||||
|
||||
ptr2 = aligned_ptr - sizeof( int );
|
||||
*( ( int* ) ptr2 ) = ( int )( aligned_ptr - ptr );
|
||||
|
||||
@@ -226,8 +226,8 @@ Plugin * Plugin::instantiate(const QString& pluginName, Model * parent,
|
||||
}
|
||||
else
|
||||
{
|
||||
InstantiationHook instantiationHook;
|
||||
if ((instantiationHook = ( InstantiationHook ) pi.library->resolve( "lmms_plugin_main" )))
|
||||
auto instantiationHook = reinterpret_cast<InstantiationHook>(pi.library->resolve("lmms_plugin_main"));
|
||||
if (instantiationHook)
|
||||
{
|
||||
inst = instantiationHook(parent, data);
|
||||
if(!inst) {
|
||||
|
||||
@@ -945,13 +945,12 @@ void Song::createNewProject()
|
||||
m_oldFileName = "";
|
||||
setProjectFileName("");
|
||||
|
||||
Track * t;
|
||||
t = Track::create( Track::Type::Instrument, this );
|
||||
dynamic_cast<InstrumentTrack * >( t )->loadInstrument(
|
||||
"tripleoscillator" );
|
||||
t = Track::create(Track::Type::Instrument, Engine::patternStore());
|
||||
dynamic_cast<InstrumentTrack * >( t )->loadInstrument(
|
||||
"kicker" );
|
||||
auto tripleOscTrack = Track::create(Track::Type::Instrument, this);
|
||||
dynamic_cast<InstrumentTrack*>(tripleOscTrack)->loadInstrument("tripleoscillator");
|
||||
|
||||
auto kickerTrack = Track::create(Track::Type::Instrument, Engine::patternStore());
|
||||
dynamic_cast<InstrumentTrack*>(kickerTrack)->loadInstrument("kicker");
|
||||
|
||||
Track::create( Track::Type::Sample, this );
|
||||
Track::create( Track::Type::Pattern, this );
|
||||
Track::create( Track::Type::Automation, this );
|
||||
|
||||
@@ -53,12 +53,7 @@ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
"Could not avoid possible interception by PulseAudio\n" );
|
||||
}
|
||||
|
||||
int err;
|
||||
|
||||
if( ( err = snd_pcm_open( &m_handle,
|
||||
probeDevice().toLatin1().constData(),
|
||||
SND_PCM_STREAM_PLAYBACK,
|
||||
0 ) ) < 0 )
|
||||
if (int err = snd_pcm_open(&m_handle, probeDevice().toLatin1().constData(), SND_PCM_STREAM_PLAYBACK, 0); err < 0)
|
||||
{
|
||||
printf( "Playback open error: %s\n", snd_strerror( err ) );
|
||||
return;
|
||||
@@ -67,14 +62,13 @@ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
snd_pcm_hw_params_malloc( &m_hwParams );
|
||||
snd_pcm_sw_params_malloc( &m_swParams );
|
||||
|
||||
if( ( err = setHWParams( channels(),
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
|
||||
if (int err = setHWParams(channels(), SND_PCM_ACCESS_RW_INTERLEAVED); err < 0)
|
||||
{
|
||||
printf( "Setting of hwparams failed: %s\n",
|
||||
snd_strerror( err ) );
|
||||
return;
|
||||
}
|
||||
if( ( err = setSWParams() ) < 0 )
|
||||
if (int err = setSWParams(); err < 0)
|
||||
{
|
||||
printf( "Setting of swparams failed: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -83,9 +77,8 @@ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) :
|
||||
|
||||
// set FD_CLOEXEC flag for all file descriptors so forked processes
|
||||
// do not inherit them
|
||||
struct pollfd * ufds;
|
||||
int count = snd_pcm_poll_descriptors_count( m_handle );
|
||||
ufds = new pollfd[count];
|
||||
auto ufds = new pollfd[count];
|
||||
snd_pcm_poll_descriptors( m_handle, ufds, count );
|
||||
for (int i = 0; i < std::max(3, count); ++i)
|
||||
{
|
||||
@@ -160,7 +153,7 @@ AudioAlsa::DeviceInfoCollection AudioAlsa::getAvailableDevices()
|
||||
{
|
||||
DeviceInfoCollection deviceInfos;
|
||||
|
||||
char **hints;
|
||||
char** hints = nullptr;
|
||||
|
||||
/* Enumerate sound devices */
|
||||
int err = snd_device_name_hint(-1, "pcm", (void***)&hints);
|
||||
@@ -261,25 +254,21 @@ void AudioAlsa::applyQualitySettings()
|
||||
snd_pcm_close( m_handle );
|
||||
}
|
||||
|
||||
int err;
|
||||
if( ( err = snd_pcm_open( &m_handle,
|
||||
probeDevice().toLatin1().constData(),
|
||||
SND_PCM_STREAM_PLAYBACK,
|
||||
0 ) ) < 0 )
|
||||
if (int err = snd_pcm_open(&m_handle, probeDevice().toLatin1().constData(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
err < 0)
|
||||
{
|
||||
printf( "Playback open error: %s\n",
|
||||
snd_strerror( err ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ( err = setHWParams( channels(),
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
|
||||
if (int err = setHWParams(channels(), SND_PCM_ACCESS_RW_INTERLEAVED); err < 0)
|
||||
{
|
||||
printf( "Setting of hwparams failed: %s\n",
|
||||
snd_strerror( err ) );
|
||||
return;
|
||||
}
|
||||
if( ( err = setSWParams() ) < 0 )
|
||||
if (int err = setSWParams(); err < 0)
|
||||
{
|
||||
printf( "Setting of swparams failed: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -370,10 +359,8 @@ void AudioAlsa::run()
|
||||
|
||||
int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
{
|
||||
int err, dir;
|
||||
|
||||
// choose all parameters
|
||||
if( ( err = snd_pcm_hw_params_any( m_handle, m_hwParams ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_any(m_handle, m_hwParams); err < 0)
|
||||
{
|
||||
printf( "Broken configuration for playback: no configurations "
|
||||
"available: %s\n", snd_strerror( err ) );
|
||||
@@ -381,8 +368,7 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
}
|
||||
|
||||
// set the interleaved read/write format
|
||||
if( ( err = snd_pcm_hw_params_set_access( m_handle, m_hwParams,
|
||||
_access ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_access(m_handle, m_hwParams, _access); err < 0)
|
||||
{
|
||||
printf( "Access type not available for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -390,11 +376,9 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
}
|
||||
|
||||
// set the sample format
|
||||
if( ( snd_pcm_hw_params_set_format( m_handle, m_hwParams,
|
||||
SND_PCM_FORMAT_S16_LE ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_format(m_handle, m_hwParams, SND_PCM_FORMAT_S16_LE); err < 0)
|
||||
{
|
||||
if( ( snd_pcm_hw_params_set_format( m_handle, m_hwParams,
|
||||
SND_PCM_FORMAT_S16_BE ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_format(m_handle, m_hwParams, SND_PCM_FORMAT_S16_BE); err < 0)
|
||||
{
|
||||
printf( "Neither little- nor big-endian available for "
|
||||
"playback: %s\n", snd_strerror( err ) );
|
||||
@@ -408,8 +392,7 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
}
|
||||
|
||||
// set the count of channels
|
||||
if( ( err = snd_pcm_hw_params_set_channels( m_handle, m_hwParams,
|
||||
_channels ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_channels(m_handle, m_hwParams, _channels); err < 0)
|
||||
{
|
||||
printf( "Channel count (%i) not available for playbacks: %s\n"
|
||||
"(Does your soundcard not support surround?)\n",
|
||||
@@ -418,11 +401,9 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
}
|
||||
|
||||
// set the sample rate
|
||||
if( ( err = snd_pcm_hw_params_set_rate( m_handle, m_hwParams,
|
||||
sampleRate(), 0 ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_rate(m_handle, m_hwParams, sampleRate(), 0); err < 0)
|
||||
{
|
||||
if( ( err = snd_pcm_hw_params_set_rate( m_handle, m_hwParams,
|
||||
audioEngine()->baseSampleRate(), 0 ) ) < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_rate(m_handle, m_hwParams, audioEngine()->baseSampleRate(), 0); err < 0)
|
||||
{
|
||||
printf( "Could not set sample rate: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -432,36 +413,29 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
|
||||
m_periodSize = audioEngine()->framesPerPeriod();
|
||||
m_bufferSize = m_periodSize * 8;
|
||||
dir = 0;
|
||||
err = snd_pcm_hw_params_set_period_size_near( m_handle, m_hwParams,
|
||||
&m_periodSize, &dir );
|
||||
if( err < 0 )
|
||||
int dir;
|
||||
if (int err = snd_pcm_hw_params_set_period_size_near(m_handle, m_hwParams, &m_periodSize, &dir); err < 0)
|
||||
{
|
||||
printf( "Unable to set period size %lu for playback: %s\n",
|
||||
m_periodSize, snd_strerror( err ) );
|
||||
return err;
|
||||
}
|
||||
dir = 0;
|
||||
err = snd_pcm_hw_params_get_period_size( m_hwParams, &m_periodSize,
|
||||
&dir );
|
||||
if( err < 0 )
|
||||
if (int err = snd_pcm_hw_params_get_period_size(m_hwParams, &m_periodSize, &dir); err < 0)
|
||||
{
|
||||
printf( "Unable to get period size for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
}
|
||||
|
||||
dir = 0;
|
||||
err = snd_pcm_hw_params_set_buffer_size_near( m_handle, m_hwParams,
|
||||
&m_bufferSize );
|
||||
if( err < 0 )
|
||||
if (int err = snd_pcm_hw_params_set_buffer_size_near(m_handle, m_hwParams, &m_bufferSize); err < 0)
|
||||
{
|
||||
printf( "Unable to set buffer size %lu for playback: %s\n",
|
||||
m_bufferSize, snd_strerror( err ) );
|
||||
return ( err );
|
||||
}
|
||||
err = snd_pcm_hw_params_get_buffer_size( m_hwParams, &m_bufferSize );
|
||||
|
||||
if( 2 * m_periodSize > m_bufferSize )
|
||||
if (int err = snd_pcm_hw_params_get_buffer_size(m_hwParams, &m_bufferSize); 2 * m_periodSize > m_bufferSize)
|
||||
{
|
||||
printf( "buffer to small, could not use\n" );
|
||||
return ( err );
|
||||
@@ -469,8 +443,7 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
|
||||
|
||||
// write the parameters to device
|
||||
err = snd_pcm_hw_params( m_handle, m_hwParams );
|
||||
if( err < 0 )
|
||||
if (int err = snd_pcm_hw_params(m_handle, m_hwParams); err < 0)
|
||||
{
|
||||
printf( "Unable to set hw params for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -485,10 +458,8 @@ int AudioAlsa::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
|
||||
|
||||
int AudioAlsa::setSWParams()
|
||||
{
|
||||
int err;
|
||||
|
||||
// get the current swparams
|
||||
if( ( err = snd_pcm_sw_params_current( m_handle, m_swParams ) ) < 0 )
|
||||
if (int err = snd_pcm_sw_params_current(m_handle, m_swParams); err < 0)
|
||||
{
|
||||
printf( "Unable to determine current swparams for playback: %s"
|
||||
"\n", snd_strerror( err ) );
|
||||
@@ -496,8 +467,7 @@ int AudioAlsa::setSWParams()
|
||||
}
|
||||
|
||||
// start the transfer when a period is full
|
||||
if( ( err = snd_pcm_sw_params_set_start_threshold( m_handle,
|
||||
m_swParams, m_periodSize ) ) < 0 )
|
||||
if (int err = snd_pcm_sw_params_set_start_threshold(m_handle, m_swParams, m_periodSize); err < 0)
|
||||
{
|
||||
printf( "Unable to set start threshold mode for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -506,8 +476,7 @@ int AudioAlsa::setSWParams()
|
||||
|
||||
// allow the transfer when at least m_periodSize samples can be
|
||||
// processed
|
||||
if( ( err = snd_pcm_sw_params_set_avail_min( m_handle, m_swParams,
|
||||
m_periodSize ) ) < 0 )
|
||||
if (int err = snd_pcm_sw_params_set_avail_min(m_handle, m_swParams, m_periodSize); err < 0)
|
||||
{
|
||||
printf( "Unable to set avail min for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
@@ -527,7 +496,7 @@ int AudioAlsa::setSWParams()
|
||||
#endif
|
||||
|
||||
// write the parameters to the playback device
|
||||
if( ( err = snd_pcm_sw_params( m_handle, m_swParams ) ) < 0 )
|
||||
if (int err = snd_pcm_sw_params(m_handle, m_swParams); err < 0)
|
||||
{
|
||||
printf( "Unable to set sw params for playback: %s\n",
|
||||
snd_strerror( err ) );
|
||||
|
||||
@@ -195,8 +195,7 @@ fpp_t AudioDevice::resample( const surroundSampleFrame * _src,
|
||||
m_srcData.data_out = _dst[0].data ();
|
||||
m_srcData.src_ratio = (double) _dst_sr / _src_sr;
|
||||
m_srcData.end_of_input = 0;
|
||||
int error;
|
||||
if( ( error = src_process( m_srcState, &m_srcData ) ) )
|
||||
if (int error = src_process(m_srcState, &m_srcData))
|
||||
{
|
||||
printf( "AudioDevice::resample(): error while resampling: %s\n",
|
||||
src_strerror( error ) );
|
||||
@@ -213,12 +212,11 @@ int AudioDevice::convertToS16( const surroundSampleFrame * _ab,
|
||||
{
|
||||
if( _convert_endian )
|
||||
{
|
||||
int_sample_t temp;
|
||||
for( fpp_t frame = 0; frame < _frames; ++frame )
|
||||
{
|
||||
for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl )
|
||||
{
|
||||
temp = static_cast<int_sample_t>(AudioEngine::clip(_ab[frame][chnl]) * OUTPUT_SAMPLE_MULTIPLIER);
|
||||
auto temp = static_cast<int_sample_t>(AudioEngine::clip(_ab[frame][chnl]) * OUTPUT_SAMPLE_MULTIPLIER);
|
||||
|
||||
( _output_buffer + frame * channels() )[chnl] =
|
||||
( temp & 0x00ff ) << 8 |
|
||||
|
||||
@@ -156,7 +156,6 @@ bool AudioFileOgg::startEncoding()
|
||||
ogg_packet header_main;
|
||||
ogg_packet header_comments;
|
||||
ogg_packet header_codebooks;
|
||||
int result;
|
||||
|
||||
// Build the packets
|
||||
vorbis_analysis_headerout( &m_vd, m_comments, &header_main,
|
||||
@@ -167,14 +166,9 @@ bool AudioFileOgg::startEncoding()
|
||||
ogg_stream_packetin( &m_os, &header_comments );
|
||||
ogg_stream_packetin( &m_os, &header_codebooks );
|
||||
|
||||
while( ( result = ogg_stream_flush( &m_os, &m_og ) ) )
|
||||
while (ogg_stream_flush(&m_os, &m_og))
|
||||
{
|
||||
if( !result )
|
||||
{
|
||||
break;
|
||||
}
|
||||
int ret = writePage();
|
||||
if( ret != m_og.header_len + m_og.body_len )
|
||||
if (int ret = writePage(); ret != m_og.header_len + m_og.body_len)
|
||||
{
|
||||
// clean up
|
||||
finishEncoding();
|
||||
|
||||
@@ -92,10 +92,9 @@ AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioEngine * _audioEngine
|
||||
|
||||
PaDeviceIndex inDevIdx = -1;
|
||||
PaDeviceIndex outDevIdx = -1;
|
||||
const PaDeviceInfo * di;
|
||||
for( int i = 0; i < Pa_GetDeviceCount(); ++i )
|
||||
{
|
||||
di = Pa_GetDeviceInfo( i );
|
||||
const auto di = Pa_GetDeviceInfo(i);
|
||||
if( di->name == device &&
|
||||
Pa_GetHostApiInfo( di->hostApi )->name == backend )
|
||||
{
|
||||
@@ -343,10 +342,9 @@ void AudioPortAudioSetupUtil::updateBackends()
|
||||
return;
|
||||
}
|
||||
|
||||
const PaHostApiInfo * hi;
|
||||
for( int i = 0; i < Pa_GetHostApiCount(); ++i )
|
||||
{
|
||||
hi = Pa_GetHostApiInfo( i );
|
||||
const auto hi = Pa_GetHostApiInfo(i);
|
||||
m_backendModel.addItem( hi->name );
|
||||
}
|
||||
|
||||
@@ -367,10 +365,9 @@ void AudioPortAudioSetupUtil::updateDevices()
|
||||
// get active backend
|
||||
const QString& backend = m_backendModel.currentText();
|
||||
int hostApi = 0;
|
||||
const PaHostApiInfo * hi;
|
||||
for( int i = 0; i < Pa_GetHostApiCount(); ++i )
|
||||
{
|
||||
hi = Pa_GetHostApiInfo( i );
|
||||
const auto hi = Pa_GetHostApiInfo(i);
|
||||
if( backend == hi->name )
|
||||
{
|
||||
hostApi = i;
|
||||
@@ -380,10 +377,9 @@ void AudioPortAudioSetupUtil::updateDevices()
|
||||
|
||||
// get devices for selected backend
|
||||
m_deviceModel.clear();
|
||||
const PaDeviceInfo * di;
|
||||
for( int i = 0; i < Pa_GetDeviceCount(); ++i )
|
||||
{
|
||||
di = Pa_GetDeviceInfo( i );
|
||||
const auto di = Pa_GetDeviceInfo(i);
|
||||
if( di->hostApi == hostApi )
|
||||
{
|
||||
m_deviceModel.addItem( di->name );
|
||||
|
||||
@@ -69,7 +69,6 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
|
||||
const QString& configDeviceId = ConfigManager::inst()->value( "audiosoundio", "out_device_id" );
|
||||
const QString& configDeviceRaw = ConfigManager::inst()->value( "audiosoundio", "out_device_raw" );
|
||||
|
||||
int err;
|
||||
int outDeviceCount = 0;
|
||||
int backendCount = soundio_backend_count(m_soundio);
|
||||
for (int i = 0; i < backendCount; i += 1)
|
||||
@@ -77,11 +76,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
|
||||
SoundIoBackend backend = soundio_get_backend(m_soundio, i);
|
||||
if (configBackend == soundio_backend_name(backend))
|
||||
{
|
||||
if ((err = soundio_connect_backend(m_soundio, backend)))
|
||||
{
|
||||
// error occurred, leave outDeviceCount 0
|
||||
}
|
||||
else
|
||||
if (!soundio_connect_backend(m_soundio, backend))
|
||||
{
|
||||
soundio_flush_events(m_soundio);
|
||||
if (m_disconnectErr)
|
||||
@@ -98,7 +93,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
|
||||
if (outDeviceCount <= 0)
|
||||
{
|
||||
// try connecting to the default backend
|
||||
if ((err = soundio_connect(m_soundio)))
|
||||
if (int err = soundio_connect(m_soundio))
|
||||
{
|
||||
fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(err));
|
||||
return;
|
||||
@@ -179,7 +174,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
|
||||
m_outstream->layout = *soundio_channel_layout_get_default(channels());
|
||||
m_outstream->format = SoundIoFormatFloat32NE;
|
||||
|
||||
if ((err = soundio_outstream_open(m_outstream)))
|
||||
if (int err = soundio_outstream_open(m_outstream))
|
||||
{
|
||||
fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(err));
|
||||
return;
|
||||
@@ -214,8 +209,6 @@ AudioSoundIo::~AudioSoundIo()
|
||||
|
||||
void AudioSoundIo::startProcessing()
|
||||
{
|
||||
int err;
|
||||
|
||||
m_outBufFrameIndex = 0;
|
||||
m_outBufFramesTotal = 0;
|
||||
m_outBufSize = audioEngine()->framesPerPeriod();
|
||||
@@ -224,7 +217,7 @@ void AudioSoundIo::startProcessing()
|
||||
|
||||
if (! m_outstreamStarted)
|
||||
{
|
||||
if ((err = soundio_outstream_start(m_outstream)))
|
||||
if (int err = soundio_outstream_start(m_outstream))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"AudioSoundIo::startProcessing() :: soundio unable to start stream: %s\n",
|
||||
@@ -236,7 +229,7 @@ void AudioSoundIo::startProcessing()
|
||||
|
||||
m_stopped = false;
|
||||
|
||||
if ((err = soundio_outstream_pause(m_outstream, false)))
|
||||
if (int err = soundio_outstream_pause(m_outstream, false))
|
||||
{
|
||||
m_stopped = true;
|
||||
fprintf(stderr,
|
||||
@@ -247,12 +240,10 @@ void AudioSoundIo::startProcessing()
|
||||
|
||||
void AudioSoundIo::stopProcessing()
|
||||
{
|
||||
int err;
|
||||
|
||||
m_stopped = true;
|
||||
if (m_outstream)
|
||||
{
|
||||
if ((err = soundio_outstream_pause(m_outstream, true)))
|
||||
if (int err = soundio_outstream_pause(m_outstream, true))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"AudioSoundIo::stopProcessing() :: pausing result error: %s\n",
|
||||
@@ -281,16 +272,14 @@ void AudioSoundIo::writeCallback(int frameCountMin, int frameCountMax)
|
||||
{
|
||||
if (m_stopped) {return;}
|
||||
const struct SoundIoChannelLayout *layout = &m_outstream->layout;
|
||||
SoundIoChannelArea *areas;
|
||||
SoundIoChannelArea* areas;
|
||||
int bytesPerSample = m_outstream->bytes_per_sample;
|
||||
int err;
|
||||
|
||||
int framesLeft = frameCountMax;
|
||||
|
||||
while (framesLeft > 0)
|
||||
{
|
||||
int frameCount = framesLeft;
|
||||
if ((err = soundio_outstream_begin_write(m_outstream, &areas, &frameCount)))
|
||||
if (int err = soundio_outstream_begin_write(m_outstream, &areas, &frameCount))
|
||||
{
|
||||
errorCallback(err);
|
||||
return;
|
||||
@@ -332,7 +321,7 @@ void AudioSoundIo::writeCallback(int frameCountMin, int frameCountMax)
|
||||
m_outBufFrameIndex += 1;
|
||||
}
|
||||
|
||||
if ((err = soundio_outstream_end_write(m_outstream)))
|
||||
if (int err = soundio_outstream_end_write(m_outstream))
|
||||
{
|
||||
errorCallback(err);
|
||||
return;
|
||||
@@ -372,11 +361,10 @@ void AudioSoundIo::setupWidget::reconnectSoundIo()
|
||||
|
||||
soundio_disconnect(m_soundio);
|
||||
|
||||
int err;
|
||||
int backend_index = m_backendModel.findText(configBackend);
|
||||
if (backend_index < 0)
|
||||
{
|
||||
if ((err = soundio_connect(m_soundio)))
|
||||
if (int err = soundio_connect(m_soundio))
|
||||
{
|
||||
fprintf(stderr, "soundio: unable to connect backend: %s\n", soundio_strerror(err));
|
||||
return;
|
||||
@@ -387,11 +375,11 @@ void AudioSoundIo::setupWidget::reconnectSoundIo()
|
||||
else
|
||||
{
|
||||
SoundIoBackend backend = soundio_get_backend(m_soundio, backend_index);
|
||||
if ((err = soundio_connect_backend(m_soundio, backend)))
|
||||
if (int err = soundio_connect_backend(m_soundio, backend))
|
||||
{
|
||||
fprintf(stderr, "soundio: unable to connect %s backend: %s\n",
|
||||
soundio_backend_name(backend), soundio_strerror(err));
|
||||
if ((err = soundio_connect(m_soundio)))
|
||||
if (int err = soundio_connect(m_soundio))
|
||||
{
|
||||
fprintf(stderr, "soundio: unable to connect backend: %s\n", soundio_strerror(err));
|
||||
return;
|
||||
|
||||
@@ -129,12 +129,11 @@ lv2_evbuf_next(LV2_Evbuf_Iterator iter)
|
||||
|
||||
LV2_Evbuf* evbuf = iter.evbuf;
|
||||
uint32_t offset = iter.offset;
|
||||
uint32_t size;
|
||||
size = ((LV2_Atom_Event*)
|
||||
((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &evbuf->buf.atom)
|
||||
+ offset))->body.size;
|
||||
offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size);
|
||||
|
||||
const auto contents = static_cast<char*>(LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &evbuf->buf.atom)) + offset;
|
||||
const uint32_t size = reinterpret_cast<LV2_Atom_Event*>(contents)->body.size;
|
||||
|
||||
offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size);
|
||||
LV2_Evbuf_Iterator next = { evbuf, offset };
|
||||
return next;
|
||||
}
|
||||
|
||||
@@ -425,12 +425,8 @@ void Lv2Proc::handleMidiInputEvent(const MidiEvent &event, const TimePos &time,
|
||||
|
||||
AutomatableModel *Lv2Proc::modelAtPort(const QString &uri)
|
||||
{
|
||||
// unused currently
|
||||
AutomatableModel *mod;
|
||||
auto itr = m_connectedModels.find(uri.toUtf8().data());
|
||||
if (itr != m_connectedModels.end()) { mod = itr->second; }
|
||||
else { mod = nullptr; }
|
||||
return mod;
|
||||
const auto itr = m_connectedModels.find(uri.toUtf8().data());
|
||||
return itr != m_connectedModels.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -906,19 +906,13 @@ int main( int argc, char * * argv )
|
||||
mb.setWindowIcon( embed::getIconPixmap( "icon_small" ) );
|
||||
mb.setWindowFlags( Qt::WindowCloseButtonHint );
|
||||
|
||||
QPushButton * recover;
|
||||
QPushButton * discard;
|
||||
QPushButton * exit;
|
||||
|
||||
// setting all buttons to the same roles allows us
|
||||
// to have a custom layout
|
||||
discard = mb.addButton( MainWindow::tr( "Discard" ),
|
||||
QMessageBox::AcceptRole );
|
||||
recover = mb.addButton( MainWindow::tr( "Recover" ),
|
||||
QMessageBox::AcceptRole );
|
||||
auto discard = mb.addButton(MainWindow::tr("Discard"), QMessageBox::AcceptRole);
|
||||
auto recover = mb.addButton(MainWindow::tr("Recover"), QMessageBox::AcceptRole);
|
||||
|
||||
// have a hidden exit button
|
||||
exit = mb.addButton( "", QMessageBox::RejectRole);
|
||||
auto exit = mb.addButton("", QMessageBox::RejectRole);
|
||||
exit->setVisible(false);
|
||||
|
||||
// set icons
|
||||
|
||||
@@ -39,10 +39,7 @@ MidiAlsaRaw::MidiAlsaRaw() :
|
||||
m_outputp( &m_output ),
|
||||
m_quit( false )
|
||||
{
|
||||
int err;
|
||||
if( ( err = snd_rawmidi_open( m_inputp, m_outputp,
|
||||
probeDevice().toLatin1().constData(),
|
||||
0 ) ) < 0 )
|
||||
if (int err = snd_rawmidi_open(m_inputp, m_outputp, probeDevice().toLatin1().constData(), 0); err < 0)
|
||||
{
|
||||
printf( "cannot open MIDI-device: %s\n", snd_strerror( err ) );
|
||||
return;
|
||||
@@ -111,29 +108,27 @@ void MidiAlsaRaw::run()
|
||||
{
|
||||
msleep( 5 ); // must do that, otherwise this thread takes
|
||||
// too much CPU-time, even with LowPriority...
|
||||
int err = poll( m_pfds, m_npfds, 10000 );
|
||||
if( err < 0 && errno == EINTR )
|
||||
if (int err = poll(m_pfds, m_npfds, 10000); err < 0 && errno == EINTR)
|
||||
{
|
||||
printf( "MidiAlsaRaw::run(): Got EINTR while "
|
||||
"polling. Will stop polling MIDI-events from "
|
||||
"MIDI-port.\n" );
|
||||
break;
|
||||
}
|
||||
if( err < 0 )
|
||||
else if (err < 0)
|
||||
{
|
||||
printf( "poll failed: %s\nWill stop polling "
|
||||
"MIDI-events from MIDI-port.\n",
|
||||
strerror( errno ) );
|
||||
break;
|
||||
}
|
||||
if( err == 0 )
|
||||
else if (err == 0)
|
||||
{
|
||||
//printf( "there seems to be no active MIDI-device %d\n", ++cnt );
|
||||
continue;
|
||||
}
|
||||
unsigned short revents;
|
||||
if( ( err = snd_rawmidi_poll_descriptors_revents(
|
||||
m_input, m_pfds, m_npfds, &revents ) ) < 0 )
|
||||
unsigned short revents = 0;
|
||||
if (int err = snd_rawmidi_poll_descriptors_revents(m_input, m_pfds, m_npfds, &revents); err < 0)
|
||||
{
|
||||
printf( "cannot get poll events: %s\nWill stop polling "
|
||||
"MIDI-events from MIDI-port.\n",
|
||||
@@ -149,25 +144,19 @@ void MidiAlsaRaw::run()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
err = snd_rawmidi_read(m_input, buf.data(), buf.size());
|
||||
if( err == -EAGAIN )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( err < 0 )
|
||||
|
||||
if (int err = snd_rawmidi_read(m_input, buf.data(), buf.size()); err == -EAGAIN) { continue; }
|
||||
else if (err < 0)
|
||||
{
|
||||
printf( "cannot read from port \"%s\": %s\nWill stop "
|
||||
"polling MIDI-events from MIDI-port.\n",
|
||||
/*port_name*/"default", snd_strerror( err ) );
|
||||
break;
|
||||
}
|
||||
if( err == 0 )
|
||||
else if (err == 0) { continue; }
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for( int i = 0; i < err; ++i )
|
||||
{
|
||||
parseData( buf[i] );
|
||||
for (int i = 0; i < err; ++i) { parseData(buf[i]); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,10 +78,7 @@ MidiAlsaSeq::MidiAlsaSeq() :
|
||||
m_quit( false ),
|
||||
m_portListUpdateTimer( this )
|
||||
{
|
||||
int err;
|
||||
if( ( err = snd_seq_open( &m_seqHandle,
|
||||
probeDevice().toLatin1().constData(),
|
||||
SND_SEQ_OPEN_DUPLEX, 0 ) ) < 0 )
|
||||
if (int err = snd_seq_open(&m_seqHandle, probeDevice().toLatin1().constData(), SND_SEQ_OPEN_DUPLEX, 0); err < 0)
|
||||
{
|
||||
fprintf( stderr, "cannot open sequencer: %s\n",
|
||||
snd_strerror( err ) );
|
||||
|
||||
@@ -74,11 +74,11 @@ void MidiController::updateName()
|
||||
|
||||
void MidiController::processInEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset)
|
||||
{
|
||||
unsigned char controllerNum;
|
||||
switch(event.type())
|
||||
{
|
||||
case MidiControlChange:
|
||||
controllerNum = event.controllerNumber();
|
||||
{
|
||||
unsigned char controllerNum = event.controllerNumber();
|
||||
|
||||
if (m_midiPort.inputController() == controllerNum &&
|
||||
(m_midiPort.inputChannel() == event.channel() + 1 || m_midiPort.inputChannel() == 0))
|
||||
@@ -89,7 +89,7 @@ void MidiController::processInEvent(const MidiEvent& event, const TimePos& time,
|
||||
emit valueChanged();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
// Don't care - maybe add special cases for pitch and mod later
|
||||
break;
|
||||
|
||||
@@ -179,7 +179,6 @@ QString MidiJack::probeDevice()
|
||||
// we read data from jack
|
||||
void MidiJack::JackMidiRead(jack_nframes_t nframes)
|
||||
{
|
||||
unsigned int i,b;
|
||||
void* port_buf = jack_port_get_buffer(m_input_port, nframes);
|
||||
jack_midi_event_t in_event;
|
||||
jack_nframes_t event_index = 0;
|
||||
@@ -188,13 +187,13 @@ void MidiJack::JackMidiRead(jack_nframes_t nframes)
|
||||
int rval = jack_midi_event_get(&in_event, port_buf, 0);
|
||||
if (rval == 0 /* 0 = success */)
|
||||
{
|
||||
for(i=0; i<nframes; i++)
|
||||
for (unsigned int i = 0; i < nframes; i++)
|
||||
{
|
||||
while((in_event.time == i) && (event_index < event_count))
|
||||
{
|
||||
// lmms is setup to parse bytes coming from a device
|
||||
// parse it byte by byte as it expects
|
||||
for(b=0;b<in_event.size;b++)
|
||||
for (unsigned int b = 0; b < in_event.size; b++)
|
||||
parseData( *(in_event.buffer + b) );
|
||||
|
||||
event_index++;
|
||||
|
||||
@@ -91,24 +91,21 @@ void MidiSndio::sendByte( const unsigned char c )
|
||||
void MidiSndio::run()
|
||||
{
|
||||
struct pollfd pfd;
|
||||
nfds_t nfds;
|
||||
char buf[0x100], *p;
|
||||
size_t n;
|
||||
int ret;
|
||||
char buf[0x100];
|
||||
while( m_quit == false && m_hdl )
|
||||
{
|
||||
nfds = mio_pollfd( m_hdl, &pfd, POLLIN );
|
||||
ret = poll( &pfd, nfds, 100 );
|
||||
nfds_t nfds = mio_pollfd(m_hdl, &pfd, POLLIN);
|
||||
int ret = poll(&pfd, nfds, 100);
|
||||
if ( ret < 0 )
|
||||
break;
|
||||
if ( !ret || !( mio_revents( m_hdl, &pfd ) & POLLIN ) )
|
||||
continue;
|
||||
n = mio_read( m_hdl, buf, sizeof(buf) );
|
||||
size_t n = mio_read(m_hdl, buf, sizeof(buf));
|
||||
if ( !n )
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (p = buf; n > 0; n--, p++)
|
||||
for (char* p = buf; n > 0; n--, p++)
|
||||
{
|
||||
parseData( *p );
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ ControlLayout::ControlLayout(QWidget *parent, int margin, int hSpacing, int vSpa
|
||||
|
||||
ControlLayout::~ControlLayout()
|
||||
{
|
||||
QLayoutItem *item;
|
||||
while ((item = takeAt(0))) { delete item; }
|
||||
while (auto item = takeAt(0)) { delete item; }
|
||||
}
|
||||
|
||||
void ControlLayout::onTextChanged(const QString&)
|
||||
|
||||
@@ -1108,8 +1108,7 @@ void MainWindow::updateViewMenu()
|
||||
// Here we should put all look&feel -stuff from configmanager
|
||||
// that is safe to change on the fly. There is probably some
|
||||
// more elegant way to do this.
|
||||
QAction *qa;
|
||||
qa = new QAction(tr( "Volume as dBFS" ), this);
|
||||
auto qa = new QAction(tr("Volume as dBFS"), this);
|
||||
qa->setData("displaydbfs");
|
||||
qa->setCheckable( true );
|
||||
qa->setChecked( ConfigManager::inst()->value( "app", "displaydbfs" ).toInt() );
|
||||
|
||||
@@ -108,10 +108,8 @@ void ProjectNotes::setText( const QString & _text )
|
||||
void ProjectNotes::setupActions()
|
||||
{
|
||||
QToolBar * tb = addToolBar( tr( "Edit Actions" ) );
|
||||
QAction * a;
|
||||
|
||||
a = new QAction( embed::getIconPixmap( "edit_undo" ), tr( "&Undo" ),
|
||||
this );
|
||||
auto a = new QAction(embed::getIconPixmap("edit_undo"), tr("&Undo"), this);
|
||||
a->setShortcut( tr( "%1+Z" ).arg(UI_CTRL_KEY) );
|
||||
connect( a, SIGNAL(triggered()), m_edit, SLOT(undo()));
|
||||
tb->addAction( a );
|
||||
|
||||
@@ -314,24 +314,17 @@ void AutomationClipView::paintEvent( QPaintEvent * )
|
||||
// the outValue of the current node). When we have nodes with linear or cubic progression
|
||||
// the value of the end of the shape between the two nodes will be the inValue of
|
||||
// the next node.
|
||||
float nextValue;
|
||||
if( m_clip->progressionType() == AutomationClip::ProgressionType::Discrete )
|
||||
{
|
||||
nextValue = OUTVAL(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextValue = INVAL(it + 1);
|
||||
}
|
||||
float nextValue = m_clip->progressionType() == AutomationClip::ProgressionType::Discrete
|
||||
? OUTVAL(it)
|
||||
: INVAL(it + 1);
|
||||
|
||||
QPainterPath path;
|
||||
QPointF origin = QPointF(POS(it) * ppTick, 0.0f);
|
||||
path.moveTo( origin );
|
||||
path.moveTo(QPointF(POS(it) * ppTick,values[0]));
|
||||
float x;
|
||||
for (int i = POS(it) + 1; i < POS(it + 1); i++)
|
||||
{
|
||||
x = i * ppTick;
|
||||
float x = i * ppTick;
|
||||
if( x > ( width() - BORDER_WIDTH ) ) break;
|
||||
float value = values[i - POS(it)];
|
||||
path.lineTo( QPointF( x, value ) );
|
||||
|
||||
@@ -320,8 +320,6 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 )
|
||||
auto deltay = qAbs<float>(y1 - y0);
|
||||
int x = x0;
|
||||
float y = y0;
|
||||
int xstep;
|
||||
int ystep;
|
||||
|
||||
if( deltax < AutomationClip::quantization() )
|
||||
{
|
||||
@@ -332,34 +330,14 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 )
|
||||
|
||||
float yscale = deltay / ( deltax );
|
||||
|
||||
if( x0 < x1 )
|
||||
{
|
||||
xstep = AutomationClip::quantization();
|
||||
}
|
||||
else
|
||||
{
|
||||
xstep = -( AutomationClip::quantization() );
|
||||
}
|
||||
int xstep = (x0 < x1 ? 1 : -1) * AutomationClip::quantization();
|
||||
int ystep = y0 < y1 ? 1 : -1;
|
||||
float lineAdjust = ystep * yscale;
|
||||
|
||||
float lineAdjust;
|
||||
if( y0 < y1 )
|
||||
{
|
||||
ystep = 1;
|
||||
lineAdjust = yscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
ystep = -1;
|
||||
lineAdjust = -( yscale );
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while( i < deltax )
|
||||
for (int i = 0; i < deltax; ++i)
|
||||
{
|
||||
y = y0 + ( ystep * yscale * i ) + lineAdjust;
|
||||
|
||||
x += xstep;
|
||||
i += 1;
|
||||
m_clip->removeNode(TimePos(x));
|
||||
m_clip->putValue( TimePos( x ), y );
|
||||
}
|
||||
@@ -979,7 +957,6 @@ inline void AutomationEditor::drawCross( QPainter & p )
|
||||
inline void AutomationEditor::drawAutomationPoint(QPainter & p, timeMap::iterator it)
|
||||
{
|
||||
int x = xCoordOfTick(POS(it));
|
||||
int y;
|
||||
// Below (m_ppb * AutomationClip::quantization() / 576) is used because:
|
||||
// 1 bar equals to 192/quantization() notes. Hence, to calculate the number of pixels
|
||||
// per note we would have (m_ppb * 1 bar / (192/quantization()) notes per bar), or
|
||||
@@ -988,7 +965,7 @@ inline void AutomationEditor::drawAutomationPoint(QPainter & p, timeMap::iterato
|
||||
const int outerRadius = qBound(3, (m_ppb * AutomationClip::quantization()) / 576, 5);
|
||||
|
||||
// Draw a circle for the outValue
|
||||
y = yCoordOfLevel(OUTVAL(it));
|
||||
int y = yCoordOfLevel(OUTVAL(it));
|
||||
p.setPen(QPen(m_nodeOutValueColor.lighter(200)));
|
||||
p.setBrush(QBrush(m_nodeOutValueColor));
|
||||
p.drawEllipse(x - outerRadius, y - outerRadius, outerRadius * 2, outerRadius * 2);
|
||||
@@ -1006,7 +983,6 @@ inline void AutomationEditor::drawAutomationPoint(QPainter & p, timeMap::iterato
|
||||
inline void AutomationEditor::drawAutomationTangents(QPainter& p, timeMap::iterator it)
|
||||
{
|
||||
int x = xCoordOfTick(POS(it));
|
||||
int y, tx, ty;
|
||||
|
||||
// The tangent value correlates the variation in the node value related to the increase
|
||||
// in ticks. So to have a proportionate drawing of the tangent line, we need to find the
|
||||
@@ -1020,9 +996,9 @@ inline void AutomationEditor::drawAutomationTangents(QPainter& p, timeMap::itera
|
||||
p.setPen(QPen(m_nodeTangentLineColor));
|
||||
p.setBrush(QBrush(m_nodeTangentLineColor));
|
||||
|
||||
y = yCoordOfLevel(INVAL(it));
|
||||
tx = x - 20;
|
||||
ty = y + 20 * INTAN(it) * proportion;
|
||||
int y = yCoordOfLevel(INVAL(it));
|
||||
int tx = x - 20;
|
||||
int ty = y + 20 * INTAN(it) * proportion;
|
||||
p.drawLine(x, y, tx, ty);
|
||||
p.setBrush(QBrush(m_nodeTangentLineColor.darker(200)));
|
||||
p.drawEllipse(tx - 3, ty - 3, 6, 6);
|
||||
@@ -1101,7 +1077,6 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
}
|
||||
else
|
||||
{
|
||||
int y;
|
||||
int level = (int) m_bottomLevel;
|
||||
int printable = qMax( 1, 5 * DEFAULT_Y_DELTA
|
||||
/ m_y_delta );
|
||||
@@ -1116,7 +1091,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
{
|
||||
const QString & label = m_clip->firstObject()
|
||||
->displayValue( level );
|
||||
y = yCoordOfLevel( level );
|
||||
int y = yCoordOfLevel(level);
|
||||
p.setPen( QApplication::palette().color( QPalette::Active,
|
||||
QPalette::Shadow ) );
|
||||
p.drawText( 1, y - font_height + 1,
|
||||
@@ -1139,7 +1114,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
|
||||
if( m_clip )
|
||||
{
|
||||
int tick, x, q;
|
||||
int q;
|
||||
int x_line_end = (int)( m_y_auto || m_topLevel < m_maxLevel ?
|
||||
TOP_MARGIN :
|
||||
grid_bottom - ( m_topLevel - m_bottomLevel ) * m_y_delta );
|
||||
@@ -1163,10 +1138,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
// 3 independent loops, because quantization might not divide evenly into
|
||||
// exotic denominators (e.g. 7/11 time), which are allowed ATM.
|
||||
// First quantization grid...
|
||||
for( tick = m_currentPosition - m_currentPosition % q,
|
||||
x = xCoordOfTick( tick );
|
||||
x<=width();
|
||||
tick += q, x = xCoordOfTick( tick ) )
|
||||
for (int tick = m_currentPosition - m_currentPosition % q, x = xCoordOfTick(tick); x <= width();
|
||||
tick += q, x = xCoordOfTick(tick))
|
||||
{
|
||||
p.setPen(m_lineColor);
|
||||
p.drawLine( x, grid_bottom, x, x_line_end );
|
||||
@@ -1187,10 +1160,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
}
|
||||
else
|
||||
{
|
||||
float y;
|
||||
for( int level = (int)m_bottomLevel; level <= m_topLevel; level++)
|
||||
{
|
||||
y = yCoordOfLevel( (float)level );
|
||||
float y = yCoordOfLevel(static_cast<float>(level));
|
||||
|
||||
p.setPen(level % 10 == 0 ? m_beatLineColor : m_lineColor);
|
||||
|
||||
@@ -1226,10 +1198,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
int ticksPerBeat = DefaultTicksPerBar /
|
||||
Engine::getSong()->getTimeSigModel().getDenominator();
|
||||
|
||||
for( tick = m_currentPosition - m_currentPosition % ticksPerBeat,
|
||||
x = xCoordOfTick( tick );
|
||||
x<=width();
|
||||
tick += ticksPerBeat, x = xCoordOfTick( tick ) )
|
||||
for (int tick = m_currentPosition - m_currentPosition % ticksPerBeat, x = xCoordOfTick(tick); x <= width();
|
||||
tick += ticksPerBeat, x = xCoordOfTick(tick))
|
||||
{
|
||||
p.setPen(m_beatLineColor);
|
||||
p.drawLine( x, grid_bottom, x, x_line_end );
|
||||
@@ -1316,10 +1286,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
}
|
||||
|
||||
// and finally bars
|
||||
for( tick = m_currentPosition - m_currentPosition % TimePos::ticksPerBar(),
|
||||
x = xCoordOfTick( tick );
|
||||
x<=width();
|
||||
tick += TimePos::ticksPerBar(), x = xCoordOfTick( tick ) )
|
||||
for (int tick = m_currentPosition - m_currentPosition % TimePos::ticksPerBar(), x = xCoordOfTick(tick);
|
||||
x <= width(); tick += TimePos::ticksPerBar(), x = xCoordOfTick(tick))
|
||||
{
|
||||
p.setPen(m_barLineColor);
|
||||
p.drawLine( x, grid_bottom, x, x_line_end );
|
||||
@@ -1365,15 +1333,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
|
||||
// the outValue of the current node). When we have nodes with linear or cubic progression
|
||||
// the value of the end of the shape between the two nodes will be the inValue of
|
||||
// the next node.
|
||||
float nextValue;
|
||||
if( m_clip->progressionType() == AutomationClip::ProgressionType::Discrete )
|
||||
{
|
||||
nextValue = OUTVAL(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextValue = INVAL(it + 1);
|
||||
}
|
||||
float nextValue = m_clip->progressionType() == AutomationClip::ProgressionType::Discrete
|
||||
? OUTVAL(it)
|
||||
: INVAL(it + 1);
|
||||
|
||||
p.setRenderHints( QPainter::Antialiasing, true );
|
||||
QPainterPath path;
|
||||
@@ -1523,25 +1485,11 @@ void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value)
|
||||
|| ( value > m_topLevel && m_topLevel >= 0 )
|
||||
|| ( value < m_bottomLevel && m_bottomLevel <= 0 ) )
|
||||
{
|
||||
int y_start = yCoordOfLevel( value );
|
||||
int rect_height;
|
||||
|
||||
if( m_y_auto )
|
||||
{
|
||||
int y_end = (int)( grid_bottom
|
||||
+ ( grid_bottom - TOP_MARGIN )
|
||||
* m_minLevel
|
||||
/ ( m_maxLevel - m_minLevel ) );
|
||||
|
||||
rect_height = y_end - y_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_height = (int)( value * m_y_delta );
|
||||
}
|
||||
const int y_start = yCoordOfLevel(value);
|
||||
const int y_end = grid_bottom + (grid_bottom - TOP_MARGIN) * m_minLevel / (m_maxLevel - m_minLevel);
|
||||
const int rect_height = m_y_auto ? y_end - y_start : value * m_y_delta;
|
||||
|
||||
QBrush currentColor = m_graphColor;
|
||||
|
||||
p.fillRect( x, y_start, rect_width, rect_height, currentColor );
|
||||
}
|
||||
#ifdef LMMS_DEBUG
|
||||
|
||||
@@ -3030,10 +3030,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
|
||||
|
||||
if (hasValidMidiClip())
|
||||
{
|
||||
int pianoAreaHeight, partialKeyVisible, topKey, topNote;
|
||||
pianoAreaHeight = keyAreaBottom() - keyAreaTop();
|
||||
m_pianoKeysVisible = pianoAreaHeight / m_keyLineHeight;
|
||||
partialKeyVisible = pianoAreaHeight % m_keyLineHeight;
|
||||
int pianoAreaHeight = keyAreaBottom() - keyAreaTop();
|
||||
int m_pianoKeysVisible = pianoAreaHeight / m_keyLineHeight;
|
||||
int partialKeyVisible = pianoAreaHeight % m_keyLineHeight;
|
||||
// check if we're below the minimum key area size
|
||||
if (m_pianoKeysVisible * m_keyLineHeight < KEY_AREA_MIN_HEIGHT)
|
||||
{
|
||||
@@ -3058,8 +3057,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
|
||||
PR_TOP_MARGIN - PR_BOTTOM_MARGIN;
|
||||
partialKeyVisible = 0;
|
||||
}
|
||||
topKey = qBound(0, m_startKey + m_pianoKeysVisible - 1, NumKeys - 1);
|
||||
topNote = topKey % KeysPerOctave;
|
||||
int topKey = std::clamp(m_startKey + m_pianoKeysVisible - 1, 0, NumKeys - 1);
|
||||
int topNote = topKey % KeysPerOctave;
|
||||
// if not resizing the note edit area, we can change m_notesEditHeight
|
||||
if (m_action != Action::ResizeNoteEditArea && partialKeyVisible != 0)
|
||||
{
|
||||
|
||||
@@ -774,17 +774,9 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth
|
||||
|
||||
void SongEditor::updatePosition( const TimePos & t )
|
||||
{
|
||||
int widgetWidth, trackOpWidth;
|
||||
if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() )
|
||||
{
|
||||
widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT;
|
||||
trackOpWidth = TRACK_OP_WIDTH_COMPACT;
|
||||
}
|
||||
else
|
||||
{
|
||||
widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH;
|
||||
trackOpWidth = TRACK_OP_WIDTH;
|
||||
}
|
||||
const bool compactTrackButtons = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt();
|
||||
const auto widgetWidth = compactTrackButtons ? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT : DEFAULT_SETTINGS_WIDGET_WIDTH;
|
||||
const auto trackOpWidth = compactTrackButtons ? TRACK_OP_WIDTH_COMPACT : TRACK_OP_WIDTH;
|
||||
|
||||
if( ( m_song->isPlaying() && m_song->m_playMode == Song::PlayMode::Song
|
||||
&& m_timeLine->autoScroll() == TimeLineWidget::AutoScrollState::Enabled) ||
|
||||
|
||||
@@ -299,9 +299,8 @@ void ControllerConnectionDialog::selectController()
|
||||
{
|
||||
if( m_midiControllerSpinBox->model()->value() > 0 )
|
||||
{
|
||||
MidiController * mc;
|
||||
mc = m_midiController->copyToMidiController( Engine::getSong() );
|
||||
|
||||
auto mc = m_midiController->copyToMidiController(Engine::getSong());
|
||||
|
||||
/*
|
||||
if( m_targetModel->getTrack() &&
|
||||
!m_targetModel->getTrack()->displayName().isEmpty() )
|
||||
|
||||
@@ -199,15 +199,13 @@ void Fader::mousePressEvent( QMouseEvent* mouseEvent )
|
||||
void Fader::mouseDoubleClickEvent( QMouseEvent* mouseEvent )
|
||||
{
|
||||
bool ok;
|
||||
float newValue;
|
||||
// TODO: dbV handling
|
||||
newValue = QInputDialog::getDouble( this, tr( "Set value" ),
|
||||
tr( "Please enter a new value between %1 and %2:" ).
|
||||
arg( model()->minValue() * m_conversionFactor ).
|
||||
arg( model()->maxValue() * m_conversionFactor ),
|
||||
model()->getRoundedValue() * m_conversionFactor,
|
||||
model()->minValue() * m_conversionFactor,
|
||||
model()->maxValue() * m_conversionFactor, model()->getDigitCount(), &ok ) / m_conversionFactor;
|
||||
auto minv = model()->minValue() * m_conversionFactor;
|
||||
auto maxv = model()->maxValue() * m_conversionFactor;
|
||||
float newValue = QInputDialog::getDouble(this, tr("Set value"),
|
||||
tr("Please enter a new value between %1 and %2:").arg(minv).arg(maxv),
|
||||
model()->getRoundedValue() * m_conversionFactor, minv, maxv, model()->getDigitCount(), &ok)
|
||||
/ m_conversionFactor;
|
||||
|
||||
if( ok )
|
||||
{
|
||||
|
||||
@@ -643,11 +643,10 @@ void graphModel::convolve(const float *convolution,
|
||||
// store values in temporary array
|
||||
QVector<float> temp = m_samples;
|
||||
const int graphLength = length();
|
||||
float sum;
|
||||
// make a cyclic convolution
|
||||
for ( int i = 0; i < graphLength; i++ )
|
||||
{
|
||||
sum = 0;
|
||||
float sum = 0.0f;
|
||||
for ( int j = 0; j < convolutionLength; j++ )
|
||||
{
|
||||
sum += convolution[j] * temp[( i + j ) % graphLength];
|
||||
|
||||
@@ -91,24 +91,25 @@ void TimeDisplayWidget::updateTime()
|
||||
switch( m_displayMode )
|
||||
{
|
||||
case DisplayMode::MinutesSeconds:
|
||||
int msec;
|
||||
msec = s->getMilliseconds();
|
||||
{
|
||||
int msec = s->getMilliseconds();
|
||||
m_majorLCD.setValue(msec / 60000);
|
||||
m_minorLCD.setValue((msec / 1000) % 60);
|
||||
m_milliSecondsLCD.setValue(msec % 1000);
|
||||
break;
|
||||
|
||||
}
|
||||
case DisplayMode::BarsTicks:
|
||||
int tick;
|
||||
tick = s->getPlayPos().getTicks();
|
||||
{
|
||||
int tick = s->getPlayPos().getTicks();
|
||||
m_majorLCD.setValue((int)(tick / s->ticksPerBar()) + 1);
|
||||
m_minorLCD.setValue((tick % s->ticksPerBar()) /
|
||||
(s->ticksPerBar() / s->getTimeSigModel().getNumerator() ) +1);
|
||||
m_milliSecondsLCD.setValue((tick % s->ticksPerBar()) %
|
||||
(s->ticksPerBar() / s->getTimeSigModel().getNumerator()));
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -772,17 +772,17 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames,
|
||||
}
|
||||
}
|
||||
|
||||
Note * cur_note;
|
||||
while( nit != notes.end() &&
|
||||
( cur_note = *nit )->pos() == cur_start )
|
||||
while (nit != notes.end() && (*nit)->pos() == cur_start)
|
||||
{
|
||||
const auto currentNote = *nit;
|
||||
|
||||
// If the note is a Step Note, frames will be 0 so the NotePlayHandle
|
||||
// plays for the whole length of the sample
|
||||
const auto note_frames = cur_note->type() == Note::Type::Step
|
||||
const auto noteFrames = currentNote->type() == Note::Type::Step
|
||||
? 0
|
||||
: cur_note->length().frames(frames_per_tick);
|
||||
: currentNote->length().frames(frames_per_tick);
|
||||
|
||||
NotePlayHandle* notePlayHandle = NotePlayHandleManager::acquire( this, _offset, note_frames, *cur_note );
|
||||
NotePlayHandle* notePlayHandle = NotePlayHandleManager::acquire(this, _offset, noteFrames, *currentNote);
|
||||
notePlayHandle->setPatternTrack(pattern_track);
|
||||
// are we playing global song?
|
||||
if( _clip_num < 0 )
|
||||
|
||||
Reference in New Issue
Block a user