Skip to content

Commit 50ea61c

Browse files
authored
Merge pull request #760 from schollz/notinflash
feat: improve cpu usage in zeptocore by 10%
2 parents 078f565 + 2edcc3c commit 50ea61c

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

lib/bitcrush.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef LIB_BITCRUSH_H_
22
#define LIB_BITCRUSH_H_
33

4-
void Bitcrush_process(int16_t *values, uint16_t num_values, uint8_t sample_rate,
4+
void __not_in_flash_func(Bitcrush_process)(int16_t *values, uint16_t num_values, uint8_t sample_rate,
55
uint8_t bitrate) {
66
sample_rate = linlin(sample_rate, 0, 255, 1, 8);
77
bitrate = linlin(bitrate, 0, 255, 0, 12);

lib/comb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Comb *Comb_malloc() {
5252
return self;
5353
}
5454

55-
void Comb_process(Comb *self, int32_t *samples, uint16_t num_samples) {
55+
void __not_in_flash_func(Comb_process)(Comb *self, int32_t *samples, uint16_t num_samples) {
5656
for (int ii = 0; ii < num_samples; ii++) {
5757
if (!self->on) {
5858
self->ringbuffer[0][self->index] = samples[ii * 2 + 0];

lib/delay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void Delay_setFeedbackf(Delay *self, float feedback) {
6565
Delay_setFeedback(self, (uint8_t)(feedback * 8.0f));
6666
}
6767

68-
void Delay_process(Delay *self, int32_t *samples, uint16_t num_samples,
68+
void __not_in_flash_func(Delay_process)(Delay *self, int32_t *samples, uint16_t num_samples,
6969
uint8_t channel) {
7070
for (int ii = 0; ii < num_samples; ii++) {
7171
while (self->ringbuffer_index > self->duration) {

lib/envelope2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Envelope2 *Envelope2_create(uint32_t mSampleRate, float start, float stop,
3131
return envelope2;
3232
}
3333

34-
float Envelope2_update(Envelope2 *envelope2) {
34+
float __not_in_flash_func(Envelope2_update)(Envelope2 *envelope2) {
3535
if (envelope2->t < envelope2->duration_samples) {
3636
envelope2->t++;
3737
envelope2->curr = cos(M_PI * (envelope2->t) / envelope2->duration_samples);

lib/fixedpoint.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#define Q16_16_FRACTIONAL_BITS (1 << Q16_16_Q_BITS)
3434

3535
/* Converts a Q16.16 fixed-point value to an int16. */
36-
int16_t q16_16_fp_to_int16(int32_t fixedValue) {
36+
int16_t __not_in_flash_func(q16_16_fp_to_int16)(int32_t fixedValue) {
3737
/* Shift the fixed-point value right by the number of Q-bits to obtain the
3838
integral part of the value. */
3939
return (int16_t)(fixedValue >> Q16_16_Q_BITS);
@@ -71,7 +71,7 @@ int32_t q16_16_int32_to_fp(int32_t value) {
7171
}
7272

7373
/* Multiplies two Q16.16 fixed-point values. */
74-
int32_t q16_16_multiply(int32_t a, int32_t b) {
74+
int32_t __not_in_flash_func(q16_16_multiply)(int32_t a, int32_t b) {
7575
return (int32_t)((((int64_t)a) * b) >> Q16_16_Q_BITS);
7676
}
7777

@@ -80,7 +80,7 @@ int32_t q16_16_divide(int32_t a, int32_t b) {
8080
return (int32_t)(((int64_t)a << Q16_16_Q_BITS) / b);
8181
}
8282

83-
int32_t q16_16_sin(int32_t fixedValue) {
83+
int32_t __not_in_flash_func(q16_16_sin)(int32_t fixedValue) {
8484
uint8_t negative = 0;
8585
while (fixedValue < Q16_16_0) {
8686
fixedValue += Q16_16_PI;
@@ -112,7 +112,7 @@ int32_t q16_16_sin01(int32_t fixedValue) {
112112
return q16_16_multiply(Q16_16_0_5, sin5) + Q16_16_0_5;
113113
}
114114

115-
int32_t q16_16_cos(int32_t fixedValue) {
115+
int32_t __not_in_flash_func(q16_16_cos)(int32_t fixedValue) {
116116
return q16_16_multiply(Q16_16_MINUS_1,
117117
q16_16_sin(fixedValue - Q16_16_PI_OVER_2));
118118
}

main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ uint64_t repeating_timer_callback_playback_counter = 0;
1010
int32_t phase_sample_old = 0;
1111
// timer
1212

13-
bool timer_step() {
13+
bool __not_in_flash_func(timer_step)() {
1414
if (!fil_is_open) {
1515
return true;
1616
}
@@ -614,7 +614,7 @@ bool timer_step() {
614614
return true;
615615
}
616616

617-
bool repeating_timer_callback(struct repeating_timer *t) {
617+
bool __not_in_flash_func(repeating_timer_callback)(struct repeating_timer *t) {
618618
return timer_step();
619619
}
620620

@@ -651,9 +651,13 @@ int main() {
651651
#ifdef DO_OVERCLOCK
652652
#ifdef INCLUDE_BOARDCORE
653653
set_sys_clock_khz(150000, true);
654+
#else
655+
#ifdef INCLUDE_ZEPTOCORE
656+
set_sys_clock_khz(225000, true);
654657
#else
655658
set_sys_clock_khz(200000, true);
656659
#endif
660+
#endif
657661
#else
658662
set_sys_clock_khz(125000, true);
659663
#endif

0 commit comments

Comments
 (0)