diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index e250fbe9b2da..80491823e492 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -33,6 +33,10 @@ SRC_BITMAP := \ shared-bindings/audiocore/__init__.c \ shared-bindings/audiocore/RawSample.c \ shared-bindings/audiocore/WaveFile.c \ + shared-bindings/audiodelays/Echo.c \ + shared-bindings/audiodelays/__init__.c \ + shared-bindings/audiofilters/Filter.c \ + shared-bindings/audiofilters/__init__.c \ shared-bindings/audiomixer/__init__.c \ shared-bindings/audiomixer/Mixer.c \ shared-bindings/audiomixer/MixerVoice.c \ @@ -70,6 +74,10 @@ SRC_BITMAP := \ shared-module/audiocore/__init__.c \ shared-module/audiocore/RawSample.c \ shared-module/audiocore/WaveFile.c \ + shared-module/audiodelays/Echo.c \ + shared-module/audiodelays/__init__.c \ + shared-module/audiofilters/Filter.c \ + shared-module/audiofilters/__init__.c \ shared-module/audiomixer/__init__.c \ shared-module/audiomp3/MP3Decoder.c \ shared-module/audiomixer/Mixer.c \ @@ -127,6 +135,9 @@ $(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "shared-module/audiomp3/__ini CFLAGS += \ -DCIRCUITPY_AESIO=1 \ -DCIRCUITPY_AUDIOCORE=1 \ + -DCIRCUITPY_AUDIOEFFECTS=1 \ + -DCIRCUITPY_AUDIODELAYS=1 \ + -DCIRCUITPY_AUDIOFILTERS=1 \ -DCIRCUITPY_AUDIOMIXER=1 \ -DCIRCUITPY_AUDIOMP3=1 \ -DCIRCUITPY_AUDIOMP3_USE_PORT_ALLOCATOR=0 \ diff --git a/shared-module/audiodelays/Echo.c b/shared-module/audiodelays/Echo.c index a0c34c6540d8..e4eeff48f4c3 100644 --- a/shared-module/audiodelays/Echo.c +++ b/shared-module/audiodelays/Echo.c @@ -77,7 +77,7 @@ void common_hal_audiodelays_echo_construct(audiodelays_echo_obj_t *self, uint32_ // Allocate the echo buffer for the max possible delay, echo is always 16-bit self->max_delay_ms = max_delay_ms; - self->max_echo_buffer_len = self->sample_rate / 1000.0f * max_delay_ms * (self->channel_count * sizeof(uint16_t)); // bytes + self->max_echo_buffer_len = (uint32_t)(self->sample_rate / 1000.0f * max_delay_ms) * (self->channel_count * sizeof(uint16_t)); // bytes self->echo_buffer = m_malloc(self->max_echo_buffer_len); if (self->echo_buffer == NULL) { common_hal_audiodelays_echo_deinit(self); @@ -129,11 +129,11 @@ void common_hal_audiodelays_echo_set_delay_ms(audiodelays_echo_obj_t *self, mp_o void recalculate_delay(audiodelays_echo_obj_t *self, mp_float_t f_delay_ms) { if (self->freq_shift) { // Calculate the rate of iteration over the echo buffer with 8 sub-bits - self->echo_buffer_rate = MAX(self->max_delay_ms / f_delay_ms * 256.0f, 1.0); + self->echo_buffer_rate = (uint32_t)MAX(self->max_delay_ms / f_delay_ms * MICROPY_FLOAT_CONST(256.0), MICROPY_FLOAT_CONST(1.0)); self->echo_buffer_len = self->max_echo_buffer_len; } else { // Calculate the current echo buffer length in bytes - uint32_t new_echo_buffer_len = self->sample_rate / 1000.0f * f_delay_ms * (self->channel_count * sizeof(uint16_t)); + uint32_t new_echo_buffer_len = (uint32_t)(self->sample_rate / MICROPY_FLOAT_CONST(1000.0) * f_delay_ms) * (self->channel_count * sizeof(uint16_t)); // Check if our new echo is too long for our maximum buffer if (new_echo_buffer_len > self->max_echo_buffer_len) { @@ -153,7 +153,7 @@ void recalculate_delay(audiodelays_echo_obj_t *self, mp_float_t f_delay_ms) { memset(self->echo_buffer + self->echo_buffer_len, 0, self->max_echo_buffer_len - self->echo_buffer_len); } - self->current_delay_ms = f_delay_ms; + self->current_delay_ms = (uint32_t)f_delay_ms; } mp_obj_t common_hal_audiodelays_echo_get_decay(audiodelays_echo_obj_t *self) { @@ -360,17 +360,17 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * echo = echo_buffer[echo_buffer_pos >> 8]; next_buffer_pos = echo_buffer_pos + self->echo_buffer_rate; - word = echo * decay; + word = (int16_t)(echo * decay); for (uint32_t j = echo_buffer_pos >> 8; j < next_buffer_pos >> 8; j++) { echo_buffer[j % echo_buf_len] = word; } } else { echo = echo_buffer[self->echo_buffer_read_pos++]; - word = echo * decay; + word = (int16_t)(echo * decay); echo_buffer[self->echo_buffer_write_pos++] = word; } - word = echo * mix; + word = (int16_t)(echo * mix); if (MP_LIKELY(self->bits_per_sample == 16)) { word_buffer[i] = word; @@ -433,10 +433,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * if (self->freq_shift) { echo = echo_buffer[echo_buffer_pos >> 8]; next_buffer_pos = echo_buffer_pos + self->echo_buffer_rate; - word = echo * decay + sample_word; + word = (int32_t)(echo * decay + sample_word); } else { echo = echo_buffer[self->echo_buffer_read_pos++]; - word = echo * decay + sample_word; + word = (int32_t)(echo * decay + sample_word); } if (MP_LIKELY(self->bits_per_sample == 16)) { @@ -467,12 +467,12 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * word = echo + sample_word; if (MP_LIKELY(self->bits_per_sample == 16)) { - word_buffer[i] = (sample_word * (1.0 - mix)) + (word * mix); + word_buffer[i] = (int16_t)((sample_word * (1.0 - mix)) + (word * mix)); if (!self->samples_signed) { word_buffer[i] ^= 0x8000; } } else { - int8_t mixed = (sample_word * (1.0 - mix)) + (word * mix); + int8_t mixed = (int16_t)((sample_word * (1.0 - mix)) + (word * mix)); if (self->samples_signed) { hword_buffer[i] = mixed; } else { diff --git a/shared-module/audiofilters/Filter.c b/shared-module/audiofilters/Filter.c index d7ee30e8ea66..6b8fc85dd4e2 100644 --- a/shared-module/audiofilters/Filter.c +++ b/shared-module/audiofilters/Filter.c @@ -204,6 +204,7 @@ int16_t mix_down_sample(int32_t sample) { audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + (void)channel; if (!single_channel_output) { channel = 0; @@ -297,7 +298,7 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o // Mix processed signal with original sample and transfer to output buffer for (uint32_t j = 0; j < n_samples; j++) { if (MP_LIKELY(self->bits_per_sample == 16)) { - word_buffer[i + j] = mix_down_sample((sample_src[i + j] * (1.0 - mix)) + (self->filter_buffer[j] * mix)); + word_buffer[i + j] = mix_down_sample((int32_t)((sample_src[i + j] * (MICROPY_FLOAT_CONST(1.0) - mix)) + (self->filter_buffer[j] * mix))); if (!self->samples_signed) { word_buffer[i + j] ^= 0x8000; } @@ -305,7 +306,7 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o if (self->samples_signed) { hword_buffer[i + j] = (int8_t)((sample_hsrc[i + j] * (1.0 - mix)) + (self->filter_buffer[j] * mix)); } else { - hword_buffer[i + j] = (uint8_t)(((int8_t)(((uint8_t)sample_hsrc[i + j]) ^ 0x80) * (1.0 - mix)) + (self->filter_buffer[j] * mix)) ^ 0x80; + hword_buffer[i + j] = (uint8_t)(((int8_t)(((uint8_t)sample_hsrc[i + j]) ^ 0x80) * (MICROPY_FLOAT_CONST(1.0) - mix)) + (self->filter_buffer[j] * mix)) ^ 0x80; } } } diff --git a/tests/circuitpython/audiofilter_filter.py b/tests/circuitpython/audiofilter_filter.py new file mode 100644 index 000000000000..3267ded43979 --- /dev/null +++ b/tests/circuitpython/audiofilter_filter.py @@ -0,0 +1,16 @@ +from audiofilters import Filter +from audiofilterhelper import synth_test, sine8k + +@synth_test +def basic_filter(): + effect = Filter( + bits_per_sample=16, + samples_signed=True, + ) + yield effect, [] + + effect.play(sine8k, loop=True) + yield 4 + + effect.stop() + yield 2 diff --git a/tests/circuitpython/audiofilter_filter.py.exp b/tests/circuitpython/audiofilter_filter.py.exp new file mode 100644 index 000000000000..734ac16b3a79 --- /dev/null +++ b/tests/circuitpython/audiofilter_filter.py.exp @@ -0,0 +1,1536 @@ +0 0.0 +1 0.010467529296875 +2 0.02093505859375 +3 0.031402587890625 +4 0.0418701171875 +5 0.05230712890625 +6 0.062774658203125 +7 0.073211669921875 +8 0.083648681640625 +9 0.094085693359375 +10 0.104522705078125 +11 0.11492919921875 +12 0.12530517578125 +13 0.13568115234375 +14 0.14605712890625 +15 0.156402587890625 +16 0.166748046875 +17 0.17706298828125 +18 0.187347412109375 +19 0.1976318359375 +20 0.2078857421875 +21 0.218109130859375 +22 0.22833251953125 +23 0.238525390625 +24 0.2486572265625 +25 0.2587890625 +26 0.268890380859375 +27 0.278961181640625 +28 0.28900146484375 +29 0.29901123046875 +30 0.308990478515625 +31 0.318939208984375 +32 0.328826904296875 +33 0.338714599609375 +34 0.348541259765625 +35 0.35833740234375 +36 0.36810302734375 +37 0.3778076171875 +38 0.387481689453125 +39 0.397125244140625 +40 0.406707763671875 +41 0.416259765625 +42 0.425750732421875 +43 0.435211181640625 +44 0.444610595703125 +45 0.453948974609375 +46 0.4632568359375 +47 0.4725341796875 +48 0.481719970703125 +49 0.490875244140625 +50 0.499969482421875 +51 0.509002685546875 +52 0.51800537109375 +53 0.52691650390625 +54 0.535797119140625 +55 0.54461669921875 +56 0.5533447265625 +57 0.562042236328125 +58 0.5706787109375 +59 0.579254150390625 +60 0.587738037109375 +61 0.59619140625 +62 0.60455322265625 +63 0.612884521484375 +64 0.621124267578125 +65 0.6292724609375 +66 0.63739013671875 +67 0.645416259765625 +68 0.65338134765625 +69 0.661285400390625 +70 0.669097900390625 +71 0.676849365234375 +72 0.68450927734375 +73 0.692108154296875 +74 0.699615478515625 +75 0.707061767578125 +76 0.714447021484375 +77 0.721710205078125 +78 0.72894287109375 +79 0.736053466796875 +80 0.74310302734375 +81 0.75006103515625 +82 0.7569580078125 +83 0.763763427734375 +84 0.770477294921875 +85 0.777099609375 +86 0.783660888671875 +87 0.790130615234375 +88 0.796478271484375 +89 0.802764892578125 +90 0.808990478515625 +91 0.815093994140625 +92 0.82110595703125 +93 0.8270263671875 +94 0.8328857421875 +95 0.838623046875 +96 0.84429931640625 +97 0.849853515625 +98 0.855316162109375 +99 0.860687255859375 +100 0.865997314453125 +101 0.871185302734375 +102 0.876251220703125 +103 0.881256103515625 +104 0.88616943359375 +105 0.890960693359375 +106 0.895660400390625 +107 0.9002685546875 +108 0.90478515625 +109 0.9091796875 +110 0.91351318359375 +111 0.917724609375 +112 0.92181396484375 +113 0.92584228515625 +114 0.929718017578125 +115 0.93353271484375 +116 0.937225341796875 +117 0.940826416015625 +118 0.9443359375 +119 0.947723388671875 +120 0.951019287109375 +121 0.954193115234375 +122 0.957275390625 +123 0.960235595703125 +124 0.963104248046875 +125 0.96588134765625 +126 0.968536376953125 +127 0.971099853515625 +128 0.973541259765625 +129 0.975860595703125 +130 0.97808837890625 +131 0.980224609375 +132 0.98223876953125 +133 0.984161376953125 +134 0.9859619140625 +135 0.987640380859375 +136 0.989227294921875 +137 0.990692138671875 +138 0.9920654296875 +139 0.993316650390625 +140 0.994476318359375 +141 0.995513916015625 +142 0.9964599609375 +143 0.997283935546875 +144 0.99798583984375 +145 0.99859619140625 +146 0.99908447265625 +147 0.99945068359375 +148 0.999725341796875 +149 0.999908447265625 +150 0.999969482421875 +151 0.999908447265625 +152 0.999725341796875 +153 0.99945068359375 +154 0.99908447265625 +155 0.99859619140625 +156 0.99798583984375 +157 0.997283935546875 +158 0.9964599609375 +159 0.995513916015625 +160 0.994476318359375 +161 0.993316650390625 +162 0.9920654296875 +163 0.990692138671875 +164 0.989227294921875 +165 0.987640380859375 +166 0.9859619140625 +167 0.984161376953125 +168 0.98223876953125 +169 0.980224609375 +170 0.97808837890625 +171 0.975860595703125 +172 0.973541259765625 +173 0.971099853515625 +174 0.968536376953125 +175 0.96588134765625 +176 0.963104248046875 +177 0.960235595703125 +178 0.957275390625 +179 0.954193115234375 +180 0.951019287109375 +181 0.947723388671875 +182 0.9443359375 +183 0.940826416015625 +184 0.937225341796875 +185 0.93353271484375 +186 0.929718017578125 +187 0.92584228515625 +188 0.92181396484375 +189 0.917724609375 +190 0.91351318359375 +191 0.9091796875 +192 0.90478515625 +193 0.9002685546875 +194 0.895660400390625 +195 0.890960693359375 +196 0.88616943359375 +197 0.881256103515625 +198 0.876251220703125 +199 0.871185302734375 +200 0.865997314453125 +201 0.860687255859375 +202 0.855316162109375 +203 0.849853515625 +204 0.84429931640625 +205 0.838623046875 +206 0.8328857421875 +207 0.8270263671875 +208 0.82110595703125 +209 0.815093994140625 +210 0.808990478515625 +211 0.802764892578125 +212 0.796478271484375 +213 0.790130615234375 +214 0.783660888671875 +215 0.777099609375 +216 0.770477294921875 +217 0.763763427734375 +218 0.7569580078125 +219 0.75006103515625 +220 0.74310302734375 +221 0.736053466796875 +222 0.72894287109375 +223 0.721710205078125 +224 0.714447021484375 +225 0.707061767578125 +226 0.699615478515625 +227 0.692108154296875 +228 0.68450927734375 +229 0.676849365234375 +230 0.669097900390625 +231 0.661285400390625 +232 0.65338134765625 +233 0.645416259765625 +234 0.63739013671875 +235 0.6292724609375 +236 0.621124267578125 +237 0.612884521484375 +238 0.60455322265625 +239 0.59619140625 +240 0.587738037109375 +241 0.579254150390625 +242 0.5706787109375 +243 0.562042236328125 +244 0.5533447265625 +245 0.54461669921875 +246 0.535797119140625 +247 0.52691650390625 +248 0.51800537109375 +249 0.509002685546875 +250 0.499969482421875 +251 0.490875244140625 +252 0.481719970703125 +253 0.4725341796875 +254 0.4632568359375 +255 0.453948974609375 +256 0.444610595703125 +257 0.435211181640625 +258 0.425750732421875 +259 0.416259765625 +260 0.406707763671875 +261 0.397125244140625 +262 0.387481689453125 +263 0.3778076171875 +264 0.36810302734375 +265 0.35833740234375 +266 0.348541259765625 +267 0.338714599609375 +268 0.328826904296875 +269 0.318939208984375 +270 0.308990478515625 +271 0.29901123046875 +272 0.28900146484375 +273 0.278961181640625 +274 0.268890380859375 +275 0.2587890625 +276 0.2486572265625 +277 0.238525390625 +278 0.22833251953125 +279 0.218109130859375 +280 0.2078857421875 +281 0.1976318359375 +282 0.187347412109375 +283 0.17706298828125 +284 0.166748046875 +285 0.156402587890625 +286 0.14605712890625 +287 0.13568115234375 +288 0.12530517578125 +289 0.11492919921875 +290 0.104522705078125 +291 0.094085693359375 +292 0.083648681640625 +293 0.073211669921875 +294 0.062774658203125 +295 0.05230712890625 +296 0.0418701171875 +297 0.031402587890625 +298 0.02093505859375 +299 0.010467529296875 +300 0.0 +301 -0.010467529296875 +302 -0.02093505859375 +303 -0.031402587890625 +304 -0.0418701171875 +305 -0.05230712890625 +306 -0.062774658203125 +307 -0.073211669921875 +308 -0.083648681640625 +309 -0.094085693359375 +310 -0.104522705078125 +311 -0.11492919921875 +312 -0.12530517578125 +313 -0.13568115234375 +314 -0.14605712890625 +315 -0.156402587890625 +316 -0.166748046875 +317 -0.17706298828125 +318 -0.187347412109375 +319 -0.1976318359375 +320 -0.2078857421875 +321 -0.218109130859375 +322 -0.22833251953125 +323 -0.238525390625 +324 -0.2486572265625 +325 -0.2587890625 +326 -0.268890380859375 +327 -0.278961181640625 +328 -0.28900146484375 +329 -0.29901123046875 +330 -0.308990478515625 +331 -0.318939208984375 +332 -0.328826904296875 +333 -0.338714599609375 +334 -0.348541259765625 +335 -0.35833740234375 +336 -0.36810302734375 +337 -0.3778076171875 +338 -0.387481689453125 +339 -0.397125244140625 +340 -0.406707763671875 +341 -0.416259765625 +342 -0.425750732421875 +343 -0.435211181640625 +344 -0.444610595703125 +345 -0.453948974609375 +346 -0.4632568359375 +347 -0.4725341796875 +348 -0.481719970703125 +349 -0.490875244140625 +350 -0.499969482421875 +351 -0.509002685546875 +352 -0.51800537109375 +353 -0.52691650390625 +354 -0.535797119140625 +355 -0.54461669921875 +356 -0.5533447265625 +357 -0.562042236328125 +358 -0.5706787109375 +359 -0.579254150390625 +360 -0.587738037109375 +361 -0.59619140625 +362 -0.60455322265625 +363 -0.612884521484375 +364 -0.621124267578125 +365 -0.6292724609375 +366 -0.63739013671875 +367 -0.645416259765625 +368 -0.65338134765625 +369 -0.661285400390625 +370 -0.669097900390625 +371 -0.676849365234375 +372 -0.68450927734375 +373 -0.692108154296875 +374 -0.699615478515625 +375 -0.707061767578125 +376 -0.714447021484375 +377 -0.721710205078125 +378 -0.72894287109375 +379 -0.736053466796875 +380 -0.74310302734375 +381 -0.75006103515625 +382 -0.7569580078125 +383 -0.763763427734375 +384 -0.770477294921875 +385 -0.777099609375 +386 -0.783660888671875 +387 -0.790130615234375 +388 -0.796478271484375 +389 -0.802764892578125 +390 -0.808990478515625 +391 -0.815093994140625 +392 -0.82110595703125 +393 -0.8270263671875 +394 -0.8328857421875 +395 -0.838623046875 +396 -0.84429931640625 +397 -0.849853515625 +398 -0.855316162109375 +399 -0.860687255859375 +400 -0.865997314453125 +401 -0.871185302734375 +402 -0.876251220703125 +403 -0.881256103515625 +404 -0.88616943359375 +405 -0.890960693359375 +406 -0.895660400390625 +407 -0.9002685546875 +408 -0.90478515625 +409 -0.9091796875 +410 -0.91351318359375 +411 -0.917724609375 +412 -0.92181396484375 +413 -0.92584228515625 +414 -0.929718017578125 +415 -0.93353271484375 +416 -0.937225341796875 +417 -0.940826416015625 +418 -0.9443359375 +419 -0.947723388671875 +420 -0.951019287109375 +421 -0.954193115234375 +422 -0.957275390625 +423 -0.960235595703125 +424 -0.963104248046875 +425 -0.96588134765625 +426 -0.968536376953125 +427 -0.971099853515625 +428 -0.973541259765625 +429 -0.975860595703125 +430 -0.97808837890625 +431 -0.980224609375 +432 -0.98223876953125 +433 -0.984161376953125 +434 -0.9859619140625 +435 -0.987640380859375 +436 -0.989227294921875 +437 -0.990692138671875 +438 -0.9920654296875 +439 -0.993316650390625 +440 -0.994476318359375 +441 -0.995513916015625 +442 -0.9964599609375 +443 -0.997283935546875 +444 -0.99798583984375 +445 -0.99859619140625 +446 -0.99908447265625 +447 -0.99945068359375 +448 -0.999725341796875 +449 -0.999908447265625 +450 -0.999969482421875 +451 -0.999908447265625 +452 -0.999725341796875 +453 -0.99945068359375 +454 -0.99908447265625 +455 -0.99859619140625 +456 -0.99798583984375 +457 -0.997283935546875 +458 -0.9964599609375 +459 -0.995513916015625 +460 -0.994476318359375 +461 -0.993316650390625 +462 -0.9920654296875 +463 -0.990692138671875 +464 -0.989227294921875 +465 -0.987640380859375 +466 -0.9859619140625 +467 -0.984161376953125 +468 -0.98223876953125 +469 -0.980224609375 +470 -0.97808837890625 +471 -0.975860595703125 +472 -0.973541259765625 +473 -0.971099853515625 +474 -0.968536376953125 +475 -0.96588134765625 +476 -0.963104248046875 +477 -0.960235595703125 +478 -0.957275390625 +479 -0.954193115234375 +480 -0.951019287109375 +481 -0.947723388671875 +482 -0.9443359375 +483 -0.940826416015625 +484 -0.937225341796875 +485 -0.93353271484375 +486 -0.929718017578125 +487 -0.92584228515625 +488 -0.92181396484375 +489 -0.917724609375 +490 -0.91351318359375 +491 -0.9091796875 +492 -0.90478515625 +493 -0.9002685546875 +494 -0.895660400390625 +495 -0.890960693359375 +496 -0.88616943359375 +497 -0.881256103515625 +498 -0.876251220703125 +499 -0.871185302734375 +500 -0.865997314453125 +501 -0.860687255859375 +502 -0.855316162109375 +503 -0.849853515625 +504 -0.84429931640625 +505 -0.838623046875 +506 -0.8328857421875 +507 -0.8270263671875 +508 -0.82110595703125 +509 -0.815093994140625 +510 -0.808990478515625 +511 -0.802764892578125 +512 -0.796478271484375 +513 -0.790130615234375 +514 -0.783660888671875 +515 -0.777099609375 +516 -0.770477294921875 +517 -0.763763427734375 +518 -0.7569580078125 +519 -0.75006103515625 +520 -0.74310302734375 +521 -0.736053466796875 +522 -0.72894287109375 +523 -0.721710205078125 +524 -0.714447021484375 +525 -0.707061767578125 +526 -0.699615478515625 +527 -0.692108154296875 +528 -0.68450927734375 +529 -0.676849365234375 +530 -0.669097900390625 +531 -0.661285400390625 +532 -0.65338134765625 +533 -0.645416259765625 +534 -0.63739013671875 +535 -0.6292724609375 +536 -0.621124267578125 +537 -0.612884521484375 +538 -0.60455322265625 +539 -0.59619140625 +540 -0.587738037109375 +541 -0.579254150390625 +542 -0.5706787109375 +543 -0.562042236328125 +544 -0.5533447265625 +545 -0.54461669921875 +546 -0.535797119140625 +547 -0.52691650390625 +548 -0.51800537109375 +549 -0.509002685546875 +550 -0.499969482421875 +551 -0.490875244140625 +552 -0.481719970703125 +553 -0.4725341796875 +554 -0.4632568359375 +555 -0.453948974609375 +556 -0.444610595703125 +557 -0.435211181640625 +558 -0.425750732421875 +559 -0.416259765625 +560 -0.406707763671875 +561 -0.397125244140625 +562 -0.387481689453125 +563 -0.3778076171875 +564 -0.36810302734375 +565 -0.35833740234375 +566 -0.348541259765625 +567 -0.338714599609375 +568 -0.328826904296875 +569 -0.318939208984375 +570 -0.308990478515625 +571 -0.29901123046875 +572 -0.28900146484375 +573 -0.278961181640625 +574 -0.268890380859375 +575 -0.2587890625 +576 -0.2486572265625 +577 -0.238525390625 +578 -0.22833251953125 +579 -0.218109130859375 +580 -0.2078857421875 +581 -0.1976318359375 +582 -0.187347412109375 +583 -0.17706298828125 +584 -0.166748046875 +585 -0.156402587890625 +586 -0.14605712890625 +587 -0.13568115234375 +588 -0.12530517578125 +589 -0.11492919921875 +590 -0.104522705078125 +591 -0.094085693359375 +592 -0.083648681640625 +593 -0.073211669921875 +594 -0.062774658203125 +595 -0.05230712890625 +596 -0.0418701171875 +597 -0.031402587890625 +598 -0.02093505859375 +599 -0.010467529296875 +600 0.0 +601 0.010467529296875 +602 0.02093505859375 +603 0.031402587890625 +604 0.0418701171875 +605 0.05230712890625 +606 0.062774658203125 +607 0.073211669921875 +608 0.083648681640625 +609 0.094085693359375 +610 0.104522705078125 +611 0.11492919921875 +612 0.12530517578125 +613 0.13568115234375 +614 0.14605712890625 +615 0.156402587890625 +616 0.166748046875 +617 0.17706298828125 +618 0.187347412109375 +619 0.1976318359375 +620 0.2078857421875 +621 0.218109130859375 +622 0.22833251953125 +623 0.238525390625 +624 0.2486572265625 +625 0.2587890625 +626 0.268890380859375 +627 0.278961181640625 +628 0.28900146484375 +629 0.29901123046875 +630 0.308990478515625 +631 0.318939208984375 +632 0.328826904296875 +633 0.338714599609375 +634 0.348541259765625 +635 0.35833740234375 +636 0.36810302734375 +637 0.3778076171875 +638 0.387481689453125 +639 0.397125244140625 +640 0.406707763671875 +641 0.416259765625 +642 0.425750732421875 +643 0.435211181640625 +644 0.444610595703125 +645 0.453948974609375 +646 0.4632568359375 +647 0.4725341796875 +648 0.481719970703125 +649 0.490875244140625 +650 0.499969482421875 +651 0.509002685546875 +652 0.51800537109375 +653 0.52691650390625 +654 0.535797119140625 +655 0.54461669921875 +656 0.5533447265625 +657 0.562042236328125 +658 0.5706787109375 +659 0.579254150390625 +660 0.587738037109375 +661 0.59619140625 +662 0.60455322265625 +663 0.612884521484375 +664 0.621124267578125 +665 0.6292724609375 +666 0.63739013671875 +667 0.645416259765625 +668 0.65338134765625 +669 0.661285400390625 +670 0.669097900390625 +671 0.676849365234375 +672 0.68450927734375 +673 0.692108154296875 +674 0.699615478515625 +675 0.707061767578125 +676 0.714447021484375 +677 0.721710205078125 +678 0.72894287109375 +679 0.736053466796875 +680 0.74310302734375 +681 0.75006103515625 +682 0.7569580078125 +683 0.763763427734375 +684 0.770477294921875 +685 0.777099609375 +686 0.783660888671875 +687 0.790130615234375 +688 0.796478271484375 +689 0.802764892578125 +690 0.808990478515625 +691 0.815093994140625 +692 0.82110595703125 +693 0.8270263671875 +694 0.8328857421875 +695 0.838623046875 +696 0.84429931640625 +697 0.849853515625 +698 0.855316162109375 +699 0.860687255859375 +700 0.865997314453125 +701 0.871185302734375 +702 0.876251220703125 +703 0.881256103515625 +704 0.88616943359375 +705 0.890960693359375 +706 0.895660400390625 +707 0.9002685546875 +708 0.90478515625 +709 0.9091796875 +710 0.91351318359375 +711 0.917724609375 +712 0.92181396484375 +713 0.92584228515625 +714 0.929718017578125 +715 0.93353271484375 +716 0.937225341796875 +717 0.940826416015625 +718 0.9443359375 +719 0.947723388671875 +720 0.951019287109375 +721 0.954193115234375 +722 0.957275390625 +723 0.960235595703125 +724 0.963104248046875 +725 0.96588134765625 +726 0.968536376953125 +727 0.971099853515625 +728 0.973541259765625 +729 0.975860595703125 +730 0.97808837890625 +731 0.980224609375 +732 0.98223876953125 +733 0.984161376953125 +734 0.9859619140625 +735 0.987640380859375 +736 0.989227294921875 +737 0.990692138671875 +738 0.9920654296875 +739 0.993316650390625 +740 0.994476318359375 +741 0.995513916015625 +742 0.9964599609375 +743 0.997283935546875 +744 0.99798583984375 +745 0.99859619140625 +746 0.99908447265625 +747 0.99945068359375 +748 0.999725341796875 +749 0.999908447265625 +750 0.999969482421875 +751 0.999908447265625 +752 0.999725341796875 +753 0.99945068359375 +754 0.99908447265625 +755 0.99859619140625 +756 0.99798583984375 +757 0.997283935546875 +758 0.9964599609375 +759 0.995513916015625 +760 0.994476318359375 +761 0.993316650390625 +762 0.9920654296875 +763 0.990692138671875 +764 0.989227294921875 +765 0.987640380859375 +766 0.9859619140625 +767 0.984161376953125 +768 0.98223876953125 +769 0.980224609375 +770 0.97808837890625 +771 0.975860595703125 +772 0.973541259765625 +773 0.971099853515625 +774 0.968536376953125 +775 0.96588134765625 +776 0.963104248046875 +777 0.960235595703125 +778 0.957275390625 +779 0.954193115234375 +780 0.951019287109375 +781 0.947723388671875 +782 0.9443359375 +783 0.940826416015625 +784 0.937225341796875 +785 0.93353271484375 +786 0.929718017578125 +787 0.92584228515625 +788 0.92181396484375 +789 0.917724609375 +790 0.91351318359375 +791 0.9091796875 +792 0.90478515625 +793 0.9002685546875 +794 0.895660400390625 +795 0.890960693359375 +796 0.88616943359375 +797 0.881256103515625 +798 0.876251220703125 +799 0.871185302734375 +800 0.865997314453125 +801 0.860687255859375 +802 0.855316162109375 +803 0.849853515625 +804 0.84429931640625 +805 0.838623046875 +806 0.8328857421875 +807 0.8270263671875 +808 0.82110595703125 +809 0.815093994140625 +810 0.808990478515625 +811 0.802764892578125 +812 0.796478271484375 +813 0.790130615234375 +814 0.783660888671875 +815 0.777099609375 +816 0.770477294921875 +817 0.763763427734375 +818 0.7569580078125 +819 0.75006103515625 +820 0.74310302734375 +821 0.736053466796875 +822 0.72894287109375 +823 0.721710205078125 +824 0.714447021484375 +825 0.707061767578125 +826 0.699615478515625 +827 0.692108154296875 +828 0.68450927734375 +829 0.676849365234375 +830 0.669097900390625 +831 0.661285400390625 +832 0.65338134765625 +833 0.645416259765625 +834 0.63739013671875 +835 0.6292724609375 +836 0.621124267578125 +837 0.612884521484375 +838 0.60455322265625 +839 0.59619140625 +840 0.587738037109375 +841 0.579254150390625 +842 0.5706787109375 +843 0.562042236328125 +844 0.5533447265625 +845 0.54461669921875 +846 0.535797119140625 +847 0.52691650390625 +848 0.51800537109375 +849 0.509002685546875 +850 0.499969482421875 +851 0.490875244140625 +852 0.481719970703125 +853 0.4725341796875 +854 0.4632568359375 +855 0.453948974609375 +856 0.444610595703125 +857 0.435211181640625 +858 0.425750732421875 +859 0.416259765625 +860 0.406707763671875 +861 0.397125244140625 +862 0.387481689453125 +863 0.3778076171875 +864 0.36810302734375 +865 0.35833740234375 +866 0.348541259765625 +867 0.338714599609375 +868 0.328826904296875 +869 0.318939208984375 +870 0.308990478515625 +871 0.29901123046875 +872 0.28900146484375 +873 0.278961181640625 +874 0.268890380859375 +875 0.2587890625 +876 0.2486572265625 +877 0.238525390625 +878 0.22833251953125 +879 0.218109130859375 +880 0.2078857421875 +881 0.1976318359375 +882 0.187347412109375 +883 0.17706298828125 +884 0.166748046875 +885 0.156402587890625 +886 0.14605712890625 +887 0.13568115234375 +888 0.12530517578125 +889 0.11492919921875 +890 0.104522705078125 +891 0.094085693359375 +892 0.083648681640625 +893 0.073211669921875 +894 0.062774658203125 +895 0.05230712890625 +896 0.0418701171875 +897 0.031402587890625 +898 0.02093505859375 +899 0.010467529296875 +900 0.0 +901 -0.010467529296875 +902 -0.02093505859375 +903 -0.031402587890625 +904 -0.0418701171875 +905 -0.05230712890625 +906 -0.062774658203125 +907 -0.073211669921875 +908 -0.083648681640625 +909 -0.094085693359375 +910 -0.104522705078125 +911 -0.11492919921875 +912 -0.12530517578125 +913 -0.13568115234375 +914 -0.14605712890625 +915 -0.156402587890625 +916 -0.166748046875 +917 -0.17706298828125 +918 -0.187347412109375 +919 -0.1976318359375 +920 -0.2078857421875 +921 -0.218109130859375 +922 -0.22833251953125 +923 -0.238525390625 +924 -0.2486572265625 +925 -0.2587890625 +926 -0.268890380859375 +927 -0.278961181640625 +928 -0.28900146484375 +929 -0.29901123046875 +930 -0.308990478515625 +931 -0.318939208984375 +932 -0.328826904296875 +933 -0.338714599609375 +934 -0.348541259765625 +935 -0.35833740234375 +936 -0.36810302734375 +937 -0.3778076171875 +938 -0.387481689453125 +939 -0.397125244140625 +940 -0.406707763671875 +941 -0.416259765625 +942 -0.425750732421875 +943 -0.435211181640625 +944 -0.444610595703125 +945 -0.453948974609375 +946 -0.4632568359375 +947 -0.4725341796875 +948 -0.481719970703125 +949 -0.490875244140625 +950 -0.499969482421875 +951 -0.509002685546875 +952 -0.51800537109375 +953 -0.52691650390625 +954 -0.535797119140625 +955 -0.54461669921875 +956 -0.5533447265625 +957 -0.562042236328125 +958 -0.5706787109375 +959 -0.579254150390625 +960 -0.587738037109375 +961 -0.59619140625 +962 -0.60455322265625 +963 -0.612884521484375 +964 -0.621124267578125 +965 -0.6292724609375 +966 -0.63739013671875 +967 -0.645416259765625 +968 -0.65338134765625 +969 -0.661285400390625 +970 -0.669097900390625 +971 -0.676849365234375 +972 -0.68450927734375 +973 -0.692108154296875 +974 -0.699615478515625 +975 -0.707061767578125 +976 -0.714447021484375 +977 -0.721710205078125 +978 -0.72894287109375 +979 -0.736053466796875 +980 -0.74310302734375 +981 -0.75006103515625 +982 -0.7569580078125 +983 -0.763763427734375 +984 -0.770477294921875 +985 -0.777099609375 +986 -0.783660888671875 +987 -0.790130615234375 +988 -0.796478271484375 +989 -0.802764892578125 +990 -0.808990478515625 +991 -0.815093994140625 +992 -0.82110595703125 +993 -0.8270263671875 +994 -0.8328857421875 +995 -0.838623046875 +996 -0.84429931640625 +997 -0.849853515625 +998 -0.855316162109375 +999 -0.860687255859375 +1000 -0.865997314453125 +1001 -0.871185302734375 +1002 -0.876251220703125 +1003 -0.881256103515625 +1004 -0.88616943359375 +1005 -0.890960693359375 +1006 -0.895660400390625 +1007 -0.9002685546875 +1008 -0.90478515625 +1009 -0.9091796875 +1010 -0.91351318359375 +1011 -0.917724609375 +1012 -0.92181396484375 +1013 -0.92584228515625 +1014 -0.929718017578125 +1015 -0.93353271484375 +1016 -0.937225341796875 +1017 -0.940826416015625 +1018 -0.9443359375 +1019 -0.947723388671875 +1020 -0.951019287109375 +1021 -0.954193115234375 +1022 -0.957275390625 +1023 -0.960235595703125 +1024 0.0 +1025 0.0 +1026 0.0 +1027 0.0 +1028 0.0 +1029 0.0 +1030 0.0 +1031 0.0 +1032 0.0 +1033 0.0 +1034 0.0 +1035 0.0 +1036 0.0 +1037 0.0 +1038 0.0 +1039 0.0 +1040 0.0 +1041 0.0 +1042 0.0 +1043 0.0 +1044 0.0 +1045 0.0 +1046 0.0 +1047 0.0 +1048 0.0 +1049 0.0 +1050 0.0 +1051 0.0 +1052 0.0 +1053 0.0 +1054 0.0 +1055 0.0 +1056 0.0 +1057 0.0 +1058 0.0 +1059 0.0 +1060 0.0 +1061 0.0 +1062 0.0 +1063 0.0 +1064 0.0 +1065 0.0 +1066 0.0 +1067 0.0 +1068 0.0 +1069 0.0 +1070 0.0 +1071 0.0 +1072 0.0 +1073 0.0 +1074 0.0 +1075 0.0 +1076 0.0 +1077 0.0 +1078 0.0 +1079 0.0 +1080 0.0 +1081 0.0 +1082 0.0 +1083 0.0 +1084 0.0 +1085 0.0 +1086 0.0 +1087 0.0 +1088 0.0 +1089 0.0 +1090 0.0 +1091 0.0 +1092 0.0 +1093 0.0 +1094 0.0 +1095 0.0 +1096 0.0 +1097 0.0 +1098 0.0 +1099 0.0 +1100 0.0 +1101 0.0 +1102 0.0 +1103 0.0 +1104 0.0 +1105 0.0 +1106 0.0 +1107 0.0 +1108 0.0 +1109 0.0 +1110 0.0 +1111 0.0 +1112 0.0 +1113 0.0 +1114 0.0 +1115 0.0 +1116 0.0 +1117 0.0 +1118 0.0 +1119 0.0 +1120 0.0 +1121 0.0 +1122 0.0 +1123 0.0 +1124 0.0 +1125 0.0 +1126 0.0 +1127 0.0 +1128 0.0 +1129 0.0 +1130 0.0 +1131 0.0 +1132 0.0 +1133 0.0 +1134 0.0 +1135 0.0 +1136 0.0 +1137 0.0 +1138 0.0 +1139 0.0 +1140 0.0 +1141 0.0 +1142 0.0 +1143 0.0 +1144 0.0 +1145 0.0 +1146 0.0 +1147 0.0 +1148 0.0 +1149 0.0 +1150 0.0 +1151 0.0 +1152 0.0 +1153 0.0 +1154 0.0 +1155 0.0 +1156 0.0 +1157 0.0 +1158 0.0 +1159 0.0 +1160 0.0 +1161 0.0 +1162 0.0 +1163 0.0 +1164 0.0 +1165 0.0 +1166 0.0 +1167 0.0 +1168 0.0 +1169 0.0 +1170 0.0 +1171 0.0 +1172 0.0 +1173 0.0 +1174 0.0 +1175 0.0 +1176 0.0 +1177 0.0 +1178 0.0 +1179 0.0 +1180 0.0 +1181 0.0 +1182 0.0 +1183 0.0 +1184 0.0 +1185 0.0 +1186 0.0 +1187 0.0 +1188 0.0 +1189 0.0 +1190 0.0 +1191 0.0 +1192 0.0 +1193 0.0 +1194 0.0 +1195 0.0 +1196 0.0 +1197 0.0 +1198 0.0 +1199 0.0 +1200 0.0 +1201 0.0 +1202 0.0 +1203 0.0 +1204 0.0 +1205 0.0 +1206 0.0 +1207 0.0 +1208 0.0 +1209 0.0 +1210 0.0 +1211 0.0 +1212 0.0 +1213 0.0 +1214 0.0 +1215 0.0 +1216 0.0 +1217 0.0 +1218 0.0 +1219 0.0 +1220 0.0 +1221 0.0 +1222 0.0 +1223 0.0 +1224 0.0 +1225 0.0 +1226 0.0 +1227 0.0 +1228 0.0 +1229 0.0 +1230 0.0 +1231 0.0 +1232 0.0 +1233 0.0 +1234 0.0 +1235 0.0 +1236 0.0 +1237 0.0 +1238 0.0 +1239 0.0 +1240 0.0 +1241 0.0 +1242 0.0 +1243 0.0 +1244 0.0 +1245 0.0 +1246 0.0 +1247 0.0 +1248 0.0 +1249 0.0 +1250 0.0 +1251 0.0 +1252 0.0 +1253 0.0 +1254 0.0 +1255 0.0 +1256 0.0 +1257 0.0 +1258 0.0 +1259 0.0 +1260 0.0 +1261 0.0 +1262 0.0 +1263 0.0 +1264 0.0 +1265 0.0 +1266 0.0 +1267 0.0 +1268 0.0 +1269 0.0 +1270 0.0 +1271 0.0 +1272 0.0 +1273 0.0 +1274 0.0 +1275 0.0 +1276 0.0 +1277 0.0 +1278 0.0 +1279 0.0 +1280 0.0 +1281 0.0 +1282 0.0 +1283 0.0 +1284 0.0 +1285 0.0 +1286 0.0 +1287 0.0 +1288 0.0 +1289 0.0 +1290 0.0 +1291 0.0 +1292 0.0 +1293 0.0 +1294 0.0 +1295 0.0 +1296 0.0 +1297 0.0 +1298 0.0 +1299 0.0 +1300 0.0 +1301 0.0 +1302 0.0 +1303 0.0 +1304 0.0 +1305 0.0 +1306 0.0 +1307 0.0 +1308 0.0 +1309 0.0 +1310 0.0 +1311 0.0 +1312 0.0 +1313 0.0 +1314 0.0 +1315 0.0 +1316 0.0 +1317 0.0 +1318 0.0 +1319 0.0 +1320 0.0 +1321 0.0 +1322 0.0 +1323 0.0 +1324 0.0 +1325 0.0 +1326 0.0 +1327 0.0 +1328 0.0 +1329 0.0 +1330 0.0 +1331 0.0 +1332 0.0 +1333 0.0 +1334 0.0 +1335 0.0 +1336 0.0 +1337 0.0 +1338 0.0 +1339 0.0 +1340 0.0 +1341 0.0 +1342 0.0 +1343 0.0 +1344 0.0 +1345 0.0 +1346 0.0 +1347 0.0 +1348 0.0 +1349 0.0 +1350 0.0 +1351 0.0 +1352 0.0 +1353 0.0 +1354 0.0 +1355 0.0 +1356 0.0 +1357 0.0 +1358 0.0 +1359 0.0 +1360 0.0 +1361 0.0 +1362 0.0 +1363 0.0 +1364 0.0 +1365 0.0 +1366 0.0 +1367 0.0 +1368 0.0 +1369 0.0 +1370 0.0 +1371 0.0 +1372 0.0 +1373 0.0 +1374 0.0 +1375 0.0 +1376 0.0 +1377 0.0 +1378 0.0 +1379 0.0 +1380 0.0 +1381 0.0 +1382 0.0 +1383 0.0 +1384 0.0 +1385 0.0 +1386 0.0 +1387 0.0 +1388 0.0 +1389 0.0 +1390 0.0 +1391 0.0 +1392 0.0 +1393 0.0 +1394 0.0 +1395 0.0 +1396 0.0 +1397 0.0 +1398 0.0 +1399 0.0 +1400 0.0 +1401 0.0 +1402 0.0 +1403 0.0 +1404 0.0 +1405 0.0 +1406 0.0 +1407 0.0 +1408 0.0 +1409 0.0 +1410 0.0 +1411 0.0 +1412 0.0 +1413 0.0 +1414 0.0 +1415 0.0 +1416 0.0 +1417 0.0 +1418 0.0 +1419 0.0 +1420 0.0 +1421 0.0 +1422 0.0 +1423 0.0 +1424 0.0 +1425 0.0 +1426 0.0 +1427 0.0 +1428 0.0 +1429 0.0 +1430 0.0 +1431 0.0 +1432 0.0 +1433 0.0 +1434 0.0 +1435 0.0 +1436 0.0 +1437 0.0 +1438 0.0 +1439 0.0 +1440 0.0 +1441 0.0 +1442 0.0 +1443 0.0 +1444 0.0 +1445 0.0 +1446 0.0 +1447 0.0 +1448 0.0 +1449 0.0 +1450 0.0 +1451 0.0 +1452 0.0 +1453 0.0 +1454 0.0 +1455 0.0 +1456 0.0 +1457 0.0 +1458 0.0 +1459 0.0 +1460 0.0 +1461 0.0 +1462 0.0 +1463 0.0 +1464 0.0 +1465 0.0 +1466 0.0 +1467 0.0 +1468 0.0 +1469 0.0 +1470 0.0 +1471 0.0 +1472 0.0 +1473 0.0 +1474 0.0 +1475 0.0 +1476 0.0 +1477 0.0 +1478 0.0 +1479 0.0 +1480 0.0 +1481 0.0 +1482 0.0 +1483 0.0 +1484 0.0 +1485 0.0 +1486 0.0 +1487 0.0 +1488 0.0 +1489 0.0 +1490 0.0 +1491 0.0 +1492 0.0 +1493 0.0 +1494 0.0 +1495 0.0 +1496 0.0 +1497 0.0 +1498 0.0 +1499 0.0 +1500 0.0 +1501 0.0 +1502 0.0 +1503 0.0 +1504 0.0 +1505 0.0 +1506 0.0 +1507 0.0 +1508 0.0 +1509 0.0 +1510 0.0 +1511 0.0 +1512 0.0 +1513 0.0 +1514 0.0 +1515 0.0 +1516 0.0 +1517 0.0 +1518 0.0 +1519 0.0 +1520 0.0 +1521 0.0 +1522 0.0 +1523 0.0 +1524 0.0 +1525 0.0 +1526 0.0 +1527 0.0 +1528 0.0 +1529 0.0 +1530 0.0 +1531 0.0 +1532 0.0 +1533 0.0 +1534 0.0 +1535 0.0 diff --git a/tests/testlib/audiofilterhelper.py b/tests/testlib/audiofilterhelper.py new file mode 100644 index 000000000000..15862dc398c7 --- /dev/null +++ b/tests/testlib/audiofilterhelper.py @@ -0,0 +1,26 @@ +import array +from ulab import numpy as np +from math import sin, pi, ceil +from audiocore import get_buffer, RawSample +from synthio import Note, LFO, MathOperation, Synthesizer + +sinedata = array.array("h", [int(32767 * sin(i * 2 * pi / 600)) for i in range(600)]) +sine8k = RawSample(sinedata, sample_rate=8000) + +def synth_test(_gen=None, dtype=np.int16, divisor = 32768, channel_count=1): + def func(gen): + g = gen() + synth, blocks = next(g) + t = 0 + for nframes in g: + for i in range(nframes): + samples = np.frombuffer(get_buffer(synth)[1], dtype=dtype) / divisor + block_values = [b.value for b in blocks] + for k in range(0, len(samples), channel_count): + print(t, *(list(samples[k : k + channel_count]) + block_values)) + t += 1 + + if _gen is None: + return func + else: + func(_gen)