From 8be63a363247ba196802a77949b0312b0130c102 Mon Sep 17 00:00:00 2001 From: jsakkine Date: Thu, 17 Jan 2019 10:31:29 -0800 Subject: [PATCH] Capitalize global constants (#308) We can probably agree that a good convention for constants, defines and enums is to have them capitalized. Right now it is hard to recognize from source code, what is a constant and what is a normal variable. There are still lot of enums etc. in the source code that are in lower case but they are way more localized. This is a good place to start. Signed-off-by: Jarkko Sakkinen --- src/au/aulayer.cpp | 4 +- src/common/AbstractSynthesizer.h | 6 +- src/common/Parameter.cpp | 4 +- src/common/Parameter.h | 2 +- src/common/SampleLoadRiffWave.cpp | 2 +- src/common/SurgeStorage.cpp | 4 +- src/common/SurgeStorage.h | 6 +- src/common/SurgeSynthesizer.cpp | 106 +++++++++--------- src/common/SurgeSynthesizer.h | 2 +- src/common/dsp/AdsrEnvelope.h | 2 +- src/common/dsp/BiquadFilter.cpp | 12 +- src/common/dsp/BiquadFilterSSE2.cpp | 10 +- src/common/dsp/DspUtilities.h | 2 +- src/common/dsp/FMOscillator.cpp | 8 +- src/common/dsp/FilterCoefficientMaker.cpp | 4 +- src/common/dsp/Oscillator.cpp | 10 +- src/common/dsp/Oscillator.h | 38 +++---- src/common/dsp/QuadFilterChain.cpp | 16 +-- src/common/dsp/QuadFilterChain.h | 2 +- src/common/dsp/QuadFilterUnit.cpp | 12 +- src/common/dsp/SampleAndHoldOscillator.cpp | 38 +++---- src/common/dsp/SurgeSuperOscillator.cpp | 42 +++---- src/common/dsp/SurgeVoice.cpp | 94 ++++++++-------- src/common/dsp/SurgeVoice.h | 6 +- src/common/dsp/WavetableOscillator.cpp | 36 +++--- src/common/dsp/WindowOscillator.cpp | 16 +-- src/common/dsp/effect/ConditionerEffect.cpp | 36 +++--- src/common/dsp/effect/DistortionEffect.cpp | 24 ++-- src/common/dsp/effect/DualDelayEffect.cpp | 58 +++++----- src/common/dsp/effect/Effect.cpp | 60 +++++----- src/common/dsp/effect/FreqshiftEffect.cpp | 30 ++--- src/common/dsp/effect/PhaserEffect.cpp | 18 +-- src/common/dsp/effect/Reverb1Effect.cpp | 20 ++-- src/common/dsp/effect/Reverb2Effect.cpp | 18 +-- src/common/dsp/effect/RotarySpeakerEffect.cpp | 32 +++--- src/common/dsp/effect/VocoderEffect.cpp | 16 +-- src/common/dsp/effect/effect_defs.h | 4 +- src/common/globals.h | 24 ++-- src/common/gui/COscillatorDisplay.cpp | 8 +- src/common/gui/CPatchBrowser.cpp | 2 +- src/common/gui/CSnapshotMenu.cpp | 8 +- src/common/vt_dsp/halfratefilter.cpp | 8 +- src/common/vt_dsp/halfratefilter.h | 2 +- src/common/vt_dsp/lipol.cpp | 4 +- src/common/vt_dsp/lipol.h | 2 +- src/todo/effect_emphasize.cpp | 12 +- src/todo/sub3_osc_dot.cpp | 14 +-- src/todo/sub3_osc_sample.cpp | 2 +- src/todo/sub3_osc_wavetable2.cpp | 28 ++--- src/vst2/Vst2PluginInstance.cpp | 4 +- src/vst3/SurgeVst3Processor.cpp | 4 +- 51 files changed, 461 insertions(+), 461 deletions(-) diff --git a/src/au/aulayer.cpp b/src/au/aulayer.cpp index a515108471f..9908f49f760 100644 --- a/src/au/aulayer.cpp +++ b/src/au/aulayer.cpp @@ -387,7 +387,7 @@ ComponentResult aulayer::Render( AudioUnitRenderActionFlags & ioActionFlags, con if(blockpos == 0) { // move clock - plugin_instance->time_data.ppqPos += (double) block_size * plugin_instance->time_data.tempo/(60. * sampleRate); + plugin_instance->time_data.ppqPos += (double) BLOCK_SIZE * plugin_instance->time_data.tempo/(60. * sampleRate); // process events for the current block while(events_processed < events_this_block) @@ -422,7 +422,7 @@ ComponentResult aulayer::Render( AudioUnitRenderActionFlags & ioActionFlags, con } blockpos++; - if(blockpos>=block_size) blockpos = 0; + if(blockpos>=BLOCK_SIZE) blockpos = 0; } // process remaining events (there shouldn't be any) diff --git a/src/common/AbstractSynthesizer.h b/src/common/AbstractSynthesizer.h index 20fccbed388..74f100008a3 100644 --- a/src/common/AbstractSynthesizer.h +++ b/src/common/AbstractSynthesizer.h @@ -59,15 +59,15 @@ class AbstractSynthesizer } virtual int getBlockSize() { - return block_size; + return BLOCK_SIZE; } virtual void process() = 0; virtual void loadRaw(const void* data, int size, bool preset = false) = 0; virtual unsigned int saveRaw(void** data) = 0; public: - float output alignas(16)[n_outputs][block_size]; - float input alignas(16)[n_inputs][block_size]; + float output alignas(16)[n_outputs][BLOCK_SIZE]; + float input alignas(16)[n_inputs][BLOCK_SIZE]; timedata time_data; bool audio_processing_active; }; \ No newline at end of file diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index f0181331f67..b794a04ff3e 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -89,7 +89,7 @@ void create_fullname(char* dn, char* fn, ControlGroup ctrlgroup, int ctrlgroup_e void Parameter::set_name(const char* n) { - strncpy(dispname, n, namechars); + strncpy(dispname, n, NAMECHARS); create_fullname(dispname, fullname, ctrlgroup, ctrlgroup_entry); } @@ -116,7 +116,7 @@ Parameter* Parameter::assign(int id, this->scene = scene; this->ctrlstyle = ctrlstyle; - strncpy(this->name, name, namechars); + strncpy(this->name, name, NAMECHARS); set_name(dispname); char prefix[16]; get_prefix(prefix, ctrlgroup, ctrlgroup_entry, scene); diff --git a/src/common/Parameter.h b/src/common/Parameter.h index 7fac0984adc..43e4fcf9553 100644 --- a/src/common/Parameter.h +++ b/src/common/Parameter.h @@ -149,7 +149,7 @@ class Parameter void bound_value(bool force_integer = false); pdata val, val_default, val_min, val_max; int id; - char name[namechars], dispname[namechars], name_storage[namechars], fullname[namechars]; + char name[NAMECHARS], dispname[NAMECHARS], name_storage[NAMECHARS], fullname[NAMECHARS]; bool modulateable; int valtype = 0; int scene; // 0 = patch, 1 = scene A, 2 = scene B diff --git a/src/common/SampleLoadRiffWave.cpp b/src/common/SampleLoadRiffWave.cpp index 98f176c7564..865dcf9e007 100644 --- a/src/common/SampleLoadRiffWave.cpp +++ b/src/common/SampleLoadRiffWave.cpp @@ -216,7 +216,7 @@ bool Sample::load_riff_wave_mk2(const char* fname) // this->sample_start = 0; this->channels = (unsigned char)waveFormat.Format.nChannels; - unsigned int samplesizewithmargin = WaveDataSamples + 2 * FIRipol_N + block_size + FIRoffset; + unsigned int samplesizewithmargin = WaveDataSamples + 2 * FIRipol_N + BLOCK_SIZE + FIRoffset; sample_data = new float[samplesizewithmargin]; unsigned int i; for (i = 0; i < samplesizewithmargin; i++) diff --git a/src/common/SurgeStorage.cpp b/src/common/SurgeStorage.cpp index c8205d69192..c04f4b59856 100644 --- a/src/common/SurgeStorage.cpp +++ b/src/common/SurgeStorage.cpp @@ -128,7 +128,7 @@ SurgeStorage::SurgeStorage() for (int cc = 0; cc < 128; cc++) poly_aftertouch[s][cc] = 0.f; - memset(&audio_in[0][0], 0, 2 * block_size_os * sizeof(float)); + memset(&audio_in[0][0], 0, 2 * BLOCK_SIZE_OS * sizeof(float)); #if MAC char path[1024]; @@ -872,7 +872,7 @@ void SurgeStorage::init_tables() (float)sin(2 * M_PI * min(0.5, 440 * table_pitch[i] * dsamplerate_os_inv)); table_note_omega[1][i] = (float)cos(2 * M_PI * min(0.5, 440 * table_pitch[i] * dsamplerate_os_inv)); - double k = dsamplerate_os * pow(2.0, (((double)i - 256.0) / 16.0)) / (double)block_size_os; + double k = dsamplerate_os * pow(2.0, (((double)i - 256.0) / 16.0)) / (double)BLOCK_SIZE_OS; table_envrate_lpf[i] = (float)(1.f - exp(log(db60) / k)); table_envrate_linear[i] = (float)1.f / k; } diff --git a/src/common/SurgeStorage.h b/src/common/SurgeStorage.h index e51df6e9b42..9ed3ae6e233 100644 --- a/src/common/SurgeStorage.h +++ b/src/common/SurgeStorage.h @@ -410,7 +410,7 @@ class SurgePatch // data SurgeSceneStorage scene[2], morphscene; FxStorage fx[8]; - // char name[namechars]; + // char name[NAMECHARS]; int scene_start[2], scene_size; Parameter scene_active, scenemode, scenemorph, splitkey; Parameter volume; @@ -465,8 +465,8 @@ enum sub3_copysource class SurgeStorage { public: - float audio_in alignas(16)[2][block_size_os]; - float audio_in_nonOS alignas(16)[2][block_size]; + float audio_in alignas(16)[2][BLOCK_SIZE_OS]; + float audio_in_nonOS alignas(16)[2][BLOCK_SIZE]; // float sincoffset alignas(16)[(FIRipol_M)*FIRipol_N]; // deprecated SurgeStorage(); diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index f8184c8de6c..fb1a210e402 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -98,13 +98,13 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer* parent) storage.getPatch().scene[0].modsources[ms_ctrl1 + i]; } - amp.set_blocksize(block_size); - FX1.set_blocksize(block_size); - FX2.set_blocksize(block_size); - send[0][0].set_blocksize(block_size); - send[0][1].set_blocksize(block_size); - send[1][0].set_blocksize(block_size); - send[1][1].set_blocksize(block_size); + amp.set_blocksize(BLOCK_SIZE); + FX1.set_blocksize(BLOCK_SIZE); + FX2.set_blocksize(BLOCK_SIZE); + send[0][0].set_blocksize(BLOCK_SIZE); + send[0][1].set_blocksize(BLOCK_SIZE); + send[1][0].set_blocksize(BLOCK_SIZE); + send[1][1].set_blocksize(BLOCK_SIZE); polydisplay = 0; refresh_editor = false; @@ -115,7 +115,7 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer* parent) storage.getPatch().author = ""; midiprogramshavechanged = false; - for (int i = 0; i < block_size; i++) + for (int i = 0; i < BLOCK_SIZE; i++) { input[0][i] = 0.f; input[1][i] = 0.f; @@ -1023,7 +1023,7 @@ void SurgeSynthesizer::setSamplerate(float sr) dsamplerate = sr; samplerate_inv = 1.0 / sr; dsamplerate_inv = 1.0 / sr; - dsamplerate_os = dsamplerate * osc_oversampling; + dsamplerate_os = dsamplerate * OSC_OVERSAMPLING; dsamplerate_os_inv = 1.0 / dsamplerate_os; storage.init_tables(); sinus.set_rate(1000.0 * dsamplerate_inv); @@ -2163,13 +2163,13 @@ void SurgeSynthesizer::process() if (halt_engine) { - /*for(int k=0; k= 0) @@ -2212,8 +2212,8 @@ void SurgeSynthesizer::process() SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL); #endif - clear_block(output[0], block_size_quad); - clear_block(output[1], block_size_quad); + clear_block(output[0], BLOCK_SIZE_QUAD); + clear_block(output[1], BLOCK_SIZE_QUAD); return; } } @@ -2221,34 +2221,34 @@ void SurgeSynthesizer::process() // process inputs (upsample & halfrate) if (process_input) { - hardclip_block8(input[0], block_size_quad); - hardclip_block8(input[1], block_size_quad); - copy_block(input[0], storage.audio_in_nonOS[0], block_size_quad); - copy_block(input[1], storage.audio_in_nonOS[1], block_size_quad); + hardclip_block8(input[0], BLOCK_SIZE_QUAD); + hardclip_block8(input[1], BLOCK_SIZE_QUAD); + copy_block(input[0], storage.audio_in_nonOS[0], BLOCK_SIZE_QUAD); + copy_block(input[1], storage.audio_in_nonOS[1], BLOCK_SIZE_QUAD); halfbandIN->process_block_U2(input[0], input[1], storage.audio_in[0], storage.audio_in[1]); } else { - clear_block_antidenormalnoise(storage.audio_in[0], block_size_os_quad); - clear_block_antidenormalnoise(storage.audio_in[1], block_size_os_quad); - clear_block_antidenormalnoise(storage.audio_in_nonOS[1], block_size_quad); - clear_block_antidenormalnoise(storage.audio_in_nonOS[1], block_size_quad); + clear_block_antidenormalnoise(storage.audio_in[0], BLOCK_SIZE_OS_QUAD); + clear_block_antidenormalnoise(storage.audio_in[1], BLOCK_SIZE_OS_QUAD); + clear_block_antidenormalnoise(storage.audio_in_nonOS[1], BLOCK_SIZE_QUAD); + clear_block_antidenormalnoise(storage.audio_in_nonOS[1], BLOCK_SIZE_QUAD); } - float sceneout alignas(16)[2][2][block_size_os]; - float fxsendout alignas(16)[2][2][block_size]; + float sceneout alignas(16)[2][2][BLOCK_SIZE_OS]; + float fxsendout alignas(16)[2][2][BLOCK_SIZE]; bool play_scene[2]; { - clear_block_antidenormalnoise(sceneout[0][0], block_size_os_quad); - clear_block_antidenormalnoise(sceneout[0][1], block_size_os_quad); - clear_block_antidenormalnoise(sceneout[1][0], block_size_os_quad); - clear_block_antidenormalnoise(sceneout[1][1], block_size_os_quad); + clear_block_antidenormalnoise(sceneout[0][0], BLOCK_SIZE_OS_QUAD); + clear_block_antidenormalnoise(sceneout[0][1], BLOCK_SIZE_OS_QUAD); + clear_block_antidenormalnoise(sceneout[1][0], BLOCK_SIZE_OS_QUAD); + clear_block_antidenormalnoise(sceneout[1][1], BLOCK_SIZE_OS_QUAD); - clear_block_antidenormalnoise(fxsendout[0][0], block_size_quad); - clear_block_antidenormalnoise(fxsendout[0][1], block_size_quad); - clear_block_antidenormalnoise(fxsendout[1][0], block_size_quad); - clear_block_antidenormalnoise(fxsendout[1][1], block_size_quad); + clear_block_antidenormalnoise(fxsendout[0][0], BLOCK_SIZE_QUAD); + clear_block_antidenormalnoise(fxsendout[0][1], BLOCK_SIZE_QUAD); + clear_block_antidenormalnoise(fxsendout[1][0], BLOCK_SIZE_QUAD); + clear_block_antidenormalnoise(fxsendout[1][1], BLOCK_SIZE_QUAD); } // CS ENTER @@ -2363,15 +2363,15 @@ void SurgeSynthesizer::process() if (play_scene[0]) { - hardclip_block8(sceneout[0][0], block_size_os_quad); - hardclip_block8(sceneout[0][1], block_size_os_quad); + hardclip_block8(sceneout[0][0], BLOCK_SIZE_OS_QUAD); + hardclip_block8(sceneout[0][1], BLOCK_SIZE_OS_QUAD); halfbandA->process_block_D2(sceneout[0][0], sceneout[0][1]); } if (play_scene[1]) { - hardclip_block8(sceneout[1][0], block_size_os_quad); - hardclip_block8(sceneout[1][1], block_size_os_quad); + hardclip_block8(sceneout[1][0], BLOCK_SIZE_OS_QUAD); + hardclip_block8(sceneout[1][1], BLOCK_SIZE_OS_QUAD); halfbandB->process_block_D2(sceneout[1][0], sceneout[1][1]); } @@ -2405,10 +2405,10 @@ void SurgeSynthesizer::process() } // sum scenes - copy_block(sceneout[0][0], output[0], block_size_quad); - copy_block(sceneout[0][1], output[1], block_size_quad); - accumulate_block(sceneout[1][0], output[0], block_size_quad); - accumulate_block(sceneout[1][1], output[1], block_size_quad); + copy_block(sceneout[0][0], output[0], BLOCK_SIZE_QUAD); + copy_block(sceneout[0][1], output[1], BLOCK_SIZE_QUAD); + accumulate_block(sceneout[1][0], output[0], BLOCK_SIZE_QUAD); + accumulate_block(sceneout[1][1], output[1], BLOCK_SIZE_QUAD); bool send1 = false, send2 = false; // add send effects @@ -2417,22 +2417,22 @@ void SurgeSynthesizer::process() if (fx[4] && !(storage.getPatch().fx_disable.val.i & (1 << 4))) { send[0][0].MAC_2_blocks_to(sceneout[0][0], sceneout[0][1], fxsendout[0][0], - fxsendout[0][1], block_size_quad); + fxsendout[0][1], BLOCK_SIZE_QUAD); send[0][1].MAC_2_blocks_to(sceneout[1][0], sceneout[1][1], fxsendout[0][0], - fxsendout[0][1], block_size_quad); + fxsendout[0][1], BLOCK_SIZE_QUAD); send1 = fx[4]->process_ringout(fxsendout[0][0], fxsendout[0][1], sc_a || sc_b); FX1.MAC_2_blocks_to(fxsendout[0][0], fxsendout[0][1], output[0], output[1], - block_size_quad); + BLOCK_SIZE_QUAD); } if (fx[5] && !(storage.getPatch().fx_disable.val.i & (1 << 5))) { send[1][0].MAC_2_blocks_to(sceneout[0][0], sceneout[0][1], fxsendout[1][0], - fxsendout[1][1], block_size_quad); + fxsendout[1][1], BLOCK_SIZE_QUAD); send[1][1].MAC_2_blocks_to(sceneout[1][0], sceneout[1][1], fxsendout[1][0], - fxsendout[1][1], block_size_quad); + fxsendout[1][1], BLOCK_SIZE_QUAD); send2 = fx[5]->process_ringout(fxsendout[1][0], fxsendout[1][1], sc_a || sc_b); FX2.MAC_2_blocks_to(fxsendout[1][0], fxsendout[1][1], output[0], output[1], - block_size_quad); + BLOCK_SIZE_QUAD); } } @@ -2446,24 +2446,24 @@ void SurgeSynthesizer::process() glob = fx[7]->process_ringout(output[0], output[1], glob); } - amp.multiply_2_blocks(output[0], output[1], block_size_quad); - amp_mute.multiply_2_blocks(output[0], output[1], block_size_quad); + amp.multiply_2_blocks(output[0], output[1], BLOCK_SIZE_QUAD); + amp_mute.multiply_2_blocks(output[0], output[1], BLOCK_SIZE_QUAD); // VU // falloff float a = storage.vu_falloff; vu_peak[0] = min(2.f, a * vu_peak[0]); vu_peak[1] = min(2.f, a * vu_peak[1]); - /*for(int i=0; i class lipol new_v = 0; v = 0; dv = 0; - setBlockSize(block_size); + setBlockSize(BLOCK_SIZE); } inline void newValue(T f) { diff --git a/src/common/dsp/FMOscillator.cpp b/src/common/dsp/FMOscillator.cpp index be8bb0a322b..e9762c02d65 100644 --- a/src/common/dsp/FMOscillator.cpp +++ b/src/common/dsp/FMOscillator.cpp @@ -44,7 +44,7 @@ void FMOscillator::process_block(float pitch, float drift, bool stereo, bool FM, FMdepth.newValue(32.0 * M_PI * fmdepth * fmdepth * fmdepth); FeedbackDepth.newValue(localcopy[oscdata->p[6].param_id_in_scene].f); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { RM1.process(); RM2.process(); @@ -65,7 +65,7 @@ void FMOscillator::process_block(float pitch, float drift, bool stereo, bool FM, } if (stereo) { - memcpy(outputR, output, sizeof(float) * block_size_os); + memcpy(outputR, output, sizeof(float) * BLOCK_SIZE_OS); } } @@ -149,7 +149,7 @@ void FM2Oscillator::process_block(float pitch, float drift, bool stereo, bool FM FeedbackDepth.newValue(localcopy[oscdata->p[6].param_id_in_scene].f); PhaseOffset.newValue(2.0 * M_PI * localcopy[oscdata->p[5].param_id_in_scene].f); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { RM1.process(); RM2.process(); @@ -169,7 +169,7 @@ void FM2Oscillator::process_block(float pitch, float drift, bool stereo, bool FM } if (stereo) { - memcpy(outputR, output, sizeof(float) * block_size_os); + memcpy(outputR, output, sizeof(float) * BLOCK_SIZE_OS); } } void FM2Oscillator::init_ctrltypes() diff --git a/src/common/dsp/FilterCoefficientMaker.cpp b/src/common/dsp/FilterCoefficientMaker.cpp index dda66e5d027..17772d7fed7 100644 --- a/src/common/dsp/FilterCoefficientMaker.cpp +++ b/src/common/dsp/FilterCoefficientMaker.cpp @@ -357,7 +357,7 @@ void FilterCoefficientMaker::Coeff_COMB(float freq, float reso, int subtype) float dtime = (1.f / 440.f) * note_to_pitch(-freq); dtime = dtime * dsamplerate_os - FIRoffset; // 1 sample for feedback, 1 sample for the IIR-filter without resonance - dtime = limit_range(dtime, (float)FIRipol_N, (float)max_fb_comb - FIRipol_N); + dtime = limit_range(dtime, (float)FIRipol_N, (float)MAX_FB_COMB - FIRipol_N); reso = ((subtype & 2) ? -1.0f : 1.0f) * limit_range(reso, 0.f, 1.f); float c[n_cm_coeffs]; @@ -396,7 +396,7 @@ void FilterCoefficientMaker::FromDirect(float N[n_cm_coeffs]) for (int i = 0; i < n_cm_coeffs; i++) { tC[i] = (1.f - smooth) * tC[i] + smooth * N[i]; - dC[i] = (tC[i] - C[i]) * block_size_os_inv; + dC[i] = (tC[i] - C[i]) * BLOCK_SIZE_OS_INV; } } } diff --git a/src/common/dsp/Oscillator.cpp b/src/common/dsp/Oscillator.cpp index 4fcd0bfff51..a5312d2d99f 100644 --- a/src/common/dsp/Oscillator.cpp +++ b/src/common/dsp/Oscillator.cpp @@ -73,7 +73,7 @@ void osc_sine::process_block(float pitch, float drift, bool stereo, bool FM, flo double omega = min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo)); FMdepth.newValue(fmdepth); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { output[k] = sin(phase); phase += omega + master_osc[k] * FMdepth.v; @@ -85,7 +85,7 @@ void osc_sine::process_block(float pitch, float drift, bool stereo, bool FM, flo driftlfo = drift_noise(driftlfo2); sinus.set_rate(min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo))); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { sinus.process(); output[k] = sinus.r; @@ -110,7 +110,7 @@ void osc_sine::process_block(float pitch, float drift, bool stereo, bool FM, flo } if (stereo) { - memcpy(outputR, output, sizeof(float) * block_size_os); + memcpy(outputR, output, sizeof(float) * BLOCK_SIZE_OS); } } @@ -155,7 +155,7 @@ void osc_audioinput::process_block(float pitch, float drift, bool stereo, bool F float a = g * (1.f - inp); float b = g * (1.f + inp); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { output[k] = a * storage->audio_in[0][k]; outputR[k] = b * storage->audio_in[1][k]; @@ -169,7 +169,7 @@ void osc_audioinput::process_block(float pitch, float drift, bool stereo, bool F float a = g * (1.f - inp); float b = g * (1.f + inp); - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { output[k] = a * storage->audio_in[0][k] + b * storage->audio_in[1][k]; } diff --git a/src/common/dsp/Oscillator.h b/src/common/dsp/Oscillator.h index e56e6295e6d..eed1e4409f7 100644 --- a/src/common/dsp/Oscillator.h +++ b/src/common/dsp/Oscillator.h @@ -9,8 +9,8 @@ class alignas(16) Oscillator // The data blocks processed by the SIMD instructions (e.g. SSE2), which must // always be before any other variables in the class, in order to be properly // aligned to 16 bytes. - float output alignas(16)[block_size_os]; - float outputR alignas(16)[block_size_os]; + float output alignas(16)[BLOCK_SIZE_OS]; + float outputR alignas(16)[BLOCK_SIZE_OS]; Oscillator(SurgeStorage* storage, OscillatorStorage* oscdata, pdata* localcopy); virtual ~Oscillator(); @@ -110,9 +110,9 @@ class AbstractBlitOscillator : public Oscillator AbstractBlitOscillator(SurgeStorage* storage, OscillatorStorage* oscdata, pdata* localcopy); protected: - float oscbuffer alignas(16)[ob_length + FIRipol_N]; - float oscbufferR alignas(16)[ob_length + FIRipol_N]; - float dcbuffer alignas(16)[ob_length + FIRipol_N]; + float oscbuffer alignas(16)[OB_LENGTH + FIRipol_N]; + float oscbufferR alignas(16)[OB_LENGTH + FIRipol_N]; + float dcbuffer alignas(16)[OB_LENGTH + FIRipol_N]; __m128 osc_out, osc_out2, osc_outR, osc_out2R; void prepare_unison(int voices); float integrator_hpf; @@ -120,17 +120,17 @@ class AbstractBlitOscillator : public Oscillator int n_unison; int bufpos; float out_attenuation, out_attenuation_inv, detune_bias, detune_offset; - float oscstate[max_unison], syncstate[max_unison], rate[max_unison]; - float driftlfo[max_unison], driftlfo2[max_unison]; - float panL[max_unison], panR[max_unison]; - int state[max_unison]; + float oscstate[MAX_UNISON], syncstate[MAX_UNISON], rate[MAX_UNISON]; + float driftlfo[MAX_UNISON], driftlfo2[MAX_UNISON]; + float panL[MAX_UNISON], panR[MAX_UNISON]; + int state[MAX_UNISON]; }; class SurgeSuperOscillator : public AbstractBlitOscillator { private: lipol_ps li_hpf, li_DC, li_integratormult; - float FMphase alignas(16)[block_size_os + 4]; + float FMphase alignas(16)[BLOCK_SIZE_OS + 4]; public: SurgeSuperOscillator(SurgeStorage* storage, OscillatorStorage* oscdata, pdata* localcopy); @@ -144,8 +144,8 @@ class SurgeSuperOscillator : public AbstractBlitOscillator private: bool first_run; - float dc, dc_uni[max_unison], elapsed_time[max_unison], last_level[max_unison], - pwidth[max_unison], pwidth2[max_unison]; + float dc, dc_uni[MAX_UNISON], elapsed_time[MAX_UNISON], last_level[MAX_UNISON], + pwidth[MAX_UNISON], pwidth2[MAX_UNISON]; template void update_lagvals(); float pitch; lag FMdepth, integrator_mult, l_pw, l_pw2, l_shape, l_sub, l_sync; @@ -185,8 +185,8 @@ class SampleAndHoldOscillator : public AbstractBlitOscillator template void process_blockT(float pitch, float depth, float drift = 0); template void update_lagvals(); bool first_run; - float dc, dc_uni[max_unison], elapsed_time[max_unison], last_level[max_unison], - last_level2[max_unison], pwidth[max_unison]; + float dc, dc_uni[MAX_UNISON], elapsed_time[MAX_UNISON], last_level[MAX_UNISON], + last_level2[MAX_UNISON], pwidth[MAX_UNISON]; float pitch; lag FMdepth, hpf_coeff, integrator_mult, l_pw, l_shape, l_smooth, l_sub, l_sync; int id_pw, id_shape, id_smooth, id_sub, id_sync, id_detune; @@ -211,10 +211,10 @@ class WavetableOscillator : public AbstractBlitOscillator template void update_lagvals(); inline float distort_level(float); bool first_run; - float oscpitch[max_unison]; - float dc, dc_uni[max_unison], last_level[max_unison]; + float oscpitch[MAX_UNISON]; + float dc, dc_uni[MAX_UNISON], last_level[MAX_UNISON]; float pitch; - int mipmap[max_unison], mipmap_ofs[max_unison]; + int mipmap[MAX_UNISON], mipmap_ofs[MAX_UNISON]; lag FMdepth, hpf_coeff, integrator_mult, l_hskew, l_vskew, l_clip, l_shape; float formant_t, formant_last, pitch_last, pitch_t; float tableipol, last_tableipol; @@ -232,8 +232,8 @@ const int wt2_suboscs = 8; class WindowOscillator : public Oscillator { private: - int IOutputL alignas(16)[block_size_os]; - int IOutputR alignas(16)[block_size_os]; + int IOutputL alignas(16)[BLOCK_SIZE_OS]; + int IOutputR alignas(16)[BLOCK_SIZE_OS]; struct { unsigned int Pos[wt2_suboscs]; diff --git a/src/common/dsp/QuadFilterChain.cpp b/src/common/dsp/QuadFilterChain.cpp index b574ce4895d..cc39a5cbc7c 100644 --- a/src/common/dsp/QuadFilterChain.cpp +++ b/src/common/dsp/QuadFilterChain.cpp @@ -37,7 +37,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O switch (config) { case fb_serial: // no feedback at all (saves CPU) - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { __m128 input = d.DL[k]; __m128 x = input, y = d.DR[k]; @@ -73,7 +73,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_serial2: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 input = vMul(d.FB, d.FBlineL); @@ -113,7 +113,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O break; case fb_serial3: // filter 2 is only heard in the feedback path, good for physical modelling with // comb as f2 - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 input = vMul(d.FB, d.FBlineL); @@ -154,7 +154,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_dual: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 fb = _mm_mul_ps(d.FB, d.FBlineL); @@ -187,7 +187,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_dual2: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 fb = _mm_mul_ps(d.FB, d.FBlineL); @@ -220,7 +220,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_ring: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 fb = _mm_mul_ps(d.FB, d.FBlineL); @@ -255,7 +255,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_stereo: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 fb = _mm_mul_ps(d.FB, d.FBlineL); @@ -292,7 +292,7 @@ void ProcessFBQuad(QuadFilterChainState& d, fbq_global& g, float* OutL, float* O } break; case fb_wide: - for (int k = 0; k < block_size_os; k++) + for (int k = 0; k < BLOCK_SIZE_OS; k++) { d.FB = _mm_add_ps(d.FB, d.dFB); __m128 fbL = _mm_mul_ps(d.FB, d.FBlineL); diff --git a/src/common/dsp/QuadFilterChain.h b/src/common/dsp/QuadFilterChain.h index e9f431573d0..163b7fbf251 100644 --- a/src/common/dsp/QuadFilterChain.h +++ b/src/common/dsp/QuadFilterChain.h @@ -10,7 +10,7 @@ struct QuadFilterChainState __m128 wsLPF, FBlineL, FBlineR; - __m128 DL[block_size_os], DR[block_size_os]; // wavedata + __m128 DL[BLOCK_SIZE_OS], DR[BLOCK_SIZE_OS]; // wavedata __m128 OutL, OutR, dOutL, dOutR; __m128 Out2L, Out2R, dOut2L, dOut2R; // fb_stereo only diff --git a/src/common/dsp/QuadFilterUnit.cpp b/src/common/dsp/QuadFilterUnit.cpp index e910716fe42..b8fe48fa438 100644 --- a/src/common/dsp/QuadFilterUnit.cpp +++ b/src/common/dsp/QuadFilterUnit.cpp @@ -530,7 +530,7 @@ __m128 COMBquad_SSE1(QuadFilterUnitState* __restrict f, __m128 in) int DT = e >> 8; int SE = (0xff - (e & 0xff)) * (FIRipol_N << 1); - int RP = (f->WP[i] - DT - FIRoffset) & (max_fb_comb - 1); + int RP = (f->WP[i] - DT - FIRoffset) & (MAX_FB_COMB - 1); // SINC interpolation (12 samples) __m128 a = _mm_loadu_ps(&f->DB[i][RP]); @@ -560,10 +560,10 @@ __m128 COMBquad_SSE1(QuadFilterUnitState* __restrict f, __m128 in) __m128 t = _mm_load_ss((float*)&d + i); _mm_store_ss(&f->DB[i][f->WP[i]], t); if (f->WP[i] < FIRipol_N) - _mm_store_ss(&f->DB[i][f->WP[i] + max_fb_comb], t); + _mm_store_ss(&f->DB[i][f->WP[i] + MAX_FB_COMB], t); // Increment write position - f->WP[i] = (f->WP[i] + 1) & (max_fb_comb - 1); + f->WP[i] = (f->WP[i] + 1) & (MAX_FB_COMB - 1); } } return _mm_add_ps(_mm_mul_ps(f->C[3], DBRead), _mm_mul_ps(f->C[2], in)); @@ -594,7 +594,7 @@ __m128 COMBquad_SSE2(QuadFilterUnitState* __restrict f, __m128 in) { if (f->active[i]) { - int RP = (f->WP[i] - DTi[i] - FIRoffset) & (max_fb_comb - 1); + int RP = (f->WP[i] - DTi[i] - FIRoffset) & (MAX_FB_COMB - 1); // SINC interpolation (12 samples) __m128 a = _mm_loadu_ps(&f->DB[i][RP]); @@ -625,10 +625,10 @@ __m128 COMBquad_SSE2(QuadFilterUnitState* __restrict f, __m128 in) __m128 t = _mm_load_ss((float*)&d + i); _mm_store_ss(&f->DB[i][f->WP[i]], t); if (f->WP[i] < FIRipol_N) - _mm_store_ss(&f->DB[i][f->WP[i] + max_fb_comb], t); + _mm_store_ss(&f->DB[i][f->WP[i] + MAX_FB_COMB], t); // Increment write position - f->WP[i] = (f->WP[i] + 1) & (max_fb_comb - 1); + f->WP[i] = (f->WP[i] + 1) & (MAX_FB_COMB - 1); } } return _mm_add_ps(_mm_mul_ps(f->C[3], DBRead), _mm_mul_ps(f->C[2], in)); diff --git a/src/common/dsp/SampleAndHoldOscillator.cpp b/src/common/dsp/SampleAndHoldOscillator.cpp index d2bf9c9088d..881af07211b 100644 --- a/src/common/dsp/SampleAndHoldOscillator.cpp +++ b/src/common/dsp/SampleAndHoldOscillator.cpp @@ -48,7 +48,7 @@ void SampleAndHoldOscillator::init(float pitch, bool is_display) l_sub.setRate(rate); l_sync.setRate(rate); - n_unison = limit_range(oscdata->p[6].val.i, 1, max_unison); + n_unison = limit_range(oscdata->p[6].val.i, 1, MAX_UNISON); if (is_display) { n_unison = 1; @@ -56,11 +56,11 @@ void SampleAndHoldOscillator::init(float pitch, bool is_display) } prepare_unison(n_unison); - memset(oscbuffer, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(oscbufferR, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(last_level, 0, max_unison * sizeof(float)); - memset(last_level2, 0, max_unison * sizeof(float)); - memset(elapsed_time, 0, max_unison * sizeof(float)); + memset(oscbuffer, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(oscbufferR, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(last_level, 0, MAX_UNISON * sizeof(float)); + memset(last_level2, 0, MAX_UNISON * sizeof(float)); + memset(elapsed_time, 0, MAX_UNISON * sizeof(float)); this->pitch = pitch; update_lagvals(); @@ -295,7 +295,7 @@ void SampleAndHoldOscillator::process_block( { for (l = 0; l < n_unison; l++) driftlfo[l] = drift_noise(driftlfo2[l]); - for (int s = 0; s < block_size_os; s++) + for (int s = 0; s < BLOCK_SIZE_OS; s++) { float fmmul = limit_range(1.f + depth * master_osc[s], 0.1f, 1.9f); float a = pitchmult * fmmul; @@ -315,7 +315,7 @@ void SampleAndHoldOscillator::process_block( } else { - float a = (float)block_size_os * pitchmult; + float a = (float)BLOCK_SIZE_OS * pitchmult; for (l = 0; l < n_unison; l++) { driftlfo[l] = drift_noise(driftlfo2[l]); @@ -329,14 +329,14 @@ void SampleAndHoldOscillator::process_block( } } - float hpfblock alignas(16)[block_size_os]; - li_hpf.store_block(hpfblock, block_size_os_quad); + float hpfblock alignas(16)[BLOCK_SIZE_OS]; + li_hpf.store_block(hpfblock, BLOCK_SIZE_OS_QUAD); __m128 mdc = _mm_load_ss(&dc); __m128 oa = _mm_load_ss(&out_attenuation); oa = _mm_mul_ss(oa, _mm_load_ss(&pitchmult)); - for (k = 0; k < block_size_os; k++) + for (k = 0; k < BLOCK_SIZE_OS; k++) { __m128 hpf = _mm_load_ss(&hpfblock[k]); __m128 ob = _mm_load_ss(&oscbuffer[bufpos + k]); @@ -357,12 +357,12 @@ void SampleAndHoldOscillator::process_block( } _mm_store_ss(&dc, mdc); - clear_block(&oscbuffer[bufpos], block_size_os_quad); + clear_block(&oscbuffer[bufpos], BLOCK_SIZE_OS_QUAD); if (stereo) - clear_block(&oscbufferR[bufpos], block_size_os_quad); - clear_block(&dcbuffer[bufpos], block_size_os_quad); + clear_block(&oscbufferR[bufpos], BLOCK_SIZE_OS_QUAD); + clear_block(&dcbuffer[bufpos], BLOCK_SIZE_OS_QUAD); - bufpos = (bufpos + block_size_os) & (ob_length - 1); + bufpos = (bufpos + BLOCK_SIZE_OS) & (OB_LENGTH - 1); // each block overlap FIRipol_N samples into the next (due to impulses not being wrapped around // the block edges copy the overlapping samples to the new block position @@ -373,14 +373,14 @@ void SampleAndHoldOscillator::process_block( const __m128 zero = _mm_setzero_ps(); for (k = 0; k < (FIRipol_N); k += 4) { - overlap[k >> 2] = _mm_load_ps(&oscbuffer[ob_length + k]); + overlap[k >> 2] = _mm_load_ps(&oscbuffer[OB_LENGTH + k]); _mm_store_ps(&oscbuffer[k], overlap[k >> 2]); - _mm_store_ps(&oscbuffer[ob_length + k], zero); + _mm_store_ps(&oscbuffer[OB_LENGTH + k], zero); if (stereo) { - overlapR[k >> 2] = _mm_load_ps(&oscbufferR[ob_length + k]); + overlapR[k >> 2] = _mm_load_ps(&oscbufferR[OB_LENGTH + k]); _mm_store_ps(&oscbufferR[k], overlapR[k >> 2]); - _mm_store_ps(&oscbufferR[ob_length + k], zero); + _mm_store_ps(&oscbufferR[OB_LENGTH + k], zero); } } } diff --git a/src/common/dsp/SurgeSuperOscillator.cpp b/src/common/dsp/SurgeSuperOscillator.cpp index 665c03cefe5..104fc80de27 100644 --- a/src/common/dsp/SurgeSuperOscillator.cpp +++ b/src/common/dsp/SurgeSuperOscillator.cpp @@ -122,16 +122,16 @@ void SurgeSuperOscillator::init(float pitch, bool is_display) l_sub.setRate(rate); l_sync.setRate(rate); - n_unison = limit_range(oscdata->p[6].val.i, 1, max_unison); + n_unison = limit_range(oscdata->p[6].val.i, 1, MAX_UNISON); if (is_display) n_unison = 1; prepare_unison(n_unison); - memset(oscbuffer, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(oscbufferR, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(dcbuffer, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(last_level, 0, max_unison * sizeof(float)); - memset(elapsed_time, 0, max_unison * sizeof(float)); + memset(oscbuffer, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(oscbufferR, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(dcbuffer, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(last_level, 0, MAX_UNISON * sizeof(float)); + memset(elapsed_time, 0, MAX_UNISON * sizeof(float)); this->pitch = pitch; update_lagvals(); @@ -418,7 +418,7 @@ void SurgeSuperOscillator::process_block( { for (l = 0; l < n_unison; l++) driftlfo[l] = drift_noise(driftlfo2[l]); - for (int s = 0; s < block_size_os; s++) + for (int s = 0; s < BLOCK_SIZE_OS; s++) { float fmmul = limit_range(1.f + depth * master_osc[s], 0.1f, 1.9f); float a = pitchmult * fmmul; @@ -442,7 +442,7 @@ void SurgeSuperOscillator::process_block( } else { - float a = (float)block_size_os * pitchmult; + float a = (float)BLOCK_SIZE_OS * pitchmult; for (l = 0; l < n_unison; l++) { driftlfo[l] = drift_noise(driftlfo2[l]); @@ -458,8 +458,8 @@ void SurgeSuperOscillator::process_block( } } - float hpfblock alignas(16)[block_size_os]; - li_hpf.store_block(hpfblock, block_size_os_quad); + float hpfblock alignas(16)[BLOCK_SIZE_OS]; + li_hpf.store_block(hpfblock, BLOCK_SIZE_OS_QUAD); __m128 mdc = _mm_load_ss(&dc); __m128 oa = _mm_load_ss(&out_attenuation); @@ -470,7 +470,7 @@ void SurgeSuperOscillator::process_block( __m128 char_b1 = _mm_load_ss(&CoefB1); __m128 char_a1 = _mm_load_ss(&CoefA1); - for (k = 0; k < block_size_os; k++) + for (k = 0; k < BLOCK_SIZE_OS; k++) { __m128 dcb = _mm_load_ss(&dcbuffer[bufpos + k]); __m128 hpf = _mm_load_ss(&hpfblock[k]); @@ -508,12 +508,12 @@ void SurgeSuperOscillator::process_block( } _mm_store_ss(&dc, mdc); - clear_block(&oscbuffer[bufpos], block_size_os_quad); + clear_block(&oscbuffer[bufpos], BLOCK_SIZE_OS_QUAD); if (stereo) - clear_block(&oscbufferR[bufpos], block_size_os_quad); - clear_block(&dcbuffer[bufpos], block_size_os_quad); + clear_block(&oscbufferR[bufpos], BLOCK_SIZE_OS_QUAD); + clear_block(&dcbuffer[bufpos], BLOCK_SIZE_OS_QUAD); - bufpos = (bufpos + block_size_os) & (ob_length - 1); + bufpos = (bufpos + BLOCK_SIZE_OS) & (OB_LENGTH - 1); // each block overlap FIRipol_N samples into the next (due to impulses not being wrapped around // the block edges copy the overlapping samples to the new block position @@ -524,19 +524,19 @@ void SurgeSuperOscillator::process_block( const __m128 zero = _mm_setzero_ps(); for (k = 0; k < (FIRipol_N); k += 4) { - overlap[k >> 2] = _mm_load_ps(&oscbuffer[ob_length + k]); + overlap[k >> 2] = _mm_load_ps(&oscbuffer[OB_LENGTH + k]); _mm_store_ps(&oscbuffer[k], overlap[k >> 2]); - _mm_store_ps(&oscbuffer[ob_length + k], zero); + _mm_store_ps(&oscbuffer[OB_LENGTH + k], zero); - dcoverlap[k >> 2] = _mm_load_ps(&dcbuffer[ob_length + k]); + dcoverlap[k >> 2] = _mm_load_ps(&dcbuffer[OB_LENGTH + k]); _mm_store_ps(&dcbuffer[k], dcoverlap[k >> 2]); - _mm_store_ps(&dcbuffer[ob_length + k], zero); + _mm_store_ps(&dcbuffer[OB_LENGTH + k], zero); if (stereo) { - overlapR[k >> 2] = _mm_load_ps(&oscbufferR[ob_length + k]); + overlapR[k >> 2] = _mm_load_ps(&oscbufferR[OB_LENGTH + k]); _mm_store_ps(&oscbufferR[k], overlapR[k >> 2]); - _mm_store_ps(&oscbufferR[ob_length + k], zero); + _mm_store_ps(&oscbufferR[OB_LENGTH + k], zero); } } } diff --git a/src/common/dsp/SurgeVoice.cpp b/src/common/dsp/SurgeVoice.cpp index 83a53cd7608..34a406ac982 100644 --- a/src/common/dsp/SurgeVoice.cpp +++ b/src/common/dsp/SurgeVoice.cpp @@ -453,9 +453,9 @@ template void SurgeVoice::calc_ctrldata(QuadFilterChainState* Q, in if (Q) { set1f(Q->Out2L, e, FBP.Out2L); - set1f(Q->dOut2L, e, (amp2L - FBP.Out2L) * block_size_os_inv); + set1f(Q->dOut2L, e, (amp2L - FBP.Out2L) * BLOCK_SIZE_OS_INV); set1f(Q->Out2R, e, FBP.Out2R); - set1f(Q->dOut2R, e, (amp2R - FBP.Out2R) * block_size_os_inv); + set1f(Q->dOut2R, e, (amp2R - FBP.Out2R) * BLOCK_SIZE_OS_INV); } FBP.Out2L = amp2L; FBP.Out2R = amp2R; @@ -467,9 +467,9 @@ template void SurgeVoice::calc_ctrldata(QuadFilterChainState* Q, in if (Q) { set1f(Q->OutL, e, FBP.OutL); - set1f(Q->dOutL, e, (ampL - FBP.OutL) * block_size_os_inv); + set1f(Q->dOutL, e, (ampL - FBP.OutL) * BLOCK_SIZE_OS_INV); set1f(Q->OutR, e, FBP.OutR); - set1f(Q->dOutR, e, (ampR - FBP.OutR) * block_size_os_inv); + set1f(Q->dOutR, e, (ampR - FBP.OutR) * BLOCK_SIZE_OS_INV); } FBP.OutL = ampL; @@ -481,8 +481,8 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) calc_ctrldata<0>(&Q, Qe); bool is_wide = scene->filterblock_configuration.val.i == fb_wide; - float tblock alignas(16)[block_size_os], - tblock2 alignas(16)[block_size_os]; + float tblock alignas(16)[BLOCK_SIZE_OS], + tblock2 alignas(16)[BLOCK_SIZE_OS]; float* tblockR = is_wide ? tblock2 : tblock; // float ktrkroot = (float)scene->keytrack_root.val.i; @@ -490,8 +490,8 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) float drift = localcopy[scene->drift.param_id_in_scene].f; // clear output - clear_block(output[0], block_size_os_quad); - clear_block(output[1], block_size_os_quad); + clear_block(output[0], BLOCK_SIZE_OS_QUAD); + clear_block(output[1], BLOCK_SIZE_OS_QUAD); if (osc3 || ring23 || ((osc1 || osc2) && (FMmode == fm_3to2to1)) || (osc1 && (FMmode == fm_2and3to1))) @@ -507,16 +507,16 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) if (is_wide) { osclevels[le_osc3].multiply_2_blocks_to(osc[2]->output, osc[2]->outputR, tblock, - tblockR, block_size_os_quad); + tblockR, BLOCK_SIZE_OS_QUAD); } else { - osclevels[le_osc3].multiply_block_to(osc[2]->output, tblock, block_size_os_quad); + osclevels[le_osc3].multiply_block_to(osc[2]->output, tblock, BLOCK_SIZE_OS_QUAD); } if (route[2] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[2] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } } @@ -544,17 +544,17 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) if (is_wide) { osclevels[le_osc2].multiply_2_blocks_to(osc[1]->output, osc[1]->outputR, tblock, - tblockR, block_size_os_quad); + tblockR, BLOCK_SIZE_OS_QUAD); } else { - osclevels[le_osc2].multiply_block_to(osc[1]->output, tblock, block_size_os_quad); + osclevels[le_osc2].multiply_block_to(osc[1]->output, tblock, BLOCK_SIZE_OS_QUAD); } if (route[1] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[1] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } } @@ -562,7 +562,7 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) { if (FMmode == fm_2and3to1) { - add_block(osc[1]->output, osc[2]->output, fmbuffer, block_size_os_quad); + add_block(osc[1]->output, osc[2]->output, fmbuffer, BLOCK_SIZE_OS_QUAD); osc[0]->process_block((scene->osc[0].keytrack.val.b ? state.pitch : ktrkroot) + localcopy[scene->osc[0].pitch.param_id_in_scene].f * (scene->osc[0].pitch.extend_range ? 12.f : 1.f) + @@ -592,16 +592,16 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) if (is_wide) { osclevels[le_osc1].multiply_2_blocks_to(osc[0]->output, osc[0]->outputR, tblock, - tblockR, block_size_os_quad); + tblockR, BLOCK_SIZE_OS_QUAD); } else { - osclevels[le_osc1].multiply_block_to(osc[0]->output, tblock, block_size_os_quad); + osclevels[le_osc1].multiply_block_to(osc[0]->output, tblock, BLOCK_SIZE_OS_QUAD); } if (route[0] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[0] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } } @@ -609,45 +609,45 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) { if (is_wide) { - mul_block(osc[0]->output, osc[1]->output, tblock, block_size_os_quad); - mul_block(osc[0]->outputR, osc[1]->outputR, tblockR, block_size_os_quad); - osclevels[le_ring12].multiply_2_blocks(tblock, tblockR, block_size_os_quad); + mul_block(osc[0]->output, osc[1]->output, tblock, BLOCK_SIZE_OS_QUAD); + mul_block(osc[0]->outputR, osc[1]->outputR, tblockR, BLOCK_SIZE_OS_QUAD); + osclevels[le_ring12].multiply_2_blocks(tblock, tblockR, BLOCK_SIZE_OS_QUAD); } else { - mul_block(osc[0]->output, osc[1]->output, tblock, block_size_os_quad); - osclevels[le_ring12].multiply_block(tblock, block_size_os_quad); + mul_block(osc[0]->output, osc[1]->output, tblock, BLOCK_SIZE_OS_QUAD); + osclevels[le_ring12].multiply_block(tblock, BLOCK_SIZE_OS_QUAD); } if (route[3] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[3] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } if (ring23) { if (is_wide) { - mul_block(osc[1]->output, osc[2]->output, tblock, block_size_os_quad); - mul_block(osc[1]->outputR, osc[2]->outputR, tblockR, block_size_os_quad); - osclevels[le_ring23].multiply_2_blocks(tblock, tblockR, block_size_os_quad); + mul_block(osc[1]->output, osc[2]->output, tblock, BLOCK_SIZE_OS_QUAD); + mul_block(osc[1]->outputR, osc[2]->outputR, tblockR, BLOCK_SIZE_OS_QUAD); + osclevels[le_ring23].multiply_2_blocks(tblock, tblockR, BLOCK_SIZE_OS_QUAD); } else { - mul_block(osc[1]->output, osc[2]->output, tblock, block_size_os_quad); - osclevels[le_ring23].multiply_block(tblock, block_size_os_quad); + mul_block(osc[1]->output, osc[2]->output, tblock, BLOCK_SIZE_OS_QUAD); + osclevels[le_ring23].multiply_block(tblock, BLOCK_SIZE_OS_QUAD); } if (route[4] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[4] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } if (noise) { float noisecol = limit_range(localcopy[scene->noise_colour.param_id_in_scene].f, -1.f, 1.f); - for (int i = 0; i < block_size_os; i += 2) + for (int i = 0; i < BLOCK_SIZE_OS; i += 2) { ((float*)tblock)[i] = correlated_noise_o2mk2(noisegenL[0], noisegenL[1], noisecol); ((float*)tblock)[i + 1] = ((float*)tblock)[i]; @@ -659,22 +659,22 @@ bool SurgeVoice::process_block(QuadFilterChainState& Q, int Qe) } if (is_wide) { - osclevels[le_noise].multiply_2_blocks(tblock, tblockR, block_size_os_quad); + osclevels[le_noise].multiply_2_blocks(tblock, tblockR, BLOCK_SIZE_OS_QUAD); } else { - osclevels[le_noise].multiply_block(tblock, block_size_os_quad); + osclevels[le_noise].multiply_block(tblock, BLOCK_SIZE_OS_QUAD); } if (route[5] < 2) - accumulate_block(tblock, output[0], block_size_os_quad); + accumulate_block(tblock, output[0], BLOCK_SIZE_OS_QUAD); if (route[5] > 0) - accumulate_block(tblockR, output[1], block_size_os_quad); + accumulate_block(tblockR, output[1], BLOCK_SIZE_OS_QUAD); } // PFG - osclevels[le_pfg].multiply_2_blocks(output[0], output[1], block_size_os_quad); + osclevels[le_pfg].multiply_2_blocks(output[0], output[1], BLOCK_SIZE_OS_QUAD); - for (int i = 0; i < block_size_os; i++) + for (int i = 0; i < BLOCK_SIZE_OS; i++) { _mm_store_ss(((float*)&Q.DL[i] + Qe), _mm_load_ss(&output[0][i])); _mm_store_ss(((float*)&Q.DR[i] + Qe), _mm_load_ss(&output[1][i])); @@ -730,15 +730,15 @@ void SurgeVoice::SetQFB(QuadFilterChainState* Q, int e) // Q == 0 means init(ial if (Q) { set1f(Q->Gain, e, FBP.Gain); - set1f(Q->dGain, e, (Gain - FBP.Gain) * block_size_os_inv); + set1f(Q->dGain, e, (Gain - FBP.Gain) * BLOCK_SIZE_OS_INV); set1f(Q->Drive, e, FBP.Drive); - set1f(Q->dDrive, e, (Drive - FBP.Drive) * block_size_os_inv); + set1f(Q->dDrive, e, (Drive - FBP.Drive) * BLOCK_SIZE_OS_INV); set1f(Q->FB, e, FBP.FB); - set1f(Q->dFB, e, (FB - FBP.FB) * block_size_os_inv); + set1f(Q->dFB, e, (FB - FBP.FB) * BLOCK_SIZE_OS_INV); set1f(Q->Mix1, e, FBP.Mix1); - set1f(Q->dMix1, e, (FMix1 - FBP.Mix1) * block_size_os_inv); + set1f(Q->dMix1, e, (FMix1 - FBP.Mix1) * BLOCK_SIZE_OS_INV); set1f(Q->Mix2, e, FBP.Mix2); - set1f(Q->dMix2, e, (FMix2 - FBP.Mix2) * block_size_os_inv); + set1f(Q->dMix2, e, (FMix2 - FBP.Mix2) * BLOCK_SIZE_OS_INV); } FBP.Gain = Gain; diff --git a/src/common/dsp/SurgeVoice.h b/src/common/dsp/SurgeVoice.h index 2fe906d5446..fdf66e87ce9 100644 --- a/src/common/dsp/SurgeVoice.h +++ b/src/common/dsp/SurgeVoice.h @@ -16,10 +16,10 @@ struct QuadFilterChainState; class SurgeVoice { public: - float output alignas(16)[2][block_size_os]; + float output alignas(16)[2][BLOCK_SIZE_OS]; lipol_ps osclevels alignas(16)[7]; pdata localcopy alignas(16)[n_scene_params]; - float fmbuffer alignas(16)[block_size_os]; + float fmbuffer alignas(16)[BLOCK_SIZE_OS]; // used for the 2>1<3 FM-mode (Needs the pointer earlier) SurgeVoice(SurgeStorage* storage, @@ -62,7 +62,7 @@ class SurgeVoice struct { float Gain, FB, Mix1, Mix2, OutL, OutR, Out2L, Out2R, Drive, wsLPF, FBlineL, FBlineR; - float Delay[4][max_fb_comb + FIRipol_N]; + float Delay[4][MAX_FB_COMB + FIRipol_N]; struct { float C[n_cm_coeffs], R[n_filter_registers]; diff --git a/src/common/dsp/WavetableOscillator.cpp b/src/common/dsp/WavetableOscillator.cpp index 1937b5073c6..0d2e62939a9 100644 --- a/src/common/dsp/WavetableOscillator.cpp +++ b/src/common/dsp/WavetableOscillator.cpp @@ -38,7 +38,7 @@ void WavetableOscillator::init(float pitch, bool is_display) l_vskew.setRate(rate); l_hskew.setRate(rate); - n_unison = limit_range(oscdata->p[6].val.i, 1, max_unison); + n_unison = limit_range(oscdata->p[6].val.i, 1, MAX_UNISON); if (oscdata->wt.flags & wtf_is_sample) { sampleloop = n_unison; @@ -49,9 +49,9 @@ void WavetableOscillator::init(float pitch, bool is_display) prepare_unison(n_unison); - memset(oscbuffer, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(oscbufferR, 0, sizeof(float) * (ob_length + FIRipol_N)); - memset(last_level, 0, max_unison * sizeof(float)); + memset(oscbuffer, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(oscbufferR, 0, sizeof(float) * (OB_LENGTH + FIRipol_N)); + memset(last_level, 0, MAX_UNISON * sizeof(float)); pitch_last = pitch; pitch_t = pitch; @@ -139,7 +139,7 @@ float WavetableOscillator::distort_level(float x) void WavetableOscillator::convolute(int voice, bool FM, bool stereo) { - float block_pos = oscstate[voice] * block_size_os_inv * pitchmult_inv; + float block_pos = oscstate[voice] * BLOCK_SIZE_OS_INV * pitchmult_inv; double detune = drift * driftlfo[voice]; if (n_unison > 1) @@ -425,11 +425,11 @@ void WavetableOscillator::process_block( { /*FMfilter.coeff_HP(FMfilter.calc_omega(pitch_t - 24.f - 48.f * oscdata->p[id_detune].val.f),0.707); FMfilter.process_block(&master_osc[0]); - FMfilter.process_block(&master_osc[block_size]);*/ + FMfilter.process_block(&master_osc[BLOCK_SIZE]);*/ for (l = 0; l < n_unison; l++) driftlfo[l] = drift_noise(driftlfo2[l]); - for (int s = 0; s < block_size_os; s++) + for (int s = 0; s < BLOCK_SIZE_OS; s++) { float fmmul = limit_range(1.f + depth * master_osc[s], 0.1f, 1.9f); float a = pitchmult * fmmul; @@ -449,7 +449,7 @@ void WavetableOscillator::process_block( } else { - float a = (float)block_size_os * pitchmult; + float a = (float)BLOCK_SIZE_OS * pitchmult; for (l = 0; l < n_unison; l++) { driftlfo[l] = drift_noise(driftlfo2[l]); @@ -460,10 +460,10 @@ void WavetableOscillator::process_block( // li_DC.set_target(dc); } - float hpfblock alignas(16)[block_size_os]; - li_hpf.store_block(hpfblock, block_size_os_quad); + float hpfblock alignas(16)[BLOCK_SIZE_OS]; + li_hpf.store_block(hpfblock, BLOCK_SIZE_OS_QUAD); - for (k = 0; k < block_size_os; k++) + for (k = 0; k < BLOCK_SIZE_OS; k++) { __m128 hpf = _mm_load_ss(&hpfblock[k]); __m128 ob = _mm_load_ss(&oscbuffer[bufpos + k]); @@ -479,11 +479,11 @@ void WavetableOscillator::process_block( } } - clear_block(&oscbuffer[bufpos], block_size_os_quad); + clear_block(&oscbuffer[bufpos], BLOCK_SIZE_OS_QUAD); if (stereo) - clear_block(&oscbufferR[bufpos], block_size_os_quad); + clear_block(&oscbufferR[bufpos], BLOCK_SIZE_OS_QUAD); - bufpos = (bufpos + block_size_os) & (ob_length - 1); + bufpos = (bufpos + BLOCK_SIZE_OS) & (OB_LENGTH - 1); // each block overlap FIRipol_N samples into the next (due to impulses not being wrapped around // the block edges copy the overlapping samples to the new block position @@ -494,14 +494,14 @@ void WavetableOscillator::process_block( const __m128 zero = _mm_setzero_ps(); for (k = 0; k < (FIRipol_N); k += 4) { - overlap[k >> 2] = _mm_load_ps(&oscbuffer[ob_length + k]); + overlap[k >> 2] = _mm_load_ps(&oscbuffer[OB_LENGTH + k]); _mm_store_ps(&oscbuffer[k], overlap[k >> 2]); - _mm_store_ps(&oscbuffer[ob_length + k], zero); + _mm_store_ps(&oscbuffer[OB_LENGTH + k], zero); if (stereo) { - overlapR[k >> 2] = _mm_load_ps(&oscbufferR[ob_length + k]); + overlapR[k >> 2] = _mm_load_ps(&oscbufferR[OB_LENGTH + k]); _mm_store_ps(&oscbufferR[k], overlapR[k >> 2]); - _mm_store_ps(&oscbufferR[ob_length + k], zero); + _mm_store_ps(&oscbufferR[OB_LENGTH + k], zero); } } } diff --git a/src/common/dsp/WindowOscillator.cpp b/src/common/dsp/WindowOscillator.cpp index 880b1e0df68..ee9bf43bd0d 100644 --- a/src/common/dsp/WindowOscillator.cpp +++ b/src/common/dsp/WindowOscillator.cpp @@ -166,7 +166,7 @@ void WindowOscillator::ProcessSubOscs(bool stereo) short* WaveAdr = oscdata->wt.TableI16WeakPointers[MipMapB][Sub.Table[so]]; short* WinAdr = storage->WindowWT.TableI16WeakPointers[MipMapA][Window]; - for (int i = 0; i < block_size_os; i++) + for (int i = 0; i < BLOCK_SIZE_OS; i++) { Pos += RatioA; if (Pos & ~SizeMaskWin) @@ -249,7 +249,7 @@ void WindowOscillator::ProcessSubOscs(bool stereo) short* WaveAdr = oscdata->wt.TableI16WeakPointers[MipMapB][Sub.Table[so]]; short* WinAdr = storage->WindowWT.TableI16WeakPointers[MipMapA][Window]; - for (int i = 0; i < block_size_os; i++) + for (int i = 0; i < BLOCK_SIZE_OS; i++) { Pos += RatioA; if (Pos & ~SizeMaskWin) @@ -302,9 +302,9 @@ void WindowOscillator::ProcessSubOscs(bool stereo) void WindowOscillator::process_block(float pitch, float drift, bool stereo, bool FM, float fmdepth) { - memset(IOutputL, 0, block_size_os * sizeof(int)); + memset(IOutputL, 0, BLOCK_SIZE_OS * sizeof(int)); if (stereo) - memset(IOutputR, 0, block_size_os * sizeof(int)); + memset(IOutputR, 0, BLOCK_SIZE_OS * sizeof(int)); float Detune = localcopy[oscdata->p[5].param_id_in_scene].f; for (int l = 0; l < ActiveSubOscs; l++) @@ -328,7 +328,7 @@ void WindowOscillator::process_block(float pitch, float drift, bool stereo, bool // SSE2 path if (stereo) { - for (int i = 0; i < block_size_os; i += 4) + for (int i = 0; i < BLOCK_SIZE_OS; i += 4) { _mm_store_ps(&output[i], _mm_mul_ps(_mm_cvtepi32_ps(*(__m128i*)&IOutputL[i]), scale)); _mm_store_ps(&outputR[i], _mm_mul_ps(_mm_cvtepi32_ps(*(__m128i*)&IOutputR[i]), scale)); @@ -336,7 +336,7 @@ void WindowOscillator::process_block(float pitch, float drift, bool stereo, bool } else { - for (int i = 0; i < block_size_os; i += 4) + for (int i = 0; i < BLOCK_SIZE_OS; i += 4) { _mm_store_ps(&output[i], _mm_mul_ps(_mm_cvtepi32_ps(*(__m128i*)&IOutputL[i]), scale)); } @@ -348,7 +348,7 @@ void WindowOscillator::process_block(float pitch, float drift, bool stereo, bool // MMX/SSE1 path if (stereo) { - for (int i = 0; i < block_size_os; i += 4) + for (int i = 0; i < BLOCK_SIZE_OS; i += 4) { _mm_store_ps(&output[i], _mm_mul_ps(_mm_cvtpi32x2_ps(*(__m64*)&IOutputL[i], *(__m64*)&IOutputL[i + 2]), @@ -360,7 +360,7 @@ void WindowOscillator::process_block(float pitch, float drift, bool stereo, bool } else { - for (int i = 0; i < block_size_os; i += 4) + for (int i = 0; i < BLOCK_SIZE_OS; i += 4) { _mm_store_ps(&output[i], _mm_mul_ps(_mm_cvtpi32x2_ps(*(__m64*)&IOutputL[i], *(__m64*)&IOutputL[i + 2]), diff --git a/src/common/dsp/effect/ConditionerEffect.cpp b/src/common/dsp/effect/ConditionerEffect.cpp index 8b75fbb0041..8e8e1360148 100644 --- a/src/common/dsp/effect/ConditionerEffect.cpp +++ b/src/common/dsp/effect/ConditionerEffect.cpp @@ -10,10 +10,10 @@ ConditionerEffect::ConditionerEffect(SurgeStorage* storage, FxStorage* fxdata, p { bufpos = 0; - ampL.set_blocksize(block_size); - ampR.set_blocksize(block_size); - width.set_blocksize(block_size); - postamp.set_blocksize(block_size); + ampL.set_blocksize(BLOCK_SIZE); + ampR.set_blocksize(BLOCK_SIZE); + width.set_blocksize(BLOCK_SIZE); + postamp.set_blocksize(BLOCK_SIZE); } ConditionerEffect::~ConditionerEffect() @@ -61,7 +61,7 @@ void ConditionerEffect::process_only_control() vu[4] = min(8.f, a * vu[4]); vu[5] = min(8.f, a * vu[5]); - for (int k = 0; k < block_size; k++) + for (int k = 0; k < BLOCK_SIZE; k++) { filtered_lamax = (1 - attack) * filtered_lamax + attack; filtered_lamax2 = (1 - release) * filtered_lamax2 + (release)*filtered_lamax; @@ -96,18 +96,18 @@ void ConditionerEffect::process(float* dataL, float* dataR) width.set_target_smoothed(clamp1bp(*f[2])); postamp.set_target_smoothed(db_to_linear(*f[7])); - float M alignas(16)[block_size], - S alignas(16)[block_size]; // wb = write-buffer - encodeMS(dataL, dataR, M, S, block_size_quad); - width.multiply_block(S, block_size_quad); - decodeMS(M, S, dataL, dataR, block_size_quad); - ampL.multiply_block(dataL, block_size_quad); - ampR.multiply_block(dataR, block_size_quad); + float M alignas(16)[BLOCK_SIZE], + S alignas(16)[BLOCK_SIZE]; // wb = write-buffer + encodeMS(dataL, dataR, M, S, BLOCK_SIZE_QUAD); + width.multiply_block(S, BLOCK_SIZE_QUAD); + decodeMS(M, S, dataL, dataR, BLOCK_SIZE_QUAD); + ampL.multiply_block(dataL, BLOCK_SIZE_QUAD); + ampR.multiply_block(dataR, BLOCK_SIZE_QUAD); - vu[0] = max(vu[0], get_absmax(dataL, block_size_quad)); - vu[1] = max(vu[1], get_absmax(dataR, block_size_quad)); + vu[0] = max(vu[0], get_absmax(dataL, BLOCK_SIZE_QUAD)); + vu[1] = max(vu[1], get_absmax(dataR, BLOCK_SIZE_QUAD)); - for (int k = 0; k < block_size; k++) + for (int k = 0; k < BLOCK_SIZE; k++) { float dL = delayed[0][bufpos]; float dR = delayed[1][bufpos]; @@ -144,12 +144,12 @@ void ConditionerEffect::process(float* dataL, float* dataR) bufpos = (bufpos + 1) & (lookahead - 1); } - postamp.multiply_2_blocks(dataL, dataR, block_size_quad); + postamp.multiply_2_blocks(dataL, dataR, BLOCK_SIZE_QUAD); vu[2] = gain; - vu[4] = max(vu[4], get_absmax(dataL, block_size_quad)); - vu[5] = max(vu[5], get_absmax(dataR, block_size_quad)); + vu[4] = max(vu[4], get_absmax(dataL, BLOCK_SIZE_QUAD)); + vu[5] = max(vu[5], get_absmax(dataR, BLOCK_SIZE_QUAD)); } int ConditionerEffect::vu_type(int id) diff --git a/src/common/dsp/effect/DistortionEffect.cpp b/src/common/dsp/effect/DistortionEffect.cpp index 30674326f17..e4bba792141 100644 --- a/src/common/dsp/effect/DistortionEffect.cpp +++ b/src/common/dsp/effect/DistortionEffect.cpp @@ -12,10 +12,10 @@ DistortionEffect::DistortionEffect(SurgeStorage* storage, FxStorage* fxdata, pda : Effect(storage, fxdata, pd), band1(storage), band2(storage), lp1(storage), lp2(storage), hr_a(3, false), hr_b(3, true) { - lp1.setBlockSize(block_size * distortion_OS); - lp2.setBlockSize(block_size * distortion_OS); - drive.set_blocksize(block_size); - outgain.set_blocksize(block_size); + lp1.setBlockSize(BLOCK_SIZE * distortion_OS); + lp2.setBlockSize(BLOCK_SIZE * distortion_OS); + drive.set_blocksize(BLOCK_SIZE); + outgain.set_blocksize(BLOCK_SIZE); } DistortionEffect::~DistortionEffect() @@ -67,13 +67,13 @@ void DistortionEffect::process(float* dataL, float* dataR) outgain.set_target_smoothed(db_to_linear(*f[10])); float fb = *f[5]; - float bL alignas(16)[block_size << dist_OS_bits]; - float bR alignas(16)[block_size << dist_OS_bits]; + float bL alignas(16)[BLOCK_SIZE << dist_OS_bits]; + float bR alignas(16)[BLOCK_SIZE << dist_OS_bits]; assert(dist_OS_bits == 2); - drive.multiply_2_blocks(dataL, dataR, block_size_quad); + drive.multiply_2_blocks(dataL, dataR, BLOCK_SIZE_QUAD); - for (int k = 0; k < block_size; k++) + for (int k = 0; k < BLOCK_SIZE; k++) { float a = (k & 16) ? 0.00000001 : -0.00000001; // denormal thingy float Lin = dataL[k]; @@ -95,7 +95,7 @@ void DistortionEffect::process(float* dataL, float* dataR) // dataR[k] = R*outgain; } - /*for(int k=0; k= max_delay_length) + if (wpos + BLOCK_SIZE >= max_delay_length) { - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { buffer[0][(wpos + k) & (max_delay_length - 1)] = wbL[k]; buffer[1][(wpos + k) & (max_delay_length - 1)] = wbR[k]; @@ -171,8 +171,8 @@ void DualDelayEffect::process(float* dataL, float* dataR) } else { - copy_block(wbL, &buffer[0][wpos], block_size_quad); - copy_block(wbR, &buffer[1][wpos], block_size_quad); + copy_block(wbL, &buffer[0][wpos], BLOCK_SIZE_QUAD); + copy_block(wbR, &buffer[1][wpos], BLOCK_SIZE_QUAD); } if (wpos == 0) @@ -186,15 +186,15 @@ void DualDelayEffect::process(float* dataL, float* dataR) } // scale width - float M alignas(16)[block_size], - S alignas(16)[block_size]; - encodeMS(tbufferL, tbufferR, M, S, block_size_quad); - width.multiply_block(S, block_size_quad); - decodeMS(M, S, tbufferL, tbufferR, block_size_quad); + float M alignas(16)[BLOCK_SIZE], + S alignas(16)[BLOCK_SIZE]; + encodeMS(tbufferL, tbufferR, M, S, BLOCK_SIZE_QUAD); + width.multiply_block(S, BLOCK_SIZE_QUAD); + decodeMS(M, S, tbufferL, tbufferR, BLOCK_SIZE_QUAD); - mix.fade_2_blocks_to(dataL, tbufferL, dataR, tbufferR, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, tbufferL, dataR, tbufferR, dataL, dataR, BLOCK_SIZE_QUAD); - wpos += block_size; + wpos += BLOCK_SIZE; wpos = wpos & (max_delay_length - 1); } diff --git a/src/common/dsp/effect/Effect.cpp b/src/common/dsp/effect/Effect.cpp index bc86862e28d..075227997a3 100644 --- a/src/common/dsp/effect/Effect.cpp +++ b/src/common/dsp/effect/Effect.cpp @@ -103,11 +103,11 @@ void Effect::init_ctrltypes() Eq3BandEffect::Eq3BandEffect(SurgeStorage* storage, FxStorage* fxdata, pdata* pd) : Effect(storage, fxdata, pd), band1(storage), band2(storage), band3(storage) { - gain.set_blocksize(block_size); + gain.set_blocksize(BLOCK_SIZE); - band1.setBlockSize(block_size * slowrate); // does not matter ATM as tey're smoothed - band2.setBlockSize(block_size * slowrate); - band3.setBlockSize(block_size * slowrate); + band1.setBlockSize(BLOCK_SIZE * slowrate); // does not matter ATM as tey're smoothed + band2.setBlockSize(BLOCK_SIZE * slowrate); + band3.setBlockSize(BLOCK_SIZE * slowrate); } Eq3BandEffect::~Eq3BandEffect() @@ -157,7 +157,7 @@ void Eq3BandEffect::process(float* dataL, float* dataR) band3.process_block(dataL, dataR); gain.set_target_smoothed(db_to_linear(*f[9])); - gain.multiply_2_blocks(dataL, dataR, block_size_quad); + gain.multiply_2_blocks(dataL, dataR, BLOCK_SIZE_QUAD); } void Eq3BandEffect::suspend() @@ -250,8 +250,8 @@ template ChorusEffect::ChorusEffect(SurgeStorage* storage, FxStorage* fxdata, pdata* pd) : Effect(storage, fxdata, pd), lp(storage), hp(storage) { - mix.set_blocksize(block_size); - feedback.set_blocksize(block_size); + mix.set_blocksize(BLOCK_SIZE); + feedback.set_blocksize(BLOCK_SIZE); } template ChorusEffect::~ChorusEffect() @@ -318,14 +318,14 @@ template void ChorusEffect::process(float* dataL, float* dataR) { setvars(false); - float tbufferL alignas(16)[block_size]; - float tbufferR alignas(16)[block_size]; - float fbblock alignas(16)[block_size]; + float tbufferL alignas(16)[BLOCK_SIZE]; + float tbufferR alignas(16)[BLOCK_SIZE]; + float fbblock alignas(16)[BLOCK_SIZE]; int k; - clear_block(tbufferL, block_size_quad); - clear_block(tbufferR, block_size_quad); - for (k = 0; k < block_size; k++) + clear_block(tbufferL, BLOCK_SIZE_QUAD); + clear_block(tbufferR, BLOCK_SIZE_QUAD); + for (k = 0; k < BLOCK_SIZE; k++) { __m128 L = _mm_setzero_ps(), R = _mm_setzero_ps(); @@ -333,7 +333,7 @@ template void ChorusEffect::process(float* dataL, float* dataR) { time[j].process(); float vtime = time[j].v; - int i_dtime = max(block_size, min((int)vtime, max_delay_length - FIRipol_N - 1)); + int i_dtime = max(BLOCK_SIZE, min((int)vtime, max_delay_length - FIRipol_N - 1)); int rp = ((wpos - i_dtime + k) - FIRipol_N) & (max_delay_length - 1); int sinc = FIRipol_N * limit_range((int)(FIRipol_M * (float(i_dtime + 1) - vtime)), 0, FIRipol_M - 1); @@ -356,26 +356,26 @@ template void ChorusEffect::process(float* dataL, float* dataR) lp.process_block(tbufferL, tbufferR); hp.process_block(tbufferL, tbufferR); - add_block(tbufferL, tbufferR, fbblock, block_size_quad); - feedback.multiply_block(fbblock, block_size_quad); - hardclip_block(fbblock, block_size_quad); - accumulate_block(dataL, fbblock, block_size_quad); - accumulate_block(dataR, fbblock, block_size_quad); + add_block(tbufferL, tbufferR, fbblock, BLOCK_SIZE_QUAD); + feedback.multiply_block(fbblock, BLOCK_SIZE_QUAD); + hardclip_block(fbblock, BLOCK_SIZE_QUAD); + accumulate_block(dataL, fbblock, BLOCK_SIZE_QUAD); + accumulate_block(dataR, fbblock, BLOCK_SIZE_QUAD); - if (wpos + block_size >= max_delay_length) + if (wpos + BLOCK_SIZE >= max_delay_length) { - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { buffer[(wpos + k) & (max_delay_length - 1)] = fbblock[k]; } } else { - /*for(k=0; k void ChorusEffect::process(float* dataL, float* dataR) buffer[k + max_delay_length] = buffer[k]; // copy buffer so FIR-core doesn't have to wrap // scale width - float M alignas(16)[block_size], - S alignas(16)[block_size]; - encodeMS(tbufferL, tbufferR, M, S, block_size_quad); - width.multiply_block(S, block_size_quad); - decodeMS(M, S, tbufferL, tbufferR, block_size_quad); + float M alignas(16)[BLOCK_SIZE], + S alignas(16)[BLOCK_SIZE]; + encodeMS(tbufferL, tbufferR, M, S, BLOCK_SIZE_QUAD); + width.multiply_block(S, BLOCK_SIZE_QUAD); + decodeMS(M, S, tbufferL, tbufferR, BLOCK_SIZE_QUAD); - mix.fade_2_blocks_to(dataL, tbufferL, dataR, tbufferR, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, tbufferL, dataR, tbufferR, dataL, dataR, BLOCK_SIZE_QUAD); - wpos += block_size; + wpos += BLOCK_SIZE; wpos = wpos & (max_delay_length - 1); } diff --git a/src/common/dsp/effect/FreqshiftEffect.cpp b/src/common/dsp/effect/FreqshiftEffect.cpp index 14c39589cfe..1425c2bf292 100644 --- a/src/common/dsp/effect/FreqshiftEffect.cpp +++ b/src/common/dsp/effect/FreqshiftEffect.cpp @@ -73,7 +73,7 @@ void FreqshiftEffect::setvars(bool init) float maxfb = max(db96, feedback.v); if (maxfb < 1.f) { - float f = block_size_inv * time.v * (1.f + log(db96) / log(maxfb)); + float f = BLOCK_SIZE_INV * time.v * (1.f + log(db96) / log(maxfb)); ringout_time = (int)f; } else @@ -88,18 +88,18 @@ void FreqshiftEffect::process(float* dataL, float* dataR) setvars(false); int k; - float L alignas(16)[block_size], - R alignas(16)[block_size], - Li alignas(16)[block_size], - Ri alignas(16)[block_size], - Lr alignas(16)[block_size], - Rr alignas(16)[block_size]; - - for (k = 0; k < block_size; k++) + float L alignas(16)[BLOCK_SIZE], + R alignas(16)[BLOCK_SIZE], + Li alignas(16)[BLOCK_SIZE], + Ri alignas(16)[BLOCK_SIZE], + Lr alignas(16)[BLOCK_SIZE], + Rr alignas(16)[BLOCK_SIZE]; + + for (k = 0; k < BLOCK_SIZE; k++) { time.process(); - int i_dtime = max(FIRipol_N + block_size, min((int)time.v, max_delay_length - FIRipol_N - 1)); + int i_dtime = max(FIRipol_N + BLOCK_SIZE, min((int)time.v, max_delay_length - FIRipol_N - 1)); int rp = (wpos - i_dtime + k); @@ -123,8 +123,8 @@ void FreqshiftEffect::process(float* dataL, float* dataR) Ri[k] = R[k] * o1R.i; } - fr.process_block(Lr, Rr, block_size); - fi.process_block(Li, Ri, block_size); + fr.process_block(Lr, Rr, BLOCK_SIZE); + fi.process_block(Li, Ri, BLOCK_SIZE); // do freqshift /*{ @@ -156,7 +156,7 @@ void FreqshiftEffect::process(float* dataL, float* dataR) R = 2*(r+i); }*/ - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { o2L.process(); Lr[k] *= o2L.r; @@ -176,9 +176,9 @@ void FreqshiftEffect::process(float* dataL, float* dataR) buffer[1][wp] = dataR[k] + (float)lookup_waveshape(0, (R[k] * feedback.v)); } - mix.fade_2_blocks_to(dataL, L, dataR, R, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, L, dataR, R, dataL, dataR, BLOCK_SIZE_QUAD); - wpos += block_size; + wpos += BLOCK_SIZE; wpos = wpos & (max_delay_length - 1); } diff --git a/src/common/dsp/effect/PhaserEffect.cpp b/src/common/dsp/effect/PhaserEffect.cpp index aa2e76df2da..0d0c8f13d24 100644 --- a/src/common/dsp/effect/PhaserEffect.cpp +++ b/src/common/dsp/effect/PhaserEffect.cpp @@ -33,8 +33,8 @@ PhaserEffect::PhaserEffect(SurgeStorage* storage, FxStorage* fxdata, pdata* pd) memset(biquad[i], 0, sizeof(BiquadFilter)); new (biquad[i]) BiquadFilter(storage); } - mix.set_blocksize(block_size); - feedback.setBlockSize(block_size * slowrate); + mix.set_blocksize(BLOCK_SIZE); + feedback.setBlockSize(BLOCK_SIZE * slowrate); bi = 0; } @@ -53,8 +53,8 @@ void PhaserEffect::init() // notch[i]->coeff_LP(1.0,1.0); biquad[i]->suspend(); } - clear_block(L, block_size_quad); - clear_block(R, block_size_quad); + clear_block(L, BLOCK_SIZE_QUAD); + clear_block(R, BLOCK_SIZE_QUAD); mix.set_target(1.f); mix.instantize(); bi = 0; @@ -109,10 +109,10 @@ void PhaserEffect::process(float* dataL, float* dataR) if (bi == 0) setvars(); bi = (bi + 1) & slowrate_m1; - // feedback.multiply_2_blocks((__m128*)L,(__m128*)R, block_size_quad); - // accumulate_block((__m128*)dataL, (__m128*)L, block_size_quad); - // accumulate_block((__m128*)dataR, (__m128*)R, block_size_quad); - for (int i = 0; i < block_size; i++) + // feedback.multiply_2_blocks((__m128*)L,(__m128*)R, BLOCK_SIZE_QUAD); + // accumulate_block((__m128*)dataL, (__m128*)L, BLOCK_SIZE_QUAD); + // accumulate_block((__m128*)dataR, (__m128*)R, BLOCK_SIZE_QUAD); + for (int i = 0; i < BLOCK_SIZE; i++) { feedback.process(); dL = dataL[i] + dL * feedback.v; @@ -132,7 +132,7 @@ void PhaserEffect::process(float* dataL, float* dataR) } mix.set_target_smoothed(limit_range(*f[pp_mix], 0.f, 1.f)); - mix.fade_2_blocks_to(dataL, L, dataR, R, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, L, dataR, R, dataL, dataR, BLOCK_SIZE_QUAD); } void PhaserEffect::suspend() diff --git a/src/common/dsp/effect/Reverb1Effect.cpp b/src/common/dsp/effect/Reverb1Effect.cpp index 1defc9e7b18..d73d33aefb7 100644 --- a/src/common/dsp/effect/Reverb1Effect.cpp +++ b/src/common/dsp/effect/Reverb1Effect.cpp @@ -184,7 +184,7 @@ void Reverb1Effect::update_rtime() max_dt = max(max_dt, delay_time[t]); } lastf[rp_decaytime] = *f[rp_decaytime]; - float t = block_size_inv * ((float)(max_dt >> 8) + samplerate * powf(2.f, *f[rp_decaytime]) * + float t = BLOCK_SIZE_INV * ((float)(max_dt >> 8) + samplerate * powf(2.f, *f[rp_decaytime]) * 2.f); // *2 is to get the db120 time ringout_time = (int)t; } @@ -200,8 +200,8 @@ void Reverb1Effect::update_rsize() void Reverb1Effect::process(float* dataL, float* dataR) { - float wetL alignas(16)[block_size], - wetR alignas(16)[block_size]; + float wetL alignas(16)[BLOCK_SIZE], + wetR alignas(16)[BLOCK_SIZE]; if (fxdata->p[rp_shape].val.i != shape) loadpreset(fxdata->p[rp_shape].val.i); @@ -230,7 +230,7 @@ void Reverb1Effect::process(float* dataL, float* dataR) __m128 damp4 = _mm_load1_ps(f[rp_damping]); __m128 damp4m1 = _mm_sub_ps(one4, damp4); - for (int k = 0; k < block_size; k++) + for (int k = 0; k < BLOCK_SIZE; k++) { for (int t = 0; t < rev_taps; t += 4) { @@ -292,13 +292,13 @@ void Reverb1Effect::process(float* dataL, float* dataR) hicut.process_block_slowlag(wetL, wetR); // scale width - float M alignas(16)[block_size], - S alignas(16)[block_size]; - encodeMS(wetL, wetR, M, S, block_size_quad); - width.multiply_block(S, block_size_quad); - decodeMS(M, S, wetL, wetR, block_size_quad); + float M alignas(16)[BLOCK_SIZE], + S alignas(16)[BLOCK_SIZE]; + encodeMS(wetL, wetR, M, S, BLOCK_SIZE_QUAD); + width.multiply_block(S, BLOCK_SIZE_QUAD); + decodeMS(M, S, wetL, wetR, BLOCK_SIZE_QUAD); - mix.fade_2_blocks_to(dataL, wetL, dataR, wetR, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, wetL, dataR, wetR, dataL, dataR, BLOCK_SIZE_QUAD); } void Reverb1Effect::suspend() diff --git a/src/common/dsp/effect/Reverb2Effect.cpp b/src/common/dsp/effect/Reverb2Effect.cpp index 6b3cfcaecea..3c518122287 100644 --- a/src/common/dsp/effect/Reverb2Effect.cpp +++ b/src/common/dsp/effect/Reverb2Effect.cpp @@ -173,8 +173,8 @@ void Reverb2Effect::process(float* dataL, float* dataR) float scale = powf(2.f, 1.f * *f[r2p_room_size]); calc_size(scale); - float wetL alignas(16)[block_size], - wetR alignas(16)[block_size]; + float wetL alignas(16)[BLOCK_SIZE], + wetR alignas(16)[BLOCK_SIZE]; float loop_time_s = 0.5508 * scale; float decay = powf(db60, loop_time_s / (4.f * (powf(2.f, *f[r2p_decay_time])))); @@ -191,7 +191,7 @@ void Reverb2Effect::process(float* dataL, float* dataR) _lfo.set_rate(2.0 * M_PI * powf(2, -2.f) * dsamplerate_inv); - for (int k = 0; k < block_size; k++) + for (int k = 0; k < BLOCK_SIZE; k++) { float in = (dataL[k] + dataR[k]) * 0.5f; @@ -243,13 +243,13 @@ void Reverb2Effect::process(float* dataL, float* dataR) } // scale width - float M alignas(16)[block_size], - S alignas(16)[block_size]; - encodeMS(wetL, wetR, M, S, block_size_quad); - width.multiply_block(S, block_size_quad); - decodeMS(M, S, wetL, wetR, block_size_quad); + float M alignas(16)[BLOCK_SIZE], + S alignas(16)[BLOCK_SIZE]; + encodeMS(wetL, wetR, M, S, BLOCK_SIZE_QUAD); + width.multiply_block(S, BLOCK_SIZE_QUAD); + decodeMS(M, S, wetL, wetR, BLOCK_SIZE_QUAD); - mix.fade_2_blocks_to(dataL, wetL, dataR, wetR, dataL, dataR, block_size_quad); + mix.fade_2_blocks_to(dataL, wetL, dataR, wetR, dataL, dataR, BLOCK_SIZE_QUAD); } void Reverb2Effect::suspend() diff --git a/src/common/dsp/effect/RotarySpeakerEffect.cpp b/src/common/dsp/effect/RotarySpeakerEffect.cpp index e3de04d451d..3a812c36539 100644 --- a/src/common/dsp/effect/RotarySpeakerEffect.cpp +++ b/src/common/dsp/effect/RotarySpeakerEffect.cpp @@ -129,8 +129,8 @@ void RotarySpeakerEffect::init_ctrltypes() void RotarySpeakerEffect::process_only_control() { - lfo.set_rate(2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * block_size); - lf_lfo.set_rate(0.7 * 2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * block_size); + lfo.set_rate(2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * BLOCK_SIZE); + lf_lfo.set_rate(0.7 * 2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * BLOCK_SIZE); lfo.process(); lf_lfo.process(); @@ -138,7 +138,7 @@ void RotarySpeakerEffect::process_only_control() void RotarySpeakerEffect::process(float* dataL, float* dataR) { - lfo.set_rate(2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * block_size); + lfo.set_rate(2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv * BLOCK_SIZE); lf_lfo.set_rate(0.7 * 2 * M_PI * powf(2, *f[rsp_rate]) * dsamplerate_inv); float precalc0 = (-2 - (float)lfo.i); @@ -159,15 +159,15 @@ void RotarySpeakerEffect::process(float* dataL, float* dataR) lfo.process(); - float upper[block_size]; - float lower[block_size]; - float lower_sub[block_size]; - float tbufferL[block_size]; - float tbufferR[block_size]; + float upper[BLOCK_SIZE]; + float lower[BLOCK_SIZE]; + float lower_sub[BLOCK_SIZE]; + float tbufferL[BLOCK_SIZE]; + float tbufferR[BLOCK_SIZE]; int k; - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { // float input = (float)tanh_fast(0.5f*dataL[k]+dataR[k]*drive.v); float input = 0.5f * (dataL[k] + dataR[k]); @@ -179,7 +179,7 @@ void RotarySpeakerEffect::process(float* dataL, float* dataR) xover.process_block(lower); // xover->process(lower,0); - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { // feed delay input int wp = (wpos + k) & (max_delay_length - 1); @@ -187,13 +187,13 @@ void RotarySpeakerEffect::process(float* dataL, float* dataR) upper[k] -= lower[k]; buffer[wp] = upper[k]; - /*int i_dtL = max(block_size,min((int)dL.v,max_delay_length-1)), - i_dtR = max(block_size,min((int)dR.v,max_delay_length-1)), + /*int i_dtL = max(BLOCK_SIZE,min((int)dL.v,max_delay_length-1)), + i_dtR = max(BLOCK_SIZE,min((int)dR.v,max_delay_length-1)), sincL = FIRipol_N*(int)(FIRipol_M*(ceil(dL.v)-dL.v)), sincR = FIRipol_N*(int)(FIRipol_M*(ceil(dR.v)-dR.v));*/ - int i_dtimeL = max(block_size, min((int)dL.v, max_delay_length - FIRipol_N - 1)); - int i_dtimeR = max(block_size, min((int)dR.v, max_delay_length - FIRipol_N - 1)); + int i_dtimeL = max(BLOCK_SIZE, min((int)dL.v, max_delay_length - FIRipol_N - 1)); + int i_dtimeR = max(BLOCK_SIZE, min((int)dR.v, max_delay_length - FIRipol_N - 1)); int rpL = (wpos - i_dtimeL + k); int rpR = (wpos - i_dtimeR + k); @@ -225,7 +225,7 @@ void RotarySpeakerEffect::process(float* dataL, float* dataR) // lowbass->process(lower_sub,0); lowbass.process_block(lower_sub); - for (k = 0; k < block_size; k++) + for (k = 0; k < BLOCK_SIZE; k++) { lower[k] -= lower_sub[k]; @@ -238,6 +238,6 @@ void RotarySpeakerEffect::process(float* dataL, float* dataR) hornamp[1].process(); } - wpos += block_size; + wpos += BLOCK_SIZE; wpos = wpos & (max_delay_length - 1); } \ No newline at end of file diff --git a/src/common/dsp/effect/VocoderEffect.cpp b/src/common/dsp/effect/VocoderEffect.cpp index db945fdd3ca..4ef0afbfef4 100644 --- a/src/common/dsp/effect/VocoderEffect.cpp +++ b/src/common/dsp/effect/VocoderEffect.cpp @@ -32,7 +32,7 @@ VocoderEffect::VocoderEffect(SurgeStorage* storage, FxStorage* fxdata, pdata* pd mVoicedLevel = 0.f; mUnvoicedLevel = 0.f;*/ - mGain.set_blocksize(block_size); + mGain.set_blocksize(BLOCK_SIZE); for (int i = 0; i < NVocoderVec; i++) { @@ -95,23 +95,23 @@ void VocoderEffect::process(float* dataL, float* dataR) setvars(false); } - float modulator_in alignas(16)[block_size]; + float modulator_in alignas(16)[BLOCK_SIZE]; - add_block(storage->audio_in_nonOS[0], storage->audio_in_nonOS[1], modulator_in, block_size_quad); + add_block(storage->audio_in_nonOS[0], storage->audio_in_nonOS[1], modulator_in, BLOCK_SIZE_QUAD); float Gain = *f[KGain] + 24.f; mGain.set_target_smoothed(db_to_linear(Gain)); - mGain.multiply_block(modulator_in, block_size_quad); + mGain.multiply_block(modulator_in, BLOCK_SIZE_QUAD); // Voiced / Unvoiced detection /*{ mVoicedDetect.process_block_to(modulator_in, modulator_tbuf); - float a = min(4.f, get_squaremax(modulator_tbuf,block_size_quad)); + float a = min(4.f, get_squaremax(modulator_tbuf,BLOCK_SIZE_QUAD)); mVoicedLevel = mVoicedLevel * (1.f - rate) + a*rate; mUnvoicedDetect.process_block_to(modulator_in, modulator_tbuf); - a = min(4.f, get_squaremax(modulator_tbuf,block_size_quad)); + a = min(4.f, get_squaremax(modulator_tbuf,BLOCK_SIZE_QUAD)); mUnvoicedLevel = mUnvoicedLevel * (1.f - rate) + a*rate; float Ratio = db_to_linear(*f[KUnvoicedThreshold]); @@ -119,7 +119,7 @@ void VocoderEffect::process(float* dataL, float* dataR) if (mUnvoicedLevel > (mVoicedLevel * Ratio)) { // mix carrier with noise - for(int i=0; i> 2; -const int block_size_os_quad = block_size_os >> 2; -const int max_unison = 16; -const int ob_length = block_size_os << 1; -const int ob_length_quad = ob_length >> 2; -const float block_size_inv = (1.f / block_size); -const float block_size_os_inv = (1.f / block_size_os); -const int max_fb_comb = 2048; // must be 2^n +const int NAMECHARS = 64; +const int BLOCK_SIZE = 32; +const int OSC_OVERSAMPLING = 2; +const int BLOCK_SIZE_OS = OSC_OVERSAMPLING * BLOCK_SIZE; +const int BLOCK_SIZE_QUAD = BLOCK_SIZE >> 2; +const int BLOCK_SIZE_OS_QUAD = BLOCK_SIZE_OS >> 2; +const int MAX_UNISON = 16; +const int OB_LENGTH = BLOCK_SIZE_OS << 1; +const int OB_LENGTH_QUAD = OB_LENGTH >> 2; +const float BLOCK_SIZE_INV = (1.f / BLOCK_SIZE); +const float BLOCK_SIZE_OS_INV = (1.f / BLOCK_SIZE_OS); +const int MAX_FB_COMB = 2048; // must be 2^n diff --git a/src/common/gui/COscillatorDisplay.cpp b/src/common/gui/COscillatorDisplay.cpp index d5465f0bc11..f789c8d534b 100644 --- a/src/common/gui/COscillatorDisplay.cpp +++ b/src/common/gui/COscillatorDisplay.cpp @@ -45,7 +45,7 @@ void COscillatorDisplay::draw(CDrawContext* dc) bool use_display = osc->allow_display(); if (use_display) osc->init(disp_pitch_rs, true); - int block_pos = block_size_os; + int block_pos = BLOCK_SIZE_OS; for (int y = 0; y < h2; y++) column_d[y] = 0; @@ -55,7 +55,7 @@ void COscillatorDisplay::draw(CDrawContext* dc) column[y] = 0; for (int s = 0; s < aa_samples; s++) { - if (use_display && (block_pos >= block_size_os)) + if (use_display && (block_pos >= BLOCK_SIZE_OS)) { if (uses_wavetabledata(oscdata->type.val.i)) { @@ -256,7 +256,7 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt for (auto c : storage->wtCategoryOrdering) { - char name[namechars]; + char name[NAMECHARS]; COptionMenu* subMenu = new COptionMenu(getViewSize(), 0, c, 0, 0, kNoDrawStyle); subMenu->setNbItemsPerColumn(32); int sub = 0; @@ -275,7 +275,7 @@ CMouseEventResult COscillatorDisplay::onMouseDown(CPoint& where, const CButtonSt sub++; } } - strncpy(name, storage->wt_category[c].name.c_str(), namechars); + strncpy(name, storage->wt_category[c].name.c_str(), NAMECHARS); contextMenu->addEntry(subMenu, name); subMenu->forget(); // Important, so that the refcounter gets right diff --git a/src/common/gui/CPatchBrowser.cpp b/src/common/gui/CPatchBrowser.cpp index f31974f453a..b2f4ebafea1 100644 --- a/src/common/gui/CPatchBrowser.cpp +++ b/src/common/gui/CPatchBrowser.cpp @@ -117,7 +117,7 @@ CMouseEventResult CPatchBrowser::onMouseDown(CPoint& where, const CButtonState& if (n_subc > 1) sprintf(name, "%s - %i", storage->patch_category[c].name.c_str(), subc + 1); else - strncpy(name, storage->patch_category[c].name.c_str(), namechars); + strncpy(name, storage->patch_category[c].name.c_str(), NAMECHARS); if (!single_category) { diff --git a/src/common/gui/CSnapshotMenu.cpp b/src/common/gui/CSnapshotMenu.cpp index 23a046e2663..c10c81fa599 100644 --- a/src/common/gui/CSnapshotMenu.cpp +++ b/src/common/gui/CSnapshotMenu.cpp @@ -109,10 +109,10 @@ void CSnapshotMenu::populate() } else { - char name[namechars]; + char name[NAMECHARS]; sprintf(name, "default"); - spawn_miniedit_text(name, namechars); + spawn_miniedit_text(name, NAMECHARS); save_snapshot(sect, name); storage->save_snapshots(); do_nothing = true; @@ -192,7 +192,7 @@ j; // CFxMenu -const char fxslot_names[8][namechars] = {"A Insert 1", "A Insert 2", "B Insert 1", "B Insert 2", +const char fxslot_names[8][NAMECHARS] = {"A Insert 1", "A Insert 2", "B Insert 1", "B Insert 2", "Send FX 1", "Send FX 2", "Master 1", "Master 2"}; CFxMenu::CFxMenu(const CRect& size, @@ -233,7 +233,7 @@ void CFxMenu::draw(CDrawContext* dc) txtbox.top--; txtbox.bottom += 2; dc->drawString(fxslot_names[slot], txtbox, kLeftText, true); - char fxname[namechars]; + char fxname[NAMECHARS]; sprintf(fxname, "%s", fxtype_abberations[fx->type.val.i]); dc->drawString(fxname, txtbox, kRightText, true); diff --git a/src/common/vt_dsp/halfratefilter.cpp b/src/common/vt_dsp/halfratefilter.cpp index bd9238bf7d2..03d4872d3b8 100644 --- a/src/common/vt_dsp/halfratefilter.cpp +++ b/src/common/vt_dsp/halfratefilter.cpp @@ -1,7 +1,7 @@ #include "halfratefilter.h" #include "assert.h" -const unsigned int hr_block_size = 256; +const unsigned int hr_BLOCK_SIZE = 256; const __m128 half = _mm_set_ps1(0.5f); halfrate_stereo::halfrate_stereo(int M, bool steep) @@ -17,7 +17,7 @@ void halfrate_stereo::process_block(float* __restrict floatL, float* __restrict { __m128* __restrict L = (__m128*)floatL; __m128* __restrict R = (__m128*)floatR; - __m128 o[hr_block_size]; + __m128 o[hr_BLOCK_SIZE]; // fill the buffer with interleaved stereo samples for (int k = 0; k < N; k += 4) { @@ -145,7 +145,7 @@ void halfrate_stereo::process_block_D2( { __m128* L = (__m128*)floatL; __m128* R = (__m128*)floatR; - __m128 o[hr_block_size]; + __m128 o[hr_BLOCK_SIZE]; // fill the buffer with interleaved stereo samples for (int k = 0; k < nsamples; k += 4) { @@ -277,7 +277,7 @@ void halfrate_stereo::process_block_U2( __m128* L_in = (__m128*)floatL_in; __m128* R_in = (__m128*)floatR_in; - __m128 o[hr_block_size]; + __m128 o[hr_BLOCK_SIZE]; // fill the buffer with interleaved stereo samples for (int k = 0; k < nsamples; k += 8) { diff --git a/src/common/vt_dsp/halfratefilter.h b/src/common/vt_dsp/halfratefilter.h index f7a456dcda3..8f3dbe91661 100644 --- a/src/common/vt_dsp/halfratefilter.h +++ b/src/common/vt_dsp/halfratefilter.h @@ -33,5 +33,5 @@ class halfrate_stereo int M; bool steep; float oldoutL, oldoutR; - // unsigned int block_size; + // unsigned int BLOCK_SIZE; }; diff --git a/src/common/vt_dsp/lipol.cpp b/src/common/vt_dsp/lipol.cpp index ba46f7f298f..e7d233e375d 100644 --- a/src/common/vt_dsp/lipol.cpp +++ b/src/common/vt_dsp/lipol.cpp @@ -15,8 +15,8 @@ lipol_ps::lipol_ps() void lipol_ps::set_blocksize(int bs) { - lipol_block_size = _mm_cvt_si2ss(m128_zero, bs); - m128_bs4_inv = _mm_div_ss(m128_four, lipol_block_size); + lipol_BLOCK_SIZE = _mm_cvt_si2ss(m128_zero, bs); + m128_bs4_inv = _mm_div_ss(m128_four, lipol_BLOCK_SIZE); } void lipol_ps::multiply_block(float* src, unsigned int nquads) diff --git a/src/common/vt_dsp/lipol.h b/src/common/vt_dsp/lipol.h index 82a1ca2a24e..10059c87bb3 100644 --- a/src/common/vt_dsp/lipol.h +++ b/src/common/vt_dsp/lipol.h @@ -6,7 +6,7 @@ class lipol_ps { public: __m128 target, currentval, coef, coef_m1; - __m128 lipol_block_size; + __m128 lipol_BLOCK_SIZE; __m128 m128_lipolstarter; __m128 m128_bs4_inv; diff --git a/src/todo/effect_emphasize.cpp b/src/todo/effect_emphasize.cpp index 3c2700ebb58..4cee721f6a0 100644 --- a/src/todo/effect_emphasize.cpp +++ b/src/todo/effect_emphasize.cpp @@ -42,16 +42,16 @@ void emphasize::process(float *dataL, float *dataR) bi = (bi+1) & slowrate_m1; outgain.set_target(storage->db_to_linear(*f[0])); - float bL alignas(16)[block_size << 1]; - float bR alignas(16)[block_size << 1]; + float bL alignas(16)[BLOCK_SIZE << 1]; + float bR alignas(16)[BLOCK_SIZE << 1]; EQ.process_block_to(dataL,dataR,bL,bR); - pre.process_block_U2((__m128*)bL,(__m128*)bR,(__m128*)bL,(__m128*)bR,block_size_os); + pre.process_block_U2((__m128*)bL,(__m128*)bR,(__m128*)bL,(__m128*)bR,BLOCK_SIZE_OS); __m128 type = _mm_load1_ps(f[3]); __m128 typem1 = _mm_sub_ps(m128_one,type); - for(int k=0; kp[4].param_id_in_scene; id_detune = oscdata->p[5].param_id_in_scene; - n_unison = limit_range(oscdata->p[6].val.i,1,max_unison); + n_unison = limit_range(oscdata->p[6].val.i,1,MAX_UNISON); if(is_display) n_unison = 1; out_attenuation = 1.0f/sqrt((float)n_unison); @@ -56,9 +56,9 @@ void osc_dotwave::init(float pitch, bool is_display) detune_bias = (float)2/(n_unison); detune_offset = -1; } - memset(oscbuffer,0,sizeof(float)*ob_length); - memset(last_level,0,max_unison*sizeof(float)); - memset(last_level2,0,max_unison*sizeof(float)); + memset(oscbuffer,0,sizeof(float)*OB_LENGTH); + memset(last_level,0,MAX_UNISON*sizeof(float)); + memset(last_level2,0,MAX_UNISON*sizeof(float)); this->pitch = pitch; update_lagvals(); @@ -195,7 +195,7 @@ void osc_dotwave::convolute(int voice) for(k=0; ksinctable[m+k] + lipol*storage->sincoffset[m+k]; - oscbuffer[bufpos+k&(ob_length-1)] += a*g2; + oscbuffer[bufpos+k&(OB_LENGTH-1)] += a*g2; // s += a; } @@ -254,7 +254,7 @@ template void osc_dotwave::process_blockT(float pitch,float depth) __int64 largeFM; double FMmult; - for(k=0; k void osc_dotwave::process_blockT(float pitch,float depth) oscbuffer[bufpos] = 0.f; bufpos++; - bufpos = bufpos&(ob_length-1); + bufpos = bufpos&(OB_LENGTH-1); } } diff --git a/src/todo/sub3_osc_sample.cpp b/src/todo/sub3_osc_sample.cpp index 83b39d13a9b..107988895fc 100644 --- a/src/todo/sub3_osc_sample.cpp +++ b/src/todo/sub3_osc_sample.cpp @@ -55,7 +55,7 @@ template void osc_sample::process_blockT(float pitch,float depth) update_lagvals(); - for(int k=0; k>16)&0xff)*FIRipol_N; float lipol0 = (float)((uint32)(sample_subpos&0xffff)); diff --git a/src/todo/sub3_osc_wavetable2.cpp b/src/todo/sub3_osc_wavetable2.cpp index e25ebc5354f..833dab07cd5 100644 --- a/src/todo/sub3_osc_wavetable2.cpp +++ b/src/todo/sub3_osc_wavetable2.cpp @@ -36,7 +36,7 @@ void osc_wavetable2::init(float pitch, bool is_display) l_vskew.setRate(rate); l_hskew.setRate(rate); - n_unison = limit_range(oscdata->p[6].val.i,1,max_unison); + n_unison = limit_range(oscdata->p[6].val.i,1,MAX_UNISON); if(oscdata->wt.flags & wtf_is_sample) { sampleloop = n_unison; @@ -54,8 +54,8 @@ void osc_wavetable2::init(float pitch, bool is_display) detune_bias = (float)2/(n_unison); detune_offset = -1; } - memset(oscbuffer,0,sizeof(float)*(ob_length+FIRipol_N)); - memset(last_level,0,max_unison*sizeof(float)); + memset(oscbuffer,0,sizeof(float)*(OB_LENGTH+FIRipol_N)); + memset(last_level,0,MAX_UNISON*sizeof(float)); pitch_last = pitch; pitch_t = pitch; @@ -135,7 +135,7 @@ float osc_wavetable2::distort_level(float x) void osc_wavetable2::convolute(int voice, bool FM) { - float block_pos = oscstate[voice] * block_size_os_inv * pitchmult_inv; + float block_pos = oscstate[voice] * BLOCK_SIZE_OS_INV * pitchmult_inv; double detune = drift*driftlfo[voice] + localcopy[id_detune].f*(detune_bias*float(voice) + detune_offset); @@ -156,7 +156,7 @@ void osc_wavetable2::convolute(int voice, bool FM) tableid++; if (tableid > oscdata->wt.n_tables-3) { - if (sampleloop < max_unison) sampleloop--; + if (sampleloop < MAX_UNISON) sampleloop--; if (sampleloop > 0) { @@ -365,7 +365,7 @@ template void osc_wavetable2::process_blockT(float pitch0,float depth,f if(FM) { for(l=0; l void osc_wavetable2::process_blockT(float pitch0,float depth,f } else { - float a = (float)block_size_os*pitchmult; + float a = (float)BLOCK_SIZE_OS*pitchmult; for(l=0; l void osc_wavetable2::process_blockT(float pitch0,float depth,f //li_DC.set_target(dc); } - float hpfblock alignas(16)[block_size_os]; - li_hpf.store_block(hpfblock,block_size_os_quad); + float hpfblock alignas(16)[BLOCK_SIZE_OS]; + li_hpf.store_block(hpfblock,BLOCK_SIZE_OS_QUAD); - for(k=0; k void osc_wavetable2::process_blockT(float pitch0,float depth,f _mm_store_ss(&output[k],osc_out); } - vt_dsp::clear_block(&oscbuffer[bufpos],block_size_os_quad); + vt_dsp::clear_block(&oscbuffer[bufpos],BLOCK_SIZE_OS_QUAD); - bufpos = (bufpos+block_size_os)&(ob_length-1); + bufpos = (bufpos+BLOCK_SIZE_OS)&(OB_LENGTH-1); // each block overlap FIRipol_N samples into the next (due to impulses not being wrapped around the block edges // copy the overlapping samples to the new block position @@ -420,9 +420,9 @@ template void osc_wavetable2::process_blockT(float pitch0,float depth,f const __m128 zero = _mm_setzero_ps(); for(k=0; k<(FIRipol_N); k+=4) { - overlap[k>>2] = _mm_load_ps(&oscbuffer[ob_length+k]); + overlap[k>>2] = _mm_load_ps(&oscbuffer[OB_LENGTH+k]); _mm_store_ps(&oscbuffer[k],overlap[k>>2]); - _mm_store_ps(&oscbuffer[ob_length+k],zero); + _mm_store_ps(&oscbuffer[OB_LENGTH+k],zero); } } } diff --git a/src/vst2/Vst2PluginInstance.cpp b/src/vst2/Vst2PluginInstance.cpp index 87de908de9d..c155cc46b9c 100644 --- a/src/vst2/Vst2PluginInstance.cpp +++ b/src/vst2/Vst2PluginInstance.cpp @@ -405,7 +405,7 @@ void Vst2PluginInstance::processT(float** inputs, float** outputs, VstInt32 samp // move clock timedata* td = &(_instance->time_data); _instance->time_data.ppqPos += - (double)block_size * _instance->time_data.tempo / (60. * sampleRate); + (double)BLOCK_SIZE * _instance->time_data.tempo / (60. * sampleRate); // process events for the current block while (events_processed < events_this_block) @@ -442,7 +442,7 @@ void Vst2PluginInstance::processT(float** inputs, float** outputs, VstInt32 samp } blockpos++; - if (blockpos >= block_size) + if (blockpos >= BLOCK_SIZE) blockpos = 0; } diff --git a/src/vst3/SurgeVst3Processor.cpp b/src/vst3/SurgeVst3Processor.cpp index e70eb3ad4d5..9c9cbc888fa 100644 --- a/src/vst3/SurgeVst3Processor.cpp +++ b/src/vst3/SurgeVst3Processor.cpp @@ -320,7 +320,7 @@ tresult PLUGIN_API SurgeVst3Processor::process(ProcessData& data) timedata* td = &(surgeInstance->time_data); surgeInstance->time_data.tempo = tempo; surgeInstance->time_data.ppqPos += - (double)block_size * tempo / (60. * data.processContext->sampleRate); + (double)BLOCK_SIZE * tempo / (60. * data.processContext->sampleRate); } processEvents(i, data.inputEvents, noteEventIndex); @@ -345,7 +345,7 @@ tresult PLUGIN_API SurgeVst3Processor::process(ProcessData& data) } blockpos++; - if (blockpos >= block_size) + if (blockpos >= BLOCK_SIZE) blockpos = 0; }