SynthMaker

Why doesn't this circular convolution work? help with DSP!

Archive · 2007 7 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

lapleca ·

Hi!

Please, I need help to do the circular convolution. I have done a DSP module where I try to do the convolution between a signal with 44100 samples and another signal with 512, but it doesn't work...I am desperated. what's wrong in this code?

streamin in; streamin coef; streamout out; float memcoefs[512]; // coefficient data float memin[44100]; // buffer float i,j,k; float suma; float index; loop(512)// Put coefficients { memcoefs[index]=coef; index=index+1; } stage(1) { memin[k] = in; //put input sample into buffer suma = 0; i = 0; j=0; loop(512) { suma = suma + memin[i]*memcoefs[j]; i=i+1; j=j+1; } out = suma; k=k+1; }

I know that my knowledge of DSP is very poor... I think my main problem with the convolution is do the buffers for operate, with both signals, I think that the signal don't pass through the buffer. I hope you understand me, my english is very poor too.. Thank you very much..If you could tell me something about this, I would be very grateful..

Another thing: I vote to the creation of a convolution module!!!

lapleca

rl ·

lapleca wrote: what's wrong in this code?

... streamin coef; ... float memcoefs[512]; // coefficient data ... loop(512)// Put coefficients { memcoefs[index]=coef; index=index+1; }

I think that's the problem. You have a streamin coef statement. That means one value of coeff per cycle of the code module. You can't read in all coeffs in one loop.

You would either need 512 streamin statements (resulting in 512 connectors 🙁 ) to have all coefficients available at once or you could read them sample by sample resulting in 512 samples extra-latency.

This is a limitation to the code module. A nice feature add would be an array input. Like:

memin coeff [512];

where a Mem or Mem Array could be connected.

Malc, Jorge?

As a workaround you could build the schematic without the code module until you run out of cables 😉

stefan ·

Or you could spend the first 512 samples worth of audio time for filling the array by feeding it sample by sample to the code component. Would bloat the code a fair bit, but should work 🙂

lapleca ·

Thank you very much guys!

Following the advise of rl, I have removed the loop (512) for storing the coefs (before stage(1)), and I put the buffer of coefs in the stage (1), I but it doesn't work. and Stefan, what do you mean with "you could spend the first 512 samples worth of audio time for filling the array"? I mean, what array? because I think that an array can't be an entry of a code module.. Well, this is the new code, I don't know if you suggest something like this..

streamin in; streamin coef; streamout out; float memcoefs[512]; // coefficient data float memin[44100]; // buffer float i,j,k; float suma; float index;

stage(1) { memin[k] = in; //put input sample into buffer memcoefs[index]=coef; suma = 0; i = 0; j=0; loop(512) { suma = suma + memin[i]*memcoefs[j]; i=i+1; j=j+1; } out = suma; k=k+1; index=index+1; }

I think that the problem in general is in buffers, because I need that one buffer stores the first 512 samples of the signal of 44100 samples, and after, this buffer stores the samples 2 until 513, and then 3 until 514, etc..I mean, like in a loop.. So I need 2 buffers, one of them, for filling the signal of 44100 samples, and get pieces of 512, and the other buffer for stores the 512 coefs.

I have try to do this without code module, but I don't know how exactly I can do a buffer with other modules..I am trying with MemCreate, and then WriteMem..in this sense If you know some way for creating a buffer with modules..I am proving too with this. Thank you again!

lapleca [/img]

BasherT ·

I've been struggling with something similar as part of an attempt to create a beat detection module.

I found thisonline and have been thinking about how to implement the first technique suggested which involves comparing the average "energy" of 44100 samples with the average energy of the first 1024 samples within that 44100 samples.

Once I have loaded a Wav file into memory I have been unable to figure out how to fill a buffer with 44100 samples. Any suggestions bearing in mind that the beat detection does not have to be done in real time?

stefan ·

lapleca wrote: and Stefan, what do you mean with "you could spend the first 512 samples worth of audio time for filling the array"? I mean, what array? because I think that an array can't be an entry of a code module..

I meant something that would work kindof like this (pseudo-code): streamin arrayInput; i = 0; if ( i < 512 ) array[i] = arrayInput; else [doConvolutionStuff]

i = i + 1;

So arrayInput would get it's values from outside of this component, one value at a time during the first 512 rendered samples.

Now, I don't think this is a GOOD solution, but it could work in some scenarios.

ronaldpassion ·

i am also waiting this convolution things... still doesnt find the right source...

help help..

THanx

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.