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:
@@ -354,32 +354,21 @@ void AudioFileProcessorWaveView::zoom(const bool out)
|
||||
const double comp_ratio = double(qMin(d_from, d_to))
|
||||
/ qMax(1, qMax(d_from, d_to));
|
||||
|
||||
f_cnt_t new_from;
|
||||
f_cnt_t new_to;
|
||||
const auto boundedFrom = std::clamp(m_from + step_from, 0, start);
|
||||
const auto boundedTo = std::clamp(m_to + step_to, end, frames);
|
||||
|
||||
if ((out && d_from < d_to) || (! out && d_to < d_from))
|
||||
{
|
||||
new_from = qBound(0, m_from + step_from, start);
|
||||
new_to = qBound(
|
||||
end,
|
||||
m_to + f_cnt_t(step_to * (new_from == m_from ? 1 : comp_ratio)),
|
||||
frames
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_to = qBound(end, m_to + step_to, frames);
|
||||
new_from = qBound(
|
||||
0,
|
||||
m_from + f_cnt_t(step_from * (new_to == m_to ? 1 : comp_ratio)),
|
||||
start
|
||||
);
|
||||
}
|
||||
const auto toStep = static_cast<f_cnt_t>(step_from * (boundedTo == m_to ? 1 : comp_ratio));
|
||||
const auto newFrom
|
||||
= (out && d_from < d_to) || (!out && d_to < d_from) ? boundedFrom : std::clamp(m_from + toStep, 0, start);
|
||||
|
||||
if (static_cast<double>(new_to - new_from) / m_sample->sampleRate() > 0.05)
|
||||
const auto fromStep = static_cast<f_cnt_t>(step_to * (boundedFrom == m_from ? 1 : comp_ratio));
|
||||
const auto newTo
|
||||
= (out && d_from < d_to) || (!out && d_to < d_from) ? std::clamp(m_to + fromStep, end, frames) : boundedTo;
|
||||
|
||||
if (static_cast<double>(newTo - newFrom) / m_sample->sampleRate() > 0.05)
|
||||
{
|
||||
setFrom(new_from);
|
||||
setTo(new_to);
|
||||
setFrom(newFrom);
|
||||
setTo(newTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,34 +110,18 @@ sample_t BSynth::nextStringSample( float sample_length )
|
||||
sample_realindex -= sample_length;
|
||||
}
|
||||
|
||||
sample_t sample;
|
||||
|
||||
if (interpolation) {
|
||||
|
||||
// find position in shape
|
||||
int a = static_cast<int>(sample_realindex);
|
||||
int b;
|
||||
if (a < (sample_length-1)) {
|
||||
b = static_cast<int>(sample_realindex+1);
|
||||
} else {
|
||||
b = 0;
|
||||
}
|
||||
|
||||
// Nachkommaanteil
|
||||
const float frac = fraction( sample_realindex );
|
||||
|
||||
sample = linearInterpolate( sample_shape[a], sample_shape[b], frac );
|
||||
|
||||
} else {
|
||||
// No interpolation
|
||||
sample_index = static_cast<int>(sample_realindex);
|
||||
sample = sample_shape[sample_index];
|
||||
}
|
||||
|
||||
// progress in shape
|
||||
const auto currentRealIndex = sample_realindex;
|
||||
const auto currentIndex = static_cast<int>(sample_realindex);
|
||||
sample_realindex += sample_step;
|
||||
|
||||
return sample;
|
||||
if (!interpolation)
|
||||
{
|
||||
sample_index = currentIndex;
|
||||
return sample_shape[sample_index];
|
||||
}
|
||||
|
||||
const auto nextIndex = currentIndex < sample_length - 1 ? currentIndex + 1 : 0;
|
||||
return linearInterpolate(sample_shape[currentIndex], sample_shape[nextIndex], fraction(currentRealIndex));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -276,16 +260,7 @@ void BitInvader::playNote( NotePlayHandle * _n,
|
||||
{
|
||||
if (!_n->m_pluginData)
|
||||
{
|
||||
float factor;
|
||||
if( !m_normalize.value() )
|
||||
{
|
||||
factor = defaultNormalizationFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = m_normalizeFactor;
|
||||
}
|
||||
|
||||
float factor = !m_normalize.value() ? defaultNormalizationFactor : m_normalizeFactor;
|
||||
_n->m_pluginData = new BSynth(
|
||||
const_cast<float*>( m_graph.samples() ),
|
||||
_n,
|
||||
|
||||
@@ -1116,16 +1116,15 @@ void CarlaParamsView::clearKnobs()
|
||||
}
|
||||
|
||||
// Remove spacers
|
||||
QLayoutItem* item;
|
||||
for (int16_t i=m_inputScrollAreaLayout->count() - 1; i > 0; i--)
|
||||
{
|
||||
item = m_inputScrollAreaLayout->takeAt(i);
|
||||
auto item = m_inputScrollAreaLayout->takeAt(i);
|
||||
if (item->widget()) {continue;}
|
||||
delete item;
|
||||
}
|
||||
for (int16_t i=m_outputScrollAreaLayout->count() - 1; i > 0; i--)
|
||||
{
|
||||
item = m_outputScrollAreaLayout->takeAt(i);
|
||||
auto item = m_outputScrollAreaLayout->takeAt(i);
|
||||
if (item->widget()) {continue;}
|
||||
delete item;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
{
|
||||
m_outGain = dbfsToAmp( m_delayControls.m_outGainModel.value() );
|
||||
}
|
||||
int sampleLength;
|
||||
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
dryS[0] = buf[f][0];
|
||||
@@ -123,8 +123,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
|
||||
m_delay->setFeedback( *feedbackPtr );
|
||||
m_lfo->setFrequency( *lfoTimePtr );
|
||||
sampleLength = *lengthPtr * Engine::audioEngine()->processingSampleRate();
|
||||
m_currentLength = sampleLength;
|
||||
m_currentLength = static_cast<int>(*lengthPtr * Engine::audioEngine()->processingSampleRate());
|
||||
m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) );
|
||||
m_delay->tick( buf[f] );
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
int i = 0;
|
||||
|
||||
auto sm_peak = std::array{0.0f, 0.0f};
|
||||
float gain;
|
||||
|
||||
double out_sum = 0.0;
|
||||
const float d = dryLevel();
|
||||
@@ -196,20 +195,10 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
|
||||
if( sm_peak[i] > DYN_NOISE_FLOOR )
|
||||
{
|
||||
if ( lookup < 1 )
|
||||
{
|
||||
gain = frac * samples[0];
|
||||
}
|
||||
else
|
||||
if ( lookup < 200 )
|
||||
{
|
||||
gain = linearInterpolate( samples[ lookup - 1 ],
|
||||
samples[ lookup ], frac );
|
||||
}
|
||||
else
|
||||
{
|
||||
gain = samples[199];
|
||||
};
|
||||
float gain;
|
||||
if (lookup < 1) { gain = frac * samples[0]; }
|
||||
else if (lookup < 200) { gain = linearInterpolate(samples[lookup - 1], samples[lookup], frac); }
|
||||
else { gain = samples[199]; }
|
||||
|
||||
s[i] *= gain;
|
||||
s[i] /= sm_peak[i];
|
||||
|
||||
@@ -208,15 +208,14 @@ float EqHandle::getPeakCurve( float x )
|
||||
double Q = getResonance();
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) / 40 );
|
||||
double alpha = s * sinh( log( 2 ) / 2 * Q * w0 / sinf( w0 ) );
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = 1 + alpha * A;
|
||||
b1 = -2 * c;
|
||||
b2 = 1 - alpha * A;
|
||||
a0 = 1 + alpha / A;
|
||||
a1 = -2 * c;
|
||||
a2 = 1 - alpha / A;
|
||||
double b0 = 1 + alpha * A;
|
||||
double b1 = -2 * c;
|
||||
double b2 = 1 - alpha * A;
|
||||
double a0 = 1 + alpha / A;
|
||||
double a1 = -2 * c;
|
||||
double a2 = 1 - alpha / A;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -245,15 +244,15 @@ float EqHandle::getHighShelfCurve( float x )
|
||||
double s = sinf( w0 );
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) * 0.025 );
|
||||
double beta = sqrt( A ) / m_resonance;
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A * ( ( A + 1 ) + ( A - 1 ) * c + beta * s);
|
||||
b1 = -2 * A * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
b2 = A * ( ( A + 1 ) + ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) - ( A - 1 ) * c + beta * s;
|
||||
a1 = 2 * ( ( A - 1 ) - ( A + 1 ) * c );
|
||||
a2 = ( A + 1 ) - ( A - 1 ) * c - beta * s;
|
||||
double b0 = A * ((A + 1) + (A - 1) * c + beta * s);
|
||||
double b1 = -2 * A * ((A - 1) + (A + 1) * c);
|
||||
double b2 = A * ((A + 1) + (A - 1) * c - beta * s);
|
||||
double a0 = (A + 1) - (A - 1) * c + beta * s;
|
||||
double a1 = 2 * ((A - 1) - (A + 1) * c);
|
||||
double a2 = (A + 1) - (A - 1) * c - beta * s;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
@@ -281,15 +280,14 @@ float EqHandle::getLowShelfCurve( float x )
|
||||
double s = sinf( w0 );
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) / 40 );
|
||||
double beta = sqrt( A ) / m_resonance;
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A * ( ( A + 1 ) - ( A - 1 ) * c + beta * s );
|
||||
b1 = 2 * A * ( ( A - 1 ) - ( A + 1 ) * c ) ;
|
||||
b2 = A * ( ( A + 1 ) - ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) + ( A - 1 ) * c + beta * s;
|
||||
a1 = -2 * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
a2 = ( A + 1 ) + ( A - 1) * c - beta * s;
|
||||
double b0 = A * ((A + 1) - (A - 1) * c + beta * s);
|
||||
double b1 = 2 * A * ((A - 1) - (A + 1) * c);
|
||||
double b2 = A * ((A + 1) - (A - 1) * c - beta * s);
|
||||
double a0 = (A + 1) + (A - 1) * c + beta * s;
|
||||
double a1 = -2 * ((A - 1) + (A + 1) * c);
|
||||
double a2 = (A + 1) + (A - 1) * c - beta * s;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -318,14 +316,14 @@ float EqHandle::getLowCutCurve( float x )
|
||||
double s = sinf( w0 );
|
||||
double resonance = getResonance();
|
||||
double alpha = s / (2 * resonance);
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
b0 = ( 1 + c ) * 0.5;
|
||||
b1 = ( -( 1 + c ) );
|
||||
b2 = ( 1 + c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = ( -2 * c );
|
||||
a2 = 1 - alpha;
|
||||
double b0 = (1 + c) * 0.5;
|
||||
double b1 = (-(1 + c));
|
||||
double b2 = (1 + c) * 0.5;
|
||||
double a0 = 1 + alpha;
|
||||
double a1 = (-2 * c);
|
||||
double a2 = 1 - alpha;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
@@ -361,14 +359,14 @@ float EqHandle::getHighCutCurve( float x )
|
||||
double s = sinf( w0 );
|
||||
double resonance = getResonance();
|
||||
double alpha = s / (2 * resonance);
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
b0 = ( 1 - c ) * 0.5;
|
||||
b1 = 1 - c;
|
||||
b2 = ( 1 - c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = -2 * c;
|
||||
a2 = 1 - alpha;
|
||||
double b0 = (1 - c) * 0.5;
|
||||
double b1 = 1 - c;
|
||||
double b2 = (1 - c) * 0.5;
|
||||
double a0 = 1 + alpha;
|
||||
double a1 = -2 * c;
|
||||
double a2 = 1 - alpha;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
@@ -569,16 +567,7 @@ void EqHandle::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
|
||||
|
||||
void EqHandle::wheelEvent( QGraphicsSceneWheelEvent *wevent )
|
||||
{
|
||||
float highestBandwich;
|
||||
if( m_type != EqHandleType::Para )
|
||||
{
|
||||
highestBandwich = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
highestBandwich = 4;
|
||||
}
|
||||
|
||||
float highestBandwich = m_type != EqHandleType::Para ? 10 : 4;
|
||||
int numDegrees = wevent->delta() / 120;
|
||||
float numSteps = 0;
|
||||
if( wevent->modifiers() == Qt::ControlModifier )
|
||||
|
||||
@@ -190,15 +190,13 @@ public :
|
||||
float s = sinf( w0 );
|
||||
float alpha = s / ( 2 * m_res );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = ( 1 + c ) * 0.5;
|
||||
b1 = ( -( 1 + c ) );
|
||||
b2 = ( 1 + c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = ( -2 * c );
|
||||
a2 = 1 - alpha;
|
||||
float b0 = (1 + c) * 0.5;
|
||||
float b1 = (-(1 + c));
|
||||
float b2 = (1 + c) * 0.5;
|
||||
float a0 = 1 + alpha;
|
||||
float a1 = (-2 * c);
|
||||
float a2 = 1 - alpha;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -235,15 +233,13 @@ public :
|
||||
float s = sinf( w0 );
|
||||
float alpha = s / ( 2 * m_res );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = ( 1 - c ) * 0.5;
|
||||
b1 = 1 - c;
|
||||
b2 = ( 1 - c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = -2 * c;
|
||||
a2 = 1 - alpha;
|
||||
float b0 = (1 - c) * 0.5;
|
||||
float b1 = 1 - c;
|
||||
float b2 = (1 - c) * 0.5;
|
||||
float a0 = 1 + alpha;
|
||||
float a1 = -2 * c;
|
||||
float a2 = 1 - alpha;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -279,15 +275,13 @@ public:
|
||||
float A = pow( 10, m_gain * 0.025);
|
||||
float alpha = s * sinh( log( 2 ) / 2 * m_bw * w0 / sinf(w0) );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = 1 + alpha*A;
|
||||
b1 = -2*c;
|
||||
b2 = 1 - alpha*A;
|
||||
a0 = 1 + alpha/A;
|
||||
a1 = -2*c;
|
||||
a2 = 1 - alpha/A;
|
||||
float b0 = 1 + alpha * A;
|
||||
float b1 = -2 * c;
|
||||
float b2 = 1 - alpha * A;
|
||||
float a0 = 1 + alpha / A;
|
||||
float a1 = -2 * c;
|
||||
float a2 = 1 - alpha / A;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -345,15 +339,13 @@ public :
|
||||
// float alpha = s / ( 2 * m_res );
|
||||
float beta = sqrt( A ) / m_res;
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A * ( ( A+1 ) - ( A-1 ) * c + beta * s );
|
||||
b1 = 2 * A * ( ( A - 1 ) - ( A + 1 ) * c) ;
|
||||
b2 = A * ( ( A + 1 ) - ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) + ( A - 1 ) * c + beta * s;
|
||||
a1 = -2 * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
a2 = ( A + 1 ) + ( A - 1) * c - beta * s;
|
||||
float b0 = A * ((A + 1) - (A - 1) * c + beta * s);
|
||||
float b1 = 2 * A * ((A - 1) - (A + 1) * c);
|
||||
float b2 = A * ((A + 1) - (A - 1) * c - beta * s);
|
||||
float a0 = (A + 1) + (A - 1) * c + beta * s;
|
||||
float a1 = -2 * ((A - 1) + (A + 1) * c);
|
||||
float a2 = (A + 1) + (A - 1) * c - beta * s;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
@@ -383,15 +375,14 @@ public :
|
||||
float A = pow( 10, m_gain * 0.025 );
|
||||
float beta = sqrt( A ) / m_res;
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A *( ( A +1 ) + ( A - 1 ) * c + beta * s);
|
||||
b1 = -2 * A * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
b2 = A * ( ( A + 1 ) + ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) - ( A - 1 ) * c + beta * s;
|
||||
a1 = 2 * ( ( A - 1 ) - ( A + 1 ) * c );
|
||||
a2 = ( A + 1) - ( A - 1 ) * c - beta * s;
|
||||
float b0 = A * ((A + 1) + (A - 1) * c + beta * s);
|
||||
float b1 = -2 * A * ((A - 1) + (A + 1) * c);
|
||||
float b2 = A * ((A + 1) + (A - 1) * c - beta * s);
|
||||
float a0 = (A + 1) - (A - 1) * c + beta * s;
|
||||
float a1 = 2 * ((A - 1) - (A + 1) * c);
|
||||
float a2 = (A + 1) - (A - 1) * c - beta * s;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
|
||||
@@ -228,13 +228,12 @@ void EqSpectrumView::paintEvent(QPaintEvent *event)
|
||||
//Now we calculate the path
|
||||
m_path = QPainterPath();
|
||||
float *bands = m_analyser->m_bands;
|
||||
float peak;
|
||||
m_path.moveTo( 0, height() );
|
||||
m_peakSum = 0;
|
||||
const float fallOff = 1.07;
|
||||
for( int x = 0; x < MAX_BANDS; ++x, ++bands )
|
||||
{
|
||||
peak = *bands != 0. ? (fh * 2.0 / 3.0 * (20. * log10(*bands / energy) - LOWER_Y) / (-LOWER_Y)) : 0.;
|
||||
float peak = *bands != 0. ? (fh * 2.0 / 3.0 * (20. * log10(*bands / energy) - LOWER_Y) / (-LOWER_Y)) : 0.;
|
||||
|
||||
if( peak < 0 )
|
||||
{
|
||||
|
||||
@@ -108,10 +108,11 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
|
||||
m_lDelay->setFeedback( m_flangerControls.m_feedbackModel.value() );
|
||||
m_rDelay->setFeedback( m_flangerControls.m_feedbackModel.value() );
|
||||
auto dryS = std::array<sample_t, 2>{};
|
||||
float leftLfo;
|
||||
float rightLfo;
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
float leftLfo;
|
||||
float rightLfo;
|
||||
|
||||
buf[f][0] += m_noise->tick() * noise;
|
||||
buf[f][1] += m_noise->tick() * noise;
|
||||
dryS[0] = buf[f][0];
|
||||
|
||||
Submodule plugins/FreeBoy/game-music-emu updated: 6b676192d9...21a064ea66
@@ -88,17 +88,9 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl )
|
||||
int col = 0;
|
||||
BufferDataType last_port = BufferDataType::None;
|
||||
|
||||
QGroupBox * grouper;
|
||||
if( _ctl->m_processors > 1 )
|
||||
{
|
||||
grouper = new QGroupBox( tr( "Channel " ) +
|
||||
QString::number( proc + 1 ),
|
||||
this );
|
||||
}
|
||||
else
|
||||
{
|
||||
grouper = new QGroupBox( this );
|
||||
}
|
||||
auto grouper = _ctl->m_processors > 1
|
||||
? new QGroupBox(tr("Channel ") + QString::number(proc + 1), this)
|
||||
: new QGroupBox(this);
|
||||
|
||||
auto gl = new QGridLayout(grouper);
|
||||
grouper->setLayout( gl );
|
||||
|
||||
@@ -166,12 +166,10 @@ void Lb302FilterIIR2::recalc()
|
||||
|
||||
void Lb302FilterIIR2::envRecalc()
|
||||
{
|
||||
float k, w;
|
||||
|
||||
Lb302Filter::envRecalc();
|
||||
|
||||
w = vcf_e0 + vcf_c0; // e0 is adjusted for Hz and doesn't need ENVINC
|
||||
k = exp(-w/vcf_rescoeff); // Does this mean c0 is inheritantly?
|
||||
float w = vcf_e0 + vcf_c0; // e0 is adjusted for Hz and doesn't need ENVINC
|
||||
float k = exp(-w/vcf_rescoeff); // Does this mean c0 is inheritantly?
|
||||
|
||||
vcf_a = 2.0*cos(2.0*w) * k;
|
||||
vcf_b = -k*k;
|
||||
@@ -219,18 +217,15 @@ void Lb302Filter3Pole::recalc()
|
||||
// TODO: Try using k instead of vcf_reso
|
||||
void Lb302Filter3Pole::envRecalc()
|
||||
{
|
||||
float w,k;
|
||||
float kfco;
|
||||
|
||||
Lb302Filter::envRecalc();
|
||||
|
||||
// e0 is adjusted for Hz and doesn't need ENVINC
|
||||
w = vcf_e0 + vcf_c0;
|
||||
k = (fs->cutoff > 0.975)?0.975:fs->cutoff;
|
||||
float w = vcf_e0 + vcf_c0;
|
||||
float k = (fs->cutoff > 0.975)?0.975:fs->cutoff;
|
||||
// sampleRateCutoff should not be changed to anything dynamic that is outside the
|
||||
// scope of LB302 (like e.g. the audio engine's sample rate) as this changes the filter's cutoff
|
||||
// behavior without any modification to its controls.
|
||||
kfco = 50.f + (k)*((2300.f-1600.f*(fs->envmod))+(w) *
|
||||
float kfco = 50.f + (k)*((2300.f-1600.f*(fs->envmod))+(w) *
|
||||
(700.f+1500.f*(k)+(1500.f+(k)*(sampleRateCutoff/2.f-6000.f)) *
|
||||
(fs->envmod)) );
|
||||
//+iacc*(.3+.7*kfco*kenvmod)*kaccent*kaccurve*2000
|
||||
@@ -461,8 +456,6 @@ inline float GET_INC(float freq) {
|
||||
int Lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
{
|
||||
const float sampleRatio = 44100.f / Engine::audioEngine()->processingSampleRate();
|
||||
float w;
|
||||
float samp;
|
||||
|
||||
// Hold on to the current VCF, and use it throughout this period
|
||||
Lb302Filter *filter = vcf.loadAcquire();
|
||||
@@ -566,7 +559,7 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
vco_k = -0.5 ;
|
||||
}
|
||||
else if (vco_k>0.5) {
|
||||
w = 2.0*(vco_k-0.5)-1.0;
|
||||
float w = 2.0 * (vco_k - 0.5) - 1.0;
|
||||
vco_k = 0.5 - sqrtf(1.0-(w*w));
|
||||
}
|
||||
vco_k *= 2.0; // MOOG wave gets filtered away
|
||||
@@ -610,7 +603,7 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
#ifdef LB_FILTERED
|
||||
//samp = vcf->process(vco_k)*2.0*vca_a;
|
||||
//samp = vcf->process(vco_k)*2.0;
|
||||
samp = filter->process(vco_k) * vca_a;
|
||||
float samp = filter->process(vco_k) * vca_a;
|
||||
//printf("%f %d\n", vco_c, sample_cnt);
|
||||
|
||||
|
||||
|
||||
@@ -76,21 +76,18 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
f.open(QIODevice::WriteOnly);
|
||||
QDataStream midiout(&f);
|
||||
|
||||
InstrumentTrack* instTrack;
|
||||
PatternTrack* patternTrack;
|
||||
QDomElement element;
|
||||
|
||||
|
||||
int nTracks = 0;
|
||||
auto buffer = std::array<uint8_t, BUFFER_SIZE>{};
|
||||
uint32_t size;
|
||||
|
||||
for (const Track* track : tracks) if (track->type() == Track::Type::Instrument) nTracks++;
|
||||
for (const Track* track : patternStoreTracks) if (track->type() == Track::Type::Instrument) nTracks++;
|
||||
|
||||
// midi header
|
||||
MidiFile::MIDIHeader header(nTracks);
|
||||
size = header.writeToBuffer(buffer.data());
|
||||
uint32_t size = header.writeToBuffer(buffer.data());
|
||||
midiout.writeRawData((char *)buffer.data(), size);
|
||||
|
||||
std::vector<std::vector<std::pair<int,int>>> plists;
|
||||
@@ -108,7 +105,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
//mtrack.addProgramChange(0, 0);
|
||||
mtrack.addTempo(tempo, 0);
|
||||
|
||||
instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
auto instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
element = instTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
int base_pitch = 0;
|
||||
@@ -146,7 +143,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
|
||||
if (track->type() == Track::Type::Pattern)
|
||||
{
|
||||
patternTrack = dynamic_cast<PatternTrack*>(track);
|
||||
auto patternTrack = dynamic_cast<PatternTrack*>(track);
|
||||
element = patternTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
std::vector<std::pair<int,int>> plist;
|
||||
@@ -184,7 +181,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
//mtrack.addProgramChange(0, 0);
|
||||
mtrack.addTempo(tempo, 0);
|
||||
|
||||
instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
auto instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
element = instTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
int base_pitch = 0;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <array>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
@@ -47,8 +48,8 @@ int writeVarLength(uint32_t val, uint8_t *buffer)
|
||||
byte in question is the last in the stream
|
||||
*/
|
||||
int size = 0;
|
||||
uint8_t result, little_endian[4];
|
||||
result = val & 0x7F;
|
||||
uint8_t little_endian[4];
|
||||
uint8_t result = val & 0x7F;
|
||||
little_endian[size++] = result;
|
||||
val = val >> 7;
|
||||
while (val > 0)
|
||||
@@ -129,31 +130,37 @@ struct Event
|
||||
|
||||
inline int writeToBuffer(uint8_t *buffer) const
|
||||
{
|
||||
uint8_t code, fourbytes[4];
|
||||
int size=0;
|
||||
switch (type)
|
||||
int size = 0;
|
||||
switch (type)
|
||||
{
|
||||
case NOTE_ON:
|
||||
code = 0x9 << 4 | channel;
|
||||
{
|
||||
uint8_t code = 0x9 << 4 | channel;
|
||||
size += writeVarLength(time, buffer+size);
|
||||
buffer[size++] = code;
|
||||
buffer[size++] = pitch;
|
||||
buffer[size++] = volume;
|
||||
break;
|
||||
}
|
||||
case NOTE_OFF:
|
||||
code = 0x8 << 4 | channel;
|
||||
{
|
||||
uint8_t code = 0x8 << 4 | channel;
|
||||
size += writeVarLength(time, buffer+size);
|
||||
buffer[size++] = code;
|
||||
buffer[size++] = pitch;
|
||||
buffer[size++] = volume;
|
||||
break;
|
||||
}
|
||||
case TEMPO:
|
||||
code = 0xFF;
|
||||
{
|
||||
uint8_t code = 0xFF;
|
||||
size += writeVarLength(time, buffer+size);
|
||||
buffer[size++] = code;
|
||||
buffer[size++] = 0x51;
|
||||
buffer[size++] = 0x03;
|
||||
writeBigEndian4(int(60000000.0 / tempo), fourbytes);
|
||||
|
||||
std::array<uint8_t, 4> fourbytes;
|
||||
writeBigEndian4(int(60000000.0 / tempo), fourbytes.data());
|
||||
|
||||
//printf("tempo of %x translates to ", tempo);
|
||||
/*
|
||||
@@ -164,23 +171,27 @@ struct Event
|
||||
buffer[size++] = fourbytes[2];
|
||||
buffer[size++] = fourbytes[3];
|
||||
break;
|
||||
}
|
||||
case PROG_CHANGE:
|
||||
code = 0xC << 4 | channel;
|
||||
{
|
||||
uint8_t code = 0xC << 4 | channel;
|
||||
size += writeVarLength(time, buffer+size);
|
||||
buffer[size++] = code;
|
||||
buffer[size++] = programNumber;
|
||||
break;
|
||||
}
|
||||
case TRACK_NAME:
|
||||
{
|
||||
size += writeVarLength(time, buffer+size);
|
||||
buffer[size++] = 0xFF;
|
||||
buffer[size++] = 0x03;
|
||||
size += writeVarLength(trackName.size(), buffer+size);
|
||||
trackName.copy((char *)(&buffer[size]), trackName.size());
|
||||
size += trackName.size();
|
||||
// buffer[size++] = '\0';
|
||||
// buffer[size++] = '\0';
|
||||
|
||||
break;
|
||||
// buffer[size++] = '\0';
|
||||
// buffer[size++] = '\0';
|
||||
}
|
||||
}
|
||||
return size;
|
||||
} // writeEventsToBuffer
|
||||
@@ -275,7 +286,7 @@ class MIDITrack
|
||||
vector<Event> _events = events;
|
||||
std::sort(_events.begin(), _events.end());
|
||||
vector<Event>::const_iterator it;
|
||||
uint32_t time_last = 0, tmp;
|
||||
uint32_t time_last = 0;
|
||||
for (it = _events.begin(); it!=_events.end(); ++it)
|
||||
{
|
||||
Event e = *it;
|
||||
@@ -283,7 +294,7 @@ class MIDITrack
|
||||
printf("error: e.time=%d time_last=%d\n", e.time, time_last);
|
||||
assert(false);
|
||||
}
|
||||
tmp = e.time;
|
||||
uint32_t tmp = e.time;
|
||||
e.time -= time_last;
|
||||
time_last = tmp;
|
||||
start += e.writeToBuffer(buffer+start);
|
||||
|
||||
@@ -61,10 +61,10 @@ private:
|
||||
|
||||
inline int readInt( int _bytes )
|
||||
{
|
||||
int c, value = 0;
|
||||
int value = 0;
|
||||
do
|
||||
{
|
||||
c = readByte();
|
||||
int c = readByte();
|
||||
if( c == -1 )
|
||||
{
|
||||
return( -1 );
|
||||
|
||||
@@ -244,14 +244,12 @@ void OpulenzInstrument::reloadEmulator() {
|
||||
|
||||
// This shall only be called from code protected by the holy Mutex!
|
||||
void OpulenzInstrument::setVoiceVelocity(int voice, int vel) {
|
||||
int vel_adjusted;
|
||||
int vel_adjusted = !fm_mdl.value()
|
||||
? 63 - (op1_lvl_mdl.value() * vel / 127.0)
|
||||
: 63 - op1_lvl_mdl.value();
|
||||
|
||||
// Velocity calculation, some kind of approximation
|
||||
// Only calculate for operator 1 if in adding mode, don't want to change timbre
|
||||
if( fm_mdl.value() == false ) {
|
||||
vel_adjusted = 63 - ( op1_lvl_mdl.value() * vel/127.0) ;
|
||||
} else {
|
||||
vel_adjusted = 63 - op1_lvl_mdl.value();
|
||||
}
|
||||
theEmulator->write(0x40+adlib_opadd[voice],
|
||||
( (int)op1_scale_mdl.value() & 0x03 << 6) +
|
||||
( vel_adjusted & 0x3f ) );
|
||||
@@ -297,66 +295,60 @@ int OpulenzInstrument::pushVoice(int v) {
|
||||
bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset )
|
||||
{
|
||||
emulatorMutex.lock();
|
||||
int key, vel, voice, tmp_pb;
|
||||
|
||||
switch(event.type()) {
|
||||
case MidiNoteOn:
|
||||
key = event.key();
|
||||
vel = event.velocity();
|
||||
|
||||
voice = popVoice();
|
||||
if( voice != OPL2_NO_VOICE ) {
|
||||
int key = event.key();
|
||||
int vel = event.velocity();
|
||||
switch (event.type())
|
||||
{
|
||||
case MidiNoteOn:
|
||||
if (int voice = popVoice(); voice != OPL2_NO_VOICE)
|
||||
{
|
||||
// Turn voice on, NB! the frequencies are straight by voice number,
|
||||
// not by the adlib_opadd table!
|
||||
theEmulator->write(0xA0+voice, fnums[key] & 0xff);
|
||||
theEmulator->write(0xB0+voice, 32 + ((fnums[key] & 0x1f00) >> 8) );
|
||||
theEmulator->write(0xA0 + voice, fnums[key] & 0xff);
|
||||
theEmulator->write(0xB0 + voice, 32 + ((fnums[key] & 0x1f00) >> 8));
|
||||
setVoiceVelocity(voice, vel);
|
||||
voiceNote[voice] = key;
|
||||
velocities[key] = vel;
|
||||
}
|
||||
break;
|
||||
case MidiNoteOff:
|
||||
key = event.key();
|
||||
for(voice=0; voice<OPL2_VOICES; ++voice) {
|
||||
if( voiceNote[voice] == key ) {
|
||||
theEmulator->write(0xA0+voice, fnums[key] & 0xff);
|
||||
theEmulator->write(0xB0+voice, (fnums[key] & 0x1f00) >> 8 );
|
||||
voiceNote[voice] |= OPL2_VOICE_FREE;
|
||||
break;
|
||||
case MidiNoteOff:
|
||||
for (int voice = 0; voice < OPL2_VOICES; ++voice)
|
||||
{
|
||||
if (voiceNote[voice] == key)
|
||||
{
|
||||
theEmulator->write(0xA0 + voice, fnums[key] & 0xff);
|
||||
theEmulator->write(0xB0 + voice, (fnums[key] & 0x1f00) >> 8);
|
||||
voiceNote[voice] |= OPL2_VOICE_FREE;
|
||||
pushVoice(voice);
|
||||
}
|
||||
}
|
||||
velocities[key] = 0;
|
||||
break;
|
||||
case MidiKeyPressure:
|
||||
key = event.key();
|
||||
vel = event.velocity();
|
||||
if( velocities[key] != 0) {
|
||||
velocities[key] = vel;
|
||||
}
|
||||
for(voice=0; voice<OPL2_VOICES; ++voice) {
|
||||
if(voiceNote[voice] == key) {
|
||||
setVoiceVelocity(voice, vel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MidiPitchBend:
|
||||
velocities[key] = 0;
|
||||
break;
|
||||
case MidiKeyPressure:
|
||||
if (velocities[key] != 0) { velocities[key] = vel; }
|
||||
for (int voice = 0; voice < OPL2_VOICES; ++voice)
|
||||
{
|
||||
if (voiceNote[voice] == key) { setVoiceVelocity(voice, vel); }
|
||||
}
|
||||
break;
|
||||
case MidiPitchBend:
|
||||
// Update fnumber table
|
||||
|
||||
// Neutral = 8192, full downbend = 0, full upbend = 16383
|
||||
tmp_pb = ( event.pitchBend()-8192 ) * pitchBendRange / 8192;
|
||||
|
||||
if( tmp_pb != pitchbend ) {
|
||||
if (int tmp_pb = (event.pitchBend() - 8192) * pitchBendRange / 8192; tmp_pb != pitchbend)
|
||||
{
|
||||
pitchbend = tmp_pb;
|
||||
tuneEqual(69, 440.0);
|
||||
}
|
||||
// Update pitch of all voices (also released ones)
|
||||
for( int v=0; v<OPL2_VOICES; ++v ) {
|
||||
int vn = (voiceNote[v] & ~OPL2_VOICE_FREE); // remove the flag bit
|
||||
for (int v = 0; v < OPL2_VOICES; ++v)
|
||||
{
|
||||
int vn = (voiceNote[v] & ~OPL2_VOICE_FREE); // remove the flag bit
|
||||
int playing = (voiceNote[v] & OPL2_VOICE_FREE) == 0; // just the flag bit
|
||||
theEmulator->write(0xA0+v, fnums[vn] & 0xff);
|
||||
theEmulator->write(0xB0+v, (playing ? 32 : 0) + ((fnums[vn] & 0x1f00) >> 8) );
|
||||
}
|
||||
break;
|
||||
theEmulator->write(0xA0 + v, fnums[vn] & 0xff);
|
||||
theEmulator->write(0xB0 + v, (playing ? 32 : 0) + ((fnums[vn] & 0x1f00) >> 8));
|
||||
}
|
||||
break;
|
||||
case MidiControlChange:
|
||||
switch (event.controllerNumber()) {
|
||||
case MidiControllerRegisteredParameterNumberLSB:
|
||||
@@ -382,7 +374,7 @@ bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const TimePos&
|
||||
printf("Midi event type %d\n",event.type());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
emulatorMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
@@ -504,9 +496,8 @@ void OpulenzInstrument::loadPatch(const unsigned char inst[14]) {
|
||||
}
|
||||
|
||||
void OpulenzInstrument::tuneEqual(int center, float Hz) {
|
||||
float tmp;
|
||||
for(int n=0; n<128; ++n) {
|
||||
tmp = Hz*pow( 2.0, ( n - center ) * ( 1.0 / 12.0 ) + pitchbend * ( 1.0 / 1200.0 ) );
|
||||
float tmp = Hz * pow(2.0, (n - center) * (1.0 / 12.0) + pitchbend * (1.0 / 1200.0));
|
||||
fnums[n] = Hz2fnum( tmp );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,17 +298,16 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch(
|
||||
SKIP_BYTES( 2 + 2 + 36 );
|
||||
|
||||
f_cnt_t frames;
|
||||
sample_t * wave_samples;
|
||||
std::unique_ptr<sample_t[]> wave_samples;
|
||||
if( modes & MODES_16BIT )
|
||||
{
|
||||
frames = data_length >> 1;
|
||||
wave_samples = new sample_t[frames];
|
||||
wave_samples = std::make_unique<sample_t[]>(frames);
|
||||
for( f_cnt_t frame = 0; frame < frames; ++frame )
|
||||
{
|
||||
short sample;
|
||||
if ( fread( &sample, 2, 1, fd ) != 1 )
|
||||
{
|
||||
delete[] wave_samples;
|
||||
fclose( fd );
|
||||
return( LoadError::IO );
|
||||
}
|
||||
@@ -326,13 +325,12 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch(
|
||||
else
|
||||
{
|
||||
frames = data_length;
|
||||
wave_samples = new sample_t[frames];
|
||||
wave_samples = std::make_unique<sample_t[]>(frames);
|
||||
for( f_cnt_t frame = 0; frame < frames; ++frame )
|
||||
{
|
||||
char sample;
|
||||
if ( fread( &sample, 1, 1, fd ) != 1 )
|
||||
{
|
||||
delete[] wave_samples;
|
||||
fclose( fd );
|
||||
return( LoadError::IO );
|
||||
}
|
||||
@@ -366,7 +364,6 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch(
|
||||
|
||||
m_patchSamples.push_back(psample);
|
||||
|
||||
delete[] wave_samples;
|
||||
delete[] data;
|
||||
}
|
||||
fclose( fd );
|
||||
|
||||
@@ -241,24 +241,21 @@ f_cnt_t SidInstrument::desiredReleaseFrames() const
|
||||
|
||||
static int sid_fillbuffer(unsigned char* sidreg, reSID::SID *sid, int tdelta, short *ptr, int samples)
|
||||
{
|
||||
int tdelta2;
|
||||
int result;
|
||||
int total = 0;
|
||||
int c;
|
||||
// customly added
|
||||
int residdelay = 0;
|
||||
|
||||
int badline = rand() % NUMSIDREGS;
|
||||
|
||||
for (c = 0; c < NUMSIDREGS; c++)
|
||||
for (int c = 0; c < NUMSIDREGS; c++)
|
||||
{
|
||||
unsigned char o = sidorder[c];
|
||||
|
||||
// Extra delay for loading the waveform (and mt_chngate,x)
|
||||
if ((o == 4) || (o == 11) || (o == 18))
|
||||
{
|
||||
tdelta2 = SIDWAVEDELAY;
|
||||
result = sid->clock(tdelta2, ptr, samples);
|
||||
int tdelta2 = SIDWAVEDELAY;
|
||||
int result = sid->clock(tdelta2, ptr, samples);
|
||||
total += result;
|
||||
ptr += result;
|
||||
samples -= result;
|
||||
@@ -268,8 +265,8 @@ static int sid_fillbuffer(unsigned char* sidreg, reSID::SID *sid, int tdelta, sh
|
||||
// Possible random badline delay once per writing
|
||||
if ((badline == c) && (residdelay))
|
||||
{
|
||||
tdelta2 = residdelay;
|
||||
result = sid->clock(tdelta2, ptr, samples);
|
||||
int tdelta2 = residdelay;
|
||||
int result = sid->clock(tdelta2, ptr, samples);
|
||||
total += result;
|
||||
ptr += result;
|
||||
samples -= result;
|
||||
@@ -278,14 +275,14 @@ static int sid_fillbuffer(unsigned char* sidreg, reSID::SID *sid, int tdelta, sh
|
||||
|
||||
sid->write(o, sidreg[o]);
|
||||
|
||||
tdelta2 = SIDWRITEDELAY;
|
||||
result = sid->clock(tdelta2, ptr, samples);
|
||||
int tdelta2 = SIDWRITEDELAY;
|
||||
int result = sid->clock(tdelta2, ptr, samples);
|
||||
total += result;
|
||||
ptr += result;
|
||||
samples -= result;
|
||||
tdelta -= SIDWRITEDELAY;
|
||||
}
|
||||
result = sid->clock(tdelta, ptr, samples);
|
||||
int result = sid->clock(tdelta, ptr, samples);
|
||||
total += result;
|
||||
|
||||
return total;
|
||||
|
||||
@@ -198,7 +198,6 @@ void SlicerT::findSlices()
|
||||
int lastPoint = -minDist - 1; // to always store 0 first
|
||||
float spectralFlux = 0;
|
||||
float prevFlux = 1E-10; // small value, no divison by zero
|
||||
float real, imag, magnitude, diff;
|
||||
|
||||
for (int i = 0; i < singleChannel.size() - windowSize; i += windowSize)
|
||||
{
|
||||
@@ -209,12 +208,12 @@ void SlicerT::findSlices()
|
||||
// calculate spectral flux in regard to last window
|
||||
for (int j = 0; j < windowSize / 2; j++) // only use niquistic frequencies
|
||||
{
|
||||
real = fftOut[j][0];
|
||||
imag = fftOut[j][1];
|
||||
magnitude = std::sqrt(real * real + imag * imag);
|
||||
float real = fftOut[j][0];
|
||||
float imag = fftOut[j][1];
|
||||
float magnitude = std::sqrt(real * real + imag * imag);
|
||||
|
||||
// using L2-norm (euclidean distance)
|
||||
diff = std::sqrt(std::pow(magnitude - prevMags[j], 2));
|
||||
float diff = std::sqrt(std::pow(magnitude - prevMags[j], 2));
|
||||
spectralFlux += diff;
|
||||
|
||||
prevMags[j] = magnitude;
|
||||
|
||||
@@ -209,7 +209,6 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
memset(pixel, 0, waterfallWidth() * sizeof (QRgb));
|
||||
|
||||
// add newest result on top
|
||||
int target; // pixel being constructed
|
||||
float accL = 0; // accumulators for merging multiple bins
|
||||
float accR = 0;
|
||||
for (unsigned int i = 0; i < binCount(); i++)
|
||||
@@ -233,7 +232,8 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
if (band_end - band_start > 1.0)
|
||||
{
|
||||
// band spans multiple pixels: draw all pixels it covers
|
||||
for (target = std::max((int)band_start, 0); target < band_end && target < waterfallWidth(); target++)
|
||||
for (int target = std::max(static_cast<int>(band_start), 0);
|
||||
target < band_end && target < waterfallWidth(); target++)
|
||||
{
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
@@ -245,7 +245,7 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
else
|
||||
{
|
||||
// sub-pixel drawing; add contribution of current band
|
||||
target = (int)band_start;
|
||||
int target = static_cast<int>(band_start);
|
||||
if ((int)band_start == (int)band_end)
|
||||
{
|
||||
// band ends within current target pixel, accumulate
|
||||
@@ -270,7 +270,8 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
else
|
||||
{
|
||||
// Linear: always draws one or more pixels per band
|
||||
for (target = std::max((int)band_start, 0); target < band_end && target < waterfallWidth(); target++)
|
||||
for (int target = std::max(static_cast<int>(band_start), 0);
|
||||
target < band_end && target < waterfallWidth(); target++)
|
||||
{
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
@@ -361,30 +362,20 @@ void SaProcessor::setWaterfallActive(bool active)
|
||||
// Reallocate data buffers according to newly set block size.
|
||||
void SaProcessor::reallocateBuffers()
|
||||
{
|
||||
unsigned int new_size_index = m_controls->m_blockSizeModel.value();
|
||||
unsigned int new_in_size, new_fft_size;
|
||||
unsigned int new_bins;
|
||||
m_zeroPadFactor = m_controls->m_zeroPaddingModel.value();
|
||||
|
||||
// get new block sizes and bin count based on selected index
|
||||
if (new_size_index < FFT_BLOCK_SIZES.size())
|
||||
{
|
||||
new_in_size = FFT_BLOCK_SIZES[new_size_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_in_size = FFT_BLOCK_SIZES.back();
|
||||
}
|
||||
m_zeroPadFactor = m_controls->m_zeroPaddingModel.value();
|
||||
if (new_size_index + m_zeroPadFactor < FFT_BLOCK_SIZES.size())
|
||||
{
|
||||
new_fft_size = FFT_BLOCK_SIZES[new_size_index + m_zeroPadFactor];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_fft_size = FFT_BLOCK_SIZES.back();
|
||||
}
|
||||
const unsigned int new_size_index = m_controls->m_blockSizeModel.value();
|
||||
|
||||
new_bins = new_fft_size / 2 +1;
|
||||
const unsigned int new_in_size = new_size_index < FFT_BLOCK_SIZES.size()
|
||||
? FFT_BLOCK_SIZES[new_size_index]
|
||||
: FFT_BLOCK_SIZES.back();
|
||||
|
||||
const unsigned int new_fft_size = (new_size_index + m_zeroPadFactor < FFT_BLOCK_SIZES.size())
|
||||
? FFT_BLOCK_SIZES[new_size_index + m_zeroPadFactor]
|
||||
: FFT_BLOCK_SIZES.back();
|
||||
|
||||
const unsigned int new_bins = new_fft_size / 2 + 1;
|
||||
|
||||
// Use m_reallocating to tell analyze() to avoid asking for the lock. This
|
||||
// is needed because under heavy load the FFT thread requests data lock so
|
||||
|
||||
@@ -647,14 +647,13 @@ float SaSpectrumView::ampToYPixel(float amplitude, unsigned int height)
|
||||
std::vector<std::pair<int, std::string>> SaSpectrumView::makeLogFreqTics(int low, int high)
|
||||
{
|
||||
std::vector<std::pair<int, std::string>> result;
|
||||
int i, j;
|
||||
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)
|
||||
for (int i = 1; i <= high; i *= 10)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
// insert a label from sparse series if it falls within bounds
|
||||
if (i * a[j] >= low && i * a[j] <= high)
|
||||
@@ -691,7 +690,7 @@ std::vector<std::pair<int, std::string>> SaSpectrumView::makeLogFreqTics(int low
|
||||
std::vector<std::pair<int, std::string>> SaSpectrumView::makeLinearFreqTics(int low, int high)
|
||||
{
|
||||
std::vector<std::pair<int, std::string>> result;
|
||||
int i, increment;
|
||||
int increment;
|
||||
|
||||
// select a suitable increment based on zoom level
|
||||
if (high - low < 500) {increment = 50;}
|
||||
@@ -700,7 +699,7 @@ std::vector<std::pair<int, std::string>> SaSpectrumView::makeLinearFreqTics(int
|
||||
else {increment = 2000;}
|
||||
|
||||
// generate steps based on increment, starting at 0
|
||||
for (i = 0; i <= high; i += increment)
|
||||
for (int i = 0; i <= high; i += increment)
|
||||
{
|
||||
if (i >= low)
|
||||
{
|
||||
@@ -724,7 +723,6 @@ std::vector<std::pair<int, std::string>> SaSpectrumView::makeLinearFreqTics(int
|
||||
std::vector<std::pair<float, std::string>> SaSpectrumView::makeLogAmpTics(int low, int high)
|
||||
{
|
||||
std::vector<std::pair<float, std::string>> result;
|
||||
float i;
|
||||
double increment;
|
||||
|
||||
// Base zoom level on selected range and how close is the current height
|
||||
@@ -744,7 +742,7 @@ std::vector<std::pair<float, std::string>> SaSpectrumView::makeLogAmpTics(int lo
|
||||
|
||||
// Generate n dB increments, start checking at -90 dB. Limits are tweaked
|
||||
// just a little bit to make sure float comparisons do not miss edges.
|
||||
for (i = 0.000000001; 10 * log10(i) <= (high + 0.001); i *= increment)
|
||||
for (float i = 0.000000001; 10 * log10(i) <= (high + 0.001); i *= increment)
|
||||
{
|
||||
if (10 * log10(i) >= (low - 0.001))
|
||||
{
|
||||
@@ -764,8 +762,6 @@ std::vector<std::pair<float, std::string>> SaSpectrumView::makeLogAmpTics(int lo
|
||||
std::vector<std::pair<float, std::string>> SaSpectrumView::makeLinearAmpTics(int low, int high)
|
||||
{
|
||||
std::vector<std::pair<float, std::string>> result;
|
||||
double i, nearest;
|
||||
|
||||
// make about 5 labels when window is small, 10 if it is big
|
||||
float split = (float)height() / sizeHint().height() >= 1.5 ? 10.0 : 5.0;
|
||||
|
||||
@@ -777,28 +773,28 @@ std::vector<std::pair<float, std::string>> SaSpectrumView::makeLinearAmpTics(int
|
||||
// multiples, just generate a few evenly spaced increments across the range,
|
||||
// paying attention only to the decimal places to keep labels short.
|
||||
// Limits are shifted a bit so that float comparisons do not miss edges.
|
||||
for (i = 0; i <= (lin_high + 0.0001); i += (lin_high - lin_low) / split)
|
||||
for (double i = 0; i <= (lin_high + 0.0001); i += (lin_high - lin_low) / split)
|
||||
{
|
||||
if (i >= (lin_low - 0.0001))
|
||||
{
|
||||
if (i >= 9.99 && i < 99.9)
|
||||
{
|
||||
nearest = std::round(i);
|
||||
double nearest = std::round(i);
|
||||
result.emplace_back(nearest, std::to_string(nearest).substr(0, 2));
|
||||
}
|
||||
else if (i >= 0.099)
|
||||
{ // also covers numbers above 100
|
||||
nearest = std::round(i * 10) / 10;
|
||||
double nearest = std::round(i * 10) / 10;
|
||||
result.emplace_back(nearest, std::to_string(nearest).substr(0, 3));
|
||||
}
|
||||
else if (i >= 0.0099)
|
||||
{
|
||||
nearest = std::round(i * 1000) / 1000;
|
||||
double nearest = std::round(i * 1000) / 1000;
|
||||
result.emplace_back(nearest, std::to_string(nearest).substr(0, 4));
|
||||
}
|
||||
else if (i >= 0.00099)
|
||||
{
|
||||
nearest = std::round(i * 10000) / 10000;
|
||||
double nearest = std::round(i * 10000) / 10000;
|
||||
result.emplace_back(nearest, std::to_string(nearest).substr(1, 4));
|
||||
}
|
||||
else if (i > -0.01 && i < 0.01)
|
||||
|
||||
@@ -213,7 +213,6 @@ float SaWaterfallView::yPixelToTime(float position, int height)
|
||||
std::vector<std::pair<float, std::string>> SaWaterfallView::makeTimeTics()
|
||||
{
|
||||
std::vector<std::pair<float, std::string>> result;
|
||||
float i;
|
||||
|
||||
// get time value of the last line
|
||||
float limit = yPixelToTime(m_displayBottom, m_displayHeight);
|
||||
@@ -223,7 +222,7 @@ std::vector<std::pair<float, std::string>> SaWaterfallView::makeTimeTics()
|
||||
if (increment < 0.1) {increment = 0.1;}
|
||||
|
||||
// NOTE: labels positions are rounded to match the (rounded) label value
|
||||
for (i = 0; i <= limit; i += increment)
|
||||
for (float i = 0; i <= limit; i += increment)
|
||||
{
|
||||
if (i > 99)
|
||||
{
|
||||
|
||||
@@ -90,10 +90,6 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
// audio with this effect
|
||||
double out_sum = 0.0;
|
||||
|
||||
float width;
|
||||
int frameIndex = 0;
|
||||
|
||||
|
||||
if( !isEnabled() || !isRunning() )
|
||||
{
|
||||
return( false );
|
||||
@@ -110,10 +106,10 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
m_delayBuffer[m_currFrame][1] = _buf[f][1];
|
||||
|
||||
// Get the width knob value from the Stereo Enhancer effect
|
||||
width = m_seFX.wideCoeff();
|
||||
float width = m_seFX.wideCoeff();
|
||||
|
||||
// Calculate the correct sample frame for processing
|
||||
frameIndex = m_currFrame - width;
|
||||
int frameIndex = m_currFrame - width;
|
||||
|
||||
if( frameIndex < 0 )
|
||||
{
|
||||
@@ -149,8 +145,7 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
|
||||
void StereoEnhancerEffect::clearMyBuffer()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < DEFAULT_BUFFER_SIZE; i++)
|
||||
for (int i = 0; i < DEFAULT_BUFFER_SIZE; i++)
|
||||
{
|
||||
m_delayBuffer[i][0] = 0.0f;
|
||||
m_delayBuffer[i][1] = 0.0f;
|
||||
|
||||
@@ -138,8 +138,6 @@ void VectorView::paintEvent(QPaintEvent *event)
|
||||
std::size_t frameCount = inBuffer.size();
|
||||
|
||||
// Draw new points on top
|
||||
float left, right;
|
||||
int x, y;
|
||||
|
||||
const bool logScale = m_controls->m_logarithmicModel.value();
|
||||
const unsigned short activeSize = hq ? m_displaySize : m_displaySize / 2;
|
||||
@@ -164,6 +162,8 @@ void VectorView::paintEvent(QPaintEvent *event)
|
||||
// The longer the line is, the dimmer, simulating real electron trace on luminescent screen.
|
||||
for (std::size_t frame = 0; frame < frameCount; frame++)
|
||||
{
|
||||
float left = 0.0f;
|
||||
float right = 0.0f;
|
||||
float inLeft = inBuffer[frame][0] * m_zoom;
|
||||
float inRight = inBuffer[frame][1] * m_zoom;
|
||||
// Scale left and right channel from (-1.0, 1.0) to display range
|
||||
@@ -185,8 +185,8 @@ void VectorView::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
|
||||
// Rotate display coordinates 45 degrees, flip Y axis and make sure the result stays within bounds
|
||||
x = saturate(right - left + activeSize / 2.f);
|
||||
y = saturate(activeSize - (right + left + activeSize / 2.f));
|
||||
int x = saturate(right - left + activeSize / 2.f);
|
||||
int y = saturate(activeSize - (right + left + activeSize / 2.f));
|
||||
|
||||
// Estimate number of points needed to fill space between the old and new pixel. Cap at 100.
|
||||
unsigned char points = std::min((int)sqrt((m_oldX - x) * (m_oldX - x) + (m_oldY - y) * (m_oldY - y)), 100);
|
||||
@@ -222,6 +222,8 @@ void VectorView::paintEvent(QPaintEvent *event)
|
||||
// one full-color pixel per sample.
|
||||
for (std::size_t frame = 0; frame < frameCount; frame++)
|
||||
{
|
||||
float left = 0.0f;
|
||||
float right = 0.0f;
|
||||
float inLeft = inBuffer[frame][0] * m_zoom;
|
||||
float inRight = inBuffer[frame][1] * m_zoom;
|
||||
if (logScale) {
|
||||
@@ -235,8 +237,8 @@ void VectorView::paintEvent(QPaintEvent *event)
|
||||
left = inLeft * (activeSize - 1) / 4;
|
||||
right = inRight * (activeSize - 1) / 4;
|
||||
}
|
||||
x = saturate(right - left + activeSize / 2.f);
|
||||
y = saturate(activeSize - (right + left + activeSize / 2.f));
|
||||
int x = saturate(right - left + activeSize / 2.f);
|
||||
int y = saturate(activeSize - (right + left + activeSize / 2.f));
|
||||
((QRgb*)m_displayBuffer.data())[x + y * activeSize] = m_controls->m_colorFG.rgb();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,6 @@ void ManageVestigeInstrumentView::syncPlugin( void )
|
||||
auto paramStr = std::array<char, 35>{};
|
||||
QStringList s_dumpValues;
|
||||
const QMap<QString, QString> & dump = m_vi->m_plugin->parameterDump();
|
||||
float f_value;
|
||||
|
||||
for( int i = 0; i < m_vi->paramCount; i++ )
|
||||
{
|
||||
@@ -1063,7 +1062,7 @@ void ManageVestigeInstrumentView::syncPlugin( void )
|
||||
{
|
||||
sprintf(paramStr.data(), "param%d", i);
|
||||
s_dumpValues = dump[paramStr.data()].split(":");
|
||||
f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
|
||||
float f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
|
||||
m_vi->knobFModel[ i ]->setAutomatedValue( f_value );
|
||||
m_vi->knobFModel[ i ]->setInitValue( f_value );
|
||||
}
|
||||
|
||||
@@ -75,12 +75,10 @@ std::unique_ptr<VibratingString::DelayLine> VibratingString::initDelayLine(int l
|
||||
if (len > 0)
|
||||
{
|
||||
dl->data = std::make_unique<sample_t[]>(len);
|
||||
float r;
|
||||
float offset = 0.0f;
|
||||
for (int i = 0; i < dl->length; ++i)
|
||||
{
|
||||
r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
float r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
float offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
dl->data[i] = offset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ public:
|
||||
|
||||
sample_t nextSample()
|
||||
{
|
||||
sample_t ym0;
|
||||
sample_t ypM;
|
||||
for (int i = 0; i < m_oversample; ++i)
|
||||
{
|
||||
// Output at pickup position
|
||||
@@ -58,9 +56,9 @@ public:
|
||||
m_outsamp[i] += toBridgeAccess(m_toBridge.get(), m_pickupLoc);
|
||||
|
||||
// Sample traveling into "bridge"
|
||||
ym0 = toBridgeAccess(m_toBridge.get(), 1);
|
||||
sample_t ym0 = toBridgeAccess(m_toBridge.get(), 1);
|
||||
// Sample to "nut"
|
||||
ypM = fromBridgeAccess(m_fromBridge.get(), m_fromBridge->length - 2);
|
||||
sample_t ypM = fromBridgeAccess(m_fromBridge.get(), m_fromBridge->length - 2);
|
||||
|
||||
// String state update
|
||||
|
||||
@@ -105,21 +103,18 @@ private:
|
||||
*/
|
||||
void setDelayLine(DelayLine* dl, int pick, const float* values, int len, float scale, bool state)
|
||||
{
|
||||
float r;
|
||||
float offset;
|
||||
|
||||
if (!state)
|
||||
{
|
||||
for (int i = 0; i < pick; ++i)
|
||||
{
|
||||
r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
float r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
float offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
dl->data[i] = scale * values[dl->length - i - 1] + offset;
|
||||
}
|
||||
for (int i = pick; i < dl->length; ++i)
|
||||
{
|
||||
r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
float r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
float offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
dl->data[i] = scale * values[i - pick] + offset;
|
||||
}
|
||||
}
|
||||
@@ -129,8 +124,8 @@ private:
|
||||
{
|
||||
for (int i = pick; i < dl->length; ++i)
|
||||
{
|
||||
r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
float r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
float offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
dl->data[i] = scale * values[i - pick] + offset;
|
||||
}
|
||||
}
|
||||
@@ -138,8 +133,8 @@ private:
|
||||
{
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
float r = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
float offset = (m_randomize / 2.0f - m_randomize) * r;
|
||||
dl->data[i+pick] = scale * values[i] + offset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +452,6 @@ void ManageVSTEffectView::syncPlugin()
|
||||
auto paramStr = std::array<char, 35>{};
|
||||
QStringList s_dumpValues;
|
||||
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
|
||||
float f_value;
|
||||
|
||||
for( int i = 0; i < m_vi2->paramCount; i++ )
|
||||
{
|
||||
@@ -463,7 +462,7 @@ void ManageVSTEffectView::syncPlugin()
|
||||
{
|
||||
sprintf(paramStr.data(), "param%d", i);
|
||||
s_dumpValues = dump[paramStr.data()].split(":");
|
||||
f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
|
||||
float f_value = LocaleHelper::toFloat(s_dumpValues.at(2));
|
||||
m_vi2->knobFModel[ i ]->setAutomatedValue( f_value );
|
||||
m_vi2->knobFModel[ i ]->setInitValue( f_value );
|
||||
}
|
||||
|
||||
@@ -322,14 +322,8 @@ struct RandomVectorSeedFunction : public exprtk::ifunction<float>
|
||||
|
||||
inline float operator()(const float& index,const float& seed) override
|
||||
{
|
||||
int irseed;
|
||||
if (seed < 0 || std::isnan(seed) || std::isinf(seed))
|
||||
{
|
||||
irseed=0;
|
||||
}
|
||||
else
|
||||
irseed=(int)seed;
|
||||
return randv(index,irseed);
|
||||
const int irseed = seed < 0 || std::isnan(seed) || std::isinf(seed) ? 0 : static_cast<int>(seed);
|
||||
return randv(index, irseed);
|
||||
}
|
||||
|
||||
static const int data_size=sizeof(random_data)/sizeof(int);
|
||||
|
||||
@@ -256,13 +256,12 @@ void Xpressive::smooth(float smoothness,const graphModel * in,graphModel * out)
|
||||
auto const guassian = new float[guass_size];
|
||||
float sum = 0.0f;
|
||||
float temp = 0.0f;
|
||||
int i;
|
||||
for (i = 0; i < guass_size; i++ )
|
||||
for (int i = 0; i < guass_size; i++)
|
||||
{
|
||||
temp = (i - guass_center) / delta;
|
||||
sum += guassian[i] = a * powf(F_E, -0.5f * temp * temp);
|
||||
}
|
||||
for (i = 0; i < guass_size; i++ )
|
||||
for (int i = 0; i < guass_size; i++)
|
||||
{
|
||||
guassian[i] = guassian[i] / sum;
|
||||
}
|
||||
@@ -336,13 +335,6 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) :
|
||||
pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("wavegraph"));
|
||||
m_graph->setPalette(pal);
|
||||
|
||||
PixmapButton * m_w1Btn;
|
||||
PixmapButton * m_w2Btn;
|
||||
PixmapButton * m_w3Btn;
|
||||
PixmapButton * m_o1Btn;
|
||||
PixmapButton * m_o2Btn;
|
||||
PixmapButton * m_helpBtn;
|
||||
|
||||
m_w1Btn = new PixmapButton(this, nullptr);
|
||||
m_w1Btn->move(3, ROW_BTN);
|
||||
m_w1Btn->setActiveGraphic(PLUGIN_NAME::getIconPixmap("w1_active"));
|
||||
|
||||
@@ -190,6 +190,7 @@ private:
|
||||
PixmapButton *m_w3Btn;
|
||||
PixmapButton *m_o1Btn;
|
||||
PixmapButton *m_o2Btn;
|
||||
PixmapButton *m_helpBtn;
|
||||
PixmapButton *m_sinWaveBtn;
|
||||
PixmapButton *m_triangleWaveBtn;
|
||||
PixmapButton *m_sqrWaveBtn;
|
||||
|
||||
Reference in New Issue
Block a user