<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 96000
ksmps = 10
nchnls = 1
0dbfs = 1

	opcode warp,0,iiiiii ;no outputs, 6 i-rate inputs
	
inumbins, iampin, ifreqin, iampout,ifreqout,iwarpfunction, xin

; start with an empty table
iclear 	ftgen 0, 0, inumbins, -2, 0 ;Thanks Matt!

	tablecopy iampout, iclear
	tablecopy ifreqout, iclear

;perform a do-while loop cycling through the table
;copying data from original index to new indexes in the output tables

kindex = 0 
loop: 
;read the warp or remapping function
kwarp		table   kindex, iwarpfunction
;read original data from original index points
kAmp		table   kindex, iampin	
kFreq		table   kindex, ifreqin

;write the data to the new location in a second set of “output” tables
		tablew  kAmp, kwarp, iampout
		tablew  kFreq, kwarp, ifreqout

kindex = kindex + 1 ;incrementally increase the index number

if (kindex < inumbins) kgoto loop 
;go back to the top of loop section 
;if index is less than maximum FFT bin count

endop


instr 1

ifftsize = 2048 ;FFT size
iol = 4	    ;Overlap factor
ihop = ifftsize/iol	;hop size
iwindow = ifftsize*2	;window size (can be larger than FFT)
iwintype = 2

iNumBins = (ifftsize/2) + 1	; The number of used bins+1 for use by the table
ifreqin ftgen 0,0,iNumBins,2,0
iampin  ftgen 0,0,iNumBins,2,0
ifreqout ftgen 0,0,iNumBins,2,0
iampout  ftgen 0,0,iNumBins,2,0

;function table for remapping the data
iwarpfunction ftgen 0,0,iNumBins,-7,0 ,iNumBins, iNumBins ;Unaltered

;try these for more fun!
;iwarpfunction ftgen 0,0,iNumBins,-7,0 ,iNumBins/2, iNumBins, 20, iNumBins/2
;iwarpfunction ftgen 0,0,iNumBins,-7,0 ,iNumBins/4, iNumBins, 0, iNumBins/2
;iwarpfunction ftgen 0,0,iNumBins,-7,iNumBins/20 ,iNumBins/4, 0, iNumBins/2,iNumBins
;iwarpfunction ftgen 0,0,iNumBins,-7,20 ,iNumBins, 20;Unaltered
 
;ain1, ain2 diskin "/Volumes/Sounds/vocal noises/mm-ah hrmonics.aiff", 1
ain1 in
ain1	dcblock	ain1
fsig1	pvsanal 	ain1, ifftsize, ihop, iwindow, iwintype	

; export fsig amplitude and frequency data to table
kflag 	pvsftw fsig1, iampin, ifreqin
;not that iamp and ifreq have been replaced by iampin and ifreqin.
if (kflag > 0) then ; only proc when frame is ready

 ;the UDO reference is placed here to Frequency warp the PVS data
	warp	iNumBins, iampin, ifreqin, iampout, ifreqout, iwarpfunction

; read data back to fsrc
	pvsftr fsig1, iampout, ifreqout 
;note that iamp and ifreq have been replaced by iampout and ifreqout

endif

aout1 pvsynth fsig1
out	aout1
endin

</CsInstruments>
<CsScore>
i 1 0 20
e
</CsScore>
</CsoundSynthesizer>
<MacOptions>
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
Listing: Window
WindowBounds: 0 62 801 140
CurrentView: io
IOViewEdit: On
Options: -b128 -A -s -m167 -R
</MacOptions>
<MacGUI>
ioView background {32125, 41634, 41120}
</MacGUI>

