How to fix the amplitude of a dynamic input signal with a fader or *~ object?

Josef Rebbe's icon

Hi there.

I have a microphone signal with a changing amplitude and would like to adjust the volume of it so the amplitude stays steady. Is there a smart way to do this with a fader or *~ object? I'm struggling with volume faders and their logarithmic nature, tried atodb therefore, but don't seem to get it right. Any idea anybody?

Josef

Source Audio's icon

you mean you want to have autogain on the mic input ?
depends on what you consider under steady and input level range which should be processed.
and maybe allowed lookahead amount

it could be s simple as :
if inputi is > then 0.1 then process.
wished output arround -3db
measure input and amplify it by needed factor.

done

Josef Rebbe's icon

Thanks for your reply.

I’m sending a slow sinewave sweep (32-512 Hz) to a speaker and picking it up with a measuring mic. The amplitude varies quite a lot a different frequencies. What I want is adjusting the volume of the sinewave so the sweep that’s coming out of the speaker is complete linear.

Source Audio's icon

I would record both sweep and mic input, then align them
to 1 sample accuracy, then measure the differences.
Once done, you can try to compensate output,
or create sweep with compensated level ...
or use IR response ...
in any case I would perfer that then detecting and reacting in real time

Josef Rebbe's icon

That sounds like a good idea.

Would you measure the difference with a level meter? The level meter display amplitude values between 0. and 1.. Should I divide them with each other and multiply the factor with the sweep level?

Would you measure the amplitude difference per sample and how? And could I also save the amplitude correction curve into a frequency/amplitude table for later use?

Would you mind ellaborating a bit more concrete, since I’m still a beginner?

Source Audio's icon

I would in fact also record freq sweep values as
float, in case you want to read the difference
using peek
I am out for the rest of the day, and can’t post
example of it
best case could be IR based EQ
you could use sweep and mic recording to create IR response

Josef Rebbe's icon

How can I record the freq sweep values as float

I red about IR based EQ and found this:

Capture the impulse response of a biquad~ (feed by count~ + ==~ 1) and store it in a buffer with an offset of 128 samples. Then copy those sample but reversed at the begining of the buffer, to do the symetry.

I'm still trying to figure out what this means exactly.

Roman Thilenius's icon

before you decide if you use [buffir~] or a third party VST plug-in for the filtering it should be pointed out that you do not yet know if that highly nonlinear curve you see 1.) is caused by the speaker, the microphone, or the room(!) - and that 2.) linearity of the speaker output might not do what you want, because for the ears it is different again; equal amplitude is not equal power is not equal percieved loudness.

to change the amplitude you do luckily not need to deal with decibel conversion, you only have to inverse the offsets (aka if something is 1.25 too high, you need to * 0.8 it and so on. the [peakamp~] object can provide you with absolute maximum values for periods)

Source Audio's icon

sure many factors are involved, in first place with low frequencies
which can differ a lot depending where listener and loudspeaker
are positioned in the room.
and and and
to get that "complete linear" might be impossible

you might try this:

https://cycling74.com/articles/package-arrival-the-hisstools-impulse-response-toolbox

or then try to create gain table for frequencies.

Is length of your sweep variable, and what are min and max sweep times ?

Josef Rebbe's icon

Thanks lot for your input.

Very helpful to know that I don't need to deal with decibel conversion, but only have to inverse the offsets. I figured that I can also use [meter~] instead of [peakamp~].

To clarify: I'm dealing with an underwater tactile transducer as the speaker and a more or less linear hydrophone as a measuring device. What I want to achieve is the same haptic intensity for all frequencies.

I figured out that the measurements of the bath itself doesn't influence the frequency respons, since the mic is very close to the transducer. The non-linearity has to do with the physicality of the transducer mainly.

I know that for our ears even a measured linear amplitude does not result in a linear experience (see Fletcher Munson curve). I wander if such a curve also exists for tactile sensation detected by the mechanoreceptors in our skin. I will look into that.

The length of the sweep shouldn't matter. I would need a linear respons with all speeds. Probably in my application IR wouldn't work since it is about the direct haptic impact of the transducer (no reflections).

What I did now is recording frequencies and according amplitudes into a table, then reversed the amplitude and applied it to the sweep. The result is a much better respons, but still far from linear, since the physicality of the transducer didn't change.

One thing is that the resolution of the table is much higher at high frequencies than at lower ones since I'm storing whole numbers.

The other thing is the still remaining influence of the characteristics of the transducer with this approach.

EQ transducer bad 2.maxpat
Max Patch

Roman Thilenius's icon

in the end you want to have the combination of both - the sound damping from the water and the "speaker" curve - so it seems correct to measure the complete setup.

however, there is a approximation for the sound absorption in water, which might help to classify the results a bit when compared to air.

IR / FIR does not seem wrong at all even though it is only frequency filtering, but i think using any kind of filterbank should also be ok to find the curve.

i would go so far to suggest to play steady tones across the keyboard nstead of using a sweep - and then looking at the waveforms to find their peak (with your eyes or with some kind of maximum or peak hold DSP.)

Source Audio's icon

It is a bit difficult to imagine all this without knowing more details,
like what dimensions are we talking about ?

sure you can make much better measurement,
and better correction curve.

At the end the question is, how much extra power
your transducer needs and can handle across wished frequency,
and fastest way to follow correction curve.

you don't need smooth level changes under water, or ?

what should be linear resoponse to audio frequency input ?

what you hear outside of water, or measured pressure in the water ?