Skip to content

Commit

Permalink
Capitalize global constants (#308)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jarkkojs authored and baconpaul committed Jan 17, 2019
1 parent 00fcada commit 8be63a3
Show file tree
Hide file tree
Showing 51 changed files with 461 additions and 461 deletions.
4 changes: 2 additions & 2 deletions src/au/aulayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/common/AbstractSynthesizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
4 changes: 2 additions & 2 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/common/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/SampleLoadRiffWave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
4 changes: 2 additions & 2 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
106 changes: 53 additions & 53 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2163,13 +2163,13 @@ void SurgeSynthesizer::process()

if (halt_engine)
{
/*for(int k=0; k<block_size; k++)
/*for(int k=0; k<BLOCK_SIZE; k++)
{
output[0][k] = 0;
output[1][k] = 0;
}*/
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;
}
else if (patchid_queue >= 0)
Expand Down Expand Up @@ -2212,43 +2212,43 @@ 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;
}
}

// 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
Expand Down Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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<block_size; i++)
/*for(int i=0; i<BLOCK_SIZE; i++)
{
vu_peak[0] = max(vu_peak[0], output[0][i]);
vu_peak[1] = max(vu_peak[1], output[1][i]);
}*/
vu_peak[0] = max(vu_peak[0], get_absmax(output[0], block_size_quad));
vu_peak[1] = max(vu_peak[1], get_absmax(output[1], block_size_quad));
vu_peak[0] = max(vu_peak[0], get_absmax(output[0], BLOCK_SIZE_QUAD));
vu_peak[1] = max(vu_peak[1], get_absmax(output[1], BLOCK_SIZE_QUAD));

hardclip_block8(output[0], block_size_quad);
hardclip_block8(output[1], block_size_quad);
hardclip_block8(output[0], BLOCK_SIZE_QUAD);
hardclip_block8(output[1], BLOCK_SIZE_QUAD);
}

PluginLayer* SurgeSynthesizer::getParent()
Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeSynthesizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SurgeSynthesizer : public AbstractSynthesizer
}
int getBlockSize() override
{
return block_size;
return BLOCK_SIZE;
}
int getMpeMainChannel(int voiceChannel, int key);
void process() override;
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/AdsrEnvelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class AdsrEnvelope : public ModulationSource
// calculate coefficients for envelope
const float shortest = 6.f;
const float longest = -2.f;
const float coeff_offset = 2.f - log(samplerate / block_size) / log(2.f);
const float coeff_offset = 2.f - log(samplerate / BLOCK_SIZE) / log(2.f);

float coef_A =
powf(2.f, min(0.f, coeff_offset -
Expand Down
12 changes: 6 additions & 6 deletions src/common/dsp/BiquadFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void BiquadFilter::process_block(float* data)
else*/
{
int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
a1.process();
a2.process();
Expand Down Expand Up @@ -313,7 +313,7 @@ void BiquadFilter::process_block_to(float* __restrict data, float* __restrict da
else*/
{
int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
a1.process();
a2.process();
Expand Down Expand Up @@ -347,7 +347,7 @@ void BiquadFilter::process_block_slowlag(float* __restrict dataL, float* __restr
b2.process();

int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
double input = dataL[k];
double op;
Expand Down Expand Up @@ -378,7 +378,7 @@ void BiquadFilter::process_block(float* dataL, float* dataR)
else*/
{
int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
a1.process();
a2.process();
Expand Down Expand Up @@ -415,7 +415,7 @@ void BiquadFilter::process_block_to(float* dataL, float* dataR, float* dstL, flo
else*/
{
int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
a1.process();
a2.process();
Expand Down Expand Up @@ -452,7 +452,7 @@ void BiquadFilter::process_block(double* data)
else*/
{
int k;
for (k = 0; k < block_size; k++)
for (k = 0; k < BLOCK_SIZE; k++)
{
a1.process();
a2.process();
Expand Down
Loading

0 comments on commit 8be63a3

Please sign in to comment.