Csound Csound-dev Csound-tekno Search About

[Csnd] Scaling amplitudes in polyphony

Date2007-12-04 17:26
Fromthorne
Subject[Csnd] Scaling amplitudes in polyphony
I assume these are very beginning beginner's FAQs--or at least the first
one, but i haven't been able to find the answers.  It must be something
simple....  Any leads would be much appreciated.

1. I have a simple instrument under midi control.  All is well, until
the performer plays more than three or so pitches at the same time--then
it seems to clip (surprise).  Is there a normal or standard (or at any
rate, smart) way of dealing with this?  I was fiddling with sending
output not to `out' but to a global variable and then using a separate
instrument to mix the signal, but then i have to somehow have it know
how many instruments are playing and scale the signal accordingly...?
Or not?  I have a feeling i'm barking up the wrong tree.

2. I am building a super-simple sine wave instrument.  My understanding
is that for a given amplitude, perceived loudness tends to decrease with
decreasing pitch.  Does anyone know if there is a standard function that
will yield a scalar to compensate for this effect?

--
Theron Ttlåx


Date2007-12-04 20:08
FromAndres Cabrera
Subject[Csnd] Re: Scaling amplitudes in polyphony
Hi,

El mar, 04-12-2007 a las 10:26 -0700, thorne escribió:
> 1. I have a simple instrument under midi control.  All is well, until
> the performer plays more than three or so pitches at the same time--then
> it seems to clip (surprise).  Is there a normal or standard (or at any
> rate, smart) way of dealing with this?  I was fiddling with sending
> output not to `out' but to a global variable and then using a separate
> instrument to mix the signal, but then i have to somehow have it know
> how many instruments are playing and scale the signal accordingly...?
> Or not?  I have a feeling i'm barking up the wrong tree.
> 
The only way is to use smaller amplitudes for each note or like you said
use a master mixer instrument.
Bear in mind that amplitude values in csound are not linear, and a
halving of amplitude value is actually only 6 dB lower.

> 2. I am building a super-simple sine wave instrument.  My understanding
> is that for a given amplitude, perceived loudness tends to decrease with
> decreasing pitch.  Does anyone know if there is a standard function that
> will yield a scalar to compensate for this effect?
> 
This inaccuracy in perception is shown in the fletcher-munson (sometimes
called robson-dadson) curves:
http://en.wikipedia.org/wiki/Fletcher%E2%80%93Munson_curves

It is normally compensated using weighing curves, which approximate the
effect in an easy but gross way:
http://en.wikipedia.org/wiki/A-weighting

Cheers,
Andrés


> --
> Theron Ttlåx
> 
> 
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2007-12-05 14:10
FromMark Van Peteghem
Subject[Csnd] Re: Re: Scaling amplitudes in polyphony
Andres Cabrera schreef:
>> 2. I am building a super-simple sine wave instrument.  My understanding
>> is that for a given amplitude, perceived loudness tends to decrease with
>> decreasing pitch.  Does anyone know if there is a standard function that
>> will yield a scalar to compensate for this effect?
>>
>>     
> This inaccuracy in perception is shown in the fletcher-munson (sometimes
> called robson-dadson) curves:
> http://en.wikipedia.org/wiki/Fletcher%E2%80%93Munson_curves
>
> It is normally compensated using weighing curves, which approximate the
> effect in an easy but gross way:
> http://en.wikipedia.org/wiki/A-weighting
>   

It also depends on the waveform used. In my experience a square waveform 
sounds about about as loud as a triangle waveform with the an amplitude 
that is 3 times higher. And for a sine wave the amplitude has to be even 
higher. I suppose you could deduce this from the curves mentioned above, 
by calculating how much each harmonic adds to the perceived loudness.

This makes it almost impossible to compare the loudness of different 
instruments by simply comparing the amplitude, not that it matters much.

-- 
  Mark
  _________________________________________
  When you get lemons, you make lemonade.
  When you get hardware, you make software.


