[Csnd] return imaginary part from an array of complex numbers
Date | 2018-10-02 12:05 |
From | Mauro Giubileo |
Subject | [Csnd] return imaginary part from an array of complex numbers |
Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that? Best Regards, |
Date | 2018-10-02 12:15 |
From | Anders Genell |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it? Regards, Anders
|
Date | 2018-10-02 14:17 |
From | Mauro Giubileo |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Mmmh... I think it's doable, but I hoped for something much simpler and rapid like: kRe[] c2r kComplexArray ; c2r exists :-) Or maybe, in just one opcode: kRe[], kIm[] c2ri kComplexArray I think I can make an UDO that does that, but it woud be nice if it was a native opcode. Regards, Il 2018-10-02 13:15 Anders Genell ha scritto:
|
Date | 2018-10-02 15:43 |
From | Victor Lazzarini |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
That’s easily done. But more generally we should have an interleave/deinterleave pair to do this. For all uses. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 2 Oct 2018, at 14:17, Mauro Giubileo |
Date | 2018-10-02 15:51 |
From | Anders Genell |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode. But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature... kPhs[] phs kComplexArray kMags[] mags kComplexArray kImag[] = kMags * sin(kPhs) Regards, Anders On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:
|
Date | 2018-10-02 19:19 |
From | Mauro Giubileo |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Something like: kCmplx[] ri2c kRe[], kIm[] ; real and imaginary arrays -> interleaved array Regards, Il 2018-10-02 16:43 Victor Lazzarini ha scritto:
|
Date | 2018-10-02 19:35 |
From | Mauro Giubileo |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
No, there is no need for the [] in the right side of the expression. Your code might work but 'mags' and 'phs' opcodes require the complex array to be in a particular format returned by the rfft opcode. Regards, Il 2018-10-02 16:51 Anders Genell ha scritto:
|
Date | 2018-10-02 19:49 |
From | Anders Genell |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Ah. I didn’t realize there was a particular format... Does Csound handle any other kind of complex number format? Regards, Anders
|
Date | 2018-10-03 09:01 |
From | Victor Lazzarini |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
The interleave and deinterleave opcodes are up in git now k/ivar[] interleave k/ivar1[],k/ivar2[] k/ivar1[], k/ivar2[] deinterleave k/ivar[] ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 2 Oct 2018, at 19:49, Anders Genell |
Date | 2018-10-03 11:07 |
From | Mauro Giubileo |
Subject | Re: [Csnd] return imaginary part from an array of complex numbers |
Very nice, thanks! :-) Regards, Il 2018-10-03 10:01 Victor Lazzarini ha scritto:
|