Opcodes that achieve similar results to paulstretch?

Hello,

I’m looking for any opcodes that can help me achieve similar results to paulstretching. Planning on implementing this in Cabbage as a sampler.

I already tried the paulstretch-opcode, but it is not suitable for use in Cabbage because of crashing.

Why does it crash Cabbage? Have you tried it with command line version of Csound, does it crash there too?

It crashes every time you reinitialize the i-rate controls using sliders. Works fine other than that though.

Without seeing the code hard to know what the issue might be.

You could try using sndwarp (or for stereo files sndwarpst) which allows some variables like pitch & stretch to be changed independently at a or k rate.

Thanks for the response. Here’s a code example.

<Cabbage>
form caption("Stretch") size(600, 500), guiMode("queue"), pluginId("1287"), colour (0,100,0)
keyboard bounds(8, 158, 381, 95)
filebutton bounds(14, 18, 80, 40) channel("LoadButton")
rslider bounds(90, 298, 60, 60) channel("rslider10003") range(0.1, 1, 0.5, 1, 0.01)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-dm0 -n -+rtmidi=null -M0 -Q0 --midi-key=4 --midi-velocity=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
    // Cabbage widgets
    iWindowSize cabbageGetValue "rslider10003"
    
    // Table upload
    Sfile chnget "LoadButton"
    iLen filelen    Sfile 
    iSr filesr    Sfile 
    iCh filenchnls  Sfile
    iTableSize = (iLen*iSr)*2
    
    iSoundFileL ftgen 0, 0, iTableSize, 1, Sfile, 0, 0, 1
    iSoundFileR ftgen 0, 0, iTableSize, 1, Sfile, 0, 0, 2
    
    iNum notnum
    iFreq = 2^((iNum-84)/12)  // Note 84 (C5) is when pitch = 1

    if (changed(k(iNum)) == 1) then
        event_i "i", 2, 0, 2, iWindowSize, iSoundFileL, iFreq
    endif
endin


instr 2
    aoutL paulstretch 10, p4, p5
    
    ifftsize = 4096
    ioverlap = ifftsize / 4
    iwinsize = ifftsize
    iwinshape = 1
    iFreq = p6

    fftinL pvsanal	aoutL, ifftsize, ioverlap, iwinsize, iwinshape; fft-analysis of the audio-signal
    fftblurL	pvscale	fftinL, iFreq, 0
    aoutPitchL pvsynth	fftblurL; resynthesis
   
    out aoutPitchL
endin
</CsInstruments>
<CsScore>
f0 z
</CsScore>
</CsoundSynthesizer>

Ended up going for sndwarp, thanks @ST_Music for the suggestion. No matter how I adjust the paulstretch-opcode for Cabbage, it always seems to crash when changing i-rate variables.

Hope that’s working out ok. Another thing worth mentioning is there’s some good material about the granular opcodes in the FLOSS manual, might be worth looking at depending on what results you’re trying to achieve.

Sndwarp seemed like a reasonable alternative that might allow ditching the fft/pvsynth steps.

That said, knowing what your goal is might (a more standard sampler vs something to do pads or mainly extreme time stretching) might make it easier to decide what opcodes would be best suited.

You could also ask in the Cabbage forum, I know Rory & Iain McCurdy frequent it fairly regularly and are very helpful.

Best,
Scott

The goal is all of those :rofl: Well, mostly to resemble the extreme time stretching of PaulStretch for pads, sound design, etc. Seems like sndwarp handles this relatively well, the result sounds PaulStretch-esque, and it’s quite flexible.

1 Like

A crash in Csound pulls Cabbage down. Try the following csd from the command line and it ends immediately.

<CsoundSynthesizer>
<CsOptions>
-dm0 -n -odac
</CsOptions>
<CsInstruments>
; Initialize the global variables. 

ksmps = 32
nchnls = 2
0dbfs = 1

instr 1

    iWindowSize random 0., 1    
    Sfile = "pianoMood.wav"

    iLen filelen    Sfile 
    iSr filesr    Sfile 
    iCh filenchnls  Sfile
    iTableSize = (iLen*iSr)*2
    iSoundFileL ftgen 0, 0, iTableSize, 1, Sfile, 0, 0, 1
    iSoundFileR ftgen 0, 0, iTableSize, 1, Sfile, 0, 0, 2   

    iNum = 60
    iFreq = 2^((iNum-84)/12)  // Note 84 (C5) is when pitch = 1
    if (changed(k(iNum)) == 1) then
        event_i "i", 2, 0, 2, iWindowSize, iSoundFileL, iFreq
    endif

endin

instr 2

    aoutL paulstretch 10, p4, p5
    ifftsize = 4096

    ioverlap = ifftsize / 4

    iwinsize = ifftsize
    iwinshape = 1
    iFreq = p6

    fftinL pvsanal	aoutL, ifftsize, ioverlap, iwinsize, iwinshape; fft-analysis of the audio-signal
    fftblurL	pvscale	fftinL, iFreq, 0
    aoutPitchL pvsynth	fftblurL; resynthesis  
    out aoutPitchL

endin

</CsInstruments>
<CsScore>
i1 0 1 
i1 + 1 
i1 + 1 
i1 + 1 
</CsScore>
</CsoundSynthesizer>

Change the window size to something static and it runs fine.

2 Likes