Commit graph

23 commits

Author SHA1 Message Date
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
Dan Halbert
3f4d9310ff CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
Dan Halbert
747b7619ea update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
3151656f4b synthio: more fir-filter removal; fix biquad logic errors 2023-05-30 09:24:26 -05:00
33fb771b76
synthio: Add filter argument to Synthesizer constructor
as step 1/n of adding FIR filtering
2023-05-11 17:56:11 -05:00
e87e7ee54f
synthio: add stereo & Note.panning
A note can be placed in the center (panning=0) or moved to just the left
(panning=1) or right (panning=-1) channels. Fractional panning values
place it partially in both channels.
2023-05-11 09:31:18 -05:00
c839888e28
synthio: rename function that records error position 2023-05-04 08:45:31 -05:00
e23e7d3b3f
synthio: get_buffer: return error if object deinited
this may fix a weird crash during shutdown
2023-05-04 07:45:45 -05:00
a7da245ad0
synthio: Add synthio.Note
This class allows much more expressive sound synthesis:
 * tremolo & vibrato
 * arbitrary frequency
 * different evelope & waveform per note
 * all properties dynamically settable from Python code
2023-05-04 07:23:49 -05:00
dd262258e0
synthio: Add MidiTrack.error_location to record errors
.. instead of just printing the unraiseable error on the repl
2023-05-03 09:37:02 -05:00
12c1a72f03
synthio: implement envelope
This works for me (tested playing midi to raw files on host computer, as
well as a variant of the nunchuk instrument on pygamer)

it has to re-factor how/when MIDI reading occurs, because reasons.

endorse new test results

.. and allow `-1` to specify a note with no sustain (plucked)
2023-04-25 12:05:53 -05:00
04f4092e11
synthio: support audio outputs that need double buffering
closes #7837

tested on rp2040 pico w on pico dv shield
2023-04-05 11:57:13 -05:00
b011468251
Add synthio.Synthesizer
In contrast to MidiTrack, this can be controlled from Python code,
turning notes on/off as desired.

Not tested on real HW yet, just the acceptance test based on checking
which notes it thinks are held internally.
2023-04-02 20:37:23 -05:00
e0984fa195
Factor out the synthesizer from midi track 2023-04-02 18:54:07 -05:00
e728a0c1b9
switch to 16.16 fixed point for synthesis 2023-04-01 11:47:27 -05:00
e9e4ce9546
add waveform support in synthio
a waveform object (array of 'h') can be passed in, replacing the
standard square wave. This waveform must be a 'single cycle waveform'
and some obvious things to pass in are sine, triangle or sawtooth waves,
but you can construct whatever you like.
2023-04-01 11:46:38 -05:00
13e17e6dcd
Make synthio debuggable in unix coverage port 2023-04-01 11:46:36 -05:00
db1e01c462
Don't require huge buffers for long-held notes 2023-04-01 11:46:36 -05:00
7f73ff1b2d
hold accumulator phase across span
this fixes grunk in held notes
2023-04-01 11:46:35 -05:00
02f8a45dfa
synthio: allow increasing number of channels
12 channels works well on metro m7
2023-04-01 11:46:27 -05:00
Dan Halbert
a01dec1df9 message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
Dan Halbert
33bbb8b1f4 RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
Artyom Skrobov
8056af8648 [synthio] add a simple MidiTrack implementation 2021-03-26 16:38:10 -04:00