I’ve never used these opcodes, the error message I get running:
instr 1
kIn line 0, p3, 1
kCmplx[] r2c kIn
endin
gives me a type error message
error: Unable to find opcode entry for ‘r2c’ with matching argument types:
Found: k[] r2c k
kCmplx r2c kIn …
Line: 11
from file string (1),Parsing failed due to syntax errors
my best guess is that it only works in combination with fft opcodes. But if that’s the case, then the error message is bit misleading?
I have been attempting to reverse engineer the Nasca O. Paul’s padsynth algorithm with primitive csound operators, to get a better sense of the algorithm and the math behind it.
I’m currently stuck at understanding one thing in the c code and how I would convert it to csound.
It goes a bit into understanding trigonometry, in that cartesian x,y on a unit circle seem to be expressable in polar format with real and imaginary component.
Which format is expected in the fftinv,rifft is not properly documented, the examples all seem to use signals that have 0s in their imaginary indices (the odd numbered indices).
So I can’t tell if it’s supposed to be an imaginary number as radian from 0 → 2PI or some other unit?
So the padsynth algorithm uses an operator from libfftw
tmpfftdata1=new fftw_real[fftsize];
tmpfftdata2=new fftw_real[fftsize];
for (int i=0;i<fftsize/2;i++) {
tmpfftdata1[i]=freqs.c[i];
if (i!=0) tmpfftdata1[fftsize-i]=freqs.s[i];
};
rfftw_one(planfftw_inv,tmpfftdata1,tmpfftdata2);
fftw_execute(planfftw_inv);
So my question is, can I achieve the same operation using fftinv opcode, passing it a k-rate array of
k[n] = freq_amp[i]*cos(freq_phase[i]);
k[n + 1] = freq_amp[i]*sin(freq_phase[i]);
?
Or would I need to convert the units to some other format?
Sorry for repost, I noticed that I replied to the forum, I need to fix that
I have been attempting to reverse engineer the Nasca O. Paul’s padsynth algorithm with primitive csound operators, to get a better sense of the algorithm and the math behind it.
I’m currently stuck at understanding one thing in the c code and how I would convert it to csound.
It goes a bit into understanding trigonometry, in that cartesian x,y on a unit circle seem to be expressable in polar format with real and imaginary component.
Which format is expected in the fftinv,rifft is not properly documented, the examples all seem to use signals that have 0s in their imaginary indices (the odd numbered indices).
So I can’t tell if it’s supposed to be an imaginary number as radian from 0 → 2PI or some other unit?
So the padsynth algorithm uses an operator from libfftw
tmpfftdata1=new fftw_real[fftsize];
tmpfftdata2=new fftw_real[fftsize];
for (int i=0;i<fftsize/2;i++) {
tmpfftdata1[i]=freqs.c[i];
if (i!=0) tmpfftdata1[fftsize-i]=freqs.s[i];
};
rfftw_one(planfftw_inv,tmpfftdata1,tmpfftdata2);
fftw_execute(planfftw_inv);
So my question is, can I achieve the same operation using fftinv opcode, passing it a k-rate array of
k[n] = freq_amp[i]*cos(freq_phase[i]);
k[n + 1] = freq_amp[i]*sin(freq_phase[i]);
?
Or would I need to convert the units to some other format?
I notice that these opcodes are explained well in the book Csound: A sound and music computin system, at chapter 14.4 where the opcodes mags and phs is used to converts cosine and sine to magnitude and phases. I can see better now how it relates. Perhaps I’ll figure this out, so nevermind that question.