Date2007-12-05 19:57
From"Chuckk Hubbard"
Subject[Csnd] Re: Re: Scaling amplitudes in polyphony
AttachmentsNone  

Date2007-12-05 23:39
FromRichard Dobson
Subject[Csnd] Re: Re: Re: Scaling amplitudes in polyphony
Chuckk Hubbard wrote:
> On Dec 4, 2007 10:08 PM, Andres Cabrera  wrote:
> 
>>Bear in mind that amplitude values in csound are not linear, and a
>>halving of amplitude value is actually only 6 dB lower.
> 
> 
> Don't you mean that amplitude values in Csound are linear, and
> decibels are not linear?
> 
> Actually decibels still throw me.  I am perfectly fine with computing
> simple logarithmic amplitudes in my head; and to have such a wide
> dynamic range expressed in 6 units seems limiting.  I guess I just
> outed myself as never having used much studio equipment...
> 
> -Chuckk
> 


This is one of the most common questions in digital audio and..



is why so much computer music has such a narrow dynamic range.



People may suppose that 0.1 is a really small amplitude. It isn't.

Amplitude corresponds to voltage in an electrical signal, and to 
displacement in a sound wave. Hence it is the most "raw" measure of the 
intensity of a signal. As it happens, we can hear over a huge dynamic 
range, such that an amplitude of 0.001 (relative to 1.0 as "maximum") is 
still very much audible: = -60dB, or the just-audible end of a reverb 
decay (hence the "RT60" specification of a space). The decibel is not, 
strictly speaking, a raw measure of intensity, but a ~comparison~ 
between two levels. It is a specific form of logarithmic scale, used to 
represent that vast range of amplitudes with a smaller range of numbers 
that more closely reflects the perception of the ear. To the eye, the 
difference between 1.0 and 0.5 is  a lot; but to the ear, it is not such 
a big deal.

"Linear" signifies the way a graphic scale is presented - equal distance 
= equal difference. The musical frequency scale (in Hz) is linear - the 
differences between 220 and 440, and between 440 and 660, are the same 
(220). But the ~ratios~ are different, hence the interval they represent 
is different. So pitch is described over a logarithmic scale (same 
~ratio~). Intensity can be measured similarly in either way.

So in short:
    linear       = "same distance = same increment"
    logarithmic  = "same distance = same ratio"

Hence = to get the same chjange of loudness, you multiple amplitudes 
("0.5"), or add decibels ("-6dB").

If you remember the good old days of the slide rule: that is marked with 
a log scale, so that multiplication etc works for the same amount of 
slide, wherever you are. A "linear" slide rule (= any ordinary ruler) 
could not be used for anything more than addition and subtraction.

At the "lowest" level of numeric representation, all audio software 
eventually deals with amplitudes - 0.5, 0.01, 0.00123, etc. But, it 
would be a very bad idea to manually control loudness that way, for the 
reasons above:

*  covering the top half of the slider range would only reduce power by 6dB
*  equal-distance slider movements will not result in equal-sounding 
loudness changes

~Much~ better to represent all amplitude values in dB, and let Csound 
convert it to the often very small raw amplitude levels. Much easier to 
write -30 than 0.031 (approx) and, I suspect, more ~meaningful too! In 
an amplifier or mixer, all the volume controls (faders etc) use a 
"log-law" potentiometer to achieve this - a "linear" pot would be awful.

A practical consequence of all this is that "normalizing" a soundfile to 
a peak amplitiude of 0.25 looks like a massive reduction; whereas it is 
only -12dB  (of at least 96dB available, more with 24bit and floats); 
many professional systems normalize 0dB to much less than that. Thus, 
all too often people normalize to such a high level that clipping is 
pretty much guaranteed.


A very comprehensive presentation of this topic (with graphs!) is here:

http://www.indiana.edu/~emusic/acoustics/amplitude.htm

HTH

Richard Dobson







Date2007-12-06 00:32
From"Chuckk Hubbard"
Subject[Csnd] Re: Re: Re: Re: Scaling amplitudes in polyphony
AttachmentsNone