[Csnd] Copying audio as pvs split data at init time

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] Copying audio as pvs split data at init time

eddyc
Hi,

I wanted to copy an x number of seconds of audio data to magnitude and frequency 2D arrays at init time, I looked at the example of copying fsig data to a pvsbuffer using a UDO and modified it. This is what I have but it doesn't seem to work as expected. When I retrieve the spectral arrays from the UDO I'm getting audio dropouts as the UDO still seems to be calculating the spectral data during synthesis, I was wondering where I was going wrong here.

opcode AudioToPolarArray, k[]k[], iii

    iFFTSize, iHopSize, iTimeSeconds xin

    kTimek timeinstk
    kCount init 0
    iTimekCycles = iTimeSeconds * kr
  kTimekCycles = iTimekCycles
    kMagnitudes[][] init iTimekCycles, iFFTSize/2 + 1
    kFrequencies[][] init iTimekCycles, iFFTSize/2 + 1
    kMagsFrame[] init iFFTSize/2 + 1
    kFreqsFrame[] init iFFTSize/2 + 1

    if (kTimek == 0) then

        loop:
            aOut vco2 0.4, 440
            fSig pvsanal aOut, iFFTSize, iHopSize, iFFTSize, 1
            kFrame  pvs2tab kMagsFrame, kFreqsFrame, fSig
kMagnitudes setrow kMagsFrame, kCount
kFrequencies setrow kFreqsFrame, kCount

        loop_lt kCount, 1, kTimekCycles - 1, loop

        xout kMagnitudes, kFrequencies

    endif

endop

instr synth

iFFTSize = 1024;
iHopSize = 256;
iTimeSeconds = 10;

kMagnitudes[][], kFrequencies[][] AudioToPolarArray iFFTSize, iHopSize, iTimeSeconds

k1 init 0

kMagsRow[] getrow kMagnitudes, k1
kFreqsRow[] getrow kFrequencies, k1


fSig tab2pvs kMagsRow, kFreqsRow
        aOut pvsynth fSig

        k1 += 1

    outs aOut, aOut

endin

Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying audio as pvs split data at init time

eddyc
I’ve set breakpoints in my debugger and run this Csound code, I have a breakpoint for the setrow performance function which is used in the UDO, and one for the tab2pvs performance function used after that UDO in the instrument, once the tab2pvs breakpoint is hit, the setrow breakpoint is never hit again, so it seems that it’s not because the calculation of pvs data in the UDO is still taking place while the tab2pvs and pvsynth opcodes are converting it back to audio, but yet the audio still has dropouts.
Ed

> On 19 May 2017, at 02:02, Ed Costello <[hidden email]> wrote:
>
> Hi,
>
> I wanted to copy an x number of seconds of audio data to magnitude and frequency 2D arrays at init time, I looked at the example of copying fsig data to a pvsbuffer using a UDO and modified it. This is what I have but it doesn't seem to work as expected. When I retrieve the spectral arrays from the UDO I'm getting audio dropouts as the UDO still seems to be calculating the spectral data during synthesis, I was wondering where I was going wrong here.
>
> opcode AudioToPolarArray, k[]k[], iii
>
>     iFFTSize, iHopSize, iTimeSeconds xin
>
>     kTimek timeinstk
>     kCount init 0
>     iTimekCycles = iTimeSeconds * kr
>     kTimekCycles = iTimekCycles
>     kMagnitudes[][] init iTimekCycles, iFFTSize/2 + 1
>     kFrequencies[][] init iTimekCycles, iFFTSize/2 + 1
>     kMagsFrame[] init iFFTSize/2 + 1
>     kFreqsFrame[] init iFFTSize/2 + 1
>
>     if (kTimek == 0) then
>
>         loop:
>             aOut vco2 0.4, 440
>             fSig pvsanal aOut, iFFTSize, iHopSize, iFFTSize, 1
>             kFrame  pvs2tab kMagsFrame, kFreqsFrame, fSig
>    kMagnitudes setrow kMagsFrame, kCount
>    kFrequencies setrow kFreqsFrame, kCount
>
>         loop_lt kCount, 1, kTimekCycles - 1, loop
>
>         xout kMagnitudes, kFrequencies
>
>     endif
>
> endop
>
> instr synth
>
> iFFTSize = 1024;
> iHopSize = 256;
> iTimeSeconds = 10;
>
> kMagnitudes[][], kFrequencies[][] AudioToPolarArray iFFTSize, iHopSize, iTimeSeconds
>
> k1 init 0
>
> kMagsRow[] getrow kMagnitudes, k1
> kFreqsRow[] getrow kFrequencies, k1
>
>
> fSig tab2pvs kMagsRow, kFreqsRow
>         aOut pvsynth fSig
>
>         k1 += 1
>
>     outs aOut, aOut
>
> endin
>

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Copying audio as pvs split data at init time

