Csound Csound-dev Csound-tekno Search About

Re: [Csnd] Question re: writing one instr to a table to be read by another

Date2023-02-17 02:23
FromScott Daughtrey
SubjectRe: [Csnd] Question re: writing one instr to a table to be read by another
I have been experimenting a little with this. The paulstretch opcode does not allow for transposition so the idea here is to transpose using diskin & write to a table (2 actually as file is stereo) and have the tables read by paulstretch.

All seems fine using tablewa, which I accidentally stumbled across (and don't completely comprehend; I'm actually surprised I got this to work...) . However my initial attempt using tablew, based upon example 03D07 of the FLOSS manual, produces no sound. I'd like to understand why one works & the other does not. Also, why does tablewa seem to automatically sequentially write to different idx whereas with tablew it would appear that it is recommended to use a phasor or other method?

I'm very new to writing audio to tables so please forgive my apparant complete ignorance here.

And if there are obvious ways to achieve these results in a better way feel free to offer suggestions.

Here are the two examples:

    instr 1

iRand = random(-12, 12.99)
iFreq = semitone(int(iRand))
print iFreq

aSf1, aSf2  diskin2 "cello1.wav", iFreq, 0, 1       
iLen  filelen "cello1.wav"
print iLen
iLen2 = (iLen * sr)/iFreq
print iLen2

giL ftgen 0, 0, -iLen2, -2, 0
giR ftgen 0, 0, -iLen2, -2, 0

kstart = 0
kstart tablewa giL, aSf1, 0
kstart tablewa giR, aSf2, 0

aL  paulstretch 30, 0.2, giL
aR  paulstretch 30, 0.2, giR
    outs aL*2, aL*2
    
kTime  times
printk 5, kTime
    
    endin

/////////////////////////////

    instr 1

iRand = random(-12, 12.99)
iFreq = semitone(int(iRand))
print iFreq

aSf1, aSf2  diskin2 "cello1.wav", iFreq, 0, 1       
iLen filelen "cello1.wav"
print iLen
iLen2 = (iLen * sr)/iFreq
print iLen2
iLen3 = iLen/iFreq
print iLen3

giL ftgen 0, 0, -iLen2, -2, 0
giR ftgen 0, 0, -iLen2, -2, 0

aIdx    phasor 1/iLen3
    tablew aSf1, aIdx, giL
    tablew aSf2, aIdx, giR

aL  paulstretch 30, 0.2, giL
aR  paulstretch 30, 0.2, giR
    outs aL*2, aL*2
    
kTime  times
printk 5, kTime
    
    endin

Here are the two csd & cello1.wav files in case it makes it easier to examine:
https://www.dropbox.com/s/kmxx9fqr3nkdl5r/tablewa_1.csd?dl=0

https://www.dropbox.com/s/riicv91f62kdayh/tablew_1.csd?dl=0

https://www.dropbox.com/s/tgj0lsv4dnhxmdg/Cello1.wav?dl=0

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