Commit graph

48 commits

Author SHA1 Message Date
Cooper Dalrymple
02382401c6 Reduce data size of internal buffers. 2025-05-02 09:08:19 -05:00
Cooper Dalrymple
421521516c Convert floating point operations to fixed point and use synthio_sat16. 2025-05-01 15:27:23 -05:00
Cooper Dalrymple
e855e3e1ba Limit feedback range to 0.1 - 0.9 2025-05-01 10:54:10 -05:00
Cooper Dalrymple
ba81c6b1c4 Implement allpass filters. 2025-05-01 10:42:03 -05:00
Cooper Dalrymple
e729849fac Initial setup of phaser effect. 2025-05-01 08:15:43 -05:00
Scott Shawcroft
91cf8fb83d
Make collect the default 2025-04-24 14:59:07 -07:00
Cooper Dalrymple
05a50b8fd8 Initial replacement of old Biquad with BlockBiquad 2025-04-01 09:10:25 -05:00
dcooperdalrymple
94a234fbc1 Remove unnecessary deinited functions for audiosample objects. 2025-02-18 20:38:44 -06:00
dcooperdalrymple
9dfa9cf978 Call audiosample_mark_deinit during deinitialization of audiosample objects. 2025-02-17 14:32:49 -06:00
698211167a audiofilters: Tick biquads even when playing silence 2025-02-08 09:38:37 -06:00
6054810f58 Fix filters again 2025-02-07 21:06:09 -06:00
8b20c841f7 Audiofilter: Add support for block biquads
& test by filtering some noise with a pair of BlockBiquads
2025-02-07 20:59:48 -06:00
ffae82db61 Simplify audiofilter construction through better default parameters 2025-02-07 20:56:19 -06:00
e15eba0d33 audio: reduce code size
By placing certain fields in a fixed location in all sample types,
code can be reduced & reused. For instance, the same property object
can be used for every sample type's `sample_rate` property.

The sample proto functions like `sample_rate` become superfluous since
once an object is verified to support the audiosample protocol, direct
access to the fields in the base object is possible.
2025-02-06 21:56:09 -06:00
dcooperdalrymple
e049337147 Allow variable mix down sample scale. 2025-01-17 18:24:18 -06:00
dcooperdalrymple
99b4fae790 Remove unnecessary copies of mix_down_sample. 2025-01-17 17:04:03 -06:00
dcooperdalrymple
8c40c56798 Move shared_bindings_synthio_lfo_tick to avoid error if using unsigned 16-bit audio. 2025-01-17 16:11:38 -06:00
dcooperdalrymple
b796f0d1f0 Only calculate lofi bit mask when necessary. 2025-01-17 15:27:54 -06:00
dcooperdalrymple
cef94d7446 Remove unnecessary deinit check. 2025-01-17 15:22:32 -06:00
dcooperdalrymple
5fbbeed716 Call shared_bindings_synthio_lfo_tick on audioeffects in SYNTHIO_MAX_DUR intervals. 2024-12-12 11:45:54 -06:00
dcooperdalrymple
0e64e1cf75 Implement block ticking within audio effects. 2024-12-12 11:01:30 -06:00
dcooperdalrymple
48ca21d9a1 Add Distortion to unix port and make type conversions explicit. 2024-12-11 12:35:23 -06:00
dcooperdalrymple
57022f9e92 Implemented soft clipping and continued optimization of distortion algorithms. 2024-12-11 12:17:54 -06:00
dcooperdalrymple
0410d22601 Added soft_clip property to toggle between hard clipping (default) and soft clipping. 2024-12-11 12:17:01 -06:00
dcooperdalrymple
222ce2c782 Apply similar updates to audiofilters.Filter and audiodelays.Echo: MICROPY_FLOAT_CONST, MP_ROM_INT, and synthio_block_slot_get_limited. 2024-12-10 09:33:35 -06:00
dcooperdalrymple
5c981f032f Use MICROPY_FLOAT_CONST and MICROPY_FLOAT_C_FUN within floating point calculations. 2024-12-10 09:16:17 -06:00
dcooperdalrymple
155f197fe6 Convert default float values from null checks to MP_ROM_INT. 2024-12-10 08:44:07 -06:00
dcooperdalrymple
31c9095fcd Implement synthio_block_slot_get_limited. 2024-12-10 08:35:39 -06:00
Cooper Dalrymple
064c3f310b
Merge branch 'adafruit:main' into audiofilters_distortion 2024-11-13 08:29:13 -06:00
de9b0b6b1b
Merge pull request #9772 from relic-se/audiofilters_filterlist 2024-11-10 09:13:34 -06:00
dcooperdalrymple
c96d1428e1 Remove unnecessary m_malloc_fail and deinit from memory allocation routines. 2024-11-07 19:06:25 -06:00
dcooperdalrymple
5f8ec0afc6 Validate type of filter tuple items. 2024-11-07 13:58:01 -06:00
dcooperdalrymple
941e1228f2 Rename filters back to filter and support individual Biquad object and tuple of Biquad objects. 2024-11-07 13:03:59 -06:00
f8afdcb729 Add audiodelays & audioeffects to unix coverage port
.. and add a very basic audioeffects test, showing that it plausibly
is working

