Using VolumeStream setVolume method with variable crashes ESP32 #2321
-
|
Hello Phil, I am using a mixer to handle 1 or 2 wav streams. I'm dynamically adding and removing the wav files to the mixer when they stop/start, however this will impact the total volume. For example, if I play music then add a sound effect to the mixer, this will make the music play quietly. Then after the sound is finished and removed from the mixer, the music becomes loud again. I understand this is to stop clipping but I don't want the volume to appear to change so I am dynamically altering it when the mixer is changed. However, the ESP32 crashes if I try to use volume.setVolume with a float variable: This will crash the ESP32. Using print statements over serial, the new_vol value is as expected. I can set the volume by calling something like this: Do you have any suggestions why I can't seem to pass in a float variable into this method? Are there any limits to when or how this can be called? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
setVolume() expects a float and it does not make any difference if you pass a variable or a value! |
Beta Was this translation helpful? Give feedback.
-
|
Upon further inspection, the fault is not being caused by passing a variable. It seems I can run |
Beta Was this translation helpful? Give feedback.
-
|
Ok I found the fault - thank you for your suggestion! VolumeStream was on the heap, however I had added a LinearVolumeControl which ended up on the stack. So I think this is responsible for causing the issue when changing the volume! Thank you again Phil for your time! |
Beta Was this translation helpful? Give feedback.
setVolume() expects a float and it does not make any difference if you pass a variable or a value!
Your issue must be somewhere else: so analyse the stack trace and double check that you did not allocat the VolumeStream on the stack!