Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Cabbage>
- form caption("PitchWarp") size(400, 125), colour(47, 79, 79), pluginid("pwrp")
- label bounds(30,2,384,10) text("Pitch Warp uses a function table to scale individual bins frequencies") wrap(1)
- gentable tablenumber(101) active(1) identchannel("scaleTabID") amprange(-1, 1, 101, 0.0001) bounds(70,25,320,65) tablegridcolour(0,0,0,0) tablecolour:N(72, 209, 204) tablebackgroundcolour(27, 59, 59)
- label text("Bin to pitch shift") bounds (70, 105, 320, 15)
- vslider channel("semiScale") range(6,60,24,1,1) text("Range") bounds(12,5,50,115)
- </Cabbage>
- <CsoundSynthesizer>
- <CsOptions>
- -n -d -+rtmidi=NULL -M0 -m0d
- </CsOptions>
- <CsInstruments>
- ; Initialize the global variables.
- ksmps = 32
- nchnls = 2
- 0dbfs = 1
- instr update
- giWindowSize = 4096
- giTabSize= giWindowSize+2;get spectral window size
- giOverlap = 16
- iScaleTab ftgen 101, 0, 10000, -7, 0 ,10000, 0
- iCleatTab ftgen 102, 0, giTabSize, 2, 0
- event_i "i", "Warp", 0, pow(9999,9999)
- endin
- instr Warp
- kSemiScale chnget "semiScale"
- kOut1[] init giTabSize
- kOut2[] init giTabSize
- iClear[] init giTabSize
- copyf2array iClear, 102
- ;Convert time to freq domain
- kIn1[] init giTabSize
- kIn2[] init giTabSize
- kOut1 = iClear
- kOut2 = iClear
- iWintype = 0
- aIn1 inch 1
- fIn1 pvsanal aIn1, giWindowSize, giWindowSize/giOverlap, giWindowSize, iWintype, 0
- aIn2 inch 2
- fIn2 pvsanal aIn2, giWindowSize, giWindowSize/giOverlap, giWindowSize, iWintype, 0
- ;Convert pvs to an array
- kFrame1 pvs2tab kIn1, fIn1
- kFrame2 pvs2tab kIn2, fIn2
- kFrame= kFrame1+kFrame2
- kCount = 10 ; Every second index is frequency
- kStep = 2 ; Skip every other index
- ;This is not working as expected- maybe I need the shift bins as I originaly thought...
- if changed(kFrame)==1 then
- until kCount >= giTabSize do
- kIndex = round(pow(((kCount))/giTabSize,2.5))
- kScale table kIndex, 101
- kSemi = pow(2,(kScale)*kSemiScale/12)
- kBinTarget= floor((kCount)*kSemi*giTabSize)
- kOut1[kBinTarget] = kIn1[kCount] + kOut1[kBinTarget]
- kOut2[kBinTarget] = kIn2[kCount] + kOut2[kBinTarget]
- kOut1[kBinTarget+1] = kIn1[kCount+1]*kSemi+kOut1[kBinTarget+1]
- kOut2[kBinTarget+1] = kIn2[kCount+1]*kSemi+kOut1[kBinTarget+1]
- kCount += kStep
- od
- endif
- fOut1 tab2pvs kOut1, giWindowSize/(giOverlap), giWindowSize, iWintype
- fOut2 tab2pvs kOut2, giWindowSize/(giOverlap), giWindowSize, iWintype
- aOut1 pvsynth fOut1
- aOut2 pvsynth fOut2
- outs aOut1, aOut2
- endin
- </CsInstruments>
- <CsScore>
- ;causes Csound to run for about 7000 years...
- f0 z
- ;starts instrument 1 and runs it for a week
- i "update" 0 [60*60*24*7]
- </CsScore>
- </CsoundSynthesizer>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement