PDA

View Full Version : Setting Gain on Mixer from Input



Hutchcmu
03-16-2016, 05:24 PM
I'm calculating a value from an analog pin to set gain. The calculated range passed to the Gain is 0-apprx 0.8 but results in a very quiet sound that does not vary with the input. The sound also has some noise associated with it that was not there previously. Any thoughts on why this is not working correctly? I've looked at examples and don't see anything I am doing differently.

// Determine gain from pad velocity level and set

float pad1Velocity = (float)previousLevel1 / 1023.0;
mixer1.gain(0, pad1Velocity);
mixer1.gain(1, 0.3);
mixer1.gain(2, 0.3);
mixer1.gain(3, 0.3);

PaulStoffregen
03-16-2016, 05:52 PM
Maybe you want to convert from linear to log scale? Just a guess, since I know nothing of what you're actually trying to do. But human hearing sensitivity is logarithmic (and complicated in many other time-varying ways), so maybe you should look at that.

Also, consider any rapid changes in gain will be heard as an audio signal. Rapid changes on a regular interval will concentrate a one frequency and its harmonics, which is far more noticeable to human perception that similar acoustic energy spread randomly across a wide frequency range.

Hutchcmu
03-16-2016, 06:57 PM
Thanks, Paul. I think you touched on the potential source of my issue. I am rapidly changing the gain level which could be causing the noise, and now suspect I'm dropping it too quickly, causing the low volume before I can even hear the results of the higher gain level. Won't be able to test for awhile but can't say enough how much I appreciate your efforts!