Csound Csound-dev Csound-tekno Search About

[Csnd] Problem reading a PVS buffer from different instrument instances

Date2013-04-04 16:48
FromEdward Costello
Subject[Csnd] Problem reading a PVS buffer from different instrument instances
AttachmentsNone  None  

Date2013-04-04 19:39
Fromjoachim heintz
SubjectRe: [Csnd] Problem reading a PVS buffer from different instrument
hi edward -

on a first look (without testing), i'd say it should work. does it not? 
what is the problem?
best -

	joachim

Am 04.04.2013 17:48, schrieb Edward Costello:
> Hi,
>
> I have and instrument that is always on that reads 2 function tables of
> audio into 2 PVS buffers, basically a stereo signal. I then have another
> instrument that reads from these PVS buffers and synthesises the data
> back into audio using a pvssynth. What I need to be able to do is have
> different instances of this instrument reading from the stereo PVS
> buffers at different offsets at the same time, is this possible? Or do I
> have to make separate PVS buffers for each instance?
> I have an example of what I mean here, you would think 20 instances of
> the PVSReader instrument would be louder.
>
> --
> Edward Costello
>
>
> 
>
> 
>
> -d
>
> 
>
> 
>
> sr = 44100
>
> ksmps = 256
>
> nchnls = 2
>
> 0dbfs=1
>
>
> #define ChannelOneTable #100#
>
> #define ChannelTwoTable #101#
>
> #define WarpPath #200#
>
>
> ;; based off FileToPvsBuf example written by joachim heintz 2009
>
>
> opcode TableToPvsBuf, ikk, iiiii
>
>
> i_Table, i_FFTSize, i_Overlap, i_WindowSize, i_WindowShape xin
>
> k_TimeInKCycles timeinstk
>
> if k_TimeInKCycles == 1 then
>
> i_Length = ftlen(i_Table) / sr
>
> k_Cycles = i_Length * kr
>
> k_Count init 0
>
> loop:
>
> f_FFTIn pvstanal 1, 1, 1, i_Table, 1, 0, 0
>
> i_Buffer, k_TimePointer pvsbuffer f_FFTIn, i_Length + (i_FFTSize / sr)
>
> loop_lt k_Count, 1, k_Cycles, loop
>
> xout i_Buffer, k_Count, k_TimePointer
>
> endif
>
> endop
>
>
> gi_FFTSize init 1024
>
> gk_TimePointer init 0
>
>
> instr 1, PVSBuffer
>
>
>
> gi_Overlap = gi_FFTSize / 4
>
> i_WindowSize = gi_FFTSize
>
> i_WindowShape = 1; von-Hann window
>
> gi_PVSBufferOneL, gk_HopCount, k0 TableToPvsBuf $ChannelOneTable,
> gi_FFTSize, gi_Overlap, i_WindowSize, i_WindowShape
>
> gi_PVSBufferOneR, gk_HopCount, k0 TableToPvsBuf $ChannelTwoTable,
> gi_FFTSize, gi_Overlap, i_WindowSize, i_WindowShape
>
> k_On init 0
>
> k_PVSReaderInstances = p4
>
>
> if k_On == 0 then
>
> k_Count = 0
>
> until k_Count == k_PVSReaderInstances do
>
> event "i", "PVSReader", 0, -1, gk_HopCount, k_Count + 200
>
> k_Count = k_Count + 1
>
> od
>
> k_On = 1
>
> endif
>
> gi_TimeInSeconds = ftlen($ChannelOneTable) / sr;
>
> i_PhasorCPS = 1/gi_TimeInSeconds
>
> gk_PhasorIndex phasor i_PhasorCPS
>
>
> endin
>
>
> instr 2, PVSReader
>
>
> i_HopCount = p4
>
> i_TimeTableNumber = p5
>
> gi_TimeTable ftgen i_TimeTableNumber, 0, -i_HopCount, -7, 0, i_HopCount,
> gi_TimeInSeconds
>
>
> gk_TimePointer table gk_PhasorIndex , i_TimeTableNumber, 1
>
>
> f_ChannelOne pvsbufread gk_TimePointer, gi_PVSBufferOneL
>
> f_ChannelTwo pvsbufread gk_TimePointer, gi_PVSBufferOneR
>
>
> a_ChannelOne pvsynth f_ChannelOne
>
> a_ChannelTwo pvsynth f_ChannelTwo
>
> outs a_ChannelOne, a_ChannelTwo
>
> endin
>
>
>
>
> 
>
> 
>
> f100 0 0 1
> "/Users/eddyc/Dropbox/SoftwareProjects/Audio-Mosaicing/Audio-Mosaicing/input.wav"
> 0 0 1
>
> f101 0 0 1
> "/Users/eddyc/Dropbox/SoftwareProjects/Audio-Mosaicing/Audio-Mosaicing/input.wav"
> 0 0 2
>
>
> i 1 0 -1 20
>
> e3600
>
> 
>
> 
>
>

Date2013-04-04 19:53
FromEdward Costello
SubjectRe: [Csnd] Problem reading a PVS buffer from different
AttachmentsNone  None  

