Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3486

General • Advice on sine-wave please

$
0
0
I am in the process of moving a clock project from a SAM21 M0 processor to PICO W

One element in the project is a background 'beep' for keypress feedback and other alarms. These would be a different tones running for 100ms up to 1000ms as required. I would like to use a function like this beep( tone, volume , duration) This would need to set up some code to run in the back ground.

This is LoFi output!!

I have built the example sine_wave project and it runs OK. I2S is driving a MAX98357 I2S DAC.

I notice a few glitches though. In this example the tone runs continuously and at times there might be a loader output for a second or two. Also at low volume when adjusting volume there is also a 'pop' as the volume is changed and also at about every 5 seconds a small pop. There does not seem to be 'pops' when volume is zero.

No other code is running apart from the USB to give a COM interface to my Windows PC. Power is from the USB connection.

Can anyone advise me:
Are the glitches in sound such as odd volume changes and pops a fundamental problem or a result of how the sine_wave example works feeding data to buffers.? Pops perhaps can happen as the buffer gets re written but the random loud parts are harder to understand .

Would a 'flush' function help when tome or volume is changed?

How might I turn off a tone? I think a timer call back after the tone duration would give an opportunity to make changes. Then what?
  • Clear the buffer?;
  • Set volume to Zero?
    Which I think amount to the same thing.
    OR
  • Disable the I2S with audio_i2s_set_enabled(false)

The example runs in the main loop updating the buffer on each pass. How might this run in the background? Is there an interrupt that can be captured to trigger the buffer refill process?

Thanks
Ted

Statistics: Posted by tfcroft4 — Tue Feb 06, 2024 12:07 pm — Replies 0 — Views 28



Viewing all articles
Browse latest Browse all 3486

Trending Articles