Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native audio synthesis #4467

Closed
tannewt opened this issue Mar 23, 2021 · 4 comments
Closed

Add native audio synthesis #4467

tannewt opened this issue Mar 23, 2021 · 4 comments
Assignees
Milestone

Comments

@tannewt
Copy link
Member

tannewt commented Mar 23, 2021

Right now we can only playback RawSamples, WAV and MP3. It'd be nice to add a synthio module that can generate audio based on settings set from Python. For buffering changes, it could also take in MIDI commands and apply them over time.

The Teensy Audio library is a really neat Arduino library we can reference: https://github.com/PaulStoffregen/Audio

It has these synth modules:

  • wavetable
  • drum
  • string
  • sine
  • sine_hires
  • sine_fm
  • waveform
  • waveformMod
  • pwm
  • tonesweep
  • dc
  • noise
  • pink

These effects:

  • fade
  • chorus
  • flange
  • reverb
  • freeverb
  • freeverbs
  • envelope
  • multiply
  • rectify
  • delay
  • delayExt
  • bitcrusher
  • midside
  • waveshape
  • granular
  • combine

These filters:

  • biquad
  • fir
  • filter

These analyzers:

  • peak
  • rms
  • fft256
  • fft1024
  • tone
  • notefreq
  • print
@tyomitch
Copy link
Collaborator

tyomitch commented Apr 8, 2021

API-related comments, originally from #4447:

The synthesiser can implement the AudioSample protocol, but in addition to that, we'd like to be able not to pass it a buffer upfront, but to call a write method instead that queues data up. That way we'd be able to pipe MIDI from BLE or USB directly into this object.

OTOH,

  • that would make looping (or even passing the same AudioSample to play() repeatedly) impossible;
  • the protocol for audiosample_reset_buffer_fun has no way to report failure if the AudioSample is not rewindable;
  • if the queued MIDI stream depletes during playback, the playback will stop, instead of waiting for new input. For real-time input, when the MIDI events arrive at the same speed that they're played, this would happen after every event!

Perhaps a new protocol, e.g. AudioStream, should be defined alongside AudioSample, and Audio*Out implementations will need to be updated to handle the new kind of input -- e.g. a new method play_stream which wouldn't take a loop parameter. Then synthio can have MidiStream alongside MidiTrack, with much of the implementation shared. Similarly, there can then be RawStream alongside RawSample.

@chachagsedaro
Copy link

@tannewt has there been any development on this? i was curious to see if there's any way to implement small scale audio synthesis on circuitplayground bluefruit

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 7, 2023

You might look at the recent PR's #7825 and #7840

@jepler
Copy link
Member

jepler commented May 22, 2023

8.1 has synthio.Synthesizer. It doesn't provide all the features listed above but it can hopefully form a basis for more enhancements in the future.

@jepler jepler closed this as completed May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants