Commit Graph

24 Commits

Author SHA1 Message Date
Jeff Epler 774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Dan Halbert fe0e2f13bc wip; fix qstr processing 2023-08-10 20:06:32 -04:00
Jeff Epler f2e26e8bde
get the cmsis macros the right way 2023-04-05 13:37:18 -05:00
Jeff Epler b9dea05dbf
Enable audiomixer on unix port, for testing 2023-04-05 09:02:03 -05:00
Dan Halbert a01dec1df9 message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
Jeff Epler 621953c960
Additional missing-prototypes fixes
I think this correctly enables missing-prototypes in atmel-samd
and raspberrypi ports.
2021-11-10 10:55:53 -06:00
Dan Halbert 33bbb8b1f4 RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
gamblor21 cd8deb0b72 Removed all the M4 comments 2021-04-13 17:36:14 -05:00
Mark 7ace53f22c
Remove comment for define being M4 only it can be M7 too
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2021-04-12 22:35:55 -05:00
gamblor21 9bf4b4d81e Fixes to math for level calculations 2021-04-02 16:47:25 -05:00
gamblor21 0b212e2243 Add non M4 audiomixer support 2021-03-25 17:30:40 -05:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Jeff Epler 0722dafc24 audiomixer: Fix garbled playback when voice 0 is stopped, audio pops
There were two main problems
 - word_buffer was being filled as though with unsigned samples,
   but during mixing all samples are kept in signed mode
 - If the first buffer was stopped, the voices_active flag got set
   anyway, even though the output buffer wasn't initialized yet,
   so the samples were mixed with indeterminate data

We also cover the case where no buffer was playing, and ensure
the output buffer is filled.

This now works much better.  Tested on neotrellis m4 playing back
4 mp3 streams at a time in signed-16, 22050Hz
2020-06-01 19:14:38 -05:00
Jeff Epler b4ddee2bb6 Mixer: rename function based on review comment 2020-01-20 14:08:56 -06:00
Jeff Epler 982c63a717 Mixer: use MP_LIKELY macro instead of locally brewed one 2020-01-20 14:08:32 -06:00
Jeff Epler 449dbea456 Mixer: Rework for performance, particularly of the S16 case
This removes downscaling (halving-add) when multiple voices are
being mixed.  To avoid clipping, and get similar behavior to before,
set the "level" of each voice to (1/voice_count).

Slow paths that were applicable to only M0 chips were removed.

As a side effect, the internal volume representation is now 0 ..
0x8000 (inclusive), which additionally makes a level of exactly 0.5
representable.

Testing performed, on PyGamer: For all 4 data cases, for stereo and
mono, for 1 and 2 voices, play pure sign waves represented as
RawSamples and view the result on a scope and through headphones.
Also, scope the amount of time spent in background tasks.

Code size: growth of +272 bytes

Performance (time in background task when mixing 2 stereo 16-bit voices):
76us per down from 135us (once per ~2.9ms long term average)
(Decrease from 4.7% to 2.4% of all CPU time)
2020-01-16 10:48:38 -06:00
Jeff Epler e6869c8983 mixer: factor out mix_one_voice 2020-01-16 10:31:26 -06:00
Jeff Epler feb8eb935b audiosample: convert to use a protocol
This eases addition of new sample sources, since the manual virtual
function dispatch functions are just calls via a protocol
2019-12-04 09:31:52 -06:00
jepler 8768896d6b audiomixer: Supply constants in a way "-Og" optimization expects
These arguments are constrained to be compile-time constants, a fact
that gcc complains about under "-Og" optimization, but not in normal
builds.  Declare them as enumerated types
2019-09-08 21:18:15 -05:00
sommersoft edfcee29ff remove leftover debug print 2019-09-03 22:25:27 -05:00
sommersoft 362c1664ae use more accurate ARMv7 prepocessor flags; TODOs for asm instructions 2019-09-01 17:36:29 -05:00
sommersoft 3c7c3c98d7 include CMSIS instrinsic addition functions for M4; cleanup C math funcs 2019-08-31 17:36:54 -05:00
sommersoft 7f64af38cb fix 'audiomixer_mixer_reset_buffer' 2019-08-25 09:33:23 -05:00
sommersoft df5568d993 move Mixer & MixerVoice from 'audiocore' to 'audiomixer' 2019-08-24 23:36:18 -05:00