eddyc
Sorry for all the responses, but I’ve removed the loop from the UDO now, and it looks like it’s the allocation of large arrays that is causing the audio to dropout, like setting the input to the UDO for time in seconds to 10.
Ed

> On 19 May 2017, at 18:08, Ed Costello <[hidden email]> wrote:
>
> I’ve set breakpoints in my debugger and run this Csound code, I have a breakpoint for the setrow performance function which is used in the UDO, and one for the tab2pvs performance function used after that UDO in the instrument, once the tab2pvs breakpoint is hit, the setrow breakpoint is never hit again, so it seems that it’s not because the calculation of pvs data in the UDO is still taking place while the tab2pvs and pvsynth opcodes are converting it back to audio, but yet the audio still has dropouts.
> Ed
>
>> On 19 May 2017, at 02:02, Ed Costello <[hidden email]> wrote:
>>
>> Hi,
>>
>> I wanted to copy an x number of seconds of audio data to magnitude and frequency 2D arrays at init time, I looked at the example of copying fsig data to a pvsbuffer using a UDO and modified it. This is what I have but it doesn't seem to work as expected. When I retrieve the spectral arrays from the UDO I'm getting audio dropouts as the UDO still seems to be calculating the spectral data during synthesis, I was wondering where I was going wrong here.
>>
>> opcode AudioToPolarArray, k[]k[], iii
>>
>>    iFFTSize, iHopSize, iTimeSeconds xin
>>
>>    kTimek timeinstk
>>    kCount init 0
>>    iTimekCycles = iTimeSeconds * kr
>>    kTimekCycles = iTimekCycles
>>    kMagnitudes[][] init iTimekCycles, iFFTSize/2 + 1
>>    kFrequencies[][] init iTimekCycles, iFFTSize/2 + 1
>>    kMagsFrame[] init iFFTSize/2 + 1
>>    kFreqsFrame[] init iFFTSize/2 + 1
>>
>>    if (kTimek == 0) then
>>
>>        loop:
>>            aOut vco2 0.4, 440
>>            fSig pvsanal aOut, iFFTSize, iHopSize, iFFTSize, 1
>>            kFrame  pvs2tab kMagsFrame, kFreqsFrame, fSig
>>    kMagnitudes setrow kMagsFrame, kCount
>>    kFrequencies setrow kFreqsFrame, kCount
>>
>>        loop_lt kCount, 1, kTimekCycles - 1, loop
>>
>>        xout kMagnitudes, kFrequencies
>>
>>    endif
>>
>> endop
>>
>> instr synth
>>
>> iFFTSize = 1024;
>> iHopSize = 256;
>> iTimeSeconds = 10;
>>
>> kMagnitudes[][], kFrequencies[][] AudioToPolarArray iFFTSize, iHopSize, iTimeSeconds
>>
>> k1 init 0
>>
>> kMagsRow[] getrow kMagnitudes, k1
>> kFreqsRow[] getrow kFrequencies, k1
>>
>>
>> fSig tab2pvs kMagsRow, kFreqsRow
>>        aOut pvsynth fSig
>>
>>        k1 += 1
>>
>>    outs aOut, aOut
>>
>> endin
>>
>

Csound mailing list
[hidden email]
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