writing a delay~


    Nov 27 2006 | 8:25 am
    Hello,
    Googling, searching the archives, reading undocumented code, asking in the street didn't help, so if you have secrets informations on how to build a multi-tap MSP delay external with feedback...
    best
    f.e -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|

    • Nov 27 2006 | 9:44 am
      On 27-Nov-2006, at 9:25, f.e wrote: > Googling, searching the archives, reading undocumented code, asking > in the street didn't help, so if you have secrets informations on > how to build a multi-tap MSP delay external with feedback...
      The core of any delay object will be a ring buffer, which is a standard computer engineering technique. A multi-tap delay is just a ring buffer with one write pointer and several read pointers.
      If you have a book on programming and data structures, it will explain how to build these.
      Book suggestions? I cut my teeth with the Wirth "Algorithms + Data Structures = Programs", which is old but still solid (if you can find a copy).
      HtH -- Peter
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de
    • Nov 29 2006 | 7:44 am
      Thanks Peter.
      Next time i'll call my topic "Re: [dev] get path as char * from path_getdefault()?", maybe i'll have better chance to get other answers.
      Not to be boring, but there are only 7 examples in MSP dev folder...
      f.e
      Peter Castine wrote: > On 27-Nov-2006, at 9:25, f.e wrote: >> Googling, searching the archives, reading undocumented code, asking >> in the street didn't help, so if you have secrets informations on how >> to build a multi-tap MSP delay external with feedback... > > The core of any delay object will be a ring buffer, which is a > standard computer engineering technique. A multi-tap delay is just a > ring buffer with one write pointer and several read pointers. > > If you have a book on programming and data structures, it will explain > how to build these. > > Book suggestions? I cut my teeth with the Wirth "Algorithms + Data > Structures = Programs", which is old but still solid (if you can find > a copy). > > HtH -- Peter > > -------------- http://www.bek.no/~pcastine/Litter/ ------------- > Peter Castine +--> Litter Power & Litter Bundle for Jitter > Universal Binaries on the way > iCE: Sequencing, Recording & > Interface Building for |home | chez nous| > Max/MSP Extremely cool |bei uns | i nostri| > http://www.dspaudio.com/ http://www.castine.de > > >
      -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
    • Nov 29 2006 | 6:54 pm
      You're missing the point. The other question was a very concise question about a particular technical detail. Your question was a broad design question, and now you're begging for sample code.
      This is your project, not Peter's. You've got a whole bunch of questions to answer for yourself: how long do you want to max out the delay? How will the feedback work? (Will multiple tap-outputs be feeding back? Will you need to delay for less than a sample vector? Are all of the tap out's moving at the same speed?
      I would rather see you get a bit of help than witness the flame war you're starting, so here's some pseudocode. Assuming you want a buffer of 8192 samples, 3 tap-delays, at say 1024, 2048 and 4096 delayed samples respectively:
      int tapDelays[] = {1024, 2048, 4096}; int bufferInput = 0; float* buffer; int bufferLength = 8192;
      ...
      buffer = malloc(bufferLength * sizeof(float));
      float* input (assume it's made for you) float* output (assume it's made for you) int inputLength; int curInput = 0;
      for(; curInput < inputLength; curInput++) { int i; /*save the input sample in the delay buffer*/ buffer[bufferInput] = input[curInput]; /* initialize the output sample as the accumulator for the tap-outs*/ output[curInput] = 0; for(i = 0; i < sizeof(tapDelays); i++) { /*accumulate the tapouts*/ output[curInput] += buffer[ (bufferInput - tapDelays[i]) % bufferLength]; } bufferInput++; }
      Pretty simple.. You wrap your bufferIndexes around to make sure you're always indexing into the buffer. I'm sure there are problems with that... you need to make sure modulo returns 0->bufferLength when the input is negative for example, and you need to initialize your delayBuffer to zero's. Hopefully the "ring buffer" makes a bit more sense with a little code though.
      Please be nice.
      _Mark
      On Nov 28, 2006, at 11:44 PM, f.e wrote:
      > Thanks Peter. > > Next time i'll call my topic "Re: [dev] get path as char * from > path_getdefault()?", maybe i'll have better chance to get other > answers. > > Not to be boring, but there are only 7 examples in MSP dev folder... > > f.e > > Peter Castine wrote: >> On 27-Nov-2006, at 9:25, f.e wrote: >>> Googling, searching the archives, reading undocumented code, >>> asking in the street didn't help, so if you have secrets >>> informations on how to build a multi-tap MSP delay external with >>> feedback... >> >> The core of any delay object will be a ring buffer, which is a >> standard computer engineering technique. A multi-tap delay is just >> a ring buffer with one write pointer and several read pointers. >> >> If you have a book on programming and data structures, it will >> explain how to build these. >> >> Book suggestions? I cut my teeth with the Wirth "Algorithms + Data >> Structures = Programs", which is old but still solid (if you can >> find a copy). >> >> HtH -- Peter >> >> -------------- http://www.bek.no/~pcastine/Litter/ >> ------------- >> Peter Castine +--> Litter Power & Litter Bundle for >> Jitter >> Universal Binaries on the way >> iCE: Sequencing, Recording & >> Interface Building for |home | chez >> nous| >> Max/MSP Extremely cool |bei uns | i >> nostri| >> http://www.dspaudio.com/ http:// >> www.castine.de >> >> >> > > -- > f.e chanfrault | aka | personal computer music >> >>>>>> http://www.personal-computer-music.com >> >>>>>> |sublime music for a desperate people|
    • Nov 29 2006 | 8:09 pm
      Hey hey hey, dear Mark, i'm not flaming anything or anybody. I really like Peter very very much and the reference to the other topic was a joke. And i'm not begging at all (which is a word, if translated to french, that makes me very very angry). I just say : there are 7 examples in the msp dev folder with no informations on *a lot* of things. And i'm scratching my head since days, reading a lot of articles on, virtually, how to achieve a multitap boucing delay in C. I will be pleased if you could notice that i'm *far* to be stingy about my code here (and the time it takes for), so i think you tactlessly miss the point with your 'be nice now". Anyway, i really thank you for your code (which looks very helpfull) even if you made me angry too much to read it now.
      f.e
      Mark Pauley wrote: > You're missing the point. The other question was a very concise > question about a particular technical detail. Your question was a > broad design question, and now you're begging for sample code. > > This is your project, not Peter's. You've got a whole bunch of > questions to answer for yourself: how long do you want to max out the > delay? How will the feedback work? (Will multiple tap-outputs be > feeding back? Will you need to delay for less than a sample vector? > Are all of the tap out's moving at the same speed? > > I would rather see you get a bit of help than witness the flame war > you're starting, so here's some pseudocode. > Assuming you want a buffer of 8192 samples, 3 tap-delays, at say 1024, > 2048 and 4096 delayed samples respectively: > > int tapDelays[] = {1024, 2048, 4096}; > int bufferInput = 0; > float* buffer; > int bufferLength = 8192; > > ... > > > buffer = malloc(bufferLength * sizeof(float)); > > > float* input (assume it's made for you) > float* output (assume it's made for you) > int inputLength; > int curInput = 0; > > for(; curInput < inputLength; curInput++) { > int i; > /*save the input sample in the delay buffer*/ > buffer[bufferInput] = input[curInput]; > /* initialize the output sample as the accumulator for the tap-outs*/ > output[curInput] = 0; > for(i = 0; i < sizeof(tapDelays); i++) { > /*accumulate the tapouts*/ > output[curInput] += buffer[ (bufferInput - tapDelays[i]) % > bufferLength]; > } > bufferInput++; > } > > Pretty simple.. You wrap your bufferIndexes around to make sure > you're always indexing into the buffer. > I'm sure there are problems with that... you need to make sure modulo > returns 0->bufferLength when the input is negative for example, and > you need to initialize your delayBuffer to zero's. > Hopefully the "ring buffer" makes a bit more sense with a little code > though. > > Please be nice. > > _Mark > > On Nov 28, 2006, at 11:44 PM, f.e wrote: > >> Thanks Peter. >> >> Next time i'll call my topic "Re: [dev] get path as char * from >> path_getdefault()?", maybe i'll have better chance to get other answers. >> >> Not to be boring, but there are only 7 examples in MSP dev folder... >> >> f.e >> >> Peter Castine wrote: >>> On 27-Nov-2006, at 9:25, f.e wrote: >>>> Googling, searching the archives, reading undocumented code, asking >>>> in the street didn't help, so if you have secrets informations on >>>> how to build a multi-tap MSP delay external with feedback... >>> >>> The core of any delay object will be a ring buffer, which is a >>> standard computer engineering technique. A multi-tap delay is just a >>> ring buffer with one write pointer and several read pointers. >>> >>> If you have a book on programming and data structures, it will >>> explain how to build these. >>> >>> Book suggestions? I cut my teeth with the Wirth "Algorithms + Data >>> Structures = Programs", which is old but still solid (if you can >>> find a copy). >>> >>> HtH -- Peter >>> >>> -------------- http://www.bek.no/~pcastine/Litter/ ------------- >>> Peter Castine +--> Litter Power & Litter Bundle for Jitter >>> Universal Binaries on the way >>> iCE: Sequencing, Recording & >>> Interface Building for |home | chez nous| >>> Max/MSP Extremely cool |bei uns | i nostri| >>> http://www.dspaudio.com/ http://www.castine.de >>> >>> >>> >> >> --f.e chanfrault | aka | personal computer music >>> >>>>>> http://www.personal-computer-music.com >>> >>>>>> |sublime music for a desperate people| > >
      -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
    • Nov 29 2006 | 10:31 pm
      On Nov 29, 2006, at 12:09 PM, f.e wrote:
      > I just say : there are 7 examples in the msp dev folder with no > informations on *a lot* of things.
      Sorry, but it's out of the scope of our SDK to document how to program DSP.
      > And i'm scratching my head since days, reading a lot of articles > on, virtually, how to achieve a multitap boucing delay in C.
      You're doing exactly the appropriate thing. It takes time to learn how to program DSP. It will take many more days. Don't get discouraged. Take a walk away from the computer when you reach points of extreme frustration, and then come back and read and work more.
      "multitap delay"
      -Joshua
    • Nov 30 2006 | 1:20 am
      > Take a walk away from the computer when you reach points of extreme > frustration, and then come back and read and work more.
      If I had a nickel for every time I "knew it absolutely had to work", or "my code is good, it must be the library / computer's fault"... The walk to get a glass of water solves more problems than my brain does sometimes.
      _Mark
    • Nov 30 2006 | 1:42 am
      On Nov 29, 2006, at 5:20 PM, Mark Pauley wrote:
      > If I had a nickel for every time I "knew it absolutely had to > work", or "my code is good, it must be the library / computer's > fault"... > The walk to get a glass of water solves more problems than my brain > does sometimes.
      Reminds me of Isaac Asimov's essay "The Eureka Phenomenon". Unfortunately couldn't find the original online, but it's in a few collections.
      -Joshua