[Csnd]
Date | 2011-02-05 18:04 |
From | Enrico Francioni |
Subject | [Csnd] |
Hello everyone, I wonder if there is an opcode that is able to calculate the arithmetic mean (or average math?) of a set of values (k or i). Has anyone ever created a patch for this? thanks, e |
Date | 2011-02-05 19:09 |
From | Victor Lazzarini |
Subject | Re: [Csnd] |
kaver = (k1 + k2)/2 ? On 5 Feb 2011, at 18:04, Enrico Francioni wrote: > > > Hello everyone, > > I wonder if there is an opcode that is able to calculate the > arithmetic mean > (or average math?) of a set of values (k or i). > Has anyone ever created a patch for this? > > thanks, > > e > -- > View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3372682.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" |
Date | 2011-02-05 23:47 |
From | peiman khosravi |
Subject | Re: [Csnd] |
One of the vector objects I think calculates the average of all the stored table values too. P On 5 February 2011 20:09, Victor Lazzarini |
Date | 2011-02-06 10:41 |
From | Enrico Francioni |
Subject | [Csnd] |
For example: I would like to calculate the arithmetic mean of kcps (in ptrack), but only when kcps it holds for a certain time around the same values. For example, around 440, then around 220, then around 390 ..., etc ... e |
Date | 2011-02-06 11:00 |
From | Iain McCurdy |
Subject | RE: [Csnd] |
Hi Enrico, You might like to take a look at the new mediank opcode (ver 5.13). It might provide you with the sort of data filtering you require here. Iain > Date: Sun, 6 Feb 2011 02:41:43 -0800 > From: francioni61021@libero.it > To: csound@lists.bath.ac.uk > Subject: [Csnd] Re: …arithmetic mean? > > > > For example: > I would like to calculate the arithmetic mean of kcps (in ptrack), > but only when kcps it holds for a certain time around the same values. > > For example, around 440, then around 220, then around 390 ..., etc ... > > e > -- > View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3373120.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" > |
Date | 2011-02-06 11:09 |
From | Victor Lazzarini |
Subject | Re: [Csnd] |
you've beat me too it, Ian. I was looking for the name of the opcode... actually Oeyvind asked for this to use with pitch controller. Victor On 6 Feb 2011, at 11:00, Iain McCurdy wrote:
|
Date | 2011-02-07 07:26 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] |
Yeah, it works well to take out the spurious spikes in a pitch tracking analysis signal. I've included some example code below, it also includes a frequency dependant method for auto-switching between analysis with different hopsizes, so the example could have been simplified a bit to show mediank more clearly. best Oeyvind ; Pitch and amp analysis kcps init 0 ihopsize1 = 4096 ihopsize2 = 512 iChangeover = (sr/ihopsize2)*3 if kcps > iChangeover kgoto small kcps, kamp ptrack a1, ihopsize1 if kcps <= iChangeover kgoto nosmall small: kcps, kamp ptrack a1, ihopsize2 nosmall: ; filter pitch tracking signal imedianSize = int(0.09*kr) ; calc as (1/(ihopsize*2))*kr kcps mediank kcps, imedianSize, imedianSize 2011/2/6 Victor Lazzarini |
Date | 2011-02-08 07:42 |
From | Enrico Francioni |
Subject | [Csnd] |
many thanks, Oeyvind! you can write a comment on your example? ... in fact, what is the opcode mediank? how exactly is the performance of mediank? e |
Date | 2011-02-08 07:58 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] |
All good. Here's a simpler version: ihopsize = 1024 kcps, kamp ptrack a1, ihopsize imedianSize = 129 kcps mediank kcps, imedianSize, imedianSize The median filter is quite different from most audio filters, in that the output is the middle value in it's buffer. The buffer size is set by imedianSize in the example above. You might want to experiment with different sizes to see what best fits with your data. For example for the input data [7,1,8,57,2,7,8,9,8] you can see that most of the activity is in the area around values 7,8 and 9, with spurious peaks (probably noise) at 1,2 and 57. If we sort this buffer of data in ascending order: [1,2,7,7,8,8,8,9,57] and take the middle member (number 5 from the left), we get 8 as the output. For the next k-rate period, the data in the buffer is updated (adding one member on the left side and discarding the one one the right) all best Oeyvind 2011/2/8 Enrico Francioni |
Date | 2011-02-08 08:40 |
From | Andres Cabrera |
Subject | Re: [Csnd] |
Hi, Here's the manual page: www.csounds.com/manual/html/mediank.html Cheers, Andres On Tue, Feb 8, 2011 at 7:58 AM, Oeyvind Brandtsegg |
Date | 2011-02-08 09:58 |
From | joachim heintz |
Subject | Re: [Csnd] |
hi andrés - can we add oeyvind's description at the page? i myself needed this description to really understand what this very useful opcode does. thanks - joachim Am 08.02.2011 09:40, schrieb Andres Cabrera: > Hi, > > Here's the manual page: > www.csounds.com/manual/html/mediank.html > > Cheers, > Andres > > On Tue, Feb 8, 2011 at 7:58 AM, Oeyvind Brandtsegg > |
Date | 2011-02-08 11:04 |
From | Victor Lazzarini |
Subject | Re: [Csnd] |
Would you contribute a UDO to the database with the other, switching version? I think it should be very useful. Victor On 8 Feb 2011, at 07:58, Oeyvind Brandtsegg wrote: > All good. > > Here's a simpler version: > > ihopsize = 1024 > kcps, kamp ptrack a1, ihopsize > imedianSize = 129 > kcps mediank kcps, imedianSize, imedianSize > > The median filter is quite different from most audio filters, in that > the output is the middle value in it's buffer. The buffer size is set > by imedianSize in the example above. You might want to experiment with > different sizes to see what best fits with your data. > For example for the input data > [7,1,8,57,2,7,8,9,8] > you can see that most of the activity is in the area around values > 7,8 and 9, > with spurious peaks (probably noise) at 1,2 and 57. > If we sort this buffer of data in ascending order: > [1,2,7,7,8,8,8,9,57] > and take the middle member (number 5 from the left), we get 8 as the > output. > > For the next k-rate period, the data in the buffer is updated (adding > one member on the left side and discarding the one one the right) > > all best > Oeyvind > > 2011/2/8 Enrico Francioni |
Date | 2011-02-08 13:17 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] |
oh, I'll try :-)... it's a bit hectic for the next few weeks Oeyvind 2011/2/8 Victor Lazzarini |
Date | 2011-02-08 16:55 |
From | Enrico Francioni |
Subject | [Csnd] |
…unfortunately mediank does not work with MacCsound 1.5 ... (with Csound 5.13 UB) ! [and other opcodes do not work ...] ? e -- View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3376205.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" |
Date | 2011-02-08 17:02 |
From | Victor Lazzarini |
Subject | Re: [Csnd] |
Use qutecsound? On 8 Feb 2011, at 16:55, Enrico Francioni wrote: > > > > …unfortunately mediank does not work with MacCsound 1.5 ... (with > Csound > 5.13 UB) ! > > [and other opcodes do not work ...] > ? > > e > -- > View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3376205.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" |
Date | 2011-02-08 17:05 |
From | Enrico Francioni |
Subject | [Csnd] |
I think it's time to do it ... [sig] e |
Date | 2011-02-08 19:40 |
From | Enrico Francioni |
Subject | [Csnd] |
…anyone out there has created a patch to mediank alternative? thanks… e -- View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3376485.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" |
Date | 2011-02-09 10:43 |
From | joachim heintz |
Subject | Re: [Csnd] |
what do you need exactely? in which situation? Am 08.02.2011 20:40, schrieb Enrico Francioni: > > > > …anyone out there has created a patch to mediank alternative? > > thanks… > > e 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" |
Date | 2011-02-09 16:21 |
From | Enrico Francioni |
Subject | [Csnd] |
Hi joachim! I would like to have this situation: ; Pitch and amp analysis kcps init 0 ihopsize1 = 4096 ihopsize2 = 512 iChangeover = (sr/ihopsize2)*3 if kcps > iChangeover kgoto small kcps, kamp ptrack a1, ihopsize1 if kcps <= iChangeover kgoto nosmall small: kcps, kamp ptrack a1, ihopsize2 nosmall: ; filter pitch tracking signal imedianSize = int(0.09*kr) ; calc as (1/(ihopsize*2))*kr kcps mediank kcps, imedianSize, imedianSize but with an alternative patch; I can not make use of the opcode mediank (for use with Csound 5.13 1.5 MacCsound UB) I would like to calculate the arithmetic mean of kcps (in ptrack), but only when kcps it holds for a certain time around the same values. For example, around 440, then around 220, then around 390 ..., etc ... e |
Date | 2011-02-09 21:01 |
From | joachim heintz |
Subject | Re: [Csnd] |
hi francesco - there is an UDO "Stayed" which returns 1 if a k-value has not changed since a certain time. you can download it here: http://www.csounds.com/udo/displayOpcode.php?opcode_id=130 perhaps it can help. but i think, because your kcps will certainly fluctuate continuously, you must first create a variable which is 1 when kcps is in a certain range. for instance: kinrange = (kcps > 400 && kcps < 480 ? 1 : 0) ;kcps between 400 and 480? then you can apply Stayed: kyes Stayed kinrange, .5 ;kcps between 400 and 480 for at least 0.5 seconds? does this help? joachim Am 09.02.2011 17:21, schrieb Enrico Francioni: > > Hi joachim! > > > I would like to have this situation: > > ; Pitch and amp analysis > > kcps init 0 > ihopsize1 = 4096 > ihopsize2 = 512 > iChangeover = (sr/ihopsize2)*3 > > if kcps > iChangeover kgoto small > kcps, kamp ptrack a1, ihopsize1 > if kcps <= iChangeover kgoto nosmall > small: > kcps, kamp ptrack a1, ihopsize2 > nosmall: > > ; filter pitch tracking signal > imedianSize = int(0.09*kr) ; calc as (1/(ihopsize*2))*kr > kcps mediank kcps, imedianSize, imedianSize > > > but with an alternative patch; > I can not make use of the opcode mediank > (for use with Csound 5.13 1.5 MacCsound UB) > > > I would like to calculate the arithmetic mean of kcps (in ptrack), > but only when kcps it holds for a certain time around the same values. > > For example, around 440, then around 220, then around 390 ..., etc ... > > e 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" |
Date | 2011-02-11 09:14 |
From | Enrico Francioni |
Subject | [Csnd] |
thanks joachim but with UDO Stayed I can only assess if the frequency is changed (1 or 0). I am unable to make a mean value of kcps... e |
Date | 2011-02-11 10:41 |
From | joachim heintz |
Subject | Re: [Csnd] |
yes this is the next step. i think you can do this with a k-rate lowpass filter, as one solution. like this: |
Date | 2011-02-11 17:04 |
From | Enrico Francioni |
Subject | [Csnd] |
…to solve the problem, a friend advised me to apply this patch. I added some modifications. What do you think? ;=============================== instr 1 asig inch 1 iSize pow 2, 10 gkcps,kA ptrack aSig, iSize kindex init -1 kfreq init 0 ; ...first pitch-detector kindex = kindex + 1 kfreq = kfreq + gkcps ;printk gitime, gkfreq, 80 if kindex == 32 then kindex = 0 gkfreq = kfreq / 32 kfreq = 0 endif printk .001, gkcps printk .001, gkfreq, 10 endin ;=============================== e -- View this message in context: http://csound.1045644.n5.nabble.com/arithmetic-mean-tp3372682p3381605.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" |
Date | 2011-02-11 20:08 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] |
hmm, to me it looks like you would be better off using a lowpass filter like tonek or portk. If I'm not mistaken, your solution will give you the average of 32 k-rate values, and it's not a "moving average" (not updated on every k-rate pass), but it's rather a "windowed average" (someone please correct me if I'm using the wrong term) in that it gives the average of the first 32 values, then it needs to fill up 32 new values before outputting the average of those (value 33 to 64) and then progresses in chunks of 32. best Oeyvind 2011/2/11 Enrico Francioni |
Date | 2011-02-11 20:25 |
From | Enrico Francioni |
Subject | [Csnd] |
Yes, Oeyvind but it is also true that the buffer is a few milliseconds... The road opened by joachim does not seem to be discarded ... In Csound can take different paths with each other to achieve the same results, no? e p.s. I also go into the patch joachim |
Date | 2011-02-11 21:35 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] |
Yes, indeed, you can achieve your goal in many different ways. And it seems you search and experiment very fruitfully, there is no right or wrong, so keep it up. all best Oeyvind 2011/2/11 Enrico Francioni |