Csound Csound-dev Csound-tekno Search About

[Csnd] dbamp

Date2010-11-16 14:45
Frommenno
Subject[Csnd] dbamp
hi,

i was using "dbamp" and found something that puzzled me, quite possibly a
lack of knowledge. I tried out this csd:



; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac          ; -iadc    ;;;RT audio Out
; For Non-realtime ouput leave only the line below:
; -o dbamp.wav -W ;;; for file output any platform



sr = 44100
ksmps = 32
nchnls = 2

instr 1

iamp = p4
idb  = dbamp(iamp)
     print idb
asig vco2 iamp, 110			;i use amp here, not idb
     outs asig, asig

endin




i 1 0 1 .1
i 1 + 1 1
i 1 + 1 1000
i 1 + 1 10000
e




The manual says: dbamp — Returns the decibel equivalent of the raw amplitude
x. 
The result from the csd is:

instr 1:  idb = -20.000
WARNING: rtjack: xrun in real time audio
B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.1      0.1
instr 1:  idb = 0.000
B  1.000 ..  2.000 T  2.000 TT  2.000 M:      1.2      1.2
instr 1:  idb = 60.000
B  2.000 ..  3.000 T  3.000 TT  3.000 M:   1164.5   1164.5
instr 1:  idb = 80.000
B  3.000 ..  4.000 T  4.000 TT  4.000 M:  11645.0  11645.0
Score finished in csoundPerform().
inactive allocs returned to freespace
end of score.		   overall amps:  11645.0  11645.0

here i see that with amp=10000 dbamp returns: 80, which i accept. But when
amp=1 dbamp gives 0 ??
And when amp=01 the result is even worse: -20 ??
What i like is to have confirmed that my knowledge of the oh so complex
issue of decibels needs an extreme makeover ??

thank you,
menno
-- 
View this message in context: http://csound.1045644.n5.nabble.com/dbamp-tp3267421p3267421.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-11-16 15:02
FromVictor Lazzarini
Subject[Csnd] Re: dbamp
The expression is

def dbamp(amp)
     return 20*log10(amp)


On 16 Nov 2010, at 14:45, menno wrote:

>
> hi,
>
> i was using "dbamp" and found something that puzzled me, quite  
> possibly a
> lack of knowledge. I tried out this csd:
>
> 
> 
> ; Select audio/midi flags here according to platform
> ; Audio out   Audio in
> -odac          ; -iadc    ;;;RT audio Out
> ; For Non-realtime ouput leave only the line below:
> ; -o dbamp.wav -W ;;; for file output any platform
> 
> 
>
> sr = 44100
> ksmps = 32
> nchnls = 2
>
> instr 1
>
> iamp = p4
> idb  = dbamp(iamp)
>     print idb
> asig vco2 iamp, 110			;i use amp here, not idb
>     outs asig, asig
>
> endin
>
> 
> 
>
> i 1 0 1 .1
> i 1 + 1 1
> i 1 + 1 1000
> i 1 + 1 10000
> e
>
> 
> 
>
> The manual says: dbamp — Returns the decibel equivalent of the raw  
> amplitude
> x.
> The result from the csd is:
>
> instr 1:  idb = -20.000
> WARNING: rtjack: xrun in real time audio
> B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.1      0.1
> instr 1:  idb = 0.000
> B  1.000 ..  2.000 T  2.000 TT  2.000 M:      1.2      1.2
> instr 1:  idb = 60.000
> B  2.000 ..  3.000 T  3.000 TT  3.000 M:   1164.5   1164.5
> instr 1:  idb = 80.000
> B  3.000 ..  4.000 T  4.000 TT  4.000 M:  11645.0  11645.0
> Score finished in csoundPerform().
> inactive allocs returned to freespace
> end of score.		   overall amps:  11645.0  11645.0
>
> here i see that with amp=10000 dbamp returns: 80, which i accept.  
> But when
> amp=1 dbamp gives 0 ??
> And when amp=01 the result is even worse: -20 ??
> What i like is to have confirmed that my knowledge of the oh so  
> complex
> issue of decibels needs an extreme makeover ??
>
> thank you,
> menno
> -- 
> View this message in context: http://csound.1045644.n5.nabble.com/dbamp-tp3267421p3267421.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-11-16 15:27
FromRichard Dobson
Subject[Csnd] Re: dbamp
You have discovered the reason I wrote the dbfsamp and ampdbfs opcodes 
many years ago - precisely because of this non-standard behaviour.

The old dbamp interprets the input value as a sample value assuming the 
traditional 16bit range, with the amplitude value of 10000 converted to 
a dB value of +80, as you see. We would more correctly define that 
amplitude (relative to 32767)  as 10000/32767 ~= -10.3dBFS. the 
convention today of course is that 0dB signifies peak amplitude.

But with dbamp as you found, the amplitude of 1 (understood here as one 
sample point above silence) gets translated to the value of 0dB, which 
is ~really~ confusing!

The newer dbfs~ opcodes take the current value of 0dbfs into account (by 
default 32767, but recommended to be set to 1.0 these days), so that you 
can use the standard definitions of dB levels (0dB for peak amplitude, 
-60dB for the threshold of silence, etc) and always get the appropriate 
amplitude value; whatever 0dbfs is set to.

So - use dbfsamp instead, and ideally specify 0dbfs = 1 in the 
orchestra, and use either fractional amplitude values or standard dB 
values in the score, as you prefer.

A few users have indicated that there are still uses for the old dbamp 
opcodes (which simply make the 20*log10(amp) calculation on whatever 
number is supplied), but for all general amplitude control purposes, use 
the dbfs versions,and read/write dB values in the industry-standard manner.



Richard Dobson





On 16/11/2010 14:45, menno wrote:
>
> hi,
>
> i was using "dbamp" and found something that puzzled me, quite possibly a
> lack of knowledge. I tried out this csd:
...
>
> here i see that with amp=10000 dbamp returns: 80, which i accept. But when
> amp=1 dbamp gives 0 ??
> And when amp=01 the result is even worse: -20 ??
> What i like is to have confirmed that my knowledge of the oh so complex
> issue of decibels needs an extreme makeover ??
>
> thank you,
> menno



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-11-16 15:32
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re: dbamp
the db family treat 1 as 0db; always mave. then do the maths, .1 in db is
20 log10(0.1/1) = 20 * (-1)

If you want a better use, thy dbfs family that takes 0dbfs as base,
defaulting to 32Ksome

==John ff

>
> hi,
>
> i was using "dbamp" and found something that puzzled me, quite possibly a
> lack of knowledge. I tried out this csd:
>
> 
> 
> ; Select audio/midi flags here according to platform
> ; Audio out   Audio in
> -odac          ; -iadc    ;;;RT audio Out
> ; For Non-realtime ouput leave only the line below:
> ; -o dbamp.wav -W ;;; for file output any platform
> 
> 
>
> sr = 44100
> ksmps = 32
> nchnls = 2
>
> instr 1
>
> iamp = p4
> idb  = dbamp(iamp)
>      print idb
> asig vco2 iamp, 110			;i use amp here, not idb
>      outs asig, asig
>
> endin
>
> 
> 
>
> i 1 0 1 .1
> i 1 + 1 1
> i 1 + 1 1000
> i 1 + 1 10000
> e
>
> 
> 
>
> The manual says: dbamp — Returns the decibel equivalent of the raw
> amplitude
> x.
> The result from the csd is:
>
> instr 1:  idb = -20.000
> WARNING: rtjack: xrun in real time audio
> B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.1      0.1
> instr 1:  idb = 0.000
> B  1.000 ..  2.000 T  2.000 TT  2.000 M:      1.2      1.2
> instr 1:  idb = 60.000
> B  2.000 ..  3.000 T  3.000 TT  3.000 M:   1164.5   1164.5
> instr 1:  idb = 80.000
> B  3.000 ..  4.000 T  4.000 TT  4.000 M:  11645.0  11645.0
> Score finished in csoundPerform().
> inactive allocs returned to freespace
> end of score.		   overall amps:  11645.0  11645.0
>
> here i see that with amp=10000 dbamp returns: 80, which i accept. But when
> amp=1 dbamp gives 0 ??
> And when amp=01 the result is even worse: -20 ??
> What i like is to have confirmed that my knowledge of the oh so complex
> issue of decibels needs an extreme makeover ??
>
> thank you,
> menno
> --
> View this message in context:
> http://csound.1045644.n5.nabble.com/dbamp-tp3267421p3267421.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>
>
>




Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"