Csound Csound-dev Csound-tekno Search About

[Csnd] Average of the values

Date2013-01-13 11:24
FromEnrico Francioni
Subject[Csnd] Average of the values
Hi!

…opcode which I can use to get an average of values ​​(k) over time (t)?
I should obtain the mean value of the intensity (in dB) in a time interval
of at least 4/5 seconds (for example, how does a sound level meter).

It is a my csd.
The signal is a white-noise that is sent to a monitor at a time.
The signal then is picked up by a microphone and then measured in intensity
(but over time of a few seconds).

This algorithm will help me to adjust the volume of individual monitors on
the same level (as precisely as possible).

thanks,

enrico



--
View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373.html
Sent from the Csound - General mailing list archive at Nabble.com.


Date2013-01-13 11:37
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] Average of the values
rms is possibly what you want -- it is what we used in the blues band
>
> Hi!
>
> …opcode which I can use to get an average of values ​​(k) over time
> (t)?
> I should obtain the mean value of the intensity (in dB) in a time interval
> of at least 4/5 seconds (for example, how does a sound level meter).
>
> It is a my csd.
> The signal is a white-noise that is sent to a monitor at a time.
> The signal then is picked up by a microphone and then measured in
> intensity
> (but over time of a few seconds).
>
> This algorithm will help me to adjust the volume of individual monitors on
> the same level (as precisely as possible).
>
> thanks,
>
> enrico
>
>
>
> --
> View this message in context:
> http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373.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"
>
>
>
>



Date2013-01-13 11:57
FromEnrico Francioni
Subject[Csnd] Re: Average of the values
you refer to your patch accompanist.csd?



--
View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719375.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2013-01-13 13:27
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] Re: Average of the values
> you refer to your patch accompanist.csd?
>
>


Yes





Date2013-01-13 14:40
FromEnrico Francioni
Subject[Csnd] Re: Average of the values
I do not know if I had already written in another post.

This could be another solution?





	kr	=	441

	instr	1

	a_in		inch	1
	ksign		downsamp	a_in

	kdB		= dbamp(ksign)
	kdB1		= abs(kdB)

;here there is a mean (average) every n samples:

	kindex	init	0
	kamp		init	0
	kvrg		init	0

	kindex = kindex + 1
	kamp = kamp + kdB1

	icps	 = (2^10 )+1		; = 1025

	if kindex == icps then
	kindex = 0			
	kvrg = kamp / icps
	kamp	  = 0	
	endif

	endin




f0 99999

i1	0	100









--
View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719378.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2013-01-13 17:07
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] Re: Average of the values
> I do not know if I had already written in another post.
>
> This could be another solution?
>

It would average very approximately a block of 102400 samples, and then
reset.  kvrg could change abruptly.  It depends on your intended use, but
you mny need a lowpass filter on krvg.  Compared with rms which in effect
avertages the last n samples in a running fashion.

So it depends on the purpose.  For example with a 441Hz signal it would
have very inaccurate answers (consider an impulse wave; you will get 1 or
zero depending on phase if my maths is correct)

>
> 
> 
>
> 	kr	=	441
>
> 	instr	1
>
> 	a_in		inch	1
> 	ksign		downsamp	a_in
>
> 	kdB		= dbamp(ksign)
> 	kdB1		= abs(kdB)
>
> ;here there is a mean (average) every n samples:
>
> 	kindex	init	0
> 	kamp		init	0
> 	kvrg		init	0
>
> 	kindex = kindex + 1
> 	kamp = kamp + kdB1
>
> 	icps	 = (2^10 )+1		; = 1025
>
> 	if kindex == icps then
> 	kindex = 0
> 	kvrg = kamp / icps
> 	kamp	  = 0
> 	endif
>
> 	endin
>
> 
> 
>
> f0 99999
>
> i1	0	100
>
> 
>
> 
>
>
>
>
>
> --
> View this message in context:
> http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719378.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"
>
>
>
>



Date2013-01-13 18:48
FromEnrico Francioni
Subject[Csnd] Re: Average of the values
This algorithm will help me to adjust the volume of individual monitors on
the same level (as precisely as possible).

That's what makes the algorithm (csd):

1. sends a signal (white-noise) to monitor (a monitor at a time)
2. captures the signal through a microphone (located in the center position)
3. measure the dB signal with a level detect
4. I therefore rule the volume of individual monitors to the same value (eg
58 dB)

e



--
View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719381.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2013-01-13 18:59
FromVictor Lazzarini
SubjectRe: [Csnd] Re: Average of the values
For this you want RMS.
On 13 Jan 2013, at 18:48, Enrico Francioni wrote:

