You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • it warns that outputting at higher freq could max out the mcu, but Im not clear on what causes that limitation?

    The timers used for the Waveform are a mix of a single hardware timer, plus software to handle the scheduling of multiple tasks (eg multiple waveforms, digitalPulse, software PWM, etc) on that one timer. If you do too much stuff then the processor just spends all its time servicing the interrupt and no time executing anything else!

    If you're doing a sine wave then you could just write that to a buffer and use Waveform on that buffer without need for DSP instructions though?

    If you're looking at doing realtime audio output and you're doing Inline C, then I would say you should actually just make your C code access the PWM output hardware directly - an example of doing that from JS is at https://www.espruino.com/STM32+Periphera­ls.

    Actually executing your code at a fixed interval could be a little more problematic, but probably the easiest method right now is:

    • Use analogWrite(...,{freq:44100}) on one pin
    • Physically connect that pin to another pin
    • Use setWatch(your_inline_c_fn, other_pin, { irq:true, repeat:1})

    And that should then be able to execute your function 441000 times a second without JS ever getting involved

About

Avatar for Gordon @Gordon started