Skip to content

Commit

Permalink
use AlignAfterOpenBracket: Align for clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
corrados committed Jul 16, 2024
1 parent 9155935 commit 0d4d070
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ SpacesBeforeTrailingComments: 1
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: All
IndentPPDirectives: AfterHash
AlignAfterOpenBracket: Align
#AllowShortLiteralsOnASingleLine: true
#BracketAlignmentStyle: BAS_Align
6 changes: 3 additions & 3 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#define MAX_NUM_PAD_INPUTS 5 // a maximum of 5 sensors per pad is supported (where one is rim and one is the sum of three)

inline void update_fifo(const float input,
const int fifo_length,
float* fifo_memory)
const int fifo_length,
float* fifo_memory)
{
// move all values in the history one step back and put new value on the top
for (int i = 0; i < fifo_length - 1; i++)
Expand All @@ -38,7 +38,7 @@ inline void update_fifo(const float input,
}

inline void allocate_initialize(float** array_memory,
const int array_length)
const int array_length)
{
// (delete and) allocate memory
if (*array_memory != nullptr)
Expand Down
80 changes: 40 additions & 40 deletions edrumulus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Edrumulus::Edrumulus()
}

void Edrumulus::setup(const int conf_num_pads,
const int* conf_analog_pins,
const int* conf_analog_pins_rim_shot)
const int* conf_analog_pins,
const int* conf_analog_pins_rim_shot)
{
number_pads = min(conf_num_pads, MAX_NUM_PADS);

Expand All @@ -74,19 +74,19 @@ void Edrumulus::setup(const int conf_num_pads,
// setup the ESP32 specific object, this has to be done after assigning the analog
// pin numbers and before using the analog read function (as in the DC offset estimator)
edrumulus_hardware.setup(Fs,
number_pads,
number_inputs,
analog_pin);
number_pads,
number_inputs,
analog_pin);

// estimate the DC offset for all inputs
float dc_offset_sum[MAX_NUM_PADS][MAX_NUM_PAD_INPUTS];

for (int k = 0; k < dc_offset_est_len; k++)
{
edrumulus_hardware.capture_samples(number_pads,
number_inputs,
analog_pin,
sample_org);
number_inputs,
analog_pin,
sample_org);

for (int i = 0; i < number_pads; i++)
{
Expand Down Expand Up @@ -131,9 +131,9 @@ void Edrumulus::process()
// Query samples -------------------------------------------------------------
// note that this is a blocking function
edrumulus_hardware.capture_samples(number_pads,
number_inputs,
analog_pin,
sample_org);
number_inputs,
analog_pin,
sample_org);

/*
// TEST for plotting all captures samples in the serial plotter (but with low sampling rate)
Expand Down Expand Up @@ -207,7 +207,7 @@ void Edrumulus::process()
// process sample
if (any_coupling_used && // note: short-cut for speed optimization of normal non-coupling mode
(((coupled_pad_idx_primary >= 0) && ((i == coupled_pad_idx_secondary) || (i == coupled_pad_idx_primary))) ||
((coupled_pad_idx_rim_primary >= 0) && ((i == coupled_pad_idx_rim_secondary) || (i == coupled_pad_idx_rim_primary)))))
((coupled_pad_idx_rim_primary >= 0) && ((i == coupled_pad_idx_rim_secondary) || (i == coupled_pad_idx_rim_primary)))))
{
// special case: couple pad inputs for multiple head sensor capturing (assume that both pads have dual-inputs)
if ((i == coupled_pad_idx_primary) || (i == coupled_pad_idx_secondary))
Expand Down Expand Up @@ -246,14 +246,14 @@ void Edrumulus::process()
sample[0] = (sample[2] + sample[3] + sample[4]) / 3; // sum is on channel 0

pad[coupled_pad_idx_primary].process_sample(sample,
5,
overload_detected,
peak_found[coupled_pad_idx_primary],
midi_velocity[coupled_pad_idx_primary],
midi_pos[coupled_pad_idx_primary],
rim_state[coupled_pad_idx_primary],
is_choke_on[coupled_pad_idx_primary],
is_choke_off[coupled_pad_idx_primary]);
5,
overload_detected,
peak_found[coupled_pad_idx_primary],
midi_velocity[coupled_pad_idx_primary],
midi_pos[coupled_pad_idx_primary],
rim_state[coupled_pad_idx_primary],
is_choke_on[coupled_pad_idx_primary],
is_choke_off[coupled_pad_idx_primary]);
}
}

Expand Down Expand Up @@ -285,29 +285,29 @@ void Edrumulus::process()
}

pad[coupled_pad_idx_rim_primary].process_sample(sample,
3,
overload_detected,
peak_found[coupled_pad_idx_rim_primary],
midi_velocity[coupled_pad_idx_rim_primary],
midi_pos[coupled_pad_idx_rim_primary],
rim_state[coupled_pad_idx_rim_primary],
is_choke_on[coupled_pad_idx_rim_primary],
is_choke_off[coupled_pad_idx_rim_primary]);
3,
overload_detected,
peak_found[coupled_pad_idx_rim_primary],
midi_velocity[coupled_pad_idx_rim_primary],
midi_pos[coupled_pad_idx_rim_primary],
rim_state[coupled_pad_idx_rim_primary],
is_choke_on[coupled_pad_idx_rim_primary],
is_choke_off[coupled_pad_idx_rim_primary]);
}
}
}
else
{
// normal case: process samples directly
pad[i].process_sample(sample,
number_inputs[i],
overload_detected,
peak_found[i],
midi_velocity[i],
midi_pos[i],
rim_state[i],
is_choke_on[i],
is_choke_off[i]);
number_inputs[i],
overload_detected,
peak_found[i],
midi_velocity[i],
midi_pos[i],
rim_state[i],
is_choke_on[i],
is_choke_off[i]);
}
}
}
Expand Down Expand Up @@ -438,10 +438,10 @@ void Edrumulus::set_coupled_pad_idx(const int pad_idx, const int new_idx)
}

void Edrumulus::cancel_ADC_spikes(float& signal,
int& overload_detected,
const int pad_index,
const int input_channel_index,
const int level)
int& overload_detected,
const int pad_index,
const int input_channel_index,
const int level)
{
// remove single/dual sample spikes by checking if right before and right after the
// detected spike(s) we only have noise and no useful signal (since the ESP32 spikes
Expand Down
12 changes: 6 additions & 6 deletions edrumulus.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Edrumulus

// call this function during the Setup function of the main program
void setup(const int conf_num_pads,
const int* conf_analog_pins,
const int* conf_analog_pins_rim_shot);
const int* conf_analog_pins,
const int* conf_analog_pins_rim_shot);

// call the process function during the main loop
void process();
Expand Down Expand Up @@ -179,10 +179,10 @@ class Edrumulus

// ADC spike cancellation
void cancel_ADC_spikes(float& signal,
int& overload_detected,
const int pad_index,
const int input_channel_index,
const int level);
int& overload_detected,
const int pad_index,
const int input_channel_index,
const int level);

enum Espikestate
{
Expand Down
10 changes: 5 additions & 5 deletions edrumulus.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ void setup()
int* analog_pins = analog_pins4; // initialize with the default setup
int* analog_pins_rimshot = analog_pins_rimshot4; // initialize with the default setup
const int prototype = Edrumulus_hardware::get_prototype_pins(&analog_pins,
&analog_pins_rimshot,
&number_pads,
&status_LED_pin);
&analog_pins_rimshot,
&number_pads,
&status_LED_pin);

// initialize GPIO port for status LED and set it to on during setup
pinMode(status_LED_pin, OUTPUT);
Expand Down Expand Up @@ -462,8 +462,8 @@ void loop()
#ifdef USE_MIDI
// give feedback to the controller GUI via MIDI Note Off
void confirm_setting(const int controller,
const int value,
const bool send_all)
const int value,
const bool send_all)
{
if (send_all)
{
Expand Down
48 changes: 24 additions & 24 deletions hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Edrumulus_hardware::Edrumulus_hardware()
#ifdef TEENSYDUINO

int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin)
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin)
{
// clang-format off
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3
Expand All @@ -48,9 +48,9 @@ int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
}

void Edrumulus_hardware::setup(const int conf_Fs,
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS])
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS])
{
// set essential parameters
Fs = conf_Fs;
Expand Down Expand Up @@ -97,14 +97,14 @@ void Edrumulus_hardware::setup(const int conf_Fs,
}

void Edrumulus_hardware::write_setting(const int pad_index,
const int address,
const byte value)
const int address,
const byte value)
{
EEPROM.update(pad_index * MAX_NUM_SET_PER_PAD + address, value);
}

byte Edrumulus_hardware::read_setting(const int pad_index,
const int address)
const int address)
{
return EEPROM.read(pad_index * MAX_NUM_SET_PER_PAD + address);
}
Expand All @@ -116,9 +116,9 @@ void Edrumulus_hardware::on_timer()
}

void Edrumulus_hardware::capture_samples(const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS])
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS])
{
// wait for the timer to get the correct sampling rate when reading the analog value
while (!timer_ready) delayMicroseconds(5);
Expand Down Expand Up @@ -150,9 +150,9 @@ void Edrumulus_hardware::capture_samples(const int number_pads,
#ifdef ESP_PLATFORM

int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin)
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin)
{
# ifdef CONFIG_IDF_TARGET_ESP32
// Definition:
Expand Down Expand Up @@ -224,9 +224,9 @@ int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
}

void Edrumulus_hardware::setup(const int conf_Fs,
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS])
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS])
{
// set essential parameters
Fs = conf_Fs;
Expand Down Expand Up @@ -369,9 +369,9 @@ void IRAM_ATTR Edrumulus_hardware::on_timer()
}

void Edrumulus_hardware::capture_samples(const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS])
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS])
{
// wait for the timer to get the correct sampling rate when reading the analog value
if (xSemaphoreTake(timer_semaphore, portMAX_DELAY) == pdTRUE)
Expand Down Expand Up @@ -502,9 +502,9 @@ uint16_t Edrumulus_hardware::my_analogRead(const uint8_t pin)
}

void Edrumulus_hardware::my_analogRead_parallel(const uint32_t channel_adc1_bitval,
const uint32_t channel_adc2_bitval,
uint16_t& out_adc1,
uint16_t& out_adc2)
const uint32_t channel_adc2_bitval,
uint16_t& out_adc1,
uint16_t& out_adc2)
{
# ifdef CONFIG_IDF_TARGET_ESP32
// start ADC1
Expand Down
42 changes: 21 additions & 21 deletions hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ class Edrumulus_hardware
Edrumulus_hardware();

static int get_prototype_pins(int** analog_pins,
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin);
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin);

void setup(const int conf_Fs,
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS]);
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS]);

void capture_samples(const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS]);
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS]);

void write_setting(const int pad_index, const int address, const byte value);
byte read_setting(const int pad_index, const int address);
Expand Down Expand Up @@ -95,19 +95,19 @@ class Edrumulus_hardware
Edrumulus_hardware();

static int get_prototype_pins(int** analog_pins,
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin);
int** analog_pins_rimshot,
int* number_pins,
int* status_LED_pin);

void setup(const int conf_Fs,
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS]);
const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS]);

void capture_samples(const int number_pads,
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS]);
const int number_inputs[],
int analog_pin[][MAX_NUM_PAD_INPUTS],
int sample_org[][MAX_NUM_PAD_INPUTS]);

void write_setting(const int, const int, const byte){}; // not supported
byte read_setting(const int, const int) { return 0; }; // not supported
Expand All @@ -124,9 +124,9 @@ class Edrumulus_hardware
void init_my_analogRead();
uint16_t my_analogRead(const uint8_t pin);
void my_analogRead_parallel(const uint32_t channel_adc1_bitval,
const uint32_t channel_adc2_bitval,
uint16_t& out_adc1,
uint16_t& out_adc2);
const uint32_t channel_adc2_bitval,
uint16_t& out_adc1,
uint16_t& out_adc2);

int total_number_inputs;
int input_pin[MAX_NUM_PADS * MAX_NUM_PAD_INPUTS];
Expand Down
Loading

0 comments on commit 0d4d070

Please sign in to comment.