Page 1 of 1

Changing DAC.write_timed() frequency on the fly

Posted: Mon Feb 11, 2019 3:39 pm
by mathieu
After initiating a DMA transfer from a buffer to a DAC using DAC.write_timed() in DAC.CIRCULAR mode, is there any way to change the frequency at which the buffer is written to the DAC without a new call to DAC.write_timed()? For instance by acting on Timer(6)? My goal would be to imitate some kind of Doppler audio effect, so I need to preserve the contents of the buffer as well as the index of the last read buffer element.

Thanks.

Re: Changing DAC.write_timed() frequency on the fly

Posted: Mon Feb 11, 2019 5:26 pm
by mathieu
Answering my own question based on a very quick test using a blinking LED connected to the DAC pin...

Yes, it seems to work (for the blinking LED at least) by calling Timer(6).freq(f), where f is the desired frequency. This is (to me at least) unexpected and delightful in its simplicity. I've been trying for a long time to simulate Doppler effects by on-the-fly modifications to the buffer. The solution was so much simpler and elegant...

I'll try to find time to experiment with real audio output and I'll post a minimal working example here.