Date2013-04-04 20:01
FromEdward Costello
SubjectRe: [Csnd] Problem reading a PVS buffer from different
AttachmentsNone  None  

Date2013-04-04 22:44
FromVictor Lazzarini
SubjectRe: [Csnd] Problem reading a PVS buffer from different
you need to use a fractional instrument number in that case.
On 4 Apr 2013, at 20:01, Edward Costello wrote:

I found the problem, using an event opcode sent from the PVSBuffer instrument I use a -1 to set the instrument as always on, this seems to make it so only one instance of the instrument can be on at a time. When I use a positive number instead it works.

-- 
Edward Costello

On Thursday 4 April 2013 at 20:53, Edward Costello wrote:

No the audio coming out just sounds like there is one instance of the instrument playing. In the terminal output I can see all my f-tables are being allocated, in the example I gave there are 20 instances called so I see 20 f-tables being allocated, I have tried setting a different offset of the pvs buffer for each instance to read from based on the p5 sent from the PVSBuffer instrument, but still no joy.

-- 
Edward Costello

On Thursday 4 April 2013 at 20:39, joachim heintz wrote:

hi edward -

on a first look (without testing), i'd say it should work. does it not?
what is the problem?
best -

joachim

Am 04.04.2013 17:48, schrieb Edward Costello:
Hi,

I have and instrument that is always on that reads 2 function tables of
audio into 2 PVS buffers, basically a stereo signal. I then have another
instrument that reads from these PVS buffers and synthesises the data
back into audio using a pvssynth. What I need to be able to do is have
different instances of this instrument reading from the stereo PVS
buffers at different offsets at the same time, is this possible? Or do I
have to make separate PVS buffers for each instance?
I have an example of what I mean here, you would think 20 instances of
the PVSReader instrument would be louder.

--
Edward Costello


<CsoundSynthesizer>

<CsOptions>

-d

</CsOptions>

<CsInstruments>

sr = 44100

ksmps = 256

nchnls = 2

0dbfs=1


#define ChannelOneTable #100#

#define ChannelTwoTable #101#

#define WarpPath #200#


;; based off FileToPvsBuf example written by joachim heintz 2009


opcode TableToPvsBuf, ikk, iiiii


i_Table, i_FFTSize, i_Overlap, i_WindowSize, i_WindowShape xin

k_TimeInKCycles timeinstk

if k_TimeInKCycles == 1 then

i_Length = ftlen(i_Table) / sr

k_Cycles = i_Length * kr

k_Count init 0

loop:

f_FFTIn pvstanal 1, 1, 1, i_Table, 1, 0, 0

i_Buffer, k_TimePointer pvsbuffer f_FFTIn, i_Length + (i_FFTSize / sr)

loop_lt k_Count, 1, k_Cycles, loop

xout i_Buffer, k_Count, k_TimePointer

endif

endop


gi_FFTSize init 1024

gk_TimePointer init 0


instr 1, PVSBuffer



gi_Overlap = gi_FFTSize / 4

i_WindowSize = gi_FFTSize

i_WindowShape = 1; von-Hann window

gi_PVSBufferOneL, gk_HopCount, k0 TableToPvsBuf $ChannelOneTable,
gi_FFTSize, gi_Overlap, i_WindowSize, i_WindowShape

gi_PVSBufferOneR, gk_HopCount, k0 TableToPvsBuf $ChannelTwoTable,
gi_FFTSize, gi_Overlap, i_WindowSize, i_WindowShape

k_On init 0

k_PVSReaderInstances = p4


if k_On == 0 then

k_Count = 0

until k_Count == k_PVSReaderInstances do

event "i", "PVSReader", 0, -1, gk_HopCount, k_Count + 200

k_Count = k_Count + 1

od

k_On = 1

endif

gi_TimeInSeconds = ftlen($ChannelOneTable) / sr;

i_PhasorCPS = 1/gi_TimeInSeconds

gk_PhasorIndex phasor i_PhasorCPS


endin


instr 2, PVSReader


i_HopCount = p4

i_TimeTableNumber = p5

gi_TimeTable ftgen i_TimeTableNumber, 0, -i_HopCount, -7, 0, i_HopCount,
gi_TimeInSeconds


gk_TimePointer table gk_PhasorIndex , i_TimeTableNumber, 1


f_ChannelOne pvsbufread gk_TimePointer, gi_PVSBufferOneL

f_ChannelTwo pvsbufread gk_TimePointer, gi_PVSBufferOneR


a_ChannelOne pvsynth f_ChannelOne

a_ChannelTwo pvsynth f_ChannelTwo

outs a_ChannelOne, a_ChannelTwo

endin




</CsInstruments>

<CsScore>

f100 0 0 1
"/Users/eddyc/Dropbox/SoftwareProjects/Audio-Mosaicing/Audio-Mosaicing/input.wav"
0 0 1

f101 0 0 1
"/Users/eddyc/Dropbox/SoftwareProjects/Audio-Mosaicing/Audio-Mosaicing/input.wav"
0 0 2


i 1 0 -1 20

e3600

</CsScore>

</CsoundSynthesizer>


Send bugs reports to the Sourceforge bug tracker
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie