Audio Tools ESP32 and Arduino Tasks #1519
-
I am running sounds generated from arrays, resampling, mixing, volume and filtering. I had copier.copy in loop and all worked OK. I then added some user selection and controll which put in delays etc and the sound started to break up depending on what users was doing. So I set up 2 Tasks in Arduino and set Task1 to do Copier.copy only in an infinite loop on Core 0. and Task 2 on Core1 to do user selection and controls and all worked no break ups nomatter how long a button was pressed.. And I have nothing at all in the Arduino Loop but it is still there ...empty..... But in Google and Youtube info I see that the recommendation is for Tasks to all be run on Core 1 so as to leave ESP32 core0 to run its own stuff and bluetooth and wifi etc which must be run on core0. Is that the same with Audio tools.... what is your reconmmendation and is there any examples of use..... Also when device is idle but not powered off as it would loose settings etc what is the best way to stop sound..... iss it just by setting volume to Zero on each input/output, which I find leaves a faint buzz in background as the arrays are still running......OR can I conditionally start and stop the copier.copy without alarming etc. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
If your sketch is not using Bluetooth or WiFi you would not need to bother! Just do something that works... I personally would set both to be on Core 1 and if this is not working I would keep the one with the heavy load (=the Audio) on Core 1 and offload the lightweight Button handling to core 0. If you just want to stop to copy temporarily you could call copier.setActive(false) or implement your own logic of not calling copy. If it is for a longer time you might also consider to end the output class. |
Beta Was this translation helpful? Give feedback.
-
Thanks for reply...... I seem to have problem running Task1 for copier.copy on core1....it breaks up sound or keeps resetting even if nothing in Task2 on core1. I assume Init. and config etc in Setup are run in Core0, so is that why maybe copier.copy needs to be on core0 to have access to the setups without alot of parameter passing etc...?? It all seems to be running very fast..... if I increment values to vary volumes or stepsizes I have to make the increment on the counters very small to slow down the speed of response. |
Beta Was this translation helpful? Give feedback.
-
Arduino sketches run on core 1 by default, so the setup is running there as well. |
Beta Was this translation helpful? Give feedback.
-
You were writing that you were putting the input processing into a separate task: If you don't add any delay() statement there, the audio task will almost never get a chance to do any processing: that's the reason why it's not working. You are just doing the input processing giving the audio no chance to do any work... The same is true when you now deactivate the audio processing: You might add some delay there when you don't do any processing ... |
Beta Was this translation helpful? Give feedback.
If your sketch is not using Bluetooth or WiFi you would not need to bother! Just do something that works...
I personally would set both to be on Core 1 and if this is not working I would keep the one with the heavy load (=the Audio) on Core 1 and offload the lightweight Button handling to core 0.
If you just want to stop to copy temporarily you could call copier.setActive(false) or implement your own logic of not calling copy. If it is for a longer time you might also consider to end the output class.