[Csnd] streaming linear prediction
Date | 2020-05-17 21:20 |
From | Victor Lazzarini |
Subject | [Csnd] streaming linear prediction |
Hi everyone, back to the list, after a while. You know, kids at home, work to do etc. I wanted to introduce you to some new stuff I am starting to add to Csound. Back in 2012 when we started planning Cs 6, on my todo list was the request of adding a streaming version of lpc to Csound. I had a look then, the code in lpanal did not look suitable for that and I did not pursue it any further. Now, I have been looking again at lpc, and noticed a much, much better algorithm than what we have in lpanal is described in Makhoul’s tutorial. So I decided to have a go at programming it in C, after prototyping it in Python. This weekend I finally had some time to write it. It seems to work well, and it opens up a possibility for a suite of lpc streaming opcodes. I have two of them written as a proof of concept and will add more as time permits. In particular I see two things as promising: (a) integration with fsigs; (b) using arrays to hold lpc data. So, the opcodes I wrote are asig lpcfilter ain, kpos, kflag, ifn, iN, iM [, ifw] ain - input kpos - read pos in samples kflag - 1 -> compute new filter coefficients, 0 -> keep old coefficients ifn - source table for linear prediction iN - autocorrelation size (lpc input size) iM - allpole filter order ifw - optional window table asig lpcfilter ain, asrc, iN, iM [, ifw] same as above, except for asrc - source signal for linear prediction The main difference is that the second opcode computes new coefficients every M samples, using the past N samples from the source signal. The first computes when asked, from N samples taken from the table at pos kpos. Examples: ========== gifn ftgen 0,0,0,1,"fox.wav",0,0,1 gifw ftgen 0,0,1024,20,2,1 instr 1 k1 init 0 kts = .75 // timescale a1 diskin “beats.wav",1,0,1 a3 lpcfilter a1/5,k1,1,gifn,1024,64,gifw k1 += 64*kts if k1 > ftlen(gifn) then k1 = 0 endif out a3 endin instr 2 a1 diskin "fox.wav",1,0,1 a2 diskin “beats.wav",1,0,1 a3 lpcfilter a2/5,a1,1024,64,gifw out a3 endin ======= The first instrument, reading from the table, is capable of timescale modifications (and other tricks). These may undergo some small changes before release, and I’ll add more as time permits. best ======================== Prof. Victor Lazzarini Maynooth University Ireland Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-17 21:22 |
From | Marc Demers |
Subject | [Csnd] RE=?Windows-1252?Q?=A0=3A_?=streaming linear prediction |
De : A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> de la part de Victor Lazzarini <Victor.Lazzarini@MU.IE>
Envoyé : Sunday, May 17, 2020 4:20:25 PM À : CSOUND@LISTSERV.HEANET.IE <CSOUND@LISTSERV.HEANET.IE> Objet : [Csnd] streaming linear prediction Hi everyone,
back to the list, after a while. You know, kids at home, work to do etc. I wanted to introduce you to some new stuff I am starting to add to Csound. Back in 2012 when we started planning Cs 6, on my todo list was the request of adding a streaming version of lpc to Csound. I had a look then, the code in lpanal did not look suitable for that and I did not pursue it any further. Now, I have been looking again at lpc, and noticed a much, much better algorithm than what we have in lpanal is described in Makhoul’s tutorial. So I decided to have a go at programming it in C, after prototyping it in Python. This weekend I finally had some time to write it. It seems to work well, and it opens up a possibility for a suite of lpc streaming opcodes. I have two of them written as a proof of concept and will add more as time permits. In particular I see two things as promising: (a) integration with fsigs; (b) using arrays to hold lpc data. So, the opcodes I wrote are asig lpcfilter ain, kpos, kflag, ifn, iN, iM [, ifw] ain - input kpos - read pos in samples kflag - 1 -> compute new filter coefficients, 0 -> keep old coefficients ifn - source table for linear prediction iN - autocorrelation size (lpc input size) iM - allpole filter order ifw - optional window table asig lpcfilter ain, asrc, iN, iM [, ifw] same as above, except for asrc - source signal for linear prediction The main difference is that the second opcode computes new coefficients every M samples, using the past N samples from the source signal. The first computes when asked, from N samples taken from the table at pos kpos. Examples: ========== gifn ftgen 0,0,0,1,"fox.wav",0,0,1 gifw ftgen 0,0,1024,20,2,1 instr 1 k1 init 0 kts = .75 // timescale a1 diskin “beats.wav",1,0,1 a3 lpcfilter a1/5,k1,1,gifn,1024,64,gifw k1 += 64*kts if k1 > ftlen(gifn) then k1 = 0 endif out a3 endin instr 2 a1 diskin "fox.wav",1,0,1 a2 diskin “beats.wav",1,0,1 a3 lpcfilter a2/5,a1,1024,64,gifw out a3 endin ======= The first instrument, reading from the table, is capable of timescale modifications (and other tricks). These may undergo some small changes before release, and I’ll add more as time permits. best ======================== Prof. Victor Lazzarini Maynooth University Ireland Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-17 21:50 |
From | Rory Walsh |
Subject | Re: [Csnd] streaming linear prediction |
Nice one Victor. I've never used any of the lpc stuff but this looks like a good opportunity to learn more about it. On Sun, 17 May 2020 at 21:20, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: Hi everyone, |
Date | 2020-05-17 22:23 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] streaming linear prediction |
This should simplify the process. ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 17 May 2020, at 21:50, Rory Walsh |
Date | 2020-05-17 22:28 |
From | Rory Walsh |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] streaming linear prediction |
And tell us what else you have been working on. Last we spoke you were working a way of transpiling opcodes? On Sun, 17 May 2020 at 22:23, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: This should simplify the process. |
Date | 2020-05-17 22:32 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] streaming linear prediction |
Victor, Nice that you have decided to come back to Csound. Welcome back ;-). - what have you been up to? reading Game of Thrones? ;-) This is soooooo exciting. I LOVE LPC, but I rarely get to teach it in my DSP classes. - now I will! Please release a .dmg of Csound for the Mac with these new opcodes - ASAP. As it turns out, SoundHack no longer runs on the Mac under Catalina - Over the years, SoundHack has been a big part of my DSP classes (we do a ton of Csound too, but not until the second half of the semester) - Some of you might know that SoundHack exported Csound .pvc files Well - now... Csound and Cecilia and Cabbage and Csound for Live are all becoming the main focus of my DSP teaching @ Berklee. - Anyone studying DSP usually focuses on the Masterpiece Compositions by Paul Lansky (and we all know that they feature a ton of LPC work) And so now - with these tools... and maybe some new Csound for Live instruments and Cabbage instruments that use them! there will be a number of projects and a lot of teaching that will follow! Can't wait!!!! I would love to see the Python versions too - hopefully, you will share all of your great work with us. AND - thanks Take care, -Rick _____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger) ______________________________________________ President of Boulanger Labs - http://boulangerlabs.com Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book Author & Editor of The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book ______________________________________________ about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ ______________________________________________ email: rboulanger@berklee.edu facebook: https://www.facebook.com/richard.boulanger.58 On Sun, May 17, 2020 at 4:20 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: Hi everyone, |
Date | 2020-05-17 22:59 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] streaming linear prediction |
ah, that's a hard problem. Hoping to get back tackle this sometime in the future. Prof. Victor Lazzarini
Maynooth University
Ireland
On 17 May 2020, at 22:28, Rory Walsh <rorywalsh@ear.ie> wrote:
|
Date | 2020-05-17 23:14 |
From | Oscar Pablo Di Liscia |
Subject | Re: [Csnd] streaming linear prediction |
Looks very good. I will try it soon. Many thanks! El domingo, 17 de mayo de 2020, Victor Lazzarini <Victor.Lazzarini@mu.ie> escribió:
-- Dr. Oscar Pablo Di Liscia Profesor Titular Director Programa de Investigación "Sistemas Temporales y Síntesis Espacial en el Arte Sonoro" http://stseas.web.unq.edu.ar/ Director Colección Editorial "Música y Ciencia" Escuela Universitaria de Artes Universidad Nacional de Quilmes Argentina Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-18 08:07 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] streaming linear prediction |
Wow! søn. 17. mai 2020 kl. 22:20 skrev Victor Lazzarini <Victor.Lazzarini@mu.ie>: Hi everyone, |
Date | 2020-05-18 20:14 |
From | joachim heintz |
Subject | Re: [Csnd] streaming linear prediction |
very interesting -- looking forward to trying it out! joachim On 17/05/2020 22:20, Victor Lazzarini wrote: > Hi everyone, > > back to the list, after a while. You know, kids at home, work to do etc. > > I wanted to introduce you to some new stuff I am starting to add to Csound. Back in 2012 > when we started planning Cs 6, on my todo list was the request of adding a streaming > version of lpc to Csound. I had a look then, the code in lpanal did not look suitable for > that and I did not pursue it any further. > > Now, I have been looking again at lpc, and noticed a much, much better algorithm than > what we have in lpanal is described in Makhoul’s tutorial. So I decided to have a go at > programming it in C, after prototyping it in Python. This weekend I finally had some time > to write it. It seems to work well, and it opens up a possibility for a suite of lpc streaming > opcodes. I have two of them written as a proof of concept and will add more as time > permits. In particular I see two things as promising: (a) integration with fsigs; (b) using > arrays to hold lpc data. > > So, the opcodes I wrote are > > asig lpcfilter ain, kpos, kflag, ifn, iN, iM [, ifw] > > ain - input > kpos - read pos in samples > kflag - 1 -> compute new filter coefficients, 0 -> keep old coefficients > ifn - source table for linear prediction > iN - autocorrelation size (lpc input size) > iM - allpole filter order > ifw - optional window table > > asig lpcfilter ain, asrc, iN, iM [, ifw] > > same as above, except for > > asrc - source signal for linear prediction > > The main difference is that the second opcode computes new coefficients every M samples, > using the past N samples from the source signal. The first computes when asked, from > N samples taken from the table at pos kpos. > > Examples: > ========== > gifn ftgen 0,0,0,1,"fox.wav",0,0,1 > gifw ftgen 0,0,1024,20,2,1 > > instr 1 > k1 init 0 > kts = .75 // timescale > a1 diskin “beats.wav",1,0,1 > a3 lpcfilter a1/5,k1,1,gifn,1024,64,gifw > k1 += 64*kts > if k1 > ftlen(gifn) then > k1 = 0 > endif > out a3 > endin > > instr 2 > a1 diskin "fox.wav",1,0,1 > a2 diskin “beats.wav",1,0,1 > a3 lpcfilter a2/5,a1,1024,64,gifw > out a3 > endin > ======= > > The first instrument, reading from the table, is capable of timescale modifications (and other > tricks). > > These may undergo some small changes before release, and I’ll add more as time permits. > > best > ======================== > Prof. Victor Lazzarini > Maynooth University > Ireland > > > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2020-05-18 22:28 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] streaming linear prediction |
still adjusting things, but added now a lpcanal opcode outputting an array. ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 18 May 2020, at 20:14, joachim heintz |