Mixing Sine waves with stable dB output

wannabeafrog's icon

Hello,

I'm mixing multiple sine waves sequences for a project, since I'm working with transducers I need to keep a constant signal dB output regardless of the number of waves and their amplitude at any given moment. Right now I'm using a simple arithmetic system to control each oscillator's volume, dividing the signal by the number of oscillators working and their amplitudes. Though the system helps, I'm pretty sure this is not the appropriate approach since sound behavior is logarithmic and not linear. I really don't know what is the correct way to sum my signals, but I have the feeling it may be simpler than I think.

Below is a simplified sample patcher that uses the same process I'm currently working with, so maybe you get a better idea of what I'm looking for.

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks in advance!

Roman Thilenius's icon

you did not say if you are looking a for a stable peak or a stable rms.

as for rms, you could precalculate that unless the frequencies of the partials are modulated. and you should - because measuring rms of one or only a few sines does not work very well.

as for peak, the formula couldnt be simpler: it is 1/number of partials, i.e. [*~ 0.5] when 2 oscillators are running.

-110

wannabeafrog's icon

Hello Roman,

Thank you very much for your response. Regarding your comments:

- I'm looking for a stable RMS.
- The frequencies of the partials are not modulated. And I'm using just 2 or 3 pure sine waves to excite an object with a transducer.
- I've been doing what you're suggesting for the peaks ([*~ 0.5] when 2 oscillators are running and so on), but I don't know how to preclculate the rms stability, any hints on this?

Thanks again

jonah's icon

it would give you a delay, but put a compressor at the end because of possible phase cancelation? the compressor tutorials are good. if they're all in phase then you might want to treat it like an additive waveform and pre-calculate it in gen? or maybe oscbank~ would be helpful? i'm curious about math you'd do to account for volume reduction of phase cancelation ahead of time for adding sines now though.

ps. sorry if stating obvious, but constant levels from a mechanical/electrical standpoint with changing freqs won't sound like constant levels to human ears. i'd put some meter/data readout at end to make sure it's working right. :) kinda surprised perceptual metering taking into account frequency isn't more common...

Roman Thilenius's icon

if i am not mistaken (i just got up after only 4 hours of sleep) the power of a sinewave can be found by

(peakamplitude^2) *0.5

but jonah is right, when you have 2 partials which are somewhat close but not totally "in sync", say like 100 Hz and 201 Hz, calculating their rms power offline will only give you the average rms, and not a useful power history.

(otoh, like i said above, if you measure it live using [average~] the result will also not be 100% accurate.)

so i´d say just try both and see what work best for you.

-110