I had to address several build errors that occurred in the Unix build,
mostly related to conversion from FP types to integral types (replaced
by explicit casts) and by
accidental mixing of regular & f-suffixed floating constants (replaced
with the MICROPY_FLOAT_CONST macro)

Particularly this change could use consideration:
```diff
-    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
```

The buffer length is being calculated in floating point based on the
millisecond delay & the sample rate. The result could then be a fractional
number such as 529.2 for a 12ms delay at 44.1kHz. Multiplying a floating
number by the size required for each echo buffer item
(`(self->channel_count * sizeof(uint16_t))`) could yield a number of bytes
that doesn't correspond to an integral number of buffer items. I grouped
the float->int conversion so that it converts the number of echo buffer
items to an integer and then multiplies by the size of the item.
2024-11-05 09:36:18 -06:00
dcooperdalrymple
14b1383b6b Remove trailing whitespace to fix pre-commit. 2024-11-05 08:47:24 -06:00
dcooperdalrymple
0aab00d7e5 Fix 16-bit unsigned integer silence within audio effects. 2024-11-05 08:41:23 -06:00
dcooperdalrymple
37b6b70b08 Fix error with null sample handling in audiofilters.Distortion. 2024-11-03 18:43:55 -06:00
dcooperdalrymple
63c3e394d3 Fix error with NULL sample handling in audiofilters.Filter. 2024-11-03 18:30:19 -06:00
dcooperdalrymple
1008dd5a1b Simplify audiofilters.DistortionMode.LOFI sample processing with bit mask. 2024-10-31 11:11:45 -05:00
dcooperdalrymple
3a16dafef8 Remove audiofilters.DistortionMode.ATAN 2024-10-31 10:44:05 -05:00
dcooperdalrymple
46ebae1598 Remove separate DistortionMode code files. 2024-10-31 10:33:09 -05:00
dcooperdalrymple
6badb92de8 Add support for list of Biquad objects within audiofilters.Filter. 2024-10-29 12:52:27 -05:00
dcooperdalrymple
16575fc0ef Added Distortion and DistortionMode classes to audiofilters module based on Godot's AudioEffectDistortion class. 2024-10-23 17:19:48 -05:00
dcooperdalrymple
c7e87cfae3 Remove unnecessary double buffer on filter_buffer. 2024-10-22 21:33:28 -05:00
dcooperdalrymple
e7c02bd561 Biquad filter processing. 2024-10-22 12:09:28 -05:00
dcooperdalrymple
db540c67ec Avoid processing sample if filter is None. 2024-10-22 12:09:07 -05:00
dcooperdalrymple
1bf400d2dd Rename biquad property to filter. 2024-10-22 12:08:33 -05:00
Cooper Dalrymple
5246053563 Initial structure for biquad filter effect. 2024-10-22 09:17:58 -05:00