ConverterScaler not changing the volume correctly #157
-
Hi! Amazing package this is, I'm quite new to this so I've come across some problems. One of them is the fact that ConverterScaler doesn't control the volume smoothly from 0.0 to 1.0. In Volume Control in the bottom-most example, we have this line:
When using this i my code, I could see that .setFactor() only changed the factor to 0.0 or 1.0, even if I just manually wrote in 0.5. I then switched the <int16_t> to and it did change the volume as .setFactor() got arguments ∈ (0.0, 1.0) (and .volume() returned the same values!), but it was almost completely random. Sweeping from 0.0 to 1.0 made the speaker go nuts, going up and down in volume. I'm just trying to control the volume of a generated square wave. main.cpp is littered with old and out-commented code, so here are only the relevant parts:
I'm running an ESP32 lolin32 with a MAX98357 amplifier over I2S along with a basic speaker. I also tried implementing effects and using a boost pedal, but I couldn't even get a sound even though .volume() returned values >0. Grateful for all the help I can get. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 13 replies
-
I suggest that you read the documentation about volume. In your code the |
Beta Was this translation helpful? Give feedback.
-
As I have indicated I suggest that you just stick to the example and it will work... |
Beta Was this translation helpful? Give feedback.
-
Yes it can be lower - but you want to give much more range to control. |
Beta Was this translation helpful? Give feedback.
-
The following should work
|
Beta Was this translation helpful? Give feedback.
-
Did you try to debounce your input ? |
Beta Was this translation helpful? Give feedback.
-
If I understand your logic correctly you switch from the volume 1.0 to 0 from one moment to the other. If the signal is at that point not zero (which is very likely), you generate automatically a pop!
|
Beta Was this translation helpful? Give feedback.
-
You can decrease the buffer size e.g. to 4 bytes when you define the copier. |
Beta Was this translation helpful? Give feedback.
-
My usual use case (with the the AudioKit) is to use the volume up and volume down buttons which change the volume in steps. You could also use the SineFromTable and instead of setting the volume to 0 set the setFrequency to 0 to silence it. |
Beta Was this translation helpful? Give feedback.
-
I tried to add this logic into the setAmplitude() method. The step size can be defined with setMaxAmplitudeStep(). Currently I am using 50 as default value. |
Beta Was this translation helpful? Give feedback.
-
You are right: setFactor should be float. |
Beta Was this translation helpful? Give feedback.
The following should work