Commit Graph

72 Commits

Author SHA1 Message Date
Jeff Epler 1701552dec
synthio: make sustain level relative to attack level
and re-vamp overall envelope calculation again.

Now, if you set a low overall attack level like 0.2 this avoids the
"diminishing volume" effect when many notes sound at once. You need
simply choose a maximum attack level that is appropriate for the max
number of voices that will actually be played.
2023-05-04 07:23:50 -05:00
Jeff Epler c06597c07a
synthio: replace the quietest releasing note when over-writing 2023-05-04 07:23:49 -05:00
Jeff Epler 4f56b7646e
synthio: slow ramp overall envelope back up
.. and account releasing notes at their sustain level until they're
done.

this ameliorates the effect where multiple releasing notes
don't seem to actually be releasing, but stay at a constant volume.
2023-05-04 07:23:49 -05:00
Jeff Epler 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
Jeff Epler 5514e3065d
synthio: add midi_to_hz
to convert notes in the MIDI 1-127 note scale to floating point Hz
2023-05-04 07:23:48 -05:00
Jeff Epler 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
Jeff Epler d8550f4e7c
synthio: fix offset in default square waveform 2023-05-03 09:37:02 -05:00
Jeff Epler 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
Jeff Epler 79d093d957
tweak max envelope calculation vs number of active notes 2023-04-05 17:43:03 -05:00
Jeff Epler 9993b4b01c
Prevent playing the same note on 2 channels 2023-04-05 16:53:08 -05:00
Jeff Epler 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
Jeff Epler 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
Jeff Epler e0984fa195
Factor out the synthesizer from midi track 2023-04-02 18:54:07 -05:00
Jeff Epler e728a0c1b9
switch to 16.16 fixed point for synthesis 2023-04-01 11:47:27 -05:00
Jeff Epler 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
Jeff Epler 13e17e6dcd
Make synthio debuggable in unix coverage port 2023-04-01 11:46:36 -05:00
Jeff Epler db1e01c462
Don't require huge buffers for long-held notes 2023-04-01 11:46:36 -05:00
Jeff Epler 7f73ff1b2d
hold accumulator phase across span
this fixes grunk in held notes
2023-04-01 11:46:35 -05:00
Jeff Epler 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