Delay Effects
Date | 2016-04-13 12:43 |
From | Peter Burgess |
Subject | Delay Effects |
I'm struggling to make a delay effect that doesn't totally drain my resources. My curent UDO looks like this: opcode StereoDelay, aa, aaiii ainL, ainR, idelayTaps, idelayTime, idelayGain xin idelayTimes[] init idelayTaps idelayTapsLeft init idelayTaps idelayTapNum init 0 while (idelayTapsLeft > 0) do idelayTimes[idelayTapNum] = (idelayTime / idelayTaps) * (idelayTapNum + 1) idelayTapsLeft -= 1 idelayTapNum += 1 od adelayL = 0 adelayR = 0 idelayTapsLeft = idelayTaps idelayTapNum = 0 while (idelayTapsLeft > 0) do aL delay ainL, idelayTimes[idelayTapNum] aR delay ainR, idelayTimes[idelayTapNum] adelayL += aL adelayR += aR idelayTapsLeft -= 1 idelayTapNum += 1 od xout adelayL, adelayR endop for some reason, with only 3 or 4 delay taps, I can't seem to go beyond 1.5 seconds without using near maximum processor resources (on all 4 cores!) and I get underruns: WARNING: Buffer underrun in real-time audio output I get underuns whether I'm going through jack or alsa, and I have tried adjusting the buffer size. I also got exactly the same underruns when using the multiptap opcode. It's worth mentioning that I have some other processing going on, but the cores are all peaking at about 20% when I remove the delay lines. Is there a more CPU efficient way of setting up delays? Or is there something wrong with my code that's causing unnecessary processing? I feel like my pc should be able to handle this. I've used much worse computers than this and had projects in a DAW with bundles of fx running on multiple instruments at once Pete |
Date | 2016-04-13 15:50 |
From | jpff |
Subject | Re: Delay Effects |
Why are you using arrays here? Are the opcodes delay delay1 delayk delayr delayw deltap deltap3 deltapi deltapn deltapx deltapxw vdelay vdelay3 vdelayx vdelayxs vdelayxq vdelayxw vdelayxwq vdelayxws multitap insufficient? 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 | 2016-04-13 15:58 |
From | Peter Burgess |
Subject | Re: Delay Effects |
arrays of delay tap times and gains, so I can have any number of delay taps and I calculate them all on the init pass, and just access them during the performance loop. I'm not displeased with the amount of delay opcodes, but I can't work out why my setup is causing so much CPU drag. I've tried a number of different setups now, the current one must be completely wrong cos it's not producing any sound, haha! On Wed, Apr 13, 2016 at 3:50 PM, jpff |
Date | 2016-04-13 16:29 |
From | Rory Walsh |
Subject | Re: Delay Effects |
Your opcode doesn't run for me? I get nothing but silence? On 13 April 2016 at 12:43, Peter Burgess <pete.soundtechnician@gmail.com> wrote: I'm struggling to make a delay effect that doesn't totally drain my |
Date | 2016-04-13 16:35 |
From | Rory Walsh |
Subject | Re: Delay Effects |
Attachments | QUickTest.csd |
I have to make a few edits for it to work, mostly changed i variables to k. Anyhow, I am not getting any crazy spike in CPU. On my mac mini is runs less than 1%. On 13 April 2016 at 16:29, Rory Walsh <rorywalsh@ear.ie> wrote:
|
Date | 2016-04-13 17:28 |
From | Steven Yi |
Subject | Re: Delay Effects |
The original code looks to have a problem of using a stateful opcode within a loop. I wrote a little bit about this problem a long while ago in: http://csoundjournal.com/2006summer/controlFlow_part2.html (Section "Technical Information" just before the end) If you're going to use arrays to store parameters for multiple delays, you may want to use recursion and a UDO to do so. On Wed, Apr 13, 2016 at 11:35 AM, Rory Walsh |
Date | 2016-04-13 21:58 |
From | Iain McCurdy |
Subject | Re: Delay Effects |
You could use a single delayr / delayw pair and then create the taps within them using a recursive UDO. I have an instrument that does that to create up to 300 taps, which runs with no problem. > Date: Wed, 13 Apr 2016 15:58:27 +0100 > From: pete.soundtechnician@GMAIL.COM > Subject: Re: [Csnd] Delay Effects > To: CSOUND@LISTSERV.HEANET.IE > > arrays of delay tap times and gains, so I can have any number of delay > taps and I calculate them all on the init pass, and just access them > during the performance loop. > > I'm not displeased with the amount of delay opcodes, but I can't work > out why my setup is causing so much CPU drag. I've tried a number of > different setups now, the current one must be completely wrong cos > it's not producing any sound, haha! > > On Wed, Apr 13, 2016 at 3:50 PM, jpff <jpff@codemist.co.uk> wrote: > > Why are you using arrays here? Are the opcodes > > delay > > delay1 > > delayk > > delayr > > delayw > > deltap > > deltap3 > > deltapi > > deltapn > > deltapx > > deltapxw > > vdelay > > vdelay3 > > vdelayx > > vdelayxs > > vdelayxq > > vdelayxw > > vdelayxwq > > vdelayxws > > multitap > > > > insufficient? > > > > 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 > > > > -- > http://algorythmradio.com > https://soundcloud.com/algorythmradio > > 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 | 2016-04-14 12:08 |
From | Peter Burgess |
Subject | Re: Delay Effects |
You're right Rory, I discovered eventually as well that it wasn't actually making any sound, but couldn't figure out why. I'm seeing which variables you changed to k-rate.... I still struggle to work out how i and k rate variables work in loops. I guess then that I rate variables can be manipulated, so long as everything in the loop happens at i-time, is that correct? Your edited version of the UDO does make some sound, but still doesn't work as expected, but I'm guessing that's because of the issues highlighted by steven. Also, I realised I'd used the delay time all backwards. I am treating the delay time as the time untill the last delay tap, rather than the time between each delay tap. I've altered that now aswell. Thanks for the link Steven! So, if I've understood that correctly, my multiple delay instances inside the loop won't be multiple instances at all, so each pass through the loop, the same delay instance will just be overwritten with new data. Iain: I am routing through your examples now. I had had a look at a few from your site already, but decided in the end I could figure it out by myself. Guess I was wrong, haha! Thanks all for your help! Pete On Wed, Apr 13, 2016 at 9:58 PM, Iain McCurdy |
Date | 2016-04-14 12:27 |
From | Rory Walsh |
Subject | Re: Delay Effects |
Correct. |
Date | 2016-04-14 16:42 |
From | Beinan Li |
Subject | Re: Delay Effects |
Hi Steven,
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
Is there a full list of "stateful opcode" somewhere in the manuals? or is there a thorough discussion about do's and don'ts in Csound loops? It will help newbies tremendously, especially who are used to loops in other programming languages like myself. I had similar problems with the OP when implementing filter banks. The general advice I got from someone on the list was that it's in general a bad idea to use while loop in Csound. It may not be what he literally said, but I think the spirit was that. I'm sure whoever said that while loops are taboos. But it sends the message: extreme precautions are needed. It would be great if there is a recipe for batch calling opcodes, like filter banks. So far the way I came up with was to generate that sort of code from another language. Thanks, Beinan On Wed, Apr 13, 2016 at 12:28 PM, Steven Yi <stevenyi@gmail.com> wrote: The original code looks to have a problem of using a stateful opcode |
Date | 2016-04-14 16:48 |
From | "Dr. Richard Boulanger" |
Subject | Re: Delay Effects |
Iain, Which of your instruments is the 300 tap recursive delay? Would love to check it out and show it off in class. -dB On Wed, Apr 13, 2016 at 4:58 PM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
_____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ 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/richardboulanger/ 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 |
Date | 2016-04-14 17:02 |
From | Steven Yi |
Subject | Re: Delay Effects |
Hi Beinan, There is no list of stateful opcodes that I know of. In general, I use loops when doing very low-level code that primarily deals with math operations, such as when implementing a filter or envelope generator. Anything higher-level -- such as pre-made filters and oscillators -- are likely to have state. As mentioned in the posted article, if you want to do bank-like operations, you should currently use recursion and UDOs in Csound. If you are working in other programming languages and used loops as well as developed a processing network of objects similarly to how Csound operates, you would run in the same problem. For example, if you had classes called Filter and AudioSignal, imagine this: AudioSignal output; AudioSignal inputs[16]; Filter f = new Filter(); for (int i =0; i < 16; i++) { output += f.process(inputs[i]); } You would have a problem as most filters have state. The single filter instance will depend upon the state of the last run, but then it is being used with multiple signals, not the previous filtering of the same signal. If instead you had: AudioSignal output; AudioSignal inputs[16]; Filter f[16]; for (int i =0; i < 16; i++) { output += f[i].process(inputs[i]); } You would be okay. I think with the Csound language, people think when using a loop they are doing the latter example, but it's really more like the first example. When using a recursive UDO, you are getting a new filter opcode instance per step of the recursion. That is is the important part as to why that works when loops do not. Loops shouldn't be considered taboo in any way, but they do require caution. As mentioned before, I use loops to implement filters and envelope generators in UDO code. Usually in these cases, one is calculating on a sample-by-sample basis, and one has to have state information from the previous sample calculation to generate the next sample. These things are often not efficient, easy, nor possible to calculate using only vector operations (i.e., opcodes that process a block of samples at a time). In these cases, I think loops are very appropriate. Hope that helps! steven On Thu, Apr 14, 2016 at 11:42 AM, Beinan Li |
Date | 2016-04-14 19:54 |
From | Beinan Li |
Subject | Re: Delay Effects |
Correction: I'm sure whoever said that while loops are taboos. => I'm sure whoever said that was not saying while loops are taboos Thanks, Beinan On Thu, Apr 14, 2016 at 11:42 AM, Beinan Li <li.beinan@gmail.com> wrote:
|
Date | 2016-04-15 00:46 |
From | Beinan Li |
Subject | Re: Delay Effects |
Thank you very much, Steven! This is very helpful. Clearly I was going after your second example. If only there were a magic compiler that could turn the second into the first, although I know it must be difficult. Thanks, Beinan On Thu, Apr 14, 2016 at 12:02 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Beinan, |
Date | 2016-04-15 08:09 |
From | Iain McCurdy |
Subject | Re: Delay Effects |
Hi Richard, It's this one: If you activate the filter you might not get to 300. 300 x moogvcf! bye, Iain Date: Thu, 14 Apr 2016 11:48:03 -0400 From: rboulanger@BERKLEE.EDU Subject: Re: [Csnd] Delay Effects To: CSOUND@LISTSERV.HEANET.IE Iain, Which of your instruments is the 300 tap recursive delay? Would love to check it out and show it off in class. -dB On Wed, Apr 13, 2016 at 4:58 PM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
_____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ 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/richardboulanger/ 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 |
Date | 2016-04-15 11:57 |
From | "Dr. Richard Boulanger" |
Subject | Re: Delay Effects |
Thanks Iain, Another wonderful instrument. WOW. Love it. Will show in class next week for sure. We were just covering filters and reverb in my DSP class. This will be a very inspiring example. This year and in the future! -R On Fri, Apr 15, 2016 at 3:09 AM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
_____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ 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/richardboulanger/ 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 |