> 
> This algorithm will help me to adjust the volume of individual monitors on
> the same level (as precisely as possible).
> 
> That's what makes the algorithm (csd):
> 
> 1. sends a signal (white-noise) to monitor (a monitor at a time)
> 2. captures the signal through a microphone (located in the center position)
> 3. measure the dB signal with a level detect
> 4. I therefore rule the volume of individual monitors to the same value (eg
> 58 dB)
> 
> e
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719381.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2013-01-14 09:46
FromEnrico Francioni
Subject[Csnd] Re: Average of the values
Hi Victor,
I wrote this code;
you think it could be a starting point to achieve what I said?





	kr		=	441
	0dbfs		=	1


	instr	1

        ; signal
	arnd	rand	.7
	out	arnd

        ; detect level
	a_in		inch	1
	ksign 	rms 		a_in
	kdB1		= dbamp(ksign)

	; average

	kindex	init	0
	kamp		init	0
	kvrg		init	0

	kindex = kindex + 1
	kamp = kamp + kdB1
	kpw	invalue	"pw"   ; eg 11
	ipw	=	i(kpw)
	icps	 = (2^ipw)+1

	if kindex == icps then
	kindex = 0
	kvrg = kamp / icps
	kamp	  = 0	
	endif

        if kvrg < -110 then
        kvrg	= 0
        endif

	outvalue	"vrg", kvrg

	endin



f0 99999
i1	0	100








--
View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719386.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2013-01-14 11:02
FromVictor Lazzarini
SubjectRe: [Csnd] Re: Average of the values
I don't think you need to average the RMS measurement, so, this is probably what you need

instr 1
a1 rand 0dbfs/2
ain inch 1
krms rms ain
printk2 krms
out a1
endin

then calibrate your system accordingly.

but if you want to stabilise any fluctuations, you can try using 'port', with ihtim set to 
a high enough value in ms (the 'average' period). That might work better than your averaging code (port will do the averaging)

instr 1
a1 rand 0dbfs/2
ain inch 1
krms rms ain
krms port krms,  0.5
printk2 krms
out a1
endin



Victor

On 14 Jan 2013, at 09:46, Enrico Francioni wrote:

> Hi Victor,
> I wrote this code;
> you think it could be a starting point to achieve what I said?
> 
> 
> 
> 
> 
> 	kr		=	441
> 	0dbfs		=	1
> 
> 
> 	instr	1
> 
>        ; signal
> 	arnd	rand	.7
> 	out	arnd
> 
>        ; detect level
> 	a_in		inch	1
> 	ksign 	rms 		a_in
> 	kdB1		= dbamp(ksign)
> 
> 	; average
> 
> 	kindex	init	0
> 	kamp		init	0
> 	kvrg		init	0
> 
> 	kindex = kindex + 1
> 	kamp = kamp + kdB1
> 	kpw	invalue	"pw"   ; eg 11
> 	ipw	=	i(kpw)
> 	icps	 = (2^ipw)+1
> 
> 	if kindex == icps then
> 	kindex = 0
> 	kvrg = kamp / icps
> 	kamp	  = 0	
> 	endif
> 
>        if kvrg < -110 then
>        kvrg	= 0
>        endif
> 
> 	outvalue	"vrg", kvrg
> 
> 	endin
> 
> 
> 
> f0 99999
> i1	0	100
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373p5719386.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2013-01-14 11:28
FromRuben Sverre Gjertsen
Subject[Csnd] Average irate pitch
Hi,

This could be a different discussion:
Is there a way to scan through a soundfile and return an average pitch at the beginning of a note?
I have tried pvspitch and pvscent, which output k-rate pitches.  The problem is that I don't want autotune, but a stable reference frequency.
I have reference pitch as a score parameter now, an automatic solution would be interesting.

Ruben


Den 13. jan. 2013 kl. 12.24 skrev Enrico Francioni:

> 
> Hi!
> 
> …opcode which I can use to get an average of values ​​(k) over time (t)?
> I should obtain the mean value of the intensity (in dB) in a time interval
> of at least 4/5 seconds (for example, how does a sound level meter).
> 
> It is a my csd.
> The signal is a white-noise that is sent to a monitor at a time.
> The signal then is picked up by a microphone and then measured in intensity
> (but over time of a few seconds).
> 
> This algorithm will help me to adjust the volume of individual monitors on
> the same level (as precisely as possible).
> 
> thanks,
> 
> enrico
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373.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"
> 



Date2013-01-14 12:08
FromVictor Lazzarini
SubjectRe: [Csnd] Average irate pitch
Try ptrack or plltrack through port with ihtim = 0.01

Victor
On 14 Jan 2013, at 11:28, Ruben Sverre Gjertsen wrote:

> Hi,
> 
> This could be a different discussion:
> Is there a way to scan through a soundfile and return an average pitch at the beginning of a note?
> I have tried pvspitch and pvscent, which output k-rate pitches.  The problem is that I don't want autotune, but a stable reference frequency.
> I have reference pitch as a score parameter now, an automatic solution would be interesting.
> 
> Ruben
> 
> 
> Den 13. jan. 2013 kl. 12.24 skrev Enrico Francioni:
> 
>> 
>> Hi!
>> 
>> …opcode which I can use to get an average of values ​​(k) over time (t)?
>> I should obtain the mean value of the intensity (in dB) in a time interval
>> of at least 4/5 seconds (for example, how does a sound level meter).
>> 
>> It is a my csd.
>> The signal is a white-noise that is sent to a monitor at a time.
>> The signal then is picked up by a microphone and then measured in intensity
>> (but over time of a few seconds).
>> 
>> This algorithm will help me to adjust the volume of individual monitors on
>> the same level (as precisely as possible).
>> 
>> thanks,
>> 
>> enrico
>> 
>> 
>> 
>> --
>> View this message in context: http://csound.1045644.n5.nabble.com/Average-of-the-values-tp5719373.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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie