Csound Csound-dev Csound-tekno Search About

Array question

Date2016-01-31 23:26
FromGleb
SubjectArray question
Dear list!

I'd like to get only imaginary part of fft array doing that in
overlap-and-add fashion:






sr=44100
;ksmps needs to be an integer div of hopsize 
ksmps = 64
0dbfs = 1.0
nchnls = 2

instr 1
 ihopsize = 256   ; hopsize
 ifftsize = 1024  ; FFT size 
 iolaps = ifftsize/ihopsize ; overlaps
 kcnt init 0    ; counting vars
 krow init 0
 kOla[] init ifftsize ; overlap-add buffer
 kIn[] init ifftsize  ; input buffer
 kOut[][] init iolaps, ifftsize ; output buffers
 kSlice[] init ifftsize*2
 kRow[] init ifftsize
 kRow1[] init ifftsize

 a1	oscil .5, 440
 /* every hopsize samples */
 if kcnt == ihopsize then  
   /* window and take FFT */
   kWin[] window kIn,krow*ihopsize
   kWinCp[] r2c kWin
   kSpec[] fft kWinCp
  
 /* HILBERT */
        kSlice[] slicearray kSpec, 0, ifftsize-1
  	kSlice2[]=kSlice*2
	kSlice2[0]=kSlice[0]
	kSlice2[1]=kSlice[1]
	kSlice2[ifftsize]=kSpec[ifftsize]
	kSlice2[ifftsize+1]=kSpec[ifftsize+1]
   /* IFFT + window */
   kRowCp[] fftinv kSlice2

   ; SOMETHING IS WRONG HERE (:
	kind = 0
   	until kind==ifftsize do
		kRow[kind]=kRowCp[2*kind+1]
		kind += 1
	od
 
   kWin window kRow, krow*ihopsize
   /* place it on out buffer */
   kOut setrow kWin, krow
   /* zero the ola buffer */
   kOla = 0
   /* overlap-add */
   ki = 0
   until ki == iolaps do
     kRow getrow kOut, ki
     kOla = kOla + kRow
     ki += 1
   od

   /* update counters */ 
  krow = (krow+1)%iolaps
  kcnt = 0
 endif

 /* shift audio in/out of buffers */
 kIn shiftin a1
 a2 shiftout kOla
    out a2/iolaps

 /* increment counter */
 kcnt += ksmps
endin



f1 0 2048 -10 0
i1 0 10



The line 
kRow[kind]=kRowCp[2*kind+1]
shows error @ = k

Everything works fine except that part. I just want to get the odd elements
of array, it should be the signal in quadrature.

Thank you!






-----
Gleb Rogozinsky, PhD
Associated Professor
Interactive Arts Department
Saint-Petersburg University of Film and Television

Deputy Director of Medialab
Saint-Petersburg University of Telecommunications
--
View this message in context: http://csound.1045644.n5.nabble.com/Csnd-Array-question-tp5746829.html
Sent from the Csound - General mailing list archive at Nabble.com.

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

Date2016-01-31 23:30
FromSteven Yi
SubjectRe: Array question
Hi Gleb,

I ran your CSD here and it seemed to get stuck somewhere, but I did
not get any compilation errors like @=k.  I am using a recent version
compiled from git though.  What version of Csound and platform are you
using?

steven

On Sun, Jan 31, 2016 at 6:26 PM, Gleb  wrote:
> Dear list!
>
> I'd like to get only imaginary part of fft array doing that in
> overlap-and-add fashion:
>
> 
> 
> 
> 
>
> sr=44100
> ;ksmps needs to be an integer div of hopsize
> ksmps = 64
> 0dbfs = 1.0
> nchnls = 2
>
> instr 1
>  ihopsize = 256   ; hopsize
>  ifftsize = 1024  ; FFT size
>  iolaps = ifftsize/ihopsize ; overlaps
>  kcnt init 0    ; counting vars
>  krow init 0
>  kOla[] init ifftsize ; overlap-add buffer
>  kIn[] init ifftsize  ; input buffer
>  kOut[][] init iolaps, ifftsize ; output buffers
>  kSlice[] init ifftsize*2
>  kRow[] init ifftsize
>  kRow1[] init ifftsize
>
>  a1     oscil .5, 440
>  /* every hopsize samples */
>  if kcnt == ihopsize then
>    /* window and take FFT */
>    kWin[] window kIn,krow*ihopsize
>    kWinCp[] r2c kWin
>    kSpec[] fft kWinCp
>
>  /* HILBERT */
>         kSlice[] slicearray kSpec, 0, ifftsize-1
>         kSlice2[]=kSlice*2
>         kSlice2[0]=kSlice[0]
>         kSlice2[1]=kSlice[1]
>         kSlice2[ifftsize]=kSpec[ifftsize]
>         kSlice2[ifftsize+1]=kSpec[ifftsize+1]
>    /* IFFT + window */
>    kRowCp[] fftinv kSlice2
>
>    ; SOMETHING IS WRONG HERE (:
>         kind = 0
>         until kind==ifftsize do
>                 kRow[kind]=kRowCp[2*kind+1]
>                 kind += 1
>         od
>
>    kWin window kRow, krow*ihopsize
>    /* place it on out buffer */
>    kOut setrow kWin, krow
>    /* zero the ola buffer */
>    kOla = 0
>    /* overlap-add */
>    ki = 0
>    until ki == iolaps do
>      kRow getrow kOut, ki
>      kOla = kOla + kRow
>      ki += 1
>    od
>
>    /* update counters */
>   krow = (krow+1)%iolaps
>   kcnt = 0
>  endif
>
>  /* shift audio in/out of buffers */
>  kIn shiftin a1
>  a2 shiftout kOla
>     out a2/iolaps
>
>  /* increment counter */
>  kcnt += ksmps
> endin
>
> 
> 
> f1 0 2048 -10 0
> i1 0 10
> 
>
>
> The line
> kRow[kind]=kRowCp[2*kind+1]
> shows error @ = k
>
> Everything works fine except that part. I just want to get the odd elements
> of array, it should be the signal in quadrature.
>
> Thank you!
>
>
>
>
>
>
> -----
> Gleb Rogozinsky, PhD
> Associated Professor
> Interactive Arts Department
> Saint-Petersburg University of Film and Television
>
> Deputy Director of Medialab
> Saint-Petersburg University of Telecommunications
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Csnd-Array-question-tp5746829.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> 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

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

Date2016-01-31 23:45
FromGleb Rogozinsky
SubjectRe: Array question
Hi Steven,

I am on Win 7 64bit, doing this things in Cabbage which runs 6.05.

понедельник, 1 февраля 2016 г. пользователь Steven Yi написал:
Hi Gleb,

I ran your CSD here and it seemed to get stuck somewhere, but I did
not get any compilation errors like @=k.  I am using a recent version
compiled from git though.  What version of Csound and platform are you
using?

steven

On Sun, Jan 31, 2016 at 6:26 PM, Gleb <gleb.rogozinsky@gmail.com> wrote:
> Dear list!
>
> I'd like to get only imaginary part of fft array doing that in
> overlap-and-add fashion:
>
> <CsoundSynthesizer>
> <CsOptions>
> </CsOptions>
> <CsInstruments>
>
> sr=44100
> ;ksmps needs to be an integer div of hopsize
> ksmps = 64
> 0dbfs = 1.0
> nchnls = 2
>
> instr 1
>  ihopsize = 256   ; hopsize
>  ifftsize = 1024  ; FFT size
>  iolaps = ifftsize/ihopsize ; overlaps
>  kcnt init 0    ; counting vars
>  krow init 0
>  kOla[] init ifftsize ; overlap-add buffer
>  kIn[] init ifftsize  ; input buffer
>  kOut[][] init iolaps, ifftsize ; output buffers
>  kSlice[] init ifftsize*2
>  kRow[] init ifftsize
>  kRow1[] init ifftsize
>
>  a1     oscil .5, 440
>  /* every hopsize samples */
>  if kcnt == ihopsize then
>    /* window and take FFT */
>    kWin[] window kIn,krow*ihopsize
>    kWinCp[] r2c kWin
>    kSpec[] fft kWinCp
>
>  /* HILBERT */
>         kSlice[] slicearray kSpec, 0, ifftsize-1
>         kSlice2[]=kSlice*2
>         kSlice2[0]=kSlice[0]
>         kSlice2[1]=kSlice[1]
>         kSlice2[ifftsize]=kSpec[ifftsize]
>         kSlice2[ifftsize+1]=kSpec[ifftsize+1]
>    /* IFFT + window */
>    kRowCp[] fftinv kSlice2
>
>    ; SOMETHING IS WRONG HERE (:
>         kind = 0
>         until kind==ifftsize do
>                 kRow[kind]=kRowCp[2*kind+1]
>                 kind += 1
>         od
>
>    kWin window kRow, krow*ihopsize
>    /* place it on out buffer */
>    kOut setrow kWin, krow
>    /* zero the ola buffer */
>    kOla = 0
>    /* overlap-add */
>    ki = 0
>    until ki == iolaps do
>      kRow getrow kOut, ki
>      kOla = kOla + kRow
>      ki += 1
>    od
>
>    /* update counters */
>   krow = (krow+1)%iolaps
>   kcnt = 0
>  endif
>
>  /* shift audio in/out of buffers */
>  kIn shiftin a1
>  a2 shiftout kOla
>     out a2/iolaps
>
>  /* increment counter */
>  kcnt += ksmps
> endin
>
> </CsInstruments>
> <CsScore>
> f1 0 2048 -10 0
> i1 0 10
> </CsScore>
>
>
> The line
> kRow[kind]=kRowCp[2*kind+1]
> shows error @ = k
>
> Everything works fine except that part. I just want to get the odd elements
> of array, it should be the signal in quadrature.
>
> Thank you!
>
>
>
>
>
>
> -----
> Gleb Rogozinsky, PhD
> Associated Professor
> Interactive Arts Department
> Saint-Petersburg University of Film and Television
>
> Deputy Director of Medialab
> Saint-Petersburg University of Telecommunications
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Csnd-Array-question-tp5746829.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> 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

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
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

Date2016-01-31 23:51
FromSteven Yi
SubjectRe: Array question
Maybe the problem you are experiencing was fixed in 6.06 or since
then? Could you try running it with Michael's last released (I think
he labelled it 6.07-beta)?

On Sun, Jan 31, 2016 at 6:45 PM, Gleb Rogozinsky
 wrote:
> Hi Steven,
>
> I am on Win 7 64bit, doing this things in Cabbage which runs 6.05.
>
> понедельник, 1 февраля 2016 г. пользователь Steven Yi написал:
>
>> Hi Gleb,
>>
>> I ran your CSD here and it seemed to get stuck somewhere, but I did
>> not get any compilation errors like @=k.  I am using a recent version
>> compiled from git though.  What version of Csound and platform are you
>> using?
>>
>> steven
>>
>> On Sun, Jan 31, 2016 at 6:26 PM, Gleb  wrote:
>> > Dear list!
>> >
>> > I'd like to get only imaginary part of fft array doing that in
>> > overlap-and-add fashion:
>> >
>> > 
>> > 
>> > 
>> > 
>> >
>> > sr=44100
>> > ;ksmps needs to be an integer div of hopsize
>> > ksmps = 64
>> > 0dbfs = 1.0
>> > nchnls = 2
>> >
>> > instr 1
>> >  ihopsize = 256   ; hopsize
>> >  ifftsize = 1024  ; FFT size
>> >  iolaps = ifftsize/ihopsize ; overlaps
>> >  kcnt init 0    ; counting vars
>> >  krow init 0
>> >  kOla[] init ifftsize ; overlap-add buffer
>> >  kIn[] init ifftsize  ; input buffer
>> >  kOut[][] init iolaps, ifftsize ; output buffers
>> >  kSlice[] init ifftsize*2
>> >  kRow[] init ifftsize
>> >  kRow1[] init ifftsize
>> >
>> >  a1     oscil .5, 440
>> >  /* every hopsize samples */
>> >  if kcnt == ihopsize then
>> >    /* window and take FFT */
>> >    kWin[] window kIn,krow*ihopsize
>> >    kWinCp[] r2c kWin
>> >    kSpec[] fft kWinCp
>> >
>> >  /* HILBERT */
>> >         kSlice[] slicearray kSpec, 0, ifftsize-1
>> >         kSlice2[]=kSlice*2
>> >         kSlice2[0]=kSlice[0]
>> >         kSlice2[1]=kSlice[1]
>> >         kSlice2[ifftsize]=kSpec[ifftsize]
>> >         kSlice2[ifftsize+1]=kSpec[ifftsize+1]
>> >    /* IFFT + window */
>> >    kRowCp[] fftinv kSlice2
>> >
>> >    ; SOMETHING IS WRONG HERE (:
>> >         kind = 0
>> >         until kind==ifftsize do
>> >                 kRow[kind]=kRowCp[2*kind+1]
>> >                 kind += 1
>> >         od
>> >
>> >    kWin window kRow, krow*ihopsize
>> >    /* place it on out buffer */
>> >    kOut setrow kWin, krow
>> >    /* zero the ola buffer */
>> >    kOla = 0
>> >    /* overlap-add */
>> >    ki = 0
>> >    until ki == iolaps do
>> >      kRow getrow kOut, ki
>> >      kOla = kOla + kRow
>> >      ki += 1
>> >    od
>> >
>> >    /* update counters */
>> >   krow = (krow+1)%iolaps
>> >   kcnt = 0
>> >  endif
>> >
>> >  /* shift audio in/out of buffers */
>> >  kIn shiftin a1
>> >  a2 shiftout kOla
>> >     out a2/iolaps
>> >
>> >  /* increment counter */
>> >  kcnt += ksmps
>> > endin
>> >
>> > 
>> > 
>> > f1 0 2048 -10 0
>> > i1 0 10
>> > 
>> >
>> >
>> > The line
>> > kRow[kind]=kRowCp[2*kind+1]
>> > shows error @ = k
>> >
>> > Everything works fine except that part. I just want to get the odd
>> > elements
>> > of array, it should be the signal in quadrature.
>> >
>> > Thank you!
>> >
>> >
>> >
>> >
>> >
>> >
>> > -----
>> > Gleb Rogozinsky, PhD
>> > Associated Professor
>> > Interactive Arts Department
>> > Saint-Petersburg University of Film and Television
>> >
>> > Deputy Director of Medialab
>> > Saint-Petersburg University of Telecommunications
>> > --
>> > View this message in context:
>> > http://csound.1045644.n5.nabble.com/Csnd-Array-question-tp5746829.html
>> > Sent from the Csound - General mailing list archive at Nabble.com.
>> >
>> > 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
>>
>> 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
>
> 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

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

Date2016-02-01 00:01
FromGleb
SubjectRe: Array question
Great! I got it working! Such an easy solution...



-----
Gleb Rogozinsky, PhD
Associated Professor
Interactive Arts Department
Saint-Petersburg University of Film and Television

Deputy Director of Medialab
Saint-Petersburg University of Telecommunications
--
View this message in context: http://csound.1045644.n5.nabble.com/Csnd-Array-question-tp5746829p5746833.html
Sent from the Csound - General mailing list archive at Nabble.com.

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