Advertisement
cpoovey

PitchWarp

Apr 30th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <Cabbage>
  2. form caption("PitchWarp") size(400, 125), colour(47, 79, 79), pluginid("pwrp")
  3. label bounds(30,2,384,10) text("Pitch Warp uses a function table to scale individual bins frequencies") wrap(1)
  4. 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)
  5. label text("Bin to pitch shift") bounds (70, 105, 320, 15)
  6. vslider channel("semiScale") range(6,60,24,1,1) text("Range") bounds(12,5,50,115)
  7.  
  8. </Cabbage>
  9. <CsoundSynthesizer>
  10. <CsOptions>
  11. -n -d -+rtmidi=NULL -M0 -m0d
  12. </CsOptions>
  13. <CsInstruments>
  14. ; Initialize the global variables.
  15. ksmps = 32
  16. nchnls = 2
  17. 0dbfs = 1
  18.  
  19.  
  20. instr update
  21. giWindowSize = 4096
  22. giTabSize= giWindowSize+2;get spectral window size
  23. giOverlap = 16
  24. iScaleTab ftgen 101, 0, 10000, -7, 0 ,10000, 0
  25. iCleatTab ftgen 102, 0, giTabSize, 2, 0
  26. event_i "i", "Warp", 0, pow(9999,9999)
  27. endin
  28.  
  29. instr Warp
  30. kSemiScale chnget "semiScale"
  31. kOut1[] init giTabSize
  32. kOut2[] init giTabSize
  33. iClear[] init giTabSize
  34. copyf2array iClear, 102
  35. ;Convert time to freq domain
  36. kIn1[] init giTabSize
  37.  
  38. kIn2[] init giTabSize
  39.  
  40.  
  41. kOut1 = iClear
  42. kOut2 = iClear
  43.  
  44. iWintype = 0
  45.  
  46. aIn1 inch 1
  47. fIn1 pvsanal aIn1, giWindowSize, giWindowSize/giOverlap, giWindowSize, iWintype, 0
  48.  
  49. aIn2 inch 2
  50. fIn2 pvsanal aIn2, giWindowSize, giWindowSize/giOverlap, giWindowSize, iWintype, 0
  51.  
  52. ;Convert pvs to an array
  53. kFrame1 pvs2tab kIn1, fIn1
  54. kFrame2 pvs2tab kIn2, fIn2
  55. kFrame= kFrame1+kFrame2
  56.  
  57. kCount = 10 ; Every second index is frequency
  58. kStep = 2 ; Skip every other index
  59.  
  60. ;This is not working as expected- maybe I need the shift bins as I originaly thought...
  61.  
  62. if changed(kFrame)==1 then
  63.  
  64. until kCount >= giTabSize do
  65. kIndex = round(pow(((kCount))/giTabSize,2.5))
  66. kScale table kIndex, 101
  67. kSemi = pow(2,(kScale)*kSemiScale/12)
  68. kBinTarget= floor((kCount)*kSemi*giTabSize)
  69. kOut1[kBinTarget] = kIn1[kCount] + kOut1[kBinTarget]
  70. kOut2[kBinTarget] = kIn2[kCount] + kOut2[kBinTarget]
  71. kOut1[kBinTarget+1] = kIn1[kCount+1]*kSemi+kOut1[kBinTarget+1]
  72. kOut2[kBinTarget+1] = kIn2[kCount+1]*kSemi+kOut1[kBinTarget+1]
  73. kCount += kStep
  74. od
  75. endif
  76.  
  77. fOut1 tab2pvs kOut1, giWindowSize/(giOverlap), giWindowSize, iWintype
  78. fOut2 tab2pvs kOut2, giWindowSize/(giOverlap), giWindowSize, iWintype
  79.  
  80.  
  81. aOut1 pvsynth fOut1
  82. aOut2 pvsynth fOut2
  83.  
  84. outs aOut1, aOut2
  85. endin
  86.  
  87. </CsInstruments>
  88. <CsScore>
  89. ;causes Csound to run for about 7000 years...
  90. f0 z
  91. ;starts instrument 1 and runs it for a week
  92. i "update" 0 [60*60*24*7]
  93. </CsScore>
  94. </CsoundSynthesizer>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement