Browse Source

Initial push of DISTRHO code

tags/2018-04-16
falkTX 11 years ago
parent
commit
49edfaaa68
100 changed files with 23930 additions and 0 deletions
  1. +76
    -0
      .gitignore
  2. +9
    -0
      DISTRHO.kdev4
  3. +99
    -0
      Makefile
  4. +5
    -0
      TODO
  5. +101
    -0
      bin/cabbage-todo/Effects/AutopanTremolo.csd
  6. +73
    -0
      bin/cabbage-todo/Effects/HighpassFilter.csd
  7. +71
    -0
      bin/cabbage-todo/Effects/LowpassFilter.csd
  8. +76
    -0
      bin/cabbage-todo/Effects/MultiReverb.csd
  9. +96
    -0
      bin/cabbage-todo/Effects/clip.csd
  10. +98
    -0
      bin/cabbage-todo/Effects/pdclip.csd
  11. +134
    -0
      bin/cabbage-todo/Effects/resony.csd
  12. +103
    -0
      bin/cabbage-todo/Effects/waveset.csd
  13. +370
    -0
      bin/cabbage-todo/Synths/Choir.csd
  14. +321
    -0
      bin/cabbage-todo/Synths/Clavinet.csd
  15. +461
    -0
      bin/cabbage-todo/Synths/Clavinet.snaps
  16. +60
    -0
      bin/cabbage-todo/Synths/GaussianDust.csd
  17. +115
    -0
      bin/cabbage-todo/Synths/Granular.csd
  18. +300
    -0
      bin/cabbage-todo/Synths/InharmonicAdditiveSynth.csd
  19. +59
    -0
      bin/cabbage-todo/Synths/PinkNoise.csd
  20. +379
    -0
      bin/cabbage-todo/Synths/Risset.csd
  21. +64
    -0
      bin/cabbage-todo/Synths/SonicLavaLampHelp.html
  22. +983
    -0
      bin/cabbage-todo/Synths/TR-808.csd
  23. +1376
    -0
      bin/cabbage-todo/Synths/TR-808_pattern.0.txt
  24. +250
    -0
      bin/cabbage-todo/Synths/Vectorial.csd
  25. +363
    -0
      bin/cabbage-todo/Synths/hsboscil_synth.csd
  26. +802
    -0
      bin/cabbage-todo/Synths/oscbnk_synth.csd
  27. +127
    -0
      bin/cabbage-todo/Synths/sonic_lava_lamp.csd
  28. +100
    -0
      bin/cabbage/Effects/EnvelopeFollower.csd
  29. +263
    -0
      bin/cabbage/Effects/FrequencyShifter.csd
  30. +57
    -0
      bin/cabbage/Effects/LoFi.csd
  31. +121
    -0
      bin/cabbage/Effects/Phaser.csd
  32. +59
    -0
      bin/cabbage/Effects/PingPongDelay.csd
  33. +94
    -0
      bin/cabbage/Effects/Powershape.csd
  34. +71
    -0
      bin/cabbage/Effects/RingModulator.csd
  35. +57
    -0
      bin/cabbage/Effects/StereoChorus.csd
  36. +104
    -0
      bin/cabbage/Effects/pvScale.csd
  37. +90
    -0
      bin/cabbage/Effects/pvSmooth.csd
  38. +76
    -0
      bin/cabbage/Effects/pvsBlur.csd
  39. +114
    -0
      bin/cabbage/Effects/pvsBuffer.csd
  40. +432
    -0
      bin/cabbage/MIDI/MIDI_OUT_MATRIX.csd
  41. +160
    -0
      bin/cabbage/Synths/Additive.csd
  42. +80
    -0
      bin/cabbage/Synths/CrazyPluck.csd
  43. +54
    -0
      bin/cabbage/Synths/Dust.csd
  44. +135
    -0
      bin/cabbage/Synths/HiperSaw.csd
  45. +41
    -0
      bin/cabbage/Synths/WhiteNoise.csd
  46. +612
    -0
      bin/cabbage/Synths/bassline.csd
  47. +77
    -0
      bin/cabbage/Synths/bassline.snaps
  48. +280
    -0
      doc/GPL.txt
  49. +165
    -0
      doc/LGPL.txt
  50. +64
    -0
      libs/dgl/App.hpp
  51. +143
    -0
      libs/dgl/Base.hpp
  52. +206
    -0
      libs/dgl/CairoWidget.hpp
  53. +133
    -0
      libs/dgl/Geometry.hpp
  54. +68
    -0
      libs/dgl/Image.hpp
  55. +56
    -0
      libs/dgl/ImageAboutWindow.hpp
  56. +64
    -0
      libs/dgl/ImageButton.hpp
  57. +92
    -0
      libs/dgl/ImageKnob.hpp
  58. +86
    -0
      libs/dgl/ImageSlider.hpp
  59. +21
    -0
      libs/dgl/Makefile
  60. +79
    -0
      libs/dgl/StandaloneWindow.hpp
  61. +106
    -0
      libs/dgl/Widget.hpp
  62. +84
    -0
      libs/dgl/Window.hpp
  63. +22
    -0
      libs/dgl/build/premake.lua
  64. +133
    -0
      libs/dgl/src/App.cpp
  65. +49
    -0
      libs/dgl/src/Base.cpp
  66. +416
    -0
      libs/dgl/src/Geometry.cpp
  67. +198
    -0
      libs/dgl/src/Image.cpp
  68. +78
    -0
      libs/dgl/src/ImageAboutWindow.cpp
  69. +173
    -0
      libs/dgl/src/ImageButton.cpp
  70. +364
    -0
      libs/dgl/src/ImageKnob.cpp
  71. +325
    -0
      libs/dgl/src/ImageSlider.cpp
  72. +238
    -0
      libs/dgl/src/Widget.cpp
  73. +906
    -0
      libs/dgl/src/Window.cpp
  74. +357
    -0
      libs/dgl/src/pugl/pugl.h
  75. +161
    -0
      libs/dgl/src/pugl/pugl_internal.h
  76. +459
    -0
      libs/dgl/src/pugl/pugl_osx.m
  77. +37
    -0
      libs/dgl/src/pugl/pugl_osx_extended.h
  78. +71
    -0
      libs/dgl/src/pugl/pugl_osx_extended.m
  79. +387
    -0
      libs/dgl/src/pugl/pugl_win.cpp
  80. +397
    -0
      libs/dgl/src/pugl/pugl_x11.c
  81. +269
    -0
      libs/distrho/DistrhoPlugin.hpp
  82. +26
    -0
      libs/distrho/DistrhoPluginMain.cpp
  83. +94
    -0
      libs/distrho/DistrhoUI.hpp
  84. +25
    -0
      libs/distrho/DistrhoUIMain.cpp
  85. +684
    -0
      libs/distrho/DistrhoUtils.hpp
  86. +114
    -0
      libs/distrho/src/DistrhoDefines.h
  87. +107
    -0
      libs/distrho/src/DistrhoPlugin.cpp
  88. +376
    -0
      libs/distrho/src/DistrhoPluginInternal.hpp
  89. +702
    -0
      libs/distrho/src/DistrhoPluginLADSPA+DSSI.cpp
  90. +876
    -0
      libs/distrho/src/DistrhoPluginLV2.cpp
  91. +367
    -0
      libs/distrho/src/DistrhoPluginLV2export.cpp
  92. +1009
    -0
      libs/distrho/src/DistrhoPluginVST.cpp
  93. +89
    -0
      libs/distrho/src/DistrhoUI.cpp
  94. +489
    -0
      libs/distrho/src/DistrhoUIDSSI.cpp
  95. +249
    -0
      libs/distrho/src/DistrhoUIInternal.hpp
  96. +333
    -0
      libs/distrho/src/DistrhoUILV2.cpp
  97. +441
    -0
      libs/distrho/src/dssi/dssi.h
  98. +272
    -0
      libs/distrho/src/dssi/seq_event-compat.h
  99. +603
    -0
      libs/distrho/src/ladspa/ladspa.h
  100. +619
    -0
      libs/distrho/src/lv2/atom-forge.h

+ 76
- 0
.gitignore View File

@@ -0,0 +1,76 @@
*~
*.a
*.dll
*.dylib
*.exe
*.la
*.o
*.so
*.so.*

*.cdbs-orig
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h

*.lv2
*.make
*.pro.user
Makefile
Makefile.Debug
Makefile.Release
object_script.*.Debug
object_script.*.Release

.directory
.fuse*
.svn
.*.kate-swp
.DS_Store
.kdev_include_paths
.kdev4

bin/ladspa
bin/dssi
bin/lv2
bin/vst
bin/standalone
debian
intermediate
lv2_ttl_generator

libs/distrho/dgl/Makefile.copy
libs/juce-2.0/source/amalgamation/
libs/juce-2.0/source/docs/
libs/juce-2.0/source/extras/
libs/juce-2.0/source/modules/juce_box2d/
libs/juce-2.0/source/modules/juce_browser_plugin_client/
libs/juce-2.0/source/modules/juce_cryptography/
libs/juce-2.0/source/modules/juce_opengl/
libs/juce-2.0/source/modules/juce_video/
libs/juce-2.0/source/juce.h
libs/juce-2.0/source/juce_amalgamated.*

scripts/*.h
scripts/*.pro

sdks/ASIOSDK2/*
sdks/vstsdk2.4/*

_old
ports/_todo

libs/juce/source/.gitignore
libs/juce/source/amalgamation/
libs/juce/source/docs/
libs/juce/source/extras/
libs/juce/source/juce.h
libs/juce/source/juce_amalgamated.cpp
libs/juce/source/juce_amalgamated.h
libs/juce/source/juce_amalgamated.mm
libs/juce/source/modules/juce_box2d/
libs/juce/source/modules/juce_browser_plugin_client/
libs/juce/source/modules/juce_cryptography/
libs/juce/source/modules/juce_opengl/
libs/juce/source/modules/juce_video/

+ 9
- 0
DISTRHO.kdev4 View File

@@ -0,0 +1,9 @@
[Project]
Manager=KDevGenericManager
Name=DISTRHO

[Filters]
Excludes=*~,*.o

[Project]
VersionControlSupport=kdevgit

+ 99
- 0
Makefile View File

@@ -0,0 +1,99 @@
# -----------------------------------------
# Compile all the Plugins and Ports

PREFIX = /usr/local

# -----------------------------------------
# all

all:
$(MAKE) -C libs/dgl
$(MAKE) -C libs/drowaudio
$(MAKE) -C libs/juce
$(MAKE) -C libs/juced
$(MAKE) -C libs/lv2-ttl-generator
$(MAKE) -C plugins plugins
$(MAKE) -C ports plugins
$(MAKE) gen

# -----------------------------------------
# install

install:
install -d $(DESTDIR)$(PREFIX)/lib/ladspa/
install -d $(DESTDIR)$(PREFIX)/lib/dssi/
install -d $(DESTDIR)$(PREFIX)/lib/lv2/
install -d $(DESTDIR)$(PREFIX)/lib/vst/
cp -r bin/ladspa/* $(DESTDIR)$(PREFIX)/lib/ladspa/
cp -r bin/dssi/* $(DESTDIR)$(PREFIX)/lib/dssi/
cp -r bin/vst/* $(DESTDIR)$(PREFIX)/lib/vst/
cp -r bin/lv2/*.lv2/ static-lv2-ttl/*.lv2/ $(DESTDIR)$(PREFIX)/lib/lv2/

# -----------------------------------------
# gen

gen: gen_lv2 gen_vst

gen_lv2:
$(MAKE) -C libs/lv2-ttl-generator
@./scripts/generate-cabbage-lv2.sh
@./scripts/generate-ttl.sh

gen_vst:
@./scripts/generate-cabbage-vst.sh

# -----------------------------------------
# clean

clean:
$(MAKE) clean -C libs/dgl
$(MAKE) clean -C libs/drowaudio
$(MAKE) clean -C libs/juce
$(MAKE) clean -C libs/juced
$(MAKE) clean -C libs/lv2-ttl-generator
$(MAKE) clean -C plugins
$(MAKE) clean -C ports
rm -rf bin/lv2/*.lv2/

distclean: clean
$(MAKE) distclean -C libs/dgl
$(MAKE) distclean -C libs/drowaudio
$(MAKE) distclean -C libs/juce
$(MAKE) distclean -C libs/juced
$(MAKE) distclean -C plugins
$(MAKE) distclean -C ports

# -----------------------------------------
# mingw

mingw:
$(MAKE) -C libs/lv2-ttl-generator mingw

# -----------------------------------------
# Custom build types

ladspa:
$(MAKE) -C plugins ladspa

dssi:
$(MAKE) -C libs/dgl
$(MAKE) -C plugins dssi

lv2:
$(MAKE) -C libs/dgl
$(MAKE) -C libs/drowaudio
$(MAKE) -C libs/juce
$(MAKE) -C libs/juced
$(MAKE) -C libs/lv2-ttl-generator
$(MAKE) -C plugins lv2
$(MAKE) -C ports lv2
$(MAKE) gen_lv2

vst:
$(MAKE) -C libs/dgl
$(MAKE) -C libs/drowaudio
$(MAKE) -C libs/juce
$(MAKE) -C libs/juced
$(MAKE) -C plugins vst
$(MAKE) -C ports vst
$(MAKE) gen_vst

+ 5
- 0
TODO View File

@@ -0,0 +1,5 @@
test new cabbage code
install new cabbage files (html, others?)
report all bugs upstream

fix dgl keyboard input bug

+ 101
- 0
bin/cabbage-todo/Effects/AutopanTremolo.csd View File

@@ -0,0 +1,101 @@
<Cabbage>
form caption("Autopan / Tremolo") size(440, 102), pluginID("aptr")
image pos( 0, 0), size(440, 102), colour("Maroon"), shape("rounded"), outline("white"), line(4)
rslider bounds( 5, 6, 90, 90), text("Freq.[Hz]"), channel("rate"), range(0.1, 50, 0.5, 0.5), textBox(1)
rslider bounds( 80, 6, 90, 90), text("Tempo[BPM]"), channel("tempo"), range(6, 3000, 30, 0.5, 1), textBox(1)
rslider bounds(175, 6, 90, 90), text("Depth"), channel("depth"), range(0, 1.00, 1, 0.5), textBox(1)
rslider bounds(345, 6, 90, 90), text("Level"), channel("level"), range(0, 1.00, 1), textBox(1)
checkbox bounds(160, 15, 25, 25), colour("yellow"), channel("indicator"), value(0), shape("rounded")
combobox bounds(260, 13, 90,20), channel("mode"), value(1), text("Autopan", "Tremolo")
combobox bounds(260, 38, 90,20), channel("wave"), value(1), text("Sine", "Triangle", "Square", "Randomi", "Randomh")
checkbox bounds(260, 63, 90, 15), text("TEST TONE"), colour("lime"), channel("test"), value(0)


</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)

opcode PanTrem,aa,aakkkK
ainL,ainR,krate,kdepth,kmode,kwave xin ;READ IN INPUT ARGUMENTS
ktrig changed kwave ;IF LFO WAVEFORM TYPE IS CHANGED GENERATE A MOMENTARY '1' (BANG)
if ktrig=1 then ;IF A 'BANG' HAS BEEN GENERATED IN THE ABOVE LINE
reinit UPDATE ;BEGIN A REINITIALIZATION PASS FROM LABEL 'UPDATE' SO THAT LFO WAVEFORM TYPE CAN BE UPDATED
endif ;END OF THIS CONDITIONAL BRANCH
UPDATE: ;LABEL CALLED UPDATE
iwave init i(kwave)
iwave limit iwave, 0, 4 ;
if iwave==3 then ;if randomi chosen...
klfo randomi -kdepth,kdepth,krate,1
elseif iwave==4 then ;of randomh chosen...
klfo randomh -kdepth,kdepth,krate,1
else
klfo lfo kdepth, krate, iwave ;CREATE AN LFO
endif
rireturn ;RETURN FROM REINITIALIZATION PASS
klfo = (klfo*0.5)+0.5 ;RESCALE AND OFFSET LFO SO IT STAY WITHIN THE RANGE 0 - 1 ABOUT THE VALUE 0.5
if iwave=2||iwave==4 then ;IF SQUARE WAVE MODULATION HAS BEEN CHOSEN...
klfo portk klfo, 0.001 ;SMOOTH THE SQUARE WAVE A TINY BIT TO PREVENT CLICKS
endif ;END OF THIS CONDITIONAL BRANCH
if kmode=0 then ;PAN ;IF PANNING MODE IS CHOSEN FROM BUTTON BANK...
alfo interp klfo ;INTERPOLATE K-RATE LFO AND CREATE A-RATE VARIABLE
aoutL = ainL*sqrt(alfo) ;REDEFINE GLOBAL AUDIO LEFT CHANNEL SIGNAL WITH AUTO-PANNING
aoutR = ainR*(1-sqrt(alfo)) ;REDEFINE GLOBAL AUDIO RIGHT CHANNEL SIGNAL WITH AUTO-PANNING
kindicator = (klfo>0.5?1:0)
chnset kindicator,"indicator"
elseif kmode=1 then ;TREM ;IF TREMELO MODE IS CHOSEN FROM BUTTON BANK...
kindicator = (klfo>0.5?1:0)
chnset kindicator,"indicator"
klfo = klfo+(0.5-(kdepth*0.5)) ;MODIFY LFO AT ZERO DEPTH VALUE IS 1 AND AT MAX DEPTH CENTRE OF MODULATION IS 0.5
alfo interp klfo ;INTERPOLATE K-RATE LFO AND CREATE A-RATE VARIABLE
aoutL = ainL*(alfo^2) ;REDEFINE GLOBAL AUDIO LEFT CHANNEL SIGNAL WITH TREMELO
aoutR = ainR*(alfo^2) ;REDEFINE GLOBAL AUDIO RIGHT CHANNEL SIGNAL WITH TREMELO
endif ;END OF THIS CONDITIONAL BRANCH
xout aoutL,aoutR ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
krate chnget "rate"
ktempo chnget "tempo"
kdepth chnget "depth"
kmode chnget "mode"
kwave chnget "wave"
klevel chnget "level"
ktest chnget "test"

ktrig changed krate
ktrig2 changed ktempo
if ktrig=1 then
chnset krate*60,"tempo"
elseif ktrig2=1 then
chnset ktempo/60,"rate"
endif

if ktest=1 then
a1 vco2 0.2,300,4,0.5
a2 = a1
else
a1,a2 ins
endif

a1,a2 PanTrem a1,a2,krate,kdepth,kmode-1,kwave-1
a1 = a1 * klevel
a2 = a2 * klevel
outs a1,a2
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 73
- 0
bin/cabbage-todo/Effects/HighpassFilter.csd View File

@@ -0,0 +1,73 @@
<Cabbage>
form caption("Highpass Filter") size(435, 90), pluginID("HPFl")
image pos(0, 0), size(435, 90), colour( 70,120, 90), shape("rounded"), outline("white"), line(4)
label bounds(22, 22, 60, 11), text("INPUT"), fontcolour("black")
combobox bounds(10, 33, 60, 20), channel("input"), value(1), text("Live","Tone","Noise")
rslider bounds( 75, 11, 70, 70), channel("cf"), text("Freq."), colour( 0, 60, 30), tracker(200,255,200), fontcolour("white"), range(20, 20000, 20000, 0.333)
rslider bounds(140, 11, 70, 70), channel("res"), text("Res."), colour( 0, 60, 30), tracker(200,255,200), fontcolour("white"), range(0,1.00,0)
rslider bounds(205, 11, 70, 70), channel("mix"), text("Mix"), colour( 0, 60, 30), tracker(200,255,200), fontcolour("white"), range(0,1.00,1)
button bounds(280, 10, 80, 20), text("24dB/oct", "12dB/oct"), channel("steepness"), value(0)
label bounds(290, 30, 80, 12), text("Steepness"), fontcolour("black")
checkbox bounds(280, 50, 80, 15), channel("ResType"),colour(yellow), fontcolour("black"), value(0), text("Resonant")
rslider bounds(360, 11, 70, 70), text("Level"), colour( 0, 60, 30), tracker(200,255,200), fontcolour("white"), channel("level"), range(0, 1.00, 1)
image bounds(5, 95, 205, 20), colour(75, 85, 90, 100), plant("credit"), line(0){
label bounds(0.03, 0.1, .95, .7), text("Author: Iain McCurdy |2012|"), colour("white")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
kcf chnget "cf" ;
kres chnget "res" ;
kmix chnget "mix" ;
ksteepness chnget "steepness" ;
kResType chnget "ResType" ;
klevel chnget "level" ;
kporttime linseg 0,0.001,0.02
kcf portk kcf,kporttime
/* INPUT */
kinput chnget "input"
if kinput=1 then
aL,aR ins
elseif kinput=2 then
aL vco2 0.2, 100
aR = aL
else
aL pinkish 0.2
aR pinkish 0.2
endif
if ksteepness==0&&kResType!=1 then
aFiltL atone aL,kcf
aFiltR atone aR,kcf
elseif ksteepness==1&&kResType!=1 then
aFiltL buthp aL,kcf
aFiltR buthp aR,kcf
elseif kResType==1 then
aFiltL bqrez aL,kcf,1+(kres*40),1
aFiltR bqrez aR,kcf,1+(kres*40),1
endif
aL ntrpol aL,aFiltL,kmix
aR ntrpol aR,aFiltR,kmix
outs aL*klevel,aR*klevel
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 71
- 0
bin/cabbage-todo/Effects/LowpassFilter.csd View File

@@ -0,0 +1,71 @@
<Cabbage>
form caption("Lowpass Filter") size(435, 90), pluginID("LPFl")
image pos(0, 0), size(435, 90), colour( 70, 90,100), shape("rounded"), outline("white"), line(4)
label bounds( 22, 22, 60, 11), text("INPUT"), fontcolour("white")
combobox bounds( 10, 33, 60, 20), channel("input"), value(1), text("Live","Tone","Noise")
rslider bounds( 75, 11, 70, 70), channel("cf"), text("Freq."), colour( 0, 40, 50), tracker(200,240,250), fontcolour("white"), range(20, 20000, 20000, 0.333)
rslider bounds(140, 11, 70, 70), channel("res"), text("Res."), colour( 0, 40, 50), tracker(200,240,250), fontcolour("white"), range(0,1.00,0)
rslider bounds(205, 11, 70, 70), channel("mix"), text("Mix"), colour( 0, 40, 50), tracker(200,240,250), fontcolour("white"), range(0,1.00,1)
button bounds(280, 10, 80, 20), channel("steepness"), text("24dB/oct", "12dB/oct"), value(0)
label bounds(290, 30, 80, 12), text("Steepness"), FontColour("white")
checkbox bounds(280, 50, 80, 15), channel("ResType"), FontColour("white"), value(0), text("Resonant"), colour(yellow)
rslider bounds(360, 11, 70, 70), text("Level"), colour( 0, 40, 50), tracker(200,240,250), fontcolour("white"), channel("level"), range(0, 1.00, 1)
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
kcf chnget "cf" ;
kres chnget "res" ;
kmix chnget "mix" ;
ksteepness chnget "steepness" ;
kResType chnget "ResType" ;
klevel chnget "level" ;
kporttime linseg 0,0.001,0.02
kcf portk kcf,kporttime
/* INPUT */
kinput chnget "input"
if kinput=1 then
aL,aR ins
elseif kinput=2 then
aL vco2 0.2, 100
aR = aL
else
aL pinkish 0.2
aR pinkish 0.2
endif
if ksteepness==0&&kResType!=1 then
aFiltL tone aL,kcf
aFiltR tone aR,kcf
elseif ksteepness==1&&kResType!=1 then
aFiltL butlp aL,kcf
aFiltR butlp aR,kcf
elseif kResType==1 then
aFiltL moogladder aL,kcf,kres
aFiltR moogladder aR,kcf,kres
endif
aL ntrpol aL,aFiltL,kmix
aR ntrpol aR,aFiltR,kmix
outs aL*klevel,aR*klevel
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 76
- 0
bin/cabbage-todo/Effects/MultiReverb.csd View File

@@ -0,0 +1,76 @@
Reverb effect that employs screverb and freeverb opcodes.
Pitch Mod. is only used by reverbsc.

<Cabbage>
form caption("Multi Reverb") size(415, 90), pluginID("Rvrb")
image bounds( 7, 22, 73, 45), colour( 39, 31, 20), shape("rounded"), outline(white), line(1)
image bounds(0, 0, 415, 90), colour( 39, 31, 20), shape("rounded"), outline("white"), line(4)
label bounds( 29, 26, 60, 12), text("Type"), fontColour(white)
button bounds( 11, 40, 66, 20), text("freeverb", "screverb"), channel("type"), value(0), fontcolour("lime")
rslider bounds( 80, 11, 70, 70), text("Size"), fontcolour(white), channel("fblvl"), range(0, 1.00, 0.8), colour( 79, 81, 70), tracker(240,210,170)
rslider bounds(145, 11, 70, 70), text("Damping"), fontcolour(white), channel("fco"), range(0, 1.00, 0.6), colour( 79, 81, 70), tracker(240,210,170)
rslider bounds(210, 11, 70, 70), text("Pitch Mod."), fontcolour(white), channel("pitchm"), range(0, 20.0, 1), colour( 79, 81, 70), tracker(240,210,170)
rslider bounds(275, 11, 70, 70), text("Mix"), fontcolour(white), channel("mix"), range(0, 1.00, 1), colour( 79, 81, 70), tracker(240,210,170)
rslider bounds(340, 11, 70, 70), text("Level"), fontcolour(white), channel("amp"), range(0, 1.00, 1), colour( 79, 81, 70), tracker(240,210,170)
}
image bounds(5, 95, 205, 20), colour(75, 85, 90, 100), plant("credit"), line(0){
label bounds(0.03, 0.1, .95, .7), text("Author: Iain McCurdy |2012|"), colour("white")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
ktype chnget "type" ;READ WIDGETS...
kfblvl chnget "fblvl" ;
kfco chnget "fco" ;
kpitchm chnget "pitchm" ;
kmix chnget "mix" ;
kamp chnget "amp" ;

ainL,ainR ins
denorm ainL, ainR ;DENORMALIZE BOTH CHANNELS OF AUDIO SIGNAL
if ktype==0 then
kfco expcurve kfco, 4 ;CREATE A MAPPING CURVE TO GIVE A NON LINEAR RESPONSE
kfco scale kfco,20000,20 ;RESCALE 0 - 1 TO 20 TO 20000
kSwitch changed kpitchm ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if kSwitch=1 then ;IF kSwitch=1 THEN
reinit UPDATE ;BEGIN A REINITIALIZATION PASS FROM LABEL 'UPDATE'
endif ;END OF CONDITIONAL BRANCHING
UPDATE: ;A LABEL
arvbL, arvbR reverbsc ainL, ainR, kfblvl, kfco, sr, i(kpitchm)
rireturn ;RETURN TO PERFORMANCE TIME PASSES
else
arvbL, arvbR freeverb ainL, ainR, kfblvl, 1-kfco
endif
amixL ntrpol ainL, arvbL, kmix ;CREATE A DRY/WET MIX BETWEEN THE DRY AND THE REVERBERATED SIGNAL
amixR ntrpol ainR, arvbR, kmix ;CREATE A DRY/WET MIX BETWEEN THE DRY AND THE REVERBERATED SIGNAL
outs amixL * kamp, amixR * kamp
endin

instr 3 ;workaround for failure of these widgets from intiialising properly when used as a plugin
;chnset 12000,"fco"
chnset 1,"pitchm"
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
i 3 0 0
</CsScore>

</CsoundSynthesizer>

+ 96
- 0
bin/cabbage-todo/Effects/clip.csd View File

@@ -0,0 +1,96 @@
<Cabbage>
form caption("clip") size(315, 90), pluginID("clip")
image bounds(0, 0, 315, 90), colour( 0, 10, 20), shape("rounded"), outline("white"), line(4)
rslider bounds( 10, 11, 70, 70), text("Limit"), channel("limit"), range(0.001, 1, 1, 0.5,0.001) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
rslider bounds( 75, 11, 70, 70), text("Argument"), channel("arg"), range(0, 1.00, 0.5) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
combobox bounds(150, 15, 80,20), channel("method"), size(80,50), value(1), text("B.D.J.", "Sine", "Tanh")
checkbox bounds(150, 45, 100, 20), channel("clip_light"), text("clip") fontcolour("white"), shape("rounded"), colour("red")
rslider bounds(235, 11, 70, 70), text("Level"), channel("level"), range(0, 10.00, 0.7) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
gklimit chnget "limit" ;READ WIDGETS...
gkmethod chnget "method" ;
gkmethod init 1
gkmethod init i(gkmethod)-1
gkarg chnget "arg"
gklevel chnget "level" ;
;asigL, asigR diskin2 "Seashore.wav",1,0,1 ;OPTIONALLY USE A BUILT-IN WAVEFORM FOR TESTING
asigL, asigR ins
kSwitch changed gklimit, gkmethod, gkarg ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if kSwitch=1 then ;IF A VARIABLE CHANGE INDICATOR IS RECEIVED...
reinit START ;...BEGIN A REINITIALISATION PASS FROM LABEL 'START'
endif ;END OF CONDITIONAL BRANCHING
START: ;LABEL
/* clip meter */
krmsL rms asigL
krmsR rms asigR
kon = 1
koff = 0
if(krmsL>gklimit||krmsR>gklimit) then
chnset kon,"clip_light"
else
chnset koff,"clip_light"
endif
/*------------*/
aL clip asigL, i(gkmethod), i(gklimit), i(gkarg)
aR clip asigR, i(gkmethod), i(gklimit), i(gkarg)
rireturn ;RETURN TO PERFORMANCE PASSES FROM INITIALISATION PASS
; outs aL*gklevel*(1/(gklimit^0.5)), aR*gklevel*(1/(gklimit^0.5)) ;pdclip OUTPUTS ARE SENT TO THE SPEAKERS
outs aL*gklevel, aR*gklevel ;pdclip OUTPUTS ARE SENT TO THE SPEAKERS
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>


</CsoundSynthesizer>




























+ 98
- 0
bin/cabbage-todo/Effects/pdclip.csd View File

@@ -0,0 +1,98 @@
<Cabbage>
form caption("pdclip") size(315, 90), pluginID("pdcl")
label bounds( 0, -8,315, 90), colour(20,100,100,200), fontcolour(70,150,150,200), text("pdclip"), shape("rounded"), outline("white"), line(4)
image bounds( 0, 0,315, 90), colour(10,100,200,200), shape("rounded"), outline("white"), line(4)
rslider bounds( 10, 11, 70, 70), text("Width"), channel("width"), range(0, 1.00, 0),fontcolour("white"), colour(20, 70,120), tracker("yellow")
rslider bounds( 75, 11, 70, 70), text("Centre"), channel("center"), range(-1.00, 1.00, 0),fontcolour("white"), colour(20, 70,120), tracker("yellow")
combobox bounds(150, 20, 80, 20), channel("bipolar"), size(80,50), value(2), text("Unipolar", "Bipolar")
checkbox bounds(150, 48,130, 12), channel("TestTone"), FontColour("white"), value(0), text("Sine Tone"), colour(yellow)
rslider bounds(235, 11, 70, 70), text("Level"), channel("level"), range(0, 1.00, 0.7),fontcolour("white"), colour(20, 70,120), tracker("yellow")
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

gisine ftgen 0,0,4096,10,1

instr 1
kporttime linseg 0,0.001,0.05 ; portamento time ramps up from zero
gkwidth chnget "width" ;READ WIDGETS...
gkwidth portk gkwidth,kporttime
gkcenter chnget "center" ;
gkcenter portk gkcenter,kporttime
gkbipolar chnget "bipolar" ;
gkbipolar init 1
gkbipolar = gkbipolar-1
gklevel chnget "level" ;
gklevel portk gklevel,kporttime
gkTestTone chnget "TestTone"
if gkTestTone==1 then ; if test tone selected...
koct rspline 4,8,0.2,0.5
asigL poscil 1,cpsoct(koct),gisine ; ...generate a tone
asigR = asigL ; right channel equal to left channel
else ; otherwise...
asigL, asigR ins ; read live inputs
endif

ifullscale = 0dbfs ;DEFINE FULLSCALE AMPLITUDE VALUE
kSwitch changed gkbipolar ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if kSwitch=1 then ;IF A VARIABLE CHANGE INDICATOR IS RECEIVED...
reinit START ;...BEGIN A REINITIALISATION PASS FROM LABEL 'START'
endif ;END OF CONDITIONAL BRANCHING
START: ;LABEL
;CLIP THE AUDIO SIGNAL USING pdclip
aL pdclip asigL, gkwidth, gkcenter, i(gkbipolar) ; [, ifullscale]]
aR pdclip asigR, gkwidth, gkcenter, i(gkbipolar) ; [, ifullscale]]
rireturn ;RETURN TO PERFORMANCE PASSES FROM INITIALISATION PASS
alevel interp gklevel
outs aL * alevel, aR * alevel ;pdclip OUTPUT ARE SENT TO THE SPEAKERS
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>


</CsoundSynthesizer>




























+ 134
- 0
bin/cabbage-todo/Effects/resony.csd View File

@@ -0,0 +1,134 @@
resony.csd

Resony is an implementation of a stack of second-order bandpass filters whose centre frequencies are arithmetically related.
The 'bandwidth' and 'scaling mode' parameters are as they are in the reson opcode.
'inum' (number of filters) defines the number of filters in the stack.
'ksep' (separation) normally defines the separation between the lowest and highest filter in the stack in octaves. How this relates to what the actual centre frequencies of filters will be differs depending upon which separation mode has been selected. This is explained below. Note that in this example the operation of 'ksep' has been modified slightly to allow the opcode to be better controlled from the GUI. These modifications are clarified below. Separation can be defined in octaves using the knob 'Sep.oct.' or in semitones using the 'Sep.semi.' knob.
'kbf' (base frequency) defines the centre frequency of the first filter. In 'oct.total' separation mode the pitch interval between the base frequency and (base frequency + separation) is divided into equal intervals according to the number of filters that have been selected. Note that no filter is created at the frequency of (base frequency + separation). For example: if separation=1 and num.filters=2, filters will be created at the base frequency and a tritone above the base frequency (i.e. an interval of 1/2 and an octave). I suspect this is a mistake in the opcode implementation so in this example I rescale the separation interval before passing it to the resony opcode so that the interval between the lowest and highest filter in this mode will always be the interval defined in the GUI. A further option I have provided allows the defined interval to be the interval between adjacent filters rather than the interval from lowest to highest. If 'hertz' separation mode is selected behaviour is somewhat curious. I have made some modifications to the values passed to the opcode to make this mode more controllable. Without these modifications, if number of filters is '1' no filters would be created. The frequency relationship between filters in the stack always follows the harmonic series. Both 'Base Frequency' and 'Separation' normally shift this harmonic stack of filters up or down, for this reason I have disabled user control of 'Separation' in this example, instead a value equal to the 'Number of Filters' will always be used for 'Separation'. This ensures that a harmonic stack will always be created built upon 'Base Frequency' as the fundamental. Negative values for 'separation' are allowed whenever 'separation mode' is 'octaves' (if this is the case, the stack of frequencies will extend below the base frequency). Negative values for 'separation' when 'separation mode' is 'hertz' will cause filters to 'explode'. As 'Separation' is fixed at 'Number of Filters' in this example this explosion will not occur.

<Cabbage>
form caption("resony") size(810, 90), pluginID("rsny"), colour(255,100,0,255)
image bounds( 0, 0,810, 90), colour("black"), shape("rounded"), outline("white"), line(4)
button bounds( 10, 20, 80, 50), text("Noise", "Live"), channel("input"), value(0), fontcolour("lime")
rslider bounds( 90, 10, 70, 70), text("BF."), fontcolour("white"), channel("bf"), range(20, 20000, 909, 0.5), colour("red")
rslider bounds(160, 10, 70, 70), text("BW."), fontcolour("white"), channel("bw"), range(0.01, 1000, 13, 0.5), colour("red")
rslider bounds(230, 10, 70, 70), text("Num."), fontcolour("white"), channel("num"), range(1, 80, 10, 1,1), colour("red")
rslider bounds(300, 10, 70, 70), text("Sep.oct."), fontcolour("white"), channel("sep"), range(-11, 11, 2), colour("red")
rslider bounds(370, 10, 70, 70), text("Sep.semi."), fontcolour("white"), channel("sep2"), range(-48, 48, 24,1,1), colour("red")
combobox bounds(450, 10,130, 70), caption("Scaling Mode"), channel("scl"), value(2), text("none", "peak response", "RMS")
combobox bounds(590, 10,130, 70), caption("Separation Mode"), channel("sepmode"), value(1), text("octs.total", "hertz", "octs.adjacent")
rslider bounds(730, 10, 70, 70), text("Level"), fontcolour("white"), channel("gain"), range(0.0001, 1, 30, 0.5), colour("red")
}
image bounds(5, 95, 205, 20), colour(100,100,100,80), plant("credit"), line(0){
label bounds(0.03, 0.1, .95, .7), text("Author: Iain McCurdy |2012|"), fontcolour("white")
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

;A UDO IS CREATED WHICH ENCAPSULATES THE MODIFICATIONS TO THE resony OPCODE DISCUSSED IN THIS EXAMPLE
opcode resony2,a,akkikii
ain, kbf, kbw, inum, ksep , isepmode, iscl xin

;IF 'Octaves (Total)' MODE SELECTED...
if isepmode==0 then
irescale divz inum,inum-1,1 ;PREVENT ERROR IS NUMBER OF FILTERS = ZERO
ksep = ksep * irescale ;RESCALE SEPARATION
;IF 'Hertz' MODE SELECTED...
elseif isepmode==1 then
inum = inum + 1
ksep = inum

;IF 'Octaves (Adjacent)' MODE SELECTED...
elseif isepmode==2 then
irescale divz inum,inum-1,1 ;PREVENT ERROR IS NUMBER OF FILTERS = ZERO
ksep = ksep * irescale ;RESCALE SEPARATION
ksep = ksep * (inum-1) ;RESCALE SEPARATION INTERVAL ACCORDING TO THE NUMBER OF FILTERS CHOSEN
isepmode = 0
endif

aout resony ain, kbf, kbw, inum, ksep , isepmode, iscl, 0
xout aout
endop


instr 1
kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
gkbf chnget "bf"
gkbw chnget "bw"
gkgain chnget "gain"
gknum chnget "num"
gksep chnget "sep"
gksep2 chnget "sep2"
gksepmode chnget "sepmode"
gksepmode = gksepmode - 1
gksepmode init 1
gkscl chnget "scl"
gkscl = gkscl - 1
gkscl init 1
gkinput chnget "input"

kbf portk gkbf, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE TO CREATE BASE FREQUENCY

ksep portk gksep, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE

if gkinput==0 then
asigL,asigR ins
else
asigL pinkish 1
asigR pinkish 1
endif

kSwitch changed gkscl, gknum, gksepmode ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
endif
START:
isepmode init i(gksepmode)
inum init i(gknum)
iscl init i(gkscl)
;CALL resony2 UDO
aresL resony2 asigL, kbf, gkbw, inum, ksep , isepmode, iscl
aresR resony2 asigR, kbf, gkbw, inum, ksep , isepmode, iscl

rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
outs aresL * gkgain, aresR * gkgain ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER VARIABLE gkgain
endin

instr UpdateWidgets
ksep chnget "sep"
ksep2 chnget "sep2"
ktrig1 changed ksep
ktrig2 changed ksep2
if ktrig1==1 then
chnset ksep*12, "sep2"
elseif ktrig2==1 then
chnset ksep2/12, "sep"
endif
endin

</CsInstruments>

<CsScore>
i 1 0.1 [3600*24*7]
i "UpdateWidgets" 0 3600 ;UPDATE SEPARATION DISPLAY BOX
</CsScore>

</CsoundSynthesizer>

+ 103
- 0
bin/cabbage-todo/Effects/waveset.csd View File

@@ -0,0 +1,103 @@
waveset.csd

reinit seems a bit disruptive in Cabbage 3.03?
'freeze' is not technically a freeze but instead a very large number of repeats.

Waveset opcode can be reinitialised by three different methods:
Manually using the 'Reset' button,
by a built-in metronome, the rate of which can be adjusted by the user
or by the dynamics of the input sound (the threshold of this dynamic triggereing can be adjusted by the user)
'Metro' resetting is disabled when 'Metro Rate' = 0
'Threshold' (retrigering by input signal dynamics) is disabled when 'Threshold' = 1 (maximum setting)
(resetting the opcode will reset its internal buffer and cancel out any time displacement induced by wavelet repetitions)

<Cabbage>
form caption("waveset") size(510, 90), pluginID("wset")
image pos(0, 0), size(510, 90), colour("Green"), shape("rounded"), outline("Grey"), line(4)
rslider bounds(5, 10, 70, 70), text("Repeats"), channel("repeats"), range(1, 100, 1, 1, 1), colour("yellow"), fontcolour("white")
rslider bounds(70, 10, 70, 70), text("Mult."), channel("mult"), range(1, 100, 1, 0.5, 1), colour("yellow"), fontcolour("white")
checkbox bounds(140, 23, 100, 30), channel("freeze"), text("Freeze"), value(0), colour("red"), fontcolour("white"), shape("ellipse")
line bounds(220, 2, 3, 86), colour("Grey")
button bounds(235, 15, 45,45), channel("reset"), text("Reset","Reset"), fontcolour("yellow")
rslider bounds(290, 10, 70, 70), text("Threshold"), channel("thresh"), range(0, 1.00, 1), colour("orange"), fontcolour("white")
rslider bounds(355, 10, 70, 70), text("Metro Rate"), channel("rate"), range(0, 5.00, 0), colour("orange"), fontcolour("white")
line bounds(430, 2, 3, 86), colour("Grey")
rslider bounds(435, 10, 70, 70), text("Level"), channel("level"), range(0, 1.00, 0.7), colour(255,150, 50), fontcolour("white")
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
krep chnget "repeats" ;READ WIDGETS...
kmult chnget "mult" ;
klevel chnget "level" ;
kreset chnget "reset" ;
kthresh chnget "thresh" ;
krate chnget "rate" ;
ktrigger changed kreset ;
kmetro metro krate, 0.99
kfreeze chnget "freeze"
;asigL, asigR diskin2 "Songpan.wav",1,0,1 ;USE SOUND FILE FOR TESTING
asigL, asigR ins
krms rms (asigL+asigR)*0.5
kDynTrig trigger krms,kthresh,0

if (ktrigger+kmetro+kDynTrig)>0 then
reinit UPDATE
endif
UPDATE:
aL waveset asigL,(krep*kmult)+(kfreeze*1000000000),5*60*sr ;PASS THE AUDIO SIGNAL THROUGH waveset OPCODE. Input duration is defined in samples - in this example the expression given equats to a 5 minute buffer
aR waveset asigR,(krep*kmult)+(kfreeze*1000000000),5*60*sr ;PASS THE AUDIO SIGNAL THROUGH waveset OPCODE. Input duration is defined in samples - in this example the expression given equats to a 5 minute buffer
rireturn
outs aL*klevel, aR*klevel ;WAVESET OUTPUT ARE SENT TO THE SPEAKERS
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>


</CsoundSynthesizer>




























+ 370
- 0
bin/cabbage-todo/Synths/Choir.csd View File

@@ -0,0 +1,370 @@
Choir.csd

Note velocity is interpretted as attack time (along with a slight interpretation as amplitude)
If N.Voices (number of voices) is set to '1' chorussing effect is bypassed, instead a fundemental modulation mechanism is enabled
Vibrato/tremolo depth also controllable using midi controller 1 (mod. wheel), midi channel 1
Vowel is controllable using midi controller 2, midi channel 1
N.Voices value is not strictly speaking accurate: 1 = 1 voice
2 = 2 voices
3 = 4 voices
4 = 6 voices
5 = 8 voices, this is on account of how the mechanism implements a stereo effect

<Cabbage>
form caption("Choir") size(770, 335), pluginID("choi")
; main container
image bounds( 0, 0,770, 360), colour(255,100, 0, 40), shape("rounded"), outline("white"), line(3)
; horizontal stripes
image bounds( 0, 40,770, 75), colour(100,100, 0, 60), shape("sharp")
image bounds( 0,130,770, 35), colour( 0, 0,255, 60), shape("sharp")
; vertical stripes
image bounds(310, 0, 30, 360), colour( 5,255, 0, 60), shape("sharp")
image bounds(370, 0, 80, 360), colour(255, 0,200, 60), shape("sharp")
image bounds(490, 0, 60, 360), colour( 0,255,200, 60), shape("sharp")
image bounds(560, 0, 40, 360), colour(100, 55,200, 60), shape("sharp")
image bounds(620, 0, 20, 360), colour(255, 55, 0, 60), shape("sharp")
image bounds(660, 0, 90, 360), colour( 5,255,100, 60), shape("sharp")

xypad bounds(10, 10, 250, 210), channel("vowel", "oct"), text("X = Vowel 'AEIOU' : Y = Octave Division"), rangex(0, 1, 0), rangey(0, 4, 0)
combobox bounds(265, 10, 110, 25), channel("voice"), value(5), text("Bass", "Tenor", "Countertenor", "Alto", "Soprano")
button bounds(265, 40, 110, 25), text("monophonic", "polyphonic"), channel("monopoly"), value(1), fontcolour("lime")
rslider bounds(385, 10, 60, 60), text("Leg.Time"), channel("LegTim"), range(0.005, 0.3, 0.025, 0.5, 0.005) ,colour("green"), tracker("white")
rslider bounds(445, 10, 60, 60), text("Vowel"), channel("vowel"), range(0, 1.00, 0) ,colour("green"),midCtrl(1, 2), tracker("white")
rslider bounds(505, 10, 60, 60), text("Level"), channel("lev"), range(0, 1.00, 0.6) ,colour("green"), tracker("white")
rslider bounds(265, 80, 60, 60), text("Vib.Dep."), channel("vibdep"), range(0, 2.00, 0.35) ,colour("tomato"),midCtrl(1, 1), tracker("white")
rslider bounds(325, 80, 60, 60), text("Trem.Dep."), channel("trmdep"), range(0, 1.00, 0.2) ,colour("tomato"),midCtrl(1, 1), tracker("white")
rslider bounds(385, 80, 60, 60), text("Mod.Rate"), channel("modrte"), range(0.10,20, 5, 0.5) ,colour("tomato"), tracker("white")
rslider bounds(445, 80, 60, 60), text("Mod.Delay"), channel("moddel"), range(0, 2.00, 0.3, 0.5) ,colour("tomato"), tracker("white")
rslider bounds(505, 80, 60, 60), text("Mod.Rise"), channel("modris"), range(0, 4.00, 2, 0.5) ,colour("tomato"), tracker("white")
rslider bounds(265,150, 60, 60), text("N.Voices"), channel("nvoices"), range(1, 50, 6, 1, 1) ,colour("yellow"), tracker("white")
rslider bounds(325,150, 60, 60), text("Dtn.Dep."), channel("DtnDep"), range(0, 4.00, 1, 0.5) ,colour("yellow"), tracker("white")
rslider bounds(385,150, 60, 60), text("Dtn.Rate"), channel("DtnRte"), range(0.01,40, 0.2, 0.25) ,colour("yellow"), tracker("white")
rslider bounds(445,150, 60, 60), text("Rvb.Mix"), channel("RvbMix"), range(0, 1.00, 0.15) ,colour("steelblue"), tracker("white")
rslider bounds(505,150, 60, 60), text("Rvb.Size"), channel("RvbSize"), range(0.5, 1.00, 0.82, 2) ,colour("steelblue"), tracker("white")
checkbox bounds(570, 10,190, 20), text("Filter On/Off") channel("FiltOnOff"), colour("lime") value(0)
xypad bounds(570, 35, 190, 185), channel("cf", "bw"), text("x:c.off/y:b.width"), rangex(5, 13, 8), rangey(0.1, 5, 0.3)

keyboard pos(10, 225), size(760, 80)
image bounds(10, 309, 250, 22), colour(75, 85, 90, 100), plant("credit"){
label bounds(0.03, 0.15, .99, .7), text("Author: Iain McCurdy |2012|"), colour("white")
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
massign 0,2
seed 0

;Author: Iain McCurdy (2012)

gisine ftgen 0, 0, 4096, 10, 1 ;SINE WAVE
giexp ftgen 0, 0, 1024, 19, 0.5, 0.5, 270, 0.5 ;EXPONENTIAL CURVE USED TO DEFINE THE ENVELOPE SHAPE OF FOF PULSES
gasendL,gasendR init 0

;FUNCTION TABLES STORING DATA FOR VARIOUS VOICE FORMANTS
;THE FIRST VALUE OF EACH TABLE DEFINES THE NUMBER OF DATA ELEMENTS IN THE TABLE
;THIS IS NEEDED BECAUSE TABLES SIZES MUST BE POWERS OF 2 TO FACILITATE INTERPOLATED TABLE READING (tablei)
;BASS
giBF1 ftgen 0, 0, 8, -2, 4, 600, 400, 250, 350 ;FREQ
giBF2 ftgen 0, 0, 8, -2, 4, 1040, 1620, 1750, 600 ;FREQ
giBF3 ftgen 0, 0, 8, -2, 4, 2250, 2400, 2600, 2400 ;FREQ
giBF4 ftgen 0, 0, 8, -2, 4, 2450, 2800, 3050, 2675 ;FREQ
giBF5 ftgen 0, 0, 8, -2, 4, 2750, 3100, 3340, 2950 ;FREQ
giBDb1 ftgen 0, 0, 8, -2, 4, 0, 0, 0, 0 ;dB
giBDb2 ftgen 0, 0, 8, -2, 4, -7, -12, -30, -20 ;dB
giBDb3 ftgen 0, 0, 8, -2, 4, -9, -9, -16, -32 ;dB
giBDb4 ftgen 0, 0, 8, -2, 4, -9, -12, -22, -28 ;dB
giBDb5 ftgen 0, 0, 8, -2, 4, -20, -18, -28, -36 ;dB
giBBW1 ftgen 0, 0, 8, -2, 4, 60, 40, 60, 40 ;BAND WIDTH
giBBW2 ftgen 0, 0, 8, -2, 4, 70, 80, 90, 80 ;BAND WIDTH
giBBW3 ftgen 0, 0, 8, -2, 4, 110, 100, 100, 100 ;BAND WIDTH
giBBW4 ftgen 0, 0, 8, -2, 4, 120, 120, 120, 120 ;BAND WIDTH
giBBW5 ftgen 0, 0, 8, -2, 4, 130, 120, 120, 120 ;BAND WIDTH
;TENOR
giTF1 ftgen 0, 0, 8, -2, 5, 650, 400, 290, 400, 350 ;FREQ
giTF2 ftgen 0, 0, 8, -2, 5, 1080, 1700, 1870, 800, 600 ;FREQ
giTF3 ftgen 0, 0, 8, -2, 5, 2650, 2600, 2800, 2600, 2700 ;FREQ
giTF4 ftgen 0, 0, 8, -2, 5, 2900, 3200, 3250, 2800, 2900 ;FREQ
giTF5 ftgen 0, 0, 8, -2, 5, 3250, 3580, 3540, 3000, 3300 ;FREQ
giTDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
giTDb2 ftgen 0, 0, 8, -2, 5, -6, -14, -15, -10, -20 ;dB
giTDb3 ftgen 0, 0, 8, -2, 5, -7, -12, -18, -12, -17 ;dB
giTDb4 ftgen 0, 0, 8, -2, 5, -8, -14, -20, -12, -14 ;dB
giTDb5 ftgen 0, 0, 8, -2, 5, -22, -20, -30, -26, -26 ;dB
giTBW1 ftgen 0, 0, 8, -2, 5, 80, 70, 40, 40, 40 ;BAND WIDTH
giTBW2 ftgen 0, 0, 8, -2, 5, 90, 80, 90, 80, 60 ;BAND WIDTH
giTBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 100 ;BAND WIDTH
giTBW4 ftgen 0, 0, 8, -2, 5, 130, 120, 120, 120, 120 ;BAND WIDTH
giTBW5 ftgen 0, 0, 8, -2, 5, 140, 120, 120, 120, 120 ;BAND WIDTH
;COUNTER TENOR
giCTF1 ftgen 0, 0, 8, -2, 5, 660, 440, 270, 430, 370 ;FREQ
giCTF2 ftgen 0, 0, 8, -2, 5, 1120, 1800, 1850, 820, 630 ;FREQ
giCTF3 ftgen 0, 0, 8, -2, 5, 2750, 2700, 2900, 2700, 2750 ;FREQ
giCTF4 ftgen 0, 0, 8, -2, 5, 3000, 3000, 3350, 3000, 3000 ;FREQ
giCTF5 ftgen 0, 0, 8, -2, 5, 3350, 3300, 3590, 3300, 3400 ;FREQ
giTBDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
giTBDb2 ftgen 0, 0, 8, -2, 5, -6, -14, -24, -10, -20 ;dB
giTBDb3 ftgen 0, 0, 8, -2, 5, -23, -18, -24, -26, -23 ;dB
giTBDb4 ftgen 0, 0, 8, -2, 5, -24, -20, -36, -22, -30 ;dB
giTBDb5 ftgen 0, 0, 8, -2, 5, -38, -20, -36, -34, -30 ;dB
giTBW1 ftgen 0, 0, 8, -2, 5, 80, 70, 40, 40, 40 ;BAND WIDTH
giTBW2 ftgen 0, 0, 8, -2, 5, 90, 80, 90, 80, 60 ;BAND WIDTH
giTBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 100 ;BAND WIDTH
giTBW4 ftgen 0, 0, 8, -2, 5, 130, 120, 120, 120, 120 ;BAND WIDTH
giTBW5 ftgen 0, 0, 8, -2, 5, 140, 120, 120, 120, 120 ;BAND WIDTH
;ALTO
giAF1 ftgen 0, 0, 8, -2, 5, 800, 400, 350, 450, 325 ;FREQ
giAF2 ftgen 0, 0, 8, -2, 5, 1150, 1600, 1700, 800, 700 ;FREQ
giAF3 ftgen 0, 0, 8, -2, 5, 2800, 2700, 2700, 2830, 2530 ;FREQ
giAF4 ftgen 0, 0, 8, -2, 5, 3500, 3300, 3700, 3500, 2500 ;FREQ
giAF5 ftgen 0, 0, 8, -2, 5, 4950, 4950, 4950, 4950, 4950 ;FREQ
giADb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
giADb2 ftgen 0, 0, 8, -2, 5, -4, -24, -20, -9, -12 ;dB
giADb3 ftgen 0, 0, 8, -2, 5, -20, -30, -30, -16, -30 ;dB
giADb4 ftgen 0, 0, 8, -2, 5, -36, -35, -36, -28, -40 ;dB
giADb5 ftgen 0, 0, 8, -2, 5, -60, -60, -60, -55, -64 ;dB
giABW1 ftgen 0, 0, 8, -2, 5, 50, 60, 50, 70, 50 ;BAND WIDTH
giABW2 ftgen 0, 0, 8, -2, 5, 60, 80, 100, 80, 60 ;BAND WIDTH
giABW3 ftgen 0, 0, 8, -2, 5, 170, 120, 120, 100, 170 ;BAND WIDTH
giABW4 ftgen 0, 0, 8, -2, 5, 180, 150, 150, 130, 180 ;BAND WIDTH
giABW5 ftgen 0, 0, 8, -2, 5, 200, 200, 200, 135, 200 ;BAND WIDTH
;SOPRANO
giSF1 ftgen 0, 0, 8, -2, 5, 800, 350, 270, 450, 325 ;FREQ
giSF2 ftgen 0, 0, 8, -2, 5, 1150, 2000, 2140, 800, 700 ;FREQ
giSF3 ftgen 0, 0, 8, -2, 5, 2900, 2800, 2950, 2830, 2700 ;FREQ
giSF4 ftgen 0, 0, 8, -2, 5, 3900, 3600, 3900, 3800, 3800 ;FREQ
giSF5 ftgen 0, 0, 8, -2, 5, 4950, 4950, 4950, 4950, 4950 ;FREQ
giSDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
giSDb2 ftgen 0, 0, 8, -2, 5, -6, -20, -12, -11, -16 ;dB
giSDb3 ftgen 0, 0, 8, -2, 5, -32, -15, -26, -22, -35 ;dB
giSDb4 ftgen 0, 0, 8, -2, 5, -20, -40, -26, -22, -40 ;dB
giSDb5 ftgen 0, 0, 8, -2, 5, -50, -56, -44, -50, -60 ;dB
giSBW1 ftgen 0, 0, 8, -2, 5, 80, 60, 60, 70, 50 ;BAND WIDTH
giSBW2 ftgen 0, 0, 8, -2, 5, 90, 90, 90, 80, 60 ;BAND WIDTH
giSBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 170 ;BAND WIDTH
giSBW4 ftgen 0, 0, 8, -2, 5, 130, 150, 120, 130, 180 ;BAND WIDTH
giSBW5 ftgen 0, 0, 8, -2, 5, 140, 200, 120, 135, 200 ;BAND WIDTH

opcode fofx5, a, kkki
kfund,kvowel,koct,ivoice xin
ivoice limit ivoice,0,4 ;protect against out of range values for ivoice
;create a macro for each formant to reduce code repetition
#define FORMANT(N)
#
invals table 0, giBF1+(ivoice*15)+$N-1 ;number of data elements in each table
invals = invals-1 ;
k$Nform tablei 1+(kvowel*invals), giBF1+(ivoice*15)+$N-1 ;read formant frequency from table
kRandForm$N randomi -0.025,0.025,8,1
k$Nform = k$Nform*octave(kRandForm$N)
k$Ndb tablei 1+(kvowel*invals), giBDb1+(ivoice*15)+$N-1 ;read decibel value from table
k$Namp = ampdb(k$Ndb) ;convert to an amplitude value
k$Nband tablei 1+(kvowel*invals), giBBW1+(ivoice*15)+$N-1 ;read bandwidth from table
#
;EXECUTE MACRO MULTIPLE TIMES
$FORMANT(1)
$FORMANT(2)
$FORMANT(3)
$FORMANT(4)
$FORMANT(5)
;======================================================================================================================================================================
iris = 0.003 ;grain pulse rise time
idur = 0.02 ;grain pulse duration
idec = 0.007 ;grain pulse decay
iolaps = 14850 ;maximum number of overlaps (overestimate)
ifna = gisine ;function table for audio contained within fof grains
ifnb = giexp ;function table that defines the attack and decay shapes of each fof grain
itotdur = 3600 ;total maximum duration of a note (overestimate)
;FOF===================================================================================================================================================================
iRandRange = .1
#define RandFact
#
kRndFact rspline -iRandRange,iRandRange,1,10
kRndFact = semitone(kRndFact)
#
$RandFact
a1 fof k1amp, kfund*kRndFact, k1form, koct, k1band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
a2 fof k2amp, kfund*kRndFact, k2form, koct, k2band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
a3 fof k3amp, kfund*kRndFact, k3form, koct, k3band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
a4 fof k4amp, kfund*kRndFact, k4form, koct, k4band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
a5 fof k5amp, kfund*kRndFact, k5form, koct, k5band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
;======================================================================================================================================================================

;OUT===================================================================================================================================================================
asig = (a1+a2+a3+a4+a5)/5 ;mix the five fof streams and reduce amplitude five-fold
xout asig ;send audio back to caller instrument
endop

opcode ChoVoice,a,kkiii
kDtnDep,kDtnRte,ifn,icount,invoices xin ;read in input args.
ktime randomi 0.01,0.1*kDtnDep,kDtnRte,1 ;create delay time value (linearly interpolating random function will implement pitch/time modulations)
kptime linseg 0,0.001,1 ;portamento time (ramps up quickly from zero to a held value)
ktime portk ktime,kptime ;apply portamento smoothing to delay time changes (prevents angular pitch changes)
atime interp ktime ;create an interpolated a-rate version of delay time function (this will prevent qualtisation artifacts)
atap deltapi atime+0.0015 ;tap the delay buffer (nb. buffer opened and closed in caller instrument, UDO exists within the buffer)
iDel random ksmps/sr,0.2 ;random fixed delay time. By also apply a fixed delay time we prevent excessive amplitude at ote onsets when many chorus voices (N.Voices) are used
atap delay atap,iDel ;apply fixed delay
amix init 0 ;initialise amix variable (needed incase N.Voices is 1 in which case recirsion would not be used)
if icount<invoices then ;if stack of chorus voices is not yet completed...
amix ChoVoice kDtnDep,kDtnRte,ifn,icount+1,invoices ;.. call the UDO again. Increment count number.
endif
xout atap+amix ;send chorus voice created in this interation (and all subsequent voices) back to caller instrument
endop

instr 1 ;instrument that continuously scans widgets
gkmonopoly chnget "monopoly" ;read widgets...
gkDtnDep chnget "DtnDep"
gkDtnRte chnget "DtnRte"
gkvibdep chnget "vibdep"
gkmodrte chnget "modrte"
gktrmdep chnget "trmdep"
gklevel chnget "lev"
gkvowel chnget "vowel"
gkoct chnget "oct"
gkLegTim chnget "LegTim"
gkRvbMix chnget "RvbMix"
gkRvbSize chnget "RvbSize"
kporttime linseg 0,0.001,0.1 ;portamento time (ramps up quickly from zero to a held value)
gkvowel portk gkvowel,kporttime ;apply portamento smoothing
gkoct portk gkoct,kporttime
gkFiltOnOff chnget "FiltOnOff"
gkcf chnget "cf"
gkbw chnget "bw"
gkcf portk cpsoct(gkcf),kporttime ;apply portamento smoothing
gkbw portk gkbw*gkcf,kporttime ;apply portamento smoothing
endin

instr 2 ;triggered via MIDI
gkNoteTrig init 1 ;at the beginning of a new note set note trigger flag to '1'
icps cpsmidi ;read in midi note pitch in cycles per second
givel veloc 0,1 ;read in midi note velocity
gkcps = icps ;update a global krate variable for note pitch

if i(gkmonopoly)==0 then ;if we are *not* in legato mode...
inum notnum ; read midi note number (0 - 127)
event_i "i",p1+1+(inum*0.001),0,-1,icps ; call soud producing instr
krel release ; release flag (1 when note is released, 0 otherwise)
if krel==1 then ; when note is released...
turnoff2 p1+1+(inum*0.001),4,1 ; turn off the called instrument
endif ; end of conditional
else ;otherwise... (i.e. legato mode)
iactive active p1+1 ;check to see if these is already a note active...
if iactive==0 then ;...if not...
event_i "i",p1+1,0,-1 ;...start a new held note
endif
endif
endin

instr 3
ivoice chnget "voice" ;read widgets...
imoddel chnget "moddel" ;
imodris chnget "modris" ;
invoices chnget "nvoices" ;
kporttime linseg 0,0.001,1 ;portamento time function rises quickly from zero to a held value
kporttime = kporttime*gkLegTim ;scale portamento time function with value from GUI knob widget
if i(gkmonopoly)==1 then ;if we are in legato mode...
kcps portk gkcps,kporttime ;apply portamento smooth to changes in note pitch (this will only have an effect in 'legato' mode)
kactive active p1-1 ;...check number of active midi notes (previous instrument)
if kactive==0 then ;if no midi notes are active...
turnoff ;... turn this instrument off
endif
else ;otherwise... (polyphonic / non-legato mode)
kcps = p4 ;pitch equal to the original note pitch
endif

if gkNoteTrig==1&&gkmonopoly==1 then ;if a new note is beginning and if we are in monophonic mode...
reinit RESTART_ENVELOPE ;reinitialise the modulations build up
endif
RESTART_ENVELOPE:
;VIBRATO (PITCH MODULATION)
kmodenv linseg 0,0.001+imoddel,0,0.001+imodris,1 ;modulation depth envelope - modulation can be delayed by the first envelope segement and the rise time is defined by the duration of the second segment
kDepVar randomi 0.5,1,4 ;random variance of the depth of modulation
kmodenv portk kmodenv*kDepVar,kporttime ;smooth changes in modulation envelope to prevent discontinuities whnever the envelope is restarted
rireturn
kRteVar randi 0.1,4 ;random variation of the rate of modulation
kvib lfo gkvibdep*kmodenv,gkmodrte*octave(kRteVar),0 ;vibrato function
;TREMOLO (AMPLITUDE MODULATION)
ktrem lfo kmodenv*(gktrmdep/2),gkmodrte*octave(kRteVar),0 ;TREMOLO LFO FUNCTION
ktrem = (ktrem+0.5) + (gktrmdep * 0.5) ;OFFSET AND RESCALE TREMOLO FUNCTION ACCORDING TO TREMOLO DEPTH WIDGET SETTING
iRelTim = 0.05
kCpsAtt expsegr 0.6,rnd(0.004)+0.001,1,iRelTim,1-rnd(0.05) ;a little jump in pitch at the beginning of a note will give the note a realistic attack sound. This will be most apparent when note velocity is high. And a little gliss at the end of notes.
kcpsRnd gaussi 1,0.01,10 ;create a function that will be used to apply naturalistic pitch instability
kcps = kcps*(1+kcpsRnd) ;apply pitch instability
asig fofx5 kcps*semitone(kvib)*kCpsAtt, gkvowel, gkoct, ivoice-1 ;CALL fofx5 UDO
if gkFiltOnOff==1 then
asig reson asig,gkcf,gkbw,1 ;parametric EQ
endif
aatt linseg 0,(0.3*(1-givel)*(invoices^0.8))+0.01,1 ;AMPLITUDE ENVELOPE - ATTACK TIME IS INFLUENCED BY KEY VELOCITY
asig = asig*aatt*ktrem*(0.3+givel*0.7)*gklevel ;APPLY AMPLITUDE CONTROLS: ENVELOPE, TREMOLO, KEY VELOCITY AND LEVEL

/*CHORUS*/
if invoices>1 then
abuf delayr 2 ;--left channel--
amixL ChoVoice gkDtnDep,gkDtnRte,gisine,1,invoices ;call UDO
delayw asig

abuf delayr 2 ;--right channel--
amixR ChoVoice gkDtnDep,gkDtnRte,gisine,1,invoices ;call UDO
delayw asig

asigL = amixL/(invoices^0.5) ;scale mix of chorus voices according to the number of voices...
asigR = amixR/(invoices^0.5) ;...and the right channel
else ;otherwise... (N.Voices = 1)
asigL = asig ;send mono signal to both channels
asigR = asig
endif
arel linsegr 1,iRelTim,0 ;release envelope
asigL = asigL*arel ;apply release envelope
asigR = asigR*arel

kwet limit 2*gkRvbMix,0,1 ;wet (reverb) level control (reaches maximum a knob halfway point and hold that value for the remainder of its travel)
gasendL = gasendL+asigL*kwet ;send some audio to the reverb instrument
gasendR = gasendR+asigR*kwet
kdry limit 2*(1-gkRvbMix),0,1 ;dry level (stays at maximum for the first half of the knob's travel then ramps down to zero for the remainder of its travel)
outs asigL*kdry,asigR*kdry ;SEND AUDIO TO OUTPUT
gkNoteTrig = 0 ;reset new-note trigger (in case it was '1')
endin

instr Effects
if gkRvbMix>0 then
aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000 ;create stereo reverb signal
outs aL,aR ;send reverb signal to speakers
clear gasendL,gasendR ;clear reverb send variables
endif
endin

</CsInstruments>

<CsScore>
f 0 [3600*24*7]
i 1 0 [3600*24*7] ;read widgets
i "Effects" 0 [3600*24*7] ;reverb
</CsScore>

</CsoundSynthesizer>

+ 321
- 0
bin/cabbage-todo/Synths/Clavinet.csd View File

@@ -0,0 +1,321 @@
Clavinet.csd - an emulation of the Hohner Clavinet D6
-----------------------------------------------------

Pickup Selection
----------------
CA - neck pickup only (pickup A)
CB - bridge pickup only (pickup B)
DA - both pickups in phase
DB - bridge pickup (pickup B) 180 degrees out of phase w.r.t the neck pickup

Setup
-----
Pick A - position of the first pickup (range 0 - 1). Typically referred to as the 'neck' pickup
Pick B - position of the second pickup (range 0 - 1). Typically referred to as the 'bridge' pickup
(NB. the relevant pickup has to be 'active' according to the CD AB switches in order for you to be able to here changes to it pickup position.)
Mod.A - the pickup position can also modulated by an LFO. This control controls the depth of this modulation
Mod.B - Depth of this modulation for the second pickup
Rate A - Rate of modulation for the first pickup
Rate B - Rate of modulation for the second pickup
Env.A - The pickup position can be modulated by a simple single segment envelope. This is typically used to add an particualar attack nuance to the sound. This control controls the initial amplitude of this envelope (can be positive or negative). The envelope always ends at zero.
Env.B - Envelope amplitude for the second pickup.
Time A - Duration of the envelope segment for the first pickup
Time B - Duration of the envelope segment for the second pickup
Pluck - location of the 'pluck' (range 0 - 1). Should be close to zero for a typical clavinet behaviour
Damp - string vibration damping that is applied while a note is being held. String damping is also dependent upon the note played using a 'key tracking' function table 'girefl'. In general lower notes should experience greater damping.
HPF - this controls the cutoff frequency of a highpass filter that the signal passes through.
The value supplied here is multiplied by the fundemental frequency of the note played to derive the cutoff frequency.
Therefore if a value of '2' is supplied the cutoff will always by twice the fundemental, i.e. the frequency of the first harmonic/second partial.
This control can be used to remove the emphasis of the fundemental partial.
If this control is at its minimum setting the filter is bypassed.
LPF - behaves in a similar way to HPF but in respect to a lowpass filter. This control, if reduced, can be used to soften the brightness of a note's attack.
If this control is at its maximum setting the filter is bypassed.
Inharm - applies inharmonicity to the spectrum produced by repluck. Negative values compress the spectrum, positive values expand the spectrum and zero leaves the spectrum unaffected.

Release
-------
* Poorly maintained clavinets exhibit a release 'pluck' as the rubber pad which strikes and frets is lifted from the string when the key is released. The is on account of the rubber pad wearing out.
Ampl - amplitude of the release 'pluck'
Tone - a tone control applied to the release 'pluck' (this will also affect amplitude)
D.Time - time it takes for full damping to be applied (this control has a subtle effect)
Damp - amount of damping that is applied to string vibrations whenever a key is
released (this amount of damping is achieved after 'D.Time' seconds). Note that the 'Damp'
control in the 'Setup' pop-up panel also has an impact upon the release damping.
A.Time - amplitude release time. If this is too short, vibration damping may not be heard and the above controls may not appear to do anything

Filters
-------
The D6 Clavinet design incorporates four bandpass filters which can be switched in or out of the circuit.
Emphasising four different frequency bands from high to low they are named 'brilliant', 'treble', 'medium' and 'soft'
Cutoff frequencies (fco), levels and Q values for each of the four filters can be adjusted.
Obviously the relevant filter has to be activated in order to be able to hear changes made to its settings.
The four filters are in a parallel arrangement as opposed to being in series.

<Cabbage>
form caption("Clavinet"), size(550, 195), pluginID("clav"), colour(228,156,28)

snapshot bounds(260, 46,200, 25), master(1), items("Clavinet 1", "Clavinet 2", "Clavinet 3", "Clavinet 4", "Clavinet 5", "Clavinet 6", "Clavinet 7", "Clavinet 8", "Clavinet 9", "Clavinet 10")

; filter switches
checkbox bounds( 10, 5, 70, 15), text("Brilliant") channel("brilliant"), FontColour(50,50,50), colour("lime")
checkbox bounds( 10, 25, 70, 15), text("Treble") channel("treble"), FontColour(50,50,50), colour("lime"), value(1)
checkbox bounds( 10, 45, 70, 15), text("Medium") channel("medium"), FontColour(50,50,50), colour("lime")
checkbox bounds( 10, 65, 70, 15), text("Soft") channel("soft"), FontColour(50,50,50), colour("lime")

; pickup configuration switches
checkbox bounds( 80, 5, 70, 15), text("C/D") channel("C_D"), FontColour(50,50,50), colour("lime"), value(1)
checkbox bounds( 80, 25, 70, 15), text("A/B") channel("A_B"), FontColour(50,50,50), colour("lime"), value(1)

; controls pertaining to the setup of the instrument (pickup positions, pluck position, damping etc.) accessed in a pop-up panel
groupbox bounds(150, 8, 172, 305), colour(228,156,28), plant("Setup), line(0), popup(1)
{
rslider bounds( 5, 8, 55, 55), text("Pick A"), colour(195,126, 0), FontColour(50,50,50), channel("pickA"), range(0, 1.00, 0.25, 1, 0.001)
rslider bounds( 55, 8, 55, 55), text("Pick B"), colour(195,126, 0), FontColour(50,50,50), channel("pickB"), range(0, 1.00, 0.07, 1, 0.001)
rslider bounds( 5, 68, 55, 55), text("Mod A"), colour(225,156, 28), FontColour(50,50,50), channel("ModA"), range(0,0.50, 0.03, 0.5, 0.001)
rslider bounds( 55, 68, 55, 55), text("Mod B"), colour(225,156, 28), FontColour(50,50,50), channel("ModB"), range(0,0.50, 0.03, 0.5, 0.001)
rslider bounds( 5,128, 55, 55), text("Rate A"), colour(255,186, 58), FontColour(50,50,50), channel("RateA"), range(0,14.00, 0.2, 0.5, 0.001)
rslider bounds( 55,128, 55, 55), text("Rate B"), colour(255,186, 58), FontColour(50,50,50), channel("RateB"), range(0,14.00, 0.15, 0.5, 0.001)
rslider bounds( 5,188, 55, 55), text("Env.A"), colour(255,216, 88), FontColour(50,50,50), channel("EnvA"), range(-1, 1.00, 0)
rslider bounds( 55,188, 55, 55), text("Env.B"), colour(255,216, 88), FontColour(50,50,50), channel("EnvB"), range(-1, 1.00, 0)
rslider bounds( 5,248, 55, 55), text("Time A"), colour(255,246,118), FontColour(50,50,50), channel("TimeA"), range(0, 1.00, 0.05, 0.5, 0.001)
rslider bounds( 55,248, 55, 55), text("Time B"), colour(255,246,118), FontColour(50,50,50), channel("TimeB"), range(0, 1.00, 0.05, 0.5, 0.001)
line bounds(110, 25, 1, 260), colour( 50, 50, 50)
rslider bounds(112, 8, 55, 55), text("Pluck"), colour(195,126, 0), FontColour(50,50,50), channel("plk"), range(0, 1.00, 0.005, 0.5, 0.0001)
rslider bounds(112, 68, 55, 55), text("Damp"), colour(225,156, 28), FontColour(50,50,50), channel("SusDamp"), range(-1.00, 1.00, 0)
rslider bounds(112,128, 55, 55), text("HPF"), colour(255,186, 58), FontColour(50,50,50), channel("HPF"), range(0,16.0, 0)
rslider bounds(112,188, 55, 55), text("LPF"), colour(255,216, 88), FontColour(50,50,50), channel("LPF"), range(1.0,72, 72, 0.375, 0.0001)
rslider bounds(112,248, 55, 55), text("Inharm."),colour(255,216, 88), FontColour(50,50,50), channel("inharm"), range(-0.99,0.99, 0)
}

; controls pertaining to the release stage of a note accessed in a pop-up panel
groupbox bounds(260, 8, 265, 65), colour(228,156,28), plant("Release"), line(0), popup(1)
{
rslider bounds( 5, 8, 55, 55), text("Ampl."), colour(255,186,58), FontColour(50,50,50), channel("RelAmpl"), range(0, 20.00, 2)
rslider bounds( 55, 8, 55, 55), text("Tone"), colour(255,186,58), FontColour(50,50,50), channel("RelTone"), range(100, 8000, 1000)
rslider bounds(105, 8, 55, 55), text("D.Time"), colour(255,186,58), FontColour(50,50,50), channel("RelDTime"), range(0.001, 1, 0.01, 0.5, 0.001)
rslider bounds(155, 8, 55, 55), text("Damp"), colour(255,186,58), FontColour(50,50,50), channel("RelDamp"), range(0.10, 0.99, 0.95)
rslider bounds(205, 8, 55, 55), text("A.Time"), colour(255,186,58), FontColour(50,50,50), channel("RelATime"), range(0.01,20, 0.05, 0.5, 0.01)
}

; controls pertaining to the setup of the instrument's bandpass filters accessed in a pop-up panel
groupbox bounds(150, 46, 230, 195), colour(228,156,28), plant("Filters"), line(0), popup(1)
{
label bounds( 10, 5, 60, 12), text("Brilliant"), colour("white"), FontColour(50,50,50)
label bounds( 69, 5, 60, 12), text("Treble"), colour("white"), FontColour(50,50,50)
label bounds(121, 5, 60, 12), text("Medium"), colour("white"), FontColour(50,50,50)
label bounds(185, 5, 60, 12), text("Soft"), colour("white"), FontColour(50,50,50)
checkbox bounds( 26, 18, 10, 10), channel("brilliant"), colour("lime"), value(0), shape("ellipse")
checkbox bounds( 81, 18, 10, 10), channel("treble"), colour("lime"), value(0), shape("ellipse")
checkbox bounds(136, 18, 10, 10), channel("medium"), colour("lime"), value(0), shape("ellipse")
checkbox bounds(191, 18, 10, 10), channel("soft"), colour("lime"), value(0), shape("ellipse")
rslider bounds( 5, 30, 55, 55), channel("fco1"), text("fco.1"), colour(235,166,38), FontColour(50,50,50), range(50,5000,2500,0.5)
rslider bounds( 60, 30, 55, 55), channel("fco2"), text("fco.2"), colour(235,166,38), FontColour(50,50,50), range(50,5000,1000,0.5)
rslider bounds(115, 30, 55, 55), channel("fco3"), text("fco.3"), colour(235,166,38), FontColour(50,50,50), range(50,5000, 500,0.5)
rslider bounds(170, 30, 55, 55), channel("fco4"), text("fco.4"), colour(235,166,38), FontColour(50,50,50), range(50,5000, 200,0.5)
rslider bounds( 5, 85, 55, 55), channel("gain1"), text("Gain 1"), colour(255,216,88), FontColour(50,50,50), range(0.50,30, 3,0.5)
rslider bounds( 60, 85, 55, 55), channel("gain2"), text("Gain 2"), colour(255,216,88), FontColour(50,50,50), range(0.50,30,2.3,0.5)
rslider bounds(115, 85, 55, 55), channel("gain3"), text("Gain 3"), colour(255,216,88), FontColour(50,50,50), range(0.50,30,1.3,0.5)
rslider bounds(170, 85, 55, 55), channel("gain4"), text("Gain 4"), colour(255,216,88), FontColour(50,50,50), range(0.50,30,1.4,0.5)
rslider bounds( 5,140, 55, 55), channel("Q1"), text("Q 1"), colour(255,255,138), FontColour(50,50,50), range(0.50,30,1.25,0.5)
rslider bounds( 60,140, 55, 55), channel("Q2"), text("Q 2"), colour(255,255,138), FontColour(50,50,50), range(0.50,30,1 ,0.5)
rslider bounds(115,140, 55, 55), channel("Q3"), text("Q 3"), colour(255,255,138), FontColour(50,50,50), range(0.50,30,1 ,0.5)
rslider bounds(170,140, 55, 55), channel("Q4"), text("Q 4"), colour(255,255,138), FontColour(50,50,50), range(0.50,30,2 ,0.5)
line bounds( 59, 25, 1, 150), colour(50,50,50)
line bounds(114, 25, 1, 150), colour(50,50,50)
line bounds(169, 25, 1, 150), colour(50,50,50)
}

rslider bounds(470, 5, 75, 75), text("Level"), colour(255,186,58), FontColour(50,50,50), channel("level"), range(0, 8.00, 0.5, 0.5)

keyboard bounds(10, 85, 530,80)
image bounds(5, 170, 420, 20), colour(75, 85, 90, 50), plant("credit"){
label bounds(0.03, 0.1, .6, .7), text("Author: Iain McCurdy |2013|"), colour("white"), FontColour(50,50,50)
}

</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 16
nchnls = 2
0dbfs = 1

; table used to map of note played to bridge relection
girefl ftgen 0,0,128,-27, 0,0.4, 36,0.4, 72,0.01, 127,0.01
gisine ftgen 0,0,4096,10,1
gitri ftgen 0,0,4096,7,0,1024,1,2046,-1,1024,0

opcode FreqShifter,a,aki
ain,kfshift,ifn xin ;READ IN INPUT ARGUMENTS
areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
asin oscili 1, kfshift, ifn, 0
acos oscili 1, kfshift, ifn, 0.25
;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
amod1 = areal * acos
amod2 = aimag * asin
;UPSHIFTING OUTPUT
aFS = (amod1 - amod2)
xout aFS ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
ibrilliant chnget "brilliant" ; filter switch
itreble chnget "treble" ; filter switch
imedium chnget "medium" ; filter switch
isoft chnget "soft" ; filter switch
iC_D chnget "C_D" ; single/dual pickup selector
iA_B chnget "A_B" ; neck/bridge pickup selector
gklevel chnget "level" ; output volume control

icps cpsmidi ; cps read from midi
inum notnum ; note number read from midi
ivel veloc 0,1 ; velocity read from midi

; pluck position is an i-rate variable so a mechanism is created to re-initialise the instrument if it is changed in realtime
kplk chnget "plk" ; pluck position
ktrig changed kplk ; if GUI knob changes, generate a trigger
if ktrig==1 then ; if triggered...
reinit UPDATE ; reinitialise...
endif
UPDATE: ; ...from here (until the end of the instrument)
iplk = i(kplk) ; cast k-rate pluck position to i-rate variable

; pickup positions
kpickA chnget "pickA" ; neck pickup position
kpickB chnget "pickB" ; bridge pickup position

; string vibration damping / reflectivity
irefl table inum,girefl ; read reflectivity for this note from function table (lower notes will experience more damping)
iRelDTime chnget "RelDTime" ; release damping time: time for damping state to be established
iRelDamp chnget "RelDamp" ; amount of damping upon release
krefl linsegr irefl,iRelDTime,iRelDamp ; upon note release vibrations are damped quickly and dramatically
kSusDamp chnget "SusDamp" ; user controlled modulation of string vibration damping
krefl limit krefl+kSusDamp,0.001,0.999 ; consolidate reflection/damping value and limit possible values to prevent out of range values

iamp = ivel*0.3
kenv expseg 1, 0.01,0.001,1,0.001 ; create an amplitude envelope for the noise burst
axcite pinkish kenv-0.001 ; create a pink noise signal
axcite tone axcite,icps*2
krelease release ; sense release of note
iRelAmpl chnget "RelAmpl" ; release pluck amplitude
iRelTone chnget "RelTone" ; tone of the release pluck
if krelease==1 then ; if key is released...
axcite mpulse iRelAmpl,0 ; audio impulse is created as an implementation of the release pluck impulse
axcite butlp axcite,iRelTone ; lowpass filter the impulse
endif

kModA chnget "ModA" ; pickup position modulation depth
kModB chnget "ModB"
kRateA chnget "RateA" ; pickup position modulation rate
kRateB chnget "RateB"

iEnvA chnget "EnvA" ; pickup position envelope modulation depth
iEnvB chnget "EnvB"
iTimeA chnget "TimeA" ; pickup position envelope modulation time
iTimeB chnget "TimeB"

kenv1 transeg iEnvA,iTimeA,-4,0 ; envelope applied to the pickup position (pickup A)
kenv2 transeg iEnvB,iTimeB,-4,0 ; envelope applied to the pickup position (pickup B)
kmod1 oscili kModA,kRateA,gitri ; lfo used to modulate pickup position (pickup A)
kmod2 oscili kModB,kRateB,gitri ; lfo used to modulate pickup position (pickup B)
kpickA limit kpickA + kmod1 + kenv1, 0, 1 ; consolidate pickup position between fixed value, lfo and envelope. Also protect against out of range values. (pickup A)
kpickB limit kpickB + kmod2 + kenv2, 0, 1 ; consolidate pickup position between fixed value, lfo and envelope. Also protect against out of range values. (pickup B)

iinharm chnget "inharm" ; inharmonicity of the tone. negative values compress the spectrum, positive values expand it. Compensation will be applied to the fundemental so that it will remain consistent.
iFShift = icps*iinharm ; amount of frequency shift (in CPS)

a1 repluck iplk, iamp, icps-iFShift, kpickA, krefl, axcite ; employ plucked string model (pickup A)
a2 repluck iplk, iamp, icps-iFShift, kpickB, krefl, axcite ; employ plucked string model (pickup B)

if(iinharm!=0) then ; only apply frequency shifting if inharmonicity is anything other than zero
a1 FreqShifter a1,iFShift,gisine ; call frequency shifting UDO
a2 FreqShifter a2,iFShift,gisine
endif

if(iC_D==0&&iA_B==0) then ;CA - neck pickup only
asig = a1
elseif(iC_D==0&&iA_B==1) then ;CB - bridge pickup only
asig = a2
elseif(iC_D==1&&iA_B==0) then ;DA - both pickups in phase
asig = a1 + a2
elseif(iC_D==1&&iA_B==1) then ;DB - both pickups. Pickup B 180 degrees out of phase
asig = a1 - a2
endif

; velocity to brightness
icf = (ivel*6)+8 ; cutoff frequency in 'oct' format
asig butlp asig,cpsoct(icf) ; lowpass filter audio signal

; filter switches
kfco1 chnget "fco1" ; filter cutoffs
kfco2 chnget "fco2"
kfco3 chnget "fco3"
kfco4 chnget "fco4"
kQ1 chnget "Q1" ; filter q's
kQ2 chnget "Q2"
kQ3 chnget "Q3"
kQ4 chnget "Q4"
kgain1 chnget "gain1" ; filter gains
kgain2 chnget "gain2"
kgain3 chnget "gain3"
kgain4 chnget "gain4"

; filters
amix = 0 ; audio mix of filter outputs (reset to silence upon each iteration)
if(ibrilliant==1) then ; if 'brilliant' selected...
afilt rbjeq asig, kfco1, 1, kQ1, 1, 4 ; bandpass filter sound
amix = amix + (afilt * kgain1) ; add a scaled amount of filtered signal to filter mix signal
endif
if(itreble==1) then ; if 'treble' selected...
afilt rbjeq asig, kfco2, 1, kQ2, 1, 4 ; bandpass filter sound
amix = amix + (afilt * kgain2) ; add a scaled amount of filtered signal to filter mix signal
endif
if(imedium==1) then ; if 'medium' selected...
afilt rbjeq asig, kfco3, 1, kQ3, 1, 4 ; bandpass filter sound
amix = amix + (afilt * kgain3) ; add a scaled amount of filtered signal to filter mix signal
endif
if(isoft==1) then ; if 'soft' selected...
afilt rbjeq asig, kfco4, 1, kQ4, 1, 4 ; bandpass filter sound
amix = amix + (afilt * kgain4) ; add a scaled amount of filtered signal to filter mix signal
endif
if((ibrilliant + itreble + imedium + isoft)==0) then ; if no filters selected...
amix = asig ; ...just send unfiltered audio to filter section output
endif

; key following highpass filter
kHPF chnget "HPF" ; highpass filter multiple
if kHPF>0 then ; if HPF control is greater than 1...
kcf limit icps*kHPF,20,sr/2 ; prevent out of range values which would cause the filter to 'blow up'
amix buthp amix,kcf ; filter tone relative to note fundemental
endif

; key following lowpass filter
kLPF chnget "LPF" ; lowpass filter multiple
if kLPF<72 then ; if LPF control is greater than 1...
kcf limit icps*kLPF,20,sr/2 ; prevent out of range values which would cause the filter to 'blow up'
amix butlp amix,kcf ; filter tone relative to note fundemental
endif

; release envelope
iRelATime chnget "RelATime" ; amplitude release time
aenv linsegr 1, iRelATime, 0 ; amplitude release envelope (senses key release before entering final/only segment)

; output signal
aout = amix * aenv * gklevel ; apply release envelope and level control
outs aout, aout ; send audio to outputs
endin

</CsInstruments>

<CsScore>
f 0 [60*60*24*7] ; keep performance going for up to a week
</CsScore>

</CsoundSynthesizer>

+ 461
- 0
bin/cabbage-todo/Synths/Clavinet.snaps View File

@@ -0,0 +1,461 @@
------------------------ Instrument ID:
-------- Start of Preset: Clavinet 1
brilliant: 0
treble: 1
medium: 0
soft: 0
C_D: 1
A_B: 1
pickA: 0.25
pickB: 0.0700000003
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.00499999989
SusDamp: 0
HPF: 0
LPF: 72
inharm: 0
RelAmpl: 2
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.949999988
RelATime: 0.049999997
brilliant: 0
treble: 1
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.5
-------- End of Preset: Clavinet 1

-------- Start of Preset: Clavinet 2
brilliant: 0
treble: 0
medium: 1
soft: 0
C_D: 1
A_B: 0
pickA: 0.938000023
pickB: 0.0500000007
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.165399998
SusDamp: 0.50999999
HPF: 0
LPF: 39.6390991
inharm: 0
RelAmpl: 0
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.359999985
RelATime: 4.01999998
brilliant: 0
treble: 0
medium: 1
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.925000072
-------- End of Preset: Clavinet 2

-------- Start of Preset: Clavinet 3
brilliant: 0
treble: 0
medium: 1
soft: 0
C_D: 1
A_B: 0
pickA: 0.120000005
pickB: 0.252000004
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.00079999998
SusDamp: 0.0799999759
HPF: 2.04999995
LPF: 8.57209969
inharm: -0.50999999
RelAmpl: 2.15999985
RelTone: 2358.80005
RelDTime: 0.0650000051
RelDamp: 0.300000012
RelATime: 8
brilliant: 0
treble: 0
medium: 1
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 1.21700001
-------- End of Preset: Clavinet 3

-------- Start of Preset: Clavinet 4
brilliant: 0
treble: 1
medium: 0
soft: 0
C_D: 1
A_B: 0
pickA: 0.530000031
pickB: 0.462000012
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.269099981
SusDamp: -1
HPF: 0
LPF: 25.2099991
inharm: 0
RelAmpl: 2
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.879999995
RelATime: 0.049999997
brilliant: 0
treble: 1
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.5
-------- End of Preset: Clavinet 4

-------- Start of Preset: Clavinet 5
brilliant: 0
treble: 1
medium: 0
soft: 1
C_D: 0
A_B: 1
pickA: 0.398000032
pickB: 0.522000015
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.285899997
SusDamp: 0.0999999791
HPF: 0
LPF: 31.4514999
inharm: 0
RelAmpl: 0
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.579999983
RelATime: 3.91999984
brilliant: 0
treble: 1
medium: 0
soft: 1
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.461000025
-------- End of Preset: Clavinet 5

-------- Start of Preset: Clavinet 6
brilliant: 0
treble: 1
medium: 0
soft: 0
C_D: 1
A_B: 1
pickA: 0.0940000042
pickB: 0.398000032
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.128700003
SusDamp: 0.299999982
HPF: 0
LPF: 72
inharm: 0
RelAmpl: 0
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.280000001
RelATime: 1.39999998
brilliant: 0
treble: 1
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.5
-------- End of Preset: Clavinet 6

-------- Start of Preset: Clavinet 7
brilliant: 1
treble: 1
medium: 0
soft: 0
C_D: 1
A_B: 0
pickA: 0.00200000009
pickB: 0.950000048
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.128700003
SusDamp: 0.299999982
HPF: 3.46000004
LPF: 24.0676003
inharm: 0
RelAmpl: 0
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.280000001
RelATime: 3.32999992
brilliant: 1
treble: 1
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 4.26300001
-------- End of Preset: Clavinet 7

-------- Start of Preset: Clavinet 8
brilliant: 1
treble: 1
medium: 0
soft: 0
C_D: 1
A_B: 0
pickA: 0.584000051
pickB: 0.450000018
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.23709999
SusDamp: 0.459999979
HPF: 1.46999991
LPF: 16.7103996
inharm: 0
RelAmpl: 0
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.140000001
RelATime: 3.58999991
brilliant: 1
treble: 1
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 0.720000029
-------- End of Preset: Clavinet 8

-------- Start of Preset: Clavinet 9
brilliant: 1
treble: 0
medium: 0
soft: 0
C_D: 0
A_B: 0
pickA: 0.25
pickB: 0.0700000003
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.00499999989
SusDamp: 0
HPF: 0
LPF: 25.5985985
inharm: 0
RelAmpl: 2
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.949999988
RelATime: 0.049999997
brilliant: 1
treble: 0
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 1.92100012
-------- End of Preset: Clavinet 9

-------- Start of Preset: Clavinet 10
brilliant: 1
treble: 0
medium: 0
soft: 0
C_D: 1
A_B: 0
pickA: 0.25
pickB: 0.0700000003
ModA: 0.0300000012
ModB: 0.0300000012
RateA: 0.200000003
RateB: 0.150000006
EnvA: 0
EnvB: 0
TimeA: 0.0500000007
TimeB: 0.0500000007
plk: 0.00499999989
SusDamp: 0
HPF: 0
LPF: 25.5985985
inharm: 0
RelAmpl: 2
RelTone: 1000
RelDTime: 0.0100000007
RelDamp: 0.949999988
RelATime: 0.049999997
brilliant: 1
treble: 0
medium: 0
soft: 0
fco1: 2500
fco2: 1000
fco3: 500
fco4: 200
gain1: 3
gain2: 2.29999995
gain3: 1.29999995
gain4: 1.39999998
Q1: 1.25
Q2: 1
Q3: 1
Q4: 2
level: 1.92100012
-------- End of Preset: Clavinet 10
------------------------ End of Instrument ID:

+ 60
- 0
bin/cabbage-todo/Synths/GaussianDust.csd View File

@@ -0,0 +1,60 @@
GaussianDust.csd
Iain McCurdy [2013]

<Cabbage>
form caption("Gaussian Dust"), size(325, 350), pluginID("gaus")
image bounds(0, 0, 325, 350), colour("DarkSlateGrey"), shape("rounded"), outline("white"), line(4)
checkbox bounds( 15, 10, 80, 15), text("On/Off"), channel("onoff"), value(1), fontcolour("white")
combobox bounds( 10, 40, 70, 20), channel("mode"), value(2), text("Held", "Reinit")
rslider bounds(90, 10, 60, 60), text("Amplitude"), channel("amp"), range(0, 1, 0.5, 0.5, 0.001), fontcolour("white")
rslider bounds(150, 10, 60, 60), text("Freq."), channel("freq"), range(0.1, 10000, 10, 0.25, 0.01), fontcolour("white")
rslider bounds(205, 10, 60, 60), text("Deviation"), channel("dev"), range(0, 10, 1), fontcolour("white")
rslider bounds(260, 10, 60, 60), text("Spread"), channel("spread"), range(0, 1, 1), fontcolour("white")
xypad bounds( 40, 78, 245, 260), text("Freq./Deviation"), channel("freq", "dev"), rangex(0.1, 10000, 10), rangey(0, 10.00, 0)
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

instr 1
konoff chnget "onoff" ;read in on/off switch widget value
if konoff==0 goto SKIP ;if on/off switch is off jump to skip label
kamp chnget "amp"
kfreq chnget "freq"
kdev chnget "dev"
kporttime linseg 0,0.01,0.1
kdev portk kdev,kporttime
kmode chnget "mode"
kmode = kmode - 1
kspread chnget "spread"
ktrig changed kmode ;IF gkmode COUNTER IS CHANGED GENERATE A MOMENTARY '1' IMPULSE
if ktrig==1 then ;THEREFORE IF gkmode HAS BEEN CHANGED...
reinit UPDATE ;BEGIN A REINITIALISATION PASS AT LABEL 'UPDATE'
endif ;END OF CONDITIONAL BRANCH
UPDATE: ;LABEL 'UPDATE'. REINITIALISATION BEGINS FROM HERE.
asig gausstrig kamp, kfreq, kdev, i(kmode) ;GENERATE GAUSSIAM TRIGGERS
kpan random 0.5-(kspread*0.5), 0.5+(kspread*0.5)
asigL,asigR pan2 asig,kpan
rireturn ;RETURN FROM REINITIALISATION PASS
outs asigL,asigR ;SEND AUDIO SIGNAL TO OUTPUT
SKIP: ;A label. Skip to here is on/off switch is off
endin


</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7] ;instrument plays for a week
</CsScore>

</CsoundSynthesizer>

+ 115
- 0
bin/cabbage-todo/Synths/Granular.csd View File

@@ -0,0 +1,115 @@
<Cabbage>
form caption("Granular synthesizer") size(428, 220), colour("black"), pluginID("gra1")
rslider bounds(0, 0, 80, 80) channel("random"), range(1, 2000, 200), caption("Random freq"), colour("white"), midictrl(1, 1)
rslider bounds(85, 0, 80, 80) channel("size"), range(0.005,.2, .02), caption("Grain size"), colour("white"), midictrl(1, 2)
rslider bounds(170, 0, 80, 80) channel("density"), range(1, 10, 1), caption("Density"), colour("white"), midictrl(1, 3)
rslider bounds(255, 0, 80, 80) channel("reverb"), range(0, 1, 0), caption("Reverb"), colour("white"), midictrl(1, 4)
rslider bounds(340, 0, 80, 80) channel("freq"), range(0,30, 0), caption("Flanger"), colour("white"), midictrl(1, 5)

combobox bounds(50, 90, 160, 20), channel("func1"), value(14), colour("darkgrey"), text("wt1","wt2","wt3","wt4","wt5","wt6","wt7","wt8","wt9","wt10","wt11","wt12","wt13","wt14")
combobox bounds(220, 90, 160, 20), channel("func2"), value(5), colour("darkgrey"), text("wt1","wt2","wt3","wt4","wt5","wt6","wt7","wt8","wt9","wt10","wt11","wt12","wt13","wt14")


keyboard pos(0, 130), size(420, 50)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n -+rtmidi=NULL -M0 --midi-key-cps=5 --midi-velocity-amp=4
;-n -d -+rtmidi=NULL -M0
</CsOptions>
<CsInstruments>

;Author: Giorgio Zucco (2012)


sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

gasig1 init 0
gasig2 init 0

giadd ftgen 14,0,8193,9,1,1,0,1.02,.28,0,.98,.14,0,4,.22,0,7,.39,0 ;bell
gihanning ftgen 200,0,8192,-20,2 ;Hanning
gibarlett ftgen 300,0,8192,-20,3 ;Bartlett (Triangle)



instr 1


gkfn1 chnget "func1";grain waveform
gkfn2 chnget "func2";grain waveform
;grain
kcps = p5*.5 ;grain freq
kfmd chnget "random";variazione random in Hz.
kgdur chnget "size" ;durata dei grani in secondi
iovrlp chnget "density" ;numero di grani sovrapposti
kfreq chnget "freq"

iwfn1 = 200 ;inviluppo a1
iwfn2 = 300 ;inviluppo a2

;adsr
iatt = 0.2
idec = 1
isus = 1
irel = .5

a1 grain2 kcps,kfmd,kgdur,iovrlp,gkfn1,iwfn1
a2 grain2 kcps*2,kfmd,kgdur,iovrlp,gkfn2,iwfn2

adel1 randh .009,kfreq
adel2 randh .009,kfreq
klfo poscil .01,.1,4 ;Lfo
afl1 flanger a1,adel1+klfo,.9
afl2 flanger a2,adel2+klfo,.9

kadsr mxadsr iatt,idec,isus,irel

aleft clip (a1+afl1)*.1,2,.8
aright clip (a2+afl2)*.1,2,.8

outs (aleft)*kadsr,(aright)*kadsr

vincr gasig1,(aleft)*kadsr
vincr gasig2,(aright)*kadsr
endin

instr 3
klevel chnget "reverb"
al,ar reverbsc gasig1*.5,gasig2*.5,.85,16000,sr,0
kpan1 randomi 0,1,4
kpan2 randomi 0,1,8
aout1,aout2 pan2 al,kpan1
aout3,aout4 pan2 ar,1-kpan2
outs (aout1+aout2)*klevel,(aout3+aout4)*klevel
clear gasig1,gasig2
endin


</CsInstruments>
<CsScore>
f1 0 1024 10 1
f2 0 4096 10 1 0 .111 0 .04 0 .02 0 .012 ;Triangular1
f3 0 4096 10 1 0 .111 0 .04 0 .02 0 .012 0 .009 0 .007;Triangular 2
f5 0 4096 10 1 0 0.3 0 0.2 0 0.14 0 0.1 0 0.09 0 0.07 0 0.06 0 0.05 ;square
f4 0 4096 10 1 0 .333333 0 .2 0 .142857 0 .111111 0 .090909 0 .076923 ; Square
f6 0 4096 10 1 1 1 1 .7 .5 .3 .1 ;pulse

f7 0 4096 10 1 0 0 1;sine+4
f8 0 4096 10 1 0 0 0 1;sine+5
f9 0 4096 10 1 0 0 0 0 1;sine+6
f10 0 4096 10 1 0 0 0 0 0 1;sine+7
f11 0 4096 10 1 0 0 0 0 0 0 1;sine+8
f12 0 4096 10 1 0 0 0 0 0 0 0 1;sine+9
f13 0 4096 10 1 0 0 0 0 0 0 0 0 1;sine+10


f0 36000

i3 0 36000
</CsScore>
</CsoundSynthesizer>

+ 300
- 0
bin/cabbage-todo/Synths/InharmonicAdditiveSynth.csd View File

@@ -0,0 +1,300 @@
<Cabbage>
form caption("Inharmonic Synth"), size(445, 320), pluginID("InSy")
image pos(0, 0), size(445, 290), colour("black"), shape("rounded"), outline("brown"), line(4)
combobox caption("Instrument"), channel("Instr"), pos(275, 10), size(160, 90), value(4), text("Bass Guitar", "Dahina", "Banyan", "Xylophone", "Tibetan Bowl 180mm", "Spinel Sphere", "Pot Lid", "Red Cedar Wood Plate", "Tubular Bell", "Redwood Wood Plate", "Douglas Fir Wood Plate", "Uniform Wooden Bar", "Uniform Aluminium Bar", "Vibraphone 1", "Vibraphone 2", "Chalandi Plates", "Tibetan Bowl 152mm", "Tibetan Bowl 140mm", "Wine Glass", "Small Handbell", "Albert Clock Bell", "Wood Block")

groupbox bounds(10, 10, 260, 90), text("Filter Envelope"){
rslider bounds( 10, 35,60,60), text("Amount"), colour("cornflowerblue"), channel("FAmt"), range(0, 1, 0.7)
rslider bounds( 60, 35,60,60), text("Dec."), colour("cornflowerblue"), channel("FDec"), range(0, 1, 0.45)
rslider bounds(110, 35,60,60), text("Sus."), colour("cornflowerblue"), channel("FSus"), range(0, 1, 0)
rslider bounds(160, 35,60,60), text("Rel."), colour("cornflowerblue"), channel("FRel"), range(0, 1, 0.45)
rslider bounds(210, 35,60,60), text("Shape"), channel("FShp"), colour("cornflowerblue"), range(-50, 50, -16)
}

groupbox bounds(10, 105, 210, 90), text("Amplitude Envelope"){
rslider bounds( 10,130,60,60), text("Att."), channel("AAtt"), colour("red"), range(0, 1, 0)
rslider bounds( 60,130,60,60), text("Dec."), channel("ADec"), colour("red"),range(0, 1, 0.45)
rslider bounds(110,130,60,60), text("Sus"), channel("ASus"), colour("red"),range(0, 1, 0)
rslider bounds(160,130,60,60), text("Rel"), channel("ARel"), colour("red"),range(0, 1, 0.45)
}

groupbox bounds(225, 105, 210, 90), text("Chorus"){
checkbox channel("ChoOnOff"), pos(235,135), size(40, 43), value(1)
label bounds(235,178, 40, 11), text("On/Off"), colour("black")
rslider bounds(275,130,60,60), text("Mix"), channel("ChoMix"), range(0, 1, 0.5)
rslider bounds(325,130,60,60), text("Depth"), channel("ChoDep"), range(0, 0.1, 0.01,0.5, 0.001)
rslider bounds(375,130,60,60), text("Rate"), channel("ChoRte"), range(0, 20, 0.96, 0.5)
}

keyboard pos(10, 200), size(425, 80)
image bounds(5, 295, 240, 22), colour(75, 85, 90, 100), plant("credit"){
label bounds(0.03, 0.15, .9, .7), text("Author: Iain McCurdy |2012|"), colour("white")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE
massign 3,2

;Author: Iain McCurdy (2012)

;FUNCTION TABLES STORING MODAL FREQUENCY RATIOS===================================================================================================================================
;plucked string
girtos1 ftgen 0,0,-20, -2, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
;dahina
girtos2 ftgen 0,0,-6,-2, 1, 2.89, 4.95, 6.99, 8.01, 9.02
;banyan
girtos3 ftgen 0,0,-6,-2, 1, 2.0, 3.01, 4.01, 4.69, 5.63
;xylophone
girtos4 ftgen 0,0,-6,-2, 1, 3.932, 9.538, 16.688, 24.566, 31.147
;tibetan bowl (180mm)
girtos5 ftgen 0,0,-7,-2, 1, 2.77828, 5.18099, 8.16289, 11.66063, 15.63801, 19.99
;spinel sphere with diameter of 3.6675mm
girtos6 ftgen 0,0,-24,-2, 1, 1.026513174725, 1.4224916858532, 1.4478690202098, 1.4661959580455, 1.499452545408, 1.7891839345101, 1.8768994627782, 1.9645945254541, 1.9786543873113, 2.0334612432847, 2.1452852391916, 2.1561524686621, 2.2533435661294, 2.2905090816065, 2.3331798413917, 2.4567715528268, 2.4925556408289, 2.5661806088514, 2.6055768738808, 2.6692760296751, 2.7140956766436, 2.7543617293425, 2.7710411870043
;pot lid
girtos7 ftgen 0,0,-6,-2, 1, 3.2, 6.23, 6.27, 9.92, 14.15
;red cedar wood plate
girtos8 ftgen 0,0,-4,-2, 1, 1.47, 2.09, 2.56
;tubular bell
girtos9 ftgen 0,0,-10,-2, 272/437, 538/437, 874/437, 1281/437, 1755/437, 2264/437, 2813/437, 3389/437, 4822/437, 5255/437
;redwood wood plate
girtos10 ftgen 0,0,-4,-2, 1, 1.47, 2.11, 2.57
;douglas fir wood plate
girtos11 ftgen 0,0,-4,-2, 1, 1.42, 2.11, 2.47
;uniform wooden bar
girtos12 ftgen 0,0,-6,-2, 1, 2.572, 4.644, 6.984, 9.723, 12
;uniform aluminum bar
girtos13 ftgen 0,0,-6,-2, 1, 2.756, 5.423, 8.988, 13.448, 18.680
;vibraphone 1
girtos14 ftgen 0,0,-6,-2, 1, 3.984, 10.668, 17.979, 23.679, 33.642
;vibraphone 2
girtos15 ftgen 0,0,-6,-2, 1, 3.997, 9.469, 15.566, 20.863, 29.440
;Chalandi plates
girtos16 ftgen 0,0,-5,-2, 1, 1.72581, 5.80645, 7.41935, 13.91935
;tibetan bowl (152 mm)
girtos17 ftgen 0,0,-7,-2, 1, 2.66242, 4.83757, 7.51592, 10.64012, 14.21019, 18.14027
;tibetan bowl (140 mm)
girtos18 ftgen 0,0,-5,-2, 1, 2.76515, 5.12121, 7.80681, 10.78409
;wine glass
girtos19 ftgen 0,0,-5,-2, 1, 2.32, 4.25, 6.63, 9.38
;small handbell
girtos20 ftgen 0,0,-22,-2, 1, 1.0019054878049, 1.7936737804878, 1.8009908536585, 2.5201981707317, 2.5224085365854, 2.9907012195122, 2.9940548780488, 3.7855182926829, 3.8061737804878, 4.5689024390244, 4.5754573170732, 5.0296493902439, 5.0455030487805, 6.0759908536585, 5.9094512195122, 6.4124237804878, 6.4430640243902, 7.0826219512195, 7.0923780487805, 7.3188262195122, 7.5551829268293
;albert clock bell belfast
girtos21 ftgen 0,0,-22,-2, 2.043260,1.482916,1.000000,3.328848,4.761811,1.477056,0.612007,2.661295,1.002793,4.023776,0.254139,2.043916,4.032463,2.659438,4.775560,5.500494,3.331014,0.809697,2.391301, 0.254098,1.901476,2.366563 ;,0.614968,2.046543,1.814887,3.130744,2.484426,0.558874,0.801697,0.070870,3.617036,2.782656
;wood block
girtos22 ftgen 0,0,4,-2, 915/915,1540/915,1863/915,3112/915
;=================================================================================================================================================================================

;=================================================================================================================================================================================
;GEN09 FUNCTION TABLE VERSIONS OF THE MODAL FREQUENCY TABLES
;THESE AREN'T ACTUALLY NEEDED AS THE TABLES ARE CALCULATED IN INSTRUMENT 2 BUT IF INSTRUMENT 2 IS OMITTED THESE TABLES WILL BE NEEDED
;NOTE THAT PARTIAL NUMBER HAVE BEEN MULTIPLIED BY giRtosScale AND THAT THE FREQUENCY OF ANY OSCILLATOR THAT USES THESE TABLES WILL HAVE TO BE DIVIDED BY THE SAME NUMBER
giwave1 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2000,1.000,0, 3000,1.000,0, 4000,1.000,0, 5000,1.000,0, 6000,1.000,0, 7000,1.000,0, 8000,1.000,0, 9000,1.000,0, 10000,1.000,0, 11000,1.000,0, 12000,1.000,0, 13000,1.000,0, 14000,1.000,0, 15000,1.000,0, 16000,1.000,0, 17000,1.000,0, 18000,1.000,0, 19000,1.000,0, 20000,1.000,0
giwave2 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2890,1.000,0, 4950,1.000,0, 6990,1.000,0, 8010,1.000,0, 9020,1.000,0
giwave3 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2000,1.000,0, 3010,1.000,0, 4010,1.000,0, 4690,1.000,0, 5630,1.000,0
giwave4 ftgen 0, 0, 262144, 9, 1000,1.000,0, 3932,1.000,0, 9538,1.000,0, 16688,1.000,0, 24566,1.000,0, 31147,1.000,0
giwave5 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2778,0.500,0, 5180,0.250,0, 8162,0.125,0, 11660,0.062,0, 15638,0.031,0, 19990,0.016,0
giwave6 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1026,1.000,0, 1422,1.000,0, 1447,1.000,0, 1466,1.000,0, 1499,1.000,0, 1789,1.000,0, 1876,1.000,0, 1964,1.000,0, 1978,1.000,0, 2033,1.000,0, 2145,1.000,0, 2156,1.000,0, 2253,1.000,0, 2290,1.000,0, 2333,1.000,0, 2456,1.000,0, 2492,1.000,0, 2566,1.000,0, 2605,1.000,0, 2669,1.000,0, 2714,1.000,0
giwave7 ftgen 0, 0, 262144, 9, 1000,1.000,0, 3200,1.000,0, 6230,1.000,0, 6270,1.000,0, 9920,1.000,0, 14150,1.000,0
giwave8 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1470,1.000,0, 2090,1.000,0, 2560,1.000,0
giwave9 ftgen 0, 0, 262144, 9, 622,1.000,0, 1231,1.000,0, 2000,1.000,0, 2931,1.000,0, 4016,1.000,0, 5180,1.000,0, 6437,1.000,0, 7755,1.000,0, 11034,1.000,0, 12025,1.000,0
giwave10 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1470,1.000,0, 2110,1.000,0, 2570,1.000,0
giwave11 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1420,1.000,0, 2110,1.000,0, 2470,1.000,0
giwave12 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2572,1.000,0, 4644,1.000,0, 6984,1.000,0, 9723,1.000,0, 12000,1.000,0
giwave13 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2756,1.000,0, 5423,1.000,0, 8988,1.000,0, 13448,1.000,0, 18680,1.000,0
giwave14 ftgen 0, 0, 262144, 9, 1000,1.000,0, 3984,1.000,0, 10668,1.000,0, 17979,1.000,0, 23679,1.000,0, 33642,1.000,0
giwave15 ftgen 0, 0, 262144, 9, 1000,1.000,0, 3997,1.000,0, 9469,1.000,0, 15566,1.000,0, 20863,1.000,0, 29440,1.000,0
giwave16 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1725,1.000,0, 5806,1.000,0, 7419,1.000,0, 13919,1.000,0
giwave17 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2662,1.000,0, 4837,1.000,0, 7515,1.000,0, 10640,1.000,0, 14210,1.000,0, 18140,1.000,0
giwave18 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2765,1.000,0, 5121,1.000,0, 7806,1.000,0, 10784,1.000,0
giwave19 ftgen 0, 0, 262144, 9, 1000,1.000,0, 2320,1.000,0, 4250,1.000,0, 6630,1.000,0, 9380,1.000,0
giwave20 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1001,0.833,0, 1793,0.694,0, 1800,0.579,0, 2520,0.482,0, 2522,0.402,0, 2990,0.335,0, 2994,0.279,0, 3785,0.233,0, 3806,0.194,0, 4568,0.162,0, 4575,0.135,0, 5029,0.112,0, 5045,0.093,0, 6075,0.078,0, 5909,0.065,0, 6412,0.054,0, 6443,0.045,0, 7082,0.038,0, 7092,0.031,0, 7318,0.026,0, 7555,0.022,0
giwave21 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1001,0.833,0, 1793,0.694,0, 1800,0.579,0, 2520,0.482,0, 2522,0.402,0, 2990,0.335,0, 2994,0.279,0, 3785,0.233,0, 3806,0.194,0, 4568,0.162,0, 4575,0.135,0, 5029,0.112,0, 5045,0.093,0, 6075,0.078,0, 5909,0.065,0, 6412,0.054,0, 6443,0.045,0, 7082,0.038,0, 7092,0.031,0, 7318,0.026,0, 7555,0.022,0
giwave22 ftgen 0, 0, 262144, 9, 1000,1.000,0, 1001,0.833,0, 1793,0.694,0, 1800,0.579,0, 2520,0.482,0, 2522,0.402,0, 2990,0.335,0, 2994,0.279,0, 3785,0.233,0, 3806,0.194,0, 4568,0.162,0, 4575,0.135,0, 5029,0.112,0, 5045,0.093,0, 6075,0.078,0, 5909,0.065,0, 6412,0.054,0, 6443,0.045,0, 7082,0.038,0, 7092,0.031,0, 7318,0.026,0, 7555,0.022,0
;=================================================================================================================================================================================

gisine ftgen 0,0,4096,10,1 ;A SINE WAVE
giRtosScale = 100 ;SCALING FACTOR APPLIED TO RATIOS WRITTEN TO GEN09 FUNCTION TABLE
;FREQUENCY OF AUDIO OSCILLATOR WILL BE DIVIDED BY THIS VALUE
;TOO LOW A VALUE HERE WILL RESULT IN QUANTISATION OF PARTIAL FREQUENCIES
;TOO HIGH A VALUE WILL RESULT IN HIGHER PARTIALS BEING POORLY REPRESENTED IN THE TABLE, LEADING TO ALIASING
gilfoshape ftgen 0, 0, 4096, 19, 0.5, 1, 180, 1 ;U-SHAPE PARABOLA (USED BY THE CHORUS EFFECT)
gidurscal ftgen 0, 0, 128, -16, 10, 128, -4, 0.1 ;A FUNCTION USED TO RESCALE ENVELOPE DURATIONS ACCORDING TO NOTE PLAYED
givelscal ftgen 0, 0, 128, -16, 0, 128, -4, 1 ;A FUNCTION USED TO REMAP MIDI VELOCITY VALUES - THE CURVATURE OF THIS FUNCTION CAN BE CHANGED TO TAKE ACCOUNT OF THE VARYING VELOCITY RESPONSE OF DIFFERENT MIDI KEYBOARDS
gasend init 0

instr CreateGEN09Tables ;DERIVE GEN09 FUNCTION TABLE WAVEFORMS FROM THE GEN02 FUNCTION TABLES OF MODAL FREQUENCY RATIOS
;A MACRO IS DEFINED THAT READS A SINGLE MODAL FERQUENCY RATIO FROM A TABLE
#define PARTIAL(PartNum)
#
if $PartNum<=inratios then ;IF COUNTER IS WITHIN THE LIMITS OF THE NUMBER OF DEFINED MODAL FREQUENCY RATIOS...
irto$PartNum table $PartNum-1,girtos$WaveNum ;...READ A VALUE FROM THE TABLE
irto$PartNum = round(irto$PartNum*giRtosScale) ;MULTIPLY RATIO BY giRtosScale THEN INTEGERISE BYT ROUND TO THE NEAREST WHOLE NUMBER
iamp$PartNum = iamp/(iampscal^($PartNum-1)) ;DERIVE AMPLITUDE VALUE FOR THIS PARTIAL
else ;IF COUNTER IS BEYOND THE LIMITS OF THE NUMBER OF DEFINED MODAL FREQUENCY RATIOS...
irto$PartNum = 0 ;SET RATIO TO ZERO
iamp$PartNum = 0 ;SET PARTIAL STRENGTH TO ZERO
endif
#

;A MACRO IS DEFINED THAT CREATES A GEN09 TABLE FROM MODAL FREQUENCY DATA
#define WAVEFORM(WaveNum'AmpScal)
#
inratios = ftlen(girtos$WaveNum)
iampscal = $AmpScal ;AMPLITUDE SCALING
iamp = 1 ;PARTIAL STRENGTH OF FIRST PARTIAL
$PARTIAL(1) ;MACRO EXPANDED FOR EACH PARTIAL...
$PARTIAL(2)
$PARTIAL(3)
$PARTIAL(4)
$PARTIAL(5)
$PARTIAL(6)
$PARTIAL(7)
$PARTIAL(8)
$PARTIAL(9)
$PARTIAL(10)
$PARTIAL(11)
$PARTIAL(12)
$PARTIAL(13)
$PARTIAL(14)
$PARTIAL(15)
$PARTIAL(16)
$PARTIAL(17)
$PARTIAL(18)
$PARTIAL(19)
$PARTIAL(20)
$PARTIAL(21)
$PARTIAL(22)
;GENERATE A GEN09 FUNCTION TABLE (ALL PHASES ARE SET TO ZERO)
giwave$WaveNum ftgen 0,0,131072,9, irto1,iamp1,0, irto2,iamp2,0, irto3,iamp3,0, irto4,iamp4,0, irto5,iamp5,0, irto6,iamp6,0, irto7,iamp7,0, irto8,iamp8,0, irto9,iamp9,0, irto10,iamp10,0, irto11,iamp11,0, irto12,iamp12,0, irto13,iamp13,0, irto14,iamp14,0, irto15,iamp15,0, irto16,iamp16,0, irto17,iamp17,0, irto18,iamp18,0, irto19,iamp19,0, irto20,iamp20,0, irto21,iamp21,0, irto22,iamp22,0

;UNCOMMENT THE FOLLOWING LINE IF YOU WISH TO WRITE GENERATED TABLES TO A TEXT FILE FOR LATER USE
;fprints "GEN09InharmonicTables.txt", "giwave$WaveNum%tftgen%t0, 0, 131072s, 9, %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0,%t %d,%5.3f,0%n", irto1,iamp1, irto2,iamp2, irto3,iamp3, irto4,iamp4, irto5,iamp5, irto6,iamp6, irto7,iamp7, irto8,iamp8, irto9,iamp9, irto10,iamp10, irto11,iamp11, irto12,iamp12, irto13,iamp13, irto14,iamp14, irto15,iamp15, irto16,iamp16, irto17,iamp17, irto18,iamp18, irto19,iamp19, irto20,iamp20, irto21,iamp21, irto22,iamp22
#
;EXPAND MACRO FOR EACH WAVEFORM TO BE CREATED
;ARG1 = A COUNTER, SHOULD CORRESPOND TO NUMBER APPENDED TO 'girtos' FOR THE TABLE HANDLE OF THE REQUIRED MODAL FREQUENCIES TABLE
;ARG2 = PARTIAL STRENGTHS SCALING: 1=FLAT >1=HIGHER PARTIALS ARE INCREASINGLY ATTENUATED
$WAVEFORM(1' 1.5)
$WAVEFORM(2' 2)
$WAVEFORM(3' 1.5)
$WAVEFORM(4' 2)
$WAVEFORM(5' 2)
$WAVEFORM(6' 1)
$WAVEFORM(7' 1.2)
$WAVEFORM(8' 1.5)
$WAVEFORM(9' 1)
$WAVEFORM(10' 1)
$WAVEFORM(11' 1)
$WAVEFORM(12' 1.5)
$WAVEFORM(13' 1)
$WAVEFORM(14' 2)
$WAVEFORM(15' 2)
$WAVEFORM(16' 1.5)
$WAVEFORM(17' 2)
$WAVEFORM(18' 2)
$WAVEFORM(19' 1)
$WAVEFORM(20' 1.2)
$WAVEFORM(21' 1.1)
$WAVEFORM(22' 1.1)
endin

instr 2 ;SOUND GENERATING INSTRUMENT
iInstr chnget "Instr"
iAAtt chnget "AAtt"
iADec chnget "ADec"
iASus chnget "ASus"
iARel chnget "ARel"
iFAmt chnget "FAmt"
iFDec chnget "FDec"
iFSus chnget "FSus"
iFRel chnget "FRel"
iFShp chnget "FShp"
iAAtt = (iAAtt^3)*(15-0.001)+0.001
iADec = (iADec^3)*(15-0.001)+0.001
iARel = (iARel^3)*(15-0.001)+0.001
iFDec = (iFDec^3)*(15-0.001)+0.001
iFRel = (iFRel^3)*(15-0.001)+0.001

icps cpsmidi ;READ CPS VALUE IN FROM MIDI KEYBOARD
inum notnum ;READ MIDI NOTE NUMBER
ivel veloc 0,1 ;READ MIDI VELOCITY
ivel table ivel,givelscal,1 ;REMAP MIDI VELOCITY - SEE TABLE givelscal ABOVE
iscale table inum,gidurscal ;DURATIONAL RESCALING ACCORDING TO NOTE PLAYED - HIGHER NOTE WILL DECAY QUICKER IN REFLECTION OF REAL-WORLD CHARACTERISTICS

aenv expsegr 0.001,iAAtt,1,iADec*iscale,iASus+0.0001,iARel*iscale,0.0001 ;AMPLITUDE ENVELOPE WITH MIDI SENSING RELEASE SEGEMENT
asig poscil 0.1*aenv*ivel,icps/giRtosScale,giwave1+iInstr-1 ;AUDIO OSCILLATOR poscil3 USED FOR IMPROVED FIDELITY OVER OTHER OSCILLATORS. FREQUENCY IS SCALED DOWN ACCORIND TO THE VALUE OF giRtosScale DEFINED IN THE HEADER

;UNFORTUNATELY transegr DOESN'T SEEM TO WORK SO IN THE MEANTIME THIS RATHER PROTRACTED ALTERNATIVE WILL ACT AS A SUBSTITUTE
iFlev1 limit cpsoct((iFAmt*10*ivel)+4),icps,sr/2 ;DERIVE STARTING FILTER VALUE IN CPS FROM FLTK KNOB (RANGE 0 TO 1). LIMIT IT BETWEEN FUNDEMENTAL FREQ. AND NYQUIST.
iFsus = icps+cpsoct((iFSus*10)+4) ;DERIVE FILTER SUSTAIN VALUE IN CPS FROM FLTK KNOB VALUE (RANGE 0 - 1)
iFend = icps ;FINAL FILTER ENVELOPE VALUE IS ALWAYS FUNDEMENTAL FREQUENCY
krel release ;SENSE WHEN A NOTE HAS BEEN RELEASED. 1=NOTE_RELEAESD 0=NOTE_BEING_HELD
if krel==0 then ;IF NOTE IS BEGIN HELD...
kcf transeg iFlev1,iFDec*iscale,iFShp,iFsus ;CREATE ADS (ATTACK-DECAY-SUSTAIN) PART OF ENVELOPE
else ;OTHERWISE (WE ARE IN THE RELEASE STAGE)
ktrig changed krel ;INSTIGATE A SHORT REINITIALISATION TO DERIVE AN I-TIME VALUE OF THE CURRENT AMPLITUDE VALUE FOR THE STARTING POINT OF THE RELEASE ENVELOPE
if ktrig==1 then ;
reinit StartRel
endif
StartRel:
kcf transeg i(kcf),iFRel*iscale,iFShp,iFend ;RELEASE STAGE OF THE ENVELOPE. 'i(kcf)' AS THE STARTING VALUE ENSURES THAT IT ALWAYS PICKS UP FROM WHERE THE 'ADS' PART OF THE ENVELOPE LEFT OFF.
rireturn
endif
;asig butlp asig, kcf
asig clfilt asig, kcf, 0, 2 ;LOW PASS FILTER THE SOUND (SUBTRACTIVE SYNTHESIS)
gasend = gasend+asig

endin

instr 3
kChoOnOff chnget "ChoOnOff"
gkChoMix chnget "ChoMix"
gkChoRte chnget "ChoRte"
gkChoDep chnget "ChoDep"

if kChoOnOff==0 kgoto SKIP_CHORUS
kporttime linseg 0,0.001,1
kporttime = kporttime/gkChoRte
kdlt1 randomi ksmps/sr,gkChoDep,gkChoRte,1
kdlt1 portk kdlt1,kporttime
adlt1 interp kdlt1
acho1 vdelay gasend,adlt1*1000,1*1000
kdlt2 randomi ksmps/sr,gkChoDep,gkChoRte,1
kdlt2 portk kdlt2,kporttime
adlt2 interp kdlt2
acho2 vdelay gasend,adlt2*1000,1*1000
kpan1 randomi 0,1,gkChoRte,1
kpan2 randomi 0,1,gkChoRte,1
a1L,a1R pan2 acho1,kpan1
a2L,a2R pan2 acho2,kpan2
achoL = a1L+a2L
achoR = a1R+a2R
outs achoL*gkChoMix, achoR*gkChoMix
SKIP_CHORUS:

outs gasend, gasend ;SEND UN-CHORUSSED AUDIO TO THE OUTPUTS
clear gasend
endin

</CsInstruments>

<CsScore>
i "CreateGEN09Tables" 0 0
i 3 0 [60*60*24*7]
f 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 59
- 0
bin/cabbage-todo/Synths/PinkNoise.csd View File

@@ -0,0 +1,59 @@
<Cabbage>
form caption("Pink Noise"), size(230, 80), pluginID("pnse")
image bounds( 0, 0,230, 80), colour("pink"), shape("rounded"), outline("red"), line(4)
checkbox bounds( 20, 10, 80, 15), text("On/Off"), channel("onoff"), value(1), fontcolour("black")
combobox bounds( 20, 40, 70, 20), channel("method"), value(1), text("Gardner", "Kellet", "Kellet 2")
rslider bounds(100, 10, 60, 60), text("Amplitude"), channel("amp"), range(0, 1, 0.5, 0.5, 0.001), fontcolour("black")
rslider bounds(160, 10, 60, 60), text("N.Bands"), channel("numbands"), range(4, 32, 20, 1, 1), fontcolour("black")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE
massign 0,0

instr 1
konoff chnget "onoff" ;read in on/off switch widget value
if konoff==0 goto SKIP ;if on/off switch is off jump to skip label
kmethod chnget "method"
kmethod = kmethod - 1
knumbands chnget "numbands"
kamp chnget "amp"
ktrig changed kmethod, knumbands ;GENERATE BANG (A MOMENTARY '1') IF ANY OF THE INPUT VARIABLES CHANGE
if ktrig==1 then ;IF AN I-RATE VARIABLE HAS CHANGED
reinit UPDATE ;BEGIN A REINITIALISATION PASS FROM LABEL 'UPDATE'
endif ;END OF CONDITIONAL BRANCH
UPDATE: ;LABEL CALLED 'UPDATE'
if kmethod=0 then ;IF GARDNER METHOD HAS BEEN CHOSEN...
asigL pinkish kamp, i(kmethod), i(knumbands) ;GENERATE PINK NOISE
asigR pinkish kamp, i(kmethod), i(knumbands) ;GENERATE PINK NOISE
else ;OTHERWISE (I.E. 2ND OR 3RD METHOD HAS BEEN CHOSEN)
anoise unirand 2 ;WHITE NOISE BETWEEN ZERO AND 2
anoise = (anoise-1) ;OFFSET TO RANGE BETWEEN -1 AND 1
asigL pinkish anoise, i(kmethod) ;GENERATE PINK NOISE
asigR pinkish anoise, i(kmethod) ;GENERATE PINK NOISE
asigL = asigL * kamp ;RESCALE AMPLITUDE WITH gkpinkamp
asigR = asigR * kamp ;RESCALE AMPLITUDE WITH gkpinkamp
endif ;END OF CONDITIONAL
rireturn ;RETURN FROM REINITIALISATION PASS
outs asigL,asigR ;SEND AUDIO SIGNAL TO OUTPUT
SKIP: ;A label. Skip to here is on/off switch is off
endin


</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7] ;instrument that reads in widget data
</CsScore>

</CsoundSynthesizer>

+ 379
- 0
bin/cabbage-todo/Synths/Risset.csd View File

@@ -0,0 +1,379 @@
<Cabbage>
form caption("Jean Claude Risset collection") size(552, 330), colour("black"),pluginID("jea1")
rslider bounds(15, 10, 100, 100) channel("spread"), range(0,1,.5), caption("Spread"), colour("tomato"), midictrl(1, 1)
rslider bounds(120, 10, 100, 100) channel("semi"), range(-24,12,-12), caption("Coarse"), colour("tomato")
rslider bounds(225, 10, 100, 100) channel("detune"), range(-2,2,0), caption("Detune"), colour("tomato")
rslider bounds(330, 10, 100, 100) channel("vibamp"), range(0,20,0), caption("Vib Amp"), colour("tomato")
rslider bounds(435, 10, 100, 100) channel("vibrate"), range(0,20,0), caption("Vib rate"), colour("tomato")

groupbox bounds(15, 120, 240, 100), text("ADSR amplitude"), plant("ADSR"){
rslider bounds(.0, .3, .6, .6), text("A"), colour("orange"), channel("att"), range(0.01,3, .5)
rslider bounds(.25, .3, .6, .6), text("D"), colour("orange"), channel("dec"), range(0,1, .5)
rslider bounds(.5, .3, .6, .6), text("S"), colour("orange"), channel("sus"), range(0,1,.8)
rslider bounds(.75, .3, .6, .6), text("R"), colour("orange"), channel("rel"), range(0.01,3, .2)
}
;RissClar RissDrum RissFlute RissHarmon RissNoise RissOctave RissRing
combobox bounds(280,120, 160, 20), channel("select"), value(1), text("clar","snare", "flute","harmon","noise","octave","ring")
rslider bounds(280,150, 60, 60), text("Rev level"), colour("tomato"), channel("level"), range(0,1,.8)
rslider bounds(350, 150, 60, 60), text("Rev size"), colour("tomato"), channel("size"), range(.1,.99,.7)
checkbox bounds(420,150, 160, 30),channel("onoff"), text("Reverb On/Off"), value(0)

keyboard pos(1, 240), size(550, 60)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n -+rtmidi=null -M0 -b1024 -m0d
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 16
nchnls = 2
0dbfs = 1

;Author: Giorgio Zucco (2012)

ga1 init 0
ga2 init 0




;Risset opcodes

;**************************************************
opcode RissClar,a,kk

gisine1 ftgen 0 ,0 ,512, 7, -1, 200, -.5, 112, .5 ,200, 1
gisine3 ftgen 0 , 0, 512, 9, 1, 1, 0

kveloc,knote xin


kgate linenr kveloc,0,.2,.01
a1 linen 255,.085,.75,100
a1 poscil a1,knote,gisine3
a1 table a1+256,gisine1
xout a1*kgate
endop

;**************************************************
opcode RissDrum,a,kk

gitemp1 ftgen 0 , 0 ,512, 9 ,1, 1, 0
gitemp2 ftgen 0 , 0, 512, 5 ,4096 ,512, 1
gitemp3 ftgen 0 , 0, 512, 9 ,10 ,1 ,0, 16, 1.5, 0 ,22, 2 ,0, 23 ,1.5, 0
gitemp4 ftgen 0 , 0, 512, 9, 1, 1, 0
gitemp5 ftgen 0 , 0, 512, 5, 256, 512, 1

kveloc,knote xin


kgate linenr kveloc/2, 0, .2, .01
i1 = 6000*.3
i2 = 500*.1
i3 = 1
i4 = 6000*.8
i5 = 500
a1 randi 6000,4000
a1 poscil a1,i3,gitemp2
a1 poscil a1,3000,gitemp1
a2 poscil i1,i3,gitemp2
a2 poscil a2,knote*.01,gitemp3
a3 poscil i4,i3,gitemp5
a3 poscil a3,knote,gitemp4
aout = (a1+a2+a3)*.0001
xout aout*kgate
endop

;**************************************************
opcode RissGliss,a,ik

gitemp1 ftgen 0 ,0, 8192, 10, 1

iamp,kfreq xin

irise = .5
kenv1 expseg .01, irise, iamp*1200,1000-irise,1
k1 randi kfreq*.05, 1, .2/(1000)
k2 randi kfreq*.25, .1, .3/(1000)
a1 poscil kenv1, kfreq+k1+k2, gitemp1
kenv11 expseg .01, irise, iamp*.83*1200,1000-irise,1
k11 randi kfreq*.05*1.154, 1, .2/(1000)
k12 randi kfreq*.25*1.154, .1, .3/(1000)
a11 poscil kenv11, kfreq*1.154+k11+k12, gitemp1
kenv21 expseg .01, irise, iamp*.33*1200,1000-irise,1
k21 randi kfreq*.051*.417, 1, .2/(1000)
k22 randi kfreq*.25*1.417, .1, .3/(1000)
a21 poscil kenv21, kfreq*1.417+k21+k22, gitemp1
kenv31 expseg .01, irise, iamp*.67*1200,1000-irise,1
k31 randi kfreq*.05*1.604, 1, .2/(1000)
k32 randi kfreq*.25*1.604, .1, .3/(1000)
a31 poscil kenv31, kfreq*1.604+k31+k32, gitemp1
kenv41 expseg .01, irise, iamp*1200,1000-irise,1
k41 randi kfreq*.05*2.521, 1, .2/(1000)
k42 randi kfreq*.25*2.521, .1, .3/(1000)
a41 poscil kenv41, kfreq*2.521+k41+k42, gitemp1
kenv51 expseg .01, irise, iamp*.33*1200,1000-irise,1
k51 randi kfreq*.05*2.792, 1, .2/(1000)
k52 randi kfreq*.25*2.792, .1, .3/(1000)
a51 poscil kenv51, kfreq*2.792+k51+k52, gitemp1
kenv61 expseg .01, irise, iamp*.33*1200,1000-irise,1
k61 randi kfreq*.05*3.383, 1, .2/(1000)
k62 randi kfreq*.25*3.383, .1, .3/(1000)
a61 poscil kenv61, kfreq*3.383+k61+k62,gitemp1
a1=(a1+a11+a21+a31+a41+a51+a61)*.01

;kenv71 expseg .01, irise, 1, 100*.5, 1, 100*.5-irise, 1

;kdeclick linsegr 0,.1,1,.3,.5,0.001,.01
kdeclick linsegr 0.01, 0.01, 1, 0.33*1, 0

xout ((a1)*kdeclick)*.02 ; write output

endop


;**************************************************
opcode RissFlute,a,kk

gitemp1 ftgen 0 ,0, 512, 9 ,1 ,.26,0
gitemp2 ftgen 0 , 0, 512, 10, 1, .4, .2, .1, .1, .05

kamp,kfreq xin


k1 randi (kamp*.01),5
k1 = k1 + kamp
k2 poscil k1,1/.24,gitemp1
k2 = k2 + .74
a1 poscil k2,kfreq,gitemp2
kdeclick linsegr 0.1, 0.01, 1, 0.33*1, 0
xout a1*kdeclick
endop

;**************************************************
opcode RissHarmon,a,kk
gisine ftgen 0 , 0, 1024, 10, 1 ,0, 0 ,0 , .7, .7, .7, .7 ,.7, .7

kveloc,knote xin

kgate linenr kveloc,1,2,.01
i1 = .03
i2 = 2*.03
i3 = 3*.03
i4 = 4*.03
ampenv linenr 9,.01,1,.01
a1 poscil ampenv,knote,gisine
a2 poscil ampenv,knote+i1,gisine
a3 poscil ampenv,knote+i2,gisine
a4 poscil ampenv,knote+i3,gisine
a5 poscil ampenv,knote+i4,gisine
a6 poscil ampenv,knote-i1,gisine
a7 poscil ampenv,knote-i2,gisine
a8 poscil ampenv,knote-i3,gisine
a9 poscil ampenv,knote-i4,gisine
aout = ((a1+a2+a3+a4+a5+a6+a7+a8+a9)*kgate)*.05
xout aout
endop


;**************************************************
opcode RissNoise,a,ik


gitemp1 ftgen 0 ,0, 8192, 10, 1
gitemp2 ftgen 0 ,0, 8192, 7, -1, 8192, 1
gitemp3 ftgen 0 ,0, 8192, 7, 1, 4096, 1, 0, -1, 4096, -1
gitemp4 ftgen 0 ,0, 8192, 21, 1

iveloc,knote xin

kenv linsegr 0,.01,iveloc, 1, iveloc,2,iveloc*.2,.25, 0
aosc poscil kenv, 440, gitemp4
kenv expon 2, 1, .01
aosc2 butterbp aosc, knote, knote * kenv
aosc2 butterbp aosc2, knote, knote * kenv
aosc balance aosc2, aosc
aosc = aosc * .7
xout aosc

endop

;**************************************************
opcode RissOctave,a,kk


gitemp2 ftgen 0 ,0, 128, 8, 0, .5, 0, 63.5, 1, 63.5, 0, .5 ,0
gisine ftgen 0 ,0, 4096,10,1

kamp,kfreq xin

krate = .1


iphsoff = (65/5)*.01

ka1 = kamp
iph1 = 0
kamp1 poscil ka1,krate,gitemp2,iph1
kfreq1 = kfreq
asig1 poscil kamp1,kfreq1,gisine

ka2 = kamp
iph2 = iph1+iphsoff
kamp2 poscil ka2,krate,gitemp2,iph2
kfreq2 = kfreq*2
asig2 poscil kamp2,kfreq2,gisine

ka3 = kamp
iph3 = iph2+iphsoff
kamp3 poscil ka3,krate,gitemp2,iph3
kfreq3 = kfreq*3
asig3 poscil kamp3,kfreq3,gisine

ka4 = kamp
iph4 = iph3+iphsoff
kamp4 poscil ka4,krate,gitemp2,iph4
kfreq4 = kfreq*4
asig4 poscil kamp4,kfreq4,gisine

ka5 = kamp
iph5 = iph4+iphsoff
kamp5 poscil ka5,krate,gitemp2,iph5
kfreq5 = kfreq*5
asig5 poscil kamp5,kfreq5,gisine

add = asig1+asig2+asig3+asig4+asig5
;kenv linseg 0,p3/2,1,p3/2,0
aout = add
kdeclick linsegr 0.01, 0.01, 1, 0.33*1, 0
xout (aout*.5)*kdeclick
endop



;**************************************************
opcode RissRing,a,kk


gitemp2 ftgen 0 ,0, 512, 7, 0, 43, 1, 171, 1, 84, -1, 171, -1, 43, 0
gitemp3 ftgen 0 ,0, 512, 9, 1, 1, 0


kveloc,knote xin
kgate linenr kveloc/2, 0, .2, .01
a1 expseg .2,2.3,1,1-.01,.001
a1 poscil a1,knote,gitemp3
a2 poscil 10000,1500,gitemp2
aout = (a1*a2)*.001
xout aout*kgate

endop


;**************************************************



instr 1

;kselect init 1
;channel
;kmodfreq chnget "mod"
ksemi1 chnget "semi"
kdetune chnget "detune"
kspread chnget "spread"
iatt chnget "att"
idec chnget "dec"
isus chnget "sus"
irel chnget "rel"
klfoamp chnget "vibamp"
klforate chnget "vibrate"
kselect chnget "select"

;midi
imidinn notnum
iamp ampmidi 1
kbend pchbend 0,2 ;pitch bend
;lfo
klfo lfo klfoamp,klforate,2
kfreq1 = cpsmidinn(imidinn+kbend+int(ksemi1)) ;controllo midi
kfreq2 = cpsmidinn(imidinn+kbend+kdetune+int(ksemi1))



if kselect = 1 then
ariss1 RissClar iamp,kfreq1+klfo
ariss2 RissClar iamp,kfreq2+klfo
elseif kselect = 2 then
ariss1 RissDrum iamp,kfreq1+klfo
ariss2 RissDrum iamp,kfreq2+klfo
elseif kselect = 3 then
ariss1 RissFlute iamp,kfreq1+klfo
ariss2 RissFlute iamp,kfreq2+klfo
elseif kselect = 4 then
ariss1 RissHarmon iamp,kfreq1+klfo
ariss2 RissHarmon iamp,kfreq2+klfo
elseif kselect = 5 then
ariss1 RissNoise iamp,kfreq1+klfo
ariss2 RissNoise iamp,kfreq2+klfo
elseif kselect = 6 then
ariss1 RissOctave iamp,kfreq1+klfo
ariss2 RissOctave iamp,kfreq2+klfo
elseif kselect = 7 then
ariss1 RissRing iamp,kfreq1+klfo
ariss2 RissRing iamp,kfreq2+klfo
endif

ktrig changed kselect
if ktrig = 1 then
reinit play
endif
play:

;master
aL clip ariss1,0,0dbfs
aR clip ariss2,0,0dbfs


aoutL = ((aL * kspread) + (aR * (1 - kspread))) *.5
aoutR = ((aL * (1-kspread)) + (aR * kspread)) *.5

kadsr mxadsr iatt,idec,isus,irel

outs (aoutL*kadsr),(aoutR*kadsr)
vincr ga1,aoutL*kadsr
vincr ga2,aoutR*kadsr
endin

instr 10 ;reverb
ktrig chnget "onoff"
klevel chnget "level"
ksize chnget "size"
if ktrig = 1 then
al,ar reverbsc ga1,ga2,ksize,16000,sr,0
asum1 dcblock2 al
asum2 dcblock2 ar
else
asum1 = 0
asum2 = 0
endif

outs asum1*klevel,asum2*klevel
clear ga1,ga2
endin


</CsInstruments>
<CsScore>
f1 0 16384 10 1

;f0 3600
i1 0 36000
i10 0 36000
</CsScore>
</CsoundSynthesizer>

+ 64
- 0
bin/cabbage-todo/Synths/SonicLavaLampHelp.html View File

@@ -0,0 +1,64 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)">
<META NAME="CREATED" CONTENT="20120918;12541200">
<META NAME="CHANGED" CONTENT="20120920;9525900">
<STYLE TYPE="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<P STYLE="margin-bottom: 0cm"><FONT FACE="Verdana, sans-serif"><FONT SIZE=5><U><B>Sonic
Lava Lamp</B></U></FONT></FONT></P>
<P STYLE="margin-bottom: 0cm"><BR>
</P>
<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3>
<COL WIDTH=128*>
<COL WIDTH=128*>
<TR VALIGN=TOP>
<TD WIDTH=50%>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif"><B>xypad1:</B></FONT></P>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif">x
= LFO Speed</FONT></P>
<P STYLE="text-decoration: none"><FONT FACE="Verdana, sans-serif">y
= LFO Offset</FONT></P>
</TD>
<TD WIDTH=50%>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif"><B>xypad2:</B></FONT></P>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif">x
= LFO Shape</FONT></P>
<P STYLE="text-decoration: none"><FONT FACE="Verdana, sans-serif">y
= LFO Depth</FONT></P>
</TD>
</TR>
<TR VALIGN=TOP>
<TD WIDTH=50%>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif"><B>xypad3:</B></FONT></P>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif">x
= Pan Position</FONT></P>
<P STYLE="text-decoration: none"><FONT FACE="Verdana, sans-serif">y
= Amplitude</FONT></P>
</TD>
<TD WIDTH=50%>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif"><B>xypad4:</B></FONT></P>
<P STYLE="margin-bottom: 0cm; text-decoration: none"><FONT FACE="Verdana, sans-serif">x
= Delay Time</FONT></P>
<P><FONT FACE="Verdana, sans-serif"><SPAN STYLE="text-decoration: none">y
= Delay Send</SPAN></FONT></P>
</TD>
</TR>
</TABLE>
<P STYLE="margin-bottom: 0cm; font-weight: normal; text-decoration: none">
<FONT FACE="Verdana, sans-serif"><FONT SIZE=3>Turn on automation for
each xypad and set them all into slow motion...</FONT></FONT></P>
<P STYLE="margin-bottom: 0cm"><BR>
</P>
</BODY>
</HTML>

+ 983
- 0
bin/cabbage-todo/Synths/TR-808.csd View File

@@ -0,0 +1,983 @@
Saving patterns saves tables as text file to the pwd. Each save to a new pattern number creates a new text file on disk for that pattern.
Saving snapshots only saves visible widgets.

<Cabbage>
form caption("TR-808") size(800, 400), colour("SlateGrey"), pluginID("T808")

snapshot bounds( 10,373,200, 20), preset("TR-808"), master(1), items("Preset 1", "Preset 2", "Preset 3", "Preset 4", "Preset 5", "Preset 6", "Preset 7", "Preset 8", "Preset 9", "Preset 10")
label bounds(220,375,250, 14), text("Author: Iain McCurdy |2012|"), colour("white")

groupbox bounds( 0, 0, 50, 225), text("B.Drum"),FontColour("black"), colour(192,192,192){
checkbox bounds(10, 24, 5, 5), colour("yellow"), channel("Act1"), value(0), shape("ellipse")
rslider bounds( 5, 25, 45, 45), text("Level"), FontColour("black"), channel("level1"), range(0, 2, 1)
rslider bounds( 5, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune1"), range(-2, 2, 0)
rslider bounds( 5,125, 45, 45), text("Decay"), FontColour("black"), channel("dur1"), range(0.25, 2, 1, 0.8)
rslider bounds( 5,175, 45, 45), text("Pan"), FontColour("black"),channel("pan1"), range(0, 1, 0.5)
}
groupbox bounds(50, 0, 50, 225), text("Snare"), FontColour("black"),colour(202,202,202){
checkbox bounds(60, 24, 5, 5), colour("yellow"), channel("Act2"), value(0), shape("ellipse")
rslider bounds(55, 25, 45, 45), text("Level"), FontColour("black"), channel("level2"), range(0, 2, 1)
rslider bounds(55, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune2"), range(-2, 2, 0)
rslider bounds(55,125, 45, 45), text("Decay"), FontColour("black"), channel("dur2"), range(0.25, 2, 1, 0.8)
rslider bounds(55,175, 45, 45), text("Pan"), FontColour("black"),channel("pan2"), range(0, 1, 0.5)
}
groupbox bounds(100, 0, 50, 225), text("Open HH"), FontColour("black"), colour(212,212,212){
checkbox bounds(110, 24, 5, 5), colour("yellow"), channel("Act3"), value(0), shape("ellipse")
rslider bounds(105, 25, 45, 45), text("Level"), FontColour("black"), channel("level3"), range(0, 2, 1)
rslider bounds(105, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune3"), range(-2, 2, 0)
rslider bounds(105,125, 45, 45), text("Decay"), FontColour("black"),channel("dur3"), range(0.25, 2, 1, 0.8)
rslider bounds(105,175, 45, 45), text("Pan"), FontColour("black"),channel("pan3"), range(0, 1, 0.5)
}
groupbox bounds(150, 0, 50, 225), text("Cl. HH"),FontColour("black"),colour(222,222,222){
checkbox bounds(160, 24, 5, 5), colour("yellow"), channel("Act4"), value(0), shape("ellipse")
rslider bounds(155, 25, 45, 45), text("Level"), FontColour("black"), channel("level4"), range(0, 2, 1)
rslider bounds(155, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune4"), range(-2, 2, 0)
rslider bounds(155,125, 45, 45), text("Decay"), FontColour("black"),channel("dur4"), range(0.25, 2, 1, 0.8)
rslider bounds(155,175, 45, 45), text("Pan"), FontColour("black"),channel("pan4"), range(0, 1, 0.5)
}
groupbox bounds(200, 0, 50, 225), text("Hi Tom"), FontColour("black"),colour(232,232,232){
checkbox bounds(210, 24, 5, 5), colour("yellow"), channel("Act5"), value(0), shape("ellipse")
rslider bounds(205, 25, 45, 45), text("Level"), FontColour("black"), channel("level5"), range(0, 2, 1)
rslider bounds(205, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune5"), range(-2, 2, 0)
rslider bounds(205,125, 45, 45), text("Decay"), FontColour("black"),channel("dur5"), range(0.25, 2, 1, 0.8)
rslider bounds(205,175, 45, 45), text("Pan"), FontColour("black"),channel("pan5"), range(0, 1, 0.5)
}
groupbox bounds(250, 0, 50, 225), text("Mid Tom"),FontColour("black"), colour(242,242,242){
checkbox bounds(260, 24, 5, 5), colour("yellow"), channel("Act6"), value(0), shape("ellipse")
rslider bounds(255, 25, 45, 45), text("Level"), FontColour("black"), channel("level6"), range(0, 2, 1)
rslider bounds(255, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune6"), range(-2, 2, 0)
rslider bounds(255,125, 45, 45), text("Decay"), FontColour("black"),channel("dur6"), range(0.25, 2, 1, 0.8)
rslider bounds(255,175, 45, 45), text("Pan"), FontColour("black"),channel("pan6"), range(0, 1, 0.5)
}
groupbox bounds(300, 0, 50, 225), text("Low Tom"),FontColour("black"), colour(232,232,232){
checkbox bounds(310, 24, 5, 5), colour("yellow"), channel("Act7"), value(0), shape("ellipse")
rslider bounds(305, 25, 45, 45), text("Level"), FontColour("black"), channel("level7"), range(0, 2, 1)
rslider bounds(305, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune7"), range(-2, 2, 0)
rslider bounds(305,125, 45, 45), text("Decay"), FontColour("black"),channel("dur7"), range(0.25, 2, 1, 0.8)
rslider bounds(305,175, 45, 45), text("Pan"), FontColour("black"),channel("pan7"), range(0, 1, 0.5)
}
groupbox bounds(350, 0, 50, 225), text("Cymbal"), FontColour("black"),colour(222,222,222){
checkbox bounds(360, 24, 5, 5), colour("yellow"), channel("Act8"), value(0), shape("ellipse")
rslider bounds(355, 25, 45, 45), text("Level"), FontColour("black"), channel("level8"), range(0, 2, 1)
rslider bounds(355, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune8"), range(-2, 2, 0)
rslider bounds(355,125, 45, 45), text("Decay"), FontColour("black"),channel("dur8"), range(0.25, 2, 1, 0.8)
rslider bounds(355,175, 45, 45), text("Pan"), FontColour("black"),channel("pan8"), range(0, 1, 0.5)
}
groupbox bounds(400, 0, 50, 225), text("Rim Shot"),FontColour("black"), colour(212,212,212){
checkbox bounds(410, 24, 5, 5), colour("yellow"), channel("Act9"), value(0), shape("ellipse")
rslider bounds(405, 25, 45, 45), text("Level"), FontColour("black"), channel("level9"), range(0, 2, 1)
rslider bounds(405, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune9"), range(-2, 2, 0)
rslider bounds(405,125, 45, 45), text("Decay"), FontColour("black"),channel("dur9"), range(0.25, 2, 1, 0.8)
rslider bounds(405,175, 45, 45), text("Pan"), FontColour("black"),channel("pan9"), range(0, 1, 0.5)
}
groupbox bounds(450, 0, 50, 225), text("Claves"), FontColour("black"),colour(202,202,202){
checkbox bounds(460, 24, 5, 5), colour("yellow"), channel("Act10"), value(0), shape("ellipse")
rslider bounds(455, 25, 45, 45), text("Level"), FontColour("black"), channel("level10"), range(0, 2, 1)
rslider bounds(455, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune10"), range(-2, 2, 0)
rslider bounds(455,125, 45, 45), text("Decay"), FontColour("black"),channel("dur10"), range(0.25, 2, 1, 0.8)
rslider bounds(455,175, 45, 45), text("Pan"), FontColour("black"),channel("pan10"), range(0, 1, 0.5)
}
groupbox bounds(500, 0, 50, 225), text("Cowbell"),FontColour("black"), colour(192,192,192){
checkbox bounds(510, 24, 5, 5), colour("yellow"), channel("Act11"), value(0), shape("ellipse")
rslider bounds(505, 25, 45, 45), text("Level"), FontColour("black"), channel("level11"), range(0, 2, 1)
rslider bounds(505, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune11"), range(-2, 2, 0)
rslider bounds(505,125, 45, 45), text("Decay"), FontColour("black"),channel("dur11"), range(0.25, 2, 1, 0.8)
rslider bounds(505,175, 45, 45), text("Pan"), FontColour("black"),channel("pan11"), range(0, 1, 0.5)
}
groupbox bounds(550, 0, 50, 225), text("Clap"), FontColour("black"),colour(182,182,182){
checkbox bounds(560, 24, 5, 5), colour("yellow"), channel("Act12"), value(0), shape("ellipse")
rslider bounds(555, 25, 45, 45), text("Level"),FontColour("black"), channel("level12"), range(0, 2, 1)
rslider bounds(555, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune12"), range(-2, 2, 0)
rslider bounds(555,125, 45, 45), text("Decay"), FontColour("black"), channel("dur12"), range(0.25, 2, 1, 0.8)
rslider bounds(555,175, 45, 45), text("Pan"), FontColour("black"),channel("pan12"), range(0, 1, 0.5)
}
groupbox bounds(600, 0, 50, 225), text("Maraca"),FontColour("black"), colour(172,172,172){
checkbox bounds(610, 24, 5, 5), colour("yellow"), channel("Act13"), value(0), shape("ellipse")
rslider bounds(605, 25, 45, 45), text("Level"), FontColour("black"), channel("level13"), range(0, 2, 1)
rslider bounds(605, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune13"), range(-2, 2, 0)
rslider bounds(605,125, 45, 45), text("Decay"), FontColour("black"), channel("dur13"), range(0.25, 2, 1, 0.8)
rslider bounds(605,175, 45, 45), text("Pan"), FontColour("black"),channel("pan13"), range(0, 1, 0.5)
}
groupbox bounds(650, 0, 50, 225), text("Hi Conga"),FontColour("black"), colour(162,162,162){
checkbox bounds(660, 24, 5, 5), colour("yellow"), channel("Act14"), value(0), shape("ellipse")
rslider bounds(655, 25, 45, 45), text("Level"), FontColour("black"), channel("level14"), range(0, 2, 1)
rslider bounds(655, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune14"), range(-2, 2, 0)
rslider bounds(655,125, 45, 45), text("Decay"), FontColour("black"),channel("dur14"), range(0.25, 2, 1, 0.8)
rslider bounds(655,175, 45, 45), text("Pan"), FontColour("black"),channel("pan14"), range(0, 1, 0.5)
}
groupbox bounds(700, 0, 50, 225), text("Md Cnga"),FontColour("black"), colour(152,152,152){
checkbox bounds(710, 24, 5, 5), colour("yellow"), channel("Act15"), value(0), shape("ellipse")
rslider bounds(705, 25, 45, 45), text("Level"), FontColour("black"), channel("level15"), range(0, 2, 1)
rslider bounds(705, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune15"), range(-2, 2, 0)
rslider bounds(705,125, 45, 45), text("Decay"), FontColour("black"),channel("dur15"), range(0.25, 2, 1, 0.8)
rslider bounds(705,175, 45, 45), text("Pan"), FontColour("black"),channel("pan15"), range(0, 1, 0.5)
}
groupbox bounds(750, 0, 50, 225), text("Lo Cnga"),FontColour("black"), colour(142,142,142){
checkbox bounds(760, 24, 5, 5), colour("yellow"), channel("Act16"), value(0), shape("ellipse")
rslider bounds(755, 25, 45, 45), text("Level"), FontColour("black"), channel("level16"), range(0, 2, 1)
rslider bounds(755, 75, 45, 45), text("Tune"), FontColour("black"), channel("tune16"), range(-2, 2, 0)
rslider bounds(755,125, 45, 45), text("Decay"), FontColour("black"),channel("dur16"), range(0.25, 2, 1, 0.8)
rslider bounds(755,175, 45, 45), text("Pan"), FontColour("black"),channel("pan16"), range(0, 1, 0.5)
}

keyboard pos(0, 225), size(800, 80)

button bounds( 10,315, 80, 25), text("Stop", "Run"), channel("OnOff"), value(0)
combobox bounds( 10,345, 80, 15), channel("sound"), value(1), text("Bass Drum","Snare","Open HH","Cl. HH","Hi Tom","Mid Tom","Lo Tom","Cymbal","Rimshot","Claves","Cowbell","Clap","Maraca","Hi Conga","Mid Conga","Lo Conga")
button bounds(462,315, 80, 20), text("Clear","Clear"), channel("clear"), value(0)
button bounds(462,338, 38, 20), text("Save","Save"), channel("save"), value(0)
button bounds(502,338, 38, 20), text("Load","Load"), channel("load"), value(0)
label bounds(544,328, 48, 10), text("PATTERN"), colour("black"), FontColour("black")
combobox bounds(544,338, 48, 20), channel("pattern"), value(1), text("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16")
rslider bounds(593,310, 60, 60), text("Accent"), FontColour("black"), channel("AccLev"), range(0, 1, 0.4)
rslider bounds(643,310, 60, 60), text("Tempo"), FontColour("black"), channel("tempo"), range(10, 500, 70, 1, 1)
rslider bounds(693,310, 60, 60), text("Swing"), FontColour("black"), channel("swing"), range(0, 0.5, 0)
rslider bounds(743,310, 60, 60), text("Level"), FontColour("black"), channel("level"), range(0, 2, 1)

label bounds(143,312, 12, 10), text("1"), colour("black"), FontColour("black")
label bounds(163,312, 12, 10), text("2"), colour("black"), FontColour("black")
label bounds(183,312, 12, 10), text("3"), colour("black"), FontColour("black")
label bounds(203,312, 12, 10), text("4"), colour("black"), FontColour("black")
label bounds(223,312, 12, 10), text("5"), colour("black"), FontColour("black")
label bounds(243,312, 12, 10), text("6"), colour("black"), FontColour("black")
label bounds(263,312, 12, 10), text("7"), colour("black"), FontColour("black")
label bounds(283,312, 12, 10), text("8"), colour("black"), FontColour("black")
label bounds(303,312, 12, 10), text("9"), colour("black"), FontColour("black")
label bounds(320,312, 12, 10), text("10"), colour("black"), FontColour("black")
label bounds(340,312, 12, 10), text("11"), colour("black"), FontColour("black")
label bounds(360,312, 12, 10), text("12"), colour("black"), FontColour("black")
label bounds(380,312, 12, 10), text("13"), colour("black"), FontColour("black")
label bounds(400,312, 12, 10), text("14"), colour("black"), FontColour("black")
label bounds(420,312, 12, 10), text("15"), colour("black"), FontColour("black")
label bounds(440,312, 12, 10), text("16"), colour("black"), FontColour("black")

label bounds(122, 325, 30, 12), text("On"), colour("black"), FontColour("black")
checkbox bounds(140, 325, 12, 12), channel("On1"), value(0)
checkbox bounds(160, 325, 12, 12), channel("On2"), value(0)
checkbox bounds(180, 325, 12, 12), channel("On3"), value(0)
checkbox bounds(200, 325, 12, 12), channel("On4"), value(0)
checkbox bounds(220, 325, 12, 12), channel("On5"), value(0)
checkbox bounds(240, 325, 12, 12), channel("On6"), value(0)
checkbox bounds(260, 325, 12, 12), channel("On7"), value(0)
checkbox bounds(280, 325, 12, 12), channel("On8"), value(0)
checkbox bounds(300, 325, 12, 12), channel("On9"), value(0)
checkbox bounds(320, 325, 12, 12), channel("On10"), value(0)
checkbox bounds(340, 325, 12, 12), channel("On11"), value(0)
checkbox bounds(360, 325, 12, 12), channel("On12"), value(0)
checkbox bounds(380, 325, 12, 12), channel("On13"), value(0)
checkbox bounds(400, 325, 12, 12), channel("On14"), value(0)
checkbox bounds(420, 325, 12, 12), channel("On15"), value(0)
checkbox bounds(440, 325, 12, 12), channel("On16"), value(0)

label bounds( 98, 345, 40, 12), text("Accent"), colour("black"), FontColour("black")
checkbox bounds(140, 345, 12, 12), channel("Acc1"), value(0), colour("yellow")
checkbox bounds(160, 345, 12, 12), channel("Acc2"), value(0), colour("yellow")
checkbox bounds(180, 345, 12, 12), channel("Acc3"), value(0), colour("yellow")
checkbox bounds(200, 345, 12, 12), channel("Acc4"), value(0), colour("yellow")
checkbox bounds(220, 345, 12, 12), channel("Acc5"), value(0), colour("yellow")
checkbox bounds(240, 345, 12, 12), channel("Acc6"), value(0), colour("yellow")
checkbox bounds(260, 345, 12, 12), channel("Acc7"), value(0), colour("yellow")
checkbox bounds(280, 345, 12, 12), channel("Acc8"), value(0), colour("yellow")
checkbox bounds(300, 345, 12, 12), channel("Acc9"), value(0), colour("yellow")
checkbox bounds(320, 345, 12, 12), channel("Acc10"), value(0), colour("yellow")
checkbox bounds(340, 345, 12, 12), channel("Acc11"), value(0), colour("yellow")
checkbox bounds(360, 345, 12, 12), channel("Acc12"), value(0), colour("yellow")
checkbox bounds(380, 345, 12, 12), channel("Acc13"), value(0), colour("yellow")
checkbox bounds(400, 345, 12, 12), channel("Acc14"), value(0), colour("yellow")
checkbox bounds(420, 345, 12, 12), channel("Acc15"), value(0), colour("yellow")
checkbox bounds(440, 345, 12, 12), channel("Acc16"), value(0), colour("yellow")

</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-n -+rtmidi=null -M0 -dm0
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1
massign 0,2

;Author: Iain McCurdy (2012)

gisine ftgen 0,0,1024,10,1 ;A SINE WAVE
gicos ftgen 0,0,65536,9,1,1,90 ;A COSINE WAVE
gkoff init 0
; 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16
giOn1 ftgen 0,0,16,2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0 ;BD
giOn2 ftgen 0,0,16,2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0 ;SN
giOn3 ftgen 0,0,16,2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ;HHO
giOn4 ftgen 0,0,16,2, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ;HHCl
giOn5 ftgen 0,0,16,2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Hi Tom
giOn6 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Mid Tom
giOn7 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ;Lo Tom
giOn8 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 ;Cym
giOn9 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Rimshot
giOn10 ftgen 0,0,16,2, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0 ;Claves
giOn11 ftgen 0,0,16,2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1 ;Cowbell
giOn12 ftgen 0,0,16,2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ;Clap
giOn13 ftgen 0,0,16,2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ;Maraca
giOn14 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 ;Hi Conga
giOn15 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 ;Mid Conga
giOn16 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ;Lo Conga
giAcc1 ftgen 0,0,16,2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;BD
giAcc2 ftgen 0,0,16,2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;SN
giAcc3 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;HHO
giAcc4 ftgen 0,0,16,2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ;HHCl
giAcc5 ftgen 0,0,16,2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Hi Tom
giAcc6 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Mid Tom
giAcc7 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Lo Tom
giAcc8 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ;Cym
giAcc9 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Rimshot
giAcc10 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Claves
giAcc11 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Cowbell
giAcc12 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;Clap
giAcc13 ftgen 0,0,16,2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ;Maraca
giAcc14 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ;Hi Conga
giAcc15 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ;Mid Conga
giAcc16 ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ;Lo Conga
giblank ftgen 0,0,16,2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;blank

instr 1 ;READ IN WIDGETS, SCAN MIDI NOTES PLAYED AND RELAY TO DRUM SOUNDS
;READ IN WIDGETS
gklevel1 chnget "level1"
gklevel2 chnget "level2"
gklevel3 chnget "level3"
gklevel4 chnget "level4"
gklevel5 chnget "level5"
gklevel6 chnget "level6"
gklevel7 chnget "level7"
gklevel8 chnget "level8"
gklevel9 chnget "level9"
gklevel10 chnget "level10"
gklevel11 chnget "level11"
gklevel12 chnget "level12"
gklevel13 chnget "level13"
gklevel14 chnget "level14"
gklevel15 chnget "level15"
gklevel16 chnget "level16"
gktune1 chnget "tune1"
gktune2 chnget "tune2"
gktune3 chnget "tune3"
gktune4 chnget "tune4"
gktune5 chnget "tune5"
gktune6 chnget "tune6"
gktune7 chnget "tune7"
gktune8 chnget "tune8"
gktune9 chnget "tune9"
gktune10 chnget "tune10"
gktune11 chnget "tune11"
gktune12 chnget "tune12"
gktune13 chnget "tune13"
gktune14 chnget "tune14"
gktune15 chnget "tune15"
gktune16 chnget "tune16"
gkdur1 chnget "dur1"
gkdur2 chnget "dur2"
gkdur3 chnget "dur3"
gkdur4 chnget "dur4"
gkdur5 chnget "dur5"
gkdur6 chnget "dur6"
gkdur7 chnget "dur7"
gkdur8 chnget "dur8"
gkdur9 chnget "dur9"
gkdur10 chnget "dur10"
gkdur11 chnget "dur11"
gkdur12 chnget "dur12"
gkdur13 chnget "dur13"
gkdur14 chnget "dur14"
gkdur15 chnget "dur15"
gkdur16 chnget "dur16"
gkpan1 chnget "pan1"
gkpan2 chnget "pan2"
gkpan3 chnget "pan3"
gkpan4 chnget "pan4"
gkpan5 chnget "pan5"
gkpan6 chnget "pan6"
gkpan7 chnget "pan7"
gkpan8 chnget "pan8"
gkpan9 chnget "pan9"
gkpan10 chnget "pan10"
gkpan11 chnget "pan11"
gkpan12 chnget "pan12"
gkpan13 chnget "pan13"
gkpan14 chnget "pan14"
gkpan15 chnget "pan15"
gkpan16 chnget "pan16"
gkOnOff chnget "OnOff"
gksound chnget "sound"
gkOn1 chnget "On1"
gkOn2 chnget "On2"
gkOn3 chnget "On3"
gkOn4 chnget "On4"
gkOn5 chnget "On5"
gkOn6 chnget "On6"
gkOn7 chnget "On7"
gkOn8 chnget "On8"
gkOn9 chnget "On9"
gkOn10 chnget "On10"
gkOn11 chnget "On11"
gkOn12 chnget "On12"
gkOn13 chnget "On13"
gkOn14 chnget "On14"
gkOn15 chnget "On15"
gkOn16 chnget "On16"
gkAcc1 chnget "Acc1"
gkAcc2 chnget "Acc2"
gkAcc3 chnget "Acc3"
gkAcc4 chnget "Acc4"
gkAcc5 chnget "Acc5"
gkAcc6 chnget "Acc6"
gkAcc7 chnget "Acc7"
gkAcc8 chnget "Acc8"
gkAcc9 chnget "Acc9"
gkAcc10 chnget "Acc10"
gkAcc11 chnget "Acc11"
gkAcc12 chnget "Acc12"
gkAcc13 chnget "Acc13"
gkAcc14 chnget "Acc14"
gkAcc15 chnget "Acc15"
gkAcc16 chnget "Acc16"
gkclear chnget "clear"
gksave chnget "save"
gkload chnget "load"
gkpattern chnget "pattern"
gkAccLev chnget "AccLev"
gktempo chnget "tempo"
gkswing chnget "swing"
gklevel chnget "level"
;START/STOP SEQUENCER
ktrig changed gkOnOff ;if Run/Stop button is changed...
if ktrig==1 then ;
if gkOnOff==1 then ;...if Run/Stop has been changed to 'Run'...
event "i",3,0,-1 ;...start instr 3 playing a held note
else ;otherwise...
event "i",-3,0,0 ;...stop instr 3 playing
endif
endif
;CLEAR SEQUENCES FOR ALL DRUM SOUNDS
ktrig changed gkclear
if ktrig==1 then
tablecopy giOn1, giblank ;copy blank table over existing sequence for voice 1
tablecopy giOn2, giblank ;repeat for every other voice
tablecopy giOn3, giblank
tablecopy giOn4, giblank
tablecopy giOn5, giblank
tablecopy giOn6, giblank
tablecopy giOn7, giblank
tablecopy giOn8, giblank
tablecopy giOn9, giblank
tablecopy giOn10, giblank
tablecopy giOn11, giblank
tablecopy giOn12, giblank
tablecopy giOn13, giblank
tablecopy giOn14, giblank
tablecopy giOn15, giblank
tablecopy giOn16, giblank
tablecopy giAcc1, giblank
tablecopy giAcc2, giblank
tablecopy giAcc3, giblank
tablecopy giAcc4, giblank
tablecopy giAcc5, giblank
tablecopy giAcc6, giblank
tablecopy giAcc7, giblank
tablecopy giAcc8, giblank
tablecopy giAcc9, giblank
tablecopy giAcc10, giblank
tablecopy giAcc11, giblank
tablecopy giAcc12, giblank
tablecopy giAcc13, giblank
tablecopy giAcc14, giblank
tablecopy giAcc15, giblank
tablecopy giAcc16, giblank
endif
;STORE SEQUENCE TABLES
ktrig changed gksave ;if save button is toggled...
if ktrig==1 then
reinit SAVE_TABLES ;begin a reinitialisation pass from label (ftsave operates only at i-time)
endif
SAVE_TABLES:
SFileName sprintf "TR-808_pattern.%d.txt", i(gkpattern) ;create the file name (string variable) that will be used to name the text file that will contain the pattern data
ftsave SFileName, 1, giOn1, giOn2, giOn3, giOn4, giOn5, giOn6, giOn7, giOn8, giOn9, giOn10, giOn11, giOn12, giOn13, giOn14, giOn15, giOn16, giAcc1, giAcc2, giAcc3, giAcc4, giAcc5, giAcc6, giAcc7, giAcc8, giAcc9, giAcc10, giAcc11, giAcc12, giAcc13, giAcc14, giAcc15, giAcc16 ;save all tables (on information and accents) to a text file in the pwd
rireturn

;LOAD SEQUENCE TABLES
ktrig changed gkload ;if load button is toggled...
if ktrig==1 then
reinit LOAD_TABLES ;begin a reinitialisation pass from label (ftload operates only at i-time)
endif
LOAD_TABLES:
SFileName sprintf "TR-808_pattern.%d.txt", i(gkpattern) ;create the file name (string variable) that will be the name of the file from which data will be retrieved
ftload SFileName, 1, giOn1, giOn2, giOn3, giOn4, giOn5, giOn6, giOn7, giOn8, giOn9, giOn10, giOn11, giOn12, giOn13, giOn14, giOn15, giOn16, giAcc1, giAcc2, giAcc3, giAcc4, giAcc5, giAcc6, giAcc7, giAcc8, giAcc9, giAcc10, giAcc11, giAcc12, giAcc13, giAcc14, giAcc15, giAcc16 ;load all tables (on information and accents) to a text file in the pwd
rireturn
;UPDATE SEQUENCE DISPLAY
ktrig changed gksound,gkclear,gkload
if ktrig==1 then
#define UPDATE_SEQUENCE(N)
#
kval tablekt $N-1,giOn1+gksound-1
chnset kval,"On$N"
kval tablekt $N-1,giAcc1+gksound-1
chnset kval,"Acc$N"
#
$UPDATE_SEQUENCE(1)
$UPDATE_SEQUENCE(2)
$UPDATE_SEQUENCE(3)
$UPDATE_SEQUENCE(4)
$UPDATE_SEQUENCE(5)
$UPDATE_SEQUENCE(6)
$UPDATE_SEQUENCE(7)
$UPDATE_SEQUENCE(8)
$UPDATE_SEQUENCE(9)
$UPDATE_SEQUENCE(10)
$UPDATE_SEQUENCE(11)
$UPDATE_SEQUENCE(12)
$UPDATE_SEQUENCE(13)
$UPDATE_SEQUENCE(14)
$UPDATE_SEQUENCE(15)
$UPDATE_SEQUENCE(16)
endif
;UPDATE TABLE IF SEQUENCE BUTTON CHANGED
#define UPDATE_TABLE(N)
#
ktrig changed gkOn$N
if ktrig==1 then
tablewkt gkOn$N,$N-1,giOn1+gksound-1
endif
ktrig changed gkAcc$N
if ktrig==1 then
tablewkt gkAcc$N,$N-1,giAcc1+gksound-1
endif
#
$UPDATE_TABLE(1)
$UPDATE_TABLE(2)
$UPDATE_TABLE(3)
$UPDATE_TABLE(4)
$UPDATE_TABLE(5)
$UPDATE_TABLE(6)
$UPDATE_TABLE(7)
$UPDATE_TABLE(8)
$UPDATE_TABLE(9)
$UPDATE_TABLE(10)
$UPDATE_TABLE(11)
$UPDATE_TABLE(12)
$UPDATE_TABLE(13)
$UPDATE_TABLE(14)
$UPDATE_TABLE(15)
$UPDATE_TABLE(16)
endin

instr 2 ;READ MIDI AND TRIGGER NOTES
inum notnum ;READ IN MIDI NOTE NUMBER
idb veloc -30,0 ;READ IN MIDI NOTE VELOCITY (WILL BE USED AS A DECIBEL VALUE)
iinstr wrap inum,0,16 ;MAP MIDI NOTE NUMBERS (RANGE: 0 - 127) TO DRUM SOUND NUMBER (0 - 15)
event_i "i",101+iinstr,0,0.001,ampdbfs(idb) ;CALL THE RELEVANT INSTRUMENT AND SEND AMPLITUDE VALUE AS p4
endin

instr 3 ;PLAY SEQUENCE
gindx init 0
ktick metro (gktempo*4)/60
;SWING
kSwingBeat init 0
kSwingTime = (kSwingBeat==1?(60*gkswing)/(gktempo*4):0)
if ktick==1 then
kSwingBeat = abs(kSwingBeat-1) ;FLIP BETWEEN ZERO AND 1
endif
schedkwhen ktick, 0, 0, 4, kSwingTime, 0.001
endin

instr 4 ;TEST FOR NOTE ON SEQUENCE STEP
#define VOICE(N)
#
iOnOff$N table gindx, giOn$N
if iOnOff$N==1 then
iAcc table gindx,giAcc$N
event_i "i", 100+$N, 0, 0.001, 0.4 + (iAcc*i(gkAccLev))
endif
#
$VOICE(1)
$VOICE(2)
$VOICE(3)
$VOICE(4)
$VOICE(5)
$VOICE(6)
$VOICE(7)
$VOICE(8)
$VOICE(9)
$VOICE(10)
$VOICE(11)
$VOICE(12)
$VOICE(13)
$VOICE(14)
$VOICE(15)
$VOICE(16)
gindx wrap gindx+1, 0, 16
turnoff
endin

instr 101 ;BASS DRUM
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act1" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS

p3 = 2*i(gkdur1) ;NOTE DURATION. SCALED USING GUI 'Decay' KNOB

;SUSTAIN AND BODY OF THE SOUND
kmul transeg 0.2,p3*0.5,-15,0.01, p3*0.5,0,0 ;PARTIAL STRENGTHS MULTIPLIER USED BY GBUZZ. DECAYS FROM A SOUND WITH OVERTONES TO A SINE TONE.
kbend transeg 0.5,1.2,-4, 0,1,0,0 ;SLIGHT PITCH BEND AT THE START OF THE NOTE
asig gbuzz 0.5,50*octave(gktune1)*semitone(kbend),20,1,kmul,gicos ;GBUZZ TONE
aenv transeg 1,p3-0.004,-6,0 ;AMPLITUDE ENVELOPE FOR SUSTAIN OF THE SOUND
aatt linseg 0,0.004,1 ;SOFT ATTACK
asig = asig*aenv*aatt

;HARD, SHORT ATTACK OF THE SOUND
aenv linseg 1,0.07,0 ;AMPLITUDE ENVELOPE (FAST DECAY)
acps expsega 400,0.07,0.001,1,0.001 ;FREQUENCY OF THE ATTACK SOUND. QUICKLY GLISSES FROM 400 Hz TO SUB-AUDIO
aimp oscili aenv,acps*octave(gktune1*0.25),gisine ;CREATE ATTACK SOUND
amix = ((asig*0.5)+(aimp*0.35))*gklevel1*p4*gklevel ;MIX SUSTAIN AND ATTACK SOUND ELEMENTS AND SCALE USING GUI 'Level' KNOB
aL,aR pan2 amix,gkpan1 ;PAN THE MONOPHONIC SOUND
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 102 ;SNARE DRUM
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act2" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
;SOUND CONSISTS OF TWO SINE TONES, AN OCTAVE APART AND A NOISE SIGNAL
ifrq = 342 ;FREQUENCY OF THE TONES
iNseDur = 0.3 * i(gkdur2) ;DURATION OF THE NOISE COMPONENT
iPchDur = 0.1 * i(gkdur2) ;DURATION OF THE SINE TONES COMPONENT
p3 = iNseDur ;p3 DURATION TAKEN FROM NOISE COMPONENT DURATION (ALWATS THE LONGEST COMPONENT)
;SINE TONES COMPONENT
aenv1 expseg 1,iPchDur,0.0001,p3-iPchDur,0.0001 ;AMPLITUDE ENVELOPE
apitch1 oscili 1,ifrq*octave(gktune2),gisine ;SINE TONE 1
apitch2 oscili 0.25,ifrq*0.5*octave(gktune2),gisine ;SINE TONE 2 (AN OCTAVE LOWER)
apitch = (apitch1+apitch2)*0.75 ;MIX THE TWO SINE TONES

;NOISE COMPONENT
aenv2 expon 1,p3,0.0005 ;AMPLITUDE ENVELOPE
anoise noise 0.75,0 ;CREATE SOME NOISE
anoise butbp anoise,10000*octave(gktune2),10000 ;BANDPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,1000 ;HIGHPASS FILTER THE NOISE SIGNAL
kcf expseg 5000,0.1,3000,p3-0.2,3000 ;CUTOFF FREQUENCY FOR A LOWPASS FILTER
anoise butlp anoise,kcf ;LOWPASS FILTER THE NOISE SIGNAL
amix = ((apitch*aenv1)+(anoise*aenv2))*gklevel2*p4*gklevel ;MIX AUDIO SIGNALS AND SCALE ACCORDING TO GUI 'Level' CONTROL
aL,aR pan2 amix,i(gkpan2) ;PAN THE MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 103 ;OPEN HIGH HAT
xtratim 0.1
kFrq1 = 296*octave(gktune3) ;FREQUENCIES OF THE 6 OSCILLATORS
kFrq2 = 285*octave(gktune3)
kFrq3 = 365*octave(gktune3)
kFrq4 = 348*octave(gktune3)
kFrq5 = 420*octave(gktune3)
kFrq6 = 835*octave(gktune3)
p3 = 0.5*i(gkdur3) ;DURATION OF THE NOTE
;SOUND CONSISTS OF 6 PULSE OSCILLATORS MIXED WITH A NOISE COMPONENT
;PITCHED ELEMENT
aenv linseg 1,p3-0.05,0.1,0.05,0 ;AMPLITUDE ENVELOPE FOR THE PULSE OSCILLATORS
ipw = 0.25 ;PULSE WIDTH
a1 vco2 0.5,kFrq1,2,ipw ;PULSE OSCILLATORS...
a2 vco2 0.5,kFrq2,2,ipw
a3 vco2 0.5,kFrq3,2,ipw
a4 vco2 0.5,kFrq4,2,ipw
a5 vco2 0.5,kFrq5,2,ipw
a6 vco2 0.5,kFrq6,2,ipw
amix sum a1,a2,a3,a4,a5,a6 ;MIX THE PULSE OSCILLATORS
amix reson amix,5000*octave(gktune3),5000,1 ;BANDPASS FILTER THE MIXTURE
amix buthp amix,5000 ;HIGHPASS FILTER THE SOUND...
amix buthp amix,5000 ;...AND AGAIN
amix = amix*aenv ;APPLY THE AMPLITUDE ENVELOPE
;NOISE ELEMENT
anoise noise 0.8,0 ;GENERATE SOME WHITE NOISE
aenv linseg 1,p3-0.05,0.1,0.05,0 ;CREATE AN AMPLITUDE ENVELOPE
kcf expseg 20000,0.7,9000,p3-0.1,9000 ;CREATE A CUTOFF FREQ. ENVELOPE
anoise butlp anoise,kcf ;LOWPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,8000 ;HIGHPASS FILTER THE NOISE SIGNAL
anoise = anoise*aenv ;APPLY THE AMPLITUDE ENVELOPE
;MIX PULSE OSCILLATOR AND NOISE COMPONENTS
amix = (amix+anoise)*gklevel3*p4*0.55*gklevel
aL,aR pan2 amix,gkpan3 ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND TO OUTPUTS
;kactive active p1+1 ;CHECK NUMBER OF ACTIVE INSTANCES OF CLOSED HIGH HAT INSTRUMENT
;if kactive>0 then ;IF HIGH-HAT CLOSED IS ACTIVE...
; turnoff ;TURN OFF THIS INSTRUMENT
;endif
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act3" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
endin

instr 104 ;CLOSED HIGH HAT
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act4" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
kFrq1 = 296*octave(gktune4) ;FREQUENCIES OF THE 6 OSCILLATORS
kFrq2 = 285*octave(gktune4)
kFrq3 = 365*octave(gktune4)
kFrq4 = 348*octave(gktune4)
kFrq5 = 420*octave(gktune4)
kFrq6 = 835*octave(gktune4)
idur = 0.088*i(gkdur4) ;DURATION OF THE NOTE
p3 limit idur,0.1,10 ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)

iactive active p1-1 ;SENSE ACTIVITY OF PREVIOUS INSTRUMENT (OPEN HIGH HAT)
if iactive>0 then ;IF 'OPEN HIGH HAT' IS ACTIVE...
turnoff2 p1-1,0,0 ;TURN IT OFF (CLOSED HIGH HAT TAKES PRESIDENCE)
chnset gkoff,"Act3" ;TURN OFF ACTIVE LIGHT FOR OPEN HIGH HAT
endif

;PITCHED ELEMENT
aenv expsega 1,idur,0.001,1,0.001 ;AMPLITUDE ENVELOPE FOR THE PULSE OSCILLATORS
ipw = 0.25 ;PULSE WIDTH
a1 vco2 0.5,kFrq1,2,ipw ;PULSE OSCILLATORS...
a2 vco2 0.5,kFrq2,2,ipw
a3 vco2 0.5,kFrq3,2,ipw
a4 vco2 0.5,kFrq4,2,ipw
a5 vco2 0.5,kFrq5,2,ipw
a6 vco2 0.5,kFrq6,2,ipw
amix sum a1,a2,a3,a4,a5,a6 ;MIX THE PULSE OSCILLATORS
amix reson amix,5000*octave(gktune4),5000,1 ;BANDPASS FILTER THE MIXTURE
amix buthp amix,5000 ;HIGHPASS FILTER THE SOUND...
amix buthp amix,5000 ;...AND AGAIN
amix = amix*aenv ;APPLY THE AMPLITUDE ENVELOPE
;NOISE ELEMENT
anoise noise 0.8,0 ;GENERATE SOME WHITE NOISE
aenv expsega 1,idur,0.001,1,0.001 ;CREATE AN AMPLITUDE ENVELOPE
kcf expseg 20000,0.7,9000,idur-0.1,9000 ;CREATE A CUTOFF FREQ. ENVELOPE
anoise butlp anoise,kcf ;LOWPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,8000 ;HIGHPASS FILTER THE NOISE SIGNAL
anoise = anoise*aenv ;APPLY THE AMPLITUDE ENVELOPE
;MIX PULSE OSCILLATOR AND NOISE COMPONENTS
amix = (amix+anoise)*gklevel4*p4*0.55*gklevel
aL,aR pan2 amix,gkpan4 ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND TO OUTPUTS
endin

instr 105 ;HIGH TOM
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act5" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 200 * octave(i(gktune5)) ;FREQUENCY
p3 = 0.5 * i(gkdur5) ;DURATION OF THIS NOTE

;SINE TONE SIGNAL
aAmpEnv transeg 1,p3,-10,0.001 ;AMPLITUDE ENVELOPE FOR SINE TONE SIGNAL
afmod expsega 5,0.125/ifrq,1,1,1 ;FREQUENCY MODULATION ENVELOPE. GIVES THE TONE MORE OF AN ATTACK.
asig oscili -aAmpEnv*0.6,ifrq*afmod,gisine ;SINE TONE SIGNAL

;NOISE SIGNAL
aEnvNse transeg 1,p3,-6,0.001 ;AMPLITUDE ENVELOPE FOR NOISE SIGNAL
anoise dust2 0.4, 8000 ;GENERATE NOISE SIGNAL
anoise reson anoise,400*octave(i(gktune5)),800,1 ;BANDPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,100*octave(i(gktune5)) ;HIGHPASS FILTER THE NOSIE SIGNAL
anoise butlp anoise,1000*octave(i(gktune5)) ;LOWPASS FILTER THE NOISE SIGNAL
anoise = anoise * aEnvNse ;SCALE NOISE SIGNAL WITH AMPLITUDE ENVELOPE
;MIX THE TWO SOUND COMPONENTS
amix = (asig + anoise)*gklevel5*p4*gklevel
aL,aR pan2 amix,gkpan5 ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 106 ;MID TOM
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act6" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 133*octave(i(gktune6)) ;FREQUENCY
p3 = 0.6 * i(gkdur6) ;DURATION OF THIS NOTE

;SINE TONE SIGNAL
aAmpEnv transeg 1,p3,-10,0.001 ;AMPLITUDE ENVELOPE FOR SINE TONE SIGNAL
afmod expsega 5,0.125/ifrq,1,1,1 ;FREQUENCY MODULATION ENVELOPE. GIVES THE TONE MORE OF AN ATTACK.
asig oscili -aAmpEnv*0.6,ifrq*afmod,gisine ;SINE TONE SIGNAL

;NOISE SIGNAL
aEnvNse transeg 1,p3,-6,0.001 ;AMPLITUDE ENVELOPE FOR NOISE SIGNAL
anoise dust2 0.4, 8000 ;GENERATE NOISE SIGNAL
anoise reson anoise, 400*octave(i(gktune6)),800,1 ;BANDPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,100*octave(i(gktune6)) ;HIGHPASS FILTER THE NOSIE SIGNAL
anoise butlp anoise,600*octave(i(gktune6)) ;LOWPASS FILTER THE NOISE SIGNAL
anoise = anoise * aEnvNse ;SCALE NOISE SIGNAL WITH AMPLITUDE ENVELOPE
;MIX THE TWO SOUND COMPONENTS
amix = (asig + anoise)*gklevel6*p4*gklevel
aL,aR pan2 amix,i(gkpan6) ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 107 ;LOW TOM
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act7" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 90 * octave(i(gktune7)) ;FREQUENCY
p3 = 0.7*i(gkdur7) ;DURATION OF THIS NOTE

;SINE TONE SIGNAL
aAmpEnv transeg 1,p3,-10,0.001 ;AMPLITUDE ENVELOPE FOR SINE TONE SIGNAL
afmod expsega 5,0.125/ifrq,1,1,1 ;FREQUENCY MODULATION ENVELOPE. GIVES THE TONE MORE OF AN ATTACK.
asig oscili -aAmpEnv*0.6,ifrq*afmod,gisine ;SINE TONE SIGNAL

;NOISE SIGNAL
aEnvNse transeg 1,p3,-6,0.001 ;AMPLITUDE ENVELOPE FOR NOISE SIGNAL
anoise dust2 0.4, 8000 ;GENERATE NOISE SIGNAL
anoise reson anoise,40*octave(gktune7),800,1 ;BANDPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,100*octave(i(gktune7)) ;HIGHPASS FILTER THE NOSIE SIGNAL
anoise butlp anoise,600*octave(i(gktune7)) ;LOWPASS FILTER THE NOISE SIGNAL
anoise = anoise * aEnvNse ;SCALE NOISE SIGNAL WITH AMPLITUDE ENVELOPE
;MIX THE TWO SOUND COMPONENTS
amix = (asig + anoise)*gklevel7*p4*gklevel
aL,aR pan2 amix,i(gkpan7) ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 108 ;CYMBAL
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act8" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
kFrq1 = 296*octave(gktune8) ;FREQUENCIES OF THE 6 OSCILLATORS
kFrq2 = 285*octave(gktune8)
kFrq3 = 365*octave(gktune8)
kFrq4 = 348*octave(gktune8)
kFrq5 = 420*octave(gktune8)
kFrq6 = 835*octave(gktune8)
p3 = 2*i(gkdur8) ;DURATION OF THE NOTE

;SOUND CONSISTS OF 6 PULSE OSCILLATORS MIXED WITH A NOISE COMPONENT
;PITCHED ELEMENT
aenv expon 1,p3,0.0001 ;AMPLITUDE ENVELOPE FOR THE PULSE OSCILLATORS
ipw = 0.25 ;PULSE WIDTH
a1 vco2 0.5,kFrq1,2,ipw ;PULSE OSCILLATORS...
a2 vco2 0.5,kFrq2,2,ipw
a3 vco2 0.5,kFrq3,2,ipw
a4 vco2 0.5,kFrq4,2,ipw
a5 vco2 0.5,kFrq5,2,ipw
a6 vco2 0.5,kFrq6,2,ipw
amix sum a1,a2,a3,a4,a5,a6 ;MIX THE PULSE OSCILLATORS
amix reson amix,5000 *octave(gktune8),5000,1 ;BANDPASS FILTER THE MIXTURE
amix buthp amix,10000 ;HIGHPASS FILTER THE SOUND
amix butlp amix,12000 ;LOWPASS FILTER THE SOUND...
amix butlp amix,12000 ;AND AGAIN...
amix = amix*aenv ;APPLY THE AMPLITUDE ENVELOPE
;NOISE ELEMENT
anoise noise 0.8,0 ;GENERATE SOME WHITE NOISE
aenv expsega 1,0.3,0.07,p3-0.1,0.00001 ;CREATE AN AMPLITUDE ENVELOPE
kcf expseg 14000,0.7,7000,p3-0.1,5000 ;CREATE A CUTOFF FREQ. ENVELOPE
anoise butlp anoise,kcf ;LOWPASS FILTER THE NOISE SIGNAL
anoise buthp anoise,8000 ;HIGHPASS FILTER THE NOISE SIGNAL
anoise = anoise*aenv ;APPLY THE AMPLITUDE ENVELOPE

;MIX PULSE OSCILLATOR AND NOISE COMPONENTS
amix = (amix+anoise)*gklevel8*p4*0.85*gklevel
aL,aR pan2 amix,i(gkpan8) ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND TO OUTPUTS
endin

instr 109 ;RIM SHOT
xtratim 0.1
iTR808RimShot ftgenonce 0,0,1024,10, 0.971,0.269,0.041,0.054,0.011,0.013,0.08,0.0065,0.005,0.004,0.003,0.003,0.002,0.002,0.002,0.002,0.002,0.001,0.001,0.001,0.001,0.001,0.002,0.001,0.001 ;WAVEFORM FOR TR808 RIMSHOT
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act9" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
idur = 0.027*i(gkdur9) ;NOTE DURATION
p3 limit idur,0.1,10 ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)

;RING
aenv1 expsega 1,idur,0.001,1,0.001 ;AMPLITUDE ENVELOPE FOR SUSTAIN ELEMENT OF SOUND
ifrq1 = 1700*octave(i(gktune9)) ;FREQUENCY OF SUSTAIN ELEMENT OF SOUND
aring oscili 1,ifrq1,iTR808RimShot,0 ;CREATE SUSTAIN ELEMENT OF SOUND
aring butbp aring,ifrq1,ifrq1*8
aring = aring*(aenv1-0.001)*0.5 ;APPLY AMPLITUDE ENVELOPE

;NOISE
anoise noise 1,0 ;CREATE A NOISE SIGNAL
aenv2 expsega 1, 0.002, 0.8, 0.005, 0.5, idur-0.002-0.005, 0.0001, 1, 0.0001 ;CREATE AMPLITUDE ENVELOPE
anoise buthp anoise,800 ;HIGHPASS FILTER THE NOISE SOUND
kcf expseg 4000,p3,20 ;CUTOFF FREQUENCY FUNCTION FOR LOWPASS FILTER
anoise butlp anoise,kcf ;LOWPASS FILTER THE SOUND
anoise = anoise*(aenv2-0.001) ;APPLY ENVELOPE TO NOISE SIGNAL

;MIX
amix = (aring+anoise)*gklevel9*p4*0.8*gklevel
aL,aR pan2 amix,gkpan9 ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND TO OUTPUTS
endin

instr 110 ;CLAVES
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act10" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 2500*octave(i(gktune10)) ;FREQUENCY OF OSCILLATOR
idur = 0.045 * i(gkdur10) ;DURATION OF THE NOTE
p3 limit idur,0.1,10 ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)
aenv expsega 1,idur,0.001,1,0.001 ;AMPLITUDE ENVELOPE
afmod expsega 3,0.00005,1,1,1 ;FREQUENCY MODULATION ENVELOPE. GIVES THE SOUND A LITTLE MORE ATTACK.
asig oscili -(aenv-0.001),ifrq*afmod,gisine,0 ;AUDIO OSCILLATOR
asig = asig*0.4*gklevel10*p4*gklevel ;RESCALE AMPLITUDE
aL,aR pan2 asig,gkpan10 ;PAN MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 111 ;COWBELL
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act11" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq1 = 562 * octave(i(gktune11)) ;FREQUENCIES OF THE TWO OSCILLATORS
ifrq2 = 845 * octave(i(gktune11)) ;
ipw = 0.5 ;PULSE WIDTH OF THE OSCILLATOR
idur = 0.7 ;NOTE DURATION
ishp = -30
idur = 0.7 ;NOTE DURATION
p3 = idur*i(gkdur11) ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)
ishape = -30 ;SHAPE OF THE CURVES IN THE AMPLITUDE ENVELOPE
kenv1 transeg 1,p3*0.3,ishape,0.2, p3*0.7,ishape,0.2 ;FIRST AMPLITUDE ENVELOPE - PRINCIPALLY THE ATTACK OF THE NOTE
kenv2 expon 1,p3,0.0005 ;SECOND AMPLITUDE ENVELOPE - THE SUSTAIN PORTION OF THE NOTE
kenv = kenv1*kenv2 ;COMBINE THE TWO ENVELOPES
itype = 2 ;WAVEFORM FOR VCO2 (2=PULSE)
a1 vco2 0.65,ifrq1,itype,ipw ;CREATE THE TWO OSCILLATORS
a2 vco2 0.65,ifrq2,itype,ipw
amix = a1+a2 ;MIX THE TWO OSCILLATORS
iLPF2 = 10000 ;LOWPASS FILTER RESTING FREQUENCY
kcf expseg 12000,0.07,iLPF2,1,iLPF2 ;LOWPASS FILTER CUTOFF FREQUENCY ENVELOPE
alpf butlp amix,kcf ;LOWPASS FILTER THE MIX OF THE TWO OSCILLATORS (CREATE A NEW SIGNAL)
abpf reson amix, ifrq2, 25 ;BANDPASS FILTER THE MIX OF THE TWO OSCILLATORS (CREATE A NEW SIGNAL)
amix dcblock2 (abpf*0.06*kenv1)+(alpf*0.5)+(amix*0.9) ;MIX ALL SIGNALS AND BLOCK DC OFFSET
amix buthp amix,700 ;HIGHPASS FILTER THE MIX OF ALL SIGNALS
amix = amix*0.07*kenv*p4*gklevel11*gklevel ;RESCALE AMPLITUDE
aL,aR pan2 amix,i(gkpan11) ;PAN THE MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 112 ;CLAP
;;xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act12" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
iTimGap = 0.01 ;GAP BETWEEN EVENTS DURING ATTACK PORTION OF CLAP
idur1 = 0.02 ;DURING OF THE THREE INITIAL 'CLAPS'
idur2 = 2*i(gkdur12) ;DURATION OF THE FOURTH, MAIN, CLAP
idens = 8000 ;DENSITY OF THE NOISE SIGNAL USED TO FORM THE CLAPS
iamp1 = 0.5 ;AMPLITUDE OF AUDIO BEFORE BANDPASS FILTER IN OUTPUT
iamp2 = 1 ;AMPLITUDE OF AUDIO AFTER BANDPASS FILTER IN OUTPUT
if frac(p1)==0 then ;IF THIS IS THE INITIAL NOTE (p1 WILL BE AN INTEGER)
; del. dur env.shape
event_i "i", p1+0.1, 0, idur1, p4 ;CALL THIS INSTRUMENT 4 TIMES. ADD A FRACTION ONTO p1 TO BE ABLE TO DIFFERENTIATE THESE SUBSEQUENT NOTES
event_i "i", p1+0.1, iTimGap, idur1, p4
event_i "i", p1+0.1, iTimGap*2, idur1, p4
event_i "i", p1+0.1, iTimGap*3, idur2, p4
else
kenv transeg 1,p3,-25,0 ;AMPLITUDE ENVELOPE
iamp random 0.7,1 ;SLIGHT RANDOMISATION OF AMPLITUDE
anoise dust2 kenv*iamp, idens ;CREATE NOISE SIGNAL
iBPF = 1100*octave(i(gktune12)) ;FREQUENCY OF THE BANDPASS FILTER
ibw = 2000*octave(i(gktune12)) ;BANDWIDTH OF THE BANDPASS FILTER
iHPF = 1000 ;FREQUENCY OF A HIGHPASS FILTER
iLPF = 1 ;SCALER FOR FREQUENCY OF A LOWPASS FILTER
kcf expseg 8000,0.07,1700,1,800,2,500,1,500 ;CREATE CUTOFF FREQUENCY ENVELOPE
asig butlp anoise,kcf*iLPF ;LOWPASS FILTER THE SOUND
asig buthp asig,iHPF ;HIGHPASS FILTER THE SOUND
ares reson asig,iBPF,ibw,1 ;BANDPASS FILTER THE SOUND (CREATE A NEW SIGNAL)
asig dcblock2 (asig*iamp1)+(ares*iamp2) ;MIX BANDPASS FILTERED AND NON-BANDPASS FILTERED SOUND ELEMENTS
asig = asig*p4*i(gklevel12)*1.75*gklevel ;SCALE AMPLITUDE
aL,aR pan2 asig,i(gkpan12) ;PAN MONOPHONIC SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endif
endin

instr 113 ;MARACA
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act13" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
idur = 0.07*i(gkdur13) ;DURATION 3
p3 limit idur,0.1,10 ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)
iHPF limit 6000*octave(i(gktune13)),20,sr/2 ;HIGHPASS FILTER FREQUENCY
iLPF limit 12000*octave(i(gktune13)),20,sr/3 ;LOWPASS FILTER FREQUENCY. (LIMIT MAXIMUM TO PREVENT OUT OF RANGE VALUES)
;AMPLITUDE ENVELOPE
iBP1 = 0.4 ;BREAK-POINT 1
iDur1 = 0.014*i(gkdur13) ;DURATION 1
iBP2 = 1 ;BREAKPOINT 2
iDur2 = 0.01 *i(gkdur13) ;DURATION 2
iBP3 = 0.05 ;BREAKPOINT 3
p3 limit idur,0.1,10 ;LIMIT THE MINIMUM DURATION OF THE NOTE (VERY SHORT NOTES CAN RESULT IN THE INDICATOR LIGHT ON-OFF NOTE BEING TO0 SHORT)
aenv expsega iBP1,iDur1,iBP2,iDur2,iBP3 ;CREATE AMPLITUDE ENVELOPE
anoise noise 0.75,0 ;CREATE A NOISE SIGNAL
anoise buthp anoise,iHPF ;HIGHPASS FILTER THE SOUND
anoise butlp anoise,iLPF ;LOWPASS FILTER THE SOUND
anoise = anoise*aenv*p4*gklevel13*gklevel ;SCALE THE AMPLITUDE
aL,aR pan2 anoise,i(gkpan13) ;PAN THE MONOPONIC SIGNAL
outs aL,aR ;SEND AUDIO TO OUTPUTS
endin

instr 114 ;HIGH CONGA
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act14" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 420*octave(i(gktune14)) ;FREQUENCY OF NOTE
p3 = 0.22*i(gkdur14) ;DURATION OF NOTE
aenv transeg 0.7,1/ifrq,1,1,p3,-6,0.001 ;AMPLITUDE ENVELOPE
afrq expsega ifrq*3,0.25/ifrq,ifrq,1,ifrq ;FREQUENCY ENVELOPE (CREATE A SHARPER ATTACK)
asig oscili -aenv*0.25,afrq,gisine ;CREATE THE AUDIO OSCILLATOR
asig = asig*p4*gklevel14*gklevel ;SCALE THE AMPLITUDE
aL,aR pan2 asig,gkpan14 ;PAN THE MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO THE OUTPUTS
endin

instr 115 ;MID CONGA
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act15" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 310*octave(i(gktune15)) ;FREQUENCY OF NOTE
p3 = 0.33*i(gkdur15) ;DURATION OF NOTE
aenv transeg 0.7,1/ifrq,1,1,p3,-6,0.001 ;AMPLITUDE ENVELOPE
afrq expsega ifrq*3,0.25/ifrq,ifrq,1,ifrq ;FREQUENCY ENVELOPE (CREATE A SHARPER ATTACK)
asig oscili -aenv*0.25,afrq,gisine ;CREATE THE AUDIO OSCILLATOR
asig = asig*p4*gklevel15*gklevel ;SCALE THE AMPLITUDE
aL,aR pan2 asig,gkpan15 ;PAN THE MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO THE OUTPUTS
endin

instr 116 ;LOW CONGA
xtratim 0.1
krelease release ;SENSE RELEASE OF THIS NOTE ('1' WHEN RELEASED, OTHERWISE ZERO)
chnset 1-krelease,"Act16" ;TURN ON ACTIVE LIGHT WHEN NOTE STARTS, TURN IT OFF WHEN NOTE ENDS
ifrq = 227*octave(i(gktune16)) ;FREQUENCY OF NOTE
p3 = 0.41*i(gkdur16) ;DURATION OF NOTE
aenv transeg 0.7,1/ifrq,1,1,p3,-6,0.001 ;AMPLITUDE ENVELOPE
afrq expsega ifrq*3,0.25/ifrq,ifrq,1,ifrq ;FREQUENCY ENVELOPE (CREATE A SHARPER ATTACK)
asig oscili -aenv*0.25,afrq,gisine ;CREATE THE AUDIO OSCILLATOR
asig = asig*p4*gklevel16*gklevel ;SCALE THE AMPLITUDE
aL,aR pan2 asig,gkpan16 ;PAN THE MONOPHONIC AUDIO SIGNAL
outs aL,aR ;SEND AUDIO TO THE OUTPUTS
endin

</CsInstruments>

<CsScore>
f 0 [3600*24*7]
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 1376
- 0
bin/cabbage-todo/Synths/TR-808_pattern.0.txt
File diff suppressed because it is too large
View File


+ 250
- 0
bin/cabbage-todo/Synths/Vectorial.csd View File

@@ -0,0 +1,250 @@
<Cabbage>
form caption("Vectorial Synth"), size(760, 320), pluginID("vec1")

xypad bounds(5, 0, 250, 205), channel("chanx", "chany"), text("Vectorial mixing"), rangex(0, 1, .5), rangey(0, 1, .5)

groupbox bounds(260, 0, 240, 100), text("ADSR"), plant("adsr"){
rslider bounds(.0, .3, .6, .6), text("A"), colour("orange"), channel("att"), range(0.01,3, .5)
rslider bounds(.25, .3, .6, .6), text("D"), colour("orange"), channel("dec"), range(0,1, .5)
rslider bounds(.5, .3, .6, .6), text("S"), colour("orange"), channel("sus"), range(0,1,.8)
rslider bounds(.75, .3, .6, .6), text("R"), colour("orange"), channel("rel"), range(0.01,3, .2)
}

groupbox bounds(260, 105, 240, 100), text("Tune"), plant("tune"){
rslider bounds(.0, .3, .6, .6), text("Detune1"), colour("dodgerblue"), channel("det1"), range(-24,12,0)
rslider bounds(.25, .3, .6, .6), text("Detune2"), colour("dodgerblue"), channel("det2"), range(-24,12,-5)
rslider bounds(.5, .3, .6, .6), text("Detune3"), colour("dodgerblue"), channel("det3"), range(-24,12,0)
rslider bounds(.75, .3, .6, .6), text("Detune4"), colour("dodgerblue"), channel("det4"), range(-24,12,-12)
}

groupbox bounds(505,0, 240, 100), text("LFO/Stereo chorus"), plant("mod"){
rslider bounds(.0, .3, .6, .6), text("Lfo amp"), colour("dodgerblue"), channel("lfoamp"), range(0,50, 0)
rslider bounds(.25, .3, .6, .6), text("Lfo rate"), colour("dodgerblue"), channel("lforate"), range(0,20, 0)
rslider bounds(.5, .3, .6, .6), text("depth"), colour("dodgerblue"), channel("chdepth"), range(0,10,0)
rslider bounds(.75, .3, .6, .6), text("rate"), colour("dodgerblue"), channel("chrate"), range(0,10,0)
}

groupbox bounds(505,105, 240, 100), text("Reverb"), plant("rev"){
rslider bounds(0, .3, .6, .6), text("level"), colour("dodgerblue"), channel("level"), range(0,1,0)
rslider bounds(0.25, .3, .6, .6), text("size"), colour("dodgerblue"), channel("size"), range(.1,.99,.5)
;rslider bounds(115, 30, 60, 60), text("depth"), colour("dodgerblue"), channel("chdepth"), range(0,10,0)
;rslider bounds(165, 30, 60, 60), text("rate"), colour("dodgerblue"), channel("chrate"), range(0,10,0)
checkbox bounds(.55, .40, .60, .30),channel("onoff"), text("On/Off"), value(0), colour("blue")
}

keyboard bounds(5, 220, 750, 70)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL -M0
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Giorgio Zucco (2012)

;turnon don't work!
;turnon 10 ;chorus
;turnon 12 ;reverb

ga1 init 0
ga2 init 0
garev1 init 0
garev2 init 0

gifn ftgen 1,0,16384,10,1
gifn ftgen 2,0,16384,10,1,0,1
gifn ftgen 3,0,16384,10,1,0,0,1
gifn ftgen 4,0,16384,10,1,0,0,0,1
gifn ftgen 5,0,16384,10,1,0,0,0,0,1
gifn ftgen 6,0,16384,10,1,0,1,0,0,0,1
gifn ftgen 7,0,16384,10,1,0,0,1,0,0,0,1
gifn ftgen 8,0,16384,10,1,0,0,0,1,0,0,0,1
gifn ftgen 9,0,16384,10,1,0,0,0,0,1,0,0,1,1
gifn ftgen 10,0,16384,10,1,0,0,0,0,0,1,1,0,0,1
gifn ftgen 11,0,16384,10,1,0,0,0,0,1,1,0,0,0,0,1
gifn ftgen 12,0,16384,10,1,0,0,0,1,1,0,0,0,0,0,0,1
gifn ftgen 13,0,16384,10,1,0,0,0,1,1,0,0,0,0,0,0,0,1
gifn ftgen 14,0,16384,10,1,0,0,1,0,0,1,0,0,0,0,0,0,0,1
gifn ftgen 15,0,16384,10,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1
gifn ftgen 16,0,16384,10,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1
gibell ftgen 17,0,16384,9,1,1,0,1.02,.28,0,.98,.14,0,4,.22,0,7,.39,0 ;bell
gichord ftgen 18,0,16384,9, 1,1,0,1.25,.08,0,1.49,.28,0,2,.52,0,2.52,.74,0 ;chord
gitemp ftgen 19 , 0 , 16384, 10 , 1 , 1 , 0 , 5 , 0 , 3, 0 , 1
gitemp ftgen 20, 0, 16384, 10, 1, 1, 0, 0, 1 ,0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
gitemp ftgen 21, 0 ,16384 ,10, 1, 1, 0, 1, 0, 1, 0 ,1, 0, 1, 0, 1, 0, 1, 0, 1
gitemp ftgen 22 , 0 ,16384, 10 ,1 ,0, .2 ,.2 ,.03, .12, .22, .11 ,.022, .0101, .0167

;*******************************************
opcode StChorus,aa,aakkkk

asigr,asigl,kdepth,kdepthl,krate,kratel xin ;legge i parametri in entrata

;ar,al StChorus asigr,asigl,kdepth,kdepthl,krate,kratel


k1ch randi kdepth/2,krate,1
ar1 vdelay asigr,kdepth/2+k1ch,10
k2ch randi kdepth/2,krate*0.9,.2
ar2 vdelay asigr,kdepth/2+k2ch,10
k3ch randi kdepth/2,krate*1.1,.2
ar3 vdelay asigr,kdepth/2+k3ch,10
k4ch randi kdepth/2,krate*1.3,.1
ar4 vdelay asigr,kdepth/2+k4ch,10

k1chl randi kdepthl/2,kratel,1
ar1l vdelay asigl,kdepthl/2+k1chl,10
k2chl randi kdepthl/2,kratel*0.9,.2
ar2l vdelay asigl,kdepthl/2+k2chl,10
k3chl randi kdepthl/2,kratel*1.1,.2
ar3l vdelay asigl,kdepthl/2+k3chl,10
k4chl randi kdepthl/2,kratel*1.3,.1
ar4l vdelay asigl,kdepthl/2+k4chl,10


aL = (ar1+ar2+ar3+ar4)/2
aR = (ar1l+ar2l+ar3l+ar4l)/2
xout aL,aR ; write output

endop
;***********************************************



instr 1


iatt chnget "att"
idec chnget "dec"
isus chnget "sus"
irel chnget "rel"
kdet1 chnget "det1"
kdet2 chnget "det2"
kdet3 chnget "det3"
kdet4 chnget "det4"
klfoamp chnget "lfoamp"
klforate chnget "lforate"
kindex chnget "fmamp"
kfmrate chnget "fmrate"
kcutoff chnget "cutoff"
kreso chnget "resonance"
kx chnget "chanx"
ky chnget "chany"
;midi

imidinn notnum
iamp ampmidi 1
kbend pchbend 0,2 ;pitch bend
kfreq1 = cpsmidinn(imidinn+kbend+int(kdet1)) ;controllo midi
kfreq2 = cpsmidinn(imidinn+kbend+int(kdet2))
kfreq3 = cpsmidinn(imidinn+kbend+int(kdet3))
kfreq4 = cpsmidinn(imidinn+kbend+int(kdet4))

;lfo
klfo poscil klfoamp,klforate,1

kfreq1 = kfreq1+klfo
kfreq2 = kfreq2+klfo
kfreq3 = kfreq3+klfo
kfreq4 = kfreq4+klfo

ifunc1 = rnd(15)
ifunc2 = rnd(15)
ifunc3 = rnd(15)
ifunc4 = rnd(15)


;4 osc
ain1 poscil iamp,kfreq1,ifunc1+1
ain2 poscil iamp,kfreq2,ifunc2+1
ain3 poscil iamp,kfreq3,ifunc3+1
ain4 poscil iamp,kfreq4,ifunc4+1


;vectorial mixing
k1 = (1-kx)*(1-ky)
k2 = kx*(1-ky)
k3 = (1-kx)*ky
k4 = kx*ky

k1port portk k1,.01
k2port portk k2,.01
k3port portk k3,.01
k4port portk k4,.01

kadsr mxadsr iatt,idec,isus,irel

aout = (ain1*k1port + ain2*k2port + ain3*k3port + ain4*k4port)*.3 ;global out

;abulp1 butterlp aout,kcutoff*kadsrfilt

;aring poscil aout,kcutoff,1
;amaster balance afilt1,aout

aclip clip aout,0,0dbfs

kpan jspline 1,0,4
al,ar pan2 aclip,kpan
outs (al*kadsr),(ar*kadsr)
vincr ga1,(al*kadsr)
vincr ga2,(ar*kadsr)
vincr garev1,(al*kadsr)
vincr garev2,(ar*kadsr)

endin

;stereo chorus
instr 10


k1 chnget "chdepth"
k2 chnget "chrate"
kfxdepth portk k1,.01
kfxrate portk k2,.01

acho1,acho2 StChorus ga1,ga2,kfxdepth,kfxdepth*.8,kfxrate,kfxrate*.8

outs acho1,acho2
clear ga1,ga2
endin


instr 12 ;reverb
ktrig chnget "onoff"
klevel chnget "level"
ksize chnget "size"
if ktrig = 1 then
al,ar reverbsc garev1,garev2,ksize,16000,sr,0
adc1 dcblock2 al
adc2 dcblock2 ar
kpan1 randomi 0,1,4
kpan2 randomi 0,1,8
aout1,aout2 pan2 adc1,kpan1
aout3,aout4 pan2 adc2,1-kpan2
asum1 = (aout1+aout2)*klevel
asum2 = (aout3+aout4)*klevel
else
asum1 = 0
asum2 = 0
endif

outs asum1,asum2
clear garev1,garev2
endin


</CsInstruments>
<CsScore>


;f0 36000
i1 0 36000
i10 0 36000
i12 0 36000
</CsScore>
</CsoundSynthesizer>

+ 363
- 0
bin/cabbage-todo/Synths/hsboscil_synth.csd View File

@@ -0,0 +1,363 @@
hsboscil_synth.csd

Synthesizer is divided into seven panels.

Amplitude
---------
Amp - amplitude control
Att. - amplitude envelope attack time
Dec. - amplitude envelope decay time
Sus. - amplitude envelope sustain level
Rel. - amplitude envelope release time
Mod.Shape- shape used for amplitude modulation (tremolo). Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
Rate - rate of amplitude LFO (tremolo)
Depth - depth of amplitude LFO
Delay - delay time before amplitude LFO begins
Rise - time over which amplitude LFO depth rises from zero to its prescribed value

Brightness - brightness is really just a description of where the emphasis is in the stack of octave spaced tones that hsboscil produces
----------
Brite - manual brightness control
Vel. - amount of velocity to brightness control
Att. - brightness envelope attack time
Att.Lev - brightness envelope attack level
Dec. - brightness envelope decay time
Sus. - brightness envelope sustain level
Rel. - brightness envelope release time
Rel.Lev - brightness envelope release level
Oct.Cnt.- Number of octave spaced partials in a tone
Mod.Shape- shape used for brightness modulation. Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
Rate - rate of brightness LFO
Depth - depth of brightness LFO
Delay - delay time before brightness LFO begins
Rise - time over which brightness LFO depth rises from zero to its prescribed value

Noise - interpolated gaussian modulation is applied to the pitch (tone) parameter which, at high rates/frequencies results in the addition of a noise component in the tone
-----
Rate - rate/frequency of noise modulation
Depth - depth of noise modulation

Reverb - the screverb opcode is used
------
Mix - amount of reverb that is mixed into the output. When mix is zero the effect is bypassed.
Size - size of the virtual space created by the reverb effect

Pitch Modulation - modulation of the tone (pitch) parameter. This will be at a much slower rate than that applied using the 'noise' function
----------------
Mod.Shape- shape used for pitch modulation. Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
Rate - rate of pitch modulation LFO
Depth - depth of pitch modulation LFO
Delay - delay time before pitch modulation LFO begins
Rise - time over which pitch modulation LFO depth rises from zero to its prescribed value

Freq.Shift - a frequency shifting effect
----------
Freq. - frequency by which the signal will be shifted

Chorus - a stereo chorus effect. Two chorus voices are created which the panning of which is modulated randomly. Delay time/pitch modulations are random rather than cyclical.
------
Mix - Amount of chorussed signal that is mixed into the output
Depth - Depth of modualtion used in the chorus effect
Rate - Rate of modulation used in the chorus effect




<Cabbage>
form caption("hsboscil Synth") size(590, 480), pluginID("hsbo")

snapshot bounds( 5,455,200, 20), preset("hsboscil"), master(1), items("Preset 1", "Preset 2", "Preset 3", "Preset 4", "Preset 5", "Preset 6", "Preset 7", "Preset 8", "Preset 9", "Preset 10")

;AMPLITUDE
groupbox bounds(0, 0, 590, 100), colour( 10, 15, 30, 100) text("Amplitude"), fontcolour(255,0,0){
rslider bounds( 5, 30, 60, 60), text("Amp."), channel("amp"), range(0, 1, 0.3)
line bounds( 65, 30, 2, 60), colour("DarkSlateGrey")
rslider bounds( 70, 30, 60, 60), text("Att."), channel("AAtt"), range( 0, 8.00, 0.3,0.5)
rslider bounds(120, 30, 60, 60), text("Dec."), channel("ADec"), range( 0, 8.00, 0.01,0.5)
rslider bounds(170, 30, 60, 60), text("Sus."), channel("ASus"), range( 0, 1.00, 0.5,0.5)
rslider bounds(220, 30, 60, 60), text("Rel."), channel("ARel"), range(0.01, 8, 0.3,0.5)
line bounds(285, 30, 2, 60), colour("DarkSlateGrey")
label bounds(305, 35, 70, 12), text("Mod.Shape")
combobox bounds(300, 50, 70, 20), channel("amplfo"), value(2), text("sine", "splines", "S+H", "square")
rslider bounds(375, 30, 60, 60), text("Rate"), channel("ARte"), range(0, 16.0, 4)
rslider bounds(425, 30, 60, 60), text("Depth"), channel("ADep"), range(0, 1.00, 1)
rslider bounds(475, 30, 60, 60), text("Delay"), channel("ADel"), range(0, 2.00, 0, 0.5)
rslider bounds(525, 30, 60, 60), text("Rise"), channel("ARis"), range(0, 2.00, 0.1, 0.5)
}

;BRIGHTNESS
groupbox bounds(0, 100,450,170), colour( 6, 18, 22, 100), text("Brightness"), fontcolour(205,10,10){
rslider bounds( 5,135, 60, 60), text("Brite"), channel("brite"), range(-6, 6.00, -2)
rslider bounds( 5,200, 60, 60), text("Vel."), channel("BVelDep"), range(0, 6.00, 3)
rslider bounds( 65,135, 60, 60), text("Oct.Cnt."), channel("octcnt"), range(2, 20, 3, 1, 1)
line bounds(130,127, 2, 60), colour("DarkSlateGrey")
rslider bounds(135,135, 60, 60), text("Att."), channel("BAtt"), range(0, 8.00, 0.1,0.5)
rslider bounds(185,135, 60, 60), text("Att.Lev."), channel("BAttLev"), range(-6.00, 6, 1)
rslider bounds(235,135, 60, 60), text("Dec."), channel("BDec"), range(0, 8.00, 0.1,0.5)
rslider bounds(285,135, 60, 60), text("Sus."), channel("BSus"), range(-6, 6.00, 0)
rslider bounds(335,135, 60, 60), text("Rel."), channel("BRel"), range(0, 8.00, 0.01,0.5)
rslider bounds(385,135, 60, 60), text("Rel.Lev."), channel("BRelLev"), range(-4.00, 4, 0)
line bounds( 90,200, 2, 60), colour("DarkSlateGrey")
label bounds(120,205, 70, 12), text("Mod.Shape")
combobox bounds(115,220, 70, 20), channel("britelfo"), value(2), text("sine", "splines", "S+H", "square")
rslider bounds(185,200, 60, 60), text("Rate"), channel("BRte"), range(0, 30.0, 4)
rslider bounds(235,200, 60, 60), text("Depth"), channel("BDep"), range(0, 6.00, 2)
rslider bounds(285,200, 60, 60), text("Delay"), channel("BDel"), range(0, 2.00, 0.5, 0.5)
rslider bounds(335,200, 60, 60), text("Rise"), channel("BRis"), range(0, 4.00, 1.5, 0.5)
}

;NOISE
groupbox bounds(450, 100, 70,170), colour( 20, 7, 19, 100), text("Noise"), fontcolour(255,40,60){
rslider bounds(455, 135, 60, 60), text("Rate"), channel("NRte"), range(16,10000, 1000, 0.5)
rslider bounds(455, 200, 60, 60), text("Depth"), channel("NDep"), range(0, 1.00, 0.05, 0.5)
}

;REVERB
groupbox bounds(520, 100, 70,170), colour( 3, 25, 11, 100), text("Reverb"), fontcolour(255,0,100){
rslider bounds(525,135, 60, 60), text("Mix"), channel("RvbMix"), range(0, 1.00, 0.3)
rslider bounds(525,200, 60, 60), text("Size"), channel("RvbSize"), range(0, 1.00, 0.82)
}

;PITCH MOD.
groupbox bounds( 0,270,350,100), colour( 20, 25, 40, 100), text("Pitch Modulation"), fontcolour(255,100,0){
label bounds( 15,305, 65, 12), text("Mod.Shape")
combobox bounds( 10,320, 65, 20), channel("pitchlfo"), value(1), text("sine", "splines", "S+H", "square")
rslider bounds( 80,300, 60, 60), text("Rate"), channel("PRte"), range(0, 16.00, 0, 0.5)
rslider bounds(130,300, 60, 60), text("Depth"), channel("PDep"), range(0, 1.00, 0)
rslider bounds(180,300, 60, 60), text("Delay"), channel("PDel"), range(0, 2.00, 0, 0.5)
rslider bounds(230,300, 60, 60), text("Rise"), channel("PRis"), range(0, 2.00, 0.1, 0.5)
rslider bounds(280,300, 60, 60), text("Risset"), channel("TRate"), range(-3.00, 3, 0)
}

;FREQ. SHIFT
groupbox bounds(350,270, 70,100), colour( 20, 5, 25, 100), text("Freq.Shift"), fontcolour(200,0,0){
rslider bounds(355,300, 60, 60), text("Freq."), channel("FShift"), range(-1000, 1000, -1000)
}

;CHORUS
groupbox bounds(420,270,170,100), colour( 3, 10, 13, 100), text("Chorus"), fontcolour(255,200,0){
rslider bounds(425,300, 60, 60), text("Mix"), channel("ChoMix"), range(0, 1.00, 1)
rslider bounds(475,300, 60, 60), text("Depth"), channel("ChoDep"), range(0, 0.100, 0.01,0.5,0.0001)
rslider bounds(525,300, 60, 60), text("Rate"), channel("ChoRte"), range(0, 20.0, 4, 0.5)
}

keyboard pos(0, 370), size(590, 80)
}
image bounds(290, 455, 210, 20), colour(75, 85, 90, 100), plant("credit"){
label bounds(0.03, 0.15, .9, .7), text("Author: Iain McCurdy |2012|"), colour("white")
</Cabbage>


<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 4 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE. HIGHER ksmps can result in quantisation noise in kbrite modulations.
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1
seed 0
massign 0,2

;Author: Iain McCurdy (2012)

gisine ftgen 0,0,4096,10,1
giwfn ftgen 0, 0, 131072, 10, 1 ;A SINE WAVE
gioctfn ftgen 0, 0, 1024, -19, 1, 0.5, 270, 0.5 ;A HANNING-TYPE WINDOW
gasendL,gasendR init 0

opcode FreqShifter,a,aki
ain,kfshift,ifn xin ;READ IN INPUT ARGUMENTS
areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
asin oscili 1, kfshift, ifn, 0
acos oscili 1, kfshift, ifn, 0.25
;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
amod1 = areal * acos
amod2 = aimag * asin
;UPSHIFTING OUTPUT
aFS = (amod1 - amod2)
xout aFS ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1 ;read in widgets
gkamplfo chnget "amplfo"
gkbritelfo chnget "britelfo"
gkChoMix chnget "ChoMix"
gkChoDep chnget "ChoDep"
gkChoRte chnget "ChoRte"
gkRvbMix chnget "RvbMix"
gkRvbSize chnget "RvbSize"
gkFShift chnget "FShift"
gkNRte chnget "NRte"
gkNDep chnget "NDep"
gkpitchlfo chnget "pitchlfo"
gkPDel chnget "PDel"
gkPRis chnget "PRis"
gkPRte chnget "PRte"
gkPDep chnget "PDep"
endin

instr 2 ;hsboscil instrument. MIDI notes are directed here.
kporttime linseg 0,0.001,0.01 ;PORTAMENTO TIME VALUE RISES QUICKLY FROM ZERO TO A HELD VALUE
kamp chnget "amp" ;READ WIDGETS...
iAAtt chnget "AAtt" ;
iADec chnget "ADec" ;
iASus chnget "ASus" ;
iARel chnget "ARel" ;
aenv linsegr 0.001,iAAtt+0.001,1,iADec+0.001,iASus,iARel+0.001,0.001 ;AMPLITUDE ENVELOPE
iADel chnget "ADel" ;
iARis chnget "ARis" ;
kADep chnget "ADep" ;
kARte chnget "ARte" ;
kbrite chnget "brite" ;
kbrite portk kbrite,kporttime
koctcnt chnget "octcnt" ;
iBVelDep chnget "BVelDep" ;

iBAtt chnget "BAtt" ;
iBAttLev chnget "BAttLev" ;
iBDec chnget "BDec" ;
iBSus chnget "BSus" ;
iBRel chnget "BRel" ;
iBRelLev chnget "BRelLev" ;
kBEnv linsegr 0,iBAtt+0.001,iBAttLev,iBDec+0.001,iBSus,iBRel+0.001,iBRelLev ;'BRIGHTNESS' ENVELOPE
iBDel chnget "BDel" ;
iBRis chnget "BRis" ;
kBDep chnget "BDep" ;
kBRte chnget "BRte" ;

kTRate chnget "TRate" ;

ibasfreq cpsmidi ;READ MIDI NOTE PITCH

ktrig changed koctcnt ;IF 'NUMBER OF OCTAVES' AS DEFINED BY WIDGET CHANGES GENERATE A TRIGGER
if ktrig==1 then ;IF 'NUMBER OF OCTAVES' CHANGE TRIGGER HAS BEEN GENERATED...
reinit UPDATE ;BEGIN A REINITIALISATION PASS FROM LABEL 'UPDATE'
endif ;END OF CONDITIONAL
UPDATE: ;LABEL 'UPDATE'. REINITIALISATION PASS BEGINS FROM HERE

;AMPLITUDE LFO
kdepth linseg 0,iADel+0.001,0,iARis+0.001,1 ;DEPTH OF MODULATION ENVELOPE
if gkamplfo==1 then
kALFO lfo (kdepth*kADep)/2,kARte,0 ;LFO (sine)
elseif gkamplfo==2 then
kALFO jspline (kdepth*kADep)/2,kARte,kARte
elseif gkamplfo==3 then
kALFO randomh -(kdepth*kADep)/2,(kdepth*kADep)/2,kARte
kALFO port kALFO,0.001 ;smooth out the clicks
else
kALFO lfo (kdepth*kADep)/2,kARte,2 ;LFO (bi-square)
kALFO port kALFO,0.001 ;smooth out the clicks
endif

kALFO = (kALFO+0.5) + (1 - kADep) ;OFFSET AND RESCALE LFO FUNCTION

;VELOCITY TO AMPLITUDE
iVelAmp veloc 0.2,1 ;READ IN MIDI NOTE VELOCITY AS A VALUE WITHIN THE RANGE 0.2 TO 1

;BRIGHTNESS LFO
kdepth linseg 0,iBDel+0.001,0,iBRis+0.001,1 ;DEPTH OF MODULATION ENVELOPE
if gkbritelfo==1 then
kBLFO lfo kdepth*kBDep,kBRte,0 ;LFO (sine)
elseif gkbritelfo==2 then
kBLFO jspline kdepth*kBDep,kBRte,kBRte
elseif gkbritelfo==3 then
kBLFO randomh -kdepth*kBDep,kdepth*kBDep,kBRte
kBLFO port kBLFO,0.004 ;smooth out the clicks
else
kBLFO lfo kdepth*kBDep,kBRte,2 ;LFO (bi-square)
kBLFO port kBLFO,0.004 ;smooth out the clicks
endif

;VELOCITY TO BRIGHTNESS
iBVel ampmidi iBVelDep ;MIDI NOTE VELOCITY USED TO DERIVE A VALUE THAT WILL INFLUENCE 'BRIGHTNESS'
;NOISE
knoise gaussi 1, gkNDep, gkNRte

;RISSET
kRisset lfo 1,kTRate,4 ;'RISSET GLISSANDO' FUNCTION

;PITCH MODULATION
kPDepth linseg 0,i(gkPDel)+0.001,0,i(gkPRis)+0.001,1 ;DEPTH OF MODULATION ENVELOPE
if gkpitchlfo==1 then
kPLFO lfo gkPDep*kPDepth,gkPRte,0 ;LFO
elseif gkpitchlfo==2 then
kPLFO jspline gkPDep*kPDepth,gkPRte,gkPRte
elseif gkpitchlfo==3 then
kPLFO randomh -gkPDep*kPDepth,gkPDep*kPDepth,gkPRte
kPLFO port kPLFO,0.002 ;smooth out the clicks
else
kPLFO lfo gkPDep*kPDepth,gkPRte,2 ;LFO (bi-square)
kPLFO port kPLFO,0.002 ;smooth out the clicks
endif
aL hsboscil kamp*kALFO*iVelAmp, kPLFO+kRisset+knoise, kbrite+kBEnv+kBLFO+iBVel, ibasfreq, giwfn, gioctfn, i(koctcnt), rnd(1) ;CREATE AN hsboscil TONE FOR THE LEFT CHANNEL. RANDOM INITIAL PHASE CREATE STEREO EFFECT.
aR hsboscil kamp*kALFO*iVelAmp, kPLFO+kRisset+knoise, kbrite+kBEnv+kBLFO+iBVel, ibasfreq, giwfn, gioctfn, i(koctcnt), rnd(1) ;CREATE AN hsboscil TONE FOR THE RIGHT CHANNEL. RANDOM INITIAL PHASE CREATE STEREO EFFECT.
aL = aL*aenv ;APPLY AMPLITUDE ENVELOPE TO AUDIO OUTPUT OF hsboscil
aR = aR*aenv ;APPLY AMPLITUDE ENVELOPE TO AUDIO OUTPUT OF hsboscil
rireturn
/*FREQUENCY SHIFTER*/
if gkFShift==0 kgoto SKIP_FSHIFT ;IF F.SHIFT VALUE = 0, BYPASS THE EFFECT
kFShift portk gkFShift,kporttime
aL FreqShifter aL,kFShift,gisine
aR FreqShifter aR,kFShift,gisine
SKIP_FSHIFT:

outs aL,aR ;SEND AUDIO TO OUTPUTS
gasendL = gasendL+aL
gasendR = gasendR+aR
endin
instr 3 ;Chorus effect
if gkChoMix==0 goto SKIP_CHORUS
kporttime linseg 0,0.001,1
kporttime = kporttime/gkChoRte
kdlt1 randomi ksmps/sr,gkChoDep,gkChoRte,1
kdlt1 portk kdlt1,kporttime
adlt1 interp kdlt1
acho1 vdelay gasendL,adlt1*1000,1*1000
kdlt2 randomi ksmps/sr,gkChoDep,gkChoRte,1
kdlt2 portk kdlt2,kporttime
adlt2 interp kdlt2
acho2 vdelay gasendR,adlt2*1000,1*1000
kpan1 randomi 0,1,gkChoRte,1
kpan2 randomi 0,1,gkChoRte,1
a1L,a1R pan2 acho1,kpan1
a2L,a2R pan2 acho2,kpan2
achoL = a1L+a2L
achoR = a1R+a2R
outs achoL*gkChoMix,achoR*gkChoMix

gasendL = (gasendL+achoL)*gkRvbMix
gasendR = (gasendR+achoR)*gkRvbMix
SKIP_CHORUS:
gasendL = gasendL*gkRvbMix
gasendR = gasendR*gkRvbMix
endin

instr 4 ;reverb
if gkRvbMix==0 goto SKIP_REVERB
aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000
outs aL,aR
SKIP_REVERB:
clear gasendL,gasendR
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
i 3 0 [3600*24*7]
i 4 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 802
- 0
bin/cabbage-todo/Synths/oscbnk_synth.csd View File

@@ -0,0 +1,802 @@
oscbnk_synth.csd

A synthesizer utilising the oscbnk opcode

CONTROLS
--------

-Oscillators-
Amp -- output amplitude of the oscillators sections
N.Oscs -- number of oscillators
Spread -- pitch spread
SPeed -- speed of pitch modulations
Waveform -- (dropdown menu) wavefrom used by the oscillator. Trombone 2 is a multi-waveform wavetable instrument.
mono -- activate monophonic mode
Time -- portamento time (monophonic mode)
T.Shift -- wavetable shift (will alter the tone if a multi-waveform wavetable instrument is chosen)
< Bend / Bend > -- pitch bend up / pitch bend down (in semitones). These can be linked to midi controllers to replace Cabbages lack of response to pitch bend.
Bend Rng. -- pitch bend range

-Filter Envelope-
Filter -- filter cutoff global control
Env. -- amount of influnce of the envelope
Att. -- envelope attack time
Dec. -- envelope decay time
Sus. -- envelope sustain level
Rel. -- envelope release time

-Amplitude Envelope-
Att -- envelope attack time
Dec -- envelope decay time
Sus -- envelope sustain level
Rel -- envelope release time

-Filter-
Layers -- number of interations of tonex filter. Increasing this number will sharpen cutoff.

-Filter LFO-
shape -- (drop down menu) LFO shape
Rate -- LFO rate
Depth -- LFO depth / amplitude
Delay -- delay time before LFO has any effect
Rise -- time it take for LFO amplitude to rise from zero to 'Depth'

-Reverb-
Mix -- dry/wet mix
Size -- room size


<Cabbage>
form caption("Oscillator Bank Synth") size(525, 330), pluginID("oscb")

image bounds( 0, 0,525, 330), colour( 0, 0, 50), shape("sharp"), outline("white"), line(0)

;OSCILLATOR
groupbox bounds( 0, 0,525, 85), text("Oscillators"), fontcolour("white") plant("oscillators"){
rslider bounds( 5, 25, 55, 55), fontcolour("white"), text("Amp."), channel("amp"), range(0, 10.00, 1.24), tracker("white") colour(LightBlue)
rslider bounds( 50, 25, 55, 55), fontcolour("white"), text("N.Oscs."), channel("NOscs"), range(1, 100, 10, 1, 1), tracker("white") colour(LightBlue)
rslider bounds( 95, 25, 55, 55), fontcolour("white"), text("Spread"), channel("fmd"), range(0, 1.00, 0.005,0.25,0.000001), tracker("white") colour(LightBlue)
rslider bounds(140, 25, 55, 55), fontcolour("white"), text("Speed"), channel("mvt"), range(0, 100.000, 1, 0.25,0.0001), tracker("white") colour(LightBlue)
rslider bounds(185, 25, 55, 55), fontcolour("white"), text("Width"), channel("width"), range(0, 1.000, 1, 1,0.001), tracker("white") colour(LightBlue)
combobox bounds(240, 25, 80,18), channel("waveform"), value(1), text("saw", "square", "organ", "eee", "ooh", "Clarinet","Bass Clarinet", "C.Bass Clarinet","Oboe","Bassoon","C.Bassoon",Violin","Cello","Piccolo","Flute","Alto Flute","Bass Flute", "Ahh", "Horn P", "Horn F", "B.Tbn.Harmon", "B.Tbn.Straight", "B.Tbn.Open")
checkbox bounds(240, 50, 85, 13), text("Legato"), colour("yellow"), channel("legato"), value(0)
checkbox bounds(240, 65, 85, 13), text("Mono"), colour("yellow"), channel("mono"), value(0)
rslider bounds(292, 44, 38, 38), fontcolour("white"), text("Time"), channel("LegTim"), range(0, 4.00, 0.09, 0.5, 0.01), tracker("white") colour(LightBlue)

rslider bounds(325, 25, 55, 55), fontcolour("white"), text("T.Shift"), channel("WTableShift"), range(-36, 36, 0, 1,0.001), tracker("white") colour(LightBlue)
;PITCH BEND
rslider bounds(370, 25, 55, 55), fontcolour("white"), text("< Bend"), channel("BendDown"), range(-1,0, 0, 1,0.001), tracker("white") colour(LightBlue)
rslider bounds(415, 25, 55, 55), fontcolour("white"), text("Bend >"), channel("BendUp"), range(0, 1, 0, 1,0.001), tracker("white") colour(LightBlue)
rslider bounds(465, 25, 55, 55), fontcolour("white"), text("Bend Rng."), channel("BendRange"), range(1, 24, 12, 1,1), tracker("white") colour(LightBlue)
}

;AMPLITUDE ENVELOPE
groupbox bounds(290,85, 200, 85), text("Amplitude Envelope"), plant("AmpEnv"), fontcolour("white"){
rslider bounds( 5, 25, 55, 55), fontcolour("white"), text("Att."), channel("AAtt"), range(0, 8.00, 0.13,0.5), tracker("white") colour(LightBlue)
rslider bounds( 50, 25, 55, 55), fontcolour("white"), text("Dec."), channel("ADec"), range(0, 8.00, 0.01,0.5), tracker("white") colour(LightBlue)
rslider bounds( 95, 25, 55, 55), fontcolour("white"), text("Sus."), channel("ASus"), range(0, 1.00, 1.00, 0.5), tracker("white") colour(LightBlue)
rslider bounds(140, 25, 55, 55), fontcolour("white"), text("Rel."), channel("ARel"), range(0.01, 8, 1.67, 0.5), tracker("white") colour(LightBlue)
}

;FILTER
groupbox bounds(0, 85, 290, 85), text("Filter Envelope"), fontcolour("white"){
rslider bounds( 5, 110, 55, 55), fontcolour("white"), text("Filter"), channel("cf"), range(0, 10.00, 6), tracker("white") colour(LightBlue)
rslider bounds( 50, 110, 55, 55), fontcolour("white"), text("Env."), channel("FEnvAmt"), range(0, 10.00, 1.16), tracker("white") colour(LightBlue)
rslider bounds( 95, 110, 55, 55), fontcolour("white"), text("Att."), channel("FAtt"), range(0, 8.00, 0.1,0.5), tracker("white") colour(LightBlue)
rslider bounds(140, 110, 55, 55), fontcolour("white"), text("Dec."), channel("FDec"), range(0, 8.00, 1,0.5), tracker("white") colour(LightBlue)
rslider bounds(185, 110, 55, 55), fontcolour("white"), text("Sus."), channel("FSus"), range(0, 1.00, 4, 0.5), tracker("white") colour(LightBlue)
rslider bounds(230, 110, 55, 55), fontcolour("white"), text("Rel."), channel("FRel"), range(0.01, 8, 1.3, 0.5), tracker("white") colour(LightBlue)
}

;FILTER
groupbox bounds( 0,170, 90, 85), text("Filter"), plant("Filter"){
rslider bounds( 17, 25, 55, 55), fontcolour("white"), text("Layers"), channel("FiltLayers"), range(1, 10, 1,1,1), tracker("white") colour(LightBlue)
}

;FILTER LFO
groupbox bounds( 90,170,290, 85), text("Filter LFO"), plant("FilterLFO"), fontcolour("white"){
combobox bounds( 15, 35, 80, 20), channel("FlfoType"), value(2), text("sine", "splines", "S+H", "square")
rslider bounds( 95, 25, 55, 55), text("Rate"), channel("FRte"), range(0, 16.00, 4), fontcolour("white"), tracker("white") colour(LightBlue)
rslider bounds(140, 25, 55, 55), text("Depth"), channel("FDep"), range(0, 4.00, 0), fontcolour("white"), tracker("white") colour(LightBlue)
rslider bounds(185, 25, 55, 55), text("Delay"), channel("FDel"), range(0, 2.00, 0, 0.5), fontcolour("white"), tracker("white") colour(LightBlue)
rslider bounds(230, 25, 55, 55), text("Rise"), channel("FRis"), range(0, 2.00, 0.1, 0.5), fontcolour("white"), tracker("white") colour(LightBlue)

;REVERB
groupbox bounds(380,170, 110, 85), text("Reverb"), plant("Reverb"), fontcolour("white"){
rslider bounds( 5, 25, 55, 55), fontcolour("white"), text("Mix"), channel("RvbMix"), range(0, 1.00, 0.5), tracker("white") colour(LightBlue)
rslider bounds( 50, 25, 55, 55), fontcolour("white"), text("Size"), channel("RvbSize"), range(0, 1.00, 0.77), tracker("white") colour(LightBlue)
}

keyboard bounds(0, 255, 525, 75)

image bounds(5, 337, 250, 25), colour(75, 85, 90, 100), plant("credit"){
label bounds(0.03, 0.2, .9, .6), text("Author: Iain McCurdy |2012|"), colour("white")
}

</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=NULL -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
massign 0,1

;Author: Iain McCurdy (2012)

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; CLARINET
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;FOUR GEN10 FUNCTION TABLES WHICH CORRESPOND TO THE SPECTRAL ENVELOPES OF FOUR DIFFERENT NOTES PLAYED ON THE CLARINET
;THE FOUR NOTES CHOSEN COVER THE SOUNDING RANGE OF THE INSTRUMENT
;NOTE THAT ALL FUNCTION TABLES USED BY ftmorph IN THE MORPHING PROCESS, INCLUDING THE ONE INTO WHICH THE MORPHED TABLE IS WRITTEN (SEE INSTR 1), SHOULD BE THE SAME SIZE
;FOUR GEN10 FUNCTION TABLES WHICH CORRESPOND TO THE SPECTRAL ENVELOPES OF FOUR DIFFERENT NOTES PLAYED ON THE CLARINET
;THE FOUR NOTES CHOSEN COVER THE SOUNDING RANGE OF THE INSTRUMENT
;NOTE THAT ALL FUNCTION TABLES USED BY ftmorph IN THE MORPHING PROCESS, INCLUDING THE ONE INTO WHICH THE MORPHED TABLE IS WRITTEN (SEE INSTR 1), SHOULD BE THE SAME SIZE
giclar50 ftgen 0,0,4096,10,0.273597,0.027434,0.737705,0.049480,0.448437,0.272536,0.131175,0.129945,0.283082,0.130714,0.026719,0.037582,0.018953,0.010729,0.067580,0.024573,0.016586,0.049988,0.033294,0.017090,0.008591,0.021128,0.007237,0.016060,0.016060
giclar62 ftgen 0,0,4096,10,0.753504,0.011446,0.501720,0.055791,0.241768,0.037889,0.027203,0.062793,0.102494,0.030506,0.042453,0.050202,0.031077,0.027208,0.020897,0.022205,0.012154,0.008160,0.004886,0.005076,0.003805,0.001322,0.001149,0.001450,0.001450
giclar74 ftgen 0,0,4096,10,0.519536,0.062430,0.745521,0.055790,0.103856,0.097554,0.090420,0.077181,0.017130,0.013446,0.005674,0.003296,0.003438,0.003395,0.002506,0.001169,0.002525,0.001237,0.002624,0.001440,0.000880,0.001061,0.002672,0.002090,0.002090
giclar86 ftgen 0,0,4096,10,0.823209,0.201690,0.171118,0.161374,0.041951,0.004950,0.010889,0.001107,0.001365,0.003340,0.002259,0.001175,0.000442,0.001544,0.001259,0.000549,0.000455,0.000352,0.000345,0.000396,0.000477,0.000848,0.001199,0.001081,0.001081
giwavemapClar ftgen 0,0,128,-27, 0,0, 50,0, 62,1, 74,2, 86,3, 127,3
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfClar ftgen 0,0,4,-2,giclar50,giclar62,giclar74,giclar86

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASS CLARINET
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giBClar35 ftgen 0,0,4096,10,0.384232,0.038085,0.578537,0.029558,0.143002,0.119033,0.397678,0.113380,0.577246,0.158831,0.577514,0.094994,0.440674,0.109136,0.500666,0.132354,0.360370,0.104810,0.231403,0.089565,0.207353,0.099773,0.209066,0.123801,0.158769,0.079383,0.036078,0.019583,0.010310,0.017060,0.029465,0.045821,0.031622,0.038326,0.052222,0.058647,0.083956,0.079748,0.081955,0.097274,0.069934,0.075100,0.049259,0.058121,0.068078,0.065276,0.070165,0.065898,0.072432,0.055423,0.052283,0.036547,0.034082,0.035287,0.044801,0.053917,0.050263,0.036979,0.034264,0.035892,0.035011,0.037199,0.041542,0.043201,0.039923,0.035164,0.035828,0.036193,0.037155,0.035493,0.034546,0.035091,0.029891,0.027394,0.026174,0.023757,0.021365,0.019468,0.016295,0.015301,0.015263,0.014310,0.013239,0.011972,0.011445,0.011727,0.012391,0.013892,0.015395,0.015147,0.015137,0.014816,0.013898,0.012682,0.011462,0.009883,0.008579,0.007797,0.007749
giBClar41 ftgen 0,0,4096,10,0.525063,0.002869,0.469239,0.024384,0.895713,0.021156,0.199553,0.014871,0.215693,0.036697,0.212856,0.060220,0.224360,0.026202,0.021469,0.019475,0.067282,0.034970,0.025525,0.028958,0.038550,0.041724,0.035988,0.016617,0.026564,0.031021,0.037801,0.030070,0.055636,0.040575,0.029792,0.031356,0.031871,0.058063,0.027829,0.023825,0.015824,0.011714,0.011110,0.015367,0.011850,0.008957,0.011489,0.007029,0.004640,0.004862,0.006536,0.006771,0.006683,0.005231,0.005323,0.006834,0.005342,0.005818,0.004902,0.005468,0.005431,0.006151,0.004672,0.003041,0.002322,0.002274,0.002661,0.003122,0.002931,0.002587,0.002527,0.002499,0.003095,0.003755,0.003651,0.003768,0.003972,0.003962,0.003999,0.003352,0.002866,0.002449,0.002120,0.001972,0.002040,0.002221,0.002063,0.002057,0.002415,0.002849,0.003276,0.003776,0.003994,0.003829,0.003419,0.003328,0.003575,0.003829,0.003703,0.003454,0.003149,0.002825,0.002697,0.002765
giBClar47 ftgen 0,0,4096,10,0.447815,0.011780,0.911495,0.027076,0.846723,0.050517,0.224579,0.039801,0.048967,0.024162,0.071418,0.087315,0.031778,0.048063,0.058394,0.078770,0.021135,0.041585,0.092206,0.058125,0.063991,0.033673,0.025813,0.045142,0.037450,0.016766,0.014278,0.016668,0.017869,0.025925,0.010244,0.010062,0.010634,0.008986,0.006992,0.005186,0.004618,0.003658,0.002913,0.003004,0.004250,0.003142,0.002387,0.002692,0.003592,0.004496,0.002831,0.001838,0.001680,0.002144,0.002567,0.003185,0.002727,0.002419,0.001998,0.001883,0.002286,0.002626,0.003202,0.003257,0.003056,0.003241,0.002838,0.002521,0.002294,0.002409,0.002746,0.002848,0.003387,0.004173,0.004189,0.004587,0.005402,0.004977,0.004132,0.003842,0.003974,0.003650,0.003605,0.003810,0.003745,0.003770,0.003520,0.003363,0.003391,0.003302,0.003124,0.003422,0.004022,0.004064,0.003584,0.002939,0.002329,0.001970,0.001947,0.002034,0.002069,0.002043,0.001854,0.001658
giBClar53 ftgen 0,0,4096,10,0.819856,0.006052,0.508263,0.007439,0.271031,0.012967,0.059374,0.017922,0.016997,0.004014,0.027132,0.014921,0.020230,0.012123,0.021066,0.004875,0.016894,0.004428,0.004157,0.007603,0.004211,0.011103,0.005054,0.007329,0.004043,0.002169,0.003183,0.001822,0.001158,0.001758,0.002350,0.001442,0.002218,0.002815,0.001503,0.001764,0.001171,0.001508,0.000934,0.000714,0.000902,0.000884,0.000943,0.000825,0.000579,0.000572,0.000654,0.000752,0.000902,0.000932,0.000868,0.000909,0.000903,0.001065,0.001472,0.001483,0.001803,0.001941,0.002100,0.002756,0.002543,0.001984,0.001589,0.001342,0.001414,0.001219,0.001004,0.000908,0.000887,0.001102,0.001342,0.001312,0.001089,0.000869,0.000733,0.000620,0.000574,0.000518,0.000451,0.000422,0.000446,0.000473,0.000423,0.000354,0.000335,0.000370,0.000410,0.000418,0.000435,0.000434,0.000417,0.000417,0.000388,0.000342,0.000316,0.000303,0.000306,0.000309,0.000292,0.000267
giBClar59 ftgen 0,0,4096,10,0.866645,0.024133,0.420624,0.171074,0.353043,0.050546,0.198619,0.047824,0.110458,0.081558,0.064116,0.041109,0.026267,0.036570,0.013031,0.023724,0.007023,0.010067,0.004550,0.011618,0.009601,0.005731,0.005607,0.005036,0.002347,0.002907,0.001472,0.001519,0.001304,0.002584,0.001383,0.001362,0.001591,0.002655,0.004442,0.004905,0.003148,0.004830,0.002947,0.002926,0.003063,0.002394,0.002276,0.002019,0.001689,0.002028,0.002368,0.003510,0.004637,0.004228,0.003257,0.002700,0.002231,0.001681,0.001293,0.001062,0.001121,0.000894,0.000797,0.000865,0.000752,0.000724,0.000719,0.000787,0.000896,0.000801,0.000686,0.000551,0.000468,0.000466,0.000515,0.000460,0.000382,0.000358,0.000366,0.000400,0.000405,0.000355,0.000333,0.000349,0.000352,0.000346,0.000335,0.000317,0.000303,0.000297,0.000289,0.000276,0.000290,0.000292,0.000287,0.000307,0.000318,0.000332,0.000353,0.000374,0.000388,0.000398,0.000399,0.000407
giBClar65 ftgen 0,0,4096,10,0.934141,0.012361,0.023358,0.045609,0.025913,0.017772,0.009955,0.010837,0.007253,0.001002,0.004215,0.001570,0.004226,0.001334,0.000580,0.001740,0.000839,0.001364,0.001337,0.000523,0.000377,0.000535,0.000290,0.000461,0.000486,0.000333,0.000462,0.000685,0.001136,0.000794,0.000625,0.000436,0.000303,0.000270,0.000259,0.000289,0.000208,0.000224,0.000249,0.000271,0.000200,0.000240,0.000298,0.000226,0.000198,0.000188,0.000200,0.000259,0.000198,0.000169,0.000155,0.000144,0.000123,0.000120,0.000118,0.000112,0.000108,0.000105,0.000096,0.000091,0.000090,0.000093,0.000089,0.000093,0.000094,0.000095,0.000101,0.000112,0.000120,0.000126,0.000134,0.000142,0.000149,0.000170,0.000190,0.000212,0.000246,0.000289,0.000286,0.000269,0.000279,0.000310,0.000352,0.000355,0.000341,0.000361,0.000376,0.000373,0.000385,0.000427,0.000475,0.000539,0.000655,0.000838,0.001061,0.001284,0.001429,0.001364,0.001171,0.001020
giBClar71 ftgen 0,0,4096,10,0.951349,0.052635,0.166289,0.036346,0.080225,0.105328,0.019032,0.014538,0.003453,0.003349,0.001065,0.003529,0.004876,0.003334,0.003537,0.009903,0.004407,0.002506,0.002863,0.005317,0.004116,0.003426,0.001538,0.001829,0.001351,0.001942,0.001728,0.001103,0.000733,0.000413,0.000643,0.000468,0.000336,0.000631,0.000868,0.000470,0.000257,0.000240,0.000210,0.000190,0.000182,0.000170,0.000178,0.000178
giBClar77 ftgen 0,0,4096,10,0.679870,0.126072,0.031529,0.103885,0.017231,0.001781,0.005132,0.000787,0.003992,0.001819,0.002500,0.002660,0.001298,0.001834,0.001238,0.004273,0.001518,0.000670,0.000588,0.000395,0.000786,0.000400,0.000399,0.000471,0.000235,0.000212,0.000208,0.000169,0.000163,0.000146,0.000134
giwavemapBClar ftgen 0,0,128,-27, 0,0, 35,0, 41,1, 47,2, 53,3, 59,4, 65,5, 71,6, 77,7, 127,7
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfBClar ftgen 0,0,8,-2,giBClar35,giBClar41,giBClar47,giBClar53,giBClar59,giBClar65,giBClar71,giBClar77

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; CONTRA-BASS CLARINET
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giCBClar26 ftgen 0,0,4096,10,0.100160,0.005519,0.631940,0.013046,0.749042,0.308868,0.475605,0.152792,0.074315,0.238927,0.152260,0.251283,0.030787,0.052465,0.032473,0.121972,0.064172,0.090564,0.043994,0.091868,0.039563,0.058622,0.024531,0.023127,0.026665,0.067522,0.081377,0.057914,0.066176,0.036134,0.026135,0.021056,0.038011,0.036534,0.058393,0.040915,0.050051,0.038446,0.034166,0.021341,0.014481,0.015708,0.025527,0.026622,0.033577,0.027355,0.034434,0.022920,0.016354,0.010905,0.011160,0.015075,0.019871,0.017505,0.013189,0.011442,0.008511,0.007974,0.006368,0.005988,0.005976,0.005922,0.006590,0.008199,0.006566,0.005254,0.004955,0.005576,0.005463,0.005101,0.003955,0.003622,0.004027,0.003772,0.003504,0.002848,0.002183,0.002075,0.002143,0.002014,0.001907,0.001850,0.001736,0.001543,0.001318,0.001180,0.001107,0.001066,0.001169,0.001372,0.001533,0.001667,0.001738,0.001655,0.001604,0.001603,0.001571,0.001575,0.001638,0.001696
giCBClar32 ftgen 0,0,4096,10,0.227476,0.006718,0.707706,0.018101,0.539432,0.018848,0.590242,0.029143,0.512926,0.035712,0.324304,0.035306,0.035964,0.050992,0.096916,0.025035,0.098203,0.072427,0.068155,0.060324,0.042818,0.074538,0.049430,0.100999,0.052956,0.109337,0.053778,0.108791,0.040535,0.041998,0.050107,0.102568,0.075823,0.121836,0.062713,0.047451,0.042146,0.061836,0.063525,0.079775,0.056177,0.039271,0.021422,0.017934,0.022472,0.016758,0.023407,0.025034,0.018765,0.012566,0.009566,0.008232,0.011234,0.015948,0.018924,0.020397,0.016720,0.016224,0.010210,0.006760,0.006525,0.006464,0.006410,0.007832,0.010929,0.013172,0.010412,0.008153,0.005887,0.004927,0.005543,0.006358,0.006415,0.006246,0.004977,0.004037,0.003084,0.002646,0.002504,0.002716,0.003253,0.003484,0.003416,0.003566,0.003392,0.002924,0.002750,0.002979,0.003398,0.003635,0.003855,0.004032,0.004285,0.004278,0.003688,0.003182,0.002942,0.003043,0.003240,0.003317
giCBClar38 ftgen 0,0,4096,10,0.805943,0.003127,0.607438,0.006915,0.078379,0.025071,0.319458,0.040967,0.418440,0.096874,0.067519,0.066830,0.181701,0.148461,0.024736,0.047734,0.027229,0.065092,0.020252,0.015890,0.047795,0.096969,0.049469,0.024097,0.032227,0.032247,0.057763,0.064995,0.031760,0.023574,0.021449,0.017946,0.015989,0.010329,0.017096,0.025053,0.020021,0.014542,0.009659,0.010282,0.011754,0.016404,0.013970,0.019292,0.012226,0.007260,0.007191,0.010064,0.007246,0.007400,0.007562,0.005179,0.005520,0.005811,0.004710,0.005570,0.007523,0.007671,0.005694,0.004881,0.005241,0.004991,0.005944,0.006659,0.006213,0.004986,0.004006,0.003617,0.003290,0.003479,0.004050,0.003911,0.003373,0.003294,0.003284,0.002858,0.002674,0.003290,0.003986,0.003982,0.003503,0.003424,0.003640,0.003903,0.004267,0.004774,0.005048,0.005020,0.005284,0.005837,0.006116,0.006124,0.006474,0.007329,0.008198,0.008721,0.009014,0.008920,0.008202,0.007419
giCBClar44 ftgen 0,0,4096,10,0.715187,0.010393,0.137973,0.010188,0.404486,0.073659,0.420943,0.145565,0.080881,0.104506,0.227785,0.021310,0.035316,0.052724,0.023335,0.014334,0.087911,0.036461,0.047658,0.016909,0.047453,0.017513,0.031591,0.010028,0.009677,0.014384,0.012660,0.031094,0.010732,0.009677,0.005632,0.007197,0.005202,0.005881,0.004438,0.005851,0.003283,0.002870,0.001732,0.001824,0.003100,0.002099,0.002084,0.002567,0.003519,0.003856,0.003017,0.003288,0.003518,0.003481,0.002717,0.002212,0.002009,0.002374,0.002508,0.003004,0.002356,0.001681,0.001376,0.001435,0.001604,0.001881,0.001924,0.001783,0.002097,0.002582,0.002971,0.002922,0.002735,0.002884,0.003498,0.003726,0.003454,0.003486,0.003620,0.003356,0.003457,0.003775,0.003730,0.003481,0.003126,0.002660,0.002244,0.001883,0.001625,0.001518,0.001533,0.001594,0.001565,0.001529,0.001485,0.001598,0.001965,0.002295,0.002394,0.002424,0.002401,0.002320,0.002329,0.002436
giCBClar50 ftgen 0,0,4096,10,0.880714,0.104962,0.497883,0.045337,0.172861,0.109234,0.166844,0.037601,0.179775,0.048578,0.136813,0.079191,0.068937,0.019908,0.087293,0.031265,0.010402,0.048393,0.020759,0.005769,0.015444,0.004339,0.006113,0.010598,0.009591,0.007441,0.002840,0.003349,0.003193,0.003806,0.004954,0.003108,0.003744,0.003254,0.003682,0.002736,0.002830,0.004080,0.005132,0.004023,0.004801,0.004386,0.003962,0.002657,0.003137,0.003478,0.004208,0.004600,0.004272,0.004501,0.004804,0.004328,0.003739,0.003495,0.003378,0.002513,0.002268,0.002182,0.002140,0.001833,0.001900,0.001666,0.001525,0.001441,0.001541,0.001518,0.001571,0.001664,0.001746,0.001600,0.001474,0.001527,0.001644,0.001577,0.001450,0.001382,0.001479,0.001646,0.001713,0.001652,0.001720,0.001859,0.001891,0.001654,0.001420,0.001306,0.001228,0.001173,0.001188,0.001247,0.001299,0.001317,0.001264,0.001186,0.001091,0.000947,0.000797,0.000685,0.000610,0.000547
giCBClar54 ftgen 0,0,4096,10,0.889990,0.001348,0.087695,0.023926,0.066262,0.023447,0.075142,0.026596,0.020409,0.052699,0.027246,0.016811,0.017828,0.004566,0.005199,0.010830,0.003227,0.005838,0.001883,0.001580,0.004878,0.001870,0.000924,0.001648,0.002681,0.001616,0.003610,0.002587,0.002221,0.002332,0.001110,0.001616,0.002062,0.001241,0.000899,0.001174,0.001196,0.001105,0.001254,0.001253,0.001237,0.001093,0.001281,0.001260,0.001266,0.001255,0.001194,0.000995,0.001213,0.000908,0.000857,0.000902,0.000863,0.001171,0.001146,0.001074,0.000908,0.000908,0.000752,0.000618,0.000456,0.000395,0.000445,0.000503,0.000434,0.000353,0.000347,0.000373,0.000416,0.000392,0.000334,0.000271,0.000275,0.000314,0.000314,0.000317,0.000280,0.000275,0.000289,0.000253,0.000221,0.000203,0.000194,0.000194,0.000208,0.000221,0.000212,0.000185,0.000172,0.000176,0.000173,0.000178,0.000175,0.000159,0.000152,0.000150,0.000135,0.000120,0.000115,0.000119
giwavemapCBClar ftgen 0,0,128,-27, 0,0, 26,0, 32,1, 38,2, 44,3, 50,4, 54,5, 127,5
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfCBClar ftgen 0,0,8,-2,giCBClar26,giCBClar32,giCBClar38,giCBClar44,giCBClar50,giCBClar54,giCBClar54,giCBClar54

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; OBOE
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gioboe59 ftgen 0,0,4096,10,0.239013,0.078927,0.241030,0.206347,0.832266,0.054540,0.013821,0.007450,0.022905,0.021737,0.018123,0.013105,0.002361,0.001433,0.003509,0.002589,0.001326,0.000743,0.000990,0.000868,0.000863,0.000994,0.000406,0.000288,0.000288
gioboe65 ftgen 0,0,4096,10,0.199317,0.508088,0.859044,0.346880,0.121336,0.005269,0.071954,0.035188,0.012195,0.010362,0.001516,0.002397,0.004325,0.002943,0.008168,0.003519,0.002074,0.001366,0.001019,0.000715,0.000788,0.000757,0.001403,0.001108,0.001108
gioboe73 ftgen 0,0,4096,10,0.297865,0.916220,0.218345,0.030903,0.016039,0.045984,0.003571,0.006255,0.007310,0.003701,0.001306,0.001355,0.000361,0.001108,0.001552,0.000991,0.000588,0.000780,0.000678,0.001103,0.000615,0.000264,0.000310,0.000464,0.000464
gioboe81 ftgen 0,0,4096,10,0.875554,0.822621,0.094665,0.308960,0.046707,0.031827,0.002702,0.002222,0.009030,0.009257,0.007814,0.000781,0.002099,0.001154,0.002638,0.000756,0.000750,0.001290,0.000476,0.001285,0.000627,0.000379,0.000594,0.000379,0.000379
gioboe89 ftgen 0,0,4096,10,0.965505,0.344315,0.033044,0.068398,0.013147,0.008580,0.003609,0.001848,0.001060,0.001429,0.001832,0.001218,0.000703,0.000642,0.000646,0.000867,0.000550,0.000567,0.001386,0.001239,0.001416,0.001354,0.001710,0.003111,0.003111
giwavemapOboe ftgen 0,0,128,-27, 0,0, 59,0, 65,1, 73,2, 81,3, 89,4, 127,4
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfOboe ftgen 0,0,8,-2,gioboe59,gioboe65,gioboe73,gioboe81,gioboe89,gioboe89,gioboe89,gioboe89

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASSOON
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gibassoon34 ftgen 0,0,4096,10,0.213868,0.268493,0.244166,0.230801,0.105833,0.308087,0.556920,0.478956,0.523357,0.900665,0.213470,0.229596,0.031221,0.040117,0.067113,0.060158,0.030778,0.061028,0.143814,0.063668,0.126426,0.055009,0.049138,0.085854,0.113027,0.111464,0.088765,0.037342,0.050990,0.035579,0.040460,0.032219,0.027305,0.034141,0.019655,0.009315,0.008270,0.006748,0.006472,0.007088,0.008133,0.007046,0.007850,0.005791,0.006273,0.006847,0.007249,0.009398,0.010309,0.010418,0.010247,0.010333,0.009562,0.008180,0.009576,0.009469,0.008529,0.008844,0.008053,0.007565,0.008026,0.007284,0.007299,0.007423,0.008280,0.008374,0.008239,0.008512,0.009431,0.010246,0.010350,0.009381,0.008652,0.008150,0.007888,0.007951,0.008166,0.008210,0.007921,0.007548,0.007147,0.006991,0.006978,0.006527,0.005617,0.004781,0.004549,0.004707,0.004803,0.004640,0.004303,0.003866,0.003524,0.003348,0.003108,0.002766,0.002439,0.002278,0.002406,0.002733
gibassoon38 ftgen 0,0,4096,10,0.242897,0.242266,0.380380,0.667003,0.720921,0.402509,0.422424,0.475496,0.823674,0.135651,0.169435,0.062761,0.017494,0.023826,0.049210,0.074371,0.035978,0.086397,0.160820,0.122072,0.061609,0.020374,0.023031,0.018479,0.013838,0.015511,0.012693,0.005626,0.007015,0.007590,0.008854,0.004833,0.006678,0.008155,0.006694,0.007708,0.007823,0.004336,0.003679,0.003698,0.005616,0.004049,0.003555,0.002815,0.002166,0.001778,0.002195,0.002446,0.003427,0.003600,0.005046,0.005043,0.003980,0.002591,0.002168,0.002644,0.003363,0.004603,0.004571,0.005024,0.004653,0.004659,0.004447,0.004128,0.004325,0.004464,0.004393,0.004144,0.004285,0.004442,0.004203,0.003640,0.003229,0.003115,0.003017,0.002902,0.002799,0.002839,0.003045,0.003262,0.003391,0.003250,0.003008,0.002726,0.002506,0.002370,0.002215,0.002130,0.002058,0.001832,0.001574,0.001339,0.001133,0.001005,0.000924,0.000860,0.000849,0.000896,0.000994,0.001115
gibassoon43 ftgen 0,0,4096,10,0.101647,0.135289,0.245027,0.142720,0.728360,0.361154,0.030730,0.079698,0.011579,0.074893,0.094091,0.028910,0.084641,0.058767,0.035341,0.016688,0.006781,0.020365,0.020545,0.008172,0.007968,0.017127,0.016825,0.009248,0.003609,0.002361,0.002361,0.001409,0.001208,0.001278,0.001752,0.002711,0.002221,0.001898,0.001255,0.001150,0.001935,0.001759,0.001661,0.001219,0.001111,0.001527,0.001167,0.001290,0.001366,0.001058,0.000935,0.000898,0.000937,0.001254,0.001464,0.001695,0.002012,0.002054,0.001872,0.001370,0.001074,0.000988,0.001009,0.000959,0.000905,0.000957,0.000885,0.000825,0.000811,0.000776,0.000727,0.000696,0.000758,0.000768,0.000667,0.000604,0.000548,0.000525,0.000508,0.000485,0.000445,0.000380,0.000330,0.000307,0.000329,0.000366,0.000367,0.000334,0.000291,0.000259,0.000247,0.000265,0.000309,0.000378,0.000436,0.000425,0.000390,0.000375,0.000353,0.000328,0.000312,0.000292,0.000273,0.000269
gibassoon50 ftgen 0,0,4096,10,0.147763,0.340255,0.879202,0.404023,0.259274,0.130887,0.095096,0.039056,0.091976,0.009828,0.004879,0.013408,0.016090,0.015931,0.012402,0.003430,0.006421,0.004323,0.002018,0.001465,0.003012,0.001397,0.002446,0.002683,0.002425,0.004828,0.002422,0.002479,0.002086,0.002351,0.002269,0.002034,0.001708,0.001324,0.001927,0.002764,0.003997,0.003514,0.002736,0.002327,0.002054,0.001842,0.001577,0.002009,0.002098,0.001411,0.001019,0.000816,0.000899,0.000893,0.001005,0.001296,0.000987,0.000657,0.000539,0.000400,0.000313,0.000284,0.000331,0.000417,0.000479,0.000633,0.000798,0.000893,0.001067,0.001242,0.001260,0.001282,0.001218,0.001023,0.000887,0.000830,0.000746,0.000637,0.000553,0.000534,0.000537,0.000506,0.000482,0.000477,0.000490,0.000515,0.000532,0.000508,0.000473,0.000416,0.000336,0.000271,0.000229,0.000193,0.000170,0.000169,0.000185,0.000197,0.000205,0.000223,0.000247,0.000255,0.000248,0.000249
gibassoon56 ftgen 0,0,4096,10,0.258143,0.954570,0.553228,0.188964,0.031203,0.252375,0.179421,0.053961,0.022121,0.016058,0.006372,0.002854,0.002507,0.006348,0.006626,0.008348,0.005125,0.001342,0.001956,0.002664,0.005721,0.003529,0.004933,0.002543,0.003026,0.003332,0.001828,0.003024,0.002223,0.001464,0.001354,0.001310,0.000827,0.000966,0.001111,0.001685,0.001048,0.000806,0.000660,0.000445,0.000368,0.000436,0.000578,0.000518,0.000372,0.000346,0.000342,0.000340,0.000259,0.000272,0.000318,0.000395,0.000481,0.000454,0.000428,0.000391,0.000351,0.000302,0.000261,0.000245,0.000253,0.000249,0.000223,0.000228,0.000244,0.000217,0.000203,0.000222,0.000250,0.000271,0.000235,0.000202,0.000179,0.000160,0.000151,0.000151,0.000144,0.000126,0.000116,0.000123,0.000134,0.000140,0.000142,0.000142,0.000130,0.000117,0.000109,0.000109,0.000110,0.000111,0.000122,0.000129,0.000124,0.000116,0.000115,0.000113,0.000104,0.000092,0.000080,0.000071
gibassoon62 ftgen 0,0,4096,10,0.802206,0.854305,0.242064,0.037491,0.024258,0.012991,0.003920,0.008373,0.001787,0.001801,0.003935,0.008957,0.009944,0.004249,0.003799,0.003374,0.001734,0.004753,0.008252,0.004132,0.002330,0.001700,0.001925,0.001098,0.001154,0.001943,0.000954,0.000487,0.000432,0.000605,0.000812,0.000806,0.001001,0.001178,0.001065,0.001137,0.000877,0.000630,0.000538,0.000499,0.000605,0.000532,0.000532,0.000387,0.000288,0.000253,0.000313,0.000347,0.000292,0.000225,0.000167,0.000144,0.000121,0.000116,0.000110,0.000110,0.000119,0.000111,0.000106,0.000111,0.000115,0.000114,0.000101,0.000094,0.000100,0.000102,0.000097,0.000088,0.000079,0.000070,0.000064,0.000059,0.000054,0.000053,0.000053
gibassoon67 ftgen 0,0,4096,10,0.262539,0.973041,0.138354,0.113396,0.058172,0.030635,0.005565,0.001686,0.003483,0.001977,0.003774,0.002477,0.002439,0.001226,0.002781,0.002527,0.001020,0.000611,0.000658,0.000715,0.000728,0.000531,0.000442,0.000238,0.000414,0.000325,0.000560,0.000689,0.000445,0.000306,0.000301,0.000305,0.000296,0.000325,0.000252,0.000218,0.000248,0.000193,0.000174,0.000179,0.000143,0.000140,0.000140,0.000104,0.000096,0.000116,0.000128,0.000137,0.000144,0.000113,0.000112,0.000119,0.000140,0.000116,0.000107,0.000102
giwavemapBassoon ftgen 0,0,128,-27, 0,0, 34,0, 38,1, 43,2, 50,3, 56,4, 62,5, 67,6, 127,6
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfBassoon ftgen 0,0,8,-2,gibassoon34,gibassoon38,gibassoon43,gibassoon50,gibassoon56,gibassoon62,gibassoon67,gibassoon67

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; CONTRA-BASSOON
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giCBassoon22 ftgen 0,0,4096,10,0.497216,0.592986,0.588338,0.378063,0.343716,0.540022,0.620921,0.613540,0.848864,0.535558,0.632297,0.584663,0.443376,0.419439,0.291262,0.249631,0.256447,0.182209,0.062888,0.160047,0.156792,0.115884,0.107766,0.130415,0.183253,0.145108,0.156478,0.170472,0.185752,0.181506,0.155042,0.154256,0.167703,0.145571,0.172382,0.169936,0.191248,0.207520,0.161789,0.114105,0.096757,0.068310,0.056357,0.068193,0.048257,0.046235,0.041903,0.032361,0.023090,0.012851,0.008788,0.010598,0.010151,0.010905,0.009426,0.009439,0.012674,0.016976,0.019287,0.017791,0.014995,0.015280,0.014007,0.012293,0.013920,0.015130,0.017138,0.020001,0.026003,0.029085,0.026391,0.021776,0.018388,0.016337,0.014700,0.015521,0.019019,0.022414,0.024168,0.024006,0.023403,0.022377,0.020534,0.018428,0.016165,0.013675,0.011929,0.011056,0.010352,0.010070,0.009561,0.009378,0.008855,0.008393,0.008147,0.008048,0.008099,0.007480,0.006551,0.005481
giCBassoon26 ftgen 0,0,4096,10,0.076357,0.137793,0.174617,0.207802,0.302523,0.705801,0.162577,0.073808,0.224559,0.050465,0.066110,0.181682,0.062409,0.052317,0.037698,0.029936,0.042341,0.053436,0.135414,0.059248,0.025689,0.033567,0.051201,0.029910,0.028697,0.052991,0.059280,0.029742,0.027742,0.023801,0.013878,0.006197,0.004814,0.005139,0.007873,0.007104,0.009903,0.007952,0.008234,0.005783,0.006682,0.007272,0.006943,0.007674,0.007728,0.006326,0.005179,0.004259,0.004142,0.003705,0.002547,0.001785,0.002073,0.002887,0.004184,0.004075,0.004174,0.005101,0.004993,0.004189,0.003170,0.002599,0.002866,0.003689,0.005272,0.006515,0.007262,0.006420,0.005939,0.005247,0.004710,0.004619,0.004018,0.003371,0.002611,0.001906,0.001540,0.001341,0.001128,0.001025,0.001114,0.001151,0.001224,0.001403,0.001564,0.001709,0.001914,0.002097,0.002148,0.002190,0.002192,0.002124,0.002190,0.002485,0.002819,0.002892,0.002769,0.002559,0.002374,0.002161
giCBassoon38 ftgen 0,0,4096,10,0.240531,0.304670,0.289169,0.727482,0.578083,0.169149,0.057305,0.193624,0.167977,0.206006,0.182632,0.057408,0.103574,0.044785,0.084239,0.068303,0.030771,0.133375,0.096231,0.037016,0.046566,0.020770,0.020264,0.015211,0.029647,0.018603,0.027940,0.062861,0.033828,0.015594,0.016305,0.025478,0.034356,0.038642,0.028451,0.026747,0.014914,0.016727,0.015524,0.013236,0.014264,0.013651,0.014838,0.016490,0.021208,0.017660,0.013009,0.014867,0.013013,0.010426,0.009144,0.009462,0.009367,0.009624,0.008079,0.007399,0.009012,0.009384,0.008661,0.009051,0.009394,0.010578,0.011610,0.012184,0.010442,0.009130,0.008795,0.008468,0.010039,0.011205,0.011438,0.011489,0.010526,0.008902,0.007391,0.006198,0.005970,0.005264,0.004331,0.003874,0.003514,0.003418,0.003518,0.003409,0.003150,0.003023,0.003047,0.003199,0.003624,0.003999,0.003839,0.003629,0.003712,0.003872,0.003974,0.003836,0.003596,0.003353,0.003177,0.003070
giCBassoon50 ftgen 0,0,4096,10,0.200451,0.511764,0.153876,0.491651,0.722151,0.174751,0.087283,0.068341,0.008971,0.040014,0.041083,0.015335,0.047809,0.037606,0.038259,0.020124,0.022425,0.024747,0.016480,0.008528,0.006892,0.004131,0.005947,0.005585,0.006842,0.008448,0.015885,0.005820,0.002834,0.004626,0.003886,0.003621,0.004837,0.005276,0.002715,0.002900,0.003817,0.005081,0.005598,0.006033,0.006164,0.004260,0.003944,0.004776,0.004223,0.004351,0.004769,0.004836,0.004959,0.005380,0.004538,0.003969,0.003860,0.003536,0.003521,0.003397,0.002823,0.002162,0.002001,0.001663,0.001430,0.001505,0.001566,0.001468,0.001406,0.001439,0.001225,0.001095,0.001134,0.001316,0.001630,0.001839,0.001964,0.001940,0.001824,0.001694,0.001617,0.001526,0.001348,0.001116,0.000972,0.000973,0.001011,0.001015,0.000944,0.000785,0.000650,0.000609,0.000675,0.000782,0.000839,0.000818,0.000755,0.000661,0.000566,0.000498,0.000471,0.000478,0.000486,0.000479
giwavemapCBassoon ftgen 0,0,128,-27, 0,0, 22,0, 26,1, 38,2, 50,3, 127,3
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfCBassoon ftgen 0,0,4,-2,giCBassoon22,giCBassoon26,giCBassoon38,giCBassoon50


;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; VIOLIN
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giviolin55 ftgen 0,0,4096,10,0.081672,0.785854,0.808302,0.221447,0.136644,0.103608,0.051154,0.040070,0.071067,0.358903,0.053101,0.090036,0.033729,0.068969,0.060398,0.147336,0.060769,0.055245,0.044695,0.022179,0.058528,0.083706,0.029581,0.013173;,0.013173
giviolin67 ftgen 0,0,4096,10,0.344116,0.095361,0.038223,0.090317,0.145798,0.049369,0.076997,0.057555,0.016248,0.036189,0.014161,0.008738,0.010238,0.009625,0.005588,0.004762,0.002635,0.002162,0.002822,0.002144,0.001687,0.001955,0.001870,0.001011;,0.001011
giviolin79 ftgen 0,0,4096,10,0.403041,0.281156,0.259204,0.392900,0.236559,0.108769,0.117288,0.063588,0.039483,0.018245,0.012717,0.020183,0.008506,0.017915,0.008925,0.008575,0.006947,0.008142,0.005487,0.005970,0.004402,0.003161,0.002361,0.001942;,0.001942
giviolin91 ftgen 0,0,4096,10,0.231708,0.906742,0.215622,0.092709,0.057338,0.038101,0.030758,0.023439,0.009905,0.001298,0.002108,0.000516,0.000499,0.000123,0.000642,0.000732,0.004757,0.004547,0.017582,0.033035,0.098559,0.013616,0.017674,0.019601;,0.019601
giwavemapViolin ftgen 0,0,128,-27, 0,0, 55,0, 67,1, 79,2, 91,3, 127,3
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfViolin ftgen 0,0,4,-2,giviolin55,giviolin67,giviolin79,giviolin91 ;

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; CELLO
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gicello36 ftgen 0,0,4096,10,0.022943,0.412962,0.548431,0.578468,0.092241,0.116378,0.052974,0.029585,0.093977,0.119660,0.064074,0.051807,0.015094,0.094184,0.015488,0.006640,0.007091,0.011557,0.043467,0.023330,0.018118,0.026921,0.010285,0.007653,0.015306,0.023175,0.013051,0.004840,0.005658,0.010814,0.014921,0.026066,0.028334,0.015227,0.010740,0.008966,0.009389,0.012547,0.011544,0.009900,0.012403,0.013093,0.008259,0.007148,0.006129,0.004932,0.004332,0.003397,0.002497,0.002241,0.002187,0.002227,0.001634,0.001186,0.001119,0.001131,0.001276,0.000970,0.001101,0.001647,0.001936,0.001632,0.001190,0.000891,0.000883,0.000906,0.000894,0.000855,0.000768,0.000721,0.000750,0.000900,0.000965,0.000844,0.000765,0.000643,0.000535,0.000464,0.000409,0.000403,0.000489,0.000642,0.000773,0.000819,0.000871,0.000930,0.000979,0.000950,0.000781,0.000649,0.000620,0.000653,0.000661,0.000706,0.000805,0.000856,0.000832,0.000793,0.000750,0.000702
gicello48 ftgen 0,0,4096,10,0.171752,0.537455,0.217980,0.172188,0.552902,0.583964,0.452897,0.095360,0.059208,0.033024,0.126570,0.028481,0.067671,0.029869,0.055112,0.056284,0.025151,0.038689,0.027323,0.027935,0.070762,0.023514,0.016984,0.013118,0.008692,0.004591,0.002235,0.003399,0.002568,0.002224,0.002366,0.002892,0.004660,0.003562,0.002923,0.002328,0.002327,0.001705,0.001566,0.002356,0.002199,0.003381,0.006360,0.007320,0.004930,0.002809,0.002686,0.002156,0.001566,0.001273,0.001192,0.001380,0.001683,0.002133,0.003160,0.002820,0.002065,0.002097,0.002013,0.001649,0.001366,0.001053,0.000819,0.000730,0.000775,0.000937,0.001097,0.001063,0.000917,0.000815,0.000792,0.000857,0.001010,0.001203,0.001372,0.001408,0.001295,0.001173,0.001062,0.000942,0.000825,0.000761,0.000774,0.000854,0.000932,0.000968,0.000987,0.001022,0.001018,0.000944,0.000882,0.000829,0.000779,0.000734,0.000693,0.000655,0.000602,0.000547,0.000529,0.000548
gicello60 ftgen 0,0,4096,10,0.762584,0.124687,0.088950,0.091324,0.058688,0.034069,0.038828,0.065420,0.062254,0.058503,0.033332,0.014105,0.011585,0.004135,0.005176,0.004496,0.006698,0.008491,0.007044,0.003450,0.004771,0.016317,0.009897,0.007180,0.004105,0.002477,0.003995,0.002992,0.002346,0.002233,0.002558,0.002135,0.002301,0.001713,0.001191,0.001850,0.004203,0.001813,0.000969,0.001090,0.000636,0.001237,0.000844,0.001107,0.000880,0.000791,0.000640,0.000894,0.000554,0.000727,0.001041,0.001046,0.001079,0.000456,0.000410,0.000442,0.000431,0.000437,0.000427,0.000389,0.000350,0.000284,0.000269,0.000260,0.000210,0.000253,0.000328,0.000296,0.000290,0.000419,0.000452,0.000328,0.000215,0.000229,0.000333,0.000275,0.000208,0.000204,0.000163,0.000283,0.000253,0.000264,0.000178,0.000208,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
gicello72 ftgen 0,0,4096,10,0.601382,0.263076,0.197963,0.244245,0.217992,0.114034,0.025768,0.041518,0.011954,0.006391,0.012239,0.017818,0.016819,0.012798,0.007576,0.007376,0.002891,0.021377,0.005261,0.004421,0.009226,0.004333,0.001808,0.003989,0.002078,0.001344,0.001560,0.001240,0.001586,0.001307,0.000519,0.000761,0.001009,0.000632,0.000412,0.000414,0.000361,0.000406,0.000544,0.000741,0.000281,0.000164,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giwavemapCello ftgen 0,0,128,-27, 0,0, 36,0, 48,1, 60,2, 72,3, 127,3
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfCello ftgen 0,0,4,-2,gicello36,gicello48,gicello60,gicello72 ;

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; PICCOLO
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gipiccolo74 ftgen 0,0,4096,10,0.898113,0.247693,0.060222,0.127742,0.034019,0.044738,0.029980,0.018041,0.008219,0.009819,0.015719,0.009423,0.020117,0.011802,0.007226,0.003198,0.001597,0.002062,0.001590,0.001420,0.001087,0.000581,0.000370,0.000393,0.000393
gipiccolo80 ftgen 0,0,4096,10,0.837581,0.024769,0.144022,0.109176,0.031512,0.026122,0.004565,0.008379,0.004995,0.002685,0.003489,0.002674,0.002743,0.001129,0.000485,0.000367,0.000701,0.001563,0.001166,0.000647,0.000808,0.000622,0.000358,0.000227,0.000227
gipiccolo86 ftgen 0,0,4096,10,0.730803,0.323120,0.277720,0.044844,0.009400,0.022785,0.004602,0.005762,0.006400,0.002483,0.001490,0.002354,0.004728,0.002669,0.003175,0.001177,0.000761,0.000509,0.000449,0.000703,0.001078,0.002471,0.003905,0.004114,0.004114
gipiccolo92 ftgen 0,0,4096,10,0.883567,0.117309,0.144273,0.012664,0.016747,0.002921,0.002043,0.001429,0.002107,0.008510,0.001611,0.002330,0.000075,0.000381,0.000943,0.002268,0.001748,0.001626,0.000882,0.002765,0.003187,0.004911,0.008342,0.017209,0.017209
gipiccolo98 ftgen 0,0,4096,10,0.922186,0.144948,0.042529,0.011837,0.006901,0.000900,0.001625,0.000686,0.000507 ; ,0.000305,0.000305,0.000730,0.000922,0.001408,0.001499,0.005116,0.021056,0.151393,0.034986,0.124701,0.024182,0.008037,0.002664,0.001934,0.001934
gipiccolo106 ftgen 0,0,4096,10,0.501042,0.019695,0.008976,0.003473,0.006493,0.001700,0.002765,0.003224,0.006276 ; ,0.025062,0.036907,0.005386,0.046443,0.013720,0.005391,0.007819,0.019832,0.008441,0.006927,0.007528,0.018483,0.042516,0.057060,0.083779,0.083779
giwavemapPiccolo ftgen 0,0,128,-27, 0,0, 74,0, 80,1, 86,2, 92,3, 98,4, 106,5, 127,5
gitabs4morfPiccolo ftgen 0,0,8,-2,gipiccolo74,gipiccolo80,gipiccolo86,gipiccolo92,gipiccolo98,gipiccolo106,gipiccolo106,gipiccolo106 ;


;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; FLUTE
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giflute59 ftgen 0,0,4096,10,0.876155,0.188136,0.766537,0.278649,0.134428,0.143342,0.201465,0.068043,0.011284,0.021093,0.021494,0.010577,0.016431,0.007352,0.006864,0.007433,0.006500,0.004716,0.004282,0.002545,0.002718,0.002045,0.001768,0.002409,0.002409
giflute65 ftgen 0,0,4096,10,0.799971,0.564039,0.327027,0.076562,0.324116,0.049951,0.035116,0.048856,0.017988,0.004316,0.007909,0.004093,0.003013,0.003329,0.001707,0.001995,0.001913,0.000937,0.001543,0.001868,0.001289,0.001463,0.001865,0.001076,0.001076
giflute71 ftgen 0,0,4096,10,0.902388,0.107786,0.423495,0.078015,0.066093,0.032990,0.012352,0.008687,0.005253,0.004091,0.001790,0.002202,0.000853,0.001228,0.000810,0.000828,0.000601,0.000593,0.000647,0.000906,0.000925,0.001111,0.001302,0.000899,0.000899
giflute77 ftgen 0,0,4096,10,0.925667,0.059839,0.214284,0.013980,0.026778,0.008733,0.019436,0.002640,0.004217,0.002126,0.003513,0.002455,0.001336,0.001508,0.001589,0.002155,0.002549,0.001951,0.001614,0.001076,0.001253,0.001138,0.001073,0.000990,0.000990
giflute83 ftgen 0,0,4096,10,0.865610,0.041090,0.054192,0.043068,0.022098,0.002450,0.005687,0.002093,0.005076,0.001357,0.003848,0.006820,0.002879,0.005038,0.002273,0.002877,0.001043,0.001188,0.000857,0.000726,0.000537,0.000320,0.000390,0.000666,0.000666
giflute89 ftgen 0,0,4096,10,0.907108,0.032221,0.007003,0.010577,0.004166,0.002274,0.001089,0.002739,0.002459,0.002194,0.001351,0.000570,0.000469,0.000388,0.000228,0.000180,0.000377,0.000470,0.000724,0.001478,0.002258,0.002625,0.006255,0.003183,0.003183
giflute95 ftgen 0,0,4096,10,0.927168,0.094811,0.014160,0.010743,0.004640,0.002540,0.000535,0.000356,0.000205,0.000147,0.000042,0.000032,0.000090,0.000201,0.000171,0.000595,0.000136,0.000338,0.000284,0.000244,0.001813,0.001310,0.002113,0.000510,0.000510
giflute98 ftgen 0,0,4096,10,0.793870,0.077609,0.047389,0.012277,0.005127,0.002760,0.002619,0.000390,0.000109,0.000105,0.000147,0.000425,0.000266,0.000201,0.000312,0.000210,0.001391,0.003570,0.001720,0.002746,0.001399,0.000749,0.000411,0.001156,0.001156
giwavemapFlute ftgen 0,0,128,-27, 0,0, 59,0, 65,1, 71,2, 77,3, 83,4, 89,5, 95,6, 98,7, 127,7
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfFlute ftgen 0,0,8,-2,giflute59,giflute65,giflute71,giflute77,giflute83,giflute89,giflute95,giflute98

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; ALTO FLUTE
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giAFlute55 ftgen 0,0,4096,10,0.821986,0.323726,0.027144,0.049562,0.045630,0.004837,0.008584,0.002449,0.002921,0.004780,0.006174,0.006496,0.009180,0.010020,0.008884,0.006397,0.007728,0.007543,0.005540,0.004643,0.004213,0.003464,0.002247,0.001529,0.001529
giAFlute61 ftgen 0,0,4096,10,0.629423,0.050378,0.078267,0.098147,0.002593,0.003473,0.002978,0.007847,0.002718,0.004264,0.004001,0.003129,0.002278,0.001767,0.001591,0.001198,0.000790,0.000910,0.000907,0.000909,0.000690,0.001006,0.000870,0.000801,0.000801
giAFlute67 ftgen 0,0,4096,10,0.734185,0.213440,0.086548,0.055143,0.004785,0.001811,0.011006,0.004212,0.001873,0.002130,0.001001,0.000376,0.000632,0.000823,0.000595,0.000764,0.000514,0.000403,0.000326,0.000317,0.000537,0.000523,0.000835,0.000743,0.000743
giAFlute76 ftgen 0,0,4096,10,0.868899,0.390848,0.052590,0.023839,0.033699,0.031143,0.013923,0.008881,0.003821,0.001797,0.003048,0.002506,0.002295,0.001878,0.001118,0.001109,0.001133,0.001732,0.002085,0.002020,0.001240,0.000963,0.000929,0.000456,0.000456
giwavemapAFlute ftgen 0,0,128,-27, 0,0, 55,0, 61,1, 67,2, 76,3, 127,3
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfAFlute ftgen 0,0,4,-2,giAFlute55,giAFlute55,giAFlute55,giAFlute55

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASS FLUTE
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giBFlute48 ftgen 0,0,4096,10,0.691967,0.034269,0.271945,0.033667,0.017446,0.011342,0.007238,0.006576,0.003027,0.003556,0.004425,0.004988,0.003990,0.005253,0.006140,0.003051,0.004437,0.003567,0.002838,0.001703,0.001528,0.001368,0.001703,0.001153,0.000827,0.001023,0.000899,0.000612,0.000827,0.000823,0.000948,0.001184,0.001201,0.001272,0.001032,0.001141,0.001128,0.000887,0.000790,0.000612,0.000565,0.000573,0.000586,0.000554,0.000483,0.000450,0.000404,0.000416,0.000392,0.000391,0.000327,0.000336,0.000370,0.000424,0.000460,0.000459,0.000456,0.000395,0.000319,0.000306,0.000283,0.000306,0.000338,0.000305,0.000288,0.000263,0.000247,0.000239,0.000245,0.000233,0.000190,0.000166,0.000161,0.000160,0.000150,0.000136,0.000130,0.000130,0.000126,0.000126,0.000128,0.000131,0.000131,0.000136,0.000138,0.000132,0.000122,0.000116,0.000119,0.000126,0.000122,0.000112,0.000109,0.000113,0.000118,0.000118,0.000118,0.000117,0.000116,0.000118
giBFlute54 ftgen 0,0,4096,10,0.633439,0.578363,0.200810,0.008032,0.068714,0.005615,0.005448,0.012421,0.009987,0.006289,0.004137,0.002738,0.001944,0.002935,0.003674,0.002567,0.002545,0.004116,0.003915,0.002935,0.002322,0.002647,0.003186,0.003370,0.003213,0.002193,0.001902,0.001629,0.001652,0.001274,0.001102,0.001205,0.001277,0.001134,0.001117,0.001286,0.001477,0.001607,0.002607,0.003270,0.002939,0.002558,0.001826,0.001324,0.001228,0.001070,0.001110,0.001120,0.001042,0.000924,0.000909,0.000880,0.000765,0.000674,0.000600,0.000491,0.000437,0.000441,0.000443,0.000452,0.000467,0.000527,0.000606,0.000571,0.000554,0.000518,0.000420,0.000363,0.000315,0.000275,0.000245,0.000221,0.000200,0.000202,0.000219,0.000211,0.000194,0.000187,0.000197,0.000197,0.000193,0.000201,0.000217,0.000223,0.000219,0.000213,0.000200,0.000175,0.000149,0.000131,0.000124,0.000120,0.000115,0.000111,0.000113,0.000117,0.000115,0.000107,0.000100,0.000098
giBFlute60 ftgen 0,0,4096,10,0.801592,0.068816,0.032303,0.012614,0.002660,0.014692,0.002493,0.006175,0.001826,0.001416,0.002607,0.001063,0.001542,0.001053,0.001293,0.001226,0.000781,0.001142,0.000975,0.000922,0.000693,0.000570,0.000538,0.000429,0.000587,0.000775,0.000855,0.001295,0.001190,0.000941,0.000912,0.000796,0.000662,0.000789,0.000828,0.000784,0.000614,0.000480,0.000455,0.000378,0.000334,0.000309,0.000351,0.000375,0.000427,0.000378,0.000293,0.000232,0.000224,0.000199,0.000150,0.000119,0.000100,0.000084,0.000084,0.000088,0.000085,0.000081,0.000076,0.000081,0.000080,0.000075,0.000071,0.000068,0.000063,0.000060,0.000064,0.000067,0.000065,0.000058,0.000055,0.000054,0.000054,0.000053,0.000052,0.000053,0.000053,0.000053,0.000052,0.000050,0.000049,0.000049,0.000049,0.000049,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giBFlute66 ftgen 0,0,4096,10,0.743019,0.068238,0.021487,0.010397,0.001744,0.013212,0.001676,0.005245,0.002049,0.001401,0.001686,0.001346,0.001288,0.000879,0.001087,0.000922,0.000878,0.000678,0.000904,0.000729,0.000481,0.000542,0.000525,0.000561,0.000481,0.000552,0.000745,0.001153,0.001211,0.001000,0.000706,0.000621,0.000613,0.000779,0.000764,0.000717,0.000619,0.000486,0.000448,0.000429,0.000341,0.000327,0.000331,0.000340,0.000340,0.000335,0.000288,0.000255,0.000233,0.000195,0.000173,0.000150,0.000127,0.000123,0.000119,0.000113,0.000111,0.000115,0.000116,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giBFlute72 ftgen 0,0,4096,10,0.741444,0.066744,0.018973,0.009713,0.002046,0.010742,0.001911,0.004984,0.002277,0.001308,0.001841,0.000932,0.001065,0.000889,0.001029,0.000970,0.000767,0.000708,0.000743,0.000629,0.000541,0.000457,0.000410,0.000534,0.000487,0.000489,0.000743,0.001263,0.001164,0.001062,0.000757,0.000529,0.000538,0.000606,0.000594,0.000583,0.000497,0.000463,0.000498,0.000433,0.000369,0.000363,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giBFlute76 ftgen 0,0,4096,10,0.745977,0.066489,0.014197,0.007352,0.002175,0.009766,0.002280,0.004362,0.001870,0.001375,0.001383,0.001328,0.001381,0.001194,0.001429,0.000949,0.000917,0.000802,0.000818,0.000932,0.000636,0.000646,0.000571,0.000575,0.000613,0.000679,0.000959,0.001343,0.001448,0.001365,0.001241,0.001091,0.001093,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giwavemapBFlute ftgen 0,0,128,-27, 0,0, 48,0, 54,1, 60,2, 66,3, 72,4, 76,5, 127,5
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfBFlute ftgen 0,0,4,-2,giBFlute48,giBFlute54,giBFlute60,giBFlute66,giBFlute72,giBFlute76

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; AHH
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giahh43 ftgen 0,0,4096,10,0.386674,0.073031,0.081855,0.018459,0.053239,0.061160,0.058957,0.045203,0.039489,0.065846,0.041424,0.012866,0.006504,0.005909,0.005469,0.003737,0.003814,0.002639,0.002638,0.003016,0.004285,0.006226,0.007688,0.008839,0.014596,0.028866,0.037921,0.022164,0.015744,0.007756,0.005050,0.007234,0.008132,0.006564,0.005699,0.007003,0.007011,0.005459,0.004080,0.003820,0.004403,0.004661,0.005385,0.007278,0.009647,0.010877,0.012884,0.014945,0.015339,0.012290,0.009204,0.008363,0.007093,0.005203,0.003328,0.002161,0.001538,0.001215,0.001037,0.001033,0.001172,0.001483,0.002127,0.002644,0.002412,0.001679,0.001068,0.000848,0.000972,0.001425,0.002263,0.003492,0.004427,0.004100,0.003201,0.002484,0.002255,0.002495,0.003139,0.004136,0.005259,0.005878,0.005432,0.004477,0.003617,0.002973,0.002606,0.002518,0.002611,0.002863,0.003395,0.004095,0.004529,0.004686,0.004927,0.005437,0.006092,0.006727,0.007073,0.006966
giahh49 ftgen 0,0,4096,10,0.600063,0.256340,0.126445,0.040717,0.097956,0.082383,0.135342,0.006369,0.002414,0.002312,0.001526,0.000552,0.000868,0.000435,0.000576,0.001145,0.001706,0.003688,0.013234,0.006626,0.006840,0.012971,0.003639,0.002955,0.001962,0.001988,0.000831,0.000533,0.000748,0.000490,0.000674,0.001431,0.002663,0.002680,0.002874,0.003227,0.001837,0.000874,0.000662,0.000901,0.001630,0.002139,0.001816,0.001233,0.000817,0.000658,0.000730,0.000864,0.001037,0.001616,0.002390,0.002487,0.002363,0.002429,0.002624,0.002971,0.002486,0.001530,0.000895,0.000669,0.000806,0.001085,0.001185,0.001002,0.000857,0.000900,0.001009,0.001198,0.001398,0.001306,0.001302,0.001562,0.001670,0.001440,0.001105,0.000872,0.000746,0.000748,0.000770,0.000788,0.000890,0.000973,0.000896,0.000716,0.000598,0.000536,0.000492,0.000469,0.000443,0.000384,0.000317,0.000262,0.000209,0.000162,0.000129,0.000110,0.000102,0.000099,0.000099,0.000096
giahh55 ftgen 0,0,4096,10,0.667225,0.194524,0.098683,0.096875,0.021209,0.006311,0.002978,0.001013,0.001249,0.001446,0.002393,0.004826,0.018741,0.012161,0.010480,0.005261,0.004569,0.001376,0.001132,0.003605,0.001846,0.002757,0.005346,0.004712,0.004806,0.002357,0.001109,0.001302,0.001860,0.001054,0.001120,0.001642,0.002240,0.004382,0.005473,0.003755,0.002444,0.002088,0.001822,0.000946,0.000790,0.001222,0.001653,0.001374,0.001401,0.002118,0.002061,0.001470,0.001198,0.001635,0.002387,0.002248,0.001327,0.000951,0.000884,0.000844,0.000805,0.000667,0.000669,0.000701,0.000591,0.000445,0.000367,0.000314,0.000272,0.000225,0.000179,0.000152,0.000164,0.000169,0.000151,0.000144,0.000137,0.000121,0.000115,0.000123,0.000125,0.000116,0.000102,0.000095,0.000102,0.000120,0.000135,0.000132,0.000117,0.000100,0.000084,0.000074,0.000072,0.000075,0.000077,0.000079,0.000083,0.000083,0.000081,0.000082,0.000084,0.000081,0.000074,0.000063
giahh61 ftgen 0,0,4096,10,0.701578,0.444091,0.390732,0.103519,0.007759,0.002497,0.001883,0.001103,0.001729,0.001889,0.001679,0.002455,0.000872,0.000433,0.001071,0.001382,0.002270,0.001077,0.000930,0.000940,0.001143,0.001633,0.001901,0.001446,0.002619,0.003724,0.002339,0.001969,0.001199,0.000674,0.001015,0.001321,0.001504,0.001378,0.000778,0.000682,0.001100,0.001312,0.001438,0.001513,0.000928,0.000466,0.000374,0.000410,0.000492,0.000515,0.000367,0.000230,0.000171,0.000169,0.000209,0.000236,0.000189,0.000194,0.000205,0.000196,0.000184,0.000168,0.000186,0.000223,0.000241,0.000197,0.000144,0.000113,0.000100,0.000101,0.000097,0.000088,0.000075,0.000067,0.000060,0.000051,0.000044,0.000040,0.000036,0.000034,0.000033,0.000033,0.000033,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giahh67 ftgen 0,0,4096,10,0.836515,0.800602,0.036351,0.016206,0.006383,0.007973,0.003273,0.011820,0.001230,0.001857,0.003725,0.004792,0.002586,0.008972,0.005518,0.007339,0.005207,0.006633,0.005670,0.005010,0.005379,0.002919,0.004501,0.004490,0.002854,0.003643,0.005161,0.002824,0.002183,0.001438,0.001060,0.000978,0.001138,0.001729,0.001501,0.001117,0.000626,0.000578,0.000512,0.000294,0.000255,0.000311,0.000397,0.000310,0.000205,0.000188,0.000179,0.000164,0.000172,0.000143,0.000115,0.000095,0.000084,0.000081,0.000080,0.000080,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giwavemapAhh ftgen 0,0,128,-27, 0,0, 43,0, 49,1, 55,2, 61,3, 67,4, 127,4
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
gitabs4morfAhh ftgen 0,0,8,-2,giahh43,giahh49,giahh55,giahh61,giahh67,giahh67,giahh67,giahh67

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; HORN P
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giHornP38 ftgen 0,0,4096,10,0.045737,0.148188,0.335691,0.493464,0.710665,0.765723,0.694286,0.628629,0.521398,0.428206,0.365416,0.306040,0.298023,0.254152,0.201721,0.154086,0.161771,0.146790,0.124044,0.110268,0.091099,0.076808,0.057743,0.042724,0.042724
giHornP50 ftgen 0,0,4096,10,0.280951,0.717837,0.823404,0.588908,0.394696,0.286430,0.176355,0.118365,0.064524,0.033209,0.016001,0.004104,0.004396,0.002069,0.002350,0.001903,0.001098,0.001262,0.001129,0.000906,0.000543,0.000575,0.000427,0.000355,0.000355
giHornP62 ftgen 0,0,4096,10,0.495327,0.909763,0.613398,0.368832,0.202553,0.124640,0.046586,0.011810,0.012510,0.011370,0.006659,0.004564,0.002331,0.001790,0.000667,0.000538,0.000352,0.000302,0.000558,0.000794,0.000797,0.000331,0.000342,0.000389,0.000389
giHornP74 ftgen 0,0,4096,10,0.796534,0.226262,0.060526,0.013273,0.003161,0.001015,0.001071,0.000595,0.000191,0.000337,0.000199,0.000173,0.000183,0.000187,0.000105,0.000113,0.000156,0.000119,0.000098,0.000067,0.000066,0.000064,0.000054,0.000043,0.000043
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
giwavemapHornP ftgen 0,0,128,-27, 0,0, 38,0, 50,1, 62,2, 74,3, 127,3
gitabs4morfHornP ftgen 0,0,4,-2,giHornP38,giHornP50,giHornP62,giHornP74

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; HORN F
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giHornF38 ftgen 0,0,4096,10,0.150333,0.205756,0.869097,0.723941,0.707935,0.116871,0.238125,0.330962,0.443031,0.325212,0.131256,0.267361,0.273576,0.146568,0.209758,0.158564,0.179271,0.084668,0.112177,0.118845,0.124993,0.096945,0.128906,0.125534,0.125534
giHornF50 ftgen 0,0,4096,10,0.348154,0.319965,0.418661,0.396206,0.046368,0.198167,0.035091,0.107400,0.035358,0.066696,0.053722,0.045581,0.066494,0.109943,0.059354,0.050001,0.123615,0.052990,0.032207,0.039448,0.051629,0.014079,0.014571,0.017523,0.017523
giHornF62 ftgen 0,0,4096,10,0.449507,0.544173,0.108516,0.300530,0.163030,0.351952,0.171674,0.202505,0.098101,0.066418,0.044492,0.071036,0.074224,0.064911,0.027430,0.041991,0.022245,0.017689,0.013130,0.020853,0.016891,0.038363,0.017524,0.016841,0.016841
giHornF74 ftgen 0,0,4096,10,0.923831,0.259141,0.262670,0.175552,0.089346,0.073056,0.055113,0.031968,0.027964,0.033656,0.035303,0.010920,0.019420,0.013447,0.012944,0.006111,0.007041,0.003864,0.005702,0.004615,0.003076,0.001589,0.002756,0.001234,0.001234
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
giwavemapHornF ftgen 0,0,128,-27, 0,0, 38,0, 50,1, 62,2, 74,3, 127,3
gitabs4morfHornF ftgen 0,0,4,-2,giHornF38,giHornF50,giHornF62,giHornF74

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASS TROMBONE (HARMON MUTE)
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giharmon33 ftgen 0,0,4096,10,0.875348,0.155770,0.111939,0.181031,0.355046,0.044216,0.039025,0.036422,0.074587,0.050492,0.042464,0.079868,0.121542,0.243299,0.253642,0.263571,0.422410,0.624259,0.742333,0.514304,0.760971,0.444426,0.456583,0.195508,0.070084,0.032239,0.029621,0.058523,0.044442,0.057324,0.077997,0.047218,0.046215,0.023786,0.017859,0.017652,0.012055,0.009595,0.009020,0.006000,0.004077,0.004950,0.004543,0.003196,0.002659,0.003533,0.004156,0.003745,0.002471,0.002264,0.003050,0.002614,0.001944,0.001709,0.001717,0.001934,0.002458,0.003618,0.004915,0.004334,0.003733,0.003804,0.003489,0.002755,0.002427,0.002273,0.002577,0.002702,0.002483,0.002059,0.002016,0.002214,0.002215,0.001947,0.001952,0.002236,0.002357,0.002417,0.002406,0.002309,0.002176,0.002227,0.002527,0.002649,0.002448,0.002165,0.002175,0.002322,0.002371,0.002202,0.001845,0.001620,0.001626,0.001927,0.002537,0.003091,0.003220,0.003231,0.003453,0.003751
giharmon34 ftgen 0,0,4096,10,0.443604,0.040301,0.041393,0.115682,0.622143,0.055550,0.073493,0.090539,0.109410,0.039052,0.138611,0.161174,0.290931,0.212197,0.410393,0.749789,0.917784,1.375368,0.934044,0.781551,0.356416,0.290222,0.181279,0.061983,0.081959,0.039112,0.044805,0.058922,0.022274,0.022731,0.038966,0.025063,0.031263,0.030753,0.032383,0.045020,0.032652,0.027144,0.033411,0.020397,0.015121,0.017071,0.014804,0.013636,0.012149,0.012930,0.014231,0.012821,0.011342,0.009001,0.008587,0.006187,0.005928,0.008836,0.012118,0.012242,0.009968,0.009445,0.006852,0.004519,0.002870,0.001975,0.001680,0.001593,0.001930,0.002744,0.003798,0.003938,0.003311,0.003174,0.003465,0.004740,0.006267,0.006620,0.006071,0.005274,0.005318,0.005795,0.006440,0.007152,0.007792,0.008192,0.007304,0.005765,0.004397,0.003369,0.002855,0.003059,0.003731,0.004377,0.004923,0.005763,0.006567,0.006834,0.006780,0.006575,0.005922,0.004714,0.003481,0.002696
giharmon36 ftgen 0,0,4096,10,0.934870,0.094639,0.263729,0.103300,0.556951,0.047384,0.167404,0.119804,0.122737,0.048833,0.154640,0.111318,0.302046,0.230750,0.517436,0.259307,0.354474,0.152230,0.109031,0.091431,0.071065,0.027335,0.037383,0.048534,0.033460,0.066084,0.041563,0.049933,0.029361,0.032804,0.017292,0.018054,0.023006,0.019576,0.018461,0.008645,0.007040,0.005924,0.005415,0.003713,0.003447,0.002816,0.003594,0.003583,0.002658,0.001561,0.001446,0.002347,0.003707,0.005343,0.007152,0.006970,0.005630,0.004404,0.002749,0.002098,0.002393,0.001708,0.001255,0.001150,0.001263,0.001445,0.001397,0.001331,0.001510,0.001783,0.001849,0.001576,0.001508,0.001400,0.001153,0.000940,0.000797,0.000734,0.000677,0.000581,0.000531,0.000644,0.000829,0.000891,0.000846,0.000864,0.000921,0.000980,0.000945,0.000994,0.001078,0.001054,0.000936,0.000863,0.000855,0.000855,0.000757,0.000683,0.000687,0.000667,0.000654,0.000639,0.000610,0.000586
giharmon38 ftgen 0,0,4096,10,0.275894,0.119750,0.302577,0.931731,0.080509,0.210351,0.194035,0.223110,0.137304,0.197845,0.327194,0.349699,0.653623,0.881895,0.939789,0.691399,0.569520,0.195895,0.129254,0.040633,0.094914,0.073078,0.145254,0.105583,0.162773,0.080818,0.095817,0.054832,0.079542,0.059357,0.055196,0.036903,0.021942,0.019084,0.020925,0.014726,0.013288,0.012653,0.010311,0.008738,0.008159,0.006852,0.004697,0.006565,0.011392,0.016788,0.018297,0.017879,0.015021,0.009463,0.005643,0.005105,0.004046,0.004010,0.005012,0.004282,0.003406,0.003104,0.003782,0.005116,0.003975,0.002459,0.001720,0.001650,0.002105,0.002882,0.003694,0.004103,0.003070,0.001947,0.001446,0.001258,0.001170,0.001349,0.001876,0.002582,0.002853,0.002391,0.002009,0.001887,0.001808,0.001514,0.001333,0.001265,0.001131,0.001082,0.001169,0.001278,0.001225,0.001070,0.000913,0.000800,0.000767,0.000799,0.000824,0.000902,0.001003,0.001061,0.001115,0.001185
giharmon39 ftgen 0,0,4096,10,0.215899,0.043569,0.155862,0.915877,0.029041,0.085938,0.096861,0.027476,0.042161,0.045780,0.077178,0.073681,0.292899,0.268475,0.052870,0.047343,0.020451,0.005226,0.004051,0.013123,0.014796,0.018766,0.016900,0.010549,0.011430,0.006502,0.006649,0.009883,0.007521,0.005298,0.002202,0.001505,0.001267,0.001744,0.001762,0.001880,0.001510,0.001300,0.001551,0.001113,0.001344,0.002682,0.004692,0.003899,0.003280,0.002211,0.001351,0.000889,0.000702,0.000681,0.000890,0.000985,0.000873,0.001082,0.000955,0.001016,0.001084,0.000930,0.000860,0.000656,0.000607,0.000724,0.000840,0.000859,0.000735,0.000640,0.000553,0.000553,0.000664,0.000694,0.000736,0.000846,0.000794,0.000763,0.000690,0.000686,0.000654,0.000659,0.000732,0.000714,0.000736,0.000748,0.000741,0.000620,0.000514,0.000484,0.000540,0.000707,0.000958,0.001141,0.001115,0.001012,0.000967,0.000906,0.000789,0.000653,0.000550,0.000512,0.000523,0.000521
giharmon40 ftgen 0,0,4096,10,0.369055,0.131998,0.314332,0.267587,0.083279,0.197505,0.246057,0.188865,0.247543,0.447904,0.311578,0.951654,0.440089,0.497270,0.248691,0.084689,0.024288,0.043815,0.092522,0.149863,0.063883,0.137365,0.089276,0.106339,0.067676,0.038080,0.044355,0.030311,0.016710,0.009404,0.009432,0.010647,0.009912,0.005595,0.004133,0.004025,0.003963,0.005248,0.007884,0.011332,0.009707,0.007295,0.004440,0.003429,0.004551,0.003060,0.002116,0.001763,0.001514,0.002027,0.002310,0.003069,0.002321,0.001811,0.001688,0.002021,0.001926,0.001770,0.001680,0.001534,0.001470,0.001491,0.001508,0.001391,0.001324,0.001260,0.001327,0.001406,0.001495,0.001338,0.001292,0.001395,0.001369,0.001408,0.001332,0.001258,0.001360,0.001502,0.001505,0.001392,0.001389,0.001469,0.001354,0.001230,0.001168,0.001229,0.001270,0.001296,0.001299,0.001384,0.001495,0.001524,0.001735,0.002015,0.002003,0.001730,0.001490,0.001313,0.001201,0.001201
giharmon41 ftgen 0,0,4096,10,0.338560,0.097872,0.404630,0.072213,0.101149,0.122271,0.088489,0.206809,0.295859,0.455726,0.802773,0.963091,0.671085,0.510166,0.125095,0.028121,0.044968,0.022808,0.033809,0.020551,0.006760,0.009093,0.007270,0.015331,0.017393,0.011093,0.005257,0.003771,0.002662,0.001862,0.002670,0.003093,0.003083,0.002636,0.001647,0.002030,0.003615,0.005828,0.005317,0.003389,0.002213,0.002189,0.002077,0.001392,0.000953,0.000899,0.000930,0.001189,0.001829,0.001616,0.001463,0.001355,0.001413,0.001368,0.001472,0.001201,0.000951,0.000804,0.000750,0.000839,0.001162,0.001540,0.001515,0.001241,0.001296,0.001396,0.001129,0.000785,0.000579,0.000562,0.000702,0.000938,0.001154,0.001155,0.001088,0.001192,0.001489,0.001693,0.001713,0.001549,0.001472,0.001606,0.001560,0.001278,0.001057,0.001106,0.001217,0.001127,0.001002,0.000959,0.000869,0.000789,0.000751,0.000712,0.000744,0.000874,0.001032,0.001112,0.001055,0.001033
giharmon43 ftgen 0,0,4096,10,0.135645,0.120943,0.979143,0.023489,0.114683,0.114072,0.130730,0.180948,0.281652,0.683720,0.964428,0.306787,0.213682,0.058648,0.025209,0.025596,0.047105,0.038846,0.017756,0.006258,0.005601,0.010206,0.010689,0.004381,0.002744,0.002982,0.002040,0.002284,0.001570,0.001528,0.002115,0.001649,0.002514,0.003304,0.005338,0.002902,0.001301,0.000713,0.000665,0.000652,0.000695,0.000698,0.000700,0.001056,0.000728,0.000485,0.000534,0.000633,0.000450,0.000429,0.000625,0.000827,0.001012,0.001160,0.001256,0.001213,0.001133,0.001362,0.001533,0.001305,0.001367,0.001616,0.001627,0.001417,0.001458,0.001637,0.001588,0.001552,0.001476,0.001327,0.001247,0.001076,0.000857,0.000699,0.000670,0.000726,0.000750,0.000854,0.000976,0.000936,0.000830,0.000768,0.000683,0.000599,0.000530,0.000491,0.000451,0.000398,0.000378,0.000368,0.000380,0.000455,0.000533,0.000535,0.000501,0.000464,0.000470,0.000496,0.000480,0.000442
giharmon45 ftgen 0,0,4096,10,0.244591,0.267325,0.126930,0.136762,0.271635,0.312002,0.223921,0.477139,0.969260,0.621811,0.276235,0.133028,0.017955,0.053396,0.048589,0.033493,0.018488,0.024467,0.024072,0.021974,0.013672,0.005364,0.005982,0.003607,0.001893,0.001866,0.001242,0.001433,0.001334,0.002488,0.002930,0.001518,0.001627,0.002275,0.001495,0.001193,0.000972,0.000737,0.000811,0.001235,0.001057,0.000838,0.001036,0.001047,0.001114,0.001012,0.000995,0.001090,0.001298,0.001286,0.001257,0.001216,0.001222,0.001045,0.001114,0.001441,0.001842,0.001582,0.001233,0.001180,0.001395,0.001374,0.001319,0.001317,0.001143,0.001024,0.001053,0.001334,0.001740,0.001862,0.001603,0.001274,0.001051,0.001022,0.000939,0.000839,0.000784,0.000794,0.000787,0.000752,0.000772,0.000742,0.000760,0.000882,0.001044,0.001103,0.001124,0.001129,0.001259,0.001523,0.001689,0.001631,0.001499,0.001332,0.001219,0.001138,0.001037,0.000952,0.000828,0.000746
giharmon46 ftgen 0,0,4096,10,0.315815,0.844525,0.164412,0.451756,0.585703,0.518759,0.681565,0.411064,0.952335,0.494514,0.366224,0.049949,0.050057,0.056689,0.053659,0.035965,0.043860,0.032015,0.019827,0.005201,0.006601,0.005746,0.007203,0.005429,0.003518,0.004758,0.003756,0.007828,0.015721,0.006418,0.003773,0.007304,0.003491,0.004073,0.002821,0.001771,0.002371,0.001798,0.002341,0.002659,0.003029,0.001998,0.001673,0.001293,0.000985,0.001051,0.001602,0.002316,0.002076,0.001608,0.001182,0.001234,0.001509,0.002038,0.001745,0.001690,0.001788,0.002285,0.002474,0.002206,0.002242,0.002438,0.002520,0.003014,0.003823,0.004834,0.005921,0.005640,0.004222,0.003103,0.002822,0.003289,0.003754,0.003426,0.002719,0.002201,0.001856,0.001927,0.002461,0.002893,0.002831,0.002430,0.002388,0.002815,0.003393,0.003964,0.004124,0.003523,0.002801,0.002546,0.002599,0.002485,0.002105,0.001812,0.001794,0.001803,0.001606,0.001468,0.001509,0.001549
giharmon48 ftgen 0,0,4096,10,0.122676,0.220788,0.073432,0.127649,0.149907,0.310663,0.320023,0.888642,0.333339,0.133323,0.020148,0.021610,0.031312,0.019058,0.010338,0.008856,0.009259,0.004665,0.008040,0.006064,0.004765,0.002412,0.001080,0.002281,0.002107,0.003516,0.001246,0.000827,0.000714,0.001050,0.000701,0.000675,0.000523,0.000934,0.001128,0.001435,0.000766,0.000427,0.000568,0.000725,0.001140,0.001379,0.000939,0.000679,0.000677,0.000639,0.000687,0.000664,0.000490,0.000511,0.000557,0.000610,0.000728,0.001052,0.001004,0.000764,0.000789,0.000916,0.000909,0.001108,0.000978,0.000656,0.000487,0.000484,0.000484,0.000521,0.000592,0.000647,0.000545,0.000494,0.000588,0.000761,0.000868,0.000902,0.000912,0.000928,0.000781,0.000667,0.000669,0.000665,0.000649,0.000608,0.000541,0.000459,0.000419,0.000435,0.000481,0.000492,0.000493,0.000550,0.000622,0.000616,0.000575,0.000571,0.000566,0.000520,0.000445,0.000380,0.000345,0.000334
giharmon50 ftgen 0,0,4096,10,0.162293,0.952587,0.107970,0.148379,0.162877,0.302263,0.378248,0.526544,0.202053,0.019075,0.035439,0.025852,0.023804,0.025676,0.028522,0.013081,0.004084,0.002802,0.001949,0.002297,0.001565,0.001596,0.004229,0.004413,0.001504,0.001251,0.001021,0.001404,0.001139,0.001161,0.000682,0.000466,0.000926,0.000495,0.000656,0.000798,0.001105,0.000691,0.000515,0.000562,0.000460,0.000566,0.000474,0.000481,0.000452,0.000510,0.000694,0.000487,0.000439,0.000584,0.000605,0.000623,0.000670,0.000916,0.000792,0.000871,0.000636,0.000514,0.000540,0.000466,0.000488,0.000461,0.000448,0.000510,0.000642,0.000795,0.000743,0.000838,0.001039,0.001142,0.000966,0.000733,0.000659,0.000657,0.000595,0.000548,0.000480,0.000411,0.000427,0.000488,0.000580,0.000723,0.000773,0.000693,0.000563,0.000471,0.000412,0.000429,0.000481,0.000468,0.000408,0.000367,0.000352,0.000329,0.000288,0.000260,0.000253,0.000249,0.000251,0.000257
giharmon52 ftgen 0,0,4096,10,0.167672,0.198778,0.227405,0.284738,0.650198,0.940684,0.975647,0.268741,0.049829,0.071939,0.024052,0.019628,0.020109,0.016231,0.003867,0.003960,0.004551,0.001438,0.002545,0.005214,0.004055,0.001727,0.002282,0.002593,0.001856,0.002206,0.001924,0.000871,0.000924,0.001558,0.001059,0.001121,0.001112,0.001260,0.001747,0.001193,0.000757,0.001035,0.000862,0.000951,0.001089,0.001598,0.001563,0.001170,0.001427,0.001409,0.001130,0.001424,0.001095,0.000785,0.000800,0.001135,0.001025,0.001093,0.000966,0.001083,0.001357,0.001272,0.001103,0.001508,0.002036,0.001512,0.001143,0.001348,0.001716,0.001528,0.001151,0.000935,0.001007,0.001124,0.000930,0.000715,0.000611,0.000658,0.000759,0.000788,0.000734,0.000745,0.000773,0.000916,0.001069,0.001056,0.000942,0.000778,0.000676,0.000670,0.000675,0.000675,0.000644,0.000597,0.000550,0.000537,0.000555,0.000559,0.000525,0.000454,0.000404,0.000407,0.000442,0.000480
giharmon53 ftgen 0,0,4096,10,0.026511,0.043338,0.103983,0.172681,0.197084,0.979650,0.257547,0.017830,0.077807,0.064492,0.041376,0.053973,0.027216,0.006355,0.007006,0.001571,0.001221,0.001837,0.007442,0.004872,0.002662,0.002280,0.002188,0.001493,0.002889,0.002534,0.002305,0.002344,0.001085,0.001468,0.002010,0.002087,0.000876,0.000665,0.000602,0.000985,0.000607,0.000521,0.000609,0.000586,0.000566,0.000481,0.000501,0.000665,0.000626,0.000653,0.000579,0.000643,0.000690,0.000651,0.000432,0.000403,0.000504,0.000532,0.000598,0.000456,0.000369,0.000393,0.000370,0.000313,0.000265,0.000292,0.000299,0.000335,0.000381,0.000415,0.000449,0.000480,0.000399,0.000307,0.000245,0.000249,0.000338,0.000468,0.000545,0.000532,0.000495,0.000471,0.000476,0.000450,0.000388,0.000331,0.000297,0.000269,0.000233,0.000202,0.000188,0.000169,0.000158,0.000175,0.000208,0.000254,0.000316,0.000380,0.000433,0.000473,0.000499,0.000504,0.000472,0.000425
giharmon55 ftgen 0,0,4096,10,0.081729,0.021968,0.138971,0.239901,0.947997,0.478402,0.152261,0.093610,0.063734,0.039617,0.032944,0.006609,0.015447,0.010428,0.006706,0.002730,0.013404,0.010554,0.003963,0.002958,0.000885,0.000799,0.001120,0.001680,0.001729,0.001274,0.001362,0.000943,0.002299,0.001254,0.001112,0.000960,0.001034,0.000866,0.000912,0.000751,0.001101,0.000945,0.000888,0.000760,0.000758,0.000764,0.000797,0.000790,0.000657,0.000779,0.000816,0.000819,0.000797,0.000793,0.000830,0.000803,0.000678,0.000695,0.000912,0.000796,0.000686,0.000833,0.000798,0.000772,0.000941,0.000835,0.000815,0.000695,0.000533,0.000448,0.000405,0.000411,0.000492,0.000554,0.000576,0.000587,0.000573,0.000542,0.000560,0.000560,0.000557,0.000544,0.000547,0.000555,0.000551,0.000537,0.000544,0.000557,0.000533,0.000512,0.000499,0.000514,0.000548,0.000548,0.000539,0.000526,0.000511,0.000513,0.000513,0.000510,0.000506,0.000503,0.000507,0.000508
giharmon57 ftgen 0,0,4096,10,0.150966,0.141943,0.169272,0.391010,0.953809,0.119929,0.039950,0.075251,0.042294,0.016963,0.005858,0.005238,0.002857,0.003841,0.008582,0.001485,0.001148,0.002596,0.001639,0.001556,0.002197,0.001142,0.001112,0.001195,0.001136,0.001245,0.000909,0.001301,0.000937,0.000941,0.001212,0.001227,0.000900,0.000862,0.000883,0.000728,0.001073,0.001100,0.000883,0.001160,0.000948,0.000936,0.001199,0.000883,0.000791,0.000945,0.000697,0.000592,0.000626,0.000588,0.000617,0.000696,0.000684,0.000803,0.000743,0.000641,0.000514,0.000453,0.000480,0.000536,0.000586,0.000581,0.000619,0.000622,0.000602,0.000589,0.000589,0.000600,0.000582,0.000552,0.000553,0.000557,0.000549,0.000526,0.000512,0.000519,0.000533,0.000535,0.000547,0.000544,0.000539,0.000534,0.000524,0.000512,0.000502,0.000502,0.000502,0.000497,0.000480,0.000468,0.000466,0.000464,0.000461,0.000459,0.000463,0.000470,0.000477,0.000482,0.000483,0.000488
giharmon60 ftgen 0,0,4096,10,0.306985,0.126374,0.301596,0.969500,0.074344,0.009729,0.006039,0.004002,0.001666,0.001675,0.002331,0.000674,0.000730,0.000729,0.000758,0.000585,0.000577,0.000687,0.000657,0.001017,0.000768,0.000581,0.000549,0.000326,0.000290,0.000463,0.000666,0.000567,0.000312,0.000634,0.000665,0.000397,0.000264,0.000232,0.000286,0.000583,0.000629,0.000663,0.000354,0.000268,0.000259,0.000263,0.000303,0.000274,0.000231,0.000322,0.000471,0.000473,0.000488,0.000569,0.000596,0.000564,0.000445,0.000430,0.000473,0.000519,0.000490,0.000446,0.000488,0.000475,0.000372,0.000301,0.000312,0.000304,0.000374,0.000526,0.000614,0.000564,0.000443,0.000349,0.000321,0.000320,0.000292,0.000243,0.000210,0.000227,0.000301,0.000393,0.000452,0.000473,0.000454,0.000415,0.000375,0.000353,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giharmon62 ftgen 0,0,4096,10,0.969106,0.095726,0.196065,0.188016,0.005133,0.010386,0.004868,0.005030,0.003515,0.002819,0.002632,0.002361,0.001260,0.000235,0.000966,0.001186,0.001018,0.000871,0.001416,0.000300,0.000430,0.000824,0.000912,0.000810,0.000516,0.000452,0.000279,0.000463,0.000690,0.000443,0.000429,0.000374,0.000579,0.000876,0.000457,0.000456,0.000449,0.000577,0.000797,0.000538,0.000571,0.000564,0.000466,0.000418,0.000306,0.000321,0.000334,0.000294,0.000244,0.000204,0.000231,0.000265,0.000340,0.000422,0.000467,0.000400,0.000291,0.000221,0.000207,0.000236,0.000249,0.000246,0.000207,0.000188,0.000203,0.000210,0.000206,0.000193,0.000167,0.000155,0.000192,0.000247,0.000284,0.000296,0.000308,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giharmon64 ftgen 0,0,4096,10,0.361663,0.582855,0.979701,0.215161,0.118878,0.052107,0.013704,0.009061,0.004379,0.007958,0.002817,0.003129,0.003908,0.003040,0.002896,0.002083,0.002113,0.004424,0.003621,0.002331,0.002616,0.002100,0.002293,0.001878,0.002282,0.002077,0.002490,0.002088,0.001811,0.001576,0.001425,0.001407,0.001400,0.001482,0.001847,0.001816,0.001426,0.001730,0.001541,0.001272,0.001398,0.001231,0.001332,0.001350,0.001199,0.001258,0.001149,0.001243,0.001247,0.001156,0.001074,0.001049,0.001142,0.001143,0.001058,0.000978,0.000854,0.000777,0.000688,0.000751,0.000914,0.001100,0.001101,0.001029,0.001044,0.001018,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giharmon65 ftgen 0,0,4096,10,0.314097,0.342771,0.973682,0.028876,0.015118,0.012713,0.002418,0.005174,0.003787,0.002218,0.002249,0.001625,0.002664,0.001830,0.002581,0.001180,0.001626,0.001619,0.001315,0.001513,0.001344,0.001175,0.000964,0.001112,0.001416,0.001129,0.001190,0.001045,0.001248,0.001029,0.000799,0.000750,0.000815,0.000965,0.000955,0.000725,0.000652,0.000709,0.000801,0.000717,0.000786,0.000648,0.000597,0.000630,0.000744,0.000667,0.000613,0.000496,0.000535,0.000596,0.000603,0.000583,0.000599,0.000593,0.000594,0.000603,0.000579,0.000588,0.000623,0.000624,0.000595,0.000573,0.000574,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
giwavemapharmon ftgen 0,0,128,-27, 0,0, 33,0, 34,1, 36,2, 38,3, 39,3, 40,4, 41,5, 43,6, 45,7, 46,8, 48,9, 50,10, 52,11, 53,12, 55,13, 57,14, 60,15, 62,16, 64,17, 65,18, 127,18
gitabs4morfharmon ftgen 0,0,32,-2, giharmon33,giharmon34,giharmon36,giharmon38,giharmon39,giharmon40,giharmon41,giharmon43,giharmon45,giharmon46,giharmon48,giharmon50,giharmon52,giharmon53,giharmon55,giharmon57,giharmon60,giharmon62,giharmon64,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65,giharmon65





;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASS TROMBONE (STRAIGHT MUTE)
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giMute122 ftgen 0,0,4096,10,0.164339,0.102551,0.069563,0.138697,0.223728,0.265220,0.280256,0.332069,0.420578,0.494911,0.577300,0.438019,0.538305,0.547959,0.857117,0.773953,0.517366,0.523329,0.250443,0.159600,0.171983,0.125233,0.061672,0.045591,0.028822,0.029244,0.026342,0.016326,0.018016,0.016474,0.009454,0.006045,0.003657,0.004270,0.008585,0.014528,0.017452,0.019652,0.016908,0.013257,0.016063,0.015947,0.010616,0.009647,0.007357,0.006942,0.005472,0.008460,0.014247,0.013954,0.009828,0.009192,0.009759,0.008585,0.009964,0.012870,0.010975,0.007757,0.007624,0.008209,0.008005,0.007979,0.007726,0.007655,0.007795,0.007616,0.006725,0.005945,0.005229,0.004482,0.003678,0.003014,0.002618,0.002393,0.002731,0.003322,0.003436,0.002905,0.002194,0.001589,0.001214,0.001156,0.001328,0.001483,0.001561,0.001609,0.001696,0.001872,0.001908,0.002069,0.002367,0.002374,0.002130,0.001840,0.001674,0.001720,0.001812,0.001802,0.001732,0.001622
giMute123 ftgen 0,0,4096,10,0.168432,0.062246,0.078354,0.110195,0.129041,0.377921,0.282536,0.228004,0.524063,0.552904,0.492429,0.533439,0.241793,0.431759,0.960231,0.527526,0.457018,0.447269,0.173908,0.188096,0.117536,0.088623,0.038960,0.034631,0.040187,0.030976,0.019737,0.017966,0.018488,0.010201,0.006147,0.003826,0.005925,0.007905,0.007681,0.008607,0.015400,0.021169,0.020768,0.019478,0.013836,0.014839,0.014657,0.013690,0.013236,0.016605,0.019334,0.015552,0.016319,0.019658,0.016907,0.011550,0.009411,0.009522,0.010270,0.008678,0.008528,0.008212,0.007305,0.006920,0.008975,0.009992,0.007897,0.006576,0.006398,0.005486,0.004674,0.004082,0.003255,0.002525,0.001877,0.001735,0.002072,0.002316,0.002265,0.001877,0.001508,0.001299,0.001160,0.001268,0.001500,0.001614,0.001649,0.001544,0.001559,0.001869,0.002444,0.002837,0.002564,0.002224,0.002193,0.002264,0.002103,0.001864,0.001829,0.001964,0.001969,0.001708,0.001368,0.001146
giMute124 ftgen 0,0,4096,10,0.142996,0.083116,0.064144,0.232641,0.363109,0.345440,0.348866,0.301465,0.496059,0.590541,0.450344,0.611392,0.691633,0.939595,0.719155,0.655138,0.609154,0.236629,0.218778,0.154757,0.077033,0.074852,0.040400,0.038516,0.034596,0.023126,0.013779,0.015070,0.008541,0.005439,0.004834,0.008763,0.016084,0.025053,0.033607,0.047747,0.045648,0.045497,0.025409,0.021094,0.022069,0.038009,0.041759,0.063224,0.070253,0.055822,0.048910,0.048219,0.052210,0.039531,0.037339,0.030915,0.028370,0.038122,0.044865,0.047418,0.042297,0.039872,0.040218,0.036388,0.033231,0.028010,0.022884,0.020191,0.018026,0.013653,0.011148,0.010124,0.011725,0.014502,0.015977,0.012802,0.008969,0.006321,0.005229,0.005789,0.006897,0.007670,0.008699,0.009835,0.010769,0.010605,0.010601,0.010721,0.010749,0.010852,0.010291,0.009559,0.008597,0.007779,0.007284,0.006683,0.005906,0.005353,0.005322,0.005542,0.005543,0.005124,0.004449,0.003603
giMute125 ftgen 0,0,4096,10,0.044114,0.061305,0.127226,0.214587,0.248138,0.322022,0.289079,0.300066,0.219345,0.389034,0.679974,0.361926,0.905776,0.756147,0.724622,0.413971,0.233101,0.180408,0.145204,0.056539,0.046805,0.060866,0.050067,0.038355,0.032608,0.021983,0.011622,0.006955,0.011848,0.020388,0.023077,0.028897,0.039329,0.040006,0.051071,0.030060,0.035671,0.024931,0.038339,0.037708,0.058492,0.053593,0.037184,0.045630,0.043341,0.034029,0.031437,0.034031,0.025773,0.028039,0.030454,0.031458,0.031318,0.029135,0.028627,0.025452,0.021115,0.018088,0.014741,0.013689,0.012102,0.010087,0.009117,0.010501,0.012107,0.011147,0.008670,0.006054,0.004653,0.004909,0.005979,0.007571,0.008945,0.009279,0.009403,0.009990,0.010831,0.011229,0.011576,0.012198,0.011522,0.009582,0.007918,0.007133,0.006815,0.006874,0.006545,0.005823,0.005215,0.004793,0.004226,0.003549,0.002763,0.002034,0.001527,0.001275,0.001284,0.001501,0.001663,0.001513
giMute126 ftgen 0,0,4096,10,0.060196,0.079208,0.165018,0.403007,0.474143,0.259060,0.390988,0.369395,0.520597,0.147418,0.294315,0.719113,0.948583,0.911775,0.688364,0.284237,0.196457,0.197963,0.098875,0.075773,0.045829,0.020036,0.034330,0.015751,0.015028,0.009926,0.008781,0.011622,0.026268,0.030349,0.027636,0.033521,0.031042,0.039392,0.034047,0.037282,0.023269,0.035915,0.033496,0.040946,0.033303,0.030305,0.029753,0.029612,0.029870,0.024821,0.021197,0.017836,0.015201,0.014801,0.017255,0.016419,0.014400,0.014847,0.014196,0.013845,0.010243,0.007414,0.006884,0.005313,0.005125,0.006712,0.007001,0.005537,0.003835,0.002755,0.002847,0.003574,0.003940,0.004035,0.004370,0.004927,0.004830,0.004569,0.004559,0.004585,0.004513,0.003828,0.003072,0.002596,0.002377,0.002294,0.002087,0.001940,0.001859,0.001843,0.002114,0.002255,0.001844,0.001305,0.000970,0.000768,0.000670,0.000707,0.000807,0.000885,0.000924,0.000852,0.000694,0.000544
giMute127 ftgen 0,0,4096,10,0.052401,0.049320,0.080590,0.183766,0.164401,0.307439,0.388671,0.284459,0.318081,0.164443,0.441431,0.928201,0.876487,0.740904,0.324363,0.142732,0.081529,0.077495,0.028649,0.043648,0.038991,0.025075,0.013227,0.010195,0.011781,0.010501,0.016602,0.024255,0.023187,0.036495,0.057654,0.054268,0.048563,0.024903,0.054174,0.048040,0.071704,0.054365,0.049624,0.064806,0.092036,0.062098,0.048326,0.054051,0.039134,0.032416,0.036465,0.055694,0.042371,0.035750,0.021224,0.022257,0.011427,0.014694,0.009479,0.004552,0.013174,0.019261,0.013315,0.005818,0.001677,0.002772,0.003021,0.006297,0.007154,0.008171,0.010310,0.008506,0.007517,0.010904,0.006062,0.012403,0.007495,0.006084,0.005664,0.006058,0.004342,0.006256,0.008205,0.007899,0.006624,0.007878,0.003449,0.001680,0.000514,0.001804,0.002081,0.003443,0.004990,0.003472,0.003035,0.002319,0.001815,0.000843,0.001081,0.003090,0.002248,0.001877,0.002589,0.003743
giMute128 ftgen 0,0,4096,10,0.027923,0.100208,0.119497,0.305740,0.241671,0.283542,0.288061,0.232034,0.826888,0.407135,0.944943,0.754001,0.650071,0.360755,0.163788,0.199546,0.064667,0.047976,0.067193,0.033442,0.022636,0.018891,0.006473,0.006036,0.009904,0.016425,0.024814,0.044941,0.038557,0.069982,0.053960,0.007689,0.060655,0.019491,0.072831,0.052666,0.042308,0.055883,0.044001,0.027661,0.043229,0.023057,0.025173,0.028614,0.031240,0.027168,0.026598,0.023386,0.018674,0.009964,0.010171,0.008959,0.004421,0.009443,0.011811,0.008975,0.005444,0.002992,0.002577,0.004840,0.005217,0.007905,0.008254,0.008604,0.004473,0.009592,0.008601,0.005583,0.008098,0.005796,0.002345,0.007586,0.005015,0.004900,0.007488,0.005743,0.006825,0.002224,0.002742,0.001117,0.001857,0.001298,0.003169,0.002324,0.002382,0.001822,0.001779,0.001092,0.000752,0.001206,0.002075,0.000843,0.001972,0.001844,0.002893,0.002804,0.002542,0.001110,0.001376,0.000804
giMute129 ftgen 0,0,4096,10,0.014669,0.032320,0.102462,0.174664,0.169222,0.111331,0.339606,0.209754,0.217866,0.343088,0.891951,0.530957,0.472318,0.164643,0.165367,0.091601,0.090801,0.015419,0.039607,0.019025,0.012281,0.004714,0.002434,0.014861,0.038522,0.020090,0.049806,0.050949,0.061040,0.054492,0.035308,0.046103,0.018911,0.085037,0.066539,0.090037,0.115123,0.114020,0.059158,0.070988,0.070450,0.068910,0.054753,0.043435,0.030742,0.021866,0.024247,0.013293,0.017833,0.010515,0.011265,0.016382,0.023641,0.010420,0.007923,0.005015,0.009328,0.008929,0.010346,0.011125,0.009063,0.009311,0.010454,0.010758,0.009200,0.014939,0.006906,0.005195,0.007827,0.007531,0.008761,0.010132,0.008289,0.010958,0.004572,0.001934,0.001818,0.002642,0.002171,0.002199,0.002528,0.001704,0.001645,0.001110,0.000567,0.001256,0.000671,0.001415,0.003604,0.003233,0.002086,0.001933,0.001526,0.000662,0.001458,0.000497,0.000845,0.000680,0.001138,0.001279
giMute130 ftgen 0,0,4096,10,0.064908,0.079846,0.127850,0.445046,0.330968,0.420691,0.480533,0.374119,0.245280,0.729167,0.936260,0.749421,0.381456,0.247718,0.207617,0.116908,0.051373,0.019507,0.008564,0.025213,0.010576,0.007009,0.011265,0.017944,0.027208,0.040488,0.021178,0.046272,0.038151,0.021208,0.044463,0.023287,0.045981,0.030790,0.020921,0.015858,0.026172,0.019160,0.017080,0.011607,0.015955,0.006307,0.009311,0.006865,0.003784,0.003961,0.002271,0.002504,0.000904,0.002864,0.002378,0.001916,0.001531,0.000626,0.001045,0.001491,0.001672,0.000890,0.001666,0.001476,0.001501,0.000957,0.003007,0.001529,0.001037,0.001154,0.001031,0.000515,0.000881,0.000327,0.000467,0.000436,0.000280,0.000329,0.000454,0.000243,0.000168,0.000282,0.000948,0.000411,0.000184,0.000452,0.000360,0.000354,0.000193,0.000243,0.000591,0.000203,0.000418,0.000245,0.000193,0.000287,0.000162,0.000386,0.000147,0.000097,0.000291,0.000161,0.000222,0.000228
giMute131 ftgen 0,0,4096,10,0.068230,0.065611,0.217451,0.232412,0.188182,0.427625,0.292296,0.554990,0.340081,0.915514,0.522787,0.307999,0.162151,0.094669,0.056724,0.027329,0.011538,0.010489,0.008261,0.001997,0.007832,0.008040,0.029670,0.021346,0.029403,0.071206,0.042160,0.041297,0.059757,0.018923,0.105664,0.038842,0.027166,0.042666,0.031872,0.028802,0.030657,0.019773,0.024186,0.023554,0.016848,0.015145,0.013926,0.008132,0.010479,0.005103,0.002808,0.010621,0.007445,0.004301,0.001100,0.003068,0.003063,0.004833,0.003047,0.003019,0.003716,0.005204,0.002390,0.002979,0.001408,0.001568,0.001539,0.001833,0.002366,0.001838,0.000682,0.001960,0.000613,0.000686,0.000652,0.000399,0.000606,0.000602,0.000521,0.000455,0.000432,0.000091,0.000136,0.000332,0.000272,0.000302,0.000126,0.000375,0.000314,0.000203,0.000126,0.000237,0.000293,0.000291,0.000185,0.000182,0.000275,0.000263,0.000195,0.000151,0.000202,0.000294,0.000205,0.000198
giMute132 ftgen 0,0,4096,10,0.072458,0.092631,0.167684,0.302817,0.140977,0.255042,0.110714,0.344468,0.928686,0.667412,0.338258,0.200769,0.147649,0.065744,0.004582,0.023573,0.011837,0.008391,0.007660,0.014753,0.031615,0.027782,0.039431,0.047372,0.049448,0.013895,0.042049,0.032148,0.026316,0.026284,0.049745,0.043954,0.026083,0.037453,0.029582,0.022591,0.018017,0.013163,0.009816,0.004994,0.005845,0.002926,0.004507,0.007678,0.002757,0.002125,0.001498,0.002105,0.002073,0.003179,0.003552,0.003030,0.003107,0.003121,0.004471,0.001227,0.002877,0.002488,0.002740,0.003051,0.002796,0.002240,0.000296,0.000464,0.000414,0.001290,0.000687,0.001086,0.000537,0.000387,0.000130,0.000370,0.000092,0.000561,0.000559,0.000109,0.000094,0.000089,0.000290,0.000073,0.000183,0.000250,0.000318,0.000509,0.000515,0.000390,0.000503,0.000327,0.000338,0.000232,0.000327,0.000154,0.000173,0.000108,0.000092,0.000271,0.000089,0.000076,0.000105,0.000132
giMute133 ftgen 0,0,4096,10,0.171302,0.215302,0.554037,0.602813,0.500383,0.551353,0.792246,0.972277,0.915826,0.832314,0.393008,0.188469,0.087171,0.051938,0.057335,0.030089,0.018181,0.012795,0.030872,0.033984,0.097553,0.117375,0.088919,0.019750,0.074370,0.074970,0.077987,0.098699,0.118454,0.054334,0.051802,0.037932,0.045722,0.044228,0.016572,0.018704,0.013524,0.013398,0.003788,0.004323,0.010291,0.003069,0.001274,0.001330,0.002466,0.002824,0.003268,0.005612,0.003975,0.000819,0.002777,0.002460,0.002046,0.001584,0.002892,0.002346,0.003012,0.001881,0.000649,0.000801,0.000646,0.001523,0.001240,0.001310,0.000390,0.000248,0.000279,0.000518,0.000341,0.000512,0.000393,0.000190,0.000358,0.000126,0.000196,0.000125,0.000251,0.000327,0.000531,0.000833,0.000907,0.000336,0.000482,0.000237,0.000687,0.000266,0.000316,0.000368,0.000104,0.000129,0.000172,0.000171,0.000167,0.000055,0.000143,0.000116,0.000132,0.000198,0.000238,0.000318
giMute134 ftgen 0,0,4096,10,0.097133,0.173820,0.374605,0.474497,0.645937,0.376089,0.435327,0.976798,0.725285,0.297676,0.120366,0.069249,0.033502,0.014976,0.014214,0.011249,0.006081,0.003570,0.011892,0.014690,0.022764,0.024186,0.025001,0.044955,0.049727,0.048851,0.047898,0.053897,0.023052,0.038993,0.025427,0.027582,0.022350,0.021270,0.010750,0.009160,0.013099,0.002909,0.008796,0.006376,0.001857,0.001716,0.003061,0.001735,0.002918,0.004325,0.002877,0.003817,0.005184,0.003931,0.001995,0.004293,0.003739,0.003678,0.003158,0.002071,0.001133,0.000232,0.000323,0.001563,0.001268,0.000658,0.000426,0.000063,0.000421,0.000195,0.000767,0.000535,0.000446,0.000289,0.000184,0.000296,0.000288,0.000200,0.000535,0.000186,0.000733,0.000229,0.000412,0.000107,0.000166,0.000355,0.000312,0.000317,0.000354,0.000185,0.000132,0.000137,0.000206,0.000233,0.000262,0.000150,0.000123,0.000145,0.000145,0.000117,0.000140,0.000106,0.000135,0.000169
giMute135 ftgen 0,0,4096,10,0.179021,0.401691,0.729330,0.982922,0.746447,0.524380,0.900583,0.585038,0.953435,0.443166,0.289448,0.098763,0.031244,0.011392,0.020066,0.020371,0.036289,0.021837,0.044660,0.116353,0.070855,0.059093,0.066299,0.083923,0.069741,0.061417,0.033091,0.045547,0.029414,0.028975,0.021471,0.021629,0.010855,0.013960,0.004240,0.008225,0.009562,0.004312,0.001601,0.002687,0.001271,0.003054,0.004689,0.003158,0.006429,0.004058,0.005468,0.002640,0.001551,0.003253,0.003142,0.003027,0.001217,0.000340,0.000216,0.000471,0.000540,0.000381,0.000432,0.000182,0.000650,0.000176,0.000758,0.000323,0.000522,0.000156,0.000289,0.000185,0.000281,0.000179,0.000391,0.000461,0.000214,0.000356,0.000189,0.000425,0.000214,0.000172,0.000322,0.000195,0.000387,0.000323,0.000373,0.000170,0.000176,0.000048,0.000079,0.000049,0.000161,0.000129,0.000141,0.000083,0.000119,0.000204,0.000318,0.000410,0.000202,0.000283,0.000292,0.000127
giMute136 ftgen 0,0,4096,10,0.084007,0.199308,0.212901,0.389112,0.310014,0.209644,0.951984,0.633937,0.286005,0.146120,0.053652,0.047694,0.020100,0.016786,0.003816,0.018198,0.008332,0.020077,0.037293,0.016675,0.022299,0.027356,0.023496,0.049061,0.039132,0.026396,0.012922,0.017081,0.012583,0.010068,0.005525,0.002721,0.003104,0.004799,0.003308,0.002047,0.001239,0.002036,0.002197,0.002242,0.003547,0.004859,0.003272,0.001567,0.002063,0.002229,0.001760,0.001286,0.001961,0.000541,0.000366,0.000986,0.000730,0.000861,0.000630,0.000616,0.000358,0.001058,0.000464,0.000438,0.000450,0.000487,0.000193,0.000559,0.000479,0.000260,0.000259,0.000887,0.000529,0.000258,0.000611,0.000375,0.000388,0.000092,0.000430,0.000337,0.000138,0.000312,0.000579,0.000492,0.000207,0.000330,0.000350,0.000212,0.000159,0.000387,0.000350,0.000158,0.000191,0.000374,0.000113,0.000150,0.000260,0.000156,0.000117,0.000208,0.000235,0.000105,0.000074,0.000268
giMute137 ftgen 0,0,4096,10,0.121187,0.301409,0.437255,0.488546,0.532406,0.556320,0.940536,0.612558,0.171145,0.078278,0.033359,0.039980,0.019198,0.003684,0.014541,0.021902,0.025869,0.028022,0.020078,0.018008,0.063141,0.040559,0.061443,0.025176,0.045882,0.030795,0.027823,0.023490,0.015819,0.011054,0.004279,0.008778,0.007683,0.002850,0.002807,0.001837,0.004594,0.006832,0.003882,0.006682,0.004472,0.002359,0.002653,0.002120,0.002271,0.001366,0.001048,0.000977,0.001563,0.000795,0.000741,0.000197,0.000435,0.000663,0.000303,0.000697,0.000460,0.000621,0.000388,0.000298,0.000103,0.000484,0.000378,0.000376,0.000296,0.000134,0.000043,0.000150,0.000155,0.000176,0.000187,0.000055,0.000111,0.000091,0.000143,0.000129,0.000153,0.000171,0.000204,0.000159,0.000206,0.000139,0.000065,0.000078,0.000107,0.000102,0.000128,0.000113,0.000157,0.000150,0.000078,0.000128,0.000144,0.000084,0.000114,0.000188,0.000043,0.000106,0.000116,0.000128
giMute138 ftgen 0,0,4096,10,0.137239,0.608302,0.333203,0.546467,0.231739,0.766708,0.950744,0.327806,0.160412,0.060869,0.019878,0.003953,0.008113,0.006915,0.028018,0.027245,0.043331,0.020302,0.014454,0.025972,0.026882,0.018782,0.017822,0.013846,0.010287,0.009995,0.005808,0.004941,0.003243,0.000812,0.002013,0.001670,0.000819,0.000666,0.000772,0.000298,0.000436,0.000772,0.000741,0.000154,0.001321,0.000422,0.000226,0.000631,0.000439,0.000344,0.000337,0.000336,0.000616,0.000238,0.000312,0.000215,0.000181,0.000430,0.000292,0.000227,0.000331,0.000311,0.000246,0.000311,0.000279,0.000324,0.000208,0.000103,0.000266,0.000302,0.000310,0.000240,0.000310,0.000296,0.000228,0.000305,0.000203,0.000181,0.000235,0.000154,0.000238,0.000155,0.000185,0.000226,0.000170,0.000202,0.000202,0.000228,0.000150,0.000178,0.000239,0.000187,0.000194,0.000253,0.000070,0.000165,0.000223,0.000127,0.000156,0.000160,0.000180,0.000163,0.000129,0.000224
giMute139 ftgen 0,0,4096,10,0.061443,0.238708,0.356688,0.269787,0.339649,0.912187,0.776022,0.165931,0.073909,0.021161,0.016878,0.008990,0.003708,0.022300,0.041143,0.038233,0.004859,0.023579,0.053718,0.052003,0.042268,0.022601,0.022660,0.029648,0.019517,0.017414,0.011974,0.004870,0.011305,0.003101,0.000546,0.002006,0.003619,0.004048,0.005624,0.003647,0.002198,0.002634,0.003291,0.001943,0.000613,0.000545,0.000250,0.000451,0.000789,0.000299,0.000410,0.000212,0.000138,0.000424,0.000415,0.000404,0.000244,0.000269,0.000335,0.000329,0.000230,0.000373,0.000400,0.000370,0.000260,0.000376,0.000293,0.000187,0.000119,0.000256,0.000177,0.000244,0.000278,0.000293,0.000302,0.000158,0.000215,0.000196,0.000203,0.000167,0.000136,0.000170,0.000168,0.000137,0.000166,0.000168,0.000160,0.000177,0.000247,0.000183,0.000197,0.000135,0.000162,0.000164,0.000186,0.000121,0.000206,0.000166,0.000144,0.000145,0.000141,0.000122,0.000131,0.000148
giMute140 ftgen 0,0,4096,10,0.171458,0.486737,0.414556,0.287720,0.507039,0.974434,0.387302,0.180263,0.044683,0.029233,0.014770,0.003589,0.009392,0.033786,0.054370,0.010033,0.024497,0.035533,0.046495,0.020949,0.024322,0.023346,0.018462,0.011212,0.009184,0.003515,0.005537,0.002905,0.001147,0.001777,0.002912,0.002534,0.003007,0.002041,0.002109,0.001352,0.001160,0.001111,0.000145,0.000433,0.000205,0.000056,0.000347,0.000268,0.000294,0.000170,0.000469,0.000118,0.000167,0.000252,0.000207,0.000132,0.000371,0.000145,0.000293,0.000072,0.000271,0.000135,0.000201,0.000141,0.000204,0.000171,0.000237,0.000126,0.000167,0.000093,0.000231,0.000074,0.000160,0.000043,0.000250,0.000055,0.000217,0.000066,0.000199,0.000066,0.000231,0.000104,0.000233,0.000061,0.000246,0.000078,0.000219,0.000099,0.000254,0.000073,0.000200,0.000053,0.000175,0.000057,0.000197,0.000066,0.000126,0.000068,0.000163,0.000069,0.000139,0.000114,0.000270,0.000106
giMute141 ftgen 0,0,4096,10,0.096700,0.501938,0.304973,0.388545,0.605784,0.973491,0.310298,0.166062,0.031823,0.020041,0.008197,0.018099,0.031406,0.032118,0.028621,0.035283,0.026152,0.031724,0.045821,0.032749,0.023933,0.009329,0.006590,0.003520,0.002035,0.005414,0.003178,0.001420,0.002462,0.001216,0.000800,0.002760,0.002395,0.001093,0.001088,0.001647,0.001527,0.000979,0.001163,0.001119,0.001071,0.001064,0.001131,0.001297,0.001070,0.001080,0.000990,0.000967,0.000985,0.001105,0.000916,0.000726,0.000869,0.000896,0.000931,0.000845,0.000797,0.000762,0.000805,0.000802,0.000683,0.000685,0.000708,0.000714,0.000719,0.000727,0.000634,0.000711,0.000686,0.000637,0.000694,0.000701,0.000592,0.000664,0.000534,0.000558,0.000681,0.000688,0.000614,0.000609,0.000647,0.000479,0.000513,0.000489,0.000396,0.000420,0.000504,0.000454,0.000492,0.000467,0.000503,0.000515,0.000470,0.000401,0.000502,0.000592,0.000567,0.000411,0.000453,0.000449
giMute142 ftgen 0,0,4096,10,0.079836,0.330689,0.372144,0.493873,0.925375,0.694151,0.118777,0.028983,0.015396,0.009622,0.001526,0.002627,0.008783,0.011024,0.010140,0.015272,0.009621,0.006265,0.004497,0.003760,0.002472,0.001108,0.000363,0.000521,0.000643,0.000834,0.000511,0.000843,0.000434,0.000735,0.001056,0.000991,0.001287,0.000997,0.000751,0.000669,0.000309,0.000891,0.000656,0.000613,0.000705,0.000663,0.000676,0.000561,0.000583,0.000611,0.000611,0.000702,0.000495,0.000478,0.000451,0.000393,0.000461,0.000506,0.000433,0.000473,0.000465,0.000454,0.000425,0.000361,0.000423,0.000458,0.000385,0.000422,0.000473,0.000380,0.000405,0.000421,0.000338,0.000379,0.000351,0.000358,0.000335,0.000353,0.000378,0.000372,0.000313,0.000331,0.000343,0.000315,0.000320,0.000280,0.000296,0.000226,0.000364,0.000296,0.000272,0.000282,0.000254,0.000289,0.000277,0.000204,0.000220,0.000269,0.000299,0.000321,0.000450,0.000259,0.000266,0.000435
giMute143 ftgen 0,0,4096,10,0.093603,0.658042,0.988507,0.565236,0.957972,0.360885,0.102049,0.051660,0.027922,0.005483,0.010335,0.012495,0.003673,0.003952,0.012964,0.008898,0.005397,0.006281,0.001252,0.006122,0.003828,0.000827,0.003226,0.002089,0.001925,0.000243,0.002872,0.002421,0.003325,0.002270,0.001755,0.001168,0.001149,0.000770,0.000928,0.000937,0.000720,0.000406,0.000688,0.000732,0.000790,0.000819,0.000398,0.000728,0.000703,0.001198,0.000151,0.000857,0.000600,0.000571,0.000660,0.000529,0.000450,0.000520,0.000520,0.000470,0.000463,0.000462,0.000454,0.000347,0.000590,0.000427,0.000210,0.000402,0.000401,0.000381,0.000525,0.000294,0.000410,0.000335,0.000296,0.000348,0.000580,0.000399,0.000186,0.000198,0.000288,0.000442,0.000411,0.000234,0.000356,0.000386,0.000271,0.000338,0.000271,0.000303,0.000385,0.000352,0.000226,0.000193,0.000103,0.000388,0.000349,0.000222,0.000208,0.000266,0.000232,0.000314,0.000425,0.000268
giMute144 ftgen 0,0,4096,10,0.127739,0.412859,0.669901,0.617303,0.972749,0.358440,0.065748,0.045528,0.010129,0.008737,0.005631,0.028396,0.004839,0.008872,0.006019,0.011096,0.006903,0.003885,0.004722,0.003204,0.000936,0.002573,0.001532,0.001369,0.001172,0.001160,0.002432,0.000544,0.000609,0.001867,0.000966,0.001039,0.001031,0.000884,0.000753,0.000848,0.000659,0.000749,0.000579,0.000769,0.000665,0.000754,0.000781,0.000490,0.000653,0.000626,0.000524,0.000572,0.000539,0.000566,0.000514,0.000414,0.000441,0.000453,0.000417,0.000478,0.000444,0.000495,0.000551,0.000346,0.000475,0.000442,0.000477,0.000269,0.000501,0.000483,0.000442,0.000267,0.000338,0.000368,0.000470,0.000382,0.000335,0.000358,0.000341,0.000354,0.000345,0.000310,0.000359,0.000228,0.000299,0.000348,0.000336,0.000319,0.000275,0.000294,0.000244,0.000271,0.000232,0.000358,0.000237,0.000269,0.000247,0.000360,0.000301,0.000208,0.000223,0.000248,0.000270,0.000258
giMute145 ftgen 0,0,4096,10,0.172584,0.253006,0.499844,0.963093,0.599448,0.063091,0.027923,0.009556,0.005430,0.007267,0.030576,0.010839,0.007632,0.008691,0.007373,0.004773,0.004338,0.006857,0.003189,0.000319,0.002787,0.001103,0.001002,0.001076,0.001129,0.001241,0.000702,0.000657,0.000919,0.000769,0.000959,0.000576,0.000715,0.000619,0.000732,0.000611,0.000499,0.000600,0.000491,0.000700,0.000580,0.000348,0.000432,0.000611,0.000489,0.000494,0.000446,0.000425,0.000537,0.000395,0.000420,0.000348,0.000423,0.000452,0.000417,0.000289,0.000444,0.000331,0.000335,0.000289,0.000366,0.000340,0.000289,0.000333,0.000336,0.000346,0.000297,0.000305,0.000318,0.000278,0.000199,0.000327,0.000258,0.000240,0.000298,0.000311,0.000247,0.000309,0.000274,0.000297,0.000343,0.000148,0.000267,0.000204,0.000326,0.000251,0.000194,0.000230,0.000250,0.000186,0.000238,0.000251,0.000196,0.000238,0.000292,0.000233,0.000162,0.000197,0.000198,0.000193
giMute146 ftgen 0,0,4096,10,0.169930,0.357871,0.478870,0.971148,0.103667,0.027577,0.012460,0.004728,0.004455,0.018143,0.018903,0.009745,0.013588,0.009707,0.007034,0.005601,0.003105,0.000981,0.000341,0.001493,0.000631,0.000446,0.000832,0.000522,0.000996,0.001277,0.000334,0.000333,0.000435,0.000326,0.000323,0.000353,0.000202,0.000214,0.000190,0.000284,0.000171,0.000339,0.000329,0.000183,0.000124,0.000342,0.000303,0.000128,0.000091,0.000224,0.000255,0.000167,0.000148,0.000089,0.000154,0.000248,0.000151,0.000141,0.000149,0.000108,0.000284,0.000121,0.000121,0.000193,0.000201,0.000123,0.000226,0.000223,0.000154,0.000094,0.000194,0.000058,0.000146,0.000232,0.000097,0.000224,0.000132,0.000062,0.000163,0.000214,0.000246,0.000418,0.000139,0.000221,0.000100,0.000095,0.000131,0.000152,0.000158,0.000051,0.000077,0.000080,0.000061,0.000131,0.000109,0.000055,0.000120,0.000091,0.000080,0.000081,0.000120,0.000053,0.000045,0.000123
giMute147 ftgen 0,0,4096,10,0.175950,0.306151,0.921267,0.803899,0.232506,0.029817,0.015312,0.002411,0.010177,0.008768,0.003962,0.004998,0.003485,0.001495,0.002390,0.001727,0.000838,0.000237,0.000572,0.000579,0.000740,0.001153,0.000286,0.000378,0.000226,0.000269,0.000314,0.000265,0.000200,0.000117,0.000250,0.000150,0.000183,0.000079,0.000168,0.000177,0.000049,0.000188,0.000111,0.000136,0.000108,0.000088,0.000122,0.000076,0.000110,0.000119,0.000091,0.000137,0.000123,0.000074,0.000144,0.000146,0.000077,0.000035,0.000056,0.000085,0.000020,0.000095,0.000092,0.000051,0.000122,0.000063,0.000147,0.000073,0.000076,0.000045,0.000098,0.000114,0.000063,0.000075,0.000037,0.000125,0.000019,0.000072,0.000077,0.000087,0.000132,0.000061,0.000112,0.000071,0.000050,0.000051,0.000054,0.000046,0.000107,0.000026,0.000027,0.000021,0.000035,0.000042,0.000030,0.000041,0.000038,0.000047,0.000015,0.000021,0.000032,0.000120,0.000147,0.000238
giMute148 ftgen 0,0,4096,10,0.546831,0.588315,0.974745,0.966438,0.134855,0.030603,0.009346,0.000932,0.030580,0.012583,0.020113,0.009766,0.016236,0.007109,0.004226,0.002316,0.001376,0.000358,0.001380,0.001135,0.000319,0.000940,0.000401,0.000703,0.000385,0.000515,0.000292,0.000252,0.000145,0.000137,0.000403,0.000278,0.000292,0.000275,0.000222,0.000110,0.000160,0.000085,0.000217,0.000270,0.000172,0.000158,0.000177,0.000095,0.000182,0.000067,0.000232,0.000159,0.000178,0.000150,0.000206,0.000086,0.000273,0.000112,0.000141,0.000195,0.000084,0.000079,0.000246,0.000201,0.000063,0.000129,0.000125,0.000117,0.000158,0.000162,0.000192,0.000121,0.000175,0.000267,0.000096,0.000179,0.000039,0.000074,0.000268,0.000160,0.000033,0.000069,0.000065,0.000055,0.000088,0.000054,0.000142,0.000087,0.000045,0.000095,0.000026,0.000039,0.000075,0.000073,0.000067,0.000054,0.000068,0.000091,0.000101,0.000092,0.000171,0.000084,0.000049,0.000055
giMute149 ftgen 0,0,4096,10,0.294629,0.975075,0.694387,0.796446,0.188314,0.013147,0.006022,0.018607,0.064160,0.026936,0.065686,0.065969,0.031796,0.020120,0.015238,0.003443,0.002738,0.001360,0.003362,0.001182,0.001135,0.002047,0.001013,0.000558,0.000429,0.000717,0.000504,0.000555,0.000624,0.000479,0.000343,0.000421,0.000606,0.000462,0.000385,0.000445,0.000230,0.000176,0.000301,0.000222,0.000323,0.000195,0.000306,0.000246,0.000307,0.000237,0.000215,0.000210,0.000380,0.000241,0.000377,0.000152,0.000491,0.000197,0.000367,0.000186,0.000204,0.000108,0.000304,0.000260,0.000093,0.000231,0.000163,0.000112,0.000185,0.000239,0.000226,0.000179,0.000200,0.000203,0.000175,0.000088,0.000156,0.000218,0.000201,0.000222,0.000100,0.000212,0.000151,0.000114,0.000168,0.000167,0.000170,0.000170,0.000116,0.000205,0.000116,0.000133,0.000139,0.000176,0.000154,0.000145,0.000119,0.000095,0.000085,0.000125,0.000145,0.000106,0.000145,0.000141
giMute150 ftgen 0,0,4096,10,0.594912,0.608509,0.961469,0.229985,0.033626,0.009789,0.002734,0.011904,0.013878,0.018699,0.018956,0.006098,0.006134,0.002889,0.000518,0.000310,0.000591,0.000264,0.000257,0.000698,0.000478,0.000286,0.000276,0.000212,0.000349,0.000257,0.000272,0.000224,0.000177,0.000174,0.000082,0.000176,0.000161,0.000172,0.000230,0.000066,0.000165,0.000161,0.000152,0.000109,0.000094,0.000130,0.000185,0.000186,0.000258,0.000200,0.000154,0.000204,0.000184,0.000157,0.000047,0.000131,0.000123,0.000097,0.000062,0.000144,0.000118,0.000149,0.000134,0.000157,0.000198,0.000063,0.000156,0.000144,0.000094,0.000105,0.000096,0.000093,0.000113,0.000081,0.000076,0.000079,0.000049,0.000061,0.000040,0.000104,0.000079,0.000022,0.000068,0.000078,0.000072,0.000063,0.000085,0.000086,0.000053,0.000080,0.000082,0.000054,0.000046,0.000081,0.000075,0.000056,0.000061,0.000025,0.000072,0.000042,0.000050,0.000054,0.000053,0.000068
giMute151 ftgen 0,0,4096,10,0.206347,0.510370,0.950258,0.127507,0.010206,0.002549,0.001810,0.012483,0.004635,0.004683,0.005187,0.003165,0.001760,0.000999,0.000554,0.000268,0.000624,0.000195,0.000027,0.000147,0.000141,0.000163,0.000117,0.000060,0.000105,0.000099,0.000067,0.000093,0.000160,0.000103,0.000140,0.000060,0.000090,0.000115,0.000051,0.000073,0.000045,0.000055,0.000143,0.000072,0.000114,0.000130,0.000048,0.000106,0.000081,0.000052,0.000096,0.000074,0.000050,0.000088,0.000108,0.000167,0.000065,0.000093,0.000168,0.000053,0.000085,0.000083,0.000061,0.000128,0.000058,0.000064,0.000040,0.000027,0.000100,0.000081,0.000054,0.000030,0.000036,0.000081,0.000048,0.000047,0.000067,0.000034,0.000037,0.000030,0.000021,0.000028,0.000043,0.000106,0.000063,0.000019,0.000039,0.000057,0.000021,0.000037,0.000026,0.000041,0.000039,0.000032,0.000024,0.000048,0.000021,0.000064,0.000037,0.000065,0.000049,0.000031,0.000048,0.000014
giMute152 ftgen 0,0,4096,10,0.718310,0.828992,0.971094,0.089148,0.007432,0.001882,0.006326,0.016275,0.013664,0.005083,0.004192,0.002987,0.000575,0.000244,0.000598,0.000195,0.000566,0.000394,0.000580,0.000162,0.000255,0.000166,0.000116,0.000132,0.000146,0.000108,0.000133,0.000237,0.000251,0.000229,0.000158,0.000127,0.000139,0.000150,0.000119,0.000043,0.000076,0.000198,0.000147,0.000151,0.000075,0.000073,0.000078,0.000098,0.000125,0.000095,0.000098,0.000053,0.000180,0.000068,0.000097,0.000168,0.000085,0.000055,0.000094,0.000084,0.000102,0.000047,0.000079,0.000083,0.000046,0.000050,0.000047,0.000066,0.000081,0.000049,0.000040,0.000040,0.000068,0.000075,0.000057,0.000054,0.000024,0.000106,0.000054,0.000084,0.000044,0.000058,0.000034,0.000045,0.000058,0.000029,0.000068,0.000046,0.000029,0.000029,0.000066,0.000045,0.000077,0.000038,0.000027,0.000035,0.000043,0.000036,0.000049,0.000024,0.000024,0.000045,0.000046,0.000034
giMute153 ftgen 0,0,4096,10,0.551061,0.501444,0.953401,0.068491,0.008520,0.012056,0.020903,0.021636,0.008585,0.007399,0.006298,0.001414,0.000788,0.000891,0.000358,0.000686,0.001110,0.000613,0.000691,0.000460,0.000664,0.000614,0.000565,0.000426,0.000472,0.000397,0.000391,0.000456,0.000378,0.000437,0.000434,0.000310,0.000368,0.000415,0.000400,0.000343,0.000353,0.000349,0.000357,0.000326,0.000313,0.000231,0.000257,0.000212,0.000281,0.000273,0.000286,0.000207,0.000174,0.000326,0.000097,0.000332,0.000115,0.000149,0.000211,0.000305,0.000186,0.000198,0.000220,0.000141,0.000131,0.000182,0.000188,0.000186,0.000182,0.000117,0.000163,0.000173,0.000185,0.000121,0.000186,0.000073,0.000203,0.000192,0.000150,0.000147,0.000131,0.000138,0.000145,0.000135,0.000111,0.000135,0.000109,0.000125,0.000126,0.000121,0.000105,0.000083,0.000102,0.000109,0.000069,0.000107,0.000148,0.000139,0.000126,0.000096,0.000101,0.000123,0.000104,0.000104
giMute154 ftgen 0,0,4096,10,0.965465,0.238341,0.801452,0.050222,0.006640,0.011475,0.012533,0.012724,0.004704,0.006848,0.004228,0.001130,0.001409,0.001463,0.000398,0.000800,0.000513,0.001091,0.001100,0.000393,0.000445,0.000310,0.000446,0.000589,0.000358,0.000505,0.000369,0.000525,0.000346,0.000322,0.000437,0.000435,0.000262,0.000286,0.000307,0.000308,0.000358,0.000350,0.000347,0.000237,0.000076,0.000385,0.000217,0.000215,0.000278,0.000200,0.000335,0.000203,0.000329,0.000194,0.000066,0.000171,0.000388,0.000178,0.000305,0.000205,0.000231,0.000150,0.000228,0.000249,0.000070,0.000179,0.000201,0.000134,0.000138,0.000151,0.000193,0.000156,0.000150,0.000137,0.000132,0.000132,0.000128,0.000118,0.000138,0.000126,0.000141,0.000133,0.000148,0.000184,0.000137,0.000131,0.000138,0.000107,0.000100,0.000116,0.000121,0.000092,0.000099,0.000106,0.000080,0.000101,0.000102,0.000073,0.000094,0.000104,0.000107,0.000106,0.000093,0.000085
giMute155 ftgen 0,0,4096,10,0.938142,0.970313,0.508740,0.021568,0.001864,0.002894,0.002724,0.002263,0.003861,0.001793,0.000443,0.001267,0.000409,0.000899,0.000541,0.000180,0.000417,0.000464,0.000377,0.000359,0.000247,0.000485,0.000254,0.000339,0.000219,0.000319,0.000168,0.000254,0.000251,0.000160,0.000021,0.000183,0.000145,0.000251,0.000161,0.000219,0.000034,0.000174,0.000112,0.000219,0.000100,0.000130,0.000289,0.000226,0.000368,0.000095,0.000094,0.000122,0.000072,0.000121,0.000126,0.000143,0.000135,0.000153,0.000050,0.000099,0.000080,0.000071,0.000089,0.000079,0.000117,0.000090,0.000082,0.000068,0.000126,0.000073,0.000077,0.000094,0.000076,0.000063,0.000056,0.000070,0.000076,0.000063,0.000036,0.000059,0.000040,0.000039,0.000031,0.000048,0.000048,0.000066,0.000072,0.000047,0.000057,0.000058,0.000066,0.000033,0.000044,0.000035,0.000051,0.000038,0.000039,0.000047,0.000046,0.000052,0.000050,0.000033,0.000052,0.000039
giMute156 ftgen 0,0,4096,10,0.625565,0.965980,0.202403,0.024063,0.002481,0.005337,0.005024,0.008205,0.003554,0.001210,0.000983,0.001570,0.000901,0.000291,0.000664,0.000883,0.000489,0.000671,0.000602,0.000605,0.000552,0.000393,0.000580,0.000544,0.000508,0.000536,0.000523,0.000420,0.000400,0.000436,0.000414,0.000508,0.000302,0.000362,0.000336,0.000489,0.000355,0.000362,0.000320,0.000350,0.000246,0.000251,0.000326,0.000214,0.000175,0.000260,0.000273,0.000224,0.000202,0.000232,0.000185,0.000237,0.000245,0.000169,0.000199,0.000160,0.000153,0.000211,0.000161,0.000157,0.000165,0.000177,0.000207,0.000214,0.000158,0.000167,0.000146,0.000138,0.000161,0.000162,0.000163,0.000138,0.000160,0.000141,0.000113,0.000139,0.000144,0.000099,0.000091,0.000160,0.000120,0.000102,0.000131,0.000108,0.000113,0.000114,0.000113,0.000111,0.000105,0.000113,0.000123,0.000107,0.000110,0.000112,0.000110,0.000106,0.000122,0.000112,0.000105,0.000101
giMute157 ftgen 0,0,4096,10,0.314475,0.959696,0.048444,0.004582,0.006574,0.012611,0.005426,0.002115,0.000604,0.000404,0.000356,0.000685,0.001096,0.000409,0.000072,0.000321,0.000329,0.000236,0.000403,0.000240,0.000158,0.000233,0.000268,0.000168,0.000154,0.000209,0.000165,0.000121,0.000111,0.000136,0.000085,0.000217,0.000086,0.000083,0.000149,0.000151,0.000115,0.000148,0.000123,0.000087,0.000095,0.000113,0.000089,0.000044,0.000137,0.000116,0.000130,0.000027,0.000101,0.000085,0.000121,0.000079,0.000106,0.000042,0.000011,0.000071,0.000080,0.000029,0.000039,0.000081,0.000041,0.000060,0.000040,0.000068,0.000066,0.000052,0.000050,0.000031,0.000056,0.000054,0.000039,0.000051,0.000037,0.000059,0.000054,0.000037,0.000046,0.000043,0.000038,0.000041,0.000031,0.000049,0.000033,0.000040,0.000038,0.000035,0.000050,0.000040,0.000043,0.000039,0.000051,0.000035,0.000045,0.000020,0.000038,0.000032,0.000026,0.000030,0.000031,0.000030
giMute158 ftgen 0,0,4096,10,0.428817,0.965152,0.013016,0.001790,0.004347,0.004997,0.005604,0.002582,0.000836,0.000569,0.000599,0.000465,0.000517,0.000563,0.000538,0.000350,0.000281,0.000361,0.000460,0.000274,0.000209,0.000199,0.000249,0.000304,0.000340,0.000213,0.000240,0.000152,0.000238,0.000157,0.000200,0.000196,0.000164,0.000118,0.000156,0.000141,0.000124,0.000105,0.000108,0.000150,0.000140,0.000124,0.000109,0.000104,0.000111,0.000096,0.000120,0.000092,0.000094,0.000103,0.000077,0.000064,0.000066,0.000111,0.000094,0.000093,0.000082,0.000078,0.000073,0.000096,0.000082,0.000079,0.000075,0.000072,0.000085,0.000068,0.000072,0.000053,0.000069,0.000054,0.000057,0.000058,0.000058,0.000065,0.000055,0.000063,0.000066,0.000063,0.000063,0.000058,0.000053,0.000052,0.000046,0.000046,0.000050,0.000049,0.000047,0.000045,0.000043,0.000050,0.000047,0.000052,0.000050,0.000049,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
giwavemapMute1 ftgen 0,0,128,-27, 0,0, 22,0, 23,1, 24,2, 25,3, 26,4, 27,5, 28,6, 29,7, 30,8, 31,9, 32,10, 33,11, 34,12, 35,13, 36,14, 37,15, 38,16, 39,17, 40,18, 41,19, 42,20, 43,21, 44,22, 45,23, 46,24, 47,25, 48,26, 49,27, 50,28, 51,29, 52,30, 53,31, 54,32, 55,33, 56,34, 57,35, 58,36, 127,36
gitabs4morfMute1 ftgen 0,0,64,-2, giMute122,giMute123,giMute124,giMute125,giMute126,giMute127,giMute128,giMute129,giMute130,giMute131,giMute132,giMute133,giMute134,giMute135,giMute136,giMute137,giMute138,giMute139,giMute140,giMute141,giMute142,giMute143,giMute144,giMute145,giMute146,giMute147,giMute148,giMute149,giMute150,giMute151,giMute152,giMute153,giMute154,giMute155,giMute156,giMute157,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158,giMute158




;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; BASS TROMBONE (OPEN)
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
giUnmuted22 ftgen 0,0,4096,10,0.209301,0.150536,0.083014,0.207956,0.321939,0.399510,0.327987,0.421479,0.539528,0.533091,0.721756,0.467196,0.947246,0.770314,0.912692,0.965128,0.962101,1.093136,0.708144,0.664071,0.619031,0.643414,0.371645,0.533120,0.477851,0.481481,0.451545,0.370726,0.360377,0.459325,0.288110,0.235271,0.205264,0.198828,0.206768,0.219183,0.205657,0.164230,0.168498,0.156362,0.109323,0.096989,0.105552,0.095551,0.069663,0.068933,0.067166,0.055414,0.072408,0.055978,0.033534,0.049491,0.054904,0.029956,0.018835,0.027602,0.035912,0.015979,0.021303,0.011033,0.024278,0.030411,0.020777,0.027002,0.020715,0.010245,0.010418,0.019612,0.017841,0.017176,0.012772,0.008424,0.009403,0.002947,0.006355,0.006158,0.015418,0.015477,0.011268,0.008620,0.008935,0.006072,0.005458,0.006560,0.006368,0.007559,0.004779,0.008830,0.007041,0.006334,0.002719,0.003830,0.006208,0.008425,0.006728,0.006139,0.002789,0.007133,0.005592,0.005069
giUnmuted23 ftgen 0,0,4096,10,0.129222,0.088552,0.116290,0.170792,0.176577,0.331680,0.281710,0.247957,0.379599,0.404781,0.432966,0.873924,0.774290,0.657216,0.986727,0.929760,0.832314,0.808580,0.585809,0.684034,0.674170,0.330450,0.888687,0.598954,0.599019,0.566506,0.632303,0.502653,0.431058,0.214554,0.351572,0.335693,0.277218,0.341691,0.264970,0.296760,0.293654,0.224055,0.213823,0.138880,0.188425,0.156849,0.137821,0.185206,0.172163,0.184744,0.153256,0.116401,0.138614,0.155349,0.095606,0.075646,0.091523,0.087233,0.081355,0.068920,0.094557,0.066191,0.069861,0.065915,0.072343,0.065165,0.065968,0.041851,0.063905,0.036430,0.041801,0.035516,0.038545,0.044169,0.038034,0.042219,0.032505,0.038202,0.034556,0.037548,0.036070,0.036673,0.037173,0.024089,0.029610,0.028726,0.018206,0.028118,0.023534,0.023563,0.025997,0.024870,0.021673,0.024752,0.020165,0.019645,0.016172,0.017942,0.018241,0.016560,0.014997,0.013671,0.015848,0.011383
giUnmuted24 ftgen 0,0,4096,10,0.014100,0.027948,0.037471,0.118589,0.278733,0.166216,0.237592,0.204888,0.303225,0.239198,0.590081,0.558590,0.488846,0.934503,0.791766,0.769104,0.451529,0.465344,0.363957,0.375648,0.362512,0.527955,0.584553,0.562238,0.409571,0.447397,0.547498,0.349795,0.363085,0.318352,0.305372,0.298282,0.236937,0.259059,0.251424,0.235425,0.253896,0.305811,0.227171,0.177695,0.218484,0.204418,0.227246,0.182265,0.183710,0.198997,0.141695,0.093968,0.119182,0.128975,0.118829,0.086353,0.143691,0.082113,0.096768,0.076006,0.108551,0.073045,0.080734,0.075566,0.076978,0.047507,0.057911,0.055554,0.070030,0.060662,0.054519,0.055938,0.064493,0.032839,0.043612,0.052568,0.034145,0.054702,0.041937,0.045108,0.037413,0.033601,0.044130,0.036376,0.036994,0.032488,0.031456,0.030170,0.029857,0.031038,0.027679,0.029891,0.027195,0.023506,0.027610,0.023146,0.022810,0.019058,0.018170,0.018749,0.017019,0.015480,0.016379,0.015893
giUnmuted25 ftgen 0,0,4096,10,0.075402,0.101145,0.176728,0.270616,0.291285,0.324780,0.333295,0.233831,0.290677,0.540830,0.767506,0.512758,0.980849,0.771417,0.804053,0.408122,0.631555,0.670085,0.408376,0.681153,0.911500,0.859956,0.697578,0.595419,0.593307,0.469251,0.543682,0.529757,0.367768,0.498910,0.305667,0.300578,0.386836,0.363336,0.347656,0.332606,0.322633,0.253819,0.316454,0.284584,0.227632,0.212815,0.324061,0.212387,0.161264,0.199347,0.187103,0.169679,0.152185,0.206879,0.129213,0.127022,0.158412,0.109282,0.134290,0.097383,0.119959,0.099454,0.111739,0.076911,0.100854,0.086224,0.089536,0.075617,0.075879,0.080690,0.071350,0.079834,0.089408,0.079954,0.081367,0.068297,0.067636,0.067458,0.048890,0.064138,0.053887,0.056479,0.047270,0.039648,0.049324,0.050416,0.048009,0.042951,0.034023,0.037808,0.026799,0.042091,0.023668,0.027252,0.027430,0.027822,0.030900,0.025171,0.030639,0.031093,0.018787,0.024957,0.020116,0.016682
giUnmuted26 ftgen 0,0,4096,10,0.043072,0.066480,0.103784,0.299131,0.266755,0.210417,0.254095,0.299260,0.120587,0.627381,0.502409,0.682945,0.896451,0.718962,0.798438,0.342935,0.438196,0.391451,0.571924,0.500613,0.522119,0.554206,0.351133,0.573747,0.415485,0.314183,0.377587,0.407768,0.269407,0.243405,0.358414,0.278435,0.297179,0.205957,0.278884,0.139884,0.230059,0.203655,0.273754,0.208405,0.268930,0.220588,0.093617,0.135109,0.140624,0.125541,0.127288,0.075447,0.145203,0.086283,0.144206,0.092668,0.097130,0.101259,0.096756,0.087998,0.053647,0.093505,0.075780,0.063445,0.057768,0.067925,0.062568,0.059886,0.049874,0.061576,0.047362,0.059277,0.045356,0.045205,0.049725,0.059766,0.051216,0.043048,0.047544,0.034671,0.055494,0.029430,0.038554,0.039949,0.030711,0.033481,0.031643,0.028951,0.022707,0.022752,0.019352,0.028349,0.020961,0.022731,0.022740,0.021957,0.021687,0.023511,0.015741,0.017651,0.017310,0.015487,0.015835,0.014889
giUnmuted27 ftgen 0,0,4096,10,0.116392,0.064448,0.127432,0.239485,0.257590,0.362741,0.449254,0.199901,0.348867,0.637406,0.429112,0.918400,0.936649,0.907354,0.601632,0.359938,0.492393,0.465346,0.501258,0.682788,0.539385,0.377763,0.493182,0.284353,0.308310,0.236111,0.324894,0.290903,0.171987,0.259098,0.209363,0.188311,0.165040,0.129121,0.179891,0.142395,0.192837,0.155400,0.140506,0.154670,0.085903,0.084914,0.123353,0.033350,0.085811,0.066361,0.064805,0.053334,0.059168,0.051871,0.024556,0.050781,0.036654,0.034625,0.037417,0.026993,0.036074,0.041271,0.034852,0.030858,0.035521,0.039943,0.029248,0.023157,0.034015,0.022517,0.032273,0.025478,0.021464,0.021306,0.020706,0.015205,0.017217,0.016590,0.014839,0.015475,0.014872,0.012173,0.018427,0.015918,0.010766,0.011403,0.007469,0.006837,0.010460,0.009821,0.011490,0.012841,0.009228,0.009485,0.005268,0.008016,0.007500,0.007632,0.009359,0.005060,0.006834,0.006729,0.005832,0.006610
giUnmuted28 ftgen 0,0,4096,10,0.076757,0.165970,0.231682,0.474308,0.397207,0.459106,0.300853,0.244548,0.666795,0.602133,0.902710,0.655767,0.483398,0.313870,0.349970,0.212690,0.704653,0.764853,0.648917,0.660316,0.500843,0.406945,0.437095,0.364433,0.332150,0.247819,0.335990,0.413334,0.272378,0.303040,0.347189,0.202684,0.273591,0.358844,0.326756,0.187244,0.245830,0.136904,0.149347,0.181123,0.074118,0.123133,0.099890,0.059919,0.124875,0.090488,0.085029,0.115332,0.036687,0.106389,0.065025,0.070006,0.054270,0.053720,0.068047,0.055966,0.079658,0.070141,0.046135,0.065892,0.044587,0.048301,0.044148,0.045919,0.038547,0.040422,0.052374,0.032757,0.026433,0.030900,0.031810,0.034349,0.013986,0.030399,0.015539,0.018593,0.017769,0.024225,0.019160,0.022166,0.018451,0.016544,0.010230,0.012227,0.012961,0.015889,0.015651,0.009872,0.014459,0.011942,0.015592,0.014711,0.013394,0.010871,0.008229,0.007572,0.008106,0.008828,0.011451,0.009952
giUnmuted30 ftgen 0,0,4096,10,0.102601,0.100887,0.167098,0.516781,0.330986,0.422868,0.412850,0.397849,0.628756,0.686835,0.929709,0.845577,0.935266,0.508059,0.792158,0.281350,0.378308,0.568489,0.346813,0.566233,0.413541,0.405762,0.359363,0.216505,0.366221,0.301854,0.216945,0.249969,0.168763,0.194386,0.278248,0.046419,0.257812,0.124464,0.096054,0.116201,0.059755,0.096572,0.074147,0.047405,0.054049,0.073919,0.023499,0.080643,0.079127,0.031933,0.076588,0.051990,0.032645,0.031250,0.046055,0.022654,0.038293,0.031067,0.045355,0.035515,0.043591,0.024758,0.020123,0.028097,0.025231,0.014737,0.015258,0.020891,0.010029,0.015487,0.004561,0.009797,0.007038,0.006923,0.012160,0.005577,0.012809,0.007007,0.007626,0.004440,0.008034,0.008475,0.006052,0.009027,0.006419,0.007999,0.005562,0.004974,0.008232,0.007159,0.005841,0.004633,0.005878,0.004708,0.005378,0.005775,0.004317,0.003135,0.006019,0.002682,0.003519,0.002106,0.001173,0.002911
giUnmuted31 ftgen 0,0,4096,10,0.066770,0.048141,0.313114,0.280252,0.266590,0.227818,0.195576,0.598114,0.585360,0.631625,0.922780,0.476250,0.557175,0.516114,0.284400,0.347304,0.327824,0.186298,0.429619,0.319332,0.143321,0.268362,0.179246,0.187779,0.187831,0.069696,0.157916,0.087219,0.051108,0.180413,0.090807,0.061893,0.087674,0.029616,0.053852,0.035420,0.032698,0.030786,0.031084,0.040347,0.022290,0.019770,0.033986,0.022503,0.008514,0.028204,0.013058,0.011683,0.016372,0.011838,0.005125,0.012279,0.007251,0.009685,0.008196,0.009381,0.007698,0.004608,0.004124,0.002835,0.002636,0.005858,0.004185,0.001287,0.002347,0.002862,0.004396,0.003505,0.001776,0.002038,0.003386,0.001389,0.002214,0.001394,0.002558,0.001971,0.001212,0.000993,0.001220,0.001435,0.001036,0.000315,0.000862,0.001509,0.000972,0.000423,0.000797,0.001030,0.001800,0.000491,0.000318,0.000990,0.000987,0.000840,0.000380,0.000536,0.000975,0.000576,0.000444,0.000286
giUnmuted32 ftgen 0,0,4096,10,0.153577,0.222613,0.376395,0.526417,0.515836,0.662033,0.484716,0.943689,0.936088,0.683402,0.940687,0.666224,0.399824,0.298609,0.378373,0.633100,0.213897,0.505597,0.312328,0.232655,0.144484,0.129531,0.225201,0.231697,0.116577,0.093467,0.083941,0.021798,0.081229,0.048477,0.071105,0.034486,0.057723,0.028194,0.029190,0.019811,0.027128,0.025539,0.014725,0.015158,0.019471,0.022215,0.011935,0.015510,0.012182,0.010768,0.007979,0.010226,0.004972,0.009394,0.006760,0.006326,0.005823,0.003912,0.005859,0.001846,0.002697,0.003683,0.003892,0.002554,0.002904,0.004195,0.000672,0.001703,0.001212,0.002070,0.001499,0.001454,0.002153,0.001936,0.000769,0.001242,0.001260,0.000672,0.000842,0.001179,0.001096,0.001223,0.001090,0.001644,0.001218,0.000337,0.000969,0.000736,0.000734,0.000228,0.000786,0.000788,0.000390,0.000223,0.001065,0.000755,0.000257,0.000513,0.000711,0.000538,0.000385,0.000437,0.000469,0.000430
giUnmuted33 ftgen 0,0,4096,10,0.199259,0.293112,0.678605,0.427095,0.796552,0.592920,0.832602,0.749712,0.753129,0.956136,0.706813,0.595711,0.292833,0.370551,0.334616,0.299621,0.458159,0.299313,0.277013,0.116169,0.127934,0.137952,0.174017,0.060317,0.067909,0.049889,0.073748,0.061114,0.028611,0.050743,0.022684,0.016755,0.015577,0.022867,0.023917,0.026384,0.015817,0.016226,0.020209,0.017937,0.014795,0.014935,0.011316,0.011197,0.003987,0.006306,0.007657,0.008754,0.008017,0.001430,0.002030,0.006426,0.004673,0.001697,0.003547,0.003128,0.001704,0.002225,0.003744,0.001255,0.001218,0.001706,0.000784,0.001874,0.002414,0.001450,0.001425,0.001431,0.001039,0.000512,0.001115,0.001012,0.000767,0.001368,0.000891,0.001254,0.000438,0.001473,0.000396,0.000944,0.000406,0.000645,0.000805,0.000497,0.000596,0.000632,0.000660,0.000453,0.000657,0.000437,0.000597,0.000534,0.000231,0.000579,0.000359,0.000597,0.000289,0.000515,0.000474,0.000508
giUnmuted34 ftgen 0,0,4096,10,0.156283,0.263433,0.503588,0.547226,0.458841,0.440476,0.745137,0.926771,0.703339,0.326809,0.455305,0.144506,0.578160,0.557536,0.390538,0.373849,0.349519,0.171391,0.136852,0.175680,0.170348,0.095999,0.101795,0.067277,0.069750,0.038210,0.062274,0.031281,0.045966,0.025999,0.019665,0.025196,0.019584,0.017978,0.018616,0.019068,0.009254,0.008323,0.009829,0.007950,0.009281,0.004125,0.006169,0.005516,0.008089,0.004623,0.003210,0.003435,0.002272,0.003102,0.002101,0.002482,0.000800,0.001308,0.001448,0.002671,0.000440,0.001102,0.000625,0.001246,0.000739,0.001198,0.000853,0.000982,0.000459,0.000870,0.000679,0.000793,0.000524,0.000192,0.000634,0.000314,0.000778,0.000405,0.000532,0.000235,0.000824,0.000204,0.000655,0.000308,0.000375,0.000408,0.000459,0.000698,0.000335,0.000370,0.000416,0.000463,0.000712,0.000202,0.000604,0.000194,0.000642,0.000492,0.000566,0.000304,0.000430,0.000666,0.000460,0.000725
giUnmuted35 ftgen 0,0,4096,10,0.109719,0.205679,0.327171,0.211979,0.275588,0.441424,0.909739,0.954713,0.704080,0.558176,0.412328,0.520298,0.672399,0.332547,0.403159,0.369356,0.239488,0.211806,0.231043,0.127727,0.249776,0.131377,0.104229,0.096938,0.102833,0.065079,0.066313,0.070405,0.083568,0.043975,0.062456,0.056332,0.053849,0.056551,0.038084,0.032551,0.031631,0.024900,0.019231,0.022793,0.025653,0.029848,0.012080,0.012343,0.008958,0.007429,0.009658,0.011782,0.006432,0.008668,0.004940,0.004961,0.011409,0.003677,0.005188,0.006053,0.002706,0.005660,0.005030,0.003473,0.004147,0.002260,0.003165,0.004611,0.001572,0.002973,0.001712,0.001380,0.002403,0.001241,0.001415,0.002559,0.000850,0.001416,0.000832,0.001164,0.001932,0.000912,0.001026,0.000996,0.000473,0.001056,0.000666,0.000709,0.000940,0.000380,0.000715,0.000818,0.000554,0.000733,0.000482,0.000638,0.000669,0.000419,0.000706,0.000551,0.000449,0.000615,0.000441,0.000574
giUnmuted37 ftgen 0,0,4096,10,0.163591,0.404564,0.575089,0.472316,0.486294,0.822510,0.806591,0.969411,0.362995,0.433080,0.496749,0.467537,0.467839,0.267451,0.183238,0.218200,0.199060,0.155508,0.175596,0.093844,0.131201,0.054473,0.064991,0.054622,0.028696,0.047964,0.032300,0.032288,0.027946,0.028929,0.025863,0.016471,0.015090,0.011768,0.012035,0.007896,0.009150,0.007422,0.006861,0.006328,0.006340,0.003206,0.001979,0.001196,0.003410,0.003344,0.001708,0.001304,0.001426,0.001391,0.002381,0.001136,0.000501,0.000621,0.001295,0.001362,0.001331,0.000559,0.000199,0.000503,0.000879,0.001032,0.000443,0.000370,0.000358,0.000616,0.000749,0.000331,0.000239,0.000475,0.000621,0.000552,0.000280,0.000188,0.000404,0.000434,0.000385,0.000500,0.000299,0.000339,0.000250,0.000436,0.000389,0.000319,0.000252,0.000279,0.000331,0.000496,0.000362,0.000299,0.000301,0.000389,0.000340,0.000331,0.000305,0.000321,0.000282,0.000312,0.000322,0.000305
giUnmuted38 ftgen 0,0,4096,10,0.088638,0.393952,0.219528,0.233796,0.390552,0.873953,0.973908,0.452420,0.406845,0.369372,0.418449,0.275682,0.233818,0.174596,0.176589,0.199987,0.084305,0.099145,0.066017,0.092595,0.045456,0.041233,0.057805,0.035677,0.029982,0.021224,0.023785,0.011487,0.013368,0.009656,0.009504,0.010544,0.006813,0.005152,0.006761,0.004720,0.005569,0.005772,0.003926,0.003876,0.001447,0.001937,0.001824,0.001260,0.001196,0.001056,0.001716,0.000597,0.000870,0.000129,0.001182,0.000562,0.000716,0.000558,0.000346,0.000458,0.000280,0.000472,0.000305,0.000628,0.000215,0.000532,0.000286,0.000686,0.000363,0.000433,0.000417,0.000257,0.000323,0.000182,0.000362,0.000182,0.000308,0.000090,0.000457,0.000168,0.000301,0.000207,0.000232,0.000295,0.000234,0.000253,0.000115,0.000278,0.000128,0.000246,0.000142,0.000206,0.000208,0.000168,0.000245,0.000156,0.000184,0.000153,0.000195,0.000110,0.000237,0.000120,0.000147,0.000197
giUnmuted39 ftgen 0,0,4096,10,0.072477,0.251689,0.379198,0.380111,0.725478,0.949509,0.692901,0.578175,0.268676,0.362999,0.292393,0.221151,0.135379,0.142198,0.166308,0.080654,0.080723,0.055948,0.052355,0.045652,0.019205,0.017803,0.021033,0.012636,0.010918,0.015171,0.012617,0.010832,0.009232,0.006483,0.005626,0.003851,0.002409,0.001860,0.003662,0.003232,0.003431,0.001824,0.002610,0.001564,0.001117,0.000540,0.000571,0.001003,0.001335,0.000552,0.000678,0.000584,0.001061,0.000360,0.000733,0.000138,0.000610,0.000585,0.000395,0.000329,0.000646,0.000491,0.000414,0.000402,0.000119,0.000403,0.000173,0.000409,0.000081,0.000323,0.000367,0.000312,0.000184,0.000390,0.000085,0.000295,0.000195,0.000268,0.000142,0.000267,0.000047,0.000196,0.000144,0.000201,0.000119,0.000264,0.000129,0.000192,0.000106,0.000089,0.000146,0.000206,0.000209,0.000106,0.000142,0.000140,0.000184,0.000083,0.000036,0.000158,0.000137,0.000135,0.000284,0.000115
giUnmuted40 ftgen 0,0,4096,10,0.225959,0.669389,0.383703,0.337797,0.897874,0.917315,0.679617,0.847733,0.413981,0.550916,0.384995,0.299373,0.229249,0.175955,0.251333,0.151143,0.072766,0.141216,0.038843,0.059075,0.024251,0.038600,0.034595,0.024303,0.012174,0.014682,0.023313,0.013042,0.011554,0.011010,0.010318,0.007734,0.007817,0.007700,0.004889,0.002809,0.002953,0.002732,0.002419,0.002929,0.001031,0.001758,0.002569,0.001934,0.000195,0.000657,0.000465,0.000529,0.000132,0.000495,0.000114,0.000374,0.000066,0.000383,0.000298,0.000374,0.000325,0.000203,0.000379,0.000195,0.000256,0.000055,0.000261,0.000143,0.000303,0.000225,0.000165,0.000287,0.000154,0.000362,0.000079,0.000339,0.000076,0.000304,0.000074,0.000377,0.000110,0.000203,0.000160,0.000220,0.000170,0.000246,0.000154,0.000238,0.000107,0.000233,0.000176,0.000143,0.000173,0.000149,0.000209,0.000112,0.000150,0.000111,0.000112,0.000142,0.000096,0.000126,0.000128,0.000116
giUnmuted41 ftgen 0,0,4096,10,0.097703,0.458893,0.214092,0.303131,0.643075,0.941287,0.605134,0.446467,0.333405,0.230717,0.265198,0.183918,0.159675,0.159325,0.106876,0.068197,0.087184,0.044215,0.041701,0.023995,0.024583,0.018444,0.017021,0.012909,0.009709,0.009292,0.005646,0.005169,0.005487,0.004703,0.003198,0.001953,0.002304,0.001896,0.001346,0.001214,0.000950,0.001006,0.000408,0.000899,0.000811,0.000603,0.000416,0.000186,0.000451,0.000580,0.000293,0.000134,0.000491,0.000610,0.000365,0.000202,0.000238,0.000284,0.000383,0.000318,0.000171,0.000207,0.000319,0.000262,0.000156,0.000201,0.000269,0.000277,0.000189,0.000255,0.000252,0.000251,0.000238,0.000176,0.000262,0.000221,0.000254,0.000156,0.000243,0.000273,0.000203,0.000144,0.000205,0.000227,0.000273,0.000231,0.000129,0.000148,0.000263,0.000231,0.000178,0.000240,0.000111,0.000150,0.000125,0.000253,0.000117,0.000217,0.000249,0.000167,0.000129,0.000153,0.000156,0.000166
giUnmuted42 ftgen 0,0,4096,10,0.124305,0.470693,0.408472,0.419845,0.726811,0.899803,0.320069,0.227380,0.170542,0.278327,0.087448,0.075657,0.070450,0.011278,0.027231,0.027560,0.017657,0.007864,0.003498,0.005879,0.002004,0.003338,0.002302,0.002026,0.001182,0.001269,0.001074,0.000364,0.000612,0.000235,0.000662,0.000064,0.000466,0.000427,0.000278,0.000267,0.000353,0.000292,0.000282,0.000261,0.000314,0.000191,0.000121,0.000300,0.000198,0.000184,0.000171,0.000233,0.000128,0.000158,0.000242,0.000129,0.000168,0.000158,0.000221,0.000105,0.000151,0.000134,0.000034,0.000239,0.000107,0.000190,0.000107,0.000133,0.000170,0.000077,0.000159,0.000133,0.000084,0.000139,0.000186,0.000114,0.000238,0.000054,0.000180,0.000124,0.000143,0.000260,0.000043,0.000132,0.000091,0.000030,0.000116,0.000080,0.000072,0.000057,0.000105,0.000076,0.000116,0.000065,0.000171,0.000053,0.000072,0.000074,0.000062,0.000114,0.000055,0.000095,0.000113,0.000044
giUnmuted43 ftgen 0,0,4096,10,0.125142,0.748133,0.488996,0.937672,0.810384,0.425414,0.265649,0.228407,0.170598,0.111821,0.121106,0.061239,0.019591,0.017183,0.019865,0.007807,0.001783,0.002592,0.001011,0.003527,0.002854,0.000493,0.002776,0.000788,0.001901,0.002961,0.000261,0.000981,0.000309,0.001260,0.001590,0.000419,0.000880,0.000853,0.000491,0.001106,0.000390,0.000507,0.000664,0.000732,0.000588,0.000322,0.000375,0.000612,0.000570,0.000284,0.000276,0.000346,0.000470,0.000510,0.000208,0.000313,0.000421,0.000286,0.000339,0.000330,0.000236,0.000285,0.000339,0.000333,0.000325,0.000301,0.000405,0.000289,0.000185,0.000254,0.000429,0.000220,0.000088,0.000342,0.000434,0.000323,0.000114,0.000423,0.000294,0.000189,0.000274,0.000329,0.000150,0.000193,0.000230,0.000213,0.000130,0.000222,0.000238,0.000078,0.000370,0.000313,0.000161,0.000338,0.000185,0.000246,0.000194,0.000179,0.000174,0.000154,0.000140,0.000235,0.000115,0.000258
giUnmuted44 ftgen 0,0,4096,10,0.302063,0.713050,0.452426,0.930055,0.680724,0.256993,0.187429,0.166946,0.128520,0.034480,0.011033,0.010095,0.010484,0.013378,0.003779,0.001842,0.002372,0.003682,0.002032,0.001052,0.001063,0.001158,0.000116,0.001123,0.001585,0.000539,0.001398,0.000809,0.000447,0.000282,0.000640,0.000371,0.000503,0.000484,0.000108,0.000162,0.000180,0.000319,0.000232,0.000211,0.000045,0.000246,0.000082,0.000069,0.000149,0.000105,0.000143,0.000097,0.000032,0.000091,0.000142,0.000202,0.000052,0.000133,0.000185,0.000054,0.000154,0.000137,0.000181,0.000042,0.000135,0.000129,0.000100,0.000108,0.000143,0.000065,0.000082,0.000182,0.000049,0.000189,0.000083,0.000061,0.000143,0.000078,0.000056,0.000079,0.000120,0.000037,0.000098,0.000063,0.000110,0.000162,0.000076,0.000078,0.000059,0.000095,0.000049,0.000104,0.000088,0.000117,0.000133,0.000031,0.000103,0.000040,0.000058,0.000025,0.000024,0.000077,0.000069,0.000155
giUnmuted45 ftgen 0,0,4096,10,0.233846,0.388855,0.488775,0.775865,0.964456,0.501325,0.291914,0.282804,0.153115,0.120898,0.100772,0.061525,0.021515,0.015412,0.010305,0.004386,0.004785,0.007854,0.004759,0.004311,0.003465,0.002391,0.000787,0.001491,0.000948,0.000812,0.000611,0.000750,0.000529,0.000347,0.000811,0.000462,0.000235,0.000129,0.000100,0.000270,0.000180,0.000344,0.000298,0.000283,0.000076,0.000033,0.000229,0.000057,0.000107,0.000302,0.000392,0.000250,0.000158,0.000123,0.000211,0.000176,0.000204,0.000052,0.000045,0.000073,0.000098,0.000048,0.000042,0.000062,0.000184,0.000108,0.000087,0.000108,0.000246,0.000201,0.000114,0.000035,0.000098,0.000163,0.000193,0.000214,0.000220,0.000138,0.000157,0.000201,0.000169,0.000255,0.000225,0.000166,0.000090,0.000040,0.000130,0.000094,0.000063,0.000032,0.000089,0.000092,0.000126,0.000045,0.000031,0.000089,0.000106,0.000113,0.000102,0.000097,0.000078,0.000087,0.000116,0.000073
giUnmuted46 ftgen 0,0,4096,10,0.278221,0.573695,0.445852,0.941888,0.349456,0.146739,0.401320,0.181176,0.109258,0.079677,0.027531,0.020462,0.010172,0.004976,0.008831,0.004459,0.003116,0.005925,0.003482,0.001955,0.000824,0.000849,0.000990,0.000555,0.000572,0.000248,0.000282,0.000312,0.000425,0.000324,0.000073,0.000533,0.000097,0.000455,0.000267,0.000126,0.000125,0.000100,0.000382,0.000051,0.000129,0.000240,0.000307,0.000083,0.000247,0.000140,0.000183,0.000087,0.000275,0.000383,0.000065,0.000167,0.000138,0.000204,0.000147,0.000389,0.000087,0.000087,0.000085,0.000041,0.000137,0.000224,0.000036,0.000053,0.000195,0.000205,0.000101,0.000065,0.000194,0.000064,0.000193,0.000258,0.000182,0.000073,0.000094,0.000173,0.000055,0.000075,0.000093,0.000129,0.000045,0.000085,0.000107,0.000117,0.000074,0.000107,0.000122,0.000085,0.000048,0.000110,0.000056,0.000075,0.000100,0.000057,0.000058,0.000070,0.000058,0.000062,0.000024,0.000053
giUnmuted48 ftgen 0,0,4096,10,0.452762,0.304359,0.946745,0.826937,0.631116,0.540533,0.395792,0.137892,0.089376,0.056327,0.024940,0.018700,0.015991,0.009294,0.006775,0.006495,0.001878,0.002247,0.000868,0.001248,0.001564,0.001249,0.001144,0.001326,0.001103,0.000911,0.000811,0.000899,0.000763,0.000818,0.000796,0.000855,0.000820,0.000710,0.000624,0.000684,0.000656,0.000643,0.000581,0.000503,0.000628,0.000640,0.000595,0.000471,0.000287,0.000521,0.000550,0.000603,0.000454,0.000276,0.000515,0.000524,0.000515,0.000548,0.000414,0.000417,0.000623,0.000306,0.000257,0.000314,0.000328,0.000356,0.000371,0.000363,0.000334,0.000261,0.000258,0.000294,0.000248,0.000426,0.000222,0.000250,0.000403,0.000222,0.000365,0.000158,0.000358,0.000267,0.000252,0.000328,0.000186,0.000291,0.000280,0.000198,0.000269,0.000258,0.000279,0.000252,0.000236,0.000257,0.000228,0.000248,0.000225,0.000222,0.000211,0.000262,0.000206,0.000219,0.000216,0.000223
giUnmuted49 ftgen 0,0,4096,10,0.384255,0.558888,0.714667,0.956957,0.356637,0.233667,0.190339,0.102786,0.061868,0.032079,0.017290,0.009522,0.005673,0.005487,0.002456,0.002036,0.000425,0.001796,0.002623,0.001222,0.000730,0.000805,0.000937,0.000709,0.000258,0.000626,0.000855,0.000810,0.000503,0.000376,0.000366,0.000792,0.000435,0.000475,0.000434,0.000367,0.000729,0.000327,0.000400,0.000367,0.000285,0.000247,0.000517,0.000305,0.000346,0.000356,0.000254,0.000337,0.000385,0.000231,0.000456,0.000215,0.000106,0.000201,0.000338,0.000284,0.000295,0.000166,0.000172,0.000132,0.000143,0.000401,0.000352,0.000229,0.000228,0.000272,0.000210,0.000234,0.000250,0.000182,0.000231,0.000084,0.000152,0.000170,0.000231,0.000207,0.000174,0.000130,0.000145,0.000280,0.000219,0.000185,0.000135,0.000104,0.000157,0.000222,0.000197,0.000090,0.000129,0.000142,0.000121,0.000183,0.000157,0.000120,0.000130,0.000101,0.000113,0.000151,0.000146,0.000114
giUnmuted50 ftgen 0,0,4096,10,0.446591,0.477584,0.426492,0.970753,0.374135,0.215282,0.306904,0.140851,0.070867,0.038834,0.002282,0.017849,0.007741,0.003585,0.006831,0.006003,0.003705,0.001554,0.003344,0.000137,0.001907,0.000924,0.001095,0.001011,0.000580,0.000998,0.001204,0.000696,0.001058,0.000873,0.000742,0.000768,0.000685,0.000814,0.000666,0.000827,0.000659,0.000713,0.000613,0.000584,0.000711,0.000452,0.000535,0.000517,0.000488,0.000572,0.000501,0.000577,0.000468,0.000403,0.000316,0.000555,0.000474,0.000513,0.000541,0.000421,0.000425,0.000418,0.000385,0.000321,0.000462,0.000415,0.000342,0.000312,0.000347,0.000323,0.000339,0.000320,0.000298,0.000318,0.000268,0.000265,0.000232,0.000302,0.000354,0.000263,0.000304,0.000222,0.000312,0.000311,0.000342,0.000363,0.000274,0.000300,0.000250,0.000296,0.000254,0.000287,0.000249,0.000199,0.000219,0.000195,0.000210,0.000230,0.000217,0.000181,0.000209,0.000200,0.000218,0.000224
giUnmuted51 ftgen 0,0,4096,10,0.287446,0.531276,0.971557,0.630155,0.300795,0.250731,0.098819,0.107126,0.053101,0.062126,0.011011,0.012837,0.004178,0.006909,0.004394,0.002253,0.002430,0.002140,0.001992,0.000671,0.000287,0.000471,0.000271,0.000130,0.000051,0.000046,0.000110,0.000021,0.000075,0.000192,0.000076,0.000065,0.000131,0.000125,0.000081,0.000150,0.000030,0.000017,0.000085,0.000079,0.000026,0.000096,0.000129,0.000153,0.000110,0.000071,0.000054,0.000060,0.000076,0.000043,0.000064,0.000017,0.000052,0.000117,0.000038,0.000047,0.000024,0.000058,0.000033,0.000021,0.000042,0.000074,0.000063,0.000027,0.000066,0.000039,0.000035,0.000030,0.000050,0.000068,0.000048,0.000058,0.000037,0.000069,0.000030,0.000032,0.000081,0.000067,0.000051,0.000033,0.000053,0.000067,0.000038,0.000025,0.000009,0.000037,0.000026,0.000021,0.000009,0.000039,0.000025,0.000029,0.000019,0.000007,0.000014,0.000020,0.000025,0.000019,0.000024,0.000011
giUnmuted52 ftgen 0,0,4096,10,0.780315,0.602043,0.971703,0.598540,0.419892,0.250576,0.135924,0.028914,0.007076,0.002504,0.001073,0.002881,0.002091,0.001033,0.001393,0.001759,0.002069,0.001160,0.001046,0.000119,0.000300,0.000679,0.000689,0.000161,0.000393,0.000523,0.000306,0.000179,0.000312,0.000431,0.000186,0.000165,0.000492,0.000276,0.000209,0.000416,0.000299,0.000153,0.000254,0.000350,0.000169,0.000155,0.000291,0.000165,0.000059,0.000258,0.000299,0.000257,0.000195,0.000128,0.000254,0.000142,0.000138,0.000172,0.000115,0.000086,0.000226,0.000168,0.000117,0.000109,0.000203,0.000108,0.000106,0.000096,0.000163,0.000088,0.000138,0.000083,0.000076,0.000118,0.000119,0.000130,0.000104,0.000106,0.000157,0.000102,0.000046,0.000053,0.000071,0.000098,0.000102,0.000096,0.000078,0.000080,0.000075,0.000076,0.000080,0.000077,0.000073,0.000056,0.000081,0.000076,0.000093,0.000054,0.000098,0.000069,0.000047,0.000076,0.000050,0.000039
giUnmuted53 ftgen 0,0,4096,10,0.372046,0.398945,0.933433,0.303716,0.202319,0.090480,0.045828,0.011018,0.009763,0.001157,0.003828,0.006742,0.001634,0.000320,0.001952,0.001823,0.000292,0.001455,0.000996,0.000511,0.001143,0.001002,0.000470,0.000777,0.000907,0.000648,0.000685,0.000677,0.000506,0.000454,0.000526,0.000488,0.000439,0.000473,0.000508,0.000505,0.000540,0.000447,0.000407,0.000416,0.000398,0.000364,0.000198,0.000374,0.000324,0.000391,0.000404,0.000361,0.000265,0.000399,0.000341,0.000282,0.000274,0.000277,0.000232,0.000236,0.000232,0.000234,0.000221,0.000241,0.000245,0.000215,0.000179,0.000214,0.000247,0.000215,0.000207,0.000202,0.000207,0.000195,0.000189,0.000164,0.000193,0.000172,0.000163,0.000189,0.000196,0.000183,0.000169,0.000170,0.000159,0.000177,0.000172,0.000148,0.000148,0.000174,0.000160,0.000170,0.000159,0.000159,0.000153,0.000140,0.000152,0.000124,0.000137,0.000135,0.000132,0.000111,0.000136,0.000145
giUnmuted55 ftgen 0,0,4096,10,0.553293,0.970661,0.775964,0.469479,0.247296,0.167610,0.076609,0.033410,0.020341,0.014035,0.008333,0.004948,0.005841,0.001285,0.003257,0.000737,0.001858,0.001036,0.001645,0.001036,0.001103,0.001137,0.001058,0.001046,0.000830,0.000920,0.000754,0.000986,0.000805,0.000941,0.000725,0.000785,0.000639,0.000792,0.000693,0.000710,0.000502,0.000630,0.000647,0.000611,0.000541,0.000612,0.000564,0.000535,0.000526,0.000550,0.000561,0.000452,0.000489,0.000502,0.000455,0.000494,0.000395,0.000489,0.000391,0.000455,0.000426,0.000401,0.000395,0.000424,0.000366,0.000409,0.000441,0.000420,0.000368,0.000384,0.000385,0.000372,0.000378,0.000347,0.000334,0.000364,0.000324,0.000342,0.000334,0.000331,0.000328,0.000319,0.000317,0.000303,0.000307,0.000324,0.000295,0.000316,0.000284,0.000293,0.000301,0.000292,0.000308,0.000294,0.000306,0.000291,0.000290,0.000281,0.000282,0.000284,0.000276,0.000270,0.000271,0.000271
giUnmuted56 ftgen 0,0,4096,10,0.400932,0.968520,0.498998,0.389257,0.178633,0.106598,0.036188,0.017795,0.012342,0.000119,0.001239,0.002906,0.000849,0.000166,0.001155,0.001166,0.000733,0.000431,0.000261,0.000740,0.000954,0.000788,0.000425,0.000292,0.000215,0.000111,0.000367,0.000116,0.000157,0.000202,0.000291,0.000325,0.000311,0.000291,0.000228,0.000258,0.000334,0.000245,0.000207,0.000181,0.000101,0.000272,0.000256,0.000160,0.000202,0.000191,0.000135,0.000209,0.000287,0.000145,0.000174,0.000142,0.000151,0.000158,0.000211,0.000156,0.000085,0.000205,0.000120,0.000149,0.000178,0.000110,0.000128,0.000155,0.000127,0.000078,0.000172,0.000112,0.000089,0.000134,0.000141,0.000080,0.000122,0.000145,0.000057,0.000148,0.000118,0.000076,0.000098,0.000141,0.000071,0.000118,0.000134,0.000051,0.000121,0.000094,0.000107,0.000067,0.000125,0.000091,0.000070,0.000129,0.000072,0.000073,0.000102,0.000110,0.000065,0.000125,0.000102,0.000073
giUnmuted57 ftgen 0,0,4096,10,0.291306,0.935026,0.610503,0.348987,0.214608,0.091185,0.014377,0.010820,0.009119,0.004516,0.002313,0.001529,0.002367,0.001896,0.001988,0.001276,0.001387,0.001297,0.001665,0.001145,0.001069,0.001265,0.001014,0.000912,0.000914,0.000884,0.001057,0.000657,0.000966,0.000629,0.000867,0.000822,0.000934,0.000930,0.000759,0.000705,0.000586,0.000610,0.000554,0.000522,0.000534,0.000515,0.000527,0.000475,0.000482,0.000475,0.000461,0.000481,0.000430,0.000442,0.000430,0.000434,0.000438,0.000393,0.000406,0.000411,0.000359,0.000372,0.000357,0.000351,0.000349,0.000324,0.000336,0.000324,0.000314,0.000303,0.000301,0.000285,0.000290,0.000281,0.000290,0.000278,0.000275,0.000275,0.000263,0.000266,0.000238,0.000227,0.000236,0.000240,0.000236,0.000232,0.000222,0.000228,0.000230,0.000219,0.000211,0.000210,0.000218,0.000220,0.000216,0.000205,0.000201,0.000207,0.000204,0.000198,0.000198,0.000199,0.000198,0.000204
giUnmuted58 ftgen 0,0,4096,10,0.424856,0.955425,0.300308,0.167209,0.106790,0.022221,0.009677,0.003945,0.002919,0.000972,0.002109,0.001042,0.000179,0.000802,0.000783,0.000469,0.000622,0.000452,0.000340,0.000342,0.000529,0.000442,0.000227,0.000537,0.000344,0.000279,0.000438,0.000291,0.000255,0.000281,0.000355,0.000226,0.000212,0.000190,0.000247,0.000230,0.000217,0.000203,0.000212,0.000229,0.000161,0.000199,0.000193,0.000163,0.000189,0.000156,0.000148,0.000176,0.000153,0.000136,0.000144,0.000163,0.000148,0.000142,0.000156,0.000124,0.000124,0.000128,0.000131,0.000128,0.000116,0.000119,0.000096,0.000126,0.000103,0.000119,0.000108,0.000098,0.000108,0.000100,0.000109,0.000095,0.000104,0.000104,0.000089,0.000098,0.000092,0.000092,0.000094,0.000088,0.000084,0.000083,0.000085,0.000085,0.000078,0.000083,0.000080,0.000081,0.000078,0.000077,0.000082,0.000082,0.000079,0.000080,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted59 ftgen 0,0,4096,10,0.359547,0.978853,0.629720,0.355319,0.173057,0.062497,0.018952,0.015355,0.001883,0.003244,0.000776,0.001277,0.001682,0.000930,0.001021,0.000861,0.000797,0.000784,0.000905,0.000938,0.000691,0.000529,0.000651,0.000668,0.000567,0.000394,0.000564,0.000553,0.000563,0.000374,0.000399,0.000503,0.000337,0.000498,0.000410,0.000391,0.000452,0.000316,0.000406,0.000293,0.000417,0.000301,0.000349,0.000279,0.000358,0.000270,0.000271,0.000287,0.000270,0.000252,0.000235,0.000266,0.000229,0.000223,0.000239,0.000206,0.000237,0.000201,0.000212,0.000207,0.000197,0.000204,0.000185,0.000193,0.000174,0.000185,0.000168,0.000173,0.000159,0.000158,0.000167,0.000156,0.000160,0.000158,0.000153,0.000144,0.000156,0.000152,0.000147,0.000148,0.000140,0.000141,0.000134,0.000134,0.000132,0.000133,0.000132,0.000129,0.000139,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted60 ftgen 0,0,4096,10,0.261374,0.958638,0.539283,0.255231,0.147692,0.058306,0.039086,0.029455,0.008523,0.006366,0.003368,0.001295,0.000525,0.000726,0.000847,0.000590,0.000475,0.000526,0.000505,0.000443,0.000320,0.000407,0.000362,0.000443,0.000436,0.000378,0.000327,0.000302,0.000313,0.000302,0.000287,0.000249,0.000268,0.000271,0.000288,0.000219,0.000205,0.000188,0.000206,0.000244,0.000213,0.000204,0.000153,0.000138,0.000190,0.000183,0.000175,0.000180,0.000157,0.000145,0.000159,0.000168,0.000161,0.000138,0.000144,0.000137,0.000134,0.000133,0.000132,0.000126,0.000126,0.000129,0.000119,0.000120,0.000108,0.000109,0.000110,0.000111,0.000101,0.000092,0.000091,0.000098,0.000100,0.000096,0.000094,0.000096,0.000089,0.000087,0.000090,0.000085,0.000088,0.000082,0.000081,0.000085,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted61 ftgen 0,0,4096,10,0.417597,0.966833,0.416727,0.180794,0.059064,0.009951,0.012483,0.005985,0.000936,0.001803,0.000655,0.001165,0.001044,0.000808,0.000730,0.000802,0.000431,0.000761,0.000635,0.000600,0.000672,0.000449,0.000439,0.000419,0.000423,0.000466,0.000371,0.000301,0.000340,0.000369,0.000332,0.000355,0.000303,0.000303,0.000266,0.000327,0.000298,0.000235,0.000293,0.000250,0.000196,0.000286,0.000226,0.000187,0.000270,0.000214,0.000201,0.000218,0.000195,0.000204,0.000206,0.000186,0.000183,0.000183,0.000170,0.000171,0.000168,0.000166,0.000163,0.000161,0.000161,0.000147,0.000147,0.000142,0.000139,0.000140,0.000142,0.000142,0.000138,0.000137,0.000135,0.000131,0.000129,0.000130,0.000131,0.000129,0.000128,0.000128,0.000129,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted62 ftgen 0,0,4096,10,0.619523,0.961285,0.413119,0.108674,0.024175,0.002125,0.004476,0.003247,0.001352,0.001965,0.000417,0.001471,0.001777,0.000808,0.001622,0.001287,0.001022,0.001266,0.000711,0.000939,0.000934,0.000662,0.000613,0.000589,0.000621,0.000570,0.000567,0.000537,0.000348,0.000623,0.000348,0.000581,0.000430,0.000433,0.000451,0.000404,0.000403,0.000380,0.000391,0.000385,0.000372,0.000351,0.000360,0.000320,0.000325,0.000307,0.000314,0.000267,0.000307,0.000276,0.000259,0.000269,0.000263,0.000231,0.000245,0.000235,0.000254,0.000203,0.000228,0.000209,0.000210,0.000212,0.000201,0.000201,0.000200,0.000193,0.000197,0.000181,0.000186,0.000191,0.000187,0.000179,0.000186,0.000183,0.000156,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted63 ftgen 0,0,4096,10,0.930506,0.830293,0.419689,0.124916,0.038385,0.024593,0.004794,0.004719,0.003135,0.000873,0.001282,0.002043,0.001147,0.000967,0.000988,0.000678,0.000173,0.000513,0.000302,0.000290,0.000411,0.000762,0.000371,0.000406,0.000100,0.000164,0.000359,0.000407,0.000105,0.000293,0.000391,0.000246,0.000158,0.000094,0.000092,0.000176,0.000072,0.000179,0.000079,0.000130,0.000159,0.000270,0.000068,0.000103,0.000061,0.000031,0.000141,0.000112,0.000103,0.000058,0.000084,0.000104,0.000104,0.000093,0.000106,0.000081,0.000073,0.000109,0.000082,0.000051,0.000083,0.000073,0.000065,0.000063,0.000070,0.000082,0.000059,0.000073,0.000066,0.000057,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted64 ftgen 0,0,4096,10,0.972240,0.962179,0.327494,0.131881,0.030060,0.012594,0.010159,0.006424,0.001103,0.003403,0.002598,0.002451,0.001553,0.001352,0.001133,0.001503,0.001006,0.001536,0.001309,0.001202,0.000888,0.001138,0.001263,0.001203,0.001186,0.000543,0.000766,0.000841,0.000896,0.000659,0.000695,0.000682,0.000638,0.000554,0.000597,0.000599,0.000595,0.000633,0.000510,0.000491,0.000552,0.000483,0.000426,0.000553,0.000423,0.000448,0.000409,0.000425,0.000270,0.000375,0.000420,0.000306,0.000414,0.000322,0.000332,0.000333,0.000282,0.000349,0.000328,0.000344,0.000339,0.000347,0.000316,0.000285,0.000300,0.000263,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted65 ftgen 0,0,4096,10,0.946888,0.960545,0.184774,0.018883,0.010446,0.014745,0.001268,0.004635,0.003175,0.000946,0.004142,0.002215,0.000862,0.002500,0.001973,0.001800,0.000634,0.001025,0.001812,0.001970,0.001697,0.001360,0.000855,0.000747,0.001079,0.000849,0.000880,0.000574,0.000730,0.000688,0.000981,0.000337,0.000974,0.000733,0.000756,0.000555,0.000861,0.000545,0.000749,0.000475,0.000535,0.000441,0.000525,0.000483,0.000584,0.000565,0.000414,0.000551,0.000370,0.000472,0.000237,0.000446,0.000374,0.000619,0.000426,0.000403,0.000396,0.000408,0.000394,0.000340,0.000296,0.000324,0.000299,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted67 ftgen 0,0,4096,10,0.904104,0.687203,0.074239,0.008596,0.008832,0.003406,0.003870,0.000671,0.001852,0.001635,0.001087,0.000499,0.001292,0.000964,0.000856,0.000780,0.000614,0.000711,0.000618,0.000934,0.000903,0.000581,0.000840,0.000399,0.000489,0.000328,0.000505,0.000515,0.000432,0.000365,0.000364,0.000454,0.000390,0.000377,0.000361,0.000314,0.000378,0.000357,0.000330,0.000270,0.000342,0.000244,0.000217,0.000204,0.000235,0.000181,0.000230,0.000167,0.000212,0.000212,0.000203,0.000218,0.000163,0.000210,0.000170,0.000173,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted69 ftgen 0,0,4096,10,0.944934,0.293223,0.066919,0.017808,0.007234,0.002307,0.002545,0.000739,0.000556,0.000511,0.000549,0.000723,0.000242,0.000601,0.000453,0.000316,0.000324,0.000312,0.000164,0.000264,0.000131,0.000093,0.000233,0.000211,0.000152,0.000187,0.000090,0.000233,0.000171,0.000154,0.000116,0.000082,0.000095,0.000121,0.000103,0.000074,0.000094,0.000088,0.000098,0.000122,0.000105,0.000080,0.000084,0.000079,0.000074,0.000104,0.000062,0.000071,0.000065,0.000064,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
giUnmuted70 ftgen 0,0,4096,10,0.943312,0.441802,0.052080,0.022643,0.001043,0.002473,0.002554,0.002310,0.001720,0.000881,0.001191,0.001619,0.000857,0.000858,0.001539,0.000697,0.000554,0.000498,0.000409,0.000174,0.000105,0.000147,0.000252,0.000549,0.000348,0.000262,0.000426,0.000336,0.000226,0.000305,0.000193,0.000333,0.000263,0.000183,0.000164,0.000171,0.000202,0.000221,0.000188,0.000137,0.000129,0.000098,0.000100,0.000144,0.000071,0.000094,0.000086,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000
;GEN02 TABLE CONTAINING THE FUNCTION TABLE NUMBERS OF THE TABLES BETWEEN WHICH MORPHING WILL TAKE PLACE
giwavemapUnmuted ftgen 0,0,128,-27, 0,0, 22,0, 23,1, 24,2, 25,3, 26,4, 27,5, 28,6, 30,7, 31,8, 32,9, 33,10, 34,11, 35,12, 37,13, 38,14, 39,15, 40,16, 41,17, 42,18, 43,19, 44,20, 45,21, 46,22, 48,23, 49,24, 50,25, 51,26, 52,27, 53,28, 55,29, 56,30, 57,31, 58,32, 59,33, 60,34, 61,35, 62,36, 63,37, 64,38, 65,39, 67,40, 69,41, 70,42, 127,42
gitabs4morfUnmuted ftgen 0,0,64,-2, giUnmuted22,giUnmuted23,giUnmuted24,giUnmuted25,giUnmuted26,giUnmuted27,giUnmuted28,giUnmuted30,giUnmuted31,giUnmuted32,giUnmuted33,giUnmuted34,giUnmuted35,giUnmuted37,giUnmuted38,giUnmuted39,giUnmuted40,giUnmuted41,giUnmuted42,giUnmuted43,giUnmuted44,giUnmuted45,giUnmuted46,giUnmuted48,giUnmuted49,giUnmuted50,giUnmuted51,giUnmuted52,giUnmuted53,giUnmuted55,giUnmuted56,giUnmuted57,giUnmuted58,giUnmuted59,giUnmuted60,giUnmuted61,giUnmuted62,giUnmuted63,giUnmuted64,giUnmuted65,giUnmuted67,giUnmuted69,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70,giUnmuted70


gisaw ftgen 0,0,4096,11,80,1,0.9
gisquare ftgen 0,0,4096,10, 1,0, 1/3,0, 1/5,0, 1/7,0, 1/9,0, 1/11,0, 1/13,0, 1/15,0, 1/17,0, 1/19,0, 1/21,0, 1/23,0, 1/25,0, 1/27,0, 1/29,0, 1/31,0, 1/33,0, 1/35,0, 1/37,0, 1/39
giorg ftgen 0,0,4096,9, 1,1,rnd(1), 2,1/2,rnd(1), 4,1/4,rnd(1), 8,1/8,rnd(1), 16,1/16,rnd(1), 32,1/32,rnd(1), 64,1/64,rnd(1), 128,1/128,rnd(1)
gieee ftgen 0,0,4096,10, 0.430487,0.778043,0.090552,0.011467,0.030632,0.017911,0.006520,0.006820,0.007109,0.006437,0.008527,0.009083,0.016774,0.058922,0.070507,0.116728,0.045479,0.060107,0.069023,0.036487,0.047350,0.049526,0.036678,0.022550,0.022550
giooh ftgen 0,0,4096,10, 0.110941,0.606890,0.046168,0.040510,0.031310,0.007323,0.003115,0.002749,0.002420,0.002253,0.002853,0.002337,0.002672,0.002061,0.002202,0.002410,0.002615,0.005079,0.003192,0.002699,0.003708,0.003501,0.002264,0.001713,0.001713

gicos ftgen 0,0,4096,11,1 ;COSINE WAVE (USED BY THE LFOS)
gieqffn ftgen 0,0,4097,7,-1,4096,1
gieqlfn ftgen 0,0,4097,7,-1,4096,1
gieqqfn ftgen 0,0,4097,7,-1,4096,1

gasendL,gasendR init 0

opcode sspline,k,Kiii
kdur,istart,iend,icurve xin ;READ IN INPUT ARGUMENTS
imid = istart+((iend-istart)/2) ;SPLINE MID POINT VALUE
isspline ftgentmp 0,0,4096,-16,istart,4096*0.5,icurve,imid,(4096/2)-1,-icurve,iend ;GENERATE 'S' SPLINE
kspd = i(kdur)/kdur ;POINTER SPEED AS A RATIO (WITH REFERENCE TO THE ORIGINAL DURATION)
kptr init 0 ;POINTER INITIAL VALUE
kout tablei kptr,isspline ;READ VALUE FROM TABLE
kptr limit kptr+((ftlen(isspline)/(i(kdur)*kr))*kspd), 0, ftlen(isspline)-1 ;INCREMENT THE POINTER BY THE REQUIRED NUMBER OF TABLE POINTS IN ONE CONTROL CYCLE AND LIMIT IT BETWEEN FIRST AND LAST TABLE POINT - FINAL VALUE WILL BE HELD IF POINTER ATTEMPTS TO EXCEED TABLE DURATION
xout kout ;SEND VALUE BACK TO CALLER INSTRUMENT
endop

instr ReadWidgets
kporttime linseg 0,0.001,0.1

;OSCILLATOR
gkamp chnget "amp"
gkNOscs chnget "NOscs"
gkfmd chnget "fmd"
gkmvt chnget "mvt"
gkwaveform chnget "waveform"
gkwaveform init 1
gkwidth chnget "width"
gkWTableShift chnget "WTableShift"
gkBendDown chnget "BendDown"
gkBendUp chnget "BendUp"
gkBendRange chnget "BendRange"
gkPchBend portk (gkBendDown+gkBendUp)*gkBendRange, kporttime
gkWTableShift portk gkWTableShift, kporttime
gkFiltLayers chnget "FiltLayers"

gkFlfoType chnget "FlfoType" ;
gkFRte chnget "FRte" ;
gkFDep chnget "FDep" ;
gkFDel chnget "FDel" ;
gkFRis chnget "FRis" ;

gkcfoct chnget "cf"
gkFEnvAmt chnget "FEnvAmt"
gkFAtt chnget "FAtt"
gkFDec chnget "FDec"
gkFSus chnget "FSus"
gkFRel chnget "FRel"

gkRvbMix chnget "RvbMix"

gkAAtt chnget "AAtt"
gkADec chnget "ADec"
gkASus chnget "ASus"
gkARel chnget "ARel"
endin

instr 1
ilegato chnget "legato"
gkNoteTrig init 1 ;at the beginning of a new note set note trigger flag to '1'
inum notnum
gknum = inum
givel veloc 0,1 ;read in midi note velocity

if ilegato==0 then ;if we are *not* in legato mode...
aL,aR subinstr p1+1,inum ;call voice instrument as a subinstrument. Audio will be fed back to this instrument before being sent to the outputs.
outs aL,aR ;send audio to outputs
else ;otherwise... (i.e. legato mode)
iactive active p1+1 ;check to see if these is already a note active...
if iactive==0 then ;...if not...
event_i "i",p1+1,0,-1 ;...start a new held note
endif
endif
endin

instr 2
ilegato chnget "legato"
kLegTim chnget "LegTim"
kmono chnget "mono"
kporttime linseg 0,0.001,1 ;portamento time function rises quickly from zero to a held value
kglisstime = kporttime*kLegTim ;scale portamento time function with value from GUI knob widget
if ilegato==1 then ;if we are in legato mode...

ktrig changed gknum ;...GENERATE A TRIGGER IS A NEW NOTE NUMBER IS GENERATED (FROM INSTR. 1)
gkOldNum init i(gknum) ;OLD NOTE NUMBER = FIRST NOTE NUMBER UPON INITIAL NOTE BEING PLAYED
if ktrig=1 then ;IF A NEW (LEGATO) NOTE HAS BEEN PRESSED
reinit S_CURVE_2 ;BEGIN A REINITIALISATION PASS FROM LABEL
endif ;END OF CONDITIONAL BRANCH
S_CURVE_2: ;A LABEL. REINITIALISATION BEGINS FROM HERE.
idiff = 1+abs(i(gknum)-i(gkOldNum)) ;ABSOLUTE DIFFERENCE BETWEEN OLD NOTE AND NEW NOTE IN STEPS (+ 1)
knum sspline (kglisstime*idiff)+ksmps/sr,i(gkOldNum),i(gknum),2;CALL sspline UDO (PORTASMENTO TIME MULTIPLIED BY NOTE GAP (idiff))
rireturn ;RETURN FROM INITIALISATION PASS
gkOldNum = knum ;SET OLD NUMBER CURRENT NUMBER

kactive active p1-1 ;...check number of active midi notes (previous instrument)
if kactive==0 then ;if no midi notes are active...
turnoff ;... turn this instrument off
endif
else ;otherwise... (polyphonic / non-legato mode)
knum = p4
endif

knum = knum + gkPchBend ;add pitch bend
;AMPLITUDE ENVELOPE
aenv linsegr 0.001,i(gkAAtt)+0.001,1,i(gkADec)+0.001,i(gkASus),i(gkARel)+0.001,0.001 ;AMPLITUDE ENVELOPE
aenv = aenv-0.001
;FILTER AND FILTER ENVELOPE
kFEnv linsegr 0,i(gkFAtt)+0.001,1,i(gkFDec)+0.001,i(gkFSus),i(gkFRel)+0.001,0
kFEnv = kFEnv * gkFEnvAmt

;FILTER LFO
kdepth linseg 0,i(gkFDel)+0.001,0,i(gkFRis)+0.001,1 ;DEPTH OF MODULATION ENVELOPE
if gkFlfoType==1 then
kFLFO lfo kdepth*gkFDep,gkFRte,0 ;LFO (sine)
elseif gkFlfoType==2 then
kFLFO jspline kdepth*gkFDep,gkFRte,gkFRte
elseif gkFlfoType==3 then
kFLFO randomh -kdepth*gkFDep,kdepth*gkFDep,gkFRte
kFLFO port kFLFO,0.004 ;smooth out the clicks
else
kFLFO lfo kdepth*gkFDep,gkFRte,2 ;LFO (bi-square)
kFLFO port kFLFO,0.004 ;smooth out the clicks
endif

kCFoct limit 4+kFEnv+gkcfoct+kFLFO,4,14
kCF = cpsoct(kCFoct)
ivel veloc 0,0.1 ;READ IN NOTE VELOCITY
if i(gkwaveform)==6 then
giwavemap = giwavemapClar
gitabs4morf = gitabs4morfClar
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==7 then
giwavemap = giwavemapBClar
gitabs4morf = gitabs4morfBClar
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==8 then
giwavemap = giwavemapCBClar
gitabs4morf = gitabs4morfCBClar
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==9 then
giwavemap = giwavemapOboe
gitabs4morf = gitabs4morfOboe
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==10 then
giwavemap = giwavemapBassoon
gitabs4morf = gitabs4morfBassoon
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==11 then
giwavemap = giwavemapCBassoon
gitabs4morf = gitabs4morfCBassoon
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==12 then
giwavemap = giwavemapViolin
gitabs4morf = gitabs4morfViolin
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==13 then
giwavemap = giwavemapCello
gitabs4morf = gitabs4morfCello
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==14 then
giwavemap = giwavemapPiccolo
gitabs4morf = gitabs4morfPiccolo
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==15 then
giwavemap = giwavemapFlute
gitabs4morf = gitabs4morfFlute
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==16 then
giwavemap = giwavemapAFlute
gitabs4morf = gitabs4morfAFlute
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==17 then
giwavemap = giwavemapBFlute
gitabs4morf = gitabs4morfBFlute
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==18 then
giwavemap = giwavemapAhh
gitabs4morf = gitabs4morfAhh
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==19 then
giwavemap = giwavemapHornP
gitabs4morf = gitabs4morfHornP
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==20 then
giwavemap = giwavemapHornF
gitabs4morf = gitabs4morfHornF
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==21 then
giwavemap = giwavemapharmon
gitabs4morf = gitabs4morfharmon
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==22 then
giwavemap = giwavemapMute1
gitabs4morf = gitabs4morfMute1
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
elseif i(gkwaveform)==23 then
giwavemap = giwavemapUnmuted
gitabs4morf = gitabs4morfUnmuted
imorphtab ftgentmp 0,0,4096,10,1
kndx limit knum+gkWTableShift,0,127
kftndx tablei kndx,giwavemap ;ftndx REMAPPED ACCORDING TO THE WAVETABLE MAP FOR THIS INSTRUMENT
ftmorf kftndx, gitabs4morf, imorphtab ;CREATE THE MORHED TABLE ACCORDING TO THE VALUE OF THE FUNCTION TABLE INDEX CREATED ABOVE
kwave = imorphtab
else
kwave = gisaw+gkwaveform-1 ;DERIVE FUNCTION TABLE NUMBER OF WAVEFORM FOR THE OSCILLATORS
endif

ktrig changed gkNOscs,kmono ;IF ANY OF THE CONTROLS WHICH MUST BE ENTERED AS I-RATE CONTROLLERS HAVE CHANGED GENERATE A TRIGGER IMPULSE AT THE OUTPUT
if ktrig==1 then ;IF ANY I-RATE CONTROL HAS CHANGED...
reinit UPDATE ;BEGIN A RE-INITILISATION PASS FROM LABEL 'UPDATE'
endif
UPDATE: ;BEGIN REINIT PASS FROM HERE
kmvt jspline gkmvt,gkmvt,gkmvt
kcps = cpsmidinn(knum)

if i(kmono)==1 then
;OUTPUT OPCODE CPS | AMD | FMD | PMD | OVERLAPS | SEED | L1MINF | L1MAXF | L2MINF | L2MAXF | LFOMODE | EQMINF | EQMAXF | EQMINL | EQMAXL | EQMINQ | EQMAXQ | EQMODE | KFN | L1FN | L2FN | EQFFN | EQLF | EQQFN | TABL | OUTFN
aL oscbnk kcps, 0, gkfmd*kcps, 0, i(gkNOscs), rnd(1), 0, kmvt, 0, 0, 238, 0, 8000, 1, 1, 1, 1, -1, kwave, gicos, gicos, gieqffn, gieqlfn, gieqqfn
aR = aL
else
;TWO ITERATIONS OF oscbnk ARE CREATED, ONE FOR EACH OF THE STEREO AUDIO CHANNELS. THE OUTPUTS WILL BE DIFFERENT AS THE RANDOM NUMBER GENERATORS WILL BE SEEDED BY THE SYSTEM CLOCK
;OUTPUT OPCODE CPS | AMD | FMD | PMD | OVERLAPS | SEED | L1MINF | L1MAXF | L2MINF | L2MAXF | LFOMODE | EQMINF | EQMAXF | EQMINL | EQMAXL | EQMINQ | EQMAXQ | EQMODE | KFN | L1FN | L2FN | EQFFN | EQLF | EQQFN | TABL | OUTFN
aL oscbnk kcps, 0, gkfmd*kcps, 0, i(gkNOscs), rnd(1), 0, kmvt, 0, 0, 238, 0, 8000, 1, 1, 1, 1, -1, kwave, gicos, gicos, gieqffn, gieqlfn, gieqqfn
aR oscbnk kcps, 0, gkfmd*kcps, 0, i(gkNOscs), rnd(1), 0, -kmvt, 0, 0, 238, 0, 8000, 1, 1, 1, 1, -1, kwave, gicos, gicos, gieqffn, gieqlfn, gieqqfn
aL ntrpol (aL+aR)*0.66,aL,gkwidth
aR ntrpol (aL+aR)*0.66,aR,gkwidth
endif
rireturn ;RETURN FROM REINIT PASS

;aL clfilt aL, kCF,0,2
;aR clfilt aR, kCF,0,2

ktrig changed gkFiltLayers
if ktrig=1 then
reinit RESTART_TONEX
endif
RESTART_TONEX:
aL tonex aL, kCF,i(gkFiltLayers)
aR tonex aR, kCF,i(gkFiltLayers)
rireturn
aL = aL*aenv*ivel*gkamp
aR = aR*aenv*ivel*gkamp
outs aL, aR ;SEND AUDIO TO THE OUTPUTS. RESCALE EACH CHANNEL WITH NOTE VELOCITY, AMPLITUDE ENVELOPE AND AMP CONTROL WIDGET.
gasendL = gasendL+(aL*gkRvbMix)
gasendR = gasendR+(aR*gkRvbMix)
endin

instr 4 ;reverb
gkRvbSize chnget "RvbSize"
if gkRvbMix==0 goto SKIP_REVERB
aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000
outs aL,aR
SKIP_REVERB:
clear gasendL,gasendR
endin

</CsInstruments>

<CsScore>
i "ReadWidgets" 0 [3600*24*7]
i 4 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 127
- 0
bin/cabbage-todo/Synths/sonic_lava_lamp.csd View File

@@ -0,0 +1,127 @@
<Cabbage>
form caption("Sonic Lava Lamp") size(510, 450), pluginID("sonl")
image bounds( 5, 0,250, 210), colour(255,255, 50,100),shape("rounded"), outline("white"), line(0)
image bounds(255, 0,250, 210), colour( 0, 0,255,100),shape("rounded"), outline("white"), line(0)
image bounds( 5,210,250, 210), colour( 5,255, 0,100),shape("rounded"), outline("white"), line(0)
image bounds(255,210,250, 210), colour(255, 0,200,100),shape("rounded"), outline("white"), line(0)

xypad bounds(5, 0, 250, 210), channel("LFOspeed", "LFO_OS"), rangex(0, 1.00, 0.01), rangey(5, 11, 8), text("Speed/OS")
xypad bounds(255, 0, 250, 210), channel("LFOshape", "LFOdepth"), rangex(0, 1, 0.7), rangey(0.1, 4, 2), text("Shape/Depth")
xypad bounds(5, 210, 250, 210), channel("pan", "amp"), rangex(0, 1, 0.5), rangey(0, 1, 0.8), text("pan/amp")
xypad bounds(255, 210, 250, 210), channel("DelTim", "DelSnd"), rangex(0, 1.00, 0.5), rangey(0, 1.00, 0.5), text("Delay Time/Send")
infobutton bounds(5,425, 100, 20), text("Help"), file("SonicLavaLampHelp.html")
image bounds(105, 425, 315, 20), colour(75, 85, 90, 100), plant("credit"), line(0){
label bounds(0.03, 0.1, .6, .7), text("Author: Iain McCurdy |2012|"), colour("white")
}
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)

gisine ftgen 0, 0, 4096, 10, 1 ;SINE WAVE
giSawUp ftgen 0, 0, 4096, -7, -1, 4096, 1
giTri ftgen 0, 0, 4096, -7, -1, 2048, 1, 2048, -1
giSawDn ftgen 0, 0, 4096, -7, 1, 4096, -1
giSq ftgen 0, 0, 4096, -7, 1, 2048, 1, 0, -1, 2048, -1
giMorfTab ftgen 0, 0, 4096, -7, 1, 2048, 1, 0, -1, 2048, -1
giTabs4Morf ftgen 0, 0, 8, -2, giSq, giSawUp, giTri, giSawDn, giSq, giSq, giSq, giSq
giAmpCurve ftgen 0, 0, 16, -16, 1, 6, 0, 1, 5, -4, 0.2, 5, 0, 0.2
giEnv ftgen 0, 0, 4096, 20,3,1 ;9, 0.5, 1, 0

opcode PingPongDelay, aa,aakk
ainL,ainR,ktime,kfeedback xin
atime interp ktime ;INTERPOLATED A-RATE VERSION OF DELAY TIME
aL_OS vdelay ainL,(atime*1000)/2,(10*1000)/2 ;DELAYED OFFSET OF LEFT CHANNEL (FIRST 'PING')
;LEFT CHANNEL
abuf delayr 10 ;ESTABLISH DELAY BUFFER
aDelL deltapi atime ;TAP BUFFER
delayw aL_OS+(aDelL*kfeedback) ;WRITE INPUT AUDIO INTO BUFFER
;RIGHT CHANNEL
abuf delayr 10 ;ESTABLISH DELAY BUFFER
aDelR deltapi atime ;TAP BUFFER
delayw ainR+(aDelR*kfeedback) ;WRITE INPUT AUDIO INTO BUFFER
xout aDelL+aL_OS,aDelR
endop

instr InitialiseXYpads
; xypads output zeroes until they are moved (regardless of any initialisation done within the widget)
; a workaround is to initialise the xypad using chnset within an instrument
; here I have used a macro so cut down on code repetition
#define SET_XYPAD_INIT(NAME'VAL)#
kval = $VAL
chnset kval,"$NAME"#
$SET_XYPAD_INIT(LFOspeed'0.01)
$SET_XYPAD_INIT(LFO_OS'8)
$SET_XYPAD_INIT(LFOshape'0.7)
$SET_XYPAD_INIT(LFOdepth'2)
$SET_XYPAD_INIT(pan'0.5)
$SET_XYPAD_INIT(amp'0.8)
$SET_XYPAD_INIT(DelTim'0.5)
$SET_XYPAD_INIT(DelSnd'0.5)
endin

instr 1
kLFOspeed chnget "LFOspeed"
kLFO_OS chnget "LFO_OS"
kLFOshape chnget "LFOshape"
kLFOdepth chnget "LFOdepth"
kamp chnget "amp"
kpan chnget "pan"
kDelTim chnget "DelTim"
kDelSnd chnget "DelSnd"

kLFOspeed expcurve kLFOspeed,6
kLFOspeed scale kLFOspeed, 40,0.01
kDelTim expcurve kDelTim,6
kDelTim scale kDelTim, 0.5,0.01

kporttime linseg 0,0.01,0.03
kDelSnd portk kDelSnd,kporttime*3
kLFOdepth portk kLFOdepth,kporttime
kLFO_OS portk kLFO_OS,kporttime
kLFOshape portk kLFOshape,kporttime
kamp portk kamp,kporttime
kamp expcurve kamp,2
kpan portk kpan,kporttime
ftmorf kLFOshape*5, giTabs4Morf, giMorfTab
aoctLFO oscili kLFOdepth,kLFOspeed,giMorfTab
aoct = aoctLFO+kLFO_OS
koct downsamp aoct
kAmpCurve tablei koct,giAmpCurve
kcps = cpsoct(koct)
aamp interp kAmpCurve/3
asig oscili aamp,kcps,gisine ;AUDIO OSCILLATOR
aenv oscili 1,kLFOspeed,giEnv
kEnvXFade jspline 1,0.2,0.6
kEnvXFade limit kEnvXFade,0,1
asig ntrpol asig*aenv,asig,kEnvXFade

aL,aR pan2 asig,kpan
aRvbL,aRvbR reverbsc aL,aR,0.8,4000
aL sum (aL*kamp),(aRvbL*0.1)
aR sum (aR*kamp),(aRvbR*0.1)
kDelTim portk kDelTim,kporttime*10
aDlyL,aDlyR PingPongDelay aL*kDelSnd,aR*kDelSnd,2*kDelTim,0.6
aL sum aL,(aDlyL*0.5)
aR sum aR,(aDlyR*0.5)

outs aL, aR
endin

</CsInstruments>

<CsScore>
i "InitialiseXYpads" 0 0.01
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 100
- 0
bin/cabbage/Effects/EnvelopeFollower.csd View File

@@ -0,0 +1,100 @@
<Cabbage>
form caption("Envelope Follower") size(440, 100), pluginID("envf")
image pos(0, 0), size(440, 100), colour("brown"), shape("rounded"), outline("white"), line(4)
checkbox bounds(15, 70, 15, 15), channel("lev1"), value(0), colour(200,220,0,255),shape("ellipse")
checkbox bounds(15, 55, 15, 15), channel("lev2"), value(0), colour(250,190,0,255),shape("ellipse")
checkbox bounds(15, 40, 15, 15), channel("lev3"), value(0), colour(255,120,0,255),shape("ellipse")
checkbox bounds(15, 25, 15, 15), channel("lev4"), value(0), colour(255, 60,0,255),shape("ellipse")
checkbox bounds(15, 10, 15, 15), channel("lev5"), value(0), colour(255, 0,0,255),shape("ellipse")
rslider bounds( 40, 11, 75, 75), text("Sensitivity"), channel("sens"), range(0, 1, 0.65), colour(255,100,100), fontcolour(255,255,200)
rslider bounds(110, 6, 45, 45), text("Att."), channel("att"), range(0.001, 0.5, 0.01, 0.5, 0.001), colour(255,200,100), fontcolour(255,255,200)
rslider bounds(110, 51, 45, 45), text("Dec."), channel("rel"), range(0.001, 0.5, 0.2, 0.5, 0.001), colour(255,200,100), fontcolour(255,255,200)
rslider bounds(150, 11, 75, 75), text("Frequency"), channel("freq"), range(10, 10000, 1000, 0.5), colour(255,100,100), fontcolour(255,255,200)
rslider bounds(220, 11, 75, 75), text("Resonance"), channel("res"), range(0, 1, 0.75), colour(255,100,100), fontcolour(255,255,200)
rslider bounds(290, 11, 75, 75), text("Distortion"), channel("dist"), range(0, 1.00, 0), colour(255,100,100), fontcolour(255,255,200)
rslider bounds(360, 11, 75, 75), text("Level"), channel("level"), range(0, 1.00, 1), colour(255,200,100), fontcolour(255,255,200)
}
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)

opcode EnvelopeFollower,a,akkkkkk
ain,ksens,katt,krel,kfreq,kres,kdist xin ;READ IN INPUT ARGUMENTS
setksmps 4
; ATTCK.REL. - ADJUST THE RESPONSE OF THE ENVELOPE FOLLOWER HERE
aFollow follow2 ain, katt, krel ;AMPLITUDE FOLLOWING AUDIO SIGNAL
kFollow downsamp aFollow ;DOWNSAMPLE TO K-RATE
kFollow expcurve kFollow/0dbfs,0.5 ;ADJUSTMENT OF THE RESPONSE OF DYNAMICS TO FILTER FREQUENCY MODULATION
kFrq = kfreq + (kFollow*ksens*10000) ;CREATE A LEFT CHANNEL MODULATING FREQUENCY BASE ON THE STATIC VALUE CREATED BY kfreq AND THE AMOUNT OF DYNAMIC ENVELOPE FOLLOWING GOVERNED BY ksens
kFrq limit kFrq, 20,sr/2 ;LIMIT FREQUENCY RANGE TO PREVENT OUT OF RANGE FREQUENCIES
aout lpf18 ain, kFrq, kres, kdist ;REDEFINE AUDIO SIGNAL AS FILTERED VERSION OF ITSELF
xout aout ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

opcode SwitchPort, k, kii
kin,iupport,idnport xin
kold init 0
kporttime = (kin<kold?idnport:iupport)
kout portk kin, kporttime
kold = kout
xout kout
endop

instr 1
ksens chnget "sens"
katt chnget "att"
krel chnget "rel"
kfreq chnget "freq"
kres chnget "res"
kdist chnget "dist"
klevel chnget "level"
a1,a2 ins
;a1,a2 diskin2 "808loop.wav",1,0,1
;a1 = a1*0.4
;a2 = a2*0.4


/*level meter*/
amix sum a1,a2
krms rms amix*0.5
krms pow krms,0.75
krms SwitchPort krms,0.01,0.2
kon = 1
koff = 0
#define INDICATOR(LEV'N)
#
kOnTrig trigger krms,$LEV^1.5,0
kOffTrig trigger krms,$LEV^1.5,1
if kOnTrig==1 then
chnset kon,"lev$N"
elseif kOffTrig==1 then
chnset koff,"lev$N"
endif
#
$INDICATOR(1/6'1)
$INDICATOR(2/6'2)
$INDICATOR(3/6'3)
$INDICATOR(4/6'4)
$INDICATOR(5/6'5)

a1 EnvelopeFollower a1,ksens,katt,krel,kfreq,kres*0.95,kdist*100
a2 EnvelopeFollower a2,ksens,katt,krel,kfreq,kres*0.95,kdist*100
a1 = a1 * klevel * (1 - ((kdist*0.3)^0.02)) ;scale amplitude according to distortion level (to compensate for gain increases it applies)
a2 = a2 * klevel * (1 - ((kdist*0.3)^0.02))
outs a1,a2
endin

</CsInstruments>
<CsScore>
i 1 0 [60*60*24*7]
</CsScore>
</CsoundSynthesizer>

+ 263
- 0
bin/cabbage/Effects/FrequencyShifter.csd View File

@@ -0,0 +1,263 @@
; FrequencyShifter.csd
; Iain McCurdy, 2013.
;
; Frequency shifting using the hilbert filter
;
; CONTROLS
; --------
; Input -- Choose audio input: Live, sine tone or pink noise
; Polarity -- 3 options: 'Positive' = multiply 'Freq.' by 1, 'Negative' = multiply 'Freq.' by -1, 'Dual' = sum of 'Positive' and 'Negative' outputs
; Mix -- Dry/Wet mix control
; Freq. -- Principle frequency of the shifting frequency (before modulation by other controls)
; Mult. -- multipler of shifting frequency. Can be useful for finer control of shifting frequency around zero.
; Feedback -- Amount of frequency shifter that is fed back into its input
; Level -- Output level
; Dual Mono / Stereo -- 'Dual Mono' = both channels treated in the same way. 'Stereo' = right channel 180 degrees out of phase with respect to the left
; Stereo mode most apparent if shifting frequency is close to zero
; zero freq -- set 'Freq.' to zero
; [LFO~]
; Modulate Frequency -- Switch to activate LFO modulation of shifting frequency
; Shape -- Shape of the LFO: sine / triangle / square / random sample and hold / random splines
; Rate -- Rate of LFO (in hertz)
; Min -- Minimum frequency of the LFO modulation
; Max -- Maximum frequency of the LFO modulation
; Pan Mod -- Amount of panning modulation (strictly speaking, stereo balance modulation). Rate of modulation governed also by 'Rate'
; Sync LFO -- Restart LFO. Can be useful if 'random spline' modulation becomes 'stuck' at a low frequency


<Cabbage>
form caption("Time Domain Frequency Shifter") size(500,180), pluginID("fshi")
image bounds( 0, 0, 500,180), colour("darkslategrey"), outline("silver"), line(6), shape("rounded")
label bounds(22, 7, 60, 11), text("INPUT"), fontcolour("white")
combobox bounds(10, 18, 65, 20), channel("input"), value(1), text("Live","Tone","Noise")
label bounds(14, 42, 60, 11), text("POLARITY"), fontcolour("white")
combobox bounds(10, 53, 65, 20), channel("polarity"), value(1), text("Positive","Negative","Dual")
rslider bounds( 75, 10, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 0.5), colour("darkslategrey"), fontcolour("white), tracker("yellow")
rslider bounds(145, 10, 70, 70), text("Freq."), channel("freq"), range(-4000, 4000, -50), colour("darkslategrey"), fontcolour("white), tracker("yellow")
rslider bounds(215, 10, 70, 70), text("Mult."), channel("mult"), range(-1, 1.00, 0.1), colour("darkslategrey"), fontcolour("white), tracker("yellow")
rslider bounds(285, 10, 70, 70), text("Feedback"), channel("fback"), range(0, 0.75, 0.6), colour("darkslategrey"), fontcolour("white), tracker("yellow")
rslider bounds(355, 10, 70, 70), text("Level"), channel("level"), range(0, 1.00, 1), colour("darkslategrey"), fontcolour("white), tracker("yellow")

checkbox bounds(425, 20, 12, 12), channel("r1") fontcolour("white") colour(yellow) value(1)
checkbox bounds(425, 32, 12, 12), channel("r2") fontcolour("white") colour(yellow)
label bounds(438, 21, 60, 9), text("DUAL MONO"), fontcolour("white")
label bounds(438, 33, 60, 9), text("STEREO"), fontcolour("white")

button bounds(425, 50, 65, 20), colour("Green"), text("Zero Freq", "Zero Freq"), channel("Zerofreq"), value(0)

line bounds( 10, 90, 480, 2), colour("Grey")
checkbox bounds( 10,100,150, 20), channel("ModOnOff") text("LFO Modulate Freq."), fontcolour("white") colour(lime) value(0)
label bounds( 30,127, 75, 11), text("SHAPE"), fontcolour("white")
combobox bounds( 10,138, 85, 20), channel("LFOShape"), value(7), text("Sine","Triangle","Square","Saw Up","Saw Down","Rand.S&H","Rand.Spline")
rslider bounds( 145,100, 70, 70), text("Rate"), channel("LFORate"), range(0, 30, 1.5, 0.5, 0.001), colour("lightslategrey"), fontcolour("white), tracker("yellow")
rslider bounds( 215,100, 70, 70), text("Min"), channel("LFOMin"), range(-2000, 2000, -600), colour("lightslategrey"), fontcolour("white), tracker("yellow")
rslider bounds( 285,100, 70, 70), text("Max"), channel("LFOMax"), range(-2000, 2000, 600), colour("lightslategrey"), fontcolour("white), tracker("yellow")
rslider bounds( 355,100, 70, 70), text("Pan Mod."), channel("PanSpread"),range(0, 1.00, 1), colour("lightslategrey"), fontcolour("white), tracker("yellow")
button bounds(425,100, 65, 20), colour("Green"), text("Sync LFO", "Sync LFO"), channel("SyncLFO"), value(0)

</Cabbage>
<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Iain McCurdy, 2012
;http://iainmccurdy.org/csound.html
;Frequency shifter effect based around the hilbert filter.

gisine ftgen 0,0,4096,10,1 ;A SINE WAVE SHAPE
gicos ftgen 0,0,4096,11,1 ;A COSINE WAVE SHAPE
gishapes ftgen 0,0,8,-2,0,1,2,4,5

opcode FreqShifter,a,akkkki
adry,kmix,kfreq,kmult,kfback,ifn xin ;READ IN INPUT ARGUMENTS
iWet ftgenonce 0,0,1024,-7,0,512,1,512,1 ;RESCALING FUNCTION FOR WET LEVEL CONTROL
iDry ftgenonce 0,0,1024,-7,1,512,1,512,0 ;RESCALING FUNCTION FOR DRY LEVEL CONTROL
kWet table kmix, iWet, 1 ;RESCALE WET LEVEL CONTROL ACCORDING TO FUNCTION TABLE giWet
kDry table kmix, iDry, 1 ;RESCALE DRY LEVEL CONTROL ACCORDING TO FUNCTION TABLE giWet
aFS init 0 ;INITILISE FEEDBACK SIGNAL (FOR FIRST K-PASS)
ain = adry + (aFS * kfback) ;ADD FEEDBACK SIGNAL TO INPUT (AMOUNT OF FEEDBACK CONTROLLED BY 'Feedback Gain' SLIDER)
areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
kfshift = kfreq*kmult
;QUADRATURE OSCILLATORS. I.E. 90 OUT OF PHASE WITH RESPECT TO EACH OTHER
;OUTUTS OPCODE AMPLITUDE | FREQ. | FUNCTION_TABLE | INITIAL_PHASE (OPTIONAL;DEFAULTS TO ZERO)
asin oscili 1, kfshift, ifn, 0
acos oscili 1, kfshift, ifn, 0.25
;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
amod1 = areal * acos
amod2 = aimag * asin
;UPSHIFTING OUTPUT
aFS = (amod1 - amod2)
aout sum aFS*kWet, adry*kDry ;CREATE WET/DRY MIX
xout aout ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop


opcode CabbageRadio2,k,SS ; change opcode name and number is string variable inputs
S1,S2 xin ; add string inputs for the required number of inputs
kon = 0
koff = 0
ksum = 0
ktrigsum = 0
#define READ_CHANGES(NAME) #
k$NAME chnget $NAME
ksum = ksum + k$NAME
kon$NAME trigger k$NAME,0.5,0
ktrigsum = ktrigsum + kon$NAME#

#define WRITE_CHANGES(NAME'COUNT) #
if kon$NAME!=1 then
chnset koff,$NAME
else
kval = $COUNT
endif#

$READ_CHANGES(S1)
$READ_CHANGES(S2) ; add macro expansions for the required number of radio buttons

if ktrigsum>0 then

$WRITE_CHANGES(S1'1)
$WRITE_CHANGES(S2'2) ; add macro expansions for the required number of radio buttons

endif

kval = (ksum=0?0:kval)
xout kval
endop


instr 1
kporttime linseg 0,0.001,0.05
koff = 0
kmix chnget "mix" ; read input widgets
kfreq chnget "freq"
kfreq portk kfreq,kporttime
kmult chnget "mult"
kmult portk kmult,kporttime
kfback chnget "fback"
klevel chnget "level"
kpolarity chnget "polarity"
kStereoMode CabbageRadio2 "r1","r2" ; call UDO
kZeroFreq chnget "Zerofreq"
ktrig changed kZeroFreq
if ktrig=1 then
chnset koff,"freq"
endif
kModOnOff chnget "ModOnOff"
kLFOShape chnget "LFOShape"
kLFORate chnget "LFORate"
kLFOMin chnget "LFOMin"
kLFOMax chnget "LFOMax"
kPanSpread chnget "PanSpread"
kSyncLFO chnget "SyncLFO"


/* INPUT */
kinput chnget "input"
if kinput=1 then
a1,a2 ins
elseif kinput=2 then
a1 oscils 0.2, 300, 0
a2 = a1
else
a1 pinkish 0.2
a2 pinkish 0.2
endif



/* LFO */
if kModOnOff=1 then
ktrig changed kLFOShape,kSyncLFO
if ktrig=1 then
reinit RESTART_LFO
endif
RESTART_LFO:
if i(kLFOShape)=6 then
kLFOFreq randomh kLFOMin,kLFOMax,kLFORate
elseif i(kLFOShape)=7 then ; random spline
;kLFOFreq randomi kLFOMin,kLFOMax,kLFORate,1
;kLFOFreq portk kLFOFreq,1/kLFORate
kLFOFreq rspline kLFOMin,kLFOMax,kLFORate,kLFORate*2
else
ishape table i(kLFOShape)-1,gishapes
kLFOFreq lfo 1,kLFORate,ishape
kLFOFreq scale (kLFOFreq*0.5)+0.5,kLFOMin,kLFOMax
endif
rireturn
endif

kfreq = kfreq+kLFOFreq

/* FREQUENCY SHIFTERS */
ktrig changed kStereoMode
if ktrig=1 then
reinit RESTART_FREQUENCY_SHIFTERS
endif
RESTART_FREQUENCY_SHIFTERS:
if kpolarity=1 then ; polarity is positive...
a1 FreqShifter a1,kmix,kfreq,kmult,kfback,gisine
if i(kStereoMode)=2 then
a2 FreqShifter a2,kmix,kfreq,kmult,kfback,gicos ; cosine version
else
a2 FreqShifter a2,kmix,kfreq,kmult,kfback,gisine
endif
elseif kpolarity=2 then ; polarity is negative...
a1 FreqShifter a1,kmix,-kfreq,kmult,kfback,gisine
if i(kStereoMode)=2 then
a2 FreqShifter a2,kmix,-kfreq,kmult,kfback,gicos ; cosine version
else
a2 FreqShifter a2,kmix,-kfreq,kmult,kfback,gisine
endif
else ; polarity is dual...
aa FreqShifter a1,kmix,kfreq,kmult,kfback,gisine ; positive
if i(kStereoMode)=2 then
ab FreqShifter a2,kmix,kfreq,kmult,kfback,gicos ; cosine version
else
ab FreqShifter a2,kmix,kfreq,kmult,kfback,gisine
endif
ac FreqShifter a1,kmix,-kfreq,kmult,kfback,gisine ; negative
if i(kStereoMode)=2 then
ad FreqShifter a2,kmix,-kfreq,kmult,kfback,gicos ; cosine version
else
ad FreqShifter a2,kmix,-kfreq,kmult,kfback,gisine
endif
rireturn

a1 = (aa+ac)*0.5 ; sum positive and negative and attenuate
a2 = (ab+ad)*0.5
endif


/* PANNING */
if kModOnOff=1 then
kpan randomi 0.5-(kPanSpread*0.5),0.5+(kPanSpread*0.5),kLFORate,1
kpan portk kpan,1/kLFORate
a1 = a1 * sin(kpan*$M_PI_2)
a2 = a2 * cos(kpan*$M_PI_2)
;a1 = a1*kpan
;a2 = a2*(1-kpan)
endif



a1 = a1 * klevel ; scale using level control
a2 = a2 * klevel
outs a1,a2
endin

</CsInstruments>
<CsScore>
i 1 0 [60*60*24*7]
</CsScore>
</CsoundSynthesizer>

+ 57
- 0
bin/cabbage/Effects/LoFi.csd View File

@@ -0,0 +1,57 @@
<Cabbage>
form size(230, 120), caption("Lo Fi"), pluginID("lofi")
image pos(-40,-10), size(300,300), colour(0, 130,230,0), shape("ellipse"), outline(200, 30,100, 80), line(70)
image pos( 0, 0), size(300,300), colour(200, 30, 30,0), shape("ellipse"), outline( 0,130, 30, 80), line(70)
image pos( 40, 10), size(300,300), colour(250, 0, 30,0), shape("ellipse"), outline( 0, 0, 30, 50), line(70)
image pos( 80, 20), size(300,300), colour( 0, 0,255,0), shape("ellipse"), outline( 0, 0,255, 50), line(70)
image pos(120, 30), size(300,300), colour( 0,255,255,0), shape("ellipse"), outline( 0,255,255, 50), line(70)
image pos(160, 40), size(300,300), colour(255,255, 0,0), shape("ellipse"), outline(255,255, 0, 50), line(70)
image pos(0, 0), size(230, 120), colour("Chocolate"), shape("rounded"), outline("white"), line(5)
rslider bounds( 5, 31, 80, 80), text("Bits"), channel("bits"), range(1, 16, 16), fontcolour("White"),colour("orange"), tracker("brown")
rslider bounds( 75, 7, 80, 80), text("Foldover"), channel("fold"), range(1, 1024, 0, 0.25), fontcolour("White"),colour("orange"), tracker("brown")
rslider bounds(145, 31, 80, 80), text("Level"), channel("level"), range(0, 1.00, 1), fontcolour("White"),colour("orange"), tracker("brown")
}
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Iain McCurdy, 2012
;http://iainmccurdy.org/csound.html


opcode LoFi,a,akk
ain,kbits,kfold xin ;READ IN INPUT ARGUMENTS
kvalues pow 2, kbits ;RAISES 2 TO THE POWER OF kbitdepth. THE OUTPUT VALUE REPRESENTS THE NUMBER OF POSSIBLE VALUES AT THAT PARTICULAR BIT DEPTH
aout = (int((ain/0dbfs)*kvalues))/kvalues ;BIT DEPTH REDUCE AUDIO SIGNAL
aout fold aout, kfold ;APPLY SAMPLING RATE FOLDOVER
xout aout ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
kbits chnget "bits"
kfold chnget "fold"
klevel chnget "level"
a1,a2 ins
kporttime linseg 0,0.001,0.01
kfold portk kfold,kporttime
a1 LoFi a1,kbits*0.6,kfold
a2 LoFi a2,kbits*0.6,kfold
a1 = a1 * klevel
a2 = a2 * klevel
outs a1,a2
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 121
- 0
bin/cabbage/Effects/Phaser.csd View File

@@ -0,0 +1,121 @@
<Cabbage>
form caption("Phaser") size(580, 90), pluginID("phsr")
image bounds(0, 0, 580, 90), colour( 100, 110, 130), shape("rounded"), outline(black), line(4)
label bounds(29, 8, 60, 10), text("INPUT"), fontcolour(0,10,30)
combobox bounds(10, 18, 70, 20), channel("input"), value(1), text("Live","Tone","Noise")
label bounds(19, 43, 60, 10), text("LFO SHAPE"), fontcolour(0,10,30)
combobox bounds(10, 53, 70, 20), channel("shape"), value(1), text("Triangle","Sine","Square","Saw","Saw","Rand.Int","Rand.S&H")
rslider bounds( 85, 10, 70, 70), text("Rate"), channel("rate"), range(0,14.00,0.5,0.5, 0.0001), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200), midiCtrl(1,1)
rslider bounds(155, 10, 70, 70), text("Depth"), channel("depth"), range(0, 1.00, 0.5, 1, .01), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
rslider bounds(225, 10, 70, 70), text("Freq."), channel("freq"), range(0, 1.00, 0.4, 1, .01), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
rslider bounds(295, 10, 70, 70), text("Feedback"), channel("fback"), range(0, 1.00, 0.4, 1, .01), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
rslider bounds(365, 10, 70, 70), text("Stages"), channel("stages"), range(1, 64,8, 1, 1), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
rslider bounds(435, 10, 70, 70), text("Mix"), channel("mix"), range(0, 1.00,0.5, 1, .01), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
rslider bounds(505, 10, 70, 70), text("Level"), channel("level"), range(0, 1.00, 1, 1, .01), colour(100,100,110), fontcolour(0,10,30), tracker(255,255,200)
</Cabbage>

<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)
;http://iainmccurdy.org/csound.html


opcode Phaser,a,akkkKki
ain,krate,kdepth,kfreq,kstages,kfback,ishape xin ;READ IN INPUT ARGUMENTS
if ishape=1 then
klfo lfo kdepth*0.5, krate, 1 ;LFO FOR THE PHASER (TRIANGULAR SHAPE)
elseif ishape=2 then
klfo lfo kdepth*0.5, krate, 0 ;LFO FOR THE PHASER (SINE SHAPE)
elseif ishape=3 then
klfo lfo kdepth*0.5, krate, 2 ;LFO FOR THE PHASER (SQUARE SHAPE)
elseif ishape=4 then
klfo lfo kdepth*0.5, krate, 4 ;LFO FOR THE PHASER (SAWTOOTH)
elseif ishape=5 then
klfo lfo kdepth*0.5, krate, 5 ;LFO FOR THE PHASER (SAWTOOTH)
elseif ishape=6 then
klfo randomi -kdepth*0.5, kdepth*0.5, krate*8 ;LFO FOR THE PHASER (RANDOMI SHAPE)
klfo portk klfo, 1/(krate*8) ;SMOOTH CHANGES OF DIRECTION
elseif ishape=7 then
klfo randomh -kdepth*0.5, kdepth*0.5, krate ;LFO FOR THE PHASER (RANDOMH SHAPE)
endif
aout phaser1 ain, cpsoct((klfo+(kdepth*0.5)+kfreq)), kstages, kfback ;PHASER1 IS APPLIED TO THE INPUT AUDIO
xout aout ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

opcode PhaserSt,aa,aakkkKki
ainL,ainR,krate,kdepth,kfreq,kstages,kfback,ishape xin ;READ IN INPUT ARGUMENTS
if ishape=1 then
klfo lfo kdepth*0.5, krate, 1 ;LFO FOR THE PHASER (TRIANGULAR SHAPE)
elseif ishape=2 then
klfo lfo kdepth*0.5, krate, 0 ;LFO FOR THE PHASER (SINE SHAPE)
elseif ishape=3 then
klfo lfo kdepth*0.5, krate, 2 ;LFO FOR THE PHASER (SQUARE SHAPE)
elseif ishape=4 then
klfo lfo kdepth*0.5, krate, 4 ;LFO FOR THE PHASER (SAWTOOTH)
elseif ishape=5 then
klfo lfo kdepth*0.5, krate, 5 ;LFO FOR THE PHASER (SAWTOOTH)
elseif ishape=6 then
klfo randomi -kdepth*0.5, kdepth*0.5, krate*8 ;LFO FOR THE PHASER (RANDOMI SHAPE)
klfo portk klfo, 1/(krate*8) ;SMOOTH CHANGES OF DIRECTION
elseif ishape=7 then
klfo randomh -kdepth*0.5, kdepth*0.5, krate ;LFO FOR THE PHASER (RANDOMH SHAPE)
endif
aoutL phaser1 ainL, cpsoct((klfo+(kdepth*0.5)+kfreq)), kstages, kfback ;PHASER1 IS APPLIED TO THE INPUT AUDIO
aoutR phaser1 ainR, cpsoct((klfo+(kdepth*0.5)+kfreq)), kstages, kfback ;PHASER1 IS APPLIED TO THE INPUT AUDIO
xout aoutL,aoutR ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
kporttime linseg 0,0.001,0.05
krate chnget "rate"
kdepth chnget "depth"
kfreq chnget "freq"
kfback chnget "fback"
kstages chnget "stages"
klevel chnget "level"
kmix chnget "mix"
kshape chnget "shape"
kshape init 1

/* INPUT */
kinput chnget "input"
if kinput=1 then
a1,a2 ins
elseif kinput=2 then
a1 vco2 0.2,200
a2 = a1
else
a1 pinkish 0.2
a2 pinkish 0.2
endif

ktrig changed kshape,kstages ; reinitialise for i-rate parms
if ktrig=1 then
reinit RESTART_PHASER
endif
RESTART_PHASER:
;aPhs1 Phaser a1,krate,kdepth*8,(kfreq*5)+6,kstages,kfback*0.9,i(kshape) ; call UDO
;aPhs2 Phaser a2,krate,kdepth*8,(kfreq*5)+6,kstages,kfback*0.9,i(kshape)
aPhs1,aPhs2 PhaserSt a1,a2,krate,kdepth*8,(kfreq*5)+6,kstages,kfback*0.9,i(kshape) ; use stereo version to ensure lfo sync for random lfos

rireturn
a1 ntrpol a1,aPhs1,kmix ; wet/dry mix
a2 ntrpol a2,aPhs2,kmix
outs a1* klevel, a2* klevel
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 59
- 0
bin/cabbage/Effects/PingPongDelay.csd View File

@@ -0,0 +1,59 @@
<Cabbage>
form caption("Ping Pong Delay") size(350, 90), pluginID("ppdl")
image bounds(0, 0,350, 90), colour("Maroon"), shape("rounded"), outline("white"), line(4)
rslider bounds(10, 11, 70, 70), text("Time"), channel("time"), range(0.001, 10, 0.4, 0.5), colour(135, 30, 30) tracker(255,255,150) fontcolour(silver)
rslider bounds(75, 11, 70, 70), text("Cutoff"), channel("cutoff"), range(20,20000,20000,0.5), colour(135, 30, 30) tracker(255,255,150) fontcolour(silver)
rslider bounds(140, 11, 70, 70), text("Feedback"), channel("feedback"), range(0, 1.00, 0.5), colour(135, 30, 30) tracker(255,255,150) fontcolour(silver)
rslider bounds(205, 11, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 0.5), colour(135, 30, 30) tracker(255,255,150) fontcolour(silver)
rslider bounds(270, 11, 70, 70), text("Level"), channel("level"), range(0, 1.00, 0.7), colour(135, 30, 30) tracker(255,255,150) fontcolour(silver)

</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

;Author: Iain McCurdy (2012)

instr 1
ktime chnget "time" ;READ WIDGETS...
kcutoff chnget "cutoff" ;
kfeedback chnget "feedback" ;
kmix chnget "mix" ;
klevel chnget "level" ;
asigL, asigR ins
kporttime linseg 0,0.01,0.03 ;CREATE A VARIABLE THAT WILL BE USED FOR PORTAMENTO TIME
ktime portk ktime,kporttime ;PORTAMENTO SMOOTHING OF DELAT TIME
atime interp ktime ;INTERPOLATED A-RATE VERSION OF DELAY TIME
aL_OS vdelay asigL,(atime*1000)/2,(10*1000)/2 ;DELAYED OFFSET OF LEFT CHANNEL (FIRST 'PING')
;LEFT CHANNEL
abuf delayr 10 ;ESTABLISH DELAY BUFFER
aDelL deltapi atime ;TAP BUFFER
aDelL tone aDelL,kcutoff ;LOWPASS FILTER DELAY TAP
delayw aL_OS+(aDelL*kfeedback) ;WRITE INPUT AUDIO INTO BUFFER
;RIGHT CHANNEL
abuf delayr 10 ;ESTABLISH DELAY BUFFER
aDelR deltapi atime ;TAP BUFFER
aDelR tone aDelR,kcutoff ;LOWPASS FILTER DELAY TAP
delayw asigR+(aDelR*kfeedback) ;WRITE INPUT AUDIO INTO BUFFER
amixL ntrpol asigL,aDelL+aL_OS,kmix ;MIX DRY AND WET SIGNALS (LEFT CHANNEL)
amixR ntrpol asigR,aDelR,kmix ;MIX DRY AND WET SIGNALS (RIGHT CHANNEL)
outs amixL*klevel, amixR*klevel ;PING PONG DELAY OUTPUTS ARE SENT OUT
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>

+ 94
- 0
bin/cabbage/Effects/Powershape.csd View File

@@ -0,0 +1,94 @@
; Powershape.csd
; Iain McCurdy 2012
;
; Encapsulation of the powershape opcode used for wave distortion
;
; CONTROLS
; --------
; Test Tone -- a glissandoing test tone
; Amount -- amount of distortion
; Level -- output level

<Cabbage>
form caption("Powershape") size(300,107), pluginID("pshp")
image bounds(0, 0,300,107), colour("Brown"), shape("rounded"), outline("white"), line(4)
checkbox bounds(10, 8,130, 12), channel("TestTone"), FontColour("white"), value(0), text("Sine Tone"), colour(yellow)
hslider bounds( 5, 15,290, 40), colour("white"), tracker("white"), channel("amount"), range(1, 500, 1, 0.5,0.001)
label bounds(130, 47, 60, 11), text("Amount"), fontcolour("white")
hslider bounds( 5, 55,290, 40), colour("white"), tracker("white"), channel("level"), range(0, 50, 0.5, 0.25,0.000001)
label bounds(135, 87, 60, 11), text("Level"), fontcolour("white")
}
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1

gisine ftgen 0,0,4096,10,1 ;,0,1/2,0,1/4,0,1/8,0,1/16,0,1/32,0,1/64

instr 1
kporttime linseg 0,0.001,0.05 ; portamento time ramps up from zero
gkshape chnget "amount" ; READ WIDGETS...
gkshape portk gkshape,kporttime
gklevel chnget "level" ;
gklevel portk gklevel,kporttime
gklevel portk gklevel,kporttime
gkTestTone chnget "TestTone"
if gkTestTone==1 then ; if test tone selected...
koct rspline 4,8,0.2,0.5
asigL poscil 1,cpsoct(koct),gisine ; ...generate a tone
asigR = asigL ; right channel equal to left channel
else ; otherwise...
asigL, asigR ins ; read live inputs
endif
ifullscale = 0dbfs ;DEFINE FULLSCALE AMPLITUDE VALUE
aL powershape asigL, gkshape, ifullscale ;CREATE POWERSHAPED SIGNAL
aR powershape asigR, gkshape, ifullscale ;CREATE POWERSHAPED SIGNAL
alevel interp gklevel
outs aL * alevel, aR * alevel ;WAVESET OUTPUT ARE SENT TO THE SPEAKERS
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>


</CsoundSynthesizer>




























+ 71
- 0
bin/cabbage/Effects/RingModulator.csd View File

@@ -0,0 +1,71 @@
<Cabbage>
form caption("Ring Modulator") size(435, 90), pluginID("rmod")
;label bounds(7, 3, 200, 11), text("Iain McCurdy [2013]"), FontColour("grey")
image pos(0, 0), size(435, 90), colour("black"), shape("rounded"), outline("lime"), line(5)
rslider bounds( 5, 12, 70, 70), text("Freq."), channel("freq"), range(0, 15000, 800, 0.25), colour("yellow")
rslider bounds( 75, 12, 70, 70), text("Sine/Sq."), channel("wave"), range(0, 1.00, 0), colour("yellow")
line bounds(150, 2, 3, 86), colour("lime")
rslider bounds(160, 12, 70, 70), text("Env."), channel("env"), range(0, 1.00, 0.5, 0.5), colour("orange")
rslider bounds(230, 6, 40, 40), text("Att."), channel("att"), range(0.001, 0.5, 0.01, 0.5), colour("orange")
rslider bounds(230, 46, 40, 40), text("Dec."), channel("dec"), range(0.001, 0.5, 0.1, 0.5), colour("orange")
line bounds(275, 2, 3, 86), colour("lime")
rslider bounds(290, 12, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 1), colour("chocolate")
rslider bounds(360, 12, 70, 70), text("Level"), channel("level"), range(0, 1.00, 1), colour("chocolate")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)
;http://iainmccurdy.org/csound.html

opcode RingModulator,a,akkkkkk
ain,kmix,kfreq,kwave,kenv,katt,kdec xin ;READ IN INPUT ARGUMENTS
iWet ftgentmp 0,0,1024,-7,0,512,1,512,1 ;RESCALING FUNCTION FOR WET LEVEL CONTROL
iDry ftgentmp 0,0,1024,-7,1,512,1,512,0 ;RESCALING FUNCTION FOR DRY LEVEL CONTROL
isine ftgentmp 0,0,4096,10,1 ;SINE WAVE
kWet table kmix, iWet, 1 ;RESCALE WET LEVEL CONTROL ACCORDING TO FUNCTION TABLE iWet
kDry table kmix, iDry, 1 ;RESCALE DRY LEVEL CONTROL ACCORDING TO FUNCTION TABLE iDry
kporttime linseg 0,0.001,0.02 ;PORTAMENTO VARIABLE
kModFrq portk kfreq, kporttime ;SMOOTH VARIABLE CHANGES
aFollow follow2 ain, katt, kdec ;AMPLITUDE FOLLOWING kModFrq + (cpsoct(kFollow*kenv*30)) ;CREATE A LEFT CHANNEL MODULATING FREQUENCY BASE ON THE STATIC VALUE CREATED BY kfreq AND THE AMOUNT OF DYNAMIC ENVELOPE FOLLOWING GOVERNED BY kenv
kFollow downsamp aFollow
kFollow logcurve kFollow/0dbfs,2
kModFrq = kModFrq + (kFollow*kenv*8000) ;CREATE A LEFT CHANNEL MODULATING FREQUENCY BASE ON THE STATIC VALUE CREATED BY kfreq AND THE AMOUNT OF DYNAMIC ENVELOPE FOLLOWING GOVERNED BY kenv
aModSi poscil 1, kModFrq, isine ;CREATE RING MODULATING SIGNAL
aModSq vco2 1, kModFrq, 10 ;CREATE RING MODULATING SIGNAL
aMod ntrpol aModSi,aModSq,kwave
aout sum ain*kDry, ain*aMod*kWet ;MIX DRY AND WET SIGNALS
xout aout ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
kmix chnget "mix"
kfreq chnget "freq"
kwave chnget "wave"
kenv chnget "env"
katt chnget "att"
kdec chnget "dec"
klevel chnget "level"
a1,a2 ins
;;a1,a2 diskin2 "808loop.wav",1,0,1
a1 RingModulator a1,kmix,kfreq,kwave,kenv,katt,kdec
a2 RingModulator a2,kmix,kfreq,kwave,kenv,katt,kdec
a1 = a1 * klevel
a2 = a2 * klevel
outs a1,a2
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 57
- 0
bin/cabbage/Effects/StereoChorus.csd View File

@@ -0,0 +1,57 @@
<Cabbage>
form caption("Stereo Chorus") size(305, 100), pluginID("scho")
image bounds(0, 0, 305, 100), colour("DarkSlateGrey"), shape("rounded"), outline("white"), line(6)
rslider bounds( 10, 13, 75, 75), text("Rate"), channel("rate"), range(0.001, 7, 0.5,0.5), fontcolour("white"), colour("DarkSlateGrey"), tracker("Silver")
rslider bounds( 80, 13, 75, 75), text("Depth"), channel("depth"), range(0, 1.00, 0.2), fontcolour("white"), colour("DarkSlateGrey"), tracker("Silver")
rslider bounds(150, 13, 75, 75), text("Width"), channel("width"), range(0, 1.00, 0.75), fontcolour("white"), colour("DarkSlateGrey"), tracker("Silver")
rslider bounds(220, 13, 75, 75), text("Level"), channel("level"), range(0, 1.00, .1), fontcolour("white"), colour("DarkSlateGrey"), tracker("Silver")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Iain McCurdy (2012)
;http://iainmccurdy.org/csound.html

opcode StChorus,aa,aakkk
ainL,ainR,krate,kdepth,kwidth xin ;READ IN INPUT ARGUMENTS
ilfoshape ftgentmp 0, 0, 131072, 19, 1, 0.5, 0, 0.5 ;POSITIVE DOMAIN ONLY SINE WAVE
kporttime linseg 0,0.001,0.02 ;RAMPING UP PORTAMENTO VARIABLE
kChoDepth portk kdepth*0.01, kporttime ;SMOOTH VARIABLE CHANGES WITH PORTK
aChoDepth interp kChoDepth ;INTERPOLATE TO CREATE A-RATE VERSION OF K-RATE VARIABLE
amodL osciliktp krate, ilfoshape, 0 ;LEFT CHANNEL LFO
amodR osciliktp krate, ilfoshape, kwidth*0.5 ;THE PHASE OF THE RIGHT CHANNEL LFO IS ADJUSTABLE
amodL = (amodL*aChoDepth)+.01 ;RESCALE AND OFFSET LFO (LEFT CHANNEL)
amodR = (amodR*aChoDepth)+.01 ;RESCALE AND OFFSET LFO (RIGHT CHANNEL)
aChoL vdelay ainL, amodL*1000, 1.2*1000 ;CREATE VARYING DELAYED / CHORUSED SIGNAL (LEFT CHANNEL)
aChoR vdelay ainR, amodR*1000, 1.2*1000 ;CREATE VARYING DELAYED / CHORUSED SIGNAL (RIGHT CHANNEL)
aoutL sum aChoL*0.6, ainL*0.6 ;MIX DRY AND WET SIGNAL (LEFT CHANNEL)
aoutR sum aChoR*0.6, ainR*0.6 ;MIX DRY AND WET SIGNAL (RIGHT CHANNEL)
xout aoutL,aoutR ;SEND AUDIO BACK TO CALLER INSTRUMENT
endop

instr 1
krate chnget "rate"
kdepth chnget "depth"
kwidth chnget "width"
klevel chnget "level"
a1,a2 ins
a1,a2 StChorus a1,a2,krate,kdepth,kwidth
a1 = a1 * klevel
a2 = a2 * klevel
outs a1,a2
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 104
- 0
bin/cabbage/Effects/pvScale.csd View File

@@ -0,0 +1,104 @@
<Cabbage>
form caption("pvscale Pitch Shifter") size(510, 90), pluginID("scal")
image bounds( 15, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds( 85, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds(155, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds(295, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds(365, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds(435, 9, 60, 60), colour(30,30,30), shape("ellipse"), line(0)
image bounds(6,23, 498, 30), colour("grey"), shape("ellipse")
image bounds(0, 0, 510, 90), colour("SlateGrey"), outline("silver"), line(4)
rslider bounds(10, 10, 70, 70), text("Semitones"), channel("semis"), range(-24, 24, 7, 1, 1),fontcolour("black"),colour("DarkSlateGrey")
rslider bounds(80, 10, 70, 70), text("Cents"), channel("cents"), range(-100, 100, 0, 1, 1),fontcolour("black"),colour("DarkSlateGrey")
rslider bounds(150, 10, 70, 70), text("Feedback"), channel("FB"), range(0.00, 0.99, 0),fontcolour("black"),colour("DarkSlateGrey")
combobox bounds(220, 28, 70,20), channel("FB_mode"), value(0), text("F Sig.", "Audio")
label bounds(220, 54, 70, 12), text("F.back Mode"), FontColour("black")
rslider bounds(290, 10, 70, 70), text("FFT Size"), channel("att_table"), range(1, 8, 5, 1,1), fontcolour("black"),colour("DarkSlateGrey")
rslider bounds(360, 10, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 0.5),fontcolour("black"),colour("DarkSlateGrey")
rslider bounds(430, 10, 70, 70), text("Level"), channel("lev"), range(0, 1.00, 0.5, 0.5),fontcolour("black"),colour("DarkSlateGrey")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE

;Iain McCurdy
;http://iainmccurdy.org/csound.html
;Pitch shifting effect using pvs scale opcode.

/* FFT attribute tables */
giFFTattributes1 ftgen 0, 0, 4, -2, 64, 32, 64, 1
giFFTattributes2 ftgen 0, 0, 4, -2, 128, 64, 128, 1
giFFTattributes3 ftgen 0, 0, 4, -2, 256, 128, 256, 1
giFFTattributes4 ftgen 0, 0, 4, -2, 512, 128, 512, 1
giFFTattributes5 ftgen 0, 0, 4, -2, 1024, 256, 1024, 1
giFFTattributes6 ftgen 0, 0, 4, -2, 2048, 512, 2048, 1
giFFTattributes7 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
giFFTattributes8 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1

opcode pvscale_module,a,akkkkkiiii
ain,kscale,kfeedback,kFB_mode,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
if(kFB_mode==0) then
f_FB pvsinit iFFTsize,ioverlap,iwinsize,iwintype, 0 ;INITIALISE FEEDBACK FSIG
f_anal pvsanal ain, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE AUDIO INPUT SIGNAL AND OUTPUT AN FSIG
f_mix pvsmix f_anal, f_FB ;MIX AUDIO INPUT WITH FEEDBACK SIGNAL
f_scale pvscale f_mix, kscale ;RESCALE FREQUENCIES
f_FB pvsgain f_scale, kfeedback ;CREATE FEEDBACK F-SIGNAL FOR NEXT PASS
aout pvsynth f_scale ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
else
aFB init 0
f_anal pvsanal ain+aFB, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE AUDIO INPUT SIGNAL AND OUTPUT AN FSIG
f_scale pvscale f_anal, kscale ;RESCALE FREQUENCIES
aout pvsynth f_scale ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
aFB = aout*kfeedback
endif
amix ntrpol ain, aout, kmix ;CREATE DRY/WET MIX
xout amix*klev
endop

instr 1
ainL,ainR ins
;ainL,ainR diskin2 "SynthPad.wav",1,0,1
kmix chnget "mix"
kFB chnget "FB"
kFB_mode chnget "FB_mode"

/* SET FFT ATTRIBUTES */
katt_table chnget "att_table" ; FFT atribute table
katt_table init 5
ktrig changed katt_table
if ktrig==1 then
reinit update
endif
update:
iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
iwintype table 3, giFFTattributes1 + i(katt_table) - 1
/*-------------------*/
kfeedback chnget "FB"
ksemis chnget "semis"
kcents chnget "cents"
kmix chnget "mix"
klev chnget "lev"
kporttime linseg 0,0.001,0.02
kscale = semitone(ksemis)*cent(kcents)
aoutL pvscale_module ainL,kscale,kfeedback,kFB_mode,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
aoutR pvscale_module ainR,kscale,kfeedback,kFB_mode,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
outs aoutR,aoutR
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 90
- 0
bin/cabbage/Effects/pvSmooth.csd View File

@@ -0,0 +1,90 @@
pvsmooth
FFT feedback is disabled if amplitude smoothing is increased beyond zero. If this is not done the instrument will fail.

<Cabbage>
form caption("pvSmooth") size(505, 90), pluginID("smoo")
image bounds(0, 0, 505, 90), colour("Cream"), outline("silver"), line(5)
label pos(-5, -30), size(815, 150), fontcolour(210,105, 30, 80), text("smooth"), shape("rounded"), outline("white"), line(4)
rslider bounds( 10, 8, 75, 75), text("Amp.Smooth"), channel("acf"), range(0, 1.00, 0, 0.75, 0.001),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
rslider bounds( 90, 8, 75, 75), text("Frq.Smooth"), channel("fcf"), range(0, 1.00, 0, 0.5, 0.0001),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
rslider bounds(170, 8, 75, 75), text("Feedback"), channel("FB"), range(0, 0.999, 0, 1,0.001),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
rslider bounds(250, 8, 75, 75), text("FFT Size"), channel("att_table"), range(1,10, 5, 1,1),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
rslider bounds(330, 8, 75, 75), text("Mix"), channel("mix"), range(0, 1.00, 1),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
rslider bounds(410, 8, 75, 75), text("Level"), channel("lev"), range(0, 1.00, 0.5),fontcolour(138, 54, 15),colour("chocolate"), tracker(138, 54, 15)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE

;Iain McCurdy
;http://iainmccurdy.org/csound.html
;Spectral smoothing effect.

/* FFT attribute tables */
giFFTattributes1 ftgen 0, 0, 4, -2, 64, 32, 64, 1
giFFTattributes2 ftgen 0, 0, 4, -2, 128, 64, 128, 1
giFFTattributes3 ftgen 0, 0, 4, -2, 256, 128, 256, 1
giFFTattributes4 ftgen 0, 0, 4, -2, 512, 128, 512, 1
giFFTattributes5 ftgen 0, 0, 4, -2, 1024, 128, 1024, 1
giFFTattributes6 ftgen 0, 0, 4, -2, 2048, 256, 2048, 1
giFFTattributes7 ftgen 0, 0, 4, -2, 2048,1024, 2048, 1
giFFTattributes8 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
giFFTattributes9 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1
giFFTattributes10 ftgen 0, 0, 4, -2,16384,4096,16384, 1

opcode pvsmooth_module,a,akkkkkiiii
ain,kacf,kfcf,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
f_FB pvsinit iFFTsize,ioverlap,iwinsize,iwintype, 0 ;INITIALISE FEEDBACK FSIG
f_anal pvsanal ain, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE AUDIO INPUT SIGNAL AND OUTPUT AN FSIG
f_mix pvsmix f_anal, f_FB ;MIX AUDIO INPUT WITH FEEDBACK SIGNAL
f_smooth pvsmooth f_mix, kacf, kfcf ;BLUR AMPLITUDE AND FREQUENCY VALUES OF AN F-SIGNAL
f_FB pvsgain f_smooth, kfeedback ;CREATE FEEDBACK F-SIGNAL FOR NEXT PASS
aout pvsynth f_smooth ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
amix ntrpol ain, aout, kmix ;CREATE DRY/WET MIX
xout amix*klev
endop

instr 1
ainL,ainR ins
;ainL,ainR diskin "808loop.wav",1,0,1 ;USE FOR TESTING
;ainL,ainR diskin "SynthPad.wav",1,0,1 ;USE FOR TESTING

katt_table chnget "att_table" ; FFT atribute table
katt_table init 5
ktrig changed katt_table
if ktrig==1 then
reinit update
endif
update:
iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
iwintype table 3, giFFTattributes1 + i(katt_table) - 1
kfeedback chnget "FB"
kacf chnget "acf"
kfcf chnget "fcf"
kfeedback = (kacf>0?0:kfeedback) ; feedback + amplitude smoothing can cause failure so we must protect against this
kacf = 1-kacf
kfcf = 1-kfcf
kporttime linseg 0,0.001,0.02
kmix chnget "mix"
klev chnget "lev"
aoutL pvsmooth_module ainL,kacf,kfcf,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
aoutR pvsmooth_module ainR,kacf,kfcf,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
outs aoutR,aoutR
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 76
- 0
bin/cabbage/Effects/pvsBlur.csd View File

@@ -0,0 +1,76 @@
<Cabbage>
form caption("pvsBlur"), size(235,125) colour( 70, 90,100), pluginID("blur")
image bounds(0, 0,235,125), colour( 70, 90,100), shape("rounded"), outline("white"), line(5)
rslider bounds( 10, 10, 70, 70), text("FFT Size"), channel("att_table"), range(1, 7, 4, 1,1), fontcolour("white"),colour( 70, 90,100),tracker("white")
rslider bounds( 80, 10, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 1), fontcolour("white"),colour( 70, 90,100),tracker("white")
rslider bounds(150, 10, 70, 70), text("Level"), channel("lev"), range(0, 1.00, 0.5, 0.5), fontcolour("white"),colour( 70, 90,100),tracker("white")
hslider bounds( 10, 70,210, 40), channel("blurtime"), range(0, 2.00, 0.0, 0.5, 0.0001), fontcolour("white"),colour( 70, 90,100),tracker("white")
label bounds( 92,103, 60, 11), text("Blur Time"), fontcolour("white")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE

; Author: Iain McCurdy (2012)
; http://iainmccurdy.org/csound.html

/* FFT attribute tables */
giFFTattributes1 ftgen 0, 0, 4, -2, 128, 64, 128, 1
giFFTattributes2 ftgen 0, 0, 4, -2, 256, 128, 256, 1
giFFTattributes3 ftgen 0, 0, 4, -2, 512, 128, 512, 1
giFFTattributes4 ftgen 0, 0, 4, -2, 1024, 256, 1024, 1
giFFTattributes5 ftgen 0, 0, 4, -2, 2048, 512, 2048, 1
giFFTattributes6 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
giFFTattributes7 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1

opcode pvsblur_module,a,akkkiiii
ain,kblurtime,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
f_anal pvsanal ain, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE AUDIO INPUT SIGNAL AND OUTPUT AN FSIG
f_blur pvsblur f_anal, kblurtime, 2 ;BLUR AMPLITUDE AND FREQUENCY VALUES OF AN F-SIGNAL
aout pvsynth f_blur ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
amix ntrpol ain, aout, kmix ;CREATE DRY/WET MIX
xout amix*klev
endop

instr 1
kblurtime chnget "blurtime"
kmix chnget "mix"
klev chnget "lev"

ainL,ainR ins
;ainL,ainR diskin "808loop.wav",1,0,1 ;USE FOR TESTING

/* SET FFT ATTRIBUTES */
katt_table chnget "att_table" ; FFT atribute table
katt_table init 5
ktrig changed katt_table
if ktrig==1 then
reinit update
endif
update:
iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
iwintype table 3, giFFTattributes1 + i(katt_table) - 1
/*-------------------*/
kporttime linseg 0,0.001,0.02
kblurtime portk kblurtime,kporttime
aoutL pvsblur_module ainL,kblurtime,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
aoutR pvsblur_module ainR,kblurtime,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
outs aoutR,aoutR
endin

</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7]
</CsScore>

</CsoundSynthesizer>

+ 114
- 0
bin/cabbage/Effects/pvsBuffer.csd View File

@@ -0,0 +1,114 @@
; pvsBuffer.csd (for Cabbage)
; Writes audio into a circular FFT buffer.
; Read speed can be modified as can the frequencies.
; Take Care! Feedback values above 1 are intended to be used only when transposition if not unison.

<Cabbage>
form caption("pvsBuffer") size(580,90), pluginID("buff")
image bounds(0, 0, 580, 90), colour(100, 80, 80,125), shape("rounded"), outline("white"), line(4)
rslider bounds(10, 11, 70, 70), text("Speed"), channel("speed"), range(0, 4, 1, 0.5, 0.0001), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(80, 11, 70, 70), text("Buf. Size"), channel("buflen"), range(0.10, 8.00, 1, 0.5), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(150, 11, 70, 70), text("Semitones"), channel("semis"), range(-24, 24, 0, 1, 1), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(220, 11, 70, 70), text("Cents"), channel("cents"), range(-100, 100, 0, 1, 1), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(290, 11, 70, 70), text("Feedback"), channel("FB"), range(0, 1.50, 0), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(360, 11, 70, 70), text("FFT Size"), channel("att_table"), range(1, 8, 5, 1,1), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(430, 11, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 1), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
rslider bounds(500, 11, 70, 70), text("Level"), channel("lev"), range(0, 1.00, 0.5), fontcolour("white"), colour(100, 80, 80, 5) tracker(silver)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE

;Author: Iain McCurdy (2012)
;http://iainmccurdy.org/csound.html

/* FFT attribute tables */
giFFTattributes1 ftgen 0, 0, 4, -2, 64, 32, 64, 1
giFFTattributes2 ftgen 0, 0, 4, -2, 128, 64, 128, 1
giFFTattributes3 ftgen 0, 0, 4, -2, 256, 128, 256, 1
giFFTattributes4 ftgen 0, 0, 4, -2, 512, 128, 512, 1
giFFTattributes5 ftgen 0, 0, 4, -2, 1024, 256, 1024, 1
giFFTattributes6 ftgen 0, 0, 4, -2, 2048, 512, 2048, 1
giFFTattributes7 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
giFFTattributes8 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1

opcode pvsbuffer_module,a,akkkkkkiiii
ain,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
kPhOffset = 0
ktrig changed kbuflen
ibuflen init 1
kspeed init 1
kscale init 1
if ktrig==1 then
reinit UPDATE
endif
UPDATE:
ibuflen = i(kbuflen)
iphasor ftgen 0, 0, 65536, 7, 0, 65536, 1 ;WAVE SHAPE FOR A MOVING PHASE POINTER
aread osciliktp kspeed/ibuflen, iphasor, kPhOffset ;CREATE MOVING POINTER TO READ FROM BUFFER
kread downsamp aread
kread = kread * ibuflen ;RESCALE READ POINTER WITH PHASOR RANGE SLIDER
aFB init 0
f_anal pvsanal ain+aFB, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE THE AUDIO SIGNAL THAT WAS CREATED IN INSTRUMENT 1. OUTPUT AN F-SIGNAL.
ibuffer,ktime pvsbuffer f_anal, ibuflen ;BUFFER FSIG
rireturn
khandle init ibuffer ;INITIALISE HANDLE TO BUFFER
f_buf pvsbufread kread , khandle ;READ BUFFER
f_scale pvscale f_buf, kscale ;RESCALE FREQUENCIES
aresyn pvsynth f_scale ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
aFB dcblock2 aresyn * kfeedback ;CREATE FEEDBACK SIGNAL FOR NEXT PASS AND BLOCK DC OFFSET ACCUMULATION
amix ntrpol ain, aresyn, kmix ;CREATE DRY/WET MIX
xout amix*klev
endop

instr 1
ainL,ainR ins
;ainL,ainR diskin "SynthPad.wav",1,0,1 ;USE FOR TESTING
kspeed chnget "speed"
kbuflen chnget "buflen"
ksemis chnget "semis"
kcents chnget "cents"
ksemis init 0
kcents init 0
kscale = semitone(ksemis)*cent(kcents)
kscale init 1
kbuflen init 1
kspeed init 1
kmix chnget "mix"
kfeedback chnget "FB"
klev chnget "lev"
kmix init 1
kfeedback init 0
klev init 0.5

/* SET FFT ATTRIBUTES */
katt_table chnget "att_table" ; FFT atribute table
katt_table init 5
ktrig changed katt_table
if ktrig==1 then
reinit update
endif
update:
iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
iwintype table 3, giFFTattributes1 + i(katt_table) - 1
/*-------------------*/
aoutL pvsbuffer_module ainL,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
aoutR pvsbuffer_module ainR,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
outs aoutL,aoutR
endin

</CsInstruments>
<CsScore>
i 1 0.1 [60*60*24*7]
</CsScore>
</CsoundSynthesizer>

+ 432
- 0
bin/cabbage/MIDI/MIDI_OUT_MATRIX.csd View File

@@ -0,0 +1,432 @@
<Cabbage>
form size(835, 445), caption("MIDI outbox"), pluginID("plu1")
groupbox bounds(4, 4, 820, 400), colour(2, 2, 2), fontcolour("cornflowerblue"), text("Step Sequencer"), plant("8x16"){
checkbox bounds(11, 25, 49, 30), channel("AA")
checkbox bounds(11, 60, 49, 30), channel("BA")
checkbox bounds(11, 95, 49, 30), channel("CA")
checkbox bounds(11, 130, 49, 30), channel("DA")
checkbox bounds(11, 165, 49, 30), channel("EA")
checkbox bounds(11, 200, 49, 30), channel("FA")
checkbox bounds(11, 235, 49, 30), channel("GA")
checkbox bounds(11, 270, 49, 30), channel("HA")
checkbox bounds(60, 25, 49, 30), channel("AB")
checkbox bounds(60, 60, 49, 30), channel("BB")
checkbox bounds(60, 95, 49, 30), channel("CB")
checkbox bounds(60, 130, 49, 30), channel("DB")
checkbox bounds(60, 165, 49, 30), channel("EB")
checkbox bounds(60, 200, 49, 30), channel("FB")
checkbox bounds(60, 235, 49, 30), channel("GB")
checkbox bounds(60, 270, 49, 30), channel("HB")
checkbox bounds(109, 25, 49, 30), channel("AC")
checkbox bounds(109, 60, 49, 30), channel("BC")
checkbox bounds(109, 95, 49, 30), channel("CC")
checkbox bounds(109, 130, 49, 30), channel("DC")
checkbox bounds(109, 165, 49, 30), channel("EC")
checkbox bounds(109, 200, 49, 30), channel("FC")
checkbox bounds(109, 235, 49, 30), channel("GC")
checkbox bounds(109, 270, 49, 30), channel("HC")
checkbox bounds(160, 25, 49, 30), channel("AD")
checkbox bounds(160, 60, 49, 30), channel("BD")
checkbox bounds(160, 95, 49, 30), channel("CD")
checkbox bounds(160, 130, 49, 30), channel("DD")
checkbox bounds(160, 165, 49, 30), channel("ED")
checkbox bounds(160, 200, 49, 30), channel("FD")
checkbox bounds(160, 235, 49, 30), channel("GD")
checkbox bounds(160, 270, 49, 30), channel("HD")
checkbox bounds(209, 25, 49, 30), channel("AE")
checkbox bounds(209, 60, 49, 30), channel("BE")
checkbox bounds(209, 95, 49, 30), channel("CE")
checkbox bounds(209, 130, 49, 30), channel("DE")
checkbox bounds(209, 165, 49, 30), channel("EE")
checkbox bounds(209, 200, 49, 30), channel("FE")
checkbox bounds(209, 235, 49, 30), channel("GE")
checkbox bounds(209, 270, 49, 30), channel("HE")
checkbox bounds(259, 25, 49, 30), channel("AF")
checkbox bounds(259, 60, 49, 30), channel("BF")
checkbox bounds(259, 95, 49, 30), channel("CF")
checkbox bounds(259, 130, 49, 30), channel("DF")
checkbox bounds(259, 165, 49, 30), channel("EF")
checkbox bounds(259, 200, 49, 30), channel("FF")
checkbox bounds(259, 235, 49, 30), channel("GF")
checkbox bounds(259, 270, 49, 30), channel("HF")
checkbox bounds(308, 25, 49, 30), channel("AG")
checkbox bounds(308, 60, 49, 30), channel("BG")
checkbox bounds(308, 95, 49, 30), channel("CG")
checkbox bounds(308, 130, 49, 30), channel("DG")
checkbox bounds(308, 165, 49, 30), channel("EG")
checkbox bounds(308, 200, 49, 30), channel("FG")
checkbox bounds(308, 235, 49, 30), channel("GG")
checkbox bounds(308, 270, 49, 30), channel("HG")
checkbox bounds(357, 25, 49, 30), channel("AH")
checkbox bounds(357, 60, 49, 30), channel("BH")
checkbox bounds(357, 95, 49, 30), channel("CH")
checkbox bounds(357, 130, 49, 30), channel("DH")
checkbox bounds(357, 165, 49, 30), channel("EH")
checkbox bounds(357, 200, 49, 30), channel("FH")
checkbox bounds(357, 235, 49, 30), channel("GH")
checkbox bounds(357, 270, 49, 30), channel("HH")
checkbox bounds(406, 25, 49, 30), channel("AI")
checkbox bounds(406, 60, 49, 30), channel("BI")
checkbox bounds(406, 95, 49, 30), channel("CI")
checkbox bounds(406, 130, 49, 30), channel("DI")
checkbox bounds(406, 165, 49, 30), channel("EI")
checkbox bounds(406, 200, 49, 30), channel("FI")
checkbox bounds(406, 235, 49, 30), channel("GI")
checkbox bounds(406, 270, 49, 30), channel("HI")
checkbox bounds(455, 25, 49, 30), channel("AJ")
checkbox bounds(455, 60, 49, 30), channel("BJ")
checkbox bounds(455, 95, 49, 30), channel("CJ")
checkbox bounds(455, 130, 49, 30), channel("DJ")
checkbox bounds(455, 165, 49, 30), channel("EJ")
checkbox bounds(455, 200, 49, 30), channel("FJ")
checkbox bounds(455, 235, 49, 30), channel("GJ")
checkbox bounds(455, 270, 49, 30), channel("HJ")
checkbox bounds(506, 25, 49, 30), channel("AK")
checkbox bounds(506, 60, 49, 30), channel("BK")
checkbox bounds(506, 95, 49, 30), channel("CK")
checkbox bounds(506, 130, 49, 30), channel("DK")
checkbox bounds(506, 165, 49, 30), channel("EK")
checkbox bounds(506, 200, 49, 30), channel("FK")
checkbox bounds(506, 235, 49, 30), channel("GK")
checkbox bounds(506, 270, 49, 30), channel("HK")
checkbox bounds(555, 25, 49, 30), channel("AL")
checkbox bounds(555, 60, 49, 30), channel("BL")
checkbox bounds(555, 95, 49, 30), channel("CL")
checkbox bounds(555, 130, 49, 30), channel("DL")
checkbox bounds(555, 165, 49, 30), channel("EL")
checkbox bounds(555, 200, 49, 30), channel("FL")
checkbox bounds(555, 235, 49, 30), channel("GL")
checkbox bounds(555, 270, 49, 30), channel("HL")
checkbox bounds(605, 25, 49, 30), channel("AM")
checkbox bounds(605, 60, 49, 30), channel("BM")
checkbox bounds(605, 95, 49, 30), channel("CM")
checkbox bounds(605, 130, 49, 30), channel("DM")
checkbox bounds(605, 165, 49, 30), channel("EM")
checkbox bounds(605, 200, 49, 30), channel("FM")
checkbox bounds(605, 235, 49, 30), channel("GM")
checkbox bounds(605, 270, 49, 30), channel("HM")
checkbox bounds(654, 25, 49, 30), channel("AN")
checkbox bounds(654, 60, 49, 30), channel("BN")
checkbox bounds(654, 95, 49, 30), channel("CN")
checkbox bounds(654, 130, 49, 30), channel("DN")
checkbox bounds(654, 165, 49, 30), channel("EN")
checkbox bounds(654, 200, 49, 30), channel("FN")
checkbox bounds(654, 235, 49, 30), channel("GN")
checkbox bounds(654, 270, 49, 30), channel("HN")
checkbox bounds(703, 25, 49, 30), channel("AO")
checkbox bounds(703, 60, 49, 30), channel("BO")
checkbox bounds(703, 95, 49, 30), channel("CO")
checkbox bounds(703, 130, 49, 30), channel("DO")
checkbox bounds(703, 165, 49, 30), channel("EO")
checkbox bounds(703, 200, 49, 30), channel("FO")
checkbox bounds(703, 235, 49, 30), channel("GO")
checkbox bounds(703, 270, 49, 30), channel("HO")
checkbox bounds(752, 25, 49, 30), channel("AP")
checkbox bounds(752, 60, 49, 30), channel("BP")
checkbox bounds(752, 95, 49, 30), channel("CP")
checkbox bounds(752, 130, 49, 30), channel("DP")
checkbox bounds(752, 165, 49, 30), channel("EP")
checkbox bounds(752, 200, 49, 30), channel("FP")
checkbox bounds(752, 235, 49, 30), channel("GP")
checkbox bounds(752, 270, 49, 30), channel("HP")
line bounds(4, 302, 800, 2) colour("lime")
checkbox bounds(11, 310, 49, 30), channel("step1"), colour("yellow")
checkbox bounds(60, 310, 49, 30), channel("step2"), colour("yellow")
checkbox bounds(109, 310, 49, 30), channel("step3"), colour("yellow")
checkbox bounds(160, 310, 49, 30), channel("step4"), colour("yellow")
checkbox bounds(209, 310, 49, 30), channel("step5"), colour("yellow")
checkbox bounds(259, 310, 49, 30), channel("step6"), colour("yellow")
checkbox bounds(308, 310, 49, 30), channel("step7"), colour("yellow")
checkbox bounds(357, 310, 49, 30), channel("step8"), colour("yellow")
checkbox bounds(406, 310, 49, 30), channel("step9"), colour("yellow")
checkbox bounds(455, 310, 49, 30), channel("step10"), colour("yellow")
checkbox bounds(506, 310, 49, 30), channel("step11"), colour("yellow")
checkbox bounds(555, 310, 49, 30), channel("step12"), colour("yellow")
checkbox bounds(605, 310, 49, 30), channel("step13"), colour("yellow")
checkbox bounds(654, 310, 49, 30), channel("step14"), colour("yellow")
checkbox bounds(703, 310, 49, 30), channel("step15"), colour("yellow")
checkbox bounds(752, 310, 49, 30), channel("step16"), colour("yellow")
checkbox bounds(688, 355, 164, 30), colour("green"), fontcolour("white"), text("Enable"), channel("enable")
hslider bounds(360, 350, 311, 40), text("BPM"), textbox(1), range(10, 260, 180, 1, 1), channel("bpm")
hslider bounds(16, 350, 328, 40), text("Duration"), textbox(1), range(0.1, 10, 2), channel("duration")
}
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -m0d -M0 -Q0
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs=1
;freq 2 midi udo
opcode F2M, i, i
ifq xin
inotenum = round(12 * (log(ifq/220)/log(2)) + 57)
xout inotenum
endop
;simple UDO to toggle the 16 check boxes
opcode toggleCheckBoxes, k, kSSSSSSSSSSSSSSSS
kindex, S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16 xin
kOn = 1
kOff = 0
;turn off all check boxes first..
chnset kOff, S1
chnset kOff, S2
chnset kOff, S3
chnset kOff, S4
chnset kOff, S5
chnset kOff, S6
chnset kOff, S7
chnset kOff, S8
chnset kOff, S9
chnset kOff, S10
chnset kOff, S11
chnset kOff, S12
chnset kOff, S13
chnset kOff, S14
chnset kOff, S15
chnset kOff, S16
if(kindex==0) then
chnset kOn, S1
elseif(kindex==1) then
chnset kOn, S2
elseif(kindex==2) then
chnset kOn, S3
elseif(kindex==3) then
chnset kOn, S4
elseif(kindex==4) then
chnset kOn, S5
elseif(kindex==5) then
chnset kOn, S6
elseif(kindex==6) then
chnset kOn, S7
elseif(kindex==7) then
chnset kOn, S8
elseif(kindex==8) then
chnset kOn, S9
elseif(kindex==9) then
chnset kOn, S10
elseif(kindex==10) then
chnset kOn, S11
elseif(kindex==11) then
chnset kOn, S12
elseif(kindex==12) then
chnset kOn, S13
elseif(kindex==13) then
chnset kOn, S14
elseif(kindex==14) then
chnset kOn, S15
elseif(kindex==15) then
chnset kOn, S16
endif
xout kindex
endop
;init tables to hold hits, for sampler tables see the score
gif1 ftgen 100, 0, 16, 2, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 , 0, 0, 0, 0
gif2 ftgen 101, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif3 ftgen 102, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif4 ftgen 103, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif5 ftgen 104, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif6 ftgen 105, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif7 ftgen 106, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif8 ftgen 107, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif9 ftgen 108, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif10 ftgen 109, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif11 ftgen 110, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif12 ftgen 111, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif13 ftgen 112, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif14 ftgen 113, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif15 ftgen 114, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
gif16 ftgen 115, 0, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
instr 1000
kAA chnget "AA"
kBA chnget "BA"
kCA chnget "CA"
kDA chnget "DA"
kEA chnget "EA"
kFA chnget "FA"
kGA chnget "GA"
kHA chnget "HA"
kAB chnget "AB"
kBB chnget "BB"
kCB chnget "CB"
kDB chnget "DB"
kEB chnget "EB"
kFB chnget "FB"
kGB chnget "GB"
kHB chnget "HB"
kAC chnget "AC"
kBC chnget "BC"
kCC chnget "CC"
kDC chnget "DC"
kEC chnget "EC"
kFC chnget "FC"
kGC chnget "GC"
kHC chnget "HC"
kAD chnget "AD"
kBD chnget "BD"
kCD chnget "CD"
kDD chnget "DD"
kED chnget "ED"
kFD chnget "FD"
kGD chnget "GD"
kHD chnget "HD"
kAE chnget "AE"
kBE chnget "BE"
kCE chnget "CE"
kDE chnget "DE"
kEE chnget "EE"
kFE chnget "FE"
kGE chnget "GE"
kHE chnget "HE"
kAF chnget "AF"
kBF chnget "BF"
kCF chnget "CF"
kDF chnget "DF"
kEF chnget "EF"
kFF chnget "FF"
kGF chnget "GF"
kHF chnget "HF"
kAG chnget "AG"
kBG chnget "BG"
kCG chnget "CG"
kDG chnget "DG"
kEG chnget "EG"
kFG chnget "FG"
kGG chnget "GG"
kHG chnget "HG"
kAH chnget "AH"
kBH chnget "BH"
kCH chnget "CH"
kDH chnget "DH"
kEH chnget "EH"
kFH chnget "FH"
kGH chnget "GH"
kHH chnget "HH"
kAI chnget "AI"
kBI chnget "BI"
kCI chnget "CI"
kDI chnget "DI"
kEI chnget "EI"
kFI chnget "FI"
kGI chnget "GI"
kHI chnget "HI"
kAJ chnget "AJ"
kBJ chnget "BJ"
kCJ chnget "CJ"
kDJ chnget "DJ"
kEJ chnget "EJ"
kFJ chnget "FJ"
kGJ chnget "GJ"
kHJ chnget "HJ"
kAK chnget "AK"
kBK chnget "BK"
kCK chnget "CK"
kDK chnget "DK"
kEK chnget "EK"
kFK chnget "FK"
kGK chnget "GK"
kHK chnget "HK"
kAL chnget "AL"
kBL chnget "BL"
kCL chnget "CL"
kDL chnget "DL"
kEL chnget "EL"
kFL chnget "FL"
kGL chnget "GL"
kHL chnget "HL"
kAM chnget "AM"
kBM chnget "BM"
kCM chnget "CM"
kDM chnget "DM"
kEM chnget "EM"
kFM chnget "FM"
kGM chnget "GM"
kHM chnget "HM"
kAN chnget "AN"
kBN chnget "BN"
kCN chnget "CN"
kDN chnget "DN"
kEN chnget "EN"
kFN chnget "FN"
kGN chnget "GN"
kHN chnget "HN"
kAO chnget "AO"
kBO chnget "BO"
kCO chnget "CO"
kDO chnget "DO"
kEO chnget "EO"
kFO chnget "FO"
kGO chnget "GO"
kHO chnget "HO"
kAP chnget "AP"
kBP chnget "BP"
kCP chnget "CP"
kDP chnget "DP"
kEP chnget "EP"
kFP chnget "FP"
kGP chnget "GP"
kHP chnget "HP"
event "f", 100, 0, 16, 2, kAA, kAB, kAC, kAD, kAE, kAF, kAG, kAH, kAI, kAJ, kAK, kAL, kAM, kAN, kAO, kAP
event "f", 101, 0, 16, 2, kBA, kBB, kBC, kBD, kBE, kBF, kBG, kBH, kBI, kBJ, kBK, kBL, kBM, kBN, kBO, kBP
event "f", 102, 0, 16, 2, kCA, kCB, kCC, kCD, kCE, kCF, kCG, kCH, kCI, kCJ, kCK, kCL, kCM, kCN, kCO, kCP
event "f", 103, 0, 16, 2, kDA, kDB, kDC, kDD, kDE, kDF, kDG, kDH, kDI, kDJ, kDK, kDL, kDM, kDN, kDO, kDP
event "f", 104, 0, 16, 2, kEA, kEB, kEC, kED, kEE, kEF, kEG, kEH, kEI, kEJ, kEK, kEL, kEM, kEN, kEO, kEP
event "f", 105, 0, 16, 2, kFA, kFB, kFC, kFD, kFE, kFF, kFG, kFH, kFI, kFJ, kFK, kFL, kFM, kFN, kFO, kFP
event "f", 106, 0, 16, 2, kGA, kGB, kGC, kGD, kGE, kGF, kGG, kGH, kGI, kGJ, kGK, kGL, kGM, kGN, kGO, kGP
event "f", 107, 0, 16, 2, kHA, kHB, kHC, kHD, kHE, kHF, kHG, kHH, kHI, kHJ, kHK, kHL, kHM, kHN, kHO, kHP
endin
instr 2000
kGO chnget "enable"
if(kGO==1) then
iNumTables = 8
kIndex, kIncr, kNoteTable init 0
ktempo chnget "bpm"
kDuration chnget "duration"
kTrig metro ktempo/60 ;trig notes every 1/5 of a second
if(kTrig==1) then
Main_Loop:
k1 tablekt kIncr, kIndex+100
event "i", 1, 0, kDuration, k1, kIndex
loop_lt kIndex, 1, iNumTables, Main_Loop
kDummy toggleCheckBoxes, kIncr, "step1", "step2", "step3", "step4", "step5", "step6", "step7", "step8", "step9", "step10", "step11", "step12", "step13", "step14", "step15", "step16"
kIncr = (kIncr>14 ? 0 : kIncr+1)
kIndex=0
endif
endif
endin
instr 1
if(p4!=0)then
iNote tab_i p5, 1
iMIDINote F2M cpspch(iNote+8)
noteondur 1, iMIDINote, 20, p3
;midiout 176, 1, 1, 1
endif
endin
</CsInstruments>
<CsScore>
f1 0 8 -2 1 .11 .09 .07 .05 .04 .02 .00
i1000 1 1000
i2000 1 1000
</CsScore>
</CsoundSynthesizer>

+ 160
- 0
bin/cabbage/Synths/Additive.csd View File

@@ -0,0 +1,160 @@
<Cabbage>
form caption("Additive synthesizer") size(562, 340), colour("black"),pluginID("add1")
rslider bounds(15, 10, 100, 100) channel("speed"), range(1,10,2), caption("Speed"), colour("lime ")
rslider bounds(120, 10, 100, 100) channel("semi"), range(-12,12,0), caption("Coarse"), colour("lime ")
rslider bounds(225, 10, 100, 100) channel("partials"), range(3,8,4), caption("Partials"), colour("lime ")
rslider bounds(330, 10, 100, 100) caption("Vib Amp"), colour("lime "), channel("lfoamp"), range(0,20, 0)
rslider bounds(435, 10, 100, 100) caption("Vib Rate"), colour("lime "), channel("lforate"), range(0,20, 0)

groupbox bounds(15, 120, 240, 100), text("ADSR amplitude"), plant("ADSR"){
rslider bounds(0, .3, .6, .6), text("A"), colour("lime"), channel("att"), range(0.01,3, .5)
rslider bounds(.25, .3, .6, .6), text("D"), colour("lime "), channel("dec"), range(0,1, .5)
rslider bounds(.5, .3, .6, .6), text("S"), colour("lime "), channel("sus"), range(0,1,.8)
rslider bounds(.75, .3, .6, .6), text("R"), colour("lime "), channel("rel"), range(0.01,3, .2)
}
groupbox bounds(285, 120, 250, 100), text("Filter/Reverb"), plant("filtrev"){
rslider bounds(0, .3, .6, .6), text("cutoff"), colour("lime "), channel("cutoff"), range(200,8000,1000)
rslider bounds(.25, .3, .6, .6),text("level"), colour("lime "), channel("level"), range(0,1,.7)
rslider bounds(.5, .3, .6, .6), text("size"), colour("lime "), channel("size"), range(.1,.99,.8)
checkbox bounds(.75, .40, .60, .30),channel("onoff"), text("ON"), value(0)
}

keyboard pos(10, 240), size(540, 60)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n -+rtmidi=null -M0 -b1024 -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;Author: Giorgio Zucco (2012)
garev init 0


instr 1

;channel
kspeed chnget "speed"
ksemi1 chnget "semi"
ktable chnget "partials"
iatt chnget "att"
idec chnget "dec"
isus chnget "sus"
irel chnget "rel"
klfoamp chnget "lfoamp"
klforate chnget "lforate"
kcutoff chnget "cutoff"

;midi
imidinn notnum
iamp ampmidi 1
kbend pchbend 0,2 ;pitch bend
kbasefreq = cpsmidinn(imidinn+kbend+int(ksemi1)) ;controllo midi

;vibrato
klfo vibr klfoamp,klforate,1

;additive
kpartial init 3
iamptab = 2 ;tabella ampiezze
kpartial = int(ktable) ;tabella parziali

ktrig changed kpartial
if ktrig = 1 then
reinit play
endif
play:

k1 randomh 1,7,kspeed ;indice della tabella letto in modo casuale
k2 randomh 1,7,kspeed-.9 ;simile ad un arpeggio di armonici con rate indipendente
k3 randomh 1,7,kspeed-.8
k4 randomh 1,7,kspeed-.7
k5 randomh 1,7,kspeed-.6
k6 randomh 1,7,kspeed-.5
k7 randomh 1,7,kspeed-.4

;tabella delle parziali
kfreqtable1 table k1,i(kpartial)
kfreqtable2 table k2,i(kpartial)
kfreqtable3 table k3,i(kpartial)
kfreqtable4 table k4,i(kpartial)
kfreqtable5 table k5,i(kpartial)
kfreqtable6 table k6,i(kpartial)
kfreqtable7 table k7,i(kpartial)

;tabella ampiezze
iamptable1 table 1,iamptab
iamptable2 table 2,iamptab
iamptable3 table 3,iamptab
iamptable4 table 4,iamptab
iamptable5 table 5,iamptab
iamptable6 table 6,iamptab
iamptable7 table 7,iamptab

;otto oscillatori
a1 poscil iamp*2,(kbasefreq+klfo),1 ;frequenza fondamentale
a2 poscil iamp*iamptable1,((kbasefreq+klfo)+klfo)*kfreqtable1,1
a3 poscil iamp*iamptable2,(kbasefreq+klfo)*kfreqtable2,1
a4 poscil iamp*iamptable3,(kbasefreq+klfo)*kfreqtable3,1
a5 poscil iamp*iamptable4,(kbasefreq+klfo)*kfreqtable4,1
a6 poscil iamp*iamptable5,(kbasefreq+klfo)*kfreqtable5,1
a7 poscil iamp*iamptable6,(kbasefreq+klfo)*kfreqtable6,1
a8 poscil iamp*iamptable7,(kbasefreq+klfo)*kfreqtable7,1


asum sum a1,a2,a3,a4,a5,a6,a7,a8 ;somma degli oscillatori

afilt clfilt asum/8,kcutoff,0,4
aout clip afilt,0,0dbfs
kenv mxadsr iatt,idec,isus,irel

outs aout*kenv,aout*kenv ;uscita con inviluppo
vincr garev,aout*kenv

endin

instr 3 ;reverb
ktrig chnget "onoff"
klevel chnget "level"
ksize chnget "size"
if ktrig = 1 then
al,ar reverbsc garev,garev,ksize,16000,sr,0
adc1 dcblock2 al
adc2 dcblock2 ar
kpan1 randomi 0,1,4
kpan2 randomi 0,1,8
aout1,aout2 pan2 adc1,kpan1
aout3,aout4 pan2 adc2,1-kpan2
asum1 = (aout1+aout2)*klevel
asum2 = (aout3+aout4)*klevel
else
asum1 = 0
asum2 = 0
endif

outs asum1,asum2
clear garev
endin


</CsInstruments>
<CsScore>
f1 0 16384 10 1
f2 0 -7 -2 .9 .8 .7 .6 .5 .4 .3 .2 ;ampiezze parziali

f3 0 -7 -2 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 ;parziali
f4 0 -7 -2 1 2 3 4 5 6 7 8
f5 0 -7 -2 1 1.2 1.4 1.6 1.8 2 2.4 2.6
f6 0 -7 -2 1 2 4 5 7 8 10 11
f7 0 -7 -2 1 1.3 1.5 1.7 1.9 2.11 3.13 4.15
f8 0 -7 -2 1 1 3 5 7 9 11 13

i1 0 36000
i3 0 36000
</CsScore>
</CsoundSynthesizer>

+ 80
- 0
bin/cabbage/Synths/CrazyPluck.csd View File

@@ -0,0 +1,80 @@
<Cabbage>
form caption("CrazyPluck"), size(300, 220), pluginID("cra1")
groupbox bounds(0, 0, 300, 100), text("Parameters"), plant("control1"){
rslider bounds(.05, .3, .6, .6), text("ratio"), colour("white"), channel("ratio"), range(1, 1.2,1)
rslider bounds(.28, .3, .6, .6), text("time"), colour("white"), channel("time"), range(.001,.1,.1)
rslider bounds(.52, .3, .6, .6), text("random"), colour("white"), channel("random"), range(.001,.1,0)
rslider bounds(.75, .3, .6, .6), text("Event number"), colour("white"), channel("number"), range(1,50,10)
}
keyboard bounds(0, 110, 300, 70)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL -M0
</CsOptions>
<CsInstruments>

;Author: Giorgio Zucco (2012)


sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1


instr 1

giamp ampmidi 1 ;controllo midi
gifreq cpsmidi

instrument = 10 ;strumento da controllare
inum=1 ;per attivare la sezione loop
idelay = 0
inumber chnget "number" ;numero di eventi da generare
idur = 2 ;durata evento
iratio chnget "ratio" ;1,1,1,1.2 ;slider che controlla il pitch transpose
itime chnget "time" ;1,2,.001,.1 ;slider che controlla il delay tra un evento e il successivo
irndtime chnget "random" ;1,3,.001,.1 ;slider che controlla la variazione random del ritardo

loop: ;inizia la sezione da reiterare

gifreq = gifreq*iratio ;pitch controllato da slider 1
idelay = idelay+itime+rnd(irndtime) ;delay controllato da slider 2 e 3

event_i "i",instrument,idelay,idur,giamp,gifreq,abs(inumber)

loop_le inum,1,abs(inumber),loop ;ripete il processo per 20 istanze (inumber)

endin


instr 10

;a1 pluck (p4*1-p6)/p6,p5,p5,0,1
ival = (p4*1-p6)
a1 pluck ival/p6,p5,p5,0,1

; Or using the new csound 6 function syntax
;a1 = pluck((p4*1-p6)/p6,p5,p5,0,1)


aout clip a1,0,0dbfs
kenv adsr 0.01,.5,.2,.1 ;inviluppo

outs aout*kenv,aout*kenv

endin

</CsInstruments>
<CsScore>

;i1 0 36000
f0 36000



</CsScore>
</CsoundSynthesizer>

+ 54
- 0
bin/cabbage/Synths/Dust.csd View File

@@ -0,0 +1,54 @@
<Cabbage>
form caption("Dust"), size(300, 80), pluginID("dust")
image bounds( 0, 0,300, 80), colour("brown"), shape("rounded"), outline("white"), line(4)
checkbox bounds( 10, 10, 80, 15), text("On/Off"), channel("onoff"), value(1), fontcolour("white")
rslider bounds( 70, 10, 60, 60), text("Amplitude"), channel("amp"), range(0, 1.00, 0.5, 0.5, 0.001), fontcolour("white")
rslider bounds(125, 10, 60, 60), text("Freq."), channel("freq"), range(0.1, 10000, 500, 0.5, 0.01), fontcolour("white")
rslider bounds(180, 10, 60, 60), text("Spread"), channel("spread"), range(0, 1.00, 1), fontcolour("white")
rslider bounds(235, 10, 60, 60), text("Tone Var."), channel("ToneVar"), range(0, 1.00, 0), fontcolour("white")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE
massign 0,0

instr 1
konoff chnget "onoff" ;read in on/off switch widget value
if konoff==0 goto SKIP ;if on/off switch is off jump to skip label
kamp chnget "amp"
kfreq chnget "freq"
kspread chnget "spread"
asig dust2 kamp, kfreq ;GENERATE 'dust2' IMPULSES

; tone variation
kToneVar chnget "ToneVar"
if(kToneVar>0) then
kcfoct random 14-(kToneVar*10),14
asig tonex asig,cpsoct(kcfoct),1
endif


kpan random 0.5-(kspread*0.5), 0.5+(kspread*0.5)
asigL,asigR pan2 asig,kpan
outs asigL,asigR ;SEND AUDIO SIGNAL TO OUTPUT
SKIP: ;A label. Skip to here is on/off switch is off
endin


</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7] ;instrument that reads in widget data
</CsScore>

</CsoundSynthesizer>

+ 135
- 0
bin/cabbage/Synths/HiperSaw.csd View File

@@ -0,0 +1,135 @@
<Cabbage>
form caption("HiperSaw synthesizer") size(552, 330), colour("black"),pluginID("hip1")
rslider bounds(15, 10, 100, 100) channel("detune"), range(0,1,.5), caption("Depth"), colour("orange"), midictrl(1, 1)
rslider bounds(120, 10, 100, 100) channel("semi"), range(-12,12,-12), caption("Coarse"), colour("orange")
rslider bounds(225, 10, 100, 100) channel("cutoff"), range(60,22000,12000), caption("Cutoff"), colour("orange")
rslider bounds(330, 10, 100, 100) channel("reso"), range(.1,.99,.2), caption("Resonance"), colour("orange")
rslider bounds(435, 10, 100, 100) channel("spread"), range(0, 1, .5), caption("Stereo image"), colour("orange")

groupbox bounds(15, 120, 240, 100), text("ADSR amplitude"), plant("ADSR"){
rslider bounds(.0, .3, .6, .6), text("A"), colour("orange"), channel("att"), range(0.01,3, .5)
rslider bounds(.25, .3, .6, .6), text("D"), colour("orange"), channel("dec"), range(0,1, .5)
rslider bounds(.5, .3, .6, .6), text("S"), colour("orange"), channel("sus"), range(0,1,.8)
rslider bounds(.75, .3, .6, .6), text("R"), colour("orange"), channel("rel"), range(0.01,3, .2)
}

groupbox bounds(270, 120, 130, 100), text("LFO"), plant("lfo"){
rslider bounds(0.05, .30, .60, .60), text("Lfo Amp"), colour("orange"), channel("lfoamp"), range(0,100, 0)
rslider bounds(.5, .30, .60, .60), text("Lfo Rate"), colour("orange"), channel("lforate"), range(0,20, 0)
;rslider bounds(115, 30, 60, 60), text("S"), colour("orange"), channel("sus"), range(0,1,.8)
;rslider bounds(165, 30, 60, 60), text("R"), colour("orange"), channel("rel"), range(0.01,3, .2)
}
groupbox bounds(410, 120, 130, 100), text("LFO filter"), plant("lfofilter"){
rslider bounds(0.05, .30, .60, .60), text("Lfo Amp"), colour("orange"), channel("lfoamp2"), range(0,1000, 0)
rslider bounds(.5, .30, .60, .60), text("Lfo Rate"), colour("orange"), channel("lforate2"), range(0,10, 0)
;rslider bounds(115, 30, 60, 60), text("S"), colour("orange"), channel("sus"), range(0,1,.8)
;rslider bounds(165, 30, 60, 60), text("R"), colour("orange"), channel("rel"), range(0.01,3, .2)
}

keyboard pos(1, 240), size(550, 60)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n -+rtmidi=null -M0 -b1024 -m0d
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

;Author: Giorgio Zucco (2012)

;UDO Hipersaw
opcode Hipersaw2,a,kkki

kamp,kcps,kdetune,ifunc xin

krnd1 poscil kdetune,.1,ifunc
krnd2 poscil kdetune,.2,ifunc
krnd3 poscil kdetune,.3,ifunc
krnd4 poscil kdetune,.4,ifunc
krnd5 poscil kdetune,.5,ifunc
krnd6 poscil kdetune,.6,ifunc
krnd7 poscil kdetune,.7,ifunc
krnd8 poscil kdetune,.8,ifunc

a1 vco2 kamp,kcps,0
a2 vco2 kamp,kcps+kdetune,0
a3 vco2 kamp,kcps+(kdetune+krnd1)*.1,0
a4 vco2 kamp,kcps+(kdetune+krnd2)*.1,0
a5 vco2 kamp,kcps+(kdetune+krnd3)*.1,0
a6 vco2 kamp,kcps+(kdetune+krnd4)*.1,0
a7 vco2 kamp,kcps+(kdetune+krnd5)*.1,0
a8 vco2 kamp,kcps+(kdetune+krnd6)*.1,0
a9 vco2 kamp,kcps+(kdetune+krnd7)*.1,0
a10 vco2 kamp,kcps+(kdetune+krnd8)*.1,0


asum sum a1,a2,a3,a4,a5,a6,a7,a8,a9,a10


xout asum*.3 ; write output

endop


instr 1

;channel
kdrive chnget "detune"
ksemi1 chnget "semi"
kcut chnget "cutoff"
kreso chnget "reso"
kspread chnget "spread"
iatt chnget "att"
idec chnget "dec"
isus chnget "sus"
irel chnget "rel"
klfoamp chnget "lfoamp"
klforate chnget "lforate"
klfoamp2 chnget "lfoamp2" ;lfo x filter
klforate2 chnget "lforate2"
;midi
imidinn notnum
iamp ampmidi 1
kbend pchbend 0,2 ;pitch bend
kfreq1 = cpsmidinn(imidinn+kbend+int(ksemi1)) ;controllo midi
kfreq2 = cpsmidinn(imidinn+kbend+int(ksemi1)) ;controllo midi + detune

;lfo
klfo poscil klfoamp,klforate,1
;hipersaw waveform
asig1 Hipersaw2 iamp,(kfreq1+klfo),kdrive*8,1
asig2 Hipersaw2 iamp,(kfreq2+klfo),(1-kdrive*8),1

;filter
klfofilter lfo klfoamp2,klforate2,3
aout1 moogladder asig1,kcut+klfofilter,kreso
aout2 moogladder asig2,kcut+klfofilter,kreso
;aout1 balance amoog1,asig1
;aout2 balance amoog2,asig2

;master
aL clip aout1,0,.9
aR clip aout2,0,.9


aoutL = ((aL * kspread) + (aR * (1 - kspread))) *.5
aoutR = ((aL * (1-kspread)) + (aR * kspread)) *.5

kadsr mxadsr iatt,idec,isus,irel

outs aoutL*kadsr,aoutR*kadsr

endin



</CsInstruments>
<CsScore>
f1 0 4096 10 1
i1 0 36000
</CsScore>
</CsoundSynthesizer>

+ 41
- 0
bin/cabbage/Synths/WhiteNoise.csd View File

@@ -0,0 +1,41 @@
<Cabbage>
form caption("White Noise"), size(210, 80), pluginID("wnse")
image bounds( 0, 0,210, 80), colour("white"), shape("rounded"), outline("black"), line(4)
checkbox bounds( 20, 10, 80, 15), text("On/Off"), channel("onoff"), value(1), fontcolour("black")
rslider bounds( 80, 10, 60, 60), text("Amplitude"), channel("amp"), range(0, 1, 0.5, 0.5, 0.001), fontcolour("black")
rslider bounds(140, 10, 60, 60), text("Beta"), channel("beta"), range(-0.999, 0.999,0,1,0.001), fontcolour("black")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-dm0 -n -+rtmidi=null -M0
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1 ;MAXIMUM AMPLITUDE
massign 0,0

instr 1
konoff chnget "onoff" ;read in on/off switch widget value
if konoff==0 goto SKIP ;if on/off switch is off jump to skip label
kamp chnget "amp" ;read in widgets...
kbeta chnget "beta" ;
asigL noise kamp, kbeta ;GENERATE WHITE NOISE
asigR noise kamp, kbeta ;GENERATE WHITE NOISE
outs asigL,asigR ;SEND AUDIO SIGNAL TO OUTPUT
SKIP: ;A label. Skip to here is on/off switch is off
endin


</CsInstruments>

<CsScore>
i 1 0 [60*60*24*7] ;instrument that reads in widget data
</CsScore>

</CsoundSynthesizer>

+ 612
- 0
bin/cabbage/Synths/bassline.csd View File

@@ -0,0 +1,612 @@
<Cabbage>
form caption("Bassline") size(615, 250), pluginID("basl")

snapshot bounds( 80,185,200, 20), preset("bassline"), items("Preset 1", "Preset 2", "Preset 3", "Preset 4", "Preset 5", "Preset 6", "Preset 7", "Preset 8", "Preset 9", "Preset 10")

image bounds( 0, 0,615,220), colour("grey"), shape("rounded"), outline("white"), line(4)
checkbox bounds( 64, 8, 4, 4), channel("Act1"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds( 99, 8, 4, 4), channel("Act2"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(134, 8, 4, 4), channel("Act3"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(169, 8, 4, 4), channel("Act4"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(204, 8, 4, 4), channel("Act5"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(239, 8, 4, 4), channel("Act6"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(274, 8, 4, 4), channel("Act7"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(309, 8, 4, 4), channel("Act8"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(344, 8, 4, 4), channel("Act9"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(379, 8, 4, 4), channel("Act10"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(414, 8, 4, 4), channel("Act11"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(449, 8, 4, 4), channel("Act12"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(484, 8, 4, 4), channel("Act13"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(519, 8, 4, 4), channel("Act14"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(554, 8, 4, 4), channel("Act15"), value(0), colour("yellow"), shape("ellipse")
checkbox bounds(589, 8, 4, 4), channel("Act16"), value(0), colour("yellow"), shape("ellipse")

label bounds( 10, 23, 40, 12), text("Note"), FontColour("black"), colour("black")
rslider bounds( 45, 15, 45, 45), text("1"), FontColour("black"), channel("Note1"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds( 80, 15, 45, 45), text("2"), channel("Note2"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(115, 15, 45, 45), text("3"), channel("Note3"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(150, 15, 45, 45), text("4"), channel("Note4"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(185, 15, 45, 45), text("5"), channel("Note5"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(220, 15, 45, 45), text("6"), channel("Note6"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(255, 15, 45, 45), text("7"), channel("Note7"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(290, 15, 45, 45), text("8"), channel("Note8"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(325, 15, 45, 45), text("9"), channel("Note9"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(360, 15, 45, 45), text("10"), channel("Note10"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(395, 15, 45, 45), text("11"), channel("Note11"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(430, 15, 45, 45), text("12"), channel("Note12"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(465, 15, 45, 45), text("13"), channel("Note13"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(500, 15, 45, 45), text("14"), channel("Note14"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(535, 15, 45, 45), text("15"), channel("Note15"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")
rslider bounds(570, 15, 45, 45), text("16"), channel("Note16"), FontColour("black"), range(24, 96, 60, 1, 1), preset("bassline")

label bounds( 10, 62, 40, 12), text("On/Off"), colour("black"), FontColour("black")
checkbox bounds( 61, 62, 12, 12), channel("On1"), value(0), preset("bassline")
checkbox bounds( 96, 62, 12, 12), channel("On2"), value(0), preset("bassline")
checkbox bounds(131, 62, 12, 12), channel("On3"), value(0), preset("bassline")
checkbox bounds(166, 62, 12, 12), channel("On4"), value(0), preset("bassline")
checkbox bounds(201, 62, 12, 12), channel("On5"), value(0), preset("bassline")
checkbox bounds(236, 62, 12, 12), channel("On6"), value(0), preset("bassline")
checkbox bounds(271, 62, 12, 12), channel("On7"), value(0), preset("bassline")
checkbox bounds(306, 62, 12, 12), channel("On8"), value(0), preset("bassline")
checkbox bounds(341, 62, 12, 12), channel("On9"), value(0), preset("bassline")
checkbox bounds(376, 62, 12, 12), channel("On10"), value(0), preset("bassline")
checkbox bounds(411, 62, 12, 12), channel("On11"), value(0), preset("bassline")
checkbox bounds(446, 62, 12, 12), channel("On12"), value(0), preset("bassline")
checkbox bounds(481, 62, 12, 12), channel("On13"), value(0), preset("bassline")
checkbox bounds(516, 62, 12, 12), channel("On14"), value(0), preset("bassline")
checkbox bounds(551, 62, 12, 12), channel("On15"), value(0), preset("bassline")
checkbox bounds(586, 62, 12, 12), channel("On16"), value(0), preset("bassline")

label bounds( 11, 80, 40, 12), text("Hold"), colour("black"), FontColour("black")
checkbox bounds( 61, 80, 12, 12), channel("Hold1"), value(0), preset("bassline")
checkbox bounds( 96, 80, 12, 12), channel("Hold2"), value(0), preset("bassline")
checkbox bounds(131, 80, 12, 12), channel("Hold3"), value(0), preset("bassline")
checkbox bounds(166, 80, 12, 12), channel("Hold4"), value(0), preset("bassline")
checkbox bounds(201, 80, 12, 12), channel("Hold5"), value(0), preset("bassline")
checkbox bounds(236, 80, 12, 12), channel("Hold6"), value(0), preset("bassline")
checkbox bounds(271, 80, 12, 12), channel("Hold7"), value(0), preset("bassline")
checkbox bounds(306, 80, 12, 12), channel("Hold8"), value(0), preset("bassline")
checkbox bounds(341, 80, 12, 12), channel("Hold9"), value(0), preset("bassline")
checkbox bounds(376, 80, 12, 12), channel("Hold10"), value(0), preset("bassline")
checkbox bounds(411, 80, 12, 12), channel("Hold11"), value(0), preset("bassline")
checkbox bounds(446, 80, 12, 12), channel("Hold12"), value(0), preset("bassline")
checkbox bounds(481, 80, 12, 12), channel("Hold13"), value(0), preset("bassline")
checkbox bounds(516, 80, 12, 12), channel("Hold14"), value(0), preset("bassline")
checkbox bounds(551, 80, 12, 12), channel("Hold15"), value(0), preset("bassline")
checkbox bounds(586, 80, 12, 12), channel("Hold16"), value(0), preset("bassline")

label bounds( 11, 98, 40, 12), text("Accent"), colour("black"), FontColour("black")
checkbox bounds( 61, 98, 12, 12), channel("Acc1"), value(0), preset("bassline")
checkbox bounds( 96, 98, 12, 12), channel("Acc2"), value(0), preset("bassline")
checkbox bounds(131, 98, 12, 12), channel("Acc3"), value(0), preset("bassline")
checkbox bounds(166, 98, 12, 12), channel("Acc4"), value(0), preset("bassline")
checkbox bounds(201, 98, 12, 12), channel("Acc5"), value(0), preset("bassline")
checkbox bounds(236, 98, 12, 12), channel("Acc6"), value(0), preset("bassline")
checkbox bounds(271, 98, 12, 12), channel("Acc7"), value(0), preset("bassline")
checkbox bounds(306, 98, 12, 12), channel("Acc8"), value(0), preset("bassline")
checkbox bounds(341, 98, 12, 12), channel("Acc9"), value(0), preset("bassline")
checkbox bounds(376, 98, 12, 12), channel("Acc10"), value(0), preset("bassline")
checkbox bounds(411, 98, 12, 12), channel("Acc11"), value(0), preset("bassline")
checkbox bounds(446, 98, 12, 12), channel("Acc12"), value(0), preset("bassline")
checkbox bounds(481, 98, 12, 12), channel("Acc13"), value(0), preset("bassline")
checkbox bounds(516, 98, 12, 12), channel("Acc14"), value(0), preset("bassline")
checkbox bounds(551, 98, 12, 12), channel("Acc15"), value(0), preset("bassline")
checkbox bounds(586, 98, 12, 12), channel("Acc16"), value(0), preset("bassline")

button bounds( 10,120, 60, 25), colour("Green"), text("Stop", "Run"), channel("OnOff"), value(1)
combobox bounds( 10,150, 60, 15), channel("Waveform"), value(1), text("saw","square","triangle","PWM","noise"), preset("bassline")
rslider bounds( 20,170, 40, 40), text("P.W."), channel("pw"), range(0.01,0.99, 0.25), preset("bassline"), FontColour("black")
rslider bounds( 70,120, 60, 60), text("Vol."), channel("Vol"), range(0, 5.00, 1), preset("bassline"), FontColour("black")
rslider bounds(120,120, 60, 60), text("Cutoff"), channel("CfBase"), range(4.00, 14, 8), preset("bassline"), FontColour("black")
rslider bounds(170,120, 60, 60), text("Env.Mod"), channel("CfEnv"), range(0, 10.00, 4), preset("bassline"), FontColour("black")
rslider bounds(220,120, 60, 60), text("Res."), channel("Res"), range(0,0.98, .4), preset("bassline"), FontColour("black")
rslider bounds(270,120, 60, 60), text("Dist."), channel("Dist"), range(0,1.00, 0), preset("bassline"), FontColour("black")
rslider bounds(320,120, 60, 60), text("Decay"), channel("Decay"), range(0.10, 5, .3, 0.25), preset("bassline"), FontColour("black")
rslider bounds(370,120, 60, 60), text("Accent"), channel("Accent"), range(0, 1.00, .5), preset("bassline"), FontColour("black")
rslider bounds(420,120, 60, 60), text("Tempo"), channel("Tempo"), range(1, 500, 110, 1, 1), FontColour("black"), FontColour("black")
button bounds(480,120, 60, 15), text("Reset"), channel("Reset"), value(0)
button bounds(540,120, 60, 15), text("Random"), channel("Rnd"), value(0)
button bounds(480,140, 60, 15), text("-semi"), channel("SemiDn"), value(0)
button bounds(540,140, 60, 15), text("+semi"), channel("SemiUp"), value(0)
button bounds(480,160, 60, 15), text("-oct"), channel("OctDn"), value(0)
button bounds(540,160, 60, 15), text("+oct"), channel("OctUp"), value(0)

button bounds(280, 185, 80, 20), text("External", "Internal"), channel("ClockSource"), value(0)
label bounds(285, 205, 80, 12), text("Clock Source"), FontColour("black")

image bounds(5, 225, 330, 20), colour(75, 85, 90, 100), plant("credit"){
label bounds(0.03, 0.1, .6, .7), text("Author: Iain McCurdy |2012|"), colour("white")
}

hostbpm channel("bpm")
</Cabbage>

<CsoundSynthesizer>

<CsOptions>
-d -n
</CsOptions>

<CsInstruments>

sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1
seed 0
;Author: Iain McCurdy (2012)

opcode moogladdersr,a,akk
asig,kcf,kres xin
setksmps 1
acf interp kcf
kcf downsamp acf
asig moogladder asig, kcf, kres
xout asig
endop

opcode resonsr,a,akki
asig,kcf,kbw,iscal xin
setksmps 1
acf interp kcf
kcf downsamp acf
abw interp kbw
kbw downsamp abw
asig reson asig, kcf, kbw,iscal
xout asig
endop

instr 1 ;BASSLINE INSTRUMENT
kporttime linseg 0,0.001,0.01 ;PORTAMENTO TIME RAMPS UP QUICKLY FROM ZERO TO A HELD VALUE
;READ IN WIDGETS...
gkOnOff chnget "OnOff"
gkNote1 chnget "Note1"
gkNote2 chnget "Note2"
gkNote3 chnget "Note3"
gkNote4 chnget "Note4"
gkNote5 chnget "Note5"
gkNote6 chnget "Note6"
gkNote7 chnget "Note7"
gkNote8 chnget "Note8"
gkNote9 chnget "Note9"
gkNote10 chnget "Note10"
gkNote11 chnget "Note11"
gkNote12 chnget "Note12"
gkNote13 chnget "Note13"
gkNote14 chnget "Note14"
gkNote15 chnget "Note15"
gkNote16 chnget "Note16"
gkOn1 chnget "On1"
gkOn2 chnget "On2"
gkOn3 chnget "On3"
gkOn4 chnget "On4"
gkOn5 chnget "On5"
gkOn6 chnget "On6"
gkOn7 chnget "On7"
gkOn8 chnget "On8"
gkOn9 chnget "On9"
gkOn10 chnget "On10"
gkOn11 chnget "On11"
gkOn12 chnget "On12"
gkOn13 chnget "On13"
gkOn14 chnget "On14"
gkOn15 chnget "On15"
gkOn16 chnget "On16"
gkHold1 chnget "Hold1"
gkHold2 chnget "Hold2"
gkHold3 chnget "Hold3"
gkHold4 chnget "Hold4"
gkHold5 chnget "Hold5"
gkHold6 chnget "Hold6"
gkHold7 chnget "Hold7"
gkHold8 chnget "Hold8"
gkHold9 chnget "Hold9"
gkHold10 chnget "Hold10"
gkHold11 chnget "Hold11"
gkHold12 chnget "Hold12"
gkHold13 chnget "Hold13"
gkHold14 chnget "Hold14"
gkHold15 chnget "Hold15"
gkHold16 chnget "Hold16"
gkAcc1 chnget "Acc1"
gkAcc2 chnget "Acc2"
gkAcc3 chnget "Acc3"
gkAcc4 chnget "Acc4"
gkAcc5 chnget "Acc5"
gkAcc6 chnget "Acc6"
gkAcc7 chnget "Acc7"
gkAcc8 chnget "Acc8"
gkAcc9 chnget "Acc9"
gkAcc10 chnget "Acc10"
gkAcc11 chnget "Acc11"
gkAcc12 chnget "Acc12"
gkAcc13 chnget "Acc13"
gkAcc14 chnget "Acc14"
gkAcc15 chnget "Acc15"
gkAcc16 chnget "Acc16"
gkVol chnget "Vol"
gkCfBase chnget "CfBase"
gkCfBase portk gkCfBase,kporttime*5
gkCfEnv chnget "CfEnv"
gkCfEnv portk gkCfEnv,kporttime*5
gkRes chnget "Res"
gkDist chnget "Dist"
gkDecay chnget "Decay"
gkAccent chnget "Accent"
gkWaveform chnget "Waveform"
kpw chnget "pw"
gkReset chnget "Reset"
gkRnd chnget "Rnd"
kSemiDn chnget "SemiDn"
kSemiUp chnget "SemiUp"
kOctDn chnget "OctDn"
kOctUp chnget "OctUp"
kClockSource chnget "ClockSource"
if kClockSource==0 then
gkTempo chnget "Tempo"
else
gkTempo chnget "bpm"
gkTempo limit gkTempo,1,2000
endif
kNonActive init 0
kStop trigger gkOnOff,0.5,1 ; IS LOOP PLAYING TURNED OFF...
if kStop==1 then
chnset kNonActive,"Act1"
chnset kNonActive,"Act2"
chnset kNonActive,"Act3"
chnset kNonActive,"Act4"
chnset kNonActive,"Act5"
chnset kNonActive,"Act6"
chnset kNonActive,"Act7"
chnset kNonActive,"Act8"
chnset kNonActive,"Act9"
chnset kNonActive,"Act10"
chnset kNonActive,"Act11"
chnset kNonActive,"Act12"
chnset kNonActive,"Act13"
chnset kNonActive,"Act14"
chnset kNonActive,"Act15"
chnset kNonActive,"Act16"
reinit RESET_LOOP
endif
RESET_LOOP:

if gkOnOff==0 kgoto SKIP
kPhFreq = gkTempo/240 ;FREQUENCY WITH WHICH TO REPEAT THE ENTIRE PHRASE
kBtFreq = gkTempo/15 ;FREQUENCY OF EACH 1/16TH NOTE
kNewNote metro kBtFreq ;GENERATES A TRIGGER FOR EACH BEAT
;ENVELOPES WITH HELD SEGMENTS
; freq trig ph NOTE:1 (dur) 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 DUMMY
kNoteLoop lpshold kPhFreq, 0, 0, gkNote1, 1, gkNote2, 1, gkNote3, 1, gkNote4, 1, gkNote5, 1, gkNote6, 1, gkNote7, 1, gkNote8, 1, gkNote9, 1, gkNote10, 1, gkNote11, 1, gkNote12, 1, gkNote13, 1, gkNote4, 1, gkNote15, 1, gkNote16, 1 ;,gkNote1 ;NEED AN EXTRA 'DUMMY' VALUE
kOn lpshold kPhFreq, 0, 0, gkOn1, 1, gkOn2, 1, gkOn3, 1, gkOn4, 1, gkOn5, 1, gkOn6, 1, gkOn7, 1, gkOn8, 1, gkOn9, 1, gkOn10, 1, gkOn11, 1, gkOn12, 1, gkOn13, 1, gkOn14, 1, gkOn15, 1, gkOn16, 1 ;,1 ;NEED AN EXTRA 'DUMMY' VALUE
kAcc lpshold kPhFreq, 0, 0, gkAcc1, 1, gkAcc2, 1, gkAcc3, 1, gkAcc4, 1, gkAcc5, 1, gkAcc6, 1, gkAcc7, 1, gkAcc8, 1, gkAcc9, 1, gkAcc10, 1, gkAcc11, 1, gkAcc12, 1, gkAcc13, 1, gkAcc14, 1, gkAcc15, 1, gkAcc16, 1 ;,1 ;NEED AN EXTRA 'DUMMY' VALUE
kHoldLoop lpshold kPhFreq, 0, 0, gkHold1, 1, gkHold2, 1, gkHold3, 1, gkHold4, 1, gkHold5, 1, gkHold6, 1, gkHold7, 1, gkHold8, 1, gkHold9, 1, gkHold10, 1, gkHold11, 1, gkHold12, 1, gkHold13, 1, gkHold14, 1, gkHold15, 1, gkHold16, 1 ;,0 ;NEED AN EXTRA 'DUMMY' VALUE
kStep lpshold kPhFreq, 0, 0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1 ;,0 ;NEED AN EXTRA 'DUMMY' VALUE
kNewOn trigger kOn,0.5,0 ;SENSE A NOTE ON FOLLOWING A NOTE OFF
kAcc portk kAcc*gkAccent,kporttime ;SCALE ACCENT USING ON-SCREEN KNOB AND SMOOTH CHANGES IN ACCENT VALUE TO PREVENT CLICKS
;IGNORE PITCH VALUES AND HOLD VALUES FOR 'OFF' NOTES
kNote init i(gkNote1)
if kOn==1 then ;IF THIS IS AN 'ON' NOTE...
kNote = kNoteLoop ;USE NOTE LOOP VALUE FOR PCH
kHold = kHoldLoop ;USE HOLD LOOP VALUE FOR HOLD
endif
kHoldDel vdel_k kHold, 1/(kBtFreq*2), 1 ;OFFSET HOLD SO THAT ITS VALUE WILL OVERLAP THE NEXT NOTE
kNote portk kNote, 0.01*kHoldDel*kOn ;APPLY PORTAMENTO TO PITCH CHANGES - IF NOTE IS NOT HELD, NO PORTAMENTO WILL BE APPLIED
;FILTER ENVELOPE
kFiltRetrig = (1-kHoldDel) * kNewNote * kOn ; + kOnTrig
;CREATE A FILTER CUTOFF FREQUENCY ENVELOPE. FILTER ATTACK LEVEL IS A SUM OF BASE FREQUENCY, ENVELOPE DEPTH AND ACCENT
; freq trig ph v t v t v t(?)
kCfOct loopseg 1/3600, kFiltRetrig+kNewOn, 0, gkCfBase+gkCfEnv+(kAcc*2), gkDecay, gkCfBase, 3600-gkDecay, gkCfBase, 0
kCfOct limit kCfOct, 4, 14 ;LIMIT THE CUTOFF FREQUENCY TO BE WITHIN SENSIBLE LIMITS
;AMPLITUDE ENVELOPE - SEPARATES NOTES THAT ARE NOT HELD
katt = 0.02 * (60/gkTempo)
kdec = 0.02 * (60/gkTempo)
; freq trig ph v tim v t v t v t(?)
kAmpEnv loopseg kBtFreq, 0, 0, 0, katt, 1, (1/kBtFreq)-katt-kdec, 1, kdec,0, 0 ;SUSTAIN SEGMENT DURATION (AND THEREFORE ATTACK AND DECAY SEGMENT DURATIONS) ARE DEPENDENT UPON TEMPO
kAmp = (kHoldDel==1?1:kAmpEnv)
;AUDIO OSCILLATOR
kWavTrig changed gkWaveform ;GENERATE A 'BANG' IF WAVEFORM SELECTOR CHANGES
if kWavTrig=1 then ;IF A 'BANG' HAS BEEN GENERATED...
reinit REINIT_VCO ;BEGIN A REINITIALIZATION PASS FROM THE LABEL 'REINIT_VCO'
endif
REINIT_VCO: ;A LABEL
if i(gkWaveform)==1 then ;SAWTOOTH
imode = 0
elseif i(gkWaveform)==2 then ;SQUARE
imode = 10
elseif i(gkWaveform)==3 then ;TRIANGLE
imode = 12
elseif i(gkWaveform)==4 then ;PWM
imode = 2
elseif i(gkWaveform)==5 then ;NOISE
anoise pinkish 1
aSig resonsr anoise,cpsmidinn(kNote),cpsmidinn(kNote)*0.005,1
aSig = aSig*20
goto SKIP_VCO2
endif
kpw portk kpw,kporttime
aSig vco2 0.2, cpsmidinn(kNote), imode, kpw ;GENERATE AUDIO USING VCO OSCILLATOR
SKIP_VCO2:
rireturn ;RETURN FROM INITIALIZATION PASS TO PERFORMANCE PASSES

;FILTER (CALLS UDO: A VERSION OF moogladder IN WHICH CUTOFF FREQUENCY IS MODULATED AT kr=sr) IN ORDER TO PREVENT QUANTISATION NOISE)
kres limit gkRes+(kAcc*0.4),0,0.98 ;PREVENT EXCESSIVE RESONANCE THAT COULD RESULT FROM THE COMBINATION OF RESONANCE SETTING AND ACCENTING
/*
aFilt moogladdersr aSig, cpsoct(kCfOct), kres ;FILTER AUDIO
aSig balance aFilt,aSig
;DISTORTION
if gkDist==0 kgoto SKIP_DISTORTION
iSclLimit ftgentmp 0, 0, 1024, -16, 1, 1024, -8, 0.01 ;RESCALING CURVE FOR CLIP 'LIMIT' PARAMETER
iSclGain ftgentmp 0, 0, 1024, -16, 1, 1024, 4, 10 ;RESCALING CURVE FOR GAIN COMPENSATION
kLimit table gkDist, iSclLimit, 1 ;READ LIMIT VALUE FROM RESCALING CURVE
kGain table gkDist, iSclGain, 1 ;READ GAIN VALUE FROM RESCALING CURVE
kTrigDist changed kLimit ;IF LIMIT VALUE CHANGES GENERATE A 'BANG'
if kTrigDist=1 then ;IF A 'BANG' HAS BEEN GENERATED...
reinit REINIT_CLIP ;BEGIN A REINITIALIZATION PASS FROM LABEL 'REINIT_CLIP'
endif
REINIT_CLIP:
aSig clip aSig, 0, i(kLimit) ;CLIP DISTORT AUDIO SIGNAL
rireturn ;
aSig = aSig * kGain ;COMPENSATE FOR GAIN LOSS FROM 'CLIP' PROCESSING
*/
iSclGain ftgentmp 0, 0, 1024, -16, 1, 1024, -6, 0.1 ;RESCALING CURVE FOR GAIN COMPENSATION
kGain table gkDist, iSclGain, 1 ;READ GAIN VALUE FROM RESCALING CURVE
aSig lpf18 aSig,cpsoct(kCfOct),kres, (gkDist^2)*20 ;LOWPASS
;aSig tone aSig,cpsoct(kCfOct)
af1 resonz aSig,150,150,1
aSig = aSig+af1
aSig butlp aSig,4000
aSig = aSig * kGain ;COMPENSATE FOR GAIN LOSS FROM 'CLIP' PROCESSING
SKIP_DISTORTION:
kOn port kOn, 0.006 ;SMOOTH CHANGES IN ON OFF SWITCHING
aAmp interp kAmp*kOn*((kAcc*0.7)+1)*gkVol ;COMBINE ALL FACTORS THAT CONTRIBUTE TO AMPLITUDE AND INTERPOLATE AND CREATE AN A-RATE VERSION OF THIS RESULT (TO PREVENT QUANTISATION NOISE)
aSig = aSig * aAmp ;SCALE AUDIO USING AMPLITUDE CONTROL FUNCTION
outs aSig, aSig ;AUDIO SENT TO OUTPUT, APPLY AMP. ENVELOPE, VOLUME CONTROL AND NOTE ON/OFF STATUS

rireturn
SKIP:
;RESET SEQUENCE TO BLANK
ktrig changed gkReset
if ktrig==1 then
kval = 60
chnset kval,"Note1"
chnset kval,"Note2"
chnset kval,"Note3"
chnset kval,"Note4"
chnset kval,"Note5"
chnset kval,"Note6"
chnset kval,"Note7"
chnset kval,"Note8"
chnset kval,"Note9"
chnset kval,"Note10"
chnset kval,"Note11"
chnset kval,"Note12"
chnset kval,"Note13"
chnset kval,"Note14"
chnset kval,"Note15"
chnset kval,"Note16"
kval = 0
chnset kval,"On1"
chnset kval,"On2"
chnset kval,"On3"
chnset kval,"On4"
chnset kval,"On5"
chnset kval,"On6"
chnset kval,"On7"
chnset kval,"On8"
chnset kval,"On9"
chnset kval,"On10"
chnset kval,"On11"
chnset kval,"On12"
chnset kval,"On13"
chnset kval,"On14"
chnset kval,"On15"
chnset kval,"On16"
chnset kval,"Hold1"
chnset kval,"Hold2"
chnset kval,"Hold3"
chnset kval,"Hold4"
chnset kval,"Hold5"
chnset kval,"Hold6"
chnset kval,"Hold7"
chnset kval,"Hold8"
chnset kval,"Hold9"
chnset kval,"Hold10"
chnset kval,"Hold11"
chnset kval,"Hold12"
chnset kval,"Hold13"
chnset kval,"Hold14"
chnset kval,"Hold15"
chnset kval,"Hold16"
chnset kval,"Acc1"
chnset kval,"Acc2"
chnset kval,"Acc3"
chnset kval,"Acc4"
chnset kval,"Acc5"
chnset kval,"Acc6"
chnset kval,"Acc7"
chnset kval,"Acc8"
chnset kval,"Acc9"
chnset kval,"Acc10"
chnset kval,"Acc11"
chnset kval,"Acc12"
chnset kval,"Acc13"
chnset kval,"Acc14"
chnset kval,"Acc15"
chnset kval,"Acc16"
endif

;RANDOMISE SEQUENCE
ktrig changed gkRnd
if ktrig==1 then
#define RANDOM_STEP(N)
#
kval random 48,72.999
chnset int(kval),"Note$N"
kval random 0,1.999
chnset int(kval),"On$N"
kval random 0,1.999
chnset int(kval),"Hold$N"
kval random 0,1.999
chnset int(kval),"Acc$N"
#
$RANDOM_STEP(1)
$RANDOM_STEP(2)
$RANDOM_STEP(3)
$RANDOM_STEP(4)
$RANDOM_STEP(5)
$RANDOM_STEP(6)
$RANDOM_STEP(7)
$RANDOM_STEP(8)
$RANDOM_STEP(9)
$RANDOM_STEP(10)
$RANDOM_STEP(11)
$RANDOM_STEP(12)
$RANDOM_STEP(13)
$RANDOM_STEP(14)
$RANDOM_STEP(15)
$RANDOM_STEP(16)
endif
;PROGRESS INDICATORS
kStepChange changed kStep
kActive = 1
kNonActive = 0
if kStepChange==1 then
if kStep==1 then
chnset kActive,"Act1"
chnset kNonActive,"Act16"
elseif kStep==2 then
chnset kActive,"Act2"
chnset kNonActive,"Act1"
elseif kStep==3 then
chnset kActive,"Act3"
chnset kNonActive,"Act2"
elseif kStep==4 then
chnset kActive,"Act4"
chnset kNonActive,"Act3"
elseif kStep==5 then
chnset kActive,"Act5"
chnset kNonActive,"Act4"
elseif kStep==6 then
chnset kActive,"Act6"
chnset kNonActive,"Act5"
elseif kStep==7 then
chnset kActive,"Act7"
chnset kNonActive,"Act6"
elseif kStep==8 then
chnset kActive,"Act8"
chnset kNonActive,"Act7"
elseif kStep==9 then
chnset kActive,"Act9"
chnset kNonActive,"Act8"
elseif kStep==10 then
chnset kActive,"Act10"
chnset kNonActive,"Act9"
elseif kStep==11 then
chnset kActive,"Act11"
chnset kNonActive,"Act10"
elseif kStep==12 then
chnset kActive,"Act12"
chnset kNonActive,"Act11"
elseif kStep==13 then
chnset kActive,"Act13"
chnset kNonActive,"Act12"
elseif kStep==14 then
chnset kActive,"Act14"
chnset kNonActive,"Act13"
elseif kStep==15 then
chnset kActive,"Act15"
chnset kNonActive,"Act14"
elseif kStep==16 then
chnset kActive,"Act16"
chnset kNonActive,"Act15"
endif
endif

;TRANSPOSE
ktrig1 changed kSemiDn
ktrig2 changed kSemiUp
ktrig3 changed kOctDn
ktrig4 changed kOctUp
if ktrig1+ktrig2+ktrig3+ktrig4==1 then
#define TRANSPOSE(N)
#
kval limit gkNote$N+kInt,24,96
chnset kval,"Note$N"
#
if ktrig1==1 then
kInt = -1
elseif ktrig2==1 then
kInt = 1
elseif ktrig3==1 then
kInt = -12
elseif ktrig4==1 then
kInt = 12
endif
$TRANSPOSE(1)
$TRANSPOSE(2)
$TRANSPOSE(3)
$TRANSPOSE(4)
$TRANSPOSE(5)
$TRANSPOSE(6)
$TRANSPOSE(7)
$TRANSPOSE(8)
$TRANSPOSE(9)
$TRANSPOSE(10)
$TRANSPOSE(11)
$TRANSPOSE(12)
$TRANSPOSE(13)
$TRANSPOSE(14)
$TRANSPOSE(15)
$TRANSPOSE(16)
endif
endin
</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>




























+ 77
- 0
bin/cabbage/Synths/bassline.snaps View File

@@ -0,0 +1,77 @@
------------------------ Instrument ID: bassline
-------- Start of Preset: Preset 1
Note1: 48
Note2: 60
Note3: 60
Note4: 60
Note5: 60
Note6: 60
Note7: 60
Note8: 60
Note9: 60
Note10: 60
Note11: 60
Note12: 60
Note13: 60
Note14: 60
Note15: 60
Note16: 60
On1: 1
On2: 0
On3: 0
On4: 0
On5: 0
On6: 0
On7: 0
On8: 0
On9: 0
On10: 0
On11: 0
On12: 0
On13: 0
On14: 0
On15: 0
On16: 0
Hold1: 0
Hold2: 0
Hold3: 0
Hold4: 0
Hold5: 0
Hold6: 0
Hold7: 0
Hold8: 0
Hold9: 0
Hold10: 0
Hold11: 0
Hold12: 0
Hold13: 0
Hold14: 0
Hold15: 0
Hold16: 0
Acc1: 0
Acc2: 0
Acc3: 0
Acc4: 0
Acc5: 0
Acc6: 0
Acc7: 0
Acc8: 0
Acc9: 0
Acc10: 0
Acc11: 0
Acc12: 0
Acc13: 0
Acc14: 0
Acc15: 0
Acc16: 0
Waveform: 1
pw: 0.25
Vol: 1
CfBase: 8
CfEnv: 4
Res: 0.400000006
Dist: 0
Decay: 0.300000012
Accent: 0.5
-------- End of Preset: Preset 1
------------------------ End of Instrument ID: bassline

+ 280
- 0
doc/GPL.txt View File

@@ -0,0 +1,280 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

+ 165
- 0
doc/LGPL.txt View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

+ 64
- 0
libs/dgl/App.hpp View File

@@ -0,0 +1,64 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_APP_HPP_INCLUDED
#define DGL_APP_HPP_INCLUDED

#include "Base.hpp"

START_NAMESPACE_DGL

class Window;

// -----------------------------------------------------------------------

class App
{
public:
class IdleCallback
{
public:
virtual ~IdleCallback() {}
virtual void idleCallback() = 0;
};

App();
~App();

void idle();
void exec();
void quit();
bool isQuiting() const;

void addIdleCallback(IdleCallback* const callback);
void removeIdleCallback(IdleCallback* const callback);

private:
struct PrivateData;
PrivateData* const pData;
friend class Window;

void _addWindow(Window* const window);
void _removeWindow(Window* const window);
void _oneShown();
void _oneHidden();
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_APP_HPP_INCLUDED

+ 143
- 0
libs/dgl/Base.hpp View File

@@ -0,0 +1,143 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_BASE_HPP_INCLUDED
#define DGL_BASE_HPP_INCLUDED

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define DGL_OS_WINDOWS 1
#elif defined(__APPLE__)
# define DGL_OS_MAC 1
#elif defined(__HAIKU__)
# define DGL_OS_HAIKU 1
#elif defined(__linux__)
# define DGL_OS_LINUX 1
#endif

#if defined(HAVE_CPP11_SUPPORT)
# define PROPER_CPP11_SUPPORT
#elif defined(__GNUC__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
# define PROPER_CPP11_SUPPORT
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
# define override // gcc4.7+ only
# endif
# endif
#endif

#ifndef PROPER_CPP11_SUPPORT
# ifndef __clang__
# define noexcept throw()
# endif
# define override
# define nullptr (0)
#endif

#ifndef DGL_NAMESPACE
# define DGL_NAMESPACE DGL
#endif

#define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
#define END_NAMESPACE_DGL }
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;

#ifdef DGL_OS_MAC
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif

#if defined(GL_BGR_EXT) && ! defined(GL_BGR)
# define GL_BGR GL_BGR_EXT
#endif

#if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
# define GL_BGRA GL_BGRA_EXT
#endif

#ifndef GL_CLAMP_TO_BORDER
# define GL_CLAMP_TO_BORDER 0x812D
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

/*
* Convenience symbols for ASCII control characters.
*/
enum Char {
CHAR_BACKSPACE = 0x08,
CHAR_ESCAPE = 0x1B,
CHAR_DELETE = 0x7F
};

/*
* Special (non-Unicode) keyboard keys.
*/
enum Key {
KEY_F1 = 1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_LEFT,
KEY_UP,
KEY_RIGHT,
KEY_DOWN,
KEY_PAGE_UP,
KEY_PAGE_DOWN,
KEY_HOME,
KEY_END,
KEY_INSERT,
KEY_SHIFT,
KEY_CTRL,
KEY_ALT,
KEY_SUPER
};

/*
* Keyboard modifier flags.
*/
enum Modifier {
MODIFIER_SHIFT = 1 << 0, /**< Shift key */
MODIFIER_CTRL = 1 << 1, /**< Control key */
MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
};

/*
* Cross-platform sleep function.
*/
void sleep(unsigned int secs);

/*
* Cross-platform msleep function.
*/
void msleep(unsigned int msecs);

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_BASE_HPP_INCLUDED

+ 206
- 0
libs/dgl/CairoWidget.hpp View File

@@ -0,0 +1,206 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_CAIRO_WIDGET_HPP_INCLUDED
#define DGL_CAIRO_WIDGET_HPP_INCLUDED

#include "Widget.hpp"

#include <cairo.h>

#include <cstdio>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class CairoWidget : public Widget
{
public:
CairoWidget(Window& parent)
: Widget(parent),
fContext(nullptr),
fSurface(nullptr),
fTextureId(0)
{
}

virtual void setWidth(int width) override
{
if (fArea.getWidth() == width)
return;

Widget::setWidth(width);
_recreateSurface();
}

virtual void setHeight(int height) override
{
if (fArea.getHeight() == height)
return;

Widget::setHeight(height);
_recreateSurface();
}

virtual void setSize(const Size<int>& size) override
{
if (fArea.getSize() == size)
return;

Widget::setSize(size);
_recreateSurface();
}

void setSize(int width, int height)
{
setSize(Size<int>(width, height));
}

protected:
virtual void cairoDisplay(cairo_t* const context) = 0;

private:
void onDisplay() override
{
// wait for sizing
if (fSurface == nullptr || fContext == nullptr)
{
printf("invalid surface\n");
return;
}

if (fTextureId == 0)
glGenTextures(1, &fTextureId);
if (fTextureId == 0)
{
// TODO: invalidate widget
printf("invalid texture\n");
return;
}

#if 1
const int x = getX();
const int y = getY();
const int width = getWidth();
const int height = getHeight();

// draw cairo stuff
cairoDisplay(fContext);

// get cairo surface data (RGB24)
unsigned char* const surfaceData = cairo_image_surface_get_data(fSurface);

// enable GL texture
glEnable(GL_TEXTURE_RECTANGLE_ARB);

// set texture params
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

// bind texture to surface data
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, fTextureId);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, surfaceData);

// draw the texture

// glBegin(GL_QUADS);
// glTexCoord2f(0.0f, 0.0f);
// glVertex2i(x, y);
//
// glTexCoord2f(1.0f, 0.0f);
// glVertex2i(x+width, y);
//
// glTexCoord2f(1.0f, 1.0f);
// glVertex2i(x+width, y+height);
//
// glTexCoord2f(0.0f, 1.0f);
// glVertex2i(x, y+height);
// glEnd();

glBegin(GL_QUADS);
//glTexCoord2i(x, y);
glTexCoord2i(0, 0);
glVertex2i(x, y);

//glTexCoord2i(x+width, y);
glTexCoord2i(width, 0);
glVertex2i(x+width, y);

//glTexCoord2i(x+width, y+height);
glTexCoord2i(width, height);
glVertex2i(x+width, y+height);

//glTexCoord2i(x, y+height);
glTexCoord2i(0, height);
glVertex2i(x, y+height);
glEnd();

// cleanup
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable(GL_TEXTURE_RECTANGLE_ARB);
#endif
}

void onClose() override
{
if (fContext != nullptr)
{
cairo_destroy(fContext);
fContext = nullptr;
}

if (fSurface != nullptr)
{
cairo_surface_destroy(fSurface);
fSurface = nullptr;
}

if (fTextureId != 0)
{
glDeleteTextures(1, &fTextureId);
fTextureId = 0;
}
}

void _recreateSurface()
{
if (fContext != nullptr)
cairo_destroy(fContext);

if (fSurface != nullptr)
cairo_surface_destroy(fSurface);

fSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, fArea.getWidth(), fArea.getHeight());

if (fSurface != nullptr)
fContext = cairo_create(fSurface);
else
fContext = nullptr;
}

private:
cairo_t* fContext;
cairo_surface_t* fSurface;
GLuint fTextureId;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_CAIRO_WIDGET_HPP_INCLUDED

+ 133
- 0
libs/dgl/Geometry.hpp View File

@@ -0,0 +1,133 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_GEOMETRY_HPP_INCLUDED
#define DGL_GEOMETRY_HPP_INCLUDED

#include "Base.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

template<typename T>
class Point
{
public:
Point() noexcept;
Point(T x, T y) noexcept;
Point(const Point<T>& pos) noexcept;

T getX() const noexcept;
T getY() const noexcept;

void setX(T x) noexcept;
void setY(T y) noexcept;

void move(T x, T y) noexcept;
void move(const Point<T>& pos) noexcept;

Point<T>& operator=(const Point<T>& pos) noexcept;
Point<T>& operator+=(const Point<T>& pos) noexcept;
Point<T>& operator-=(const Point<T>& pos) noexcept;
bool operator==(const Point<T>& pos) const noexcept;
bool operator!=(const Point<T>& pos) const noexcept;

private:
T fX, fY;
template<typename> friend class Rectangle;
};

// -----------------------------------------------------------------------

template<typename T>
class Size
{
public:
Size() noexcept;
Size(T width, T height) noexcept;
Size(const Size<T>& size) noexcept;

T getWidth() const noexcept;
T getHeight() const noexcept;

void setWidth(T width) noexcept;
void setHeight(T height) noexcept;

Size<T>& operator=(const Size<T>& size) noexcept;
Size<T>& operator+=(const Size<T>& size) noexcept;
Size<T>& operator-=(const Size<T>& size) noexcept;
Size<T>& operator*=(T m) noexcept;
Size<T>& operator/=(T d) noexcept;
bool operator==(const Size<T>& size) const noexcept;
bool operator!=(const Size<T>& size) const noexcept;

private:
T fWidth, fHeight;
template<typename> friend class Rectangle;
};

// -----------------------------------------------------------------------

template<typename T>
class Rectangle
{
public:
Rectangle() noexcept;
Rectangle(T x, T y, T width, T height) noexcept;
Rectangle(T x, T y, const Size<T>& size) noexcept;
Rectangle(const Point<T>& pos, T width, T height) noexcept;
Rectangle(const Point<T>& pos, const Size<T>& size) noexcept;
Rectangle(const Rectangle<T>& rect) noexcept;

T getX() const noexcept;
T getY() const noexcept;
T getWidth() const noexcept;
T getHeight() const noexcept;

const Point<T>& getPos() const noexcept;
const Size<T>& getSize() const noexcept;

bool contains(T x, T y) const noexcept;
bool contains(const Point<T>& pos) const noexcept;
bool containsX(T x) const noexcept;
bool containsY(T y) const noexcept;

void setX(T x) noexcept;
void setY(T y) noexcept;
void setPos(T x, T y) noexcept;
void setPos(const Point<T>& pos) noexcept;

void move(T x, T y) noexcept;
void move(const Point<T>& pos) noexcept;

void setWidth(T width) noexcept;
void setHeight(T height) noexcept;
void setSize(T width, T height) noexcept;
void setSize(const Size<T>& size) noexcept;

Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept;

private:
Point<T> fPos;
Size<T> fSize;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_GEOMETRY_HPP_INCLUDED

+ 68
- 0
libs/dgl/Image.hpp View File

@@ -0,0 +1,68 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_IMAGE_HPP_INCLUDED
#define DGL_IMAGE_HPP_INCLUDED

#include "Geometry.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class Image
{
public:
Image() noexcept;
Image(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
Image(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
Image(const Image& image) noexcept;
~Image();

void loadFromMemory(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;
void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept;

bool isValid() const noexcept;

int getWidth() const noexcept;
int getHeight() const noexcept;
const Size<int>& getSize() const noexcept;

const char* getRawData() const noexcept;
GLenum getFormat() const noexcept;
GLenum getType() const noexcept;

void draw();
void draw(int x, int y);
void draw(const Point<int>& pos);

Image& operator=(const Image& image) noexcept;
bool operator==(const Image& image) const noexcept;
bool operator!=(const Image& image) const noexcept;

private:
const char* fRawData;
Size<int> fSize;
GLenum fFormat;
GLenum fType;
GLuint fTextureId;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_HPP_INCLUDED

+ 56
- 0
libs/dgl/ImageAboutWindow.hpp View File

@@ -0,0 +1,56 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED
#define DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED

#include "Image.hpp"
#include "Widget.hpp"
#include "Window.hpp"

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class ImageAboutWindow : public Window,
public Widget
{
public:
ImageAboutWindow(App& app, Window& parent, const Image& image = Image());
ImageAboutWindow(Widget* widget, const Image& image = Image());

void setImage(const Image& image);

protected:
void onDisplay() override;
bool onMouse(int button, bool press, int x, int y) override;
bool onKeyboard(bool press, uint32_t key) override;

private:
Image fImgBackground;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED

+ 64
- 0
libs/dgl/ImageButton.hpp View File

@@ -0,0 +1,64 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_IMAGE_BUTTON_HPP_INCLUDED
#define DGL_IMAGE_BUTTON_HPP_INCLUDED

#include "Image.hpp"
#include "Widget.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class ImageButton : public Widget
{
public:
class Callback
{
public:
virtual ~Callback() {}
virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0;
};

ImageButton(Window& parent, const Image& image);
ImageButton(Widget* widget, const Image& image);
ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
ImageButton(const ImageButton& imageButton);

void setCallback(Callback* callback);

protected:
void onDisplay() override;
bool onMouse(int button, bool press, int x, int y) override;
bool onMotion(int x, int y) override;

private:
Image fImageNormal;
Image fImageHover;
Image fImageDown;
Image* fCurImage;
int fCurButton;

Callback* fCallback;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_BUTTON_HPP_INCLUDED

+ 92
- 0
libs/dgl/ImageKnob.hpp View File

@@ -0,0 +1,92 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_IMAGE_KNOB_HPP_INCLUDED
#define DGL_IMAGE_KNOB_HPP_INCLUDED

#include "Image.hpp"
#include "Widget.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class ImageKnob : public Widget
{
public:
enum Orientation {
Horizontal,
Vertical
};

class Callback
{
public:
virtual ~Callback() {}
virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0;
virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0;
virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0;
};

ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical);
ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical);
ImageKnob(const ImageKnob& imageKnob);

float getValue() const;

void setOrientation(Orientation orientation);
void setRange(float min, float max);
void setStep(float step);
void setValue(float value, bool sendCallback = false);
void setRotationAngle(int angle);

void setCallback(Callback* callback);

protected:
void onDisplay() override;
bool onMouse(int button, bool press, int x, int y) override;
bool onMotion(int x, int y) override;
void onReshape(int width, int height) override;
void onClose() override;

private:
Image fImage;
float fMinimum;
float fMaximum;
float fStep;
float fValue;
float fValueTmp;
Orientation fOrientation;

int fRotationAngle;
bool fDragging;
int fLastX;
int fLastY;

Callback* fCallback;

bool fIsImgVertical;
int fImgLayerSize;
int fImgLayerCount;
Rectangle<int> fKnobArea;
GLuint fTextureId;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_KNOB_HPP_INCLUDED

+ 86
- 0
libs/dgl/ImageSlider.hpp View File

@@ -0,0 +1,86 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_IMAGE_SLIDER_HPP_INCLUDED
#define DGL_IMAGE_SLIDER_HPP_INCLUDED

#include "Image.hpp"
#include "Widget.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class ImageSlider : public Widget
{
public:
class Callback
{
public:
virtual ~Callback() {}
virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0;
virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0;
virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0;
};

ImageSlider(Window& parent, const Image& image);
ImageSlider(Widget* widget, const Image& image);
ImageSlider(const ImageSlider& imageSlider);

float getValue() const;

void setStartPos(const Point<int>& startPos);
void setStartPos(int x, int y);
void setEndPos(const Point<int>& endPos);
void setEndPos(int x, int y);

void setRange(float min, float max);
void setStep(float step);
void setValue(float value, bool sendCallback = false);

void setCallback(Callback* callback);

protected:
void onDisplay() override;
bool onMouse(int button, bool press, int x, int y) override;
bool onMotion(int x, int y) override;

private:
Image fImage;
float fMinimum;
float fMaximum;
float fStep;
float fValue;
float fValueTmp;

bool fDragging;
int fStartedX;
int fStartedY;

Callback* fCallback;

Point<int> fStartPos;
Point<int> fEndPos;
Rectangle<int> fSliderArea;

void _recheckArea();
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_SLIDER_HPP_INCLUDED

+ 21
- 0
libs/dgl/Makefile View File

@@ -0,0 +1,21 @@
# Compile the dgl library

all: build


build: dgl


dgl:
$(MAKE) -C build


clean:
$(MAKE) clean -C build
rm -rf build-*/intermediate

distclean: clean
rm -f build-*/Makefile
rm -f build-*/*.make
rm -f build-*/*.sln
rm -f build-*/*.vcproj

+ 79
- 0
libs/dgl/StandaloneWindow.hpp View File

@@ -0,0 +1,79 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED
#define DGL_STANDALONE_WINDOW_HPP_INCLUDED

#include "App.hpp"
#include "Window.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class StandaloneWindow
{
public:
StandaloneWindow()
: fApp(),
fWindow(fApp)
{
}

App& getApp() noexcept
{
return fApp;
}

Window& getWindow() noexcept
{
return fWindow;
}

void exec()
{
fWindow.show();
fApp.exec();
}

// -------------------------------------------------------------------
// helpers

void setResizable(bool yesNo)
{
fWindow.setResizable(yesNo);
}

void setSize(unsigned int width, unsigned int height)
{
fWindow.setSize(width, height);
}

void setTitle(const char* title)
{
fWindow.setTitle(title);
}

private:
App fApp;
Window fWindow;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED

+ 106
- 0
libs/dgl/Widget.hpp View File

@@ -0,0 +1,106 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_WIDGET_HPP_INCLUDED
#define DGL_WIDGET_HPP_INCLUDED

#include "Geometry.hpp"

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class App;
class Window;

class Widget
{
public:
Widget(Window& parent);
virtual ~Widget();

bool isVisible() const noexcept;
void setVisible(bool yesNo);

void show();
void hide();

int getX() const noexcept;
int getY() const noexcept;
const Point<int>& getPos() const noexcept;

void setX(int x);
void setY(int y);
void setPos(int x, int y);
void setPos(const Point<int>& pos);

void move(int x, int y);
void move(const Point<int>& pos);

int getWidth() const noexcept;
int getHeight() const noexcept;
const Size<int>& getSize() const noexcept;

// virtual needed by cairo
virtual void setWidth(int width);
virtual void setHeight(int height);
virtual void setSize(const Size<int>& size);

void setSize(int width, int height)
{
setSize(Size<int>(width, height));
}

const Rectangle<int>& getArea() const noexcept;

uint32_t getEventTimestamp();
int getModifiers();

App& getParentApp() const noexcept;
Window& getParentWindow() const noexcept;

void repaint();

protected:
virtual void onDisplay() = 0;
virtual bool onKeyboard(bool press, uint32_t key);
virtual bool onMouse(int button, bool press, int x, int y);
virtual bool onMotion(int x, int y);
virtual bool onScroll(int x, int y, float dx, float dy);
virtual bool onSpecial(bool press, Key key);
virtual void onReshape(int width, int height);
virtual void onClose();

private:
Window& fParent;
bool fVisible;
Rectangle<int> fArea;

friend class CairoWidget;
friend class Window;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_WIDGET_HPP_INCLUDED

+ 84
- 0
libs/dgl/Window.hpp View File

@@ -0,0 +1,84 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DGL_WINDOW_HPP_INCLUDED
#define DGL_WINDOW_HPP_INCLUDED

#include "Geometry.hpp"

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class App;
class Widget;

class Window
{
public:
Window(App& app);
Window(App& app, Window& parent);
Window(App& app, intptr_t parentId);
virtual ~Window();

void show();
void hide();
void close();
void exec(bool lockWait = false);

void focus();
void repaint();

bool isVisible() const noexcept;
void setVisible(bool yesNo);

bool isResizable() const noexcept;
void setResizable(bool yesNo);

int getWidth() const noexcept;
int getHeight() const noexcept;
Size<int> getSize() const noexcept;
void setSize(unsigned int width, unsigned int height);

void setTitle(const char* title);

App& getApp() const noexcept;
uint32_t getEventTimestamp() const;
int getModifiers() const;
intptr_t getWindowId() const;

private:
class PrivateData;
PrivateData* const pData;
friend class App;
friend class Widget;

void _addWidget(Widget* const widget);
void _removeWidget(Widget* const widget);
void _idle();
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_WINDOW_HPP_INCLUDED

+ 22
- 0
libs/dgl/build/premake.lua View File

@@ -0,0 +1,22 @@
dofile("../../../scripts/make-project.lua")
package = make_library_project("dgl")
package.includepaths = {
".."
}
package.files = {
matchfiles (
"../src/*.cpp"
)
}
if (macosx) then
package.files = {
package.files,
"../src/pugl/pugl_osx.m.c",
"../src/pugl/pugl_osx_extended.m.c"
}
end

+ 133
- 0
libs/dgl/src/App.cpp View File

@@ -0,0 +1,133 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../App.hpp"
#include "../Window.hpp"

#include <list>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

struct App::PrivateData {
bool doLoop;
unsigned visibleWindows;
std::list<Window*> windows;
std::list<IdleCallback*> idleCallbacks;

PrivateData()
: doLoop(false),
visibleWindows(0) {}
};

// -----------------------------------------------------------------------

App::App()
: pData(new PrivateData())
{
}

App::~App()
{
pData->windows.clear();
pData->idleCallbacks.clear();
delete pData;
}

void App::idle()
{
for (std::list<Window*>::iterator it = pData->windows.begin(); it != pData->windows.end(); ++it)
{
Window* const window(*it);
window->_idle();
}

for (std::list<IdleCallback*>::iterator it = pData->idleCallbacks.begin(); it != pData->idleCallbacks.end(); ++it)
{
IdleCallback* const idleCallback(*it);
idleCallback->idleCallback();
}
}

void App::exec()
{
while (pData->doLoop)
{
idle();
msleep(10);
}
}

void App::quit()
{
pData->doLoop = false;

for (std::list<Window*>::reverse_iterator rit = pData->windows.rbegin(); rit != pData->windows.rend(); ++rit)
{
Window* const window(*rit);
window->close();
}
}

bool App::isQuiting() const
{
return !pData->doLoop;
}

// -----------------------------------------------------------------------

void App::addIdleCallback(IdleCallback* const callback)
{
if (callback != nullptr)
pData->idleCallbacks.push_back(callback);
}

void App::removeIdleCallback(IdleCallback* const callback)
{
if (callback != nullptr)
pData->idleCallbacks.remove(callback);
}

// -----------------------------------------------------------------------

void App::_addWindow(Window* const window)
{
if (window != nullptr)
pData->windows.push_back(window);
}

void App::_removeWindow(Window* const window)
{
if (window != nullptr)
pData->windows.remove(window);
}

void App::_oneShown()
{
if (++pData->visibleWindows == 1)
pData->doLoop = true;
}

void App::_oneHidden()
{
if (--pData->visibleWindows == 0)
pData->doLoop = false;
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 49
- 0
libs/dgl/src/Base.cpp View File

@@ -0,0 +1,49 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../Base.hpp"

#ifdef DGL_OS_WINDOWS
# include <windows.h>
#else
# include <unistd.h>
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

void sleep(unsigned int secs)
{
#ifdef DGL_OS_WINDOWS
::Sleep(secs * 1000);
#else
::sleep(secs);
#endif
}

void msleep(unsigned int msecs)
{
#ifdef DGL_OS_WINDOWS
::Sleep(msecs);
#else
::usleep(msecs * 1000);
#endif
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 416
- 0
libs/dgl/src/Geometry.cpp View File

@@ -0,0 +1,416 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../Geometry.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Point

template<typename T>
Point<T>::Point() noexcept
: fX(0),
fY(0)
{
}

template<typename T>
Point<T>::Point(T x, T y) noexcept
: fX(x),
fY(y)
{
}

template<typename T>
Point<T>::Point(const Point& pos) noexcept
: fX(pos.fX),
fY(pos.fY)
{
}

template<typename T>
T Point<T>::getX() const noexcept
{
return fX;
}

template<typename T>
T Point<T>::getY() const noexcept
{
return fY;
}

template<typename T>
void Point<T>::setX(T x) noexcept
{
fX = x;
}

template<typename T>
void Point<T>::setY(T y) noexcept
{
fY = y;
}

template<typename T>
void Point<T>::move(T x, T y) noexcept
{
fX += x;
fY += y;
}

template<typename T>
void Point<T>::move(const Point& pos) noexcept
{
fX += pos.fX;
fY += pos.fY;
}

template<typename T>
Point<T>& Point<T>::operator=(const Point<T>& pos) noexcept
{
fX = pos.fX;
fY = pos.fY;
return *this;
}

template<typename T>
Point<T>& Point<T>::operator+=(const Point<T>& pos) noexcept
{
fX += pos.fX;
fY += pos.fY;
return *this;
}

template<typename T>
Point<T>& Point<T>::operator-=(const Point<T>& pos) noexcept
{
fX -= pos.fX;
fY -= pos.fY;
return *this;
}

template<typename T>
bool Point<T>::operator==(const Point<T>& pos) const noexcept
{
return (fX == pos.fX && fY== pos.fY);
}

template<typename T>
bool Point<T>::operator!=(const Point<T>& pos) const noexcept
{
return !operator==(pos);
}

// -----------------------------------------------------------------------
// Size

template<typename T>
Size<T>::Size() noexcept
: fWidth(0),
fHeight(0)
{
}

template<typename T>
Size<T>::Size(T width, T height) noexcept
: fWidth(width),
fHeight(height)
{
}

template<typename T>
Size<T>::Size(const Size<T>& size) noexcept
: fWidth(size.fWidth),
fHeight(size.fHeight)
{
}

template<typename T>
T Size<T>::getWidth() const noexcept
{
return fWidth;
}

template<typename T>
T Size<T>::getHeight() const noexcept
{
return fHeight;
}

template<typename T>
void Size<T>::setWidth(T width) noexcept
{
fWidth = width;
}

template<typename T>
void Size<T>::setHeight(T height) noexcept
{
fHeight = height;
}

template<typename T>
Size<T>& Size<T>::operator=(const Size<T>& size) noexcept
{
fWidth = size.fWidth;
fHeight = size.fHeight;
return *this;
}

template<typename T>
Size<T>& Size<T>::operator+=(const Size<T>& size) noexcept
{
fWidth += size.fWidth;
fHeight += size.fHeight;
return *this;
}

template<typename T>
Size<T>& Size<T>::operator-=(const Size<T>& size) noexcept
{
fWidth -= size.fWidth;
fHeight -= size.fHeight;
return *this;
}

template<typename T>
Size<T>& Size<T>::operator*=(T m) noexcept
{
fWidth *= m;
fHeight *= m;
return *this;
}

template<typename T>
Size<T>& Size<T>::operator/=(T d) noexcept
{
fWidth /= d;
fHeight /= d;
return *this;
}

template<typename T>
bool Size<T>::operator==(const Size<T>& size) const noexcept
{
return (fWidth == size.fWidth && fHeight == size.fHeight);
}

template<typename T>
bool Size<T>::operator!=(const Size<T>& size) const noexcept
{
return !operator==(size);
}

// -----------------------------------------------------------------------
// Rectangle

template<typename T>
Rectangle<T>::Rectangle() noexcept
: fPos(0, 0),
fSize(0, 0)
{
}

template<typename T>
Rectangle<T>::Rectangle(T x, T y, T width, T height) noexcept
: fPos(x, y),
fSize(width, height)
{
}

template<typename T>
Rectangle<T>::Rectangle(T x, T y, const Size<T>& size) noexcept
: fPos(x, y),
fSize(size)
{
}

template<typename T>
Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height) noexcept
: fPos(pos),
fSize(width, height)
{
}

template<typename T>
Rectangle<T>::Rectangle(const Point<T>& pos, const Size<T>& size) noexcept
: fPos(pos),
fSize(size)
{
}

template<typename T>
Rectangle<T>::Rectangle(const Rectangle<T>& rect) noexcept
: fPos(rect.fPos),
fSize(rect.fSize)
{
}

template<typename T>
T Rectangle<T>::getX() const noexcept
{
return fPos.fX;
}

template<typename T>
T Rectangle<T>::getY() const noexcept
{
return fPos.fY;
}

template<typename T>
T Rectangle<T>::getWidth() const noexcept
{
return fSize.fWidth;
}

template<typename T>
T Rectangle<T>::getHeight() const noexcept
{
return fSize.fHeight;
}

template<typename T>
const Point<T>& Rectangle<T>::getPos() const noexcept
{
return fPos;
}

template<typename T>
const Size<T>& Rectangle<T>::getSize() const noexcept
{
return fSize;
}

template<typename T>
bool Rectangle<T>::contains(T x, T y) const noexcept
{
return (x >= fPos.fX && y >= fPos.fY && x <= fPos.fX+fSize.fWidth && y <= fPos.fY+fSize.fHeight);
}

template<typename T>
bool Rectangle<T>::contains(const Point<T>& pos) const noexcept
{
return contains(pos.fX, pos.fY);
}

template<typename T>
bool Rectangle<T>::containsX(T x) const noexcept
{
return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth);
}

template<typename T>
bool Rectangle<T>::containsY(T y) const noexcept
{
return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight);
}

template<typename T>
void Rectangle<T>::setX(T x) noexcept
{
fPos.fX = x;
}

template<typename T>
void Rectangle<T>::setY(T y) noexcept
{
fPos.fY = y;
}

template<typename T>
void Rectangle<T>::setPos(T x, T y) noexcept
{
fPos.fX = x;
fPos.fY = y;
}

template<typename T>
void Rectangle<T>::setPos(const Point<T>& pos) noexcept
{
fPos = pos;
}

template<typename T>
void Rectangle<T>::move(T x, T y) noexcept
{
fPos.fX += x;
fPos.fY += y;
}

template<typename T>
void Rectangle<T>::move(const Point<T>& pos) noexcept
{
fPos += pos;
}

template<typename T>
void Rectangle<T>::setWidth(T width) noexcept
{
fSize.fWidth = width;
}

template<typename T>
void Rectangle<T>::setHeight(T height) noexcept
{
fSize.fHeight = height;
}

template<typename T>
void Rectangle<T>::setSize(T width, T height) noexcept
{
fSize.fWidth = width;
fSize.fHeight = height;
}

template<typename T>
void Rectangle<T>::setSize(const Size<T>& size) noexcept
{
fSize = size;
}

template<typename T>
Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept
{
fPos = rect.fPos;
fSize = rect.fSize;
return *this;
}

// -----------------------------------------------------------------------
// Possible template data types

template class Point<int>;
template class Point<long>;
template class Point<float>;
template class Point<double>;

template class Size<int>;
template class Size<long>;
template class Size<float>;
template class Size<double>;

template class Rectangle<int>;
template class Rectangle<long>;
template class Rectangle<float>;
template class Rectangle<double>;

// -----------------------------------------------------------------------

END_NAMESPACE_DGL


+ 198
- 0
libs/dgl/src/Image.cpp View File

@@ -0,0 +1,198 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../Image.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

Image::Image() noexcept
: fRawData(nullptr),
fSize(0, 0),
fFormat(0),
fType(0),
fTextureId(0)
{
}

Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept
: fRawData(rawData),
fSize(width, height),
fFormat(format),
fType(type),
fTextureId(0)
{
}

Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept
: fRawData(rawData),
fSize(size),
fFormat(format),
fType(type),
fTextureId(0)
{
}

Image::Image(const Image& image) noexcept
: fRawData(image.fRawData),
fSize(image.fSize),
fFormat(image.fFormat),
fType(image.fType),
fTextureId(0)
{
}

Image::~Image()
{
if (fTextureId != 0)
{
glDeleteTextures(1, &fTextureId);
fTextureId = 0;
}
}

void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept
{
loadFromMemory(rawData, Size<int>(width, height), format, type);
}

void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept
{
fRawData = rawData;
fSize = size;
fFormat = format;
fType = type;
}

bool Image::isValid() const noexcept
{
return (fRawData != nullptr && getWidth() > 0 && getHeight() > 0);
}

int Image::getWidth() const noexcept
{
return fSize.getWidth();
}

int Image::getHeight() const noexcept
{
return fSize.getHeight();
}

const Size<int>& Image::getSize() const noexcept
{
return fSize;
}

const char* Image::getRawData() const noexcept
{
return fRawData;
}

GLenum Image::getFormat() const noexcept
{
return fFormat;
}

GLenum Image::getType() const noexcept
{
return fType;
}

void Image::draw()
{
draw(0, 0);
}

void Image::draw(int x, int y)
{
if (! isValid())
return;
if (fTextureId == 0)
glGenTextures(1, &fTextureId);
if (fTextureId == 0)
{
// invalidate image
fSize = Size<int>(0, 0);
return;
}

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fTextureId);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWidth(), getHeight(), 0, fFormat, fType, fRawData);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

float trans[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, trans);

const int width = getWidth();
const int height = getHeight();

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(x, y);

glTexCoord2f(1.0f, 0.0f);
glVertex2i(x+width, y);

glTexCoord2f(1.0f, 1.0f);
glVertex2i(x+width, y+height);

glTexCoord2f(0.0f, 1.0f);
glVertex2i(x, y+height);
glEnd();

glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}

void Image::draw(const Point<int>& pos)
{
draw(pos.getX(), pos.getY());
}

// -----------------------------------------------------------------------

Image& Image::operator=(const Image& image) noexcept
{
fRawData = image.fRawData;
fSize = image.fSize;
fFormat = image.fFormat;
fType = image.fType;
return *this;
}

bool Image::operator==(const Image& image) const noexcept
{
return (fRawData == image.fRawData);
}

bool Image::operator!=(const Image& image) const noexcept
{
return (fRawData != image.fRawData);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 78
- 0
libs/dgl/src/ImageAboutWindow.cpp View File

@@ -0,0 +1,78 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageAboutWindow.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

ImageAboutWindow::ImageAboutWindow(App& app, Window& parent, const Image& image)
: Window(app, parent),
Widget((Window&)*this),
fImgBackground(image)
{
Window::setResizable(false);
Window::setSize(static_cast<unsigned int>(image.getWidth()), static_cast<unsigned int>(image.getHeight()));
Window::setTitle("About");
}

ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image)
: Window(widget->getParentApp(), widget->getParentWindow()),
Widget((Window&)*this),
fImgBackground(image)
{
Window::setResizable(false);
Window::setSize(static_cast<unsigned int>(image.getWidth()), static_cast<unsigned int>(image.getHeight()));
Window::setTitle("About");
}

void ImageAboutWindow::setImage(const Image& image)
{
fImgBackground = image;
Window::setSize(static_cast<unsigned int>(image.getWidth()), static_cast<unsigned int>(image.getHeight()));
}

void ImageAboutWindow::onDisplay()
{
fImgBackground.draw();
}

bool ImageAboutWindow::onMouse(int, bool press, int, int)
{
if (press)
{
Window::close();
return true;
}

return false;
}

bool ImageAboutWindow::onKeyboard(bool press, uint32_t key)
{
if (press && key == CHAR_ESCAPE)
{
Window::close();
return true;
}

return false;
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 173
- 0
libs/dgl/src/ImageButton.cpp View File

@@ -0,0 +1,173 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageButton.hpp"

#include <cassert>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

ImageButton::ImageButton(Window& parent, const Image& image)
: Widget(parent),
fImageNormal(image),
fImageHover(image),
fImageDown(image),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
}

ImageButton::ImageButton(Widget* widget, const Image& image)
: Widget(widget->getParentWindow()),
fImageNormal(image),
fImageHover(image),
fImageDown(image),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
}

ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown)
: Widget(parent),
fImageNormal(imageNormal),
fImageHover(imageHover),
fImageDown(imageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}

ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown)
: Widget(widget->getParentWindow()),
fImageNormal(imageNormal),
fImageHover(imageHover),
fImageDown(imageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(nullptr)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}

ImageButton::ImageButton(const ImageButton& imageButton)
: Widget(imageButton.getParentWindow()),
fImageNormal(imageButton.fImageNormal),
fImageHover(imageButton.fImageHover),
fImageDown(imageButton.fImageDown),
fCurImage(&fImageNormal),
fCurButton(-1),
fCallback(imageButton.fCallback)
{
assert(fImageNormal.getSize() == fImageHover.getSize() && fImageHover.getSize() == fImageDown.getSize());

setSize(fCurImage->getSize());
}

void ImageButton::setCallback(Callback* callback)
{
fCallback = callback;
}

void ImageButton::onDisplay()
{
fCurImage->draw(getPos());
}

bool ImageButton::onMouse(int button, bool press, int x, int y)
{
if (fCurButton != -1 && ! press)
{
if (fCurImage != &fImageNormal)
{
fCurImage = &fImageNormal;
repaint();
}

if (! getArea().contains(x, y))
{
fCurButton = -1;
return false;
}

if (fCallback != nullptr)
fCallback->imageButtonClicked(this, fCurButton);

//if (getArea().contains(x, y))
//{
// fCurImage = &fImageHover;
// repaint();
//}

fCurButton = -1;

return true;
}

if (press && getArea().contains(x, y))
{
if (fCurImage != &fImageDown)
{
fCurImage = &fImageDown;
repaint();
}

fCurButton = button;
return true;
}

return false;
}

bool ImageButton::onMotion(int x, int y)
{
if (fCurButton != -1)
return true;

if (getArea().contains(x, y))
{
if (fCurImage != &fImageHover)
{
fCurImage = &fImageHover;
repaint();
}

return true;
}
else
{
if (fCurImage != &fImageNormal)
{
fCurImage = &fImageNormal;
repaint();
}

return false;
}
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 364
- 0
libs/dgl/src/ImageKnob.cpp View File

@@ -0,0 +1,364 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageKnob.hpp"

#include <cmath>
#include <cstdio>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation)
: Widget(parent),
fImage(image),
fMinimum(0.0f),
fMaximum(1.0f),
fStep(0.0f),
fValue(0.5f),
fValueTmp(fValue),
fOrientation(orientation),
fRotationAngle(0),
fDragging(false),
fLastX(0),
fLastY(0),
fCallback(nullptr),
fIsImgVertical(image.getHeight() > image.getWidth()),
fImgLayerSize(fIsImgVertical ? image.getWidth() : image.getHeight()),
fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize),
fKnobArea(0, 0, fImgLayerSize, fImgLayerSize),
fTextureId(0)
{
setSize(fImgLayerSize, fImgLayerSize);
}

ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation)
: Widget(widget->getParentWindow()),
fImage(image),
fMinimum(0.0f),
fMaximum(1.0f),
fStep(0.0f),
fValue(0.5f),
fValueTmp(fValue),
fOrientation(orientation),
fRotationAngle(0),
fDragging(false),
fLastX(0),
fLastY(0),
fCallback(nullptr),
fIsImgVertical(image.getHeight() > image.getWidth()),
fImgLayerSize(fIsImgVertical ? image.getWidth() : image.getHeight()),
fImgLayerCount(fIsImgVertical ? image.getHeight()/fImgLayerSize : image.getWidth()/fImgLayerSize),
fKnobArea(0, 0, fImgLayerSize, fImgLayerSize),
fTextureId(0)
{
setSize(fImgLayerSize, fImgLayerSize);
}

ImageKnob::ImageKnob(const ImageKnob& imageKnob)
: Widget(imageKnob.getParentWindow()),
fImage(imageKnob.fImage),
fMinimum(imageKnob.fMinimum),
fMaximum(imageKnob.fMaximum),
fStep(imageKnob.fStep),
fValue(imageKnob.fValue),
fValueTmp(fValue),
fOrientation(imageKnob.fOrientation),
fRotationAngle(imageKnob.fRotationAngle),
fDragging(false),
fLastX(0),
fLastY(0),
fCallback(imageKnob.fCallback),
fIsImgVertical(imageKnob.fIsImgVertical),
fImgLayerSize(imageKnob.fImgLayerSize),
fImgLayerCount(imageKnob.fImgLayerCount),
fKnobArea(imageKnob.fKnobArea),
fTextureId(0)
{
setSize(fImgLayerSize, fImgLayerSize);

if (fRotationAngle != 0)
{
// force new texture creation
fRotationAngle = 0;
setRotationAngle(imageKnob.fRotationAngle);
}
}

float ImageKnob::getValue() const
{
return fValue;
}

void ImageKnob::setOrientation(Orientation orientation)
{
if (fOrientation == orientation)
return;

fOrientation = orientation;
}

void ImageKnob::setRange(float min, float max)
{
if (fValue < min)
{
fValue = min;
repaint();

if (fCallback != nullptr)
fCallback->imageKnobValueChanged(this, fValue);
}
else if (fValue > max)
{
fValue = max;
repaint();

if (fCallback != nullptr)
fCallback->imageKnobValueChanged(this, fValue);
}

fMinimum = min;
fMaximum = max;
}

void ImageKnob::setStep(float step)
{
fStep = step;
}

void ImageKnob::setValue(float value, bool sendCallback)
{
if (fValue == value)
return;

fValue = value;

if (fStep == 0.0f)
fValueTmp = value;

repaint();

if (sendCallback && fCallback != nullptr)
fCallback->imageKnobValueChanged(this, fValue);
}

void ImageKnob::setRotationAngle(int angle)
{
if (fRotationAngle == angle)
return;

if (fRotationAngle != 0)
{
// delete old texture
glDeleteTextures(1, &fTextureId);
fTextureId = 0;
}

fRotationAngle = angle;

if (angle != 0)
{
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &fTextureId);
glBindTexture(GL_TEXTURE_2D, fTextureId);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWidth(), getHeight(), 0, fImage.getFormat(), fImage.getType(), fImage.getRawData());

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

float trans[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, trans);

glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}
}

void ImageKnob::setCallback(Callback* callback)
{
fCallback = callback;
}

void ImageKnob::onDisplay()
{
const float normValue = (fValue - fMinimum) / (fMaximum - fMinimum);

if (fRotationAngle != 0)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fTextureId);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWidth(), getHeight(), 0, fImage.getFormat(), fImage.getType(), fImage.getRawData());

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

float trans[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, trans);

glPushMatrix();

const GLint w2 = getWidth()/2;
const GLint h2 = getHeight()/2;

glTranslatef(static_cast<float>(getX()+w2), static_cast<float>(getY()+h2), 0.0f);
glRotatef(normValue*static_cast<float>(fRotationAngle), 0.0f, 0.0f, 1.0f);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(-w2, -h2);

glTexCoord2f(1.0f, 0.0f);
glVertex2i(getWidth()-w2, -h2);

glTexCoord2f(1.0f, 1.0f);
glVertex2i(getWidth()-w2, getHeight()-h2);

glTexCoord2f(0.0f, 1.0f);
glVertex2i(-w2, getHeight()-h2);
glEnd();

glPopMatrix();

glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}
else
{
const int layerDataSize = fImgLayerSize * fImgLayerSize * ((fImage.getFormat() == GL_BGRA || fImage.getFormat() == GL_RGBA) ? 4 : 3);
const int imageDataSize = layerDataSize * fImgLayerCount;
const int imageDataOffset = imageDataSize - layerDataSize - (layerDataSize * int(normValue * float(fImgLayerCount-1)));

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glRasterPos2i(getX(), getY()+getHeight());
glDrawPixels(fImgLayerSize, fImgLayerSize, fImage.getFormat(), fImage.getType(), fImage.getRawData() + imageDataOffset);
}
}

bool ImageKnob::onMouse(int button, bool press, int x, int y)
{
if (button != 1)
return false;

if (press)
{
if (! getArea().contains(x, y))
return false;

fDragging = true;
fLastX = x;
fLastY = y;

if (fCallback != nullptr)
fCallback->imageKnobDragStarted(this);

return true;
}
else if (fDragging)
{
if (fCallback != nullptr)
fCallback->imageKnobDragFinished(this);

fDragging = false;
return true;
}

return false;
}

bool ImageKnob::onMotion(int x, int y)
{
if (! fDragging)
return false;

bool doVal = false;
float d, value;

if (fOrientation == ImageKnob::Horizontal)
{
if (int movX = x - fLastX)
{
d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
value = fValueTmp + (float(fMaximum - fMinimum) / d * float(movX));
doVal = true;
}
}
else if (fOrientation == ImageKnob::Vertical)
{
if (int movY = fLastY - y)
{
d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
value = fValueTmp + (float(fMaximum - fMinimum) / d * float(movY));
doVal = true;
}
}

if (! doVal)
return false;

if (value < fMinimum)
{
value = fMinimum;
fValueTmp = value;
}
else if (value > fMaximum)
{
value = fMaximum;
fValueTmp = value;
}
else if (fStep != 0.0f)
{
fValueTmp = value;
const float rest = std::fmod(value, fStep);
value = value - rest + (rest > fStep/2.0f ? fStep : 0.0f);
}

setValue(value, true);

fLastX = x;
fLastY = y;

return true;
}

void ImageKnob::onReshape(int width, int height)
{
// if (fRotationAngle != 0)
// glEnable(GL_TEXTURE_2D);

Widget::onReshape(width, height);
}

void ImageKnob::onClose()
{
// delete old texture
setRotationAngle(0);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 325
- 0
libs/dgl/src/ImageSlider.cpp View File

@@ -0,0 +1,325 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageSlider.hpp"

#include <cmath>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

ImageSlider::ImageSlider(Window& parent, const Image& image)
: Widget(parent),
fImage(image),
fMinimum(0.0f),
fMaximum(1.0f),
fStep(0.0f),
fValue(0.5f),
fValueTmp(fValue),
fDragging(false),
fStartedX(0),
fStartedY(0),
fCallback(nullptr)
{
setSize(fImage.getSize());
}

ImageSlider::ImageSlider(Widget* widget, const Image& image)
: Widget(widget->getParentWindow()),
fImage(image),
fMinimum(0.0f),
fMaximum(1.0f),
fStep(0.0f),
fValue(0.5f),
fValueTmp(fValue),
fDragging(false),
fStartedX(0),
fStartedY(0),
fCallback(nullptr)
{
setSize(fImage.getSize());
}

ImageSlider::ImageSlider(const ImageSlider& imageSlider)
: Widget(imageSlider.getParentWindow()),
fImage(imageSlider.fImage),
fMinimum(imageSlider.fMinimum),
fMaximum(imageSlider.fMaximum),
fStep(imageSlider.fStep),
fValue(imageSlider.fValue),
fValueTmp(fValue),
fDragging(false),
fStartedX(0),
fStartedY(0),
fCallback(imageSlider.fCallback),
fStartPos(imageSlider.fStartPos),
fEndPos(imageSlider.fEndPos),
fSliderArea(imageSlider.fSliderArea)
{
setSize(fImage.getSize());
}

float ImageSlider::getValue() const
{
return fValue;
}

void ImageSlider::setStartPos(const Point<int>& startPos)
{
fStartPos = startPos;
_recheckArea();
}

void ImageSlider::setStartPos(int x, int y)
{
setStartPos(Point<int>(x, y));
}

void ImageSlider::setEndPos(const Point<int>& endPos)
{
fEndPos = endPos;
_recheckArea();
}

void ImageSlider::setEndPos(int x, int y)
{
setEndPos(Point<int>(x, y));
}

void ImageSlider::setRange(float min, float max)
{
if (fValue < min)
{
fValue = min;
repaint();

if (fCallback != nullptr)
fCallback->imageSliderValueChanged(this, fValue);
}
else if (fValue > max)
{
fValue = max;
repaint();

if (fCallback != nullptr)
fCallback->imageSliderValueChanged(this, fValue);
}

fMinimum = min;
fMaximum = max;
}

void ImageSlider::setStep(float step)
{
fStep = step;
}

void ImageSlider::setValue(float value, bool sendCallback)
{
if (fValue == value)
return;

fValue = value;

if (fStep == 0.0f)
fValueTmp = value;

repaint();

if (sendCallback && fCallback != nullptr)
fCallback->imageSliderValueChanged(this, fValue);
}

void ImageSlider::setCallback(Callback* callback)
{
fCallback = callback;
}

void ImageSlider::onDisplay()
{
#if 0 // DEBUG, paints slider area
glColor3f(0.4f, 0.5f, 0.1f);
glRecti(fSliderArea.getX(), fSliderArea.getY(), fSliderArea.getX()+fSliderArea.getWidth(), fSliderArea.getY()+fSliderArea.getHeight());
#endif

float normValue = (fValue - fMinimum) / (fMaximum - fMinimum);

int x, y;

if (fStartPos.getX() == fEndPos.getX())
{
x = fStartPos.getX();
y = fEndPos.getY() - static_cast<int>(normValue*static_cast<float>(fEndPos.getY()-fStartPos.getY()));
}
else if (fStartPos.getY() == fEndPos.getY())
{
x = fEndPos.getX() - static_cast<int>(normValue*static_cast<float>(fEndPos.getX()-fStartPos.getX()));
y = fStartPos.getY();
}
else
return;

fImage.draw(x, y);
}

bool ImageSlider::onMouse(int button, bool press, int x, int y)
{
if (button != 1)
return false;

if (press)
{
if (! fSliderArea.contains(x, y))
return false;

float vper;

if (fStartPos.getX() == fEndPos.getX())
{
// vertical
vper = float(y - fSliderArea.getY()) / float(fSliderArea.getHeight());
}
else if (fStartPos.getY() == fEndPos.getY())
{
// horizontal
vper = float(x - fSliderArea.getX()) / float(fSliderArea.getWidth());
}
else
return false;

float value;

value = fMaximum - vper * (fMaximum - fMinimum);

if (value < fMinimum)
{
value = fMinimum;
fValueTmp = value;
}
else if (value > fMaximum)
{
value = fMaximum;
fValueTmp = value;
}
else if (fStep != 0.0f)
{
fValueTmp = value;
const float rest = std::fmod(value, fStep);
value = value - rest + (rest > fStep/2.0f ? fStep : 0.0f);
}

fDragging = true;
fStartedX = x;
fStartedY = y;

if (fCallback != nullptr)
fCallback->imageSliderDragStarted(this);

setValue(value, true);

return true;
}
else if (fDragging)
{
if (fCallback != nullptr)
fCallback->imageSliderDragFinished(this);

fDragging = false;
return true;
}

return false;
}

bool ImageSlider::onMotion(int x, int y)
{
if (! fDragging)
return false;

bool horizontal = fStartPos.getY() == fEndPos.getY();

if ((horizontal && fSliderArea.containsX(x)) || (fSliderArea.containsY(y) && ! horizontal))
{
float vper;

if (horizontal)
{
// horizontal
vper = float(x - fSliderArea.getX()) / float(fSliderArea.getWidth());
}
else
{
// vertical
vper = float(y - fSliderArea.getY()) / float(fSliderArea.getHeight());
}

float value;

value = fMaximum - vper * (fMaximum - fMinimum);

if (value < fMinimum)
{
value = fMinimum;
fValueTmp = value;
}
else if (value > fMaximum)
{
value = fMaximum;
fValueTmp = value;
}
else if (fStep != 0.0f)
{
fValueTmp = value;
const float rest = std::fmod(value, fStep);
value = value - rest + (rest > fStep/2.0f ? fStep : 0.0f);
}

setValue(value, true);
}
else if (y < fSliderArea.getY())
{
setValue(fMaximum, true);
}
else
{
setValue(fMinimum, true);
}

return true;
}

void ImageSlider::_recheckArea()
{
if (fStartPos.getX() == fEndPos.getX())
{
fSliderArea = Rectangle<int>(fStartPos.getX(),
fStartPos.getY(),
fImage.getWidth(),
fEndPos.getY() + fImage.getHeight() - fStartPos.getY());
}
else if (fStartPos.getY() == fEndPos.getY())
{
fSliderArea = Rectangle<int>(fStartPos.getX(),
fStartPos.getY(),
fEndPos.getX() + fImage.getWidth() - fStartPos.getX(),
fImage.getHeight());
}
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 238
- 0
libs/dgl/src/Widget.cpp View File

@@ -0,0 +1,238 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../App.hpp"
#include "../Widget.hpp"
#include "../Window.hpp"

#include <cassert>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Widget

Widget::Widget(Window& parent)
: fParent(parent),
fVisible(true)
{
fParent._addWidget(this);
}

Widget::~Widget()
{
fParent._removeWidget(this);
}

bool Widget::isVisible() const noexcept
{
return fVisible;
}

void Widget::setVisible(bool yesNo)
{
if (fVisible == yesNo)
return;

fVisible = yesNo;
fParent.repaint();
}

void Widget::show()
{
setVisible(true);
}

void Widget::hide()
{
setVisible(false);
}

int Widget::getX() const noexcept
{
return fArea.getX();
}

int Widget::getY() const noexcept
{
return fArea.getY();
}

const Point<int>& Widget::getPos() const noexcept
{
return fArea.getPos();
}

void Widget::setX(int x)
{
if (fArea.getX() == x)
return;

fArea.setX(x);
fParent.repaint();
}

void Widget::setY(int y)
{
if (fArea.getY() == y)
return;

fArea.setY(y);
fParent.repaint();
}

void Widget::setPos(int x, int y)
{
setPos(Point<int>(x, y));
}

void Widget::setPos(const Point<int>& pos)
{
if (fArea.getPos() == pos)
return;

fArea.setPos(pos);
fParent.repaint();
}

void Widget::move(int x, int y)
{
fArea.move(x, y);
fParent.repaint();
}

void Widget::move(const Point<int>& pos)
{
fArea.move(pos);
fParent.repaint();
}

int Widget::getWidth() const noexcept
{
return fArea.getWidth();
}

int Widget::getHeight() const noexcept
{
return fArea.getHeight();
}

const Size<int>& Widget::getSize() const noexcept
{
return fArea.getSize();
}

void Widget::setWidth(int width)
{
if (fArea.getWidth() == width)
return;

fArea.setWidth(width);
fParent.repaint();
}

void Widget::setHeight(int height)
{
if (fArea.getHeight() == height)
return;

fArea.setHeight(height);
fParent.repaint();
}

void Widget::setSize(const Size<int>& size)
{
if (fArea.getSize() == size)
return;

fArea.setSize(size);
fParent.repaint();
}

const Rectangle<int>& Widget::getArea() const noexcept
{
return fArea;
}

uint32_t Widget::getEventTimestamp()
{
return fParent.getEventTimestamp();
}

int Widget::getModifiers()
{
return fParent.getModifiers();
}

App& Widget::getParentApp() const noexcept
{
return fParent.getApp();
}

Window& Widget::getParentWindow() const noexcept
{
return fParent;
}

void Widget::repaint()
{
fParent.repaint();
}

bool Widget::onKeyboard(bool, uint32_t)
{
return false;
}

bool Widget::onMouse(int, bool, int, int)
{
return false;
}

bool Widget::onMotion(int, int)
{
return false;
}

bool Widget::onScroll(int, int, float, float)
{
return false;
}

bool Widget::onSpecial(bool, Key)
{
return false;
}

void Widget::onReshape(int width, int height)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, 0.0f, 1.0f);
glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void Widget::onClose()
{
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 906
- 0
libs/dgl/src/Window.cpp View File

@@ -0,0 +1,906 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../App.hpp"
#include "../Widget.hpp"
#include "../Window.hpp"

#include <cassert>
#include <cstdio>
#include <list>

#include "pugl/pugl.h"

#if defined(DGL_OS_WINDOWS)
# include "pugl/pugl_win.cpp"
#elif defined(DGL_OS_MAC)
# include "pugl/pugl_osx_extended.h"
extern "C" {
struct PuglViewImpl {
int width;
int height;
};}
#elif defined(DGL_OS_LINUX)
extern "C" {
# include "pugl/pugl_x11.c"
}
#else
# error Unsupported platform
#endif

#define FOR_EACH_WIDGET(it) \
for (std::list<Widget*>::iterator it = fWidgets.begin(); it != fWidgets.end(); ++it)

#define FOR_EACH_WIDGET_INV(rit) \
for (std::list<Widget*>::reverse_iterator rit = fWidgets.rbegin(); rit != fWidgets.rend(); ++rit)

#ifdef DEBUG
# define DBG(msg) std::fprintf(stderr, "%s", msg);
# define DBGp(...) std::fprintf(stderr, __VA_ARGS__);
# define DBGF std::fflush(stderr);
#else
# define DBG(msg)
# define DBGp(...)
# define DBGF
#endif

START_NAMESPACE_DGL

Window* dgl_lastUiParent = nullptr;

// -----------------------------------------------------------------------
// Window Private

class Window::PrivateData
{
public:
PrivateData(App& app, Window* const self)
: fApp(app),
fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fFirstInit(true),
fVisible(false),
fResizable(true),
fUsingEmbed(false),
#if defined(DGL_OS_WINDOWS)
hwnd(0)
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#else
_dummy('\0')
#endif
{
DBG("Creating window without parent..."); DBGF;
init();
}

PrivateData(App& app, Window* const self, Window& parent)
: fApp(app),
fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fFirstInit(true),
fVisible(false),
fResizable(true),
fUsingEmbed(false),
fModal(parent.pData),
#if defined(DGL_OS_WINDOWS)
hwnd(0)
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#else
_dummy('\0')
#endif
{
DBG("Creating window with parent..."); DBGF;
init();

#ifdef DGL_OS_LINUX
const PuglInternals* const parentImpl(parent.pData->fView->impl);

XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
#endif
}

PrivateData(App& app, Window* const self, const intptr_t parentId)
: fApp(app),
fSelf(self),
fView(puglCreate(parentId, "Window", 100, 100, (parentId == 0), (parentId != 0))),
fFirstInit(true),
fVisible(parentId != 0),
fResizable(parentId == 0),
fUsingEmbed(parentId != 0),
#if defined(DGL_OS_WINDOWS)
hwnd(0)
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#else
_dummy('\0')
#endif
{
if (parentId != 0) {
DBG("Creating embedded window..."); DBGF;
} else {
DBG("Creating window without parent..."); DBGF;
}

init();

if (parentId != 0)
{
DBG("NOTE: Embed window is always visible and non-resizable\n");
fApp._oneShown();
fFirstInit = false;
}
}

void init()
{
if (fSelf == nullptr || fView == nullptr)
{
DBG("Failed!\n");
dgl_lastUiParent = nullptr;
return;
}

dgl_lastUiParent = fSelf;

puglSetHandle(fView, this);
puglSetDisplayFunc(fView, onDisplayCallback);
puglSetKeyboardFunc(fView, onKeyboardCallback);
puglSetMotionFunc(fView, onMotionCallback);
puglSetMouseFunc(fView, onMouseCallback);
puglSetScrollFunc(fView, onScrollCallback);
puglSetSpecialFunc(fView, onSpecialCallback);
puglSetReshapeFunc(fView, onReshapeCallback);
puglSetCloseFunc(fView, onCloseCallback);

#if defined(DGL_OS_WINDOWS)
PuglInternals* impl = fView->impl;
hwnd = impl->hwnd;
assert(hwnd != 0);
#elif defined(DGL_OS_LINUX)
PuglInternals* impl = fView->impl;
xDisplay = impl->display;
xWindow = impl->win;
assert(xWindow != 0);
#endif

DBG("Success!\n");

// process any initial events
puglProcessEvents(fView);

fApp._addWindow(fSelf);
}

~PrivateData()
{
DBG("Destroying window..."); DBGF;

//fOnModal = false;
fWidgets.clear();

if (fSelf != nullptr)
{
fApp._removeWindow(fSelf);
fSelf = nullptr;
}

if (fView != nullptr)
{
puglDestroy(fView);
fView = nullptr;
}

#if defined(DGL_OS_WINDOWS)
hwnd = 0;
#elif defined(DGL_OS_LINUX)
xDisplay = nullptr;
xWindow = 0;
#endif

DBG("Success!\n");
}

// -------------------------------------------------------------------

void close()
{
DBG("Window close\n");
setVisible(false);

if (! fFirstInit)
{
fApp._oneHidden();
fFirstInit = true;
}
}

void exec(const bool lockWait)
{
DBG("Window exec\n");
exec_init();

if (lockWait)
{
for (; fVisible && fModal.enabled;)
{
// idle()
puglProcessEvents(fView);

if (fModal.parent != nullptr)
fModal.parent->idle();

msleep(10);
}

exec_fini();
}
else
{
idle();
}
}

// -------------------------------------------------------------------

void focus()
{
DBG("Window focus\n");
#if defined(DGL_OS_WINDOWS)
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
#elif defined(DGL_OS_MAC)
puglImplFocus(fView);
#elif defined(DGL_OS_LINUX)
XRaiseWindow(xDisplay, xWindow);
XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime);
XFlush(xDisplay);
#endif
}

void repaint()
{
//DBG("Window repaint\n");
puglPostRedisplay(fView);
}

// -------------------------------------------------------------------

bool isVisible() const noexcept
{
return fVisible;
}

void setVisible(const bool yesNo)
{
if (fVisible == yesNo)
{
DBG("Window setVisible matches current state, ignoring request\n");
return;
}
if (fUsingEmbed)
{
DBG("Window setVisible cannot be called when embedded\n");
return;
}

DBG("Window setVisible called\n");

fVisible = yesNo;

if (yesNo && fFirstInit)
setSize(static_cast<unsigned int>(fView->width), static_cast<unsigned int>(fView->height), true);

#if defined(DGL_OS_WINDOWS)
if (yesNo)
ShowWindow(hwnd, fFirstInit ? SW_SHOWNORMAL : SW_RESTORE);
else
ShowWindow(hwnd, SW_HIDE);

UpdateWindow(hwnd);
#elif defined(DGL_OS_MAC)
puglImplSetVisible(fView, yesNo);
#elif defined(DGL_OS_LINUX)
if (yesNo)
XMapRaised(xDisplay, xWindow);
else
XUnmapWindow(xDisplay, xWindow);

XFlush(xDisplay);
#endif

if (yesNo)
{
if (fFirstInit)
{
fApp._oneShown();
fFirstInit = false;
}
}
else if (fModal.enabled)
exec_fini();
}

// -------------------------------------------------------------------

bool isResizable() const noexcept
{
return fResizable;
}

void setResizable(const bool yesNo)
{
if (fResizable == yesNo)
{
DBG("Window setResizable matches current state, ignoring request\n");
return;
}
if (fUsingEmbed)
{
DBG("Window setResizable cannot be called when embedded\n");
return;
}

DBG("Window setResizable called\n");

fResizable = yesNo;

setSize(static_cast<unsigned int>(fView->width), static_cast<unsigned int>(fView->height), true);
}

// -------------------------------------------------------------------

int getWidth() const noexcept
{
return fView->width;
}

int getHeight() const noexcept
{
return fView->height;
}

Size<int> getSize() const noexcept
{
return Size<int>(fView->width, fView->height);
}

void setSize(unsigned int width, unsigned int height, const bool forced = false)
{
if (width == 0 || height == 0)
{
DBGp("Window setSize called with invalid value(s) %i %i, ignoring request\n", width, height);
return;
}

if (fView->width == static_cast<int>(width) && fView->height == static_cast<int>(height) && ! forced)
{
DBG("Window setSize matches current size, ignoring request\n");
return;
}

fView->width = static_cast<int>(width);
fView->height = static_cast<int>(height);

DBGp("Window setSize called %s\n", forced ? "(forced)" : "(not forced)");

#if defined(DGL_OS_WINDOWS)
int winFlags = WS_POPUPWINDOW | WS_CAPTION;

if (fResizable)
winFlags |= WS_SIZEBOX;

RECT wr = { 0, 0, static_cast<long>(width), static_cast<long>(height) };
AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST);

SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);

if (! forced)
UpdateWindow(hwnd);
#elif defined(DGL_OS_MAC)
puglImplSetSize(fView, width, height, forced);
#elif defined(DGL_OS_LINUX)
XResizeWindow(xDisplay, xWindow, width, height);

if (! fResizable)
{
XSizeHints sizeHints;
memset(&sizeHints, 0, sizeof(sizeHints));

sizeHints.flags = PMinSize|PMaxSize;
sizeHints.min_width = static_cast<int>(width);
sizeHints.min_height = static_cast<int>(height);
sizeHints.max_width = static_cast<int>(width);
sizeHints.max_height = static_cast<int>(height);

XSetNormalHints(xDisplay, xWindow, &sizeHints);
}

if (! forced)
XFlush(xDisplay);
#endif

repaint();
}

// -------------------------------------------------------------------

void setTitle(const char* const title)
{
DBGp("Window setTitle \"%s\"\n", title);

#if defined(DGL_OS_WINDOWS)
SetWindowTextA(hwnd, title);
#elif defined(DGL_OS_MAC)
puglImplSetTitle(fView, title);
#elif defined(DGL_OS_LINUX)
XStoreName(xDisplay, xWindow, title);
#endif
}

App& getApp() const noexcept
{
return fApp;
}

int getModifiers() const
{
return puglGetModifiers(fView);
}

uint32_t getEventTimestamp() const
{
return puglGetEventTimestamp(fView);
}

intptr_t getWindowId() const
{
return puglGetNativeWindow(fView);
}

// -------------------------------------------------------------------

void addWidget(Widget* const widget)
{
fWidgets.push_back(widget);
}

void removeWidget(Widget* const widget)
{
fWidgets.remove(widget);
}

void idle()
{
puglProcessEvents(fView);

if (fModal.enabled && fModal.parent != nullptr)
fModal.parent->idle();
}

// -------------------------------------------------------------------

void exec_init()
{
DBG("Window modal loop starting..."); DBGF;
assert(fModal.parent != nullptr);

if (fModal.parent == nullptr)
{
DBG("Failed, there's no modal parent!\n");
return setVisible(true);
}

fModal.enabled = true;
fModal.parent->fModal.childFocus = this;

#ifdef DGL_OS_WINDOWS
// Center this window
PuglInternals* const parentImpl = fModal.parent->fView->impl;

RECT curRect;
RECT parentRect;
GetWindowRect(hwnd, &curRect);
GetWindowRect(parentImpl->hwnd, &parentRect);

int x = parentRect.left+(parentRect.right-curRect.right)/2;
int y = parentRect.top +(parentRect.bottom-curRect.bottom)/2;

SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
UpdateWindow(hwnd);
#endif

fModal.parent->setVisible(true);
setVisible(true);

DBG("Ok\n");
}

void exec_fini()
{
DBG("Window modal loop stopping..."); DBGF;
fModal.enabled = false;

if (fModal.parent != nullptr)
fModal.parent->fModal.childFocus = nullptr;

DBG("Ok\n");
}

// -------------------------------------------------------------------

protected:
void onDisplay()
{
//DBG("PUGL: onDisplay\n");

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

FOR_EACH_WIDGET(it)
{
Widget* const widget(*it);

if (widget->isVisible())
widget->onDisplay();
}
}

void onKeyboard(const bool press, const uint32_t key)
{
DBGp("PUGL: onKeyboard : %i %i\n", press, key);

if (fModal.childFocus != nullptr)
return fModal.childFocus->focus();

FOR_EACH_WIDGET_INV(rit)
{
Widget* const widget(*rit);

if (widget->isVisible() && widget->onKeyboard(press, key))
break;
}
}

void onMouse(const int button, const bool press, const int x, const int y)
{
DBGp("PUGL: onMouse : %i %i %i %i\n", button, press, x, y);

if (fModal.childFocus != nullptr)
return fModal.childFocus->focus();

FOR_EACH_WIDGET_INV(rit)
{
Widget* const widget(*rit);

if (widget->isVisible() && widget->onMouse(button, press, x, y))
break;
}
}

void onMotion(const int x, const int y)
{
DBGp("PUGL: onMotion : %i %i\n", x, y);

if (fModal.childFocus != nullptr)
return;

FOR_EACH_WIDGET_INV(rit)
{
Widget* const widget(*rit);

if (widget->isVisible() && widget->onMotion(x, y))
break;
}
}

void onScroll(const int x, const int y, const float dx, const float dy)
{
DBGp("PUGL: onScroll : %i %i %f %f\n", x, y, dx, dy);

if (fModal.childFocus != nullptr)
return;

FOR_EACH_WIDGET_INV(rit)
{
Widget* const widget(*rit);

if (widget->isVisible() && widget->onScroll(x, y, dx, dy))
break;
}
}

void onSpecial(const bool press, const Key key)
{
DBGp("PUGL: onSpecial : %i %i\n", press, key);

if (fModal.childFocus != nullptr)
return;

FOR_EACH_WIDGET_INV(rit)
{
Widget* const widget(*rit);

if (widget->isVisible() && widget->onSpecial(press, key))
break;
}
}

void onReshape(const int width, const int height)
{
DBGp("PUGL: onReshape : %i %i\n", width, height);

FOR_EACH_WIDGET(it)
{
Widget* const widget(*it);
widget->onReshape(width, height);
}
}

void onClose()
{
DBG("PUGL: onClose\n");

if (fModal.enabled && fModal.parent != nullptr)
exec_fini();

if (fModal.childFocus != nullptr)
fModal.childFocus->onClose();

FOR_EACH_WIDGET(it)
{
Widget* const widget(*it);
widget->onClose();
}

close();
}

// -------------------------------------------------------------------

private:
App& fApp;
Window* fSelf;
PuglView* fView;

bool fFirstInit;
bool fVisible;
bool fResizable;
bool fUsingEmbed;
std::list<Widget*> fWidgets;

struct Modal {
bool enabled;
PrivateData* parent;
PrivateData* childFocus;

Modal()
: enabled(false),
parent(nullptr),
childFocus(nullptr) {}

Modal(PrivateData* const p)
: enabled(false),
parent(p),
childFocus(nullptr) {}

~Modal()
{
assert(! enabled);
assert(childFocus == nullptr);
}
} fModal;

#if defined(DGL_OS_WINDOWS)
HWND hwnd;
#elif defined(DGL_OS_LINUX)
Display* xDisplay;
::Window xWindow;
#else
char _dummy;
#endif

// -------------------------------------------------------------------
// Callbacks

#define handlePtr ((PrivateData*)puglGetHandle(view))

static void onDisplayCallback(PuglView* view)
{
handlePtr->onDisplay();
}

static void onKeyboardCallback(PuglView* view, bool press, uint32_t key)
{
handlePtr->onKeyboard(press, key);
}

static void onMouseCallback(PuglView* view, int button, bool press, int x, int y)
{
handlePtr->onMouse(button, press, x, y);
}

static void onMotionCallback(PuglView* view, int x, int y)
{
handlePtr->onMotion(x, y);
}

static void onScrollCallback(PuglView* view, int x, int y, float dx, float dy)
{
handlePtr->onScroll(x, y, dx, dy);
}

static void onSpecialCallback(PuglView* view, bool press, PuglKey key)
{
handlePtr->onSpecial(press, static_cast<Key>(key));
}

static void onReshapeCallback(PuglView* view, int width, int height)
{
handlePtr->onReshape(width, height);
}

static void onCloseCallback(PuglView* view)
{
handlePtr->onClose();
}

#undef handlePtr
};

// -----------------------------------------------------------------------
// Window

Window::Window(App& app)
: pData(new PrivateData(app, this))
{
}

Window::Window(App& app, Window& parent)
: pData(new PrivateData(app, this, parent))
{
}

Window::Window(App& app, intptr_t parentId)
: pData(new PrivateData(app, this, parentId))
{
}

Window::~Window()
{
delete pData;
}

void Window::show()
{
pData->setVisible(true);
}

void Window::hide()
{
pData->setVisible(false);
}

void Window::close()
{
pData->close();
}

void Window::exec(bool lockWait)
{
pData->exec(lockWait);
}

void Window::focus()
{
pData->focus();
}

void Window::repaint()
{
pData->repaint();
}

bool Window::isVisible() const noexcept
{
return pData->isVisible();
}

void Window::setVisible(bool yesNo)
{
pData->setVisible(yesNo);
}

bool Window::isResizable() const noexcept
{
return pData->isResizable();
}

void Window::setResizable(bool yesNo)
{
pData->setResizable(yesNo);
}

int Window::getWidth() const noexcept
{
return pData->getWidth();
}

int Window::getHeight() const noexcept
{
return pData->getHeight();
}

Size<int> Window::getSize() const noexcept
{
return pData->getSize();
}

void Window::setSize(unsigned int width, unsigned int height)
{
pData->setSize(width, height);
}

void Window::setTitle(const char* title)
{
pData->setTitle(title);
}

App& Window::getApp() const noexcept
{
return pData->getApp();
}

int Window::getModifiers() const
{
return pData->getModifiers();
}

uint32_t Window::getEventTimestamp() const
{
return pData->getEventTimestamp();
}

intptr_t Window::getWindowId() const
{
return pData->getWindowId();
}

void Window::_addWidget(Widget* const widget)
{
pData->addWidget(widget);
}

void Window::_removeWidget(Widget* const widget)
{
pData->removeWidget(widget);
}

void Window::_idle()
{
pData->idle();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#undef DBG
#undef DBGF

+ 357
- 0
libs/dgl/src/pugl/pugl.h View File

@@ -0,0 +1,357 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl.h API for Pugl, a minimal portable API for OpenGL.
*/

#ifndef PUGL_H_INCLUDED
#define PUGL_H_INCLUDED

#include <stdint.h>

/*
This API is pure portable C and contains no platform specific elements, or
even a GL dependency. However, unfortunately GL includes vary across
platforms so they are included here to allow for pure portable programs.
*/
#ifdef __APPLE__
# include "OpenGL/gl.h"
#else
# ifdef _WIN32
# include <windows.h> /* Broken Windows GL headers require this */
# endif
# include "GL/gl.h"
#endif

#ifdef PUGL_SHARED
# ifdef _WIN32
# define PUGL_LIB_IMPORT __declspec(dllimport)
# define PUGL_LIB_EXPORT __declspec(dllexport)
# else
# define PUGL_LIB_IMPORT __attribute__((visibility("default")))
# define PUGL_LIB_EXPORT __attribute__((visibility("default")))
# endif
# ifdef PUGL_INTERNAL
# define PUGL_API PUGL_LIB_EXPORT
# else
# define PUGL_API PUGL_LIB_IMPORT
# endif
#else
# define PUGL_API
#endif

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

/**
@defgroup pugl Pugl
A minimal portable API for OpenGL.
@{
*/

/**
An OpenGL view.
*/
typedef struct PuglViewImpl PuglView;

/**
A native window handle.

On X11, this is a Window.
On OSX, this is an NSView*.
On Windows, this is a HWND.
*/
typedef intptr_t PuglNativeWindow;

/**
Return status code.
*/
typedef enum {
PUGL_SUCCESS = 0
} PuglStatus;

/**
Convenience symbols for ASCII control characters.
*/
typedef enum {
PUGL_CHAR_BACKSPACE = 0x08,
PUGL_CHAR_ESCAPE = 0x1B,
PUGL_CHAR_DELETE = 0x7F
} PuglChar;

/**
Special (non-Unicode) keyboard keys.
*/
typedef enum {
PUGL_KEY_F1 = 1,
PUGL_KEY_F2,
PUGL_KEY_F3,
PUGL_KEY_F4,
PUGL_KEY_F5,
PUGL_KEY_F6,
PUGL_KEY_F7,
PUGL_KEY_F8,
PUGL_KEY_F9,
PUGL_KEY_F10,
PUGL_KEY_F11,
PUGL_KEY_F12,
PUGL_KEY_LEFT,
PUGL_KEY_UP,
PUGL_KEY_RIGHT,
PUGL_KEY_DOWN,
PUGL_KEY_PAGE_UP,
PUGL_KEY_PAGE_DOWN,
PUGL_KEY_HOME,
PUGL_KEY_END,
PUGL_KEY_INSERT,
PUGL_KEY_SHIFT,
PUGL_KEY_CTRL,
PUGL_KEY_ALT,
PUGL_KEY_SUPER
} PuglKey;

/**
Keyboard modifier flags.
*/
typedef enum {
PUGL_MOD_SHIFT = 1, /**< Shift key */
PUGL_MOD_CTRL = 1 << 1, /**< Control key */
PUGL_MOD_ALT = 1 << 2, /**< Alt/Option key */
PUGL_MOD_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
} PuglMod;

/**
Handle for opaque user data.
*/
typedef void* PuglHandle;

/**
A function called when the window is closed.
*/
typedef void (*PuglCloseFunc)(PuglView* view);

/**
A function called to draw the view contents with OpenGL.
*/
typedef void (*PuglDisplayFunc)(PuglView* view);

/**
A function called when a key is pressed or released.
@param view The view the event occured in.
@param press True if the key was pressed, false if released.
@param key Unicode point of the key pressed.
*/
typedef void (*PuglKeyboardFunc)(PuglView* view, bool press, uint32_t key);

/**
A function called when the pointer moves.
@param view The view the event occured in.
@param x The window-relative x coordinate of the pointer.
@param y The window-relative y coordinate of the pointer.
*/
typedef void (*PuglMotionFunc)(PuglView* view, int x, int y);

/**
A function called when a mouse button is pressed or released.
@param view The view the event occured in.
@param button The button number (1 = left, 2 = middle, 3 = right).
@param press True if the key was pressed, false if released.
@param x The window-relative x coordinate of the pointer.
@param y The window-relative y coordinate of the pointer.
*/
typedef void (*PuglMouseFunc)(
PuglView* view, int button, bool press, int x, int y);

/**
A function called when the view is resized.
@param view The view being resized.
@param width The new view width.
@param height The new view height.
*/
typedef void (*PuglReshapeFunc)(PuglView* view, int width, int height);

/**
A function called on scrolling (e.g. mouse wheel or track pad).

The distances used here are in "lines", a single tick of a clicking mouse
wheel. For example, @p dy = 1.0 scrolls 1 line up. Some systems and
devices support finer resolution and/or higher values for fast scrolls,
so programs should handle any value gracefully.

@param view The view being scrolled.
@param dx The scroll x distance.
@param dx The scroll y distance.
*/
typedef void (*PuglScrollFunc)(PuglView* view,
int x,
int y,
float dx,
float dy);

/**
A function called when a special key is pressed or released.

This callback allows the use of keys that do not have unicode points.

@param view The view the event occured in.
@param press True if the key was pressed, false if released.
@param key The key pressed.
*/
typedef void (*PuglSpecialFunc)(PuglView* view, bool press, PuglKey key);

/**
Create a new GL window.
@param parent Parent window, or 0 for top level.
@param title Window title, or NULL.
@param width Window width in pixels.
@param height Window height in pixels.
@param resizable Whether window should be user resizable.
@param visible Whether window should be initially visible.
*/
PUGL_API PuglView*
puglCreate(PuglNativeWindow parent,
const char* title,
int width,
int height,
bool resizable,
bool visible);

/**
Set the handle to be passed to all callbacks.

This is generally a pointer to a struct which contains all necessary state.
Everything needed in callbacks should be here, not in static variables.

Note the lack of this facility makes GLUT unsuitable for plugins or
non-trivial programs; this mistake is largely why Pugl exists.
*/
PUGL_API void
puglSetHandle(PuglView* view, PuglHandle handle);

/**
Get the handle to be passed to all callbacks.
*/
PUGL_API PuglHandle
puglGetHandle(PuglView* view);

/**
Return the timestamp (if any) of the currently-processing event.
*/
PUGL_API uint32_t
puglGetEventTimestamp(PuglView* view);

/**
Get the currently active modifiers (PuglMod flags).

This should only be called from an event handler.
*/
PUGL_API int
puglGetModifiers(PuglView* view);

/**
Ignore synthetic repeated key events.
*/
PUGL_API void
puglIgnoreKeyRepeat(PuglView* view, bool ignore);

/**
Set the function to call when the window is closed.
*/
PUGL_API void
puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc);

/**
Set the display function which should draw the UI using GL.
*/
PUGL_API void
puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc);

/**
Set the function to call on keyboard events.
*/
PUGL_API void
puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc);

/**
Set the function to call on mouse motion.
*/
PUGL_API void
puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc);

/**
Set the function to call on mouse button events.
*/
PUGL_API void
puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc);

/**
Set the function to call on scroll events.
*/
PUGL_API void
puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc);

/**
Set the function to call on special events.
*/
PUGL_API void
puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc);

/**
Set the function to call when the window size changes.
*/
PUGL_API void
puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc);

/**
Return the native window handle.
*/
PUGL_API PuglNativeWindow
puglGetNativeWindow(PuglView* view);

/**
Process all pending window events.

This handles input events as well as rendering, so it should be called
regularly and rapidly enough to keep the UI responsive.
*/
PUGL_API PuglStatus
puglProcessEvents(PuglView* view);

/**
Request a redisplay on the next call to puglProcessEvents().
*/
PUGL_API void
puglPostRedisplay(PuglView* view);

/**
Destroy a GL window.
*/
PUGL_API void
puglDestroy(PuglView* view);

/**
@}
*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* PUGL_H_INCLUDED */

+ 161
- 0
libs/dgl/src/pugl/pugl_internal.h View File

@@ -0,0 +1,161 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_internal.h Private platform-independent definitions.

Note this file contains function definitions, so it must be compiled into
the final binary exactly once. Each platform specific implementation file
including it once should achieve this.

If you are copying the pugl code into your source tree, the following
symbols can be defined to tweak pugl behaviour:

PUGL_GRAB_FOCUS: Work around reparent keyboard issues by grabbing focus.
PUGL_VERBOSE: Print GL information to console.
*/

#include "pugl.h"

#ifdef PUGL_VERBOSE
# include <stdio.h>
# define PUGL_LOG(str) fprintf(stderr, "pugl: " str)
# define PUGL_LOGF(fmt, ...) fprintf(stderr, "pugl: " fmt, __VA_ARGS__)
#else
# define PUGL_LOG(str)
# define PUGL_LOGF(fmt, ...)
#endif

void puglDefaultReshape(PuglView* view, int width, int height);

typedef struct PuglInternalsImpl PuglInternals;

struct PuglViewImpl {
int width;
int height;

PuglHandle handle;
PuglCloseFunc closeFunc;
PuglDisplayFunc displayFunc;
PuglKeyboardFunc keyboardFunc;
PuglMotionFunc motionFunc;
PuglMouseFunc mouseFunc;
PuglReshapeFunc reshapeFunc;
PuglScrollFunc scrollFunc;
PuglSpecialFunc specialFunc;

PuglInternals* impl;

int mods;
bool mouse_in_view;
bool ignoreKeyRepeat;
bool redisplay;
uint32_t event_timestamp_ms;
};

void
puglSetHandle(PuglView* view, PuglHandle handle)
{
view->handle = handle;
}

PuglHandle
puglGetHandle(PuglView* view)
{
return view->handle;
}

uint32_t
puglGetEventTimestamp(PuglView* view)
{
return view->event_timestamp_ms;
}

int
puglGetModifiers(PuglView* view)
{
return view->mods;
}

void
puglDefaultReshape(PuglView* view, int width, int height)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, 0, 1);
glViewport(0, 0, width, height);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return;

// unused
(void)view;
}

void
puglIgnoreKeyRepeat(PuglView* view, bool ignore)
{
view->ignoreKeyRepeat = ignore;
}

void
puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc)
{
view->closeFunc = closeFunc;
}

void
puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc)
{
view->displayFunc = displayFunc;
}

void
puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc)
{
view->keyboardFunc = keyboardFunc;
}

void
puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc)
{
view->motionFunc = motionFunc;
}

void
puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc)
{
view->mouseFunc = mouseFunc;
}

void
puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc)
{
view->reshapeFunc = reshapeFunc;
}

void
puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc)
{
view->scrollFunc = scrollFunc;
}

void
puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc)
{
view->specialFunc = specialFunc;
}

+ 459
- 0
libs/dgl/src/pugl/pugl_osx.m View File

@@ -0,0 +1,459 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_osx.m OSX/Cocoa Pugl Implementation.
*/

#include <stdlib.h>

#import <Cocoa/Cocoa.h>

#include "pugl_internal.h"

@interface PuglWindow : NSWindow
{
@public
PuglView* puglview;
}

- (id) initWithContentRect:(NSRect)contentRect
styleMask:(unsigned int)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;
- (void) setPuglview:(PuglView*)view;
- (BOOL) windowShouldClose:(id)sender;
- (BOOL) canBecomeKeyWindow:(id)sender;
@end

@implementation PuglWindow

- (id)initWithContentRect:(NSRect)contentRect
styleMask:(unsigned int)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
{
NSWindow* result = [super initWithContentRect:contentRect
styleMask:(NSClosableWindowMask |
NSTitledWindowMask |
NSResizableWindowMask)
backing:NSBackingStoreBuffered defer:NO];

[result setAcceptsMouseMovedEvents:YES];
[result setLevel: CGShieldingWindowLevel() + 1];

return result;
}

- (void)setPuglview:(PuglView*)view
{
puglview = view;
[self setContentSize:NSMakeSize(view->width, view->height) ];
}

- (BOOL)windowShouldClose:(id)sender
{
if (puglview->closeFunc)
puglview->closeFunc(puglview);
return YES;
}

- (BOOL) canBecomeKeyWindow:(id)sender
{
return NO;
}

@end

void
puglDisplay(PuglView* view)
{
if (view->displayFunc) {
view->displayFunc(view);
}
}

@interface PuglOpenGLView : NSOpenGLView
{
int colorBits;
int depthBits;
@public
PuglView* puglview;

NSTrackingArea* trackingArea;
}

- (id) initWithFrame:(NSRect)frame
colorBits:(int)numColorBits
depthBits:(int)numDepthBits;
- (void) reshape;
- (void) drawRect:(NSRect)rect;
- (void) mouseEntered:(NSEvent*)event;
- (void) mouseExited:(NSEvent*)event;
- (void) mouseMoved:(NSEvent*)event;
- (void) mouseDragged:(NSEvent*)event;
- (void) rightMouseDragged:(NSEvent*)event;
- (void) mouseDown:(NSEvent*)event;
- (void) mouseUp:(NSEvent*)event;
- (void) rightMouseDown:(NSEvent*)event;
- (void) rightMouseUp:(NSEvent*)event;
- (void) scrollWheel:(NSEvent*)event;
- (void) keyDown:(NSEvent*)event;
- (void) keyUp:(NSEvent*)event;
- (void) flagsChanged:(NSEvent*)event;

@end

@implementation PuglOpenGLView

- (id) initWithFrame:(NSRect)frame
colorBits:(int)numColorBits
depthBits:(int)numDepthBits
{
colorBits = numColorBits;
depthBits = numDepthBits;

NSOpenGLPixelFormatAttribute pixelAttribs[16] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
NSOpenGLPFAColorSize,
colorBits,
NSOpenGLPFADepthSize,
depthBits,
0
};

NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:pixelAttribs];

if (pixelFormat) {
self = [super initWithFrame:frame pixelFormat:pixelFormat];
[pixelFormat release];
if (self) {
[[self openGLContext] makeCurrentContext];
[self reshape];
}
} else {
self = nil;
}

return self;
}

- (void) reshape
{
[[self openGLContext] update];

NSRect bounds = [self bounds];
int width = bounds.size.width;
int height = bounds.size.height;

if (puglview) {
/* NOTE: Apparently reshape gets called when the GC gets around to
deleting the view (?), so we must have reset puglview to NULL when
this comes around.
*/
if (puglview->reshapeFunc) {
puglview->reshapeFunc(puglview, width, height);
} else {
puglDefaultReshape(puglview, width, height);
}

puglview->width = width;
puglview->height = height;
}
}

- (void) drawRect:(NSRect)rect
{
puglDisplay(puglview);
glFlush();
glSwapAPPLE();
}

static unsigned
getModifiers(PuglView* view, NSEvent* ev)
{
const unsigned modifierFlags = [ev modifierFlags];

view->event_timestamp_ms = fmod([ev timestamp] * 1000.0, UINT32_MAX);

double ts = [ev timestamp] * 1000.0;
ts = (uint32)ts % 500000; //ridiculously large vals won't fit
view->event_timestamp_ms = ts;

unsigned mods = 0;
mods |= (modifierFlags & NSShiftKeyMask) ? PUGL_MOD_SHIFT : 0;
mods |= (modifierFlags & NSControlKeyMask) ? PUGL_MOD_CTRL : 0;
mods |= (modifierFlags & NSAlternateKeyMask) ? PUGL_MOD_ALT : 0;
mods |= (modifierFlags & NSCommandKeyMask) ? PUGL_MOD_SUPER : 0;
return mods;
}

-(void)updateTrackingAreas
{
if (trackingArea != nil) {
[self removeTrackingArea:trackingArea];
[trackingArea release];
}

const int opts = (NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved |
NSTrackingActiveAlways);
trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds]
options:opts
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
}

- (void)mouseEntered:(NSEvent*)theEvent
{
[self updateTrackingAreas];
}

- (void)mouseExited:(NSEvent*)theEvent
{
}

- (void) mouseMoved:(NSEvent*)event
{
if (puglview->motionFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->motionFunc(puglview, loc.x, puglview->height - loc.y);
}
}

- (void) mouseDragged:(NSEvent*)event
{
if (puglview->motionFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->motionFunc(puglview, loc.x, puglview->height - loc.y);
}
}

- (void) rightMouseDragged:(NSEvent*)event
{
if (puglview->motionFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->motionFunc(puglview, loc.x, puglview->height - loc.y);
}
}

- (void) mouseDown:(NSEvent*)event
{
if (puglview->mouseFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->mouseFunc(puglview, 1, true, loc.x, puglview->height - loc.y);
}
}

- (void) mouseUp:(NSEvent*)event
{
if (puglview->mouseFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->mouseFunc(puglview, 1, false, loc.x, puglview->height - loc.y);
}
[self updateTrackingAreas];
}

- (void) rightMouseDown:(NSEvent*)event
{
if (puglview->mouseFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->mouseFunc(puglview, 3, true, loc.x, puglview->height - loc.y);
}
}

- (void) rightMouseUp:(NSEvent*)event
{
if (puglview->mouseFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->mouseFunc(puglview, 3, false, loc.x, puglview->height - loc.y);
}
}

- (void) scrollWheel:(NSEvent*)event
{
if (puglview->scrollFunc) {
NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
puglview->scrollFunc(puglview,
loc.x, puglview->height - loc.y,
[event deltaX], [event deltaY]);
}
[self updateTrackingAreas];
}

- (void) keyDown:(NSEvent*)event
{
if (puglview->keyboardFunc && !(puglview->ignoreKeyRepeat && [event isARepeat])) {
NSString* chars = [event characters];
puglview->mods = getModifiers(puglview, event);
puglview->keyboardFunc(puglview, true, [chars characterAtIndex:0]);
}
}

- (void) keyUp:(NSEvent*)event
{
if (puglview->keyboardFunc) {
NSString* chars = [event characters];
puglview->mods = getModifiers(puglview, event);
puglview->keyboardFunc(puglview, false, [chars characterAtIndex:0]);
}
}

- (void) flagsChanged:(NSEvent*)event
{
if (puglview->specialFunc) {
const unsigned mods = getModifiers(puglview, event);
if ((mods & PUGL_MOD_SHIFT) != (puglview->mods & PUGL_MOD_SHIFT)) {
puglview->specialFunc(puglview, mods & PUGL_MOD_SHIFT, PUGL_KEY_SHIFT);
} else if ((mods & PUGL_MOD_CTRL) != (puglview->mods & PUGL_MOD_CTRL)) {
puglview->specialFunc(puglview, mods & PUGL_MOD_CTRL, PUGL_KEY_CTRL);
} else if ((mods & PUGL_MOD_ALT) != (puglview->mods & PUGL_MOD_ALT)) {
puglview->specialFunc(puglview, mods & PUGL_MOD_ALT, PUGL_KEY_ALT);
} else if ((mods & PUGL_MOD_SUPER) != (puglview->mods & PUGL_MOD_SUPER)) {
puglview->specialFunc(puglview, mods & PUGL_MOD_SUPER, PUGL_KEY_SUPER);
}
puglview->mods = mods;
}
}

@end

struct PuglInternalsImpl {
PuglOpenGLView* glview;
id window;
bool isEmbed;
};

PuglView*
puglCreate(PuglNativeWindow parent,
const char* title,
int width,
int height,
bool resizable,
bool visible)
{
PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
if (!view || !impl) {
return NULL;
}

view->impl = impl;
view->width = width;
view->height = height;

[NSAutoreleasePool new];
[NSApplication sharedApplication];

NSString* titleString = [[NSString alloc]
initWithBytes:title
length:strlen(title)
encoding:NSUTF8StringEncoding];

id window = [[PuglWindow new]retain];

[window setPuglview:view];
[window setTitle:titleString];

impl->glview = [PuglOpenGLView new];
impl->window = window;
impl->isEmbed = (parent != 0);
impl->glview->puglview = view;

[window setContentView:impl->glview];
[NSApp activateIgnoringOtherApps:YES];
[window makeFirstResponder:impl->glview];

[window makeKeyAndOrderFront:window];

if (! visible) {
[window setIsVisible:NO];
}

return view;
}

void
puglDestroy(PuglView* view)
{
view->impl->glview->puglview = NULL;
[view->impl->window close];
[view->impl->glview release];
[view->impl->window release];
free(view->impl);
free(view);
}

PuglStatus
puglProcessEvents(PuglView* view)
{
if (! view->impl->isEmbed)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSEvent* event;

static const NSUInteger eventMask = (NSLeftMouseDownMask | NSLeftMouseUpMask |
NSRightMouseDownMask | NSRightMouseUpMask |
NSMouseMovedMask |
NSLeftMouseDraggedMask | NSRightMouseDraggedMask |
NSMouseEnteredMask | NSMouseExitedMask |
NSKeyDownMask | NSKeyUpMask |
NSFlagsChangedMask |
NSCursorUpdateMask | NSScrollWheelMask);

for (;;) {
event = [view->impl->window
nextEventMatchingMask:eventMask
untilDate:[NSDate distantPast]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];

if (event == nil)
break;

[view->impl->window sendEvent: event];
}

[pool release];
}

[view->impl->glview setNeedsDisplay: YES];

return PUGL_SUCCESS;
}

void
puglPostRedisplay(PuglView* view)
{
view->redisplay = true;
}

PuglNativeWindow
puglGetNativeWindow(PuglView* view)
{
return (PuglNativeWindow)view->impl->glview;
}

+ 37
- 0
libs/dgl/src/pugl/pugl_osx_extended.h View File

@@ -0,0 +1,37 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Copyright 2013 Filipe Coelho <falktx@falktx.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_osx_extended.h Extended OSX/Cocoa Pugl Implementation.
*/

#include <stdbool.h>

#include "pugl.h"

#ifdef __cplusplus
extern "C" {
#endif

void puglImplFocus(PuglView* view);
void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bool forced);
void puglImplSetTitle(PuglView* view, const char* title);
void puglImplSetVisible(PuglView* view, bool yesNo);

#ifdef __cplusplus
} /* extern "C" */
#endif

+ 71
- 0
libs/dgl/src/pugl/pugl_osx_extended.m View File

@@ -0,0 +1,71 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Copyright 2013 Filipe Coelho <falktx@falktx.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_osx_extended.m Extended OSX/Cocoa Pugl Implementation.
*/

#import "pugl_osx.m"

#include "pugl_osx_extended.h"

void puglImplFocus(PuglView* view)
{
id window = view->impl->window;

// TODO
[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:window];
}

void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bool forced)
{
id window = view->impl->window;

NSRect frame = [window frame];
frame.origin.y -= height - frame.size.height;
frame.size.width = width;
frame.size.height = height+20;

// if (forced) {
// [window setFrame:frame];
// } else {
[window setFrame:frame display:YES animate:NO];
// }
}

void puglImplSetTitle(PuglView* view, const char* title)
{
id window = view->impl->window;

NSString* titleString = [[NSString alloc]
initWithBytes:title
length:strlen(title)
encoding:NSUTF8StringEncoding];

[window setTitle:titleString];
}

void puglImplSetVisible(PuglView* view, bool yesNo)
{
id window = view->impl->window;

if (yesNo)
[window setIsVisible:YES];
else
[window setIsVisible:NO];
}

+ 387
- 0
libs/dgl/src/pugl/pugl_win.cpp View File

@@ -0,0 +1,387 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_win.cpp Windows/WGL Pugl Implementation.
*/

#include <windows.h>
#include <windowsx.h>
#include <GL/gl.h>

#include <stdio.h>
#include <stdlib.h>

#include "pugl_internal.h"

#ifndef WM_MOUSEWHEEL
# define WM_MOUSEWHEEL 0x020A
#endif
#ifndef WM_MOUSEHWHEEL
# define WM_MOUSEHWHEEL 0x020E
#endif
#ifndef WHEEL_DELTA
# define WHEEL_DELTA 120
#endif

const int LOCAL_CLOSE_MSG = WM_USER + 50;

struct PuglInternalsImpl {
HWND hwnd;
HDC hdc;
HGLRC hglrc;
WNDCLASS wc;
};

LRESULT CALLBACK
wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

PuglView*
puglCreate(PuglNativeWindow parent,
const char* title,
int width,
int height,
bool resizable,
bool visible)
{
PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
if (!view || !impl) {
return NULL;
}

view->impl = impl;
view->width = width;
view->height = height;

// FIXME: This is nasty, and pugl should not have static anything.
// Should class be a parameter? Does this make sense on other platforms?
static int wc_count = 0;
char classNameBuf[256];
_snprintf(classNameBuf, sizeof(classNameBuf), "%s_%d\n", title, wc_count++);

impl->wc.style = CS_OWNDC;
impl->wc.lpfnWndProc = wndProc;
impl->wc.cbClsExtra = 0;
impl->wc.cbWndExtra = 0;
impl->wc.hInstance = 0;
impl->wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
impl->wc.hCursor = LoadCursor(NULL, IDC_ARROW);
impl->wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
impl->wc.lpszMenuName = NULL;
impl->wc.lpszClassName = classNameBuf;
RegisterClass(&impl->wc);

int winFlags = WS_POPUPWINDOW | WS_CAPTION;
if (resizable) {
winFlags |= WS_SIZEBOX;
}

// Adjust the overall window size to accomodate our requested client size
RECT wr = { 0, 0, width, height };
AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST);

impl->hwnd = CreateWindowEx(
WS_EX_TOPMOST,
classNameBuf, title,
(visible ? WS_VISIBLE : 0) | (parent ? WS_CHILD : winFlags),
0, 0, wr.right-wr.left, wr.bottom-wr.top,
(HWND)parent, NULL, NULL, NULL);

if (!impl->hwnd) {
free(impl);
free(view);
return NULL;
}

#ifdef _WIN64
SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view);
#else
SetWindowLongPtr(impl->hwnd, GWL_USERDATA, (LONG)view);
#endif

impl->hdc = GetDC(impl->hwnd);

PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;

int format = ChoosePixelFormat(impl->hdc, &pfd);
SetPixelFormat(impl->hdc, format, &pfd);

impl->hglrc = wglCreateContext(impl->hdc);
wglMakeCurrent(impl->hdc, impl->hglrc);

view->width = width;
view->height = height;

return view;
}

void
puglDestroy(PuglView* view)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(view->impl->hglrc);
ReleaseDC(view->impl->hwnd, view->impl->hdc);
DestroyWindow(view->impl->hwnd);
UnregisterClass(view->impl->wc.lpszClassName, NULL);
free(view->impl);
free(view);
}

void
puglReshape(PuglView* view, int width, int height)
{
wglMakeCurrent(view->impl->hdc, view->impl->hglrc);

if (view->reshapeFunc) {
view->reshapeFunc(view, width, height);
} else {
puglDefaultReshape(view, width, height);
}

view->width = width;
view->height = height;
}

void
puglDisplay(PuglView* view)
{
wglMakeCurrent(view->impl->hdc, view->impl->hglrc);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

if (view->displayFunc) {
view->displayFunc(view);
}

glFlush();
SwapBuffers(view->impl->hdc);
view->redisplay = false;
}

static PuglKey
keySymToSpecial(int sym)
{
switch (sym) {
case VK_F1: return PUGL_KEY_F1;
case VK_F2: return PUGL_KEY_F2;
case VK_F3: return PUGL_KEY_F3;
case VK_F4: return PUGL_KEY_F4;
case VK_F5: return PUGL_KEY_F5;
case VK_F6: return PUGL_KEY_F6;
case VK_F7: return PUGL_KEY_F7;
case VK_F8: return PUGL_KEY_F8;
case VK_F9: return PUGL_KEY_F9;
case VK_F10: return PUGL_KEY_F10;
case VK_F11: return PUGL_KEY_F11;
case VK_F12: return PUGL_KEY_F12;
case VK_LEFT: return PUGL_KEY_LEFT;
case VK_UP: return PUGL_KEY_UP;
case VK_RIGHT: return PUGL_KEY_RIGHT;
case VK_DOWN: return PUGL_KEY_DOWN;
case VK_PRIOR: return PUGL_KEY_PAGE_UP;
case VK_NEXT: return PUGL_KEY_PAGE_DOWN;
case VK_HOME: return PUGL_KEY_HOME;
case VK_END: return PUGL_KEY_END;
case VK_INSERT: return PUGL_KEY_INSERT;
case VK_SHIFT: return PUGL_KEY_SHIFT;
case VK_CONTROL: return PUGL_KEY_CTRL;
case VK_MENU: return PUGL_KEY_ALT;
case VK_LWIN: return PUGL_KEY_SUPER;
case VK_RWIN: return PUGL_KEY_SUPER;
}
return (PuglKey)0;
}

static void
processMouseEvent(PuglView* view, int button, bool press, LPARAM lParam)
{
view->event_timestamp_ms = GetMessageTime();
if (press) {
SetCapture(view->impl->hwnd);
} else {
ReleaseCapture();
}
if (view->mouseFunc) {
view->mouseFunc(view, button, press,
GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam));
}
}

static void
setModifiers(PuglView* view)
{
view->mods = 0;
view->mods |= (GetKeyState(VK_SHIFT) < 0) ? PUGL_MOD_SHIFT : 0;
view->mods |= (GetKeyState(VK_CONTROL) < 0) ? PUGL_MOD_CTRL : 0;
view->mods |= (GetKeyState(VK_MENU) < 0) ? PUGL_MOD_ALT : 0;
view->mods |= (GetKeyState(VK_LWIN) < 0) ? PUGL_MOD_SUPER : 0;
view->mods |= (GetKeyState(VK_RWIN) < 0) ? PUGL_MOD_SUPER : 0;
}

static LRESULT
handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
PuglKey key;

setModifiers(view);
switch (message) {
case WM_CREATE:
case WM_SHOWWINDOW:
case WM_SIZE:
RECT rect;
GetClientRect(view->impl->hwnd, &rect);
puglReshape(view, rect.right, rect.bottom);
view->width = rect.right;
view->height = rect.bottom;
break;
case WM_PAINT:
BeginPaint(view->impl->hwnd, &ps);
puglDisplay(view);
EndPaint(view->impl->hwnd, &ps);
break;
case WM_MOUSEMOVE:
if (view->motionFunc) {
view->motionFunc(view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
}
break;
case WM_LBUTTONDOWN:
processMouseEvent(view, 1, true, lParam);
break;
case WM_MBUTTONDOWN:
processMouseEvent(view, 2, true, lParam);
break;
case WM_RBUTTONDOWN:
processMouseEvent(view, 3, true, lParam);
break;
case WM_LBUTTONUP:
processMouseEvent(view, 1, false, lParam);
break;
case WM_MBUTTONUP:
processMouseEvent(view, 2, false, lParam);
break;
case WM_RBUTTONUP:
processMouseEvent(view, 3, false, lParam);
break;
case WM_MOUSEWHEEL:
if (view->scrollFunc) {
view->event_timestamp_ms = GetMessageTime();
view->scrollFunc(
view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
0.0f, (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA);
}
break;
case WM_MOUSEHWHEEL:
if (view->scrollFunc) {
view->event_timestamp_ms = GetMessageTime();
view->scrollFunc(
view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
(int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0.0f);
}
break;
case WM_KEYDOWN:
if (view->ignoreKeyRepeat && (lParam & (1 << 30))) {
break;
} // else nobreak
case WM_KEYUP:
view->event_timestamp_ms = GetMessageTime();
if ((key = keySymToSpecial(wParam))) {
if (view->specialFunc) {
view->specialFunc(view, message == WM_KEYDOWN, key);
}
} else if (view->keyboardFunc) {
view->keyboardFunc(view, message == WM_KEYDOWN, wParam);
}
break;
case WM_QUIT:
case LOCAL_CLOSE_MSG:
if (view->closeFunc) {
view->closeFunc(view);
}
break;
default:
return DefWindowProc(
view->impl->hwnd, message, wParam, lParam);
}

return 0;
}

PuglStatus
puglProcessEvents(PuglView* view)
{
MSG msg;
while (PeekMessage(&msg, view->impl->hwnd, 0, 0, PM_REMOVE)) {
handleMessage(view, msg.message, msg.wParam, msg.lParam);
}


if (view->redisplay) {
InvalidateRect(view->impl->hwnd, NULL, FALSE);
}

return PUGL_SUCCESS;
}

LRESULT CALLBACK
wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#ifdef _WIN64
PuglView* view = (PuglView*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
#else
PuglView* view = (PuglView*)GetWindowLongPtr(hwnd, GWL_USERDATA);
#endif

switch (message) {
case WM_CREATE:
PostMessage(hwnd, WM_SHOWWINDOW, TRUE, 0);
return 0;
case WM_CLOSE:
PostMessage(hwnd, LOCAL_CLOSE_MSG, wParam, lParam);
return 0;
case WM_DESTROY:
return 0;
default:
if (view) {
return handleMessage(view, message, wParam, lParam);
} else {
return DefWindowProc(hwnd, message, wParam, lParam);
}
}
}

void
puglPostRedisplay(PuglView* view)
{
view->redisplay = true;
}

PuglNativeWindow
puglGetNativeWindow(PuglView* view)
{
return (PuglNativeWindow)view->impl->hwnd;
}

+ 397
- 0
libs/dgl/src/pugl/pugl_x11.c View File

@@ -0,0 +1,397 @@
/*
Copyright 2012-2014 David Robillard <http://drobilla.net>
Copyright 2011-2012 Ben Loftis, Harrison Consoles

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_x11.c X11 Pugl Implementation.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <GL/gl.h>
#include <GL/glx.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>

#include "pugl_internal.h"

struct PuglInternalsImpl {
Display* display;
int screen;
Window win;
GLXContext ctx;
Bool doubleBuffered;
};

/**
Attributes for single-buffered RGBA with at least
4 bits per color and a 16 bit depth buffer.
*/
static int attrListSgl[] = {
GLX_RGBA,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};

/**
Attributes for double-buffered RGBA with at least
4 bits per color and a 16 bit depth buffer.
*/
static int attrListDbl[] = {
GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};

PuglView*
puglCreate(PuglNativeWindow parent,
const char* title,
int width,
int height,
bool resizable,
bool visible)
{
PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
if (!view || !impl) {
return NULL;
}

view->impl = impl;
view->width = width;
view->height = height;

impl->display = XOpenDisplay(0);
impl->screen = DefaultScreen(impl->display);

XVisualInfo* vi = glXChooseVisual(impl->display, impl->screen, attrListDbl);
if (!vi) {
vi = glXChooseVisual(impl->display, impl->screen, attrListSgl);
impl->doubleBuffered = False;
PUGL_LOG("No double buffering available\n");
} else {
impl->doubleBuffered = True;
PUGL_LOG("Double buffered rendering enabled\n");
}

int glxMajor, glxMinor;
glXQueryVersion(impl->display, &glxMajor, &glxMinor);
PUGL_LOGF("GLX Version %d.%d\n", glxMajor, glxMinor);

impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE);

Window xParent = parent
? (Window)parent
: RootWindow(impl->display, impl->screen);

Colormap cmap = XCreateColormap(
impl->display, xParent, vi->visual, AllocNone);

XSetWindowAttributes attr;
memset(&attr, 0, sizeof(XSetWindowAttributes));
attr.colormap = cmap;
attr.border_pixel = 0;

attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask
| ButtonPressMask | ButtonReleaseMask
#ifdef XKEYFOCUSGRAB
| EnterWindowMask
#endif
| PointerMotionMask | StructureNotifyMask;

impl->win = XCreateWindow(
impl->display, xParent,
0, 0, (unsigned int)view->width, (unsigned int)view->height, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr);

XSizeHints sizeHints;
memset(&sizeHints, 0, sizeof(sizeHints));
if (!resizable) {
sizeHints.flags = PMinSize|PMaxSize;
sizeHints.min_width = width;
sizeHints.min_height = height;
sizeHints.max_width = width;
sizeHints.max_height = height;
XSetNormalHints(impl->display, impl->win, &sizeHints);
}

if (title) {
XStoreName(impl->display, impl->win, title);
}

if (!parent) {
Atom wmDelete = XInternAtom(impl->display, "WM_DELETE_WINDOW", True);
XSetWMProtocols(impl->display, impl->win, &wmDelete, 1);
}

if (visible) {
XMapRaised(impl->display, impl->win);
}

if (glXIsDirect(impl->display, impl->ctx)) {
PUGL_LOG("DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1\n");
} else {
PUGL_LOG("No DRI available\n");
}

XFree(vi);

return view;
}

void
puglDestroy(PuglView* view)
{
if (!view) {
return;
}

glXDestroyContext(view->impl->display, view->impl->ctx);
XDestroyWindow(view->impl->display, view->impl->win);
XCloseDisplay(view->impl->display);
free(view->impl);
free(view);
}

static void
puglReshape(PuglView* view, int width, int height)
{
glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx);

if (view->reshapeFunc) {
view->reshapeFunc(view, width, height);
} else {
puglDefaultReshape(view, width, height);
}

view->width = width;
view->height = height;
}

static void
puglDisplay(PuglView* view)
{
glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

if (view->displayFunc) {
view->displayFunc(view);
}

glFlush();
if (view->impl->doubleBuffered) {
glXSwapBuffers(view->impl->display, view->impl->win);
}

view->redisplay = false;
}

static PuglKey
keySymToSpecial(KeySym sym)
{
switch (sym) {
case XK_F1: return PUGL_KEY_F1;
case XK_F2: return PUGL_KEY_F2;
case XK_F3: return PUGL_KEY_F3;
case XK_F4: return PUGL_KEY_F4;
case XK_F5: return PUGL_KEY_F5;
case XK_F6: return PUGL_KEY_F6;
case XK_F7: return PUGL_KEY_F7;
case XK_F8: return PUGL_KEY_F8;
case XK_F9: return PUGL_KEY_F9;
case XK_F10: return PUGL_KEY_F10;
case XK_F11: return PUGL_KEY_F11;
case XK_F12: return PUGL_KEY_F12;
case XK_Left: return PUGL_KEY_LEFT;
case XK_Up: return PUGL_KEY_UP;
case XK_Right: return PUGL_KEY_RIGHT;
case XK_Down: return PUGL_KEY_DOWN;
case XK_Page_Up: return PUGL_KEY_PAGE_UP;
case XK_Page_Down: return PUGL_KEY_PAGE_DOWN;
case XK_Home: return PUGL_KEY_HOME;
case XK_End: return PUGL_KEY_END;
case XK_Insert: return PUGL_KEY_INSERT;
case XK_Shift_L: return PUGL_KEY_SHIFT;
case XK_Shift_R: return PUGL_KEY_SHIFT;
case XK_Control_L: return PUGL_KEY_CTRL;
case XK_Control_R: return PUGL_KEY_CTRL;
case XK_Alt_L: return PUGL_KEY_ALT;
case XK_Alt_R: return PUGL_KEY_ALT;
case XK_Super_L: return PUGL_KEY_SUPER;
case XK_Super_R: return PUGL_KEY_SUPER;
}
return (PuglKey)0;
}

static void
setModifiers(PuglView* view, unsigned xstate, unsigned long xtime)
{
view->event_timestamp_ms = (uint32_t)xtime;

view->mods = 0;
view->mods |= (xstate & ShiftMask) ? PUGL_MOD_SHIFT : 0;
view->mods |= (xstate & ControlMask) ? PUGL_MOD_CTRL : 0;
view->mods |= (xstate & Mod1Mask) ? PUGL_MOD_ALT : 0;
view->mods |= (xstate & Mod4Mask) ? PUGL_MOD_SUPER : 0;
}

static void
dispatchKey(PuglView* view, XEvent* event, bool press)
{
KeySym sym;
char str[5];
const int n = XLookupString(&event->xkey, str, 4, &sym, NULL);
if (n == 0) {
return;
} else if (n > 1) {
fprintf(stderr, "warning: Unsupported multi-byte key %X\n", (int)sym);
return;
}

const PuglKey special = keySymToSpecial(sym);
if (special && view->specialFunc) {
view->specialFunc(view, press, special);
} else if (!special && view->keyboardFunc) {
view->keyboardFunc(view, press, (uint32_t)str[0]);
}
}

PuglStatus
puglProcessEvents(PuglView* view)
{
XEvent event;
while (XPending(view->impl->display) > 0) {
XNextEvent(view->impl->display, &event);
switch (event.type) {
case MapNotify:
puglReshape(view, view->width, view->height);
break;
case ConfigureNotify:
if ((event.xconfigure.width != view->width) ||
(event.xconfigure.height != view->height)) {
puglReshape(view,
event.xconfigure.width,
event.xconfigure.height);
}
break;
case Expose:
if (event.xexpose.count != 0) {
break;
}
puglDisplay(view);
break;
case MotionNotify:
setModifiers(view, event.xmotion.state, event.xmotion.time);
if (view->motionFunc) {
view->motionFunc(view, event.xmotion.x, event.xmotion.y);
}
break;
case ButtonPress:
setModifiers(view, event.xbutton.state, event.xbutton.time);
if (event.xbutton.button >= 4 && event.xbutton.button <= 7) {
if (view->scrollFunc) {
float dx = 0, dy = 0;
switch (event.xbutton.button) {
case 4: dy = 1.0f; break;
case 5: dy = -1.0f; break;
case 6: dx = -1.0f; break;
case 7: dx = 1.0f; break;
}
view->scrollFunc(view,
event.xbutton.x, event.xbutton.y,
dx, dy);
}
break;
}
// nobreak
case ButtonRelease:
setModifiers(view, event.xbutton.state, event.xbutton.time);
if (view->mouseFunc &&
(event.xbutton.button < 4 || event.xbutton.button > 7)) {
view->mouseFunc(view,
(int)event.xbutton.button, event.type == ButtonPress,
event.xbutton.x, event.xbutton.y);
}
break;
case KeyPress:
setModifiers(view, event.xkey.state, event.xkey.time);
dispatchKey(view, &event, true);
break;
case KeyRelease:
setModifiers(view, event.xkey.state, event.xkey.time);
if (view->ignoreKeyRepeat &&
XEventsQueued(view->impl->display, QueuedAfterReading)) {
XEvent next;
XPeekEvent(view->impl->display, &next);
if (next.type == KeyPress &&
next.xkey.time == event.xkey.time &&
next.xkey.keycode == event.xkey.keycode) {
XNextEvent(view->impl->display, &event);
break;
}
}
dispatchKey(view, &event, false);
break;
case ClientMessage:
if (!strcmp(XGetAtomName(view->impl->display,
event.xclient.message_type),
"WM_PROTOCOLS")) {
if (view->closeFunc) {
view->closeFunc(view);
}
}
break;
#ifdef PUGL_GRAB_FOCUS
case EnterNotify:
XSetInputFocus(view->impl->display,
view->impl->win,
RevertToPointerRoot,
CurrentTime);
break;
#endif
default:
break;
}
}

if (view->redisplay) {
puglDisplay(view);
}

return PUGL_SUCCESS;
}

void
puglPostRedisplay(PuglView* view)
{
view->redisplay = true;
}

PuglNativeWindow
puglGetNativeWindow(PuglView* view)
{
return (PuglNativeWindow)view->impl->win;
}

+ 269
- 0
libs/distrho/DistrhoPlugin.hpp View File

@@ -0,0 +1,269 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_PLUGIN_HPP_INCLUDED
#define DISTRHO_PLUGIN_HPP_INCLUDED

#include "DistrhoUtils.hpp"

#include <cmath>

#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Parameter Hints

const uint32_t PARAMETER_IS_AUTOMABLE = 1 << 0;
const uint32_t PARAMETER_IS_BOOLEAN = 1 << 1;
const uint32_t PARAMETER_IS_INTEGER = 1 << 2;
const uint32_t PARAMETER_IS_LOGARITHMIC = 1 << 3;
const uint32_t PARAMETER_IS_OUTPUT = 1 << 4;

// -----------------------------------------------------------------------
// Parameter Ranges

struct ParameterRanges {
float def;
float min;
float max;

ParameterRanges() noexcept
: def(0.0f),
min(0.0f),
max(1.0f) {}

ParameterRanges(float def, float min, float max) noexcept
{
this->def = def;
this->min = min;
this->max = max;
}

void clear() noexcept
{
def = 0.0f;
min = 0.0f;
max = 1.0f;
}

void fixValue(float& value) const noexcept
{
if (value < min)
value = min;
else if (value > max)
value = max;
}

float getFixedValue(const float& value) const noexcept
{
if (value < min)
return min;
else if (value > max)
return max;
return value;
}

float getNormalizedValue(const float& value) const noexcept
{
const float newValue((value - min) / (max - min));

if (newValue <= 0.0f)
return 0.0f;
if (newValue >= 1.0f)
return 1.0f;
return newValue;
}

float getUnnormalizedValue(const float& value) const noexcept
{
return value * (max - min) + min;
}
};

// -----------------------------------------------------------------------
// Parameter

struct Parameter {
uint32_t hints;
d_string name;
d_string symbol;
d_string unit;
ParameterRanges ranges;

Parameter()
: hints(0x0) {}

void clear() noexcept
{
hints = 0x0;
name = "";
symbol = "";
unit = "";
ranges.clear();
}
};

// -----------------------------------------------------------------------
// MidiEvent

struct MidiEvent {
uint32_t frame;
uint8_t size;
uint8_t buf[4];

void clear() noexcept
{
frame = 0;
size = 0;
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
}
};

// -----------------------------------------------------------------------
// TimePos

struct TimePos {
bool playing;
uint64_t frame;

struct BeatBarTick {
bool valid;

int32_t bar; /*!< current bar */
int32_t beat; /*!< current beat-within-bar */
int32_t tick; /*!< current tick-within-beat */
double barStartTick;

float beatsPerBar; /*!< time signature "numerator" */
float beatType; /*!< time signature "denominator" */

double ticksPerBeat;
double beatsPerMinute;

BeatBarTick() noexcept
: valid(false),
bar(0),
beat(0),
tick(0),
barStartTick(0.0),
beatsPerBar(0.0f),
beatType(0.0f),
ticksPerBeat(0.0),
beatsPerMinute(0.0) {}
} bbt;

TimePos() noexcept
: playing(false),
frame(0) {}
};

// -----------------------------------------------------------------------
// Plugin

class Plugin
{
public:
Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount);
virtual ~Plugin();

// -------------------------------------------------------------------
// Host state

uint32_t d_getBufferSize() const noexcept;
double d_getSampleRate() const noexcept;
#if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePos& d_getTimePos() const noexcept;
#endif
#if DISTRHO_PLUGIN_WANT_LATENCY
void d_setLatency(uint32_t frames) noexcept;
#endif

protected:
// -------------------------------------------------------------------
// Information

virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; }
virtual const char* d_getLabel() const noexcept = 0;
virtual const char* d_getMaker() const noexcept = 0;
virtual const char* d_getLicense() const noexcept = 0;
virtual uint32_t d_getVersion() const noexcept = 0;
virtual long d_getUniqueId() const noexcept = 0;

// -------------------------------------------------------------------
// Init

virtual void d_initParameter(uint32_t index, Parameter& parameter) = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_initProgramName(uint32_t index, d_string& programName) = 0;
#endif
#if DISTRHO_PLUGIN_WANT_STATE
virtual void d_initStateKey(uint32_t index, d_string& stateKey) = 0;
#endif

// -------------------------------------------------------------------
// Internal data

virtual float d_getParameterValue(uint32_t index) const = 0;
virtual void d_setParameterValue(uint32_t index, float value) = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_setProgram(uint32_t index) = 0;
#endif
#if DISTRHO_PLUGIN_WANT_STATE
virtual void d_setState(const char* key, const char* value) = 0;
#endif

// -------------------------------------------------------------------
// Process

virtual void d_activate() {}
virtual void d_deactivate() {}
#if DISTRHO_PLUGIN_IS_SYNTH
virtual void d_run(float** inputs, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) = 0;
#else
virtual void d_run(float** inputs, float** outputs, uint32_t frames) = 0;
#endif

// -------------------------------------------------------------------
// Callbacks (optional)

virtual void d_bufferSizeChanged(uint32_t newBufferSize);
virtual void d_sampleRateChanged(double newSampleRate);

// -------------------------------------------------------------------

private:
struct PrivateData;
PrivateData* const pData;
friend class PluginExporter;
};

// -----------------------------------------------------------------------
// Create plugin, entry point

extern Plugin* createPlugin();

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // DISTRHO_PLUGIN_HPP_INCLUDED

+ 26
- 0
libs/distrho/DistrhoPluginMain.cpp View File

@@ -0,0 +1,26 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "src/DistrhoPlugin.cpp"

#if (defined(DISTRHO_PLUGIN_TARGET_LADSPA) || defined(DISTRHO_PLUGIN_TARGET_DSSI))
# include "src/DistrhoPluginLADSPA+DSSI.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_LV2)
# include "src/DistrhoPluginLV2.cpp"
# include "src/DistrhoPluginLV2export.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_VST)
# include "src/DistrhoPluginVST.cpp"
#endif

+ 94
- 0
libs/distrho/DistrhoUI.hpp View File

@@ -0,0 +1,94 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_UI_HPP_INCLUDED
#define DISTRHO_UI_HPP_INCLUDED

#include "DistrhoUtils.hpp"

#include "../dgl/Widget.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// UI

class UI : public DGL::Widget
{
public:
UI();
virtual ~UI();

// -------------------------------------------------------------------
// Host DSP State

double d_getSampleRate() const noexcept;
void d_editParameter(uint32_t index, bool started);
void d_setParameterValue(uint32_t index, float value);
#if DISTRHO_PLUGIN_WANT_STATE
void d_setState(const char* key, const char* value);
#endif
#if DISTRHO_PLUGIN_IS_SYNTH
void d_sendNote(uint8_t channel, uint8_t note, uint8_t velocity);
#endif

// -------------------------------------------------------------------
// Host UI State

void d_uiResize(unsigned int width, unsigned int height);

protected:
// -------------------------------------------------------------------
// Basic Information

virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; }
virtual unsigned int d_getWidth() const noexcept = 0;
virtual unsigned int d_getHeight() const noexcept = 0;

// -------------------------------------------------------------------
// DSP Callbacks

virtual void d_parameterChanged(uint32_t index, float value) = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_programChanged(uint32_t index) = 0;
#endif
#if DISTRHO_PLUGIN_WANT_STATE
virtual void d_stateChanged(const char* key, const char* value) = 0;
#endif

// -------------------------------------------------------------------
// UI Callbacks (optional)

virtual void d_uiIdle() {}

// -------------------------------------------------------------------

private:
struct PrivateData;
PrivateData* const pData;
friend class UIExporter;
};

// -----------------------------------------------------------------------
// Create UI, entry point

extern UI* createUI();

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // DISTRHO_UI_HPP_INCLUDED

+ 25
- 0
libs/distrho/DistrhoUIMain.cpp View File

@@ -0,0 +1,25 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "src/DistrhoUI.cpp"

#if defined(DISTRHO_PLUGIN_TARGET_DSSI)
# include "src/DistrhoUIDSSI.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_LV2)
# include "src/DistrhoUILV2.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_VST)
// nothing
#endif

+ 684
- 0
libs/distrho/DistrhoUtils.hpp View File

@@ -0,0 +1,684 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_UTILS_HPP_INCLUDED
#define DISTRHO_UTILS_HPP_INCLUDED

#include "src/DistrhoDefines.h"

#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#ifdef PROPER_CPP11_SUPPORT
# include <cstdint>
#else
# include <stdint.h>
#endif

#ifdef DISTRHO_OS_WINDOWS
# include <windows.h>
#else
# include <unistd.h>
#endif

#if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC)
namespace std {
inline float
fmin(float __x, float __y)
{ return __builtin_fminf(__x, __y); }
inline float
fmax(float __x, float __y)
{ return __builtin_fmaxf(__x, __y); }
inline float
rint(float __x)
{ return __builtin_rintf(__x); }
}
#endif

// -----------------------------------------------------------------------
// misc functions

static inline
long d_cconst(int a, int b, int c, int d) noexcept
{
return (a << 24) | (b << 16) | (c << 8) | (d << 0);
}

// -----------------------------------------------------------------------
// string print functions

#ifndef DEBUG
# define d_debug(...)
#else
static inline
void d_debug(const char* const fmt, ...)
{
va_list args;
va_start(args, fmt);
std::fprintf(stdout, "\x1b[30;1m");
std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\x1b[0m\n");
va_end(args);
}
#endif

static inline
void d_stdout(const char* const fmt, ...)
{
va_list args;
va_start(args, fmt);
std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\n");
va_end(args);
}

static inline
void d_stderr(const char* const fmt, ...)
{
va_list args;
va_start(args, fmt);
std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\n");
va_end(args);
}

static inline
void d_stderr2(const char* const fmt, ...)
{
va_list args;
va_start(args, fmt);
std::fprintf(stderr, "\x1b[31m");
std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\x1b[0m\n");
va_end(args);
}

// -----------------------------------------------------------------------
// d_*sleep

static inline
void d_sleep(unsigned int secs)
{
#ifdef DISTRHO_OS_WINDOWS
Sleep(secs * 1000);
#else
sleep(secs);
#endif
}

static inline
void d_msleep(unsigned int msecs)
{
#ifdef DISTRHO_OS_WINDOWS
Sleep(msecs);
#else
usleep(msecs * 1000);
#endif
}

// -----------------------------------------------------------------------
// d_string class

class d_string
{
public:
// -------------------------------------------------------------------
// constructors (no explicit conversions allowed)

/*
* Empty string.
*/
explicit d_string()
{
_init();
_dup(nullptr);
}

/*
* Simple character.
*/
explicit d_string(const char c)
{
char ch[2];
ch[0] = c;
ch[1] = '\0';

_init();
_dup(ch);
}

/*
* Simple char string.
*/
explicit d_string(char* const strBuf)
{
_init();
_dup(strBuf);
}

/*
* Simple const char string.
*/
explicit d_string(const char* const strBuf)
{
_init();
_dup(strBuf);
}

/*
* Integer.
*/
explicit d_string(const int value)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%d", value);

_init();
_dup(strBuf);
}

/*
* Unsigned integer, possibly in hexadecimal.
*/
explicit d_string(const unsigned int value, const bool hexadecimal = false)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value);

_init();
_dup(strBuf);
}

/*
* Long integer.
*/
explicit d_string(const long int value)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%ld", value);

_init();
_dup(strBuf);
}

/*
* Long unsigned integer, possibly hexadecimal.
*/
explicit d_string(const unsigned long int value, const bool hexadecimal = false)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value);

_init();
_dup(strBuf);
}

/*
* Single-precision floating point number.
*/
explicit d_string(const float value)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%f", value);

_init();
_dup(strBuf);
}

/*
* Double-precision floating point number.
*/
explicit d_string(const double value)
{
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%g", value);

_init();
_dup(strBuf);
}

// -------------------------------------------------------------------
// non-explicit constructor

/*
* Create string from another string.
*/
d_string(const d_string& str)
{
_init();
_dup(str.fBuffer);
}

// -------------------------------------------------------------------
// destructor

/*
* Destructor.
*/
~d_string()
{
assert(fBuffer != nullptr);

delete[] fBuffer;
fBuffer = nullptr;
}

// -------------------------------------------------------------------
// public methods

/*
* Get length of the string.
*/
size_t length() const noexcept
{
return fBufferLen;
}

/*
* Check if the string is empty.
*/
bool isEmpty() const noexcept
{
return (fBufferLen == 0);
}

/*
* Check if the string is not empty.
*/
bool isNotEmpty() const noexcept
{
return (fBufferLen != 0);
}

/*
* Check if the string contains another string, optionally ignoring case.
*/
bool contains(const char* const strBuf, const bool ignoreCase = false) const
{
if (strBuf == nullptr)
return false;

if (ignoreCase)
{
#ifdef __USE_GNU
return (strcasestr(fBuffer, strBuf) != nullptr);
#else
d_string tmp1(fBuffer), tmp2(strBuf);
tmp1.toLower();
tmp2.toLower();
return (std::strstr((const char*)tmp1, (const char*)tmp2) != nullptr);
#endif
}

return (std::strstr(fBuffer, strBuf) != nullptr);
}

/*
* Overloaded function.
*/
bool contains(const d_string& str, const bool ignoreCase = false) const
{
return contains(str.fBuffer, ignoreCase);
}

/*
* Check if character at 'pos' is a digit.
*/
bool isDigit(const size_t pos) const noexcept
{
if (pos >= fBufferLen)
return false;

return (fBuffer[pos] >= '0' && fBuffer[pos] <= '9');
}

/*
* Check if the string starts with the character 'c'.
*/
bool startsWith(const char c) const
{
if (c == '\0')
return false;

return (fBufferLen > 0 && fBuffer[0] == c);
}

/*
* Check if the string starts with the string 'prefix'.
*/
bool startsWith(const char* const prefix) const
{
if (prefix == nullptr)
return false;

const size_t prefixLen(std::strlen(prefix));

if (fBufferLen < prefixLen)
return false;

return (std::strncmp(fBuffer + (fBufferLen-prefixLen), prefix, prefixLen) == 0);
}

/*
* Check if the string ends with the character 'c'.
*/
bool endsWith(const char c) const
{
if (c == '\0')
return false;

return (fBufferLen > 0 && fBuffer[fBufferLen] == c);
}

/*
* Check if the string ends with the string 'suffix'.
*/
bool endsWith(const char* const suffix) const
{
if (suffix == nullptr)
return false;

const size_t suffixLen(std::strlen(suffix));

if (fBufferLen < suffixLen)
return false;

return (std::strncmp(fBuffer + (fBufferLen-suffixLen), suffix, suffixLen) == 0);
}

/*
* Clear the string.
*/
void clear() noexcept
{
truncate(0);
}

/*
* Replace all occurrences of character 'before' with character 'after'.
*/
void replace(const char before, const char after) noexcept
{
if (before == '\0' || after == '\0')
return;

for (size_t i=0; i < fBufferLen; ++i)
{
if (fBuffer[i] == before)
fBuffer[i] = after;
else if (fBuffer[i] == '\0')
break;
}
}

/*
* Truncate the string to size 'n'.
*/
void truncate(const size_t n) noexcept
{
if (n >= fBufferLen)
return;

for (size_t i=n; i < fBufferLen; ++i)
fBuffer[i] = '\0';

fBufferLen = n;
}

/*
* Convert all non-basic characters to '_'.
*/
void toBasic() noexcept
{
for (size_t i=0; i < fBufferLen; ++i)
{
if (fBuffer[i] >= '0' && fBuffer[i] <= '9')
continue;
if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z')
continue;
if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z')
continue;
if (fBuffer[i] == '_')
continue;

fBuffer[i] = '_';
}
}

/*
* Convert to all ascii characters to lowercase.
*/
void toLower() noexcept
{
static const char kCharDiff('a' - 'A');

for (size_t i=0; i < fBufferLen; ++i)
{
if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z')
fBuffer[i] += kCharDiff;
}
}

/*
* Convert to all ascii characters to uppercase.
*/
void toUpper() noexcept
{
static const char kCharDiff('a' - 'A');

for (size_t i=0; i < fBufferLen; ++i)
{
if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z')
fBuffer[i] -= kCharDiff;
}
}

// -------------------------------------------------------------------
// public operators

operator const char*() const noexcept
{
return fBuffer;
}

char& operator[](const size_t pos) const noexcept
{
return fBuffer[pos];
}

bool operator==(const char* const strBuf) const
{
return (strBuf != nullptr && std::strcmp(fBuffer, strBuf) == 0);
}

bool operator==(const d_string& str) const
{
return operator==(str.fBuffer);
}

bool operator!=(const char* const strBuf) const
{
return !operator==(strBuf);
}

bool operator!=(const d_string& str) const
{
return !operator==(str.fBuffer);
}

d_string& operator=(const char* const strBuf)
{
_dup(strBuf);

return *this;
}

d_string& operator=(const d_string& str)
{
return operator=(str.fBuffer);
}

d_string& operator+=(const char* const strBuf)
{
if (strBuf == nullptr)
return *this;

const size_t newBufSize = fBufferLen + std::strlen(strBuf) + 1;
char newBuf[newBufSize];

std::strcpy(newBuf, fBuffer);
std::strcat(newBuf, strBuf);

_dup(newBuf, newBufSize-1);

return *this;
}

d_string& operator+=(const d_string& str)
{
return operator+=(str.fBuffer);
}

d_string operator+(const char* const strBuf)
{
const size_t newBufSize = fBufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
char newBuf[newBufSize];

std::strcpy(newBuf, fBuffer);

if (strBuf != nullptr)
std::strcat(newBuf, strBuf);

return d_string(newBuf);
}

d_string operator+(const d_string& str)
{
return operator+(str.fBuffer);
}

// -------------------------------------------------------------------

private:
char* fBuffer; // the actual string buffer
size_t fBufferLen; // string length
bool fFirstInit; // true when first initiated

/*
* Shared init function.
* Called on all constructors.
*/
void _init() noexcept
{
fBuffer = nullptr;
fBufferLen = 0;
fFirstInit = true;
}

/*
* Helper function.
* Called whenever the string needs to be allocated.
*
* Notes:
* - Allocates string only if first initiated, or if 'strBuf' is not null and new string contents are different
* - If 'strBuf' is null 'size' must be 0
*/
void _dup(const char* const strBuf, const size_t size = 0)
{
if (strBuf != nullptr)
{
// don't recreate string if contents match
if (fFirstInit || std::strcmp(fBuffer, strBuf) != 0)
{
if (! fFirstInit)
{
assert(fBuffer != nullptr);
delete[] fBuffer;
}

fBufferLen = (size > 0) ? size : std::strlen(strBuf);
fBuffer = new char[fBufferLen+1];

std::strcpy(fBuffer, strBuf);

fBuffer[fBufferLen] = '\0';

fFirstInit = false;
}
}
else
{
assert(size == 0);

// don't recreate null string
if (fFirstInit || fBufferLen != 0)
{
if (! fFirstInit)
{
assert(fBuffer != nullptr);
delete[] fBuffer;
}

fBufferLen = 0;
fBuffer = new char[1];
fBuffer[0] = '\0';

fFirstInit = false;
}
}
}
};

// -----------------------------------------------------------------------

static inline
d_string operator+(const d_string& strBefore, const char* const strBufAfter)
{
const char* const strBufBefore = (const char*)strBefore;
const size_t newBufSize = strBefore.length() + ((strBufAfter != nullptr) ? std::strlen(strBufAfter) : 0) + 1;
char newBuf[newBufSize];

std::strcpy(newBuf, strBufBefore);
std::strcat(newBuf, strBufAfter);

return d_string(newBuf);
}

static inline
d_string operator+(const char* const strBufBefore, const d_string& strAfter)
{
const char* const strBufAfter = (const char*)strAfter;
const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + strAfter.length() + 1;
char newBuf[newBufSize];

std::strcpy(newBuf, strBufBefore);
std::strcat(newBuf, strBufAfter);

return d_string(newBuf);
}

// -----------------------------------------------------------------------

#endif // DISTRHO_UTILS_HPP_INCLUDED

+ 114
- 0
libs/distrho/src/DistrhoDefines.h View File

@@ -0,0 +1,114 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_DEFINES_H_INCLUDED
#define DISTRHO_DEFINES_H_INCLUDED

#include "DistrhoPluginInfo.h"

#ifndef DISTRHO_PLUGIN_NAME
# error DISTRHO_PLUGIN_NAME undefined!
#endif

#ifndef DISTRHO_PLUGIN_HAS_UI
# error DISTRHO_PLUGIN_HAS_UI undefined!
#endif

#ifndef DISTRHO_PLUGIN_IS_SYNTH
# error DISTRHO_PLUGIN_IS_SYNTH undefined!
#endif

#ifndef DISTRHO_PLUGIN_NUM_INPUTS
# error DISTRHO_PLUGIN_NUM_INPUTS undefined!
#endif

#ifndef DISTRHO_PLUGIN_NUM_OUTPUTS
# error DISTRHO_PLUGIN_NUM_OUTPUTS undefined!
#endif

#ifndef DISTRHO_PLUGIN_WANT_LATENCY
# error DISTRHO_PLUGIN_WANT_LATENCY undefined!
#endif

#ifndef DISTRHO_PLUGIN_WANT_PROGRAMS
# error DISTRHO_PLUGIN_WANT_PROGRAMS undefined!
#endif

#ifndef DISTRHO_PLUGIN_WANT_STATE
# error DISTRHO_PLUGIN_WANT_STATE undefined!
#endif

#ifndef DISTRHO_PLUGIN_WANT_TIMEPOS
# error DISTRHO_PLUGIN_WANT_TIMEPOS undefined!
#endif

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport)
# define DISTRHO_OS_WINDOWS 1
# define DISTRHO_DLL_EXTENSION "dll"
#else
# define DISTRHO_PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default")))
# if defined(__APPLE__)
# define DISTRHO_OS_MAC 1
# define DISTRHO_DLL_EXTENSION "dylib"
# elif defined(__HAIKU__)
# define DISTRHO_OS_HAIKU 1
# define DISTRHO_DLL_EXTENSION "so"
# elif defined(__linux__)
# define DISTRHO_OS_LINUX 1
# define DISTRHO_DLL_EXTENSION "so"
# endif
#endif

#ifndef DISTRHO_DLL_EXTENSION
# define DISTRHO_DLL_EXTENSION "so"
#endif

#if defined(HAVE_CPP11_SUPPORT)
# define PROPER_CPP11_SUPPORT
#elif defined(__GNUC__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
# define PROPER_CPP11_SUPPORT
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
# define override // gcc4.7+ only
# endif
# endif
#endif

#ifndef PROPER_CPP11_SUPPORT
# ifndef __clang__
# define noexcept throw()
# endif
# define override
# define nullptr (0)
#endif

#ifndef DISTRHO_NO_NAMESPACE
# ifndef DISTRHO_NAMESPACE
# define DISTRHO_NAMESPACE DISTRHO
# endif
# define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
# define END_NAMESPACE_DISTRHO }
# define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
#else
# define START_NAMESPACE_DISTRHO
# define END_NAMESPACE_DISTRHO
# define USE_NAMESPACE_DISTRHO
#endif

#define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"

#endif // DISTRHO_DEFINES_H_INCLUDED

+ 107
- 0
libs/distrho/src/DistrhoPlugin.cpp View File

@@ -0,0 +1,107 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoPluginInternal.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Static data, see DistrhoPluginInternal.hpp

uint32_t d_lastBufferSize = 0;
double d_lastSampleRate = 0.0;

// -----------------------------------------------------------------------
// Static fallback data, see DistrhoPluginInternal.hpp

const d_string PluginExporter::sFallbackString;
const ParameterRanges PluginExporter::sFallbackRanges;

// -----------------------------------------------------------------------
// Plugin

Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)
: pData(new PrivateData())
{
if (parameterCount > 0)
{
pData->parameterCount = parameterCount;
pData->parameters = new Parameter[parameterCount];
}

if (programCount > 0)
{
#if DISTRHO_PLUGIN_WANT_PROGRAMS
pData->programCount = programCount;
pData->programNames = new d_string[programCount];
#endif
}

if (stateCount > 0)
{
#if DISTRHO_PLUGIN_WANT_STATE
pData->stateCount = stateCount;
pData->stateKeys = new d_string[stateCount];
#endif
}
}

Plugin::~Plugin()
{
delete pData;
}

// -----------------------------------------------------------------------
// Host state

uint32_t Plugin::d_getBufferSize() const noexcept
{
return pData->bufferSize;
}

double Plugin::d_getSampleRate() const noexcept
{
return pData->sampleRate;
}

#if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePos& Plugin::d_getTimePos() const noexcept
{
return pData->timePos;
}
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
void Plugin::d_setLatency(uint32_t frames) noexcept
{
pData->latency = frames;
}
#endif

// -----------------------------------------------------------------------
// Callbacks (optional)

void Plugin::d_bufferSizeChanged(uint32_t)
{
}

void Plugin::d_sampleRateChanged(double)
{
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 376
- 0
libs/distrho/src/DistrhoPluginInternal.hpp View File

@@ -0,0 +1,376 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED
#define DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED

#include "../DistrhoPlugin.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Maxmimum values

static const uint32_t kMaxMidiEvents = 512;

// -----------------------------------------------------------------------
// Static data, see DistrhoPlugin.cpp

extern uint32_t d_lastBufferSize;
extern double d_lastSampleRate;

// -----------------------------------------------------------------------
// Plugin private data

struct Plugin::PrivateData {
uint32_t parameterCount;
Parameter* parameters;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
uint32_t programCount;
d_string* programNames;
#endif

#if DISTRHO_PLUGIN_WANT_STATE
uint32_t stateCount;
d_string* stateKeys;
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
uint32_t latency;
#endif

#if DISTRHO_PLUGIN_WANT_TIMEPOS
TimePos timePos;
#endif

uint32_t bufferSize;
double sampleRate;

PrivateData() noexcept
: parameterCount(0),
parameters(nullptr),
#if DISTRHO_PLUGIN_WANT_PROGRAMS
programCount(0),
programNames(nullptr),
#endif
#if DISTRHO_PLUGIN_WANT_STATE
stateCount(0),
stateKeys(nullptr),
#endif
#if DISTRHO_PLUGIN_WANT_LATENCY
latency(0),
#endif
bufferSize(d_lastBufferSize),
sampleRate(d_lastSampleRate)
{
assert(bufferSize != 0);
assert(sampleRate != 0.0);
}

~PrivateData()
{
if (parameters != nullptr)
{
delete[] parameters;
parameters = nullptr;
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
if (programNames != nullptr)
{
delete[] programNames;
programNames = nullptr;
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
if (stateKeys != nullptr)
{
delete[] stateKeys;
stateKeys = nullptr;
}
#endif
}
};

// -----------------------------------------------------------------------
// Plugin exporter class

class PluginExporter
{
public:
PluginExporter()
: fPlugin(createPlugin()),
fData((fPlugin != nullptr) ? fPlugin->pData : nullptr)
{
assert(fPlugin != nullptr);

if (fPlugin == nullptr)
return;

for (uint32_t i=0, count=fData->parameterCount; i < count; ++i)
fPlugin->d_initParameter(i, fData->parameters[i]);

#if DISTRHO_PLUGIN_WANT_PROGRAMS
for (uint32_t i=0, count=fData->programCount; i < count; ++i)
fPlugin->d_initProgramName(i, fData->programNames[i]);
#endif

#if DISTRHO_PLUGIN_WANT_STATE
for (uint32_t i=0, count=fData->stateCount; i < count; ++i)
fPlugin->d_initStateKey(i, fData->stateKeys[i]);
#endif
}

~PluginExporter()
{
delete fPlugin;
}

// -------------------------------------------------------------------

const char* getName() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getName() : "";
}

const char* getLabel() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getLabel() : "";
}

const char* getMaker() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getMaker() : "";
}

const char* getLicense() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getLicense() : "";
}

uint32_t getVersion() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getVersion() : 1000;
}

long getUniqueId() const noexcept
{
return (fPlugin != nullptr) ? fPlugin->d_getUniqueId() : 0;
}

// -------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_LATENCY
uint32_t getLatency() const noexcept
{
return (fData != nullptr) ? fData->latency : 0;
}
#endif

uint32_t getParameterCount() const noexcept
{
return (fData != nullptr) ? fData->parameterCount : 0;
}

uint32_t getParameterHints(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].hints : 0x0;
}

bool isParameterOutput(const uint32_t index) const noexcept
{
return (getParameterHints(index) & PARAMETER_IS_OUTPUT);
}

const d_string& getParameterName(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].name : sFallbackString;
}

const d_string& getParameterSymbol(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].symbol : sFallbackString;
}

const d_string& getParameterUnit(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].unit : sFallbackString;
}

const ParameterRanges& getParameterRanges(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].ranges : sFallbackRanges;
}

float getParameterValue(const uint32_t index) const noexcept
{
assert(index < fData->parameterCount);
return (fPlugin != nullptr && index < fData->parameterCount) ? fPlugin->d_getParameterValue(index) : 0.0f;
}

void setParameterValue(const uint32_t index, const float value)
{
assert(index < fData->parameterCount);

if (fPlugin != nullptr && index < fData->parameterCount)
fPlugin->d_setParameterValue(index, value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
uint32_t getProgramCount() const noexcept
{
return (fData != nullptr) ? fData->programCount : 0;
}

const d_string& getProgramName(const uint32_t index) const noexcept
{
assert(index < fData->programCount);
return (fData != nullptr && index < fData->programCount) ? fData->programNames[index] : sFallbackString;
}

void setProgram(const uint32_t index)
{
assert(index < fData->programCount);

if (fPlugin != nullptr && index < fData->programCount)
fPlugin->d_setProgram(index);
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
uint32_t getStateCount() const noexcept
{
return fData != nullptr ? fData->stateCount : 0;
}

const d_string& getStateKey(const uint32_t index) const noexcept
{
assert(index < fData->stateCount);
return (fData != nullptr && index < fData->stateCount) ? fData->stateKeys[index] : sFallbackString;
}

void setState(const char* const key, const char* const value)
{
assert(key != nullptr && value != nullptr);

if (fPlugin != nullptr && key != nullptr && value != nullptr)
fPlugin->d_setState(key, value);
}
#endif

#if DISTRHO_PLUGIN_WANT_TIMEPOS
void setTimePos(const TimePos& timePos)
{
if (fData != nullptr)
std::memcpy(&fData->timePos, &timePos, sizeof(TimePos));
}
#endif

// -------------------------------------------------------------------

void activate()
{
if (fPlugin != nullptr)
fPlugin->d_activate();
}

void deactivate()
{
if (fPlugin != nullptr)
fPlugin->d_deactivate();
}

#if DISTRHO_PLUGIN_IS_SYNTH
void run(float** const inputs, float** const outputs, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount)
{
if (fPlugin != nullptr)
fPlugin->d_run(inputs, outputs, frames, midiEvents, midiEventCount);
}
#else
void run(float** const inputs, float** const outputs, const uint32_t frames)
{
if (fPlugin != nullptr)
fPlugin->d_run(inputs, outputs, frames);
}
#endif
// -------------------------------------------------------------------

void setBufferSize(const uint32_t bufferSize, bool doCallback = false)
{
assert(bufferSize >= 2);

if (fData != nullptr)
{
if (doCallback && fData->bufferSize == bufferSize)
doCallback = false;

fData->bufferSize = bufferSize;
}

if (fPlugin != nullptr && doCallback)
{
fPlugin->d_deactivate();
fPlugin->d_bufferSizeChanged(bufferSize);
fPlugin->d_activate();
}
}

void setSampleRate(const double sampleRate, bool doCallback = false)
{
assert(sampleRate > 0.0);

if (fData != nullptr)
{
if (doCallback && fData->sampleRate == sampleRate)
doCallback = false;

fData->sampleRate = sampleRate;
}

if (fPlugin != nullptr && doCallback)
{
fPlugin->d_deactivate();
fPlugin->d_sampleRateChanged(sampleRate);
fPlugin->d_activate();
}
}

private:
// -------------------------------------------------------------------
// private members accessed by DistrhoPlugin class

Plugin* const fPlugin;
Plugin::PrivateData* const fData;

// -------------------------------------------------------------------
// Static fallback data, see DistrhoPlugin.cpp

static const d_string sFallbackString;
static const ParameterRanges sFallbackRanges;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED

+ 702
- 0
libs/distrho/src/DistrhoPluginLADSPA+DSSI.cpp View File

@@ -0,0 +1,702 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoPluginInternal.hpp"

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
# include "dssi/dssi.h"
#else
# include "ladspa/ladspa.h"
# if DISTRHO_PLUGIN_IS_SYNTH
# error Cannot build synth plugin with LADSPA
# endif
# if DISTRHO_PLUGIN_WANT_STATE
# warning LADSPA cannot handle states
# endif
#endif

#if DISTRHO_PLUGIN_WANT_TIMEPOS
# warning LADSPA/DSSI does not support TimePos
#endif

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class PluginLadspaDssi
{
public:
PluginLadspaDssi()
: fPortControls(nullptr),
fLastControlValues(nullptr)
{
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i)
fPortAudioIns[i] = nullptr;
#else
fPortAudioIns = nullptr;
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
fPortAudioOuts[i] = nullptr;
#else
fPortAudioOuts = nullptr;
#endif

{
const uint32_t count(fPlugin.getParameterCount());

fPortControls = new LADSPA_Data*[count];
fLastControlValues = new LADSPA_Data[count];

for (uint32_t i=0; i < count; ++i)
{
fPortControls[i] = nullptr;
fLastControlValues[i] = fPlugin.getParameterValue(i);
}
}

#if DISTRHO_PLUGIN_WANT_LATENCY
fPortLatency = nullptr;
#endif
}

~PluginLadspaDssi()
{
if (fPortControls != nullptr)
{
delete[] fPortControls;
fPortControls = nullptr;
}

if (fLastControlValues)
{
delete[] fLastControlValues;
fLastControlValues = nullptr;
}
}

// -------------------------------------------------------------------

void ladspa_activate()
{
fPlugin.activate();
}

void ladspa_deactivate()
{
fPlugin.deactivate();
}

// -------------------------------------------------------------------

void ladspa_connect_port(const unsigned long port, LADSPA_Data* const dataLocation)
{
unsigned long index = 0;

#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i)
{
if (port == index++)
{
fPortAudioIns[i] = dataLocation;
return;
}
}
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
{
if (port == index++)
{
fPortAudioOuts[i] = dataLocation;
return;
}
}
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
if (port == index++)
{
fPortLatency = dataLocation;
return;
}
#endif

for (unsigned long i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (port == index++)
{
fPortControls[i] = dataLocation;
return;
}
}
}

// -------------------------------------------------------------------

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
void ladspa_run(const unsigned long sampleCount)
{
dssi_run_synth(sampleCount, nullptr, 0);
}

void dssi_run_synth(const unsigned long sampleCount, snd_seq_event_t* const events, const unsigned long eventCount)
#else
void ladspa_run(const unsigned long sampleCount)
#endif
{
// pre-roll
if (sampleCount == 0)
return updateParameterOutputs();

// Check for updated parameters
float curValue;

for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (fPortControls[i] == nullptr)
continue;

curValue = *fPortControls[i];

if (fLastControlValues[i] != curValue && ! fPlugin.isParameterOutput(i))
{
fLastControlValues[i] = curValue;
fPlugin.setParameterValue(i, curValue);
}
}

#if DISTRHO_PLUGIN_IS_SYNTH
// Get MIDI Events
uint32_t midiEventCount = 0;
MidiEvent midiEvents[eventCount];

for (uint32_t i=0, j; i < eventCount; ++i)
{
const snd_seq_event_t& seqEvent(events[i]);

if (seqEvent.data.note.channel > 0xF || seqEvent.data.control.channel > 0xF)
continue;

switch (seqEvent.type)
{
case SND_SEQ_EVENT_NOTEOFF:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 3;
midiEvents[j].buf[0] = 0x80 + seqEvent.data.note.channel;
midiEvents[j].buf[1] = seqEvent.data.note.note;
midiEvents[j].buf[2] = 0;
midiEvents[j].buf[3] = 0;
break;
case SND_SEQ_EVENT_NOTEON:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 3;
midiEvents[j].buf[0] = 0x90 + seqEvent.data.note.channel;
midiEvents[j].buf[1] = seqEvent.data.note.note;
midiEvents[j].buf[2] = seqEvent.data.note.velocity;
midiEvents[j].buf[3] = 0;
break;
case SND_SEQ_EVENT_KEYPRESS:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 3;
midiEvents[j].buf[0] = 0xA0 + seqEvent.data.note.channel;
midiEvents[j].buf[1] = seqEvent.data.note.note;
midiEvents[j].buf[2] = seqEvent.data.note.velocity;
midiEvents[j].buf[3] = 0;
break;
case SND_SEQ_EVENT_CONTROLLER:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 3;
midiEvents[j].buf[0] = 0xB0 + seqEvent.data.control.channel;
midiEvents[j].buf[1] = seqEvent.data.control.param;
midiEvents[j].buf[2] = seqEvent.data.control.value;
midiEvents[j].buf[3] = 0;
break;
case SND_SEQ_EVENT_CHANPRESS:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 2;
midiEvents[j].buf[0] = 0xD0 + seqEvent.data.control.channel;
midiEvents[j].buf[1] = seqEvent.data.control.value;
midiEvents[j].buf[2] = 0;
midiEvents[j].buf[3] = 0;
break;
#if 0 // TODO
case SND_SEQ_EVENT_PITCHBEND:
j = midiEventCount++;
midiEvents[j].frame = seqEvent.time.tick;
midiEvents[j].size = 3;
midiEvents[j].buf[0] = 0xE0 + seqEvent.data.control.channel;
midiEvents[j].buf[1] = 0;
midiEvents[j].buf[2] = 0;
midiEvents[j].buf[3] = 0;
break;
#endif
}
}

fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount, midiEvents, midiEventCount);
#else
fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount);
#endif

updateParameterOutputs();

#if defined(DISTRHO_PLUGIN_TARGET_DSSI) && ! DISTRHO_PLUGIN_IS_SYNTH
return; // unused
(void)events;
(void)eventCount;
#endif
}

// -------------------------------------------------------------------

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
# if DISTRHO_PLUGIN_WANT_STATE
char* dssi_configure(const char* const key, const char* const value)
{
if (std::strncmp(key, DSSI_RESERVED_CONFIGURE_PREFIX, std::strlen(DSSI_RESERVED_CONFIGURE_PREFIX) == 0))
return nullptr;
if (std::strncmp(key, DSSI_GLOBAL_CONFIGURE_PREFIX, std::strlen(DSSI_GLOBAL_CONFIGURE_PREFIX) == 0))
return nullptr;

fPlugin.setState(key, value);
return nullptr;
}
# endif

# if DISTRHO_PLUGIN_WANT_PROGRAMS
const DSSI_Program_Descriptor* dssi_get_program(const unsigned long index)
{
if (index >= fPlugin.getProgramCount())
return nullptr;

static DSSI_Program_Descriptor desc;

desc.Bank = index / 128;
desc.Program = index % 128;
desc.Name = fPlugin.getProgramName(index);

return &desc;
}

void dssi_select_program(const unsigned long bank, const unsigned long program)
{
const unsigned long realProgram(bank * 128 + program);

if (realProgram >= fPlugin.getProgramCount())
return;

fPlugin.setProgram(realProgram);

// Update control inputs
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (fPlugin.isParameterOutput(i))
continue;

fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}
}
# endif
#endif

// -------------------------------------------------------------------

private:
PluginExporter fPlugin;

// LADSPA ports
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
LADSPA_Data* fPortAudioIns[DISTRHO_PLUGIN_NUM_INPUTS];
#else
LADSPA_Data** fPortAudioIns;
#endif
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
LADSPA_Data* fPortAudioOuts[DISTRHO_PLUGIN_NUM_OUTPUTS];
#else
LADSPA_Data** fPortAudioOuts;
#endif
LADSPA_Data** fPortControls;
#if DISTRHO_PLUGIN_WANT_LATENCY
LADSPA_Data* fPortLatency;
#endif

// Temporary data
LADSPA_Data* fLastControlValues;

// -------------------------------------------------------------------

void updateParameterOutputs()
{
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (! fPlugin.isParameterOutput(i))
continue;

fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}

#if DISTRHO_PLUGIN_WANT_LATENCY
if (fPortLatency != nullptr)
*fPortLatency = fPlugin.getLatency();
#endif
}
};

// -----------------------------------------------------------------------

static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate)
{
if (d_lastBufferSize == 0)
d_lastBufferSize = 2048;
d_lastSampleRate = sampleRate;

return new PluginLadspaDssi();
}

#define instancePtr ((PluginLadspaDssi*)instance)

static void ladspa_connect_port(LADSPA_Handle instance, unsigned long port, LADSPA_Data* dataLocation)
{
instancePtr->ladspa_connect_port(port, dataLocation);
}

static void ladspa_activate(LADSPA_Handle instance)
{
instancePtr->ladspa_activate();
}

static void ladspa_run(LADSPA_Handle instance, unsigned long sampleCount)
{
instancePtr->ladspa_run(sampleCount);
}

static void ladspa_deactivate(LADSPA_Handle instance)
{
instancePtr->ladspa_deactivate();
}

static void ladspa_cleanup(LADSPA_Handle instance)
{
delete instancePtr;
}

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
# if DISTRHO_PLUGIN_WANT_STATE
static char* dssi_configure(LADSPA_Handle instance, const char* key, const char* value)
{
return instancePtr->dssi_configure(key, value);
}
# endif

# if DISTRHO_PLUGIN_WANT_PROGRAMS
static const DSSI_Program_Descriptor* dssi_get_program(LADSPA_Handle instance, unsigned long index)
{
return instancePtr->dssi_get_program(index);
}

static void dssi_select_program(LADSPA_Handle instance, unsigned long bank, unsigned long program)
{
instancePtr->dssi_select_program(bank, program);
}
# endif

# if DISTRHO_PLUGIN_IS_SYNTH
static void dssi_run_synth(LADSPA_Handle instance, unsigned long sampleCount, snd_seq_event_t* events, unsigned long eventCount)
{
instancePtr->dssi_run_synth(sampleCount, events, eventCount);
}
# endif
#endif

#undef instancePtr

// -----------------------------------------------------------------------

static LADSPA_Descriptor sLadspaDescriptor = {
/* UniqueID */ 0,
/* Label */ nullptr,
/* Properties */ LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE,
/* Name */ nullptr,
/* Maker */ nullptr,
/* Copyright */ nullptr,
/* PortCount */ 0,
/* PortDescriptors */ nullptr,
/* PortNames */ nullptr,
/* PortRangeHints */ nullptr,
/* ImplementationData */ nullptr,
ladspa_instantiate,
ladspa_connect_port,
ladspa_activate,
ladspa_run,
/* run_adding */ nullptr,
/* set_run_adding_gain */ nullptr,
ladspa_deactivate,
ladspa_cleanup
};

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
static DSSI_Descriptor sDssiDescriptor = {
1,
&sLadspaDescriptor,
# if DISTRHO_PLUGIN_WANT_STATE
dssi_configure,
# else
/* configure */ nullptr,
# endif
# if DISTRHO_PLUGIN_WANT_PROGRAMS
dssi_get_program,
dssi_select_program,
# else
/* get_program */ nullptr,
/* select_program */ nullptr,
# endif
/* get_midi_controller_for_port */ nullptr,
# if DISTRHO_PLUGIN_IS_SYNTH
dssi_run_synth,
# else
/* run_synth */ nullptr,
# endif
/* run_synth_adding */ nullptr,
/* run_multiple_synths */ nullptr,
/* run_multiple_synths_adding */ nullptr,
nullptr, nullptr
};
#endif

// -----------------------------------------------------------------------

class DescriptorInitializer
{
public:
DescriptorInitializer()
{
// Create dummy plugin to get data from
d_lastBufferSize = 512;
d_lastSampleRate = 44100.0;
PluginExporter plugin;
d_lastBufferSize = 0;
d_lastSampleRate = 0.0;

// Get port count, init
unsigned long port = 0;
unsigned long portCount = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS + plugin.getParameterCount();
#if DISTRHO_PLUGIN_WANT_LATENCY
portCount += 1;
#endif
const char** const portNames = new const char*[portCount];
LADSPA_PortDescriptor* portDescriptors = new LADSPA_PortDescriptor[portCount];
LADSPA_PortRangeHint* portRangeHints = new LADSPA_PortRangeHint [portCount];

// Set ports
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i, ++port)
{
char portName[24] = { '\0' };
std::sprintf(portName, "Audio Input %lu", i+1);

portNames[port] = strdup(portName);
portDescriptors[port] = LADSPA_PORT_AUDIO | LADSPA_PORT_INPUT;

portRangeHints[port].HintDescriptor = 0x0;
portRangeHints[port].LowerBound = 0.0f;
portRangeHints[port].UpperBound = 1.0f;
}
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i, ++port)
{
char portName[24] = { '\0' };
std::sprintf(portName, "Audio Output %lu", i+1);

portNames[port] = strdup(portName);
portDescriptors[port] = LADSPA_PORT_AUDIO | LADSPA_PORT_OUTPUT;

portRangeHints[port].HintDescriptor = 0x0;
portRangeHints[port].LowerBound = 0.0f;
portRangeHints[port].UpperBound = 1.0f;
}
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
// Set latency port
portNames[port] = strdup("_latency");
portDescriptors[port] = LADSPA_PORT_CONTROL | LADSPA_PORT_OUTPUT;
portRangeHints[port].HintDescriptor = LADSPA_HINT_SAMPLE_RATE;
portRangeHints[port].LowerBound = 0.0f;
portRangeHints[port].UpperBound = 1.0f;
++port;
#endif

for (unsigned long i=0, count=plugin.getParameterCount(); i < count; ++i, ++port)
{
portNames[port] = strdup((const char*)plugin.getParameterName(i));
portDescriptors[port] = LADSPA_PORT_CONTROL;

if (plugin.isParameterOutput(i))
portDescriptors[port] |= LADSPA_PORT_OUTPUT;
else
portDescriptors[port] |= LADSPA_PORT_INPUT;

{
const ParameterRanges& ranges(plugin.getParameterRanges(i));
const float defValue(ranges.def);

portRangeHints[port].HintDescriptor = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE;
portRangeHints[port].LowerBound = ranges.min;
portRangeHints[port].UpperBound = ranges.max;

if (defValue == 0.0f)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_0;
else if (defValue == 1.0f)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_1;
else if (defValue == 100.0f)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_100;
else if (defValue == 440.0f)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_440;
else if (ranges.min == defValue)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_MINIMUM;
else if (ranges.max == defValue)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_MAXIMUM;
else
{
const float middleValue = ranges.min/2.0f + ranges.max/2.0f;
const float middleLow = (ranges.min/2.0f + middleValue/2.0f)/2.0f + middleValue/2.0f;
const float middleHigh = (ranges.max/2.0f + middleValue/2.0f)/2.0f + middleValue/2.0f;

if (defValue < middleLow)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_LOW;
else if (defValue > middleHigh)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_HIGH;
else
portRangeHints[port].HintDescriptor |= LADSPA_HINT_DEFAULT_MIDDLE;
}
}

{
const uint32_t hints(plugin.getParameterHints(i));

if (hints & PARAMETER_IS_BOOLEAN)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_TOGGLED;
if (hints & PARAMETER_IS_INTEGER)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_INTEGER;
if (hints & PARAMETER_IS_LOGARITHMIC)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_LOGARITHMIC;
}
}

// Set data
sLadspaDescriptor.UniqueID = plugin.getUniqueId();
sLadspaDescriptor.Label = strdup(plugin.getLabel());
sLadspaDescriptor.Name = strdup(plugin.getName());
sLadspaDescriptor.Maker = strdup(plugin.getMaker());
sLadspaDescriptor.Copyright = strdup(plugin.getLicense());
sLadspaDescriptor.PortCount = portCount;
sLadspaDescriptor.PortNames = portNames;
sLadspaDescriptor.PortDescriptors = portDescriptors;
sLadspaDescriptor.PortRangeHints = portRangeHints;
}

~DescriptorInitializer()
{
if (sLadspaDescriptor.Label != nullptr)
{
std::free((void*)sLadspaDescriptor.Label);
sLadspaDescriptor.Label = nullptr;
}

if (sLadspaDescriptor.Name != nullptr)
{
std::free((void*)sLadspaDescriptor.Name);
sLadspaDescriptor.Name = nullptr;
}

if (sLadspaDescriptor.Maker != nullptr)
{
std::free((void*)sLadspaDescriptor.Maker);
sLadspaDescriptor.Maker = nullptr;
}

if (sLadspaDescriptor.Copyright != nullptr)
{
std::free((void*)sLadspaDescriptor.Copyright);
sLadspaDescriptor.Copyright = nullptr;
}

if (sLadspaDescriptor.PortDescriptors != nullptr)
{
delete[] sLadspaDescriptor.PortDescriptors;
sLadspaDescriptor.PortDescriptors = nullptr;
}

if (sLadspaDescriptor.PortRangeHints != nullptr)
{
delete[] sLadspaDescriptor.PortRangeHints;
sLadspaDescriptor.PortRangeHints = nullptr;
}

if (sLadspaDescriptor.PortNames != nullptr)
{
for (unsigned long i=0; i < sLadspaDescriptor.PortCount; ++i)
{
if (sLadspaDescriptor.PortNames[i] != nullptr)
std::free((void*)sLadspaDescriptor.PortNames[i]);
}

delete[] sLadspaDescriptor.PortNames;
sLadspaDescriptor.PortNames = nullptr;
}
}
};

static DescriptorInitializer sDescInit;

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

DISTRHO_PLUGIN_EXPORT
const LADSPA_Descriptor* ladspa_descriptor(unsigned long index)
{
USE_NAMESPACE_DISTRHO
return (index == 0) ? &sLadspaDescriptor : nullptr;
}

#ifdef DISTRHO_PLUGIN_TARGET_DSSI
DISTRHO_PLUGIN_EXPORT
const DSSI_Descriptor* dssi_descriptor(unsigned long index)
{
USE_NAMESPACE_DISTRHO
return (index == 0) ? &sDssiDescriptor : nullptr;
}
#endif

// -----------------------------------------------------------------------

+ 876
- 0
libs/distrho/src/DistrhoPluginLV2.cpp View File

@@ -0,0 +1,876 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoPluginInternal.hpp"

#include "lv2/atom.h"
#include "lv2/atom-util.h"
#include "lv2/buf-size.h"
#include "lv2/midi.h"
#include "lv2/options.h"
#include "lv2/state.h"
#include "lv2/time.h"
#include "lv2/urid.h"
#include "lv2/worker.h"
#include "lv2/lv2_programs.h"

#ifdef noexcept
# undef noexcept
#endif

#include <map>

#ifndef DISTRHO_PLUGIN_URI
# error DISTRHO_PLUGIN_URI undefined!
#endif

#if DISTRHO_PLUGIN_WANT_STATE
# warning LV2 State still TODO (working but needs final testing)
#endif
#if DISTRHO_PLUGIN_WANT_TIMEPOS
# warning LV2 TimePos still TODO
#endif

#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_TIMEPOS || (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI))
#define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI)

typedef std::map<d_string,d_string> StringMap;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class PluginLv2
{
public:
PluginLv2(const LV2_URID_Map* const uridMap, const LV2_Worker_Schedule* const worker)
: fPortControls(nullptr),
fLastControlValues(nullptr),
#if DISTRHO_LV2_USE_EVENTS_IN || DISTRHO_LV2_USE_EVENTS_OUT
# if DISTRHO_PLUGIN_WANT_TIMEPOS
fLastTimeSpeed(0.0f),
# endif
fURIDs(uridMap),
#endif
fUridMap(uridMap),
fWorker(worker)
{
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i)
fPortAudioIns[i] = nullptr;
#else
fPortAudioIns = nullptr;
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
fPortAudioOuts[i] = nullptr;
#else
fPortAudioOuts = nullptr;
#endif

if (const uint32_t count = fPlugin.getParameterCount())
{
fPortControls = new float*[count];
fLastControlValues = new float[count];

for (uint32_t i=0; i < count; ++i)
{
fPortControls[i] = nullptr;
fLastControlValues[i] = fPlugin.getParameterValue(i);
}
}
else
{
fPortControls = nullptr;
fLastControlValues = nullptr;
}

#if DISTRHO_LV2_USE_EVENTS_IN
fPortEventsIn = nullptr;
#endif
#if DISTRHO_LV2_USE_EVENTS_OUT
fPortEventsOut = nullptr;
#endif
#if DISTRHO_PLUGIN_WANT_LATENCY
fPortLatency = nullptr;
#endif
}

~PluginLv2()
{
if (fPortControls != nullptr)
{
delete[] fPortControls;
fPortControls = nullptr;
}

if (fLastControlValues)
{
delete[] fLastControlValues;
fLastControlValues = nullptr;
}

#if DISTRHO_PLUGIN_WANT_STATE
fStateMap.clear();
#endif
}

// -------------------------------------------------------------------

void lv2_activate()
{
fPlugin.activate();
}

void lv2_deactivate()
{
fPlugin.deactivate();
}

// -------------------------------------------------------------------

void lv2_connect_port(const uint32_t port, void* const dataLocation)
{
uint32_t index = 0;

#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i)
{
if (port == index++)
{
fPortAudioIns[i] = (float*)dataLocation;
return;
}
}
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
{
if (port == index++)
{
fPortAudioOuts[i] = (float*)dataLocation;
return;
}
}
#endif

#if DISTRHO_LV2_USE_EVENTS_IN
if (port == index++)
{
fPortEventsIn = (LV2_Atom_Sequence*)dataLocation;
return;
}
#endif

#if DISTRHO_LV2_USE_EVENTS_OUT
if (port == index++)
{
fPortEventsOut = (LV2_Atom_Sequence*)dataLocation;
return;
}
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
if (port == index++)
{
fPortLatency = (float*)dataLocation;
return;
}
#endif

for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (port == index++)
{
fPortControls[i] = (float*)dataLocation;
return;
}
}
}

// -------------------------------------------------------------------

void lv2_run(const uint32_t sampleCount)
{
// pre-roll
if (sampleCount == 0)
return updateParameterOutputs();

// Check for updated parameters
float curValue;

for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (fPortControls[i] == nullptr)
continue;

curValue = *fPortControls[i];

if (fLastControlValues[i] != curValue && ! fPlugin.isParameterOutput(i))
{
fLastControlValues[i] = curValue;
fPlugin.setParameterValue(i, curValue);
}
}

#if DISTRHO_LV2_USE_EVENTS_IN
# if DISTRHO_PLUGIN_IS_SYNTH
uint32_t midiEventCount = 0;
# endif
# if DISTRHO_PLUGIN_WANT_TIMEPOS
bool needsFrameIncrement = true;
# endif
LV2_ATOM_SEQUENCE_FOREACH(fPortEventsIn, event)
{
if (event == nullptr)
break;

# if DISTRHO_PLUGIN_IS_SYNTH
if (event->body.type == fURIDs.midiEvent)
{
if (event->body.size > 4 || midiEventCount >= kMaxMidiEvents)
continue;

const uint8_t* const data((const uint8_t*)(event + 1));

MidiEvent& midiEvent(fMidiEvents[midiEventCount]);

midiEvent.frame = event->time.frames;
midiEvent.size = event->body.size;

uint8_t i;
for (i=0; i < midiEvent.size; ++i)
midiEvent.buf[i] = data[i];
for (; i < 4; ++i)
midiEvent.buf[i] = 0;

++midiEventCount;
continue;
}
# endif
# if DISTRHO_PLUGIN_WANT_TIMEPOS
if (event->body.type == fURIDs.atomBlank)
{
const LV2_Atom_Object* const obj((const LV2_Atom_Object*)&event->body);

if (obj->body.otype != fURIDs.timePosition)
continue;

LV2_Atom* bar = nullptr;
LV2_Atom* barBeat = nullptr;
LV2_Atom* beat = nullptr;
LV2_Atom* beatUnit = nullptr;
LV2_Atom* beatsPerBar = nullptr;
LV2_Atom* beatsPerMinute = nullptr;
LV2_Atom* frame = nullptr;
LV2_Atom* speed = nullptr;

lv2_atom_object_get(obj,
fURIDs.timeBar, &bar,
fURIDs.timeBarBeat, &barBeat,
fURIDs.timeBeat, &beat,
fURIDs.timeBeatUnit, &beatUnit,
fURIDs.timeBeatsPerBar, &beatsPerBar,
fURIDs.timeBeatsPerMinute, &beatsPerMinute,
fURIDs.timeFrame, &frame,
fURIDs.timeSpeed, &speed,
nullptr);

// TODO:
// - tick
// - barStartTick
// - ticksPerBeat

if (bar != nullptr)
{
if (bar->type == fURIDs.atomDouble)
fTimePos.bbt.bar = ((LV2_Atom_Double*)bar)->body + 1.0f;
else if (bar->type == fURIDs.atomFloat)
fTimePos.bbt.bar = ((LV2_Atom_Float*)bar)->body + 1.0f;
else if (bar->type == fURIDs.atomInt)
fTimePos.bbt.bar = ((LV2_Atom_Int*)bar)->body + 1;
else if (bar->type == fURIDs.atomLong)
fTimePos.bbt.bar = ((LV2_Atom_Long*)bar)->body + 1;
}

/*if (barBeat != nullptr && barBeat->type == fURIDs.atomFloat)
{
}*/

if (beat != nullptr)
{
if (beat->type == fURIDs.atomDouble)
fTimePos.bbt.beat = ((LV2_Atom_Double*)beat)->body + 1.0f;
else if (beat->type == fURIDs.atomFloat)
fTimePos.bbt.beat = ((LV2_Atom_Float*)beat)->body + 1.0f;
else if (beat->type == fURIDs.atomInt)
fTimePos.bbt.beat = ((LV2_Atom_Int*)beat)->body + 1;
else if (beat->type == fURIDs.atomLong)
fTimePos.bbt.beat = ((LV2_Atom_Long*)beat)->body + 1;
}

if (beatUnit != nullptr)
{
if (beatUnit->type == fURIDs.atomDouble)
fTimePos.bbt.beatType = ((LV2_Atom_Double*)beatUnit)->body;
else if (beatUnit->type == fURIDs.atomFloat)
fTimePos.bbt.beatType = ((LV2_Atom_Float*)beatUnit)->body;
else if (beatUnit->type == fURIDs.atomInt)
fTimePos.bbt.beatType = ((LV2_Atom_Int*)beatUnit)->body;
else if (beatUnit->type == fURIDs.atomLong)
fTimePos.bbt.beatType = ((LV2_Atom_Long*)beatUnit)->body;
}

if (beatsPerBar != nullptr)
{
if (beatsPerBar->type == fURIDs.atomDouble)
fTimePos.bbt.beatsPerBar = ((LV2_Atom_Double*)beatsPerBar)->body;
else if (beatsPerBar->type == fURIDs.atomFloat)
fTimePos.bbt.beatsPerBar = ((LV2_Atom_Float*)beatsPerBar)->body;
else if (beatsPerBar->type == fURIDs.atomInt)
fTimePos.bbt.beatsPerBar = ((LV2_Atom_Int*)beatsPerBar)->body;
else if (beatsPerBar->type == fURIDs.atomLong)
fTimePos.bbt.beatsPerBar = ((LV2_Atom_Long*)beatsPerBar)->body;
}

if (beatsPerMinute != nullptr)
{
if (beatsPerMinute->type == fURIDs.atomDouble)
fTimePos.bbt.beatsPerMinute = ((LV2_Atom_Double*)beatsPerMinute)->body;
else if (beatsPerMinute->type == fURIDs.atomFloat)
fTimePos.bbt.beatsPerMinute = ((LV2_Atom_Float*)beatsPerMinute)->body;
else if (beatsPerMinute->type == fURIDs.atomInt)
fTimePos.bbt.beatsPerMinute = ((LV2_Atom_Int*)beatsPerMinute)->body;
else if (beatsPerMinute->type == fURIDs.atomLong)
fTimePos.bbt.beatsPerMinute = ((LV2_Atom_Long*)beatsPerMinute)->body;
}

if (frame != nullptr && frame->type == fURIDs.atomLong)
{
fTimePos.frame = ((LV2_Atom_Long*)frame)->body;
needsFrameIncrement = false;
}

if (speed != nullptr && speed->type == fURIDs.atomFloat)
{
fLastTimeSpeed = ((LV2_Atom_Float*)speed)->body;
fTimePos.playing = (fLastTimeSpeed == 1.0f);
}

if ((! fTimePos.bbt.valid) && beatsPerMinute != nullptr && beatsPerBar != nullptr && beatUnit != nullptr)
fTimePos.bbt.valid = true;

continue;
}
# endif
# if (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI)
if (event->body.type == fURIDs.distrhoState && fWorker != nullptr)
{
const void* const data((const void*)(event + 1));
fWorker->schedule_work(fWorker->handle, event->body.size, data);

continue;
}
# endif
}
#endif

# if DISTRHO_PLUGIN_WANT_TIMEPOS
if (needsFrameIncrement && fLastTimeSpeed != 0.0f)
fTimePos.frame += fLastTimeSpeed*sampleCount;
fPlugin.setTimePos(fTimePos);
# endif

#if DISTRHO_PLUGIN_IS_SYNTH
fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount, fMidiEvents, midiEventCount);
#else
fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount);
#endif

#if DISTRHO_LV2_USE_EVENTS_OUT
#endif

updateParameterOutputs();
}

// -------------------------------------------------------------------

uint32_t lv2_get_options(LV2_Options_Option* const /*options*/)
{
// currently unused
return LV2_OPTIONS_ERR_UNKNOWN;
}

uint32_t lv2_set_options(const LV2_Options_Option* const options)
{
for (int i=0; options[i].key != 0; ++i)
{
if (options[i].key == fUridMap->map(fUridMap->handle, LV2_BUF_SIZE__maxBlockLength))
{
if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Int))
{
const int bufferSize(*(const int*)options[i].value);
fPlugin.setBufferSize(bufferSize);
return LV2_OPTIONS_SUCCESS;
}
else
{
d_stderr("Host changed maxBlockLength but with wrong value type");
return LV2_OPTIONS_ERR_BAD_VALUE;
}
}
else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_CORE__sampleRate))
{
if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Double))
{
const double sampleRate(*(const double*)options[i].value);
fPlugin.setSampleRate(sampleRate);
return LV2_OPTIONS_SUCCESS;
}
else
{
d_stderr("Host changed sampleRate but with wrong value type");
return LV2_OPTIONS_ERR_BAD_VALUE;
}
}
}

return LV2_OPTIONS_ERR_BAD_KEY;
}

// -------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_PROGRAMS
const LV2_Program_Descriptor* lv2_get_program(const uint32_t index)
{
if (index >= fPlugin.getProgramCount())
return nullptr;

static LV2_Program_Descriptor desc;

desc.bank = index / 128;
desc.program = index % 128;
desc.name = fPlugin.getProgramName(index);

return &desc;
}

void lv2_select_program(const uint32_t bank, const uint32_t program)
{
const uint32_t realProgram(bank * 128 + program);

if (realProgram >= fPlugin.getProgramCount())
return;

fPlugin.setProgram(realProgram);

// Update control inputs
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (fPlugin.isParameterOutput(i))
continue;

fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}
}
#endif

// -------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_STATE
LV2_State_Status lv2_save(const LV2_State_Store_Function store, const LV2_State_Handle handle, const uint32_t flags)
{
//flags = LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE;

for (auto it = fStateMap.begin(), end = fStateMap.end(); it != end; ++it)
{
const d_string& key = it->first;
const d_string& value = it->second;

store(handle, fUridMap->map(fUridMap->handle, (const char*)key), (const char*)value, value.length()+1, fURIDs.atomString, flags);
}

return LV2_STATE_SUCCESS;
}

LV2_State_Status lv2_restore(const LV2_State_Retrieve_Function retrieve, const LV2_State_Handle handle)
{
size_t size = 0;
uint32_t type = 0;
uint32_t flags = LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE;

for (uint32_t i=0, count=fPlugin.getStateCount(); i < count; ++i)
{
const d_string& key = fPlugin.getStateKey(i);

const void* data = retrieve(handle, fUridMap->map(fUridMap->handle, (const char*)key), &size, &type, &flags);

if (size == 0)
continue;
if (data == nullptr)
continue;
if (type != fURIDs.atomString)
continue;

const char* const value((const char*)data);

if (std::strlen(value) != size)
continue;

setState(key, value);
}

return LV2_STATE_SUCCESS;
}

// -------------------------------------------------------------------

LV2_Worker_Status lv2_work(const void* const data)
{
const char* const stateKey((const char*)data);
const char* const stateValue(stateKey+std::strlen(stateKey)+1);

setState(stateKey, stateValue);

return LV2_WORKER_SUCCESS;
}
#endif

// -------------------------------------------------------------------

private:
PluginExporter fPlugin;

// LV2 ports
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
float* fPortAudioIns[DISTRHO_PLUGIN_NUM_INPUTS];
#else
float** fPortAudioIns;
#endif
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
float* fPortAudioOuts[DISTRHO_PLUGIN_NUM_OUTPUTS];
#else
float** fPortAudioOuts;
#endif
float** fPortControls;
#if DISTRHO_LV2_USE_EVENTS_IN
LV2_Atom_Sequence* fPortEventsIn;
#endif
#if DISTRHO_LV2_USE_EVENTS_OUT
LV2_Atom_Sequence* fPortEventsOut;
#endif
#if DISTRHO_PLUGIN_WANT_LATENCY
float* fPortLatency;
#endif

// Temporary data
float* fLastControlValues;
#if DISTRHO_PLUGIN_IS_SYNTH
MidiEvent fMidiEvents[kMaxMidiEvents];
#endif
#if DISTRHO_PLUGIN_WANT_TIMEPOS
TimePos fTimePos;
float fLastTimeSpeed;
#endif

// LV2 URIDs
#if DISTRHO_LV2_USE_EVENTS_IN || DISTRHO_LV2_USE_EVENTS_OUT
struct URIDs {
LV2_URID atomBlank;
LV2_URID atomDouble;
LV2_URID atomFloat;
LV2_URID atomInt;
LV2_URID atomLong;
LV2_URID atomString;
LV2_URID distrhoState;
LV2_URID midiEvent;
LV2_URID timePosition;
LV2_URID timeBar;
LV2_URID timeBarBeat;
LV2_URID timeBeat;
LV2_URID timeBeatUnit;
LV2_URID timeBeatsPerBar;
LV2_URID timeBeatsPerMinute;
LV2_URID timeFrame;
LV2_URID timeSpeed;

URIDs(const LV2_URID_Map* const uridMap)
: atomBlank(uridMap->map(uridMap->handle, LV2_ATOM__Blank)),
atomDouble(uridMap->map(uridMap->handle, LV2_ATOM__Double)),
atomFloat(uridMap->map(uridMap->handle, LV2_ATOM__Float)),
atomInt(uridMap->map(uridMap->handle, LV2_ATOM__Int)),
atomLong(uridMap->map(uridMap->handle, LV2_ATOM__Long)),
atomString(uridMap->map(uridMap->handle, LV2_ATOM__String)),
distrhoState(uridMap->map(uridMap->handle, "urn:distrho:keyValueState")),
midiEvent(uridMap->map(uridMap->handle, LV2_MIDI__MidiEvent)),
timePosition(uridMap->map(uridMap->handle, LV2_TIME__Position)),
timeBar(uridMap->map(uridMap->handle, LV2_TIME__bar)),
timeBarBeat(uridMap->map(uridMap->handle, LV2_TIME__barBeat)),
timeBeat(uridMap->map(uridMap->handle, LV2_TIME__beat)),
timeBeatUnit(uridMap->map(uridMap->handle, LV2_TIME__beatUnit)),
timeBeatsPerBar(uridMap->map(uridMap->handle, LV2_TIME__beatsPerBar)),
timeBeatsPerMinute(uridMap->map(uridMap->handle, LV2_TIME__beatsPerMinute)),
timeFrame(uridMap->map(uridMap->handle, LV2_TIME__frame)),
timeSpeed(uridMap->map(uridMap->handle, LV2_TIME__speed)) {}
} fURIDs;
#endif

// LV2 features
const LV2_URID_Map* const fUridMap;
const LV2_Worker_Schedule* const fWorker;

#if DISTRHO_PLUGIN_WANT_STATE
StringMap fStateMap;

void setState(const char* const key, const char* const newValue)
{
fPlugin.setState(key, newValue);

// check if key already exists
for (auto it = fStateMap.begin(), end = fStateMap.end(); it != end; ++it)
{
const d_string& d_key = it->first;

if (d_key == key)
{
it->second = newValue;
return;
}
}

// add a new one then
d_string d_key(key);
fStateMap[d_key] = newValue;
}
#endif

void updateParameterOutputs()
{
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (! fPlugin.isParameterOutput(i))
continue;

fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}

#if DISTRHO_PLUGIN_WANT_LATENCY
if (fPortLatency != nullptr)
*fPortLatency = fPlugin.getLatency();
#endif
}
};

// -----------------------------------------------------------------------

static LV2_Handle lv2_instantiate(const LV2_Descriptor*, double sampleRate, const char*, const LV2_Feature* const* features)
{
const LV2_Options_Option* options = nullptr;
const LV2_URID_Map* uridMap = nullptr;
const LV2_Worker_Schedule* worker = nullptr;

for (int i=0; features[i] != nullptr; ++i)
{
if (std::strcmp(features[i]->URI, LV2_OPTIONS__options) == 0)
options = (const LV2_Options_Option*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_URID__map) == 0)
uridMap = (const LV2_URID_Map*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_WORKER__schedule) == 0)
worker = (const LV2_Worker_Schedule*)features[i]->data;
}

if (options == nullptr)
{
d_stderr("Options feature missing, cannot continue!");
return nullptr;
}

if (uridMap == nullptr)
{
d_stderr("URID Map feature missing, cannot continue!");
return nullptr;
}

#if DISTRHO_PLUGIN_WANT_STATE
if (worker == nullptr)
{
d_stderr("Worker feature missing, cannot continue!");
return nullptr;
}
#endif

d_lastBufferSize = 0;

for (int i=0; options[i].key != 0; ++i)
{
if (options[i].key == uridMap->map(uridMap->handle, LV2_BUF_SIZE__maxBlockLength))
{
if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Int))
d_lastBufferSize = *(const int*)options[i].value;
else
d_stderr("Host provides maxBlockLength but has wrong value type");

break;
}
}

if (d_lastBufferSize == 0)
{
d_stderr("Host does not provide maxBlockLength option");
d_lastBufferSize = 2048;
}

d_lastSampleRate = sampleRate;

return new PluginLv2(uridMap, worker);
}

#define instancePtr ((PluginLv2*)instance)

static void lv2_connect_port(LV2_Handle instance, uint32_t port, void* dataLocation)
{
instancePtr->lv2_connect_port(port, dataLocation);
}

static void lv2_activate(LV2_Handle instance)
{
instancePtr->lv2_activate();
}

static void lv2_run(LV2_Handle instance, uint32_t sampleCount)
{
instancePtr->lv2_run(sampleCount);
}

static void lv2_deactivate(LV2_Handle instance)
{
instancePtr->lv2_deactivate();
}

static void lv2_cleanup(LV2_Handle instance)
{
delete instancePtr;
}

// -----------------------------------------------------------------------

static uint32_t lv2_get_options(LV2_Handle instance, LV2_Options_Option* options)
{
return instancePtr->lv2_get_options(options);
}

static uint32_t lv2_set_options(LV2_Handle instance, const LV2_Options_Option* options)
{
return instancePtr->lv2_set_options(options);
}

// -----------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_PROGRAMS
static const LV2_Program_Descriptor* lv2_get_program(LV2_Handle instance, uint32_t index)
{
return instancePtr->lv2_get_program(index);
}

static void lv2_select_program(LV2_Handle instance, uint32_t bank, uint32_t program)
{
instancePtr->lv2_select_program(bank, program);
}
#endif

// -----------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_STATE
static LV2_State_Status lv2_save(LV2_Handle instance, LV2_State_Store_Function store, LV2_State_Handle handle, uint32_t flags, const LV2_Feature* const*)
{
return instancePtr->lv2_save(store, handle, flags);
}

static LV2_State_Status lv2_restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t, const LV2_Feature* const*)
{
return instancePtr->lv2_restore(retrieve, handle);
}

LV2_Worker_Status lv2_work(LV2_Handle instance, LV2_Worker_Respond_Function, LV2_Worker_Respond_Handle, uint32_t, const void* data)
{
return instancePtr->lv2_work(data);
}
#endif

// -----------------------------------------------------------------------

static const void* lv2_extension_data(const char* uri)
{
static const LV2_Options_Interface options = { lv2_get_options, lv2_set_options };

if (std::strcmp(uri, LV2_OPTIONS__interface) == 0)
return &options;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
static const LV2_Programs_Interface programs = { lv2_get_program, lv2_select_program };

if (std::strcmp(uri, LV2_PROGRAMS__Interface) == 0)
return &programs;
#endif

#if DISTRHO_PLUGIN_WANT_STATE
static const LV2_State_Interface state = { lv2_save, lv2_restore };
static const LV2_Worker_Interface worker = { lv2_work, nullptr, nullptr };

if (std::strcmp(uri, LV2_STATE__interface) == 0)
return &state;
if (std::strcmp(uri, LV2_WORKER__interface) == 0)
return &worker;
#endif

return nullptr;
}

#undef instancePtr

// -----------------------------------------------------------------------

static const LV2_Descriptor sLv2Descriptor = {
DISTRHO_PLUGIN_URI,
lv2_instantiate,
lv2_connect_port,
lv2_activate,
lv2_run,
lv2_deactivate,
lv2_cleanup,
lv2_extension_data
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

DISTRHO_PLUGIN_EXPORT
const LV2_Descriptor* lv2_descriptor(uint32_t index)
{
USE_NAMESPACE_DISTRHO
return (index == 0) ? &sLv2Descriptor : nullptr;
}

// -----------------------------------------------------------------------

+ 367
- 0
libs/distrho/src/DistrhoPluginLV2export.cpp View File

@@ -0,0 +1,367 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoPluginInternal.hpp"

#include "lv2/atom.h"
#include "lv2/buf-size.h"
#include "lv2/midi.h"
#include "lv2/options.h"
#include "lv2/state.h"
#include "lv2/time.h"
#include "lv2/ui.h"
#include "lv2/units.h"
#include "lv2/urid.h"
#include "lv2/worker.h"
#include "lv2/lv2_programs.h"

#include <fstream>
#include <iostream>

#ifndef DISTRHO_PLUGIN_URI
# error DISTRHO_PLUGIN_URI undefined!
#endif

#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_TIMEPOS || (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI))
#define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI)

// -----------------------------------------------------------------------

DISTRHO_PLUGIN_EXPORT
void lv2_generate_ttl(const char* const basename)
{
USE_NAMESPACE_DISTRHO

// Dummy plugin to get data from
d_lastBufferSize = 512;
d_lastSampleRate = 44100.0;
PluginExporter plugin;
d_lastBufferSize = 0;
d_lastSampleRate = 0.0;

d_string pluginLabel(basename);
d_string pluginTTL(pluginLabel + ".ttl");

// ---------------------------------------------

{
std::cout << "Writing manifest.ttl..."; std::cout.flush();
std::fstream manifestFile("manifest.ttl", std::ios::out);

d_string manifestString;
manifestString += "@prefix lv2: <" LV2_CORE_PREFIX "> .\n";
manifestString += "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n";
#if DISTRHO_PLUGIN_HAS_UI
manifestString += "@prefix ui: <" LV2_UI_PREFIX "> .\n";
#endif
manifestString += "\n";

manifestString += "<" DISTRHO_PLUGIN_URI ">\n";
manifestString += " a lv2:Plugin ;\n";
manifestString += " lv2:binary <" + pluginLabel + "." DISTRHO_DLL_EXTENSION "> ;\n";
manifestString += " rdfs:seeAlso <" + pluginTTL + "> .\n";
manifestString += "\n";

#if DISTRHO_PLUGIN_HAS_UI
manifestString += "<" DISTRHO_UI_URI ">\n";
# if DISTRHO_OS_HAIKU
manifestString += " a ui:BeUI ;\n";
# elif DISTRHO_OS_MACOS
manifestString += " a ui:CocoaUI ;\n";
# elif DISTRHO_OS_WINDOWS
manifestString += " a ui:WindowsUI ;\n";
# else
manifestString += " a ui:X11UI ;\n";
# endif
manifestString += " ui:binary <" + pluginLabel + "_ui." DISTRHO_DLL_EXTENSION "> ;\n";
#if DISTRHO_PLUGIN_WANT_PROGRAMS
manifestString += " lv2:extensionData ui:idleInterface ,\n";
manifestString += " <" LV2_PROGRAMS__Interface "> ;\n";
#else
manifestString += " lv2:extensionData ui:idleInterface ;\n";
#endif
manifestString += " lv2:optionalFeature ui:noUserResize ,\n";
manifestString += " ui:touch ;\n";
manifestString += " lv2:requiredFeature ui:resize ,\n";
manifestString += " <" LV2_OPTIONS__options "> ,\n";
manifestString += " <" LV2_URID__map "> .\n";
#endif

manifestFile << manifestString << std::endl;
manifestFile.close();
std::cout << " done!" << std::endl;
}

// ---------------------------------------------

{
std::cout << "Writing " << pluginTTL << "..."; std::cout.flush();
std::fstream pluginFile(pluginTTL, std::ios::out);

d_string pluginString;

// header
#if DISTRHO_LV2_USE_EVENTS_IN
pluginString += "@prefix atom: <" LV2_ATOM_PREFIX "> .\n";
#endif
pluginString += "@prefix doap: <http://usefulinc.com/ns/doap#> .\n";
pluginString += "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n";
pluginString += "@prefix lv2: <" LV2_CORE_PREFIX "> .\n";
#if DISTRHO_PLUGIN_HAS_UI
pluginString += "@prefix ui: <" LV2_UI_PREFIX "> .\n";
#endif
pluginString += "@prefix unit: <" LV2_UNITS_PREFIX "> .\n";
pluginString += "\n";

// plugin
pluginString += "<" DISTRHO_PLUGIN_URI ">\n";
#if DISTRHO_PLUGIN_IS_SYNTH
pluginString += " a lv2:InstrumentPlugin, lv2:Plugin ;\n";
#else
pluginString += " a lv2:Plugin ;\n";
#endif
pluginString += "\n";

// extensionData
pluginString += " lv2:extensionData <" LV2_STATE__interface "> ";
#if DISTRHO_PLUGIN_WANT_STATE
pluginString += ",\n <" LV2_OPTIONS__interface "> ";
pluginString += ",\n <" LV2_WORKER__interface "> ";
#endif
#if DISTRHO_PLUGIN_WANT_PROGRAMS
pluginString += ",\n <" LV2_PROGRAMS__Interface "> ";
#endif
pluginString += ";\n\n";

// optionalFeatures
pluginString += " lv2:optionalFeature <" LV2_CORE__hardRTCapable "> ,\n";
pluginString += " <" LV2_BUF_SIZE__boundedBlockLength "> ;\n";
pluginString += "\n";

// requiredFeatures
pluginString += " lv2:requiredFeature <" LV2_OPTIONS__options "> ";
pluginString += ",\n <" LV2_URID__map "> ";
#if DISTRHO_PLUGIN_WANT_STATE
pluginString += ",\n <" LV2_WORKER__schedule "> ";
#endif
pluginString += ";\n\n";

// UI
#if DISTRHO_PLUGIN_HAS_UI
pluginString += " ui:ui <" DISTRHO_UI_URI "> ;\n";
pluginString += "\n";
#endif

{
uint32_t portIndex = 0;

#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i, ++portIndex)
{
if (i == 0)
pluginString += " lv2:port [\n";
else
pluginString += " [\n";

pluginString += " a lv2:InputPort, lv2:AudioPort ;\n";
pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:symbol \"lv2_audio_in_" + d_string(i+1) + "\" ;\n";
pluginString += " lv2:name \"Audio Input " + d_string(i+1) + "\" ;\n";

if (i+1 == DISTRHO_PLUGIN_NUM_INPUTS)
pluginString += " ] ;\n\n";
else
pluginString += " ] ,\n";
}
pluginString += "\n";
#endif

#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i, ++portIndex)
{
if (i == 0)
pluginString += " lv2:port [\n";
else
pluginString += " [\n";

pluginString += " a lv2:OutputPort, lv2:AudioPort ;\n";
pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:symbol \"lv2_audio_out_" + d_string(i+1) + "\" ;\n";
pluginString += " lv2:name \"Audio Output " + d_string(i+1) + "\" ;\n";

if (i+1 == DISTRHO_PLUGIN_NUM_OUTPUTS)
pluginString += " ] ;\n\n";
else
pluginString += " ] ,\n";
}
pluginString += "\n";
#endif

#if DISTRHO_LV2_USE_EVENTS_IN
pluginString += " lv2:port [\n";
pluginString += " a lv2:InputPort, atom:AtomPort ;\n";
pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:name \"Events Input\" ;\n";
pluginString += " lv2:symbol \"lv2_events_in\" ;\n";
pluginString += " atom:bufferType atom:Sequence ;\n";
# if (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI)
pluginString += " atom:supports <" LV2_ATOM__String "> ;\n";
# endif
# if DISTRHO_PLUGIN_WANT_TIMEPOS
pluginString += " atom:supports <" LV2_TIME__Position "> ;\n";
# endif
# if DISTRHO_PLUGIN_IS_SYNTH
pluginString += " atom:supports <" LV2_MIDI__MidiEvent "> ;\n";
# endif

pluginString += " ] ;\n\n";
++portIndex;
#endif

#if DISTRHO_LV2_USE_EVENTS_OUT
pluginString += " lv2:port [\n";
pluginString += " a lv2:OutputPort, atom:AtomPort ;\n";
pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:name \"Events Output\" ;\n";
pluginString += " lv2:symbol \"lv2_events_out\" ;\n";
pluginString += " atom:bufferType atom:Sequence ;\n";
pluginString += " atom:supports <" LV2_ATOM__String "> ;\n";
pluginString += " ] ;\n\n";
++portIndex;
#endif

#if DISTRHO_PLUGIN_WANT_LATENCY
pluginString += " lv2:port [\n";
pluginString += " a lv2:OutputPort, lv2:ControlPort ;\n";
pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:name \"Latency\" ;\n";
pluginString += " lv2:symbol \"lv2_latency\" ;\n";
pluginString += " lv2:designation lv2:latency ;\n";
pluginString += " lv2:portProperty lv2:reportsLatency ;\n";
pluginString += " ] ;\n\n";
++portIndex;
#endif

for (uint32_t i=0, count=plugin.getParameterCount(); i < count; ++i, ++portIndex)
{
if (i == 0)
pluginString += " lv2:port [\n";
else
pluginString += " [\n";

if (plugin.isParameterOutput(i))
pluginString += " a lv2:OutputPort, lv2:ControlPort ;\n";
else
pluginString += " a lv2:InputPort, lv2:ControlPort ;\n";

pluginString += " lv2:index " + d_string(portIndex) + " ;\n";
pluginString += " lv2:name \"" + plugin.getParameterName(i) + "\" ;\n";

// symbol
{
d_string symbol(plugin.getParameterSymbol(i));

if (symbol.isEmpty())
symbol = "lv2_port_" + d_string(portIndex-1);

pluginString += " lv2:symbol \"" + symbol + "\" ;\n";
}

// ranges
{
const ParameterRanges& ranges(plugin.getParameterRanges(i));

if (plugin.getParameterHints(i) & PARAMETER_IS_INTEGER)
{
pluginString += " lv2:default " + d_string(int(plugin.getParameterValue(i))) + " ;\n";
pluginString += " lv2:minimum " + d_string(int(ranges.min)) + " ;\n";
pluginString += " lv2:maximum " + d_string(int(ranges.max)) + " ;\n";
}
else
{
pluginString += " lv2:default " + d_string(plugin.getParameterValue(i)) + " ;\n";
pluginString += " lv2:minimum " + d_string(ranges.min) + " ;\n";
pluginString += " lv2:maximum " + d_string(ranges.max) + " ;\n";
}
}

// unit
{
const d_string& unit(plugin.getParameterUnit(i));

if (! unit.isEmpty())
{
if (unit == "db" || unit == "dB")
{
pluginString += " unit:unit unit:db ;\n";
}
else if (unit == "hz" || unit == "Hz")
{
pluginString += " unit:unit unit:hz ;\n";
}
else if (unit == "khz" || unit == "kHz")
{
pluginString += " unit:unit unit:khz ;\n";
}
else if (unit == "mhz" || unit == "mHz")
{
pluginString += " unit:unit unit:mhz ;\n";
}
else if (unit == "%")
{
pluginString += " unit:unit unit:pc ;\n";
}
else
{
pluginString += " unit:unit [\n";
pluginString += " a unit:Unit ;\n";
pluginString += " unit:name \"" + unit + "\" ;\n";
pluginString += " unit:symbol \"" + unit + "\" ;\n";
pluginString += " unit:render \"%f " + unit + "\" ;\n";
pluginString += " ] ;\n";
}
}
}

// hints
{
const uint32_t hints(plugin.getParameterHints(i));

if (hints & PARAMETER_IS_BOOLEAN)
pluginString += " lv2:portProperty lv2:toggled ;\n";
if (hints & PARAMETER_IS_INTEGER)
pluginString += " lv2:portProperty lv2:integer ;\n";
if (hints & PARAMETER_IS_LOGARITHMIC)
pluginString += " lv2:portProperty <http://lv2plug.in/ns/ext/port-props#logarithmic> ;\n";
if ((hints & PARAMETER_IS_AUTOMABLE) == 0 && ! plugin.isParameterOutput(i))
pluginString += " lv2:portProperty <http://lv2plug.in/ns/ext/port-props#expensive> ;\n";
}

if (i+1 == count)
pluginString += " ] ;\n\n";
else
pluginString += " ] ,\n";
}
}

pluginString += " doap:name \"" + d_string(plugin.getName()) + "\" ;\n";
pluginString += " doap:maintainer [ foaf:name \"" + d_string(plugin.getMaker()) + "\" ] .\n";

pluginFile << pluginString << std::endl;
pluginFile.close();
std::cout << " done!" << std::endl;
}
}

+ 1009
- 0
libs/distrho/src/DistrhoPluginVST.cpp
File diff suppressed because it is too large
View File


+ 89
- 0
libs/distrho/src/DistrhoUI.cpp View File

@@ -0,0 +1,89 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoUIInternal.hpp"

START_NAMESPACE_DGL
extern Window* dgl_lastUiParent;
END_NAMESPACE_DGL

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Static data

double d_lastUiSampleRate = 0.0;

// -----------------------------------------------------------------------
// UI

UI::UI()
: DGL::Widget(*DGL::dgl_lastUiParent),
pData(new PrivateData())
{
assert(DGL::dgl_lastUiParent != nullptr);

DGL::dgl_lastUiParent = nullptr;
}

UI::~UI()
{
delete pData;
}

// -----------------------------------------------------------------------
// Host DSP State

double UI::d_getSampleRate() const noexcept
{
return pData->sampleRate;
}

void UI::d_editParameter(uint32_t index, bool started)
{
pData->editParamCallback(index + pData->parameterOffset, started);
}

void UI::d_setParameterValue(uint32_t index, float value)
{
pData->setParamCallback(index + pData->parameterOffset, value);
}

#if DISTRHO_PLUGIN_WANT_STATE
void UI::d_setState(const char* key, const char* value)
{
pData->setStateCallback(key, value);
}
#endif

#if DISTRHO_PLUGIN_IS_SYNTH
void UI::d_sendNote(uint8_t channel, uint8_t note, uint8_t velocity)
{
pData->sendNoteCallback(channel, note, velocity);
}
#endif

// -----------------------------------------------------------------------
// Host UI State

void UI::d_uiResize(unsigned int width, unsigned int height)
{
pData->uiResizeCallback(width, height);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 489
- 0
libs/distrho/src/DistrhoUIDSSI.cpp View File

@@ -0,0 +1,489 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoUIInternal.hpp"

#include <lo/lo.h>

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

struct OscData {
lo_address addr;
const char* path;
lo_server server;

OscData()
: addr(nullptr),
path(nullptr),
server(nullptr) {}

void idle() const
{
if (server == nullptr)
return;

while (lo_server_recv_noblock(server, 0) != 0) {}
}

void send_configure(const char* const key, const char* const value) const
{
char targetPath[std::strlen(path)+11];
std::strcpy(targetPath, path);
std::strcat(targetPath, "/configure");
lo_send(addr, targetPath, "ss", key, value);
}

void send_control(const int32_t index, const float value) const
{
char targetPath[std::strlen(path)+9];
std::strcpy(targetPath, path);
std::strcat(targetPath, "/control");
lo_send(addr, targetPath, "if", index, value);
}

void send_midi(unsigned char data[4]) const
{
char targetPath[std::strlen(path)+6];
std::strcpy(targetPath, path);
std::strcat(targetPath, "/midi");
lo_send(addr, targetPath, "m", data);
}

void send_update(const char* const url) const
{
char targetPath[std::strlen(path)+8];
std::strcpy(targetPath, path);
std::strcat(targetPath, "/update");
lo_send(addr, targetPath, "s", url);
}

void send_exiting() const
{
char targetPath[std::strlen(path)+9];
std::strcpy(targetPath, path);
std::strcat(targetPath, "/exiting");
lo_send(addr, targetPath, "");
}
};

// -----------------------------------------------------------------------

class UIDssi
{
public:
UIDssi(const OscData& oscData, const char* const uiTitle)
: fUI(this, 0, nullptr, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback),
fHostClosed(false),
fOscData(oscData)
{
fUI.setTitle(uiTitle);
}

~UIDssi()
{
if (fOscData.server != nullptr && ! fHostClosed)
fOscData.send_exiting();
}

void exec()
{
for (;;)
{
fOscData.idle();

if (! fUI.idle())
break;

d_msleep(50);
}
}

// -------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_STATE
void dssiui_configure(const char* key, const char* value)
{
fUI.stateChanged(key, value);
}
#endif

void dssiui_control(unsigned long index, float value)
{
fUI.parameterChanged(index, value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
void dssiui_program(unsigned long bank, unsigned long program)
{
fUI.programChanged(bank * 128 + program);
}
#endif

void dssiui_show()
{
fUI.setVisible(true);
}

void dssiui_hide()
{
fUI.setVisible(false);
}

void dssiui_quit()
{
fHostClosed = true;
fUI.quit();
}

// -------------------------------------------------------------------

protected:
void setParameterValue(const uint32_t rindex, const float value)
{
if (fOscData.server == nullptr)
return;

fOscData.send_control(rindex, value);
}

void setState(const char* const key, const char* const value)
{
if (fOscData.server == nullptr)
return;

fOscData.send_configure(key, value);
}

void sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
if (fOscData.server == nullptr)
return;
if (channel > 0xF)
return;

uint8_t mdata[4] = { 0, channel, note, velocity };
mdata[1] += (velocity != 0) ? 0x90 : 0x80;

fOscData.send_midi(mdata);
}

void uiResize(const unsigned int width, const unsigned int height)
{
fUI.setSize(width, height);
}

private:
UIExporter fUI;
bool fHostClosed;

const OscData& fOscData;

// -------------------------------------------------------------------
// Callbacks

#define uiPtr ((UIDssi*)ptr)

static void setParameterCallback(void* ptr, uint32_t rindex, float value)
{
uiPtr->setParameterValue(rindex, value);
}

static void setStateCallback(void* ptr, const char* key, const char* value)
{
uiPtr->setState(key, value);
}

static void sendNoteCallback(void* ptr, uint8_t channel, uint8_t note, uint8_t velocity)
{
uiPtr->sendNote(channel, note, velocity);
}

static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height)
{
uiPtr->uiResize(width, height);
}

#undef uiPtr
};

// -----------------------------------------------------------------------

static OscData gOscData;
static const char* gUiTitle = nullptr;
static UIDssi* globalUI = nullptr;

static void initUiIfNeeded()
{
if (globalUI != nullptr)
return;

if (d_lastUiSampleRate == 0.0)
d_lastUiSampleRate = 44100.0;

globalUI = new UIDssi(gOscData, gUiTitle);
}

// -----------------------------------------------------------------------

int osc_debug_handler(const char* path, const char*, lo_arg**, int, lo_message, void*)
{
d_debug("osc_debug_handler(\"%s\")", path);
return 0;
}

void osc_error_handler(int num, const char* msg, const char* path)
{
d_stderr("osc_error_handler(%i, \"%s\", \"%s\")", num, msg, path);
}

#if DISTRHO_PLUGIN_WANT_STATE
int osc_configure_handler(const char*, const char*, lo_arg** argv, int, lo_message, void*)
{
const char* const key = &argv[0]->s;
const char* const value = &argv[1]->s;
d_debug("osc_configure_handler(\"%s\", \"%s\")", key, value);

initUiIfNeeded();

globalUI->dssiui_configure(key, value);

return 0;
}
#endif

int osc_control_handler(const char*, const char*, lo_arg** argv, int, lo_message, void*)
{
const int32_t rindex = argv[0]->i;
const float value = argv[1]->f;
d_debug("osc_control_handler(%i, %f)", rindex, value);

int32_t index = rindex - DISTRHO_PLUGIN_NUM_INPUTS - DISTRHO_PLUGIN_NUM_OUTPUTS;

// latency
#if DISTRHO_PLUGIN_WANT_LATENCY
index -= 1;
#endif

if (index < 0)
return 0;

initUiIfNeeded();

globalUI->dssiui_control(index, value);

return 0;
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
int osc_program_handler(const char*, const char*, lo_arg** argv, int, lo_message, void*)
{
const int32_t bank = argv[0]->i;
const int32_t program = argv[1]->f;
d_debug("osc_program_handler(%i, %i)", bank, program);

initUiIfNeeded();

globalUI->dssiui_program(bank, program);

return 0;
}
#endif

int osc_sample_rate_handler(const char*, const char*, lo_arg** argv, int, lo_message, void*)
{
const int32_t sampleRate = argv[0]->i;
d_debug("osc_sample_rate_handler(%i)", sampleRate);

d_lastUiSampleRate = sampleRate;

return 0;
}

int osc_show_handler(const char*, const char*, lo_arg**, int, lo_message, void*)
{
d_debug("osc_show_handler()");

initUiIfNeeded();

globalUI->dssiui_show();

return 0;
}

int osc_hide_handler(const char*, const char*, lo_arg**, int, lo_message, void*)
{
d_debug("osc_hide_handler()");

if (globalUI != nullptr)
globalUI->dssiui_hide();

return 0;
}

int osc_quit_handler(const char*, const char*, lo_arg**, int, lo_message, void*)
{
d_debug("osc_quit_handler()");

if (globalUI != nullptr)
globalUI->dssiui_quit();

return 0;
}

END_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

int main(int argc, char* argv[])
{
USE_NAMESPACE_DISTRHO

// dummy test mode
if (argc == 1)
{
gUiTitle = "DSSI UI Test";

initUiIfNeeded();
globalUI->dssiui_show();
globalUI->exec();

return 0;
}

if (argc != 5)
{
fprintf(stderr, "Usage: %s <osc-url> <plugin-dll> <plugin-label> <instance-name>\n", argv[0]);
return 1;
}

const char* oscUrl = argv[1];
const char* uiTitle = argv[4];

char* const oscHost = lo_url_get_hostname(oscUrl);
char* const oscPort = lo_url_get_port(oscUrl);
char* const oscPath = lo_url_get_path(oscUrl);
size_t oscPathSize = strlen(oscPath);
lo_address oscAddr = lo_address_new(oscHost, oscPort);
lo_server oscServer = lo_server_new_with_proto(nullptr, LO_UDP, osc_error_handler);

char* const oscServerPath = lo_server_get_url(oscServer);

char pluginPath[strlen(oscServerPath)+oscPathSize];
strcpy(pluginPath, oscServerPath);
strcat(pluginPath, oscPath+1);

#if DISTRHO_PLUGIN_WANT_STATE
char oscPathConfigure[oscPathSize+11];
strcpy(oscPathConfigure, oscPath);
strcat(oscPathConfigure, "/configure");
lo_server_add_method(oscServer, oscPathConfigure, "ss", osc_configure_handler, nullptr);
#endif

char oscPathControl[oscPathSize+9];
strcpy(oscPathControl, oscPath);
strcat(oscPathControl, "/control");
lo_server_add_method(oscServer, oscPathControl, "if", osc_control_handler, nullptr);

d_stdout("oscServerPath: \"%s\"", oscServerPath);
d_stdout("pluginPath: \"%s\"", pluginPath);
d_stdout("oscPathControl: \"%s\"", oscPathControl);

#if DISTRHO_PLUGIN_WANT_PROGRAMS
char oscPathProgram[oscPathSize+9];
strcpy(oscPathProgram, oscPath);
strcat(oscPathProgram, "/program");
lo_server_add_method(oscServer, oscPathProgram, "ii", osc_program_handler, nullptr);
#endif

char oscPathSampleRate[oscPathSize+13];
strcpy(oscPathSampleRate, oscPath);
strcat(oscPathSampleRate, "/sample-rate");
lo_server_add_method(oscServer, oscPathSampleRate, "i", osc_sample_rate_handler, nullptr);

char oscPathShow[oscPathSize+6];
strcpy(oscPathShow, oscPath);
strcat(oscPathShow, "/show");
lo_server_add_method(oscServer, oscPathShow, "", osc_show_handler, nullptr);

char oscPathHide[oscPathSize+6];
strcpy(oscPathHide, oscPath);
strcat(oscPathHide, "/hide");
lo_server_add_method(oscServer, oscPathHide, "", osc_hide_handler, nullptr);

char oscPathQuit[oscPathSize+6];
strcpy(oscPathQuit, oscPath);
strcat(oscPathQuit, "/quit");
lo_server_add_method(oscServer, oscPathQuit, "", osc_quit_handler, nullptr);

lo_server_add_method(oscServer, nullptr, nullptr, osc_debug_handler, nullptr);

gUiTitle = uiTitle;

gOscData.addr = oscAddr;
gOscData.path = oscPath;
gOscData.server = oscServer;
gOscData.send_update(pluginPath);

// wait for init
for (int i=0; i < 100; ++i)
{
lo_server_recv(oscServer);

if (d_lastUiSampleRate != 0.0 || globalUI != nullptr)
break;

d_msleep(50);
}

int ret = 1;

if (d_lastUiSampleRate != 0.0 || globalUI != nullptr)
{
initUiIfNeeded();

globalUI->exec();

delete globalUI;
globalUI = nullptr;

ret = 0;
}

#if DISTRHO_PLUGIN_WANT_STATE
lo_server_del_method(oscServer, oscPathConfigure, "ss");
#endif
lo_server_del_method(oscServer, oscPathControl, "if");
#if DISTRHO_PLUGIN_WANT_PROGRAMS
lo_server_del_method(oscServer, oscPathProgram, "ii");
#endif
lo_server_del_method(oscServer, oscPathSampleRate, "i");
lo_server_del_method(oscServer, oscPathShow, "");
lo_server_del_method(oscServer, oscPathHide, "");
lo_server_del_method(oscServer, oscPathQuit, "");
lo_server_del_method(oscServer, nullptr, nullptr);

std::free(oscServerPath);
std::free(oscHost);
std::free(oscPort);
std::free(oscPath);

lo_address_free(oscAddr);
lo_server_free(oscServer);

return ret;
}

+ 249
- 0
libs/distrho/src/DistrhoUIInternal.hpp View File

@@ -0,0 +1,249 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef DISTRHO_UI_INTERNAL_HPP_INCLUDED
#define DISTRHO_UI_INTERNAL_HPP_INCLUDED

#include "../DistrhoUI.hpp"

#include "../../dgl/App.hpp"
#include "../../dgl/Window.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Static data, see DistrhoUI.cpp

extern double d_lastUiSampleRate;

// -----------------------------------------------------------------------
// UI callbacks

typedef void (*editParamFunc) (void* ptr, uint32_t rindex, bool started);
typedef void (*setParamFunc) (void* ptr, uint32_t rindex, float value);
typedef void (*setStateFunc) (void* ptr, const char* key, const char* value);
typedef void (*sendNoteFunc) (void* ptr, uint8_t channel, uint8_t note, uint8_t velo);
typedef void (*uiResizeFunc) (void* ptr, unsigned int width, unsigned int height);

// -----------------------------------------------------------------------
// UI private data

struct UI::PrivateData {
// DSP
double sampleRate;
uint32_t parameterOffset;

// Callbacks
editParamFunc editParamCallbackFunc;
setParamFunc setParamCallbackFunc;
setStateFunc setStateCallbackFunc;
sendNoteFunc sendNoteCallbackFunc;
uiResizeFunc uiResizeCallbackFunc;
void* ptr;

PrivateData() noexcept
: sampleRate(d_lastUiSampleRate),
parameterOffset(0),
editParamCallbackFunc(nullptr),
setParamCallbackFunc(nullptr),
setStateCallbackFunc(nullptr),
sendNoteCallbackFunc(nullptr),
uiResizeCallbackFunc(nullptr),
ptr(nullptr)
{
assert(sampleRate != 0.0);

#if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
# if DISTRHO_PLUGIN_WANT_LATENCY
parameterOffset += 1;
# endif
#endif
#ifdef DISTRHO_PLUGIN_TARGET_LV2
# if (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_TIMEPOS || DISTRHO_PLUGIN_WANT_STATE)
parameterOffset += 1;
# if DISTRHO_PLUGIN_WANT_STATE
parameterOffset += 1;
# endif
# endif
#endif
}

void editParamCallback(const uint32_t rindex, const bool started)
{
if (editParamCallbackFunc != nullptr)
editParamCallbackFunc(ptr, rindex, started);
}

void setParamCallback(const uint32_t rindex, const float value)
{
if (setParamCallbackFunc != nullptr)
setParamCallbackFunc(ptr, rindex, value);
}

void setStateCallback(const char* const key, const char* const value)
{
if (setStateCallbackFunc != nullptr)
setStateCallbackFunc(ptr, key, value);
}

void sendNoteCallback(const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
if (sendNoteCallbackFunc != nullptr)
sendNoteCallbackFunc(ptr, channel, note, velocity);
}

void uiResizeCallback(const unsigned int width, const unsigned int height)
{
if (uiResizeCallbackFunc != nullptr)
uiResizeCallbackFunc(ptr, width, height);
}
};

// -----------------------------------------------------------------------
// UI exporter class

class UIExporter
{
public:
UIExporter(void* const ptr, const intptr_t winId,
const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const uiResizeFunc uiResizeCall)
: glApp(),
glWindow(glApp, winId),
fUi(createUI()),
fData((fUi != nullptr) ? fUi->pData : nullptr)
{
assert(fUi != nullptr);

if (fUi == nullptr)
return;

fData->ptr = ptr;
fData->editParamCallbackFunc = editParamCall;
fData->setParamCallbackFunc = setParamCall;
fData->setStateCallbackFunc = setStateCall;
fData->sendNoteCallbackFunc = sendNoteCall;
fData->uiResizeCallbackFunc = uiResizeCall;

glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight());
glWindow.setResizable(false);
}

~UIExporter()
{
delete fUi;
}

// -------------------------------------------------------------------

const char* getName() const noexcept
{
return (fUi != nullptr) ? fUi->d_getName() : "";
}

unsigned int getWidth() const noexcept
{
return (fUi != nullptr) ? fUi->d_getWidth() : 0;
}

unsigned int getHeight() const noexcept
{
return (fUi != nullptr) ? fUi->d_getHeight() : 0;
}

// -------------------------------------------------------------------

uint32_t getParameterOffset() const noexcept
{
return (fData != nullptr) ? fData->parameterOffset : 0;
}

// -------------------------------------------------------------------

void parameterChanged(const uint32_t index, const float value)
{
if (fUi != nullptr)
fUi->d_parameterChanged(index, value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
void programChanged(const uint32_t index)
{
if (fUi != nullptr)
fUi->d_programChanged(index);
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
void stateChanged(const char* const key, const char* const value)
{
if (fUi != nullptr)
fUi->d_stateChanged(key, value);
}
#endif

// -------------------------------------------------------------------

bool idle()
{
if (fUi != nullptr)
fUi->d_uiIdle();

glApp.idle();

return ! glApp.isQuiting();
}

void quit()
{
glWindow.close();
glApp.quit();
}

void setSize(const unsigned int width, const unsigned int height)
{
glWindow.setSize(width, height);
}

void setTitle(const char* const uiTitle)
{
glWindow.setTitle(uiTitle);
}

void setVisible(const bool yesNo)
{
glWindow.setVisible(yesNo);
}

private:
// -------------------------------------------------------------------
// DGL Application and Window for this plugin

DGL::App glApp;
DGL::Window glWindow;

// -------------------------------------------------------------------
// private members accessed by DistrhoPlugin class

UI* const fUi;
UI::PrivateData* const fData;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // DISTRHO_UI_INTERNAL_HPP_INCLUDED

+ 333
- 0
libs/distrho/src/DistrhoUILV2.cpp View File

@@ -0,0 +1,333 @@
/*
* DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "DistrhoUIInternal.hpp"

#include "lv2/atom.h"
#include "lv2/atom-util.h"
#include "lv2/options.h"
#include "lv2/ui.h"
#include "lv2/urid.h"
#include "lv2/lv2_programs.h"

#include <string>

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class UiLv2
{
public:
UiLv2(const intptr_t winId, const LV2_URID_Map* const uridMap, const LV2UI_Resize* const uiResz, const LV2UI_Touch* uiTouch, const LV2UI_Controller controller, const LV2UI_Write_Function writeFunc)
: fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback),
fUridMap(uridMap),
fUiResize(uiResz),
fUiTouch(uiTouch),
fController(controller),
fWriteFunction(writeFunc)
{
fUiResize->ui_resize(fUiResize->handle, fUI.getWidth(), fUI.getHeight());
}

// -------------------------------------------------------------------

void lv2ui_port_event(const uint32_t rindex, const uint32_t bufferSize, const uint32_t format, const void* const buffer)
{
if (format == 0)
{
const uint32_t parameterOffset(fUI.getParameterOffset());

if (rindex < parameterOffset)
return;
if (bufferSize != sizeof(float))
return;

const float value(*(const float*)buffer);
fUI.parameterChanged(rindex-parameterOffset, value);
}
else
{
//fUI.stateChanged(key, value);
}
}

// -------------------------------------------------------------------

int lv2ui_idle()
{
fUI.idle();
return 0;
}

// -------------------------------------------------------------------

#if DISTRHO_PLUGIN_WANT_PROGRAMS
void lv2ui_select_program(const uint32_t bank, const uint32_t program)
{
const uint32_t realProgram(bank * 128 + program);

fUI.programChanged(realProgram);
}
#endif

// -------------------------------------------------------------------

protected:
void editParameterValue(const uint32_t rindex, const bool started)
{
if (fUiTouch != nullptr && fUiTouch->touch != nullptr)
fUiTouch->touch(fUiTouch->handle, rindex, started);
}

void setParameterValue(const uint32_t rindex, const float value)
{
if (fWriteFunction != nullptr)
fWriteFunction(fController, rindex, sizeof(float), 0, &value);
}

void setState(const char* const key, const char* const value)
{
if (fWriteFunction == nullptr)
return;

const uint32_t eventInPortIndex(DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS);

// join key and value
std::string tmpStr;
tmpStr += std::string(key);
tmpStr += std::string("\0", 1);
tmpStr += std::string(value);

// get msg size
const size_t msgSize(tmpStr.size()+1);

// reserve atom space
const size_t atomSize(lv2_atom_pad_size(sizeof(LV2_Atom) + msgSize));
char atomBuf[atomSize];
std::memset(atomBuf, 0, atomSize);

// set atom info
LV2_Atom* const atom((LV2_Atom*)atomBuf);
atom->size = msgSize;
atom->type = fUridMap->map(fUridMap->handle, "urn:distrho:keyValueState");

// set atom data
std::memcpy(atomBuf + sizeof(LV2_Atom), tmpStr.data(), msgSize-1);

// send to DSP side
fWriteFunction(fController, eventInPortIndex, atomSize, fUridMap->map(fUridMap->handle, LV2_ATOM__eventTransfer), atom);
}

void sendNote(const uint8_t /*channel*/, const uint8_t /*note*/, const uint8_t /*velocity*/)
{
}

void uiResize(const unsigned int width, const unsigned int height)
{
fUI.setSize(width, height);
fUiResize->ui_resize(fUiResize->handle, width, height);
}

private:
UIExporter fUI;

// LV2 features
const LV2_URID_Map* const fUridMap;
const LV2UI_Resize* const fUiResize;
const LV2UI_Touch* const fUiTouch;

// LV2 UI stuff
const LV2UI_Controller fController;
const LV2UI_Write_Function fWriteFunction;

// -------------------------------------------------------------------
// Callbacks

#define uiPtr ((UiLv2*)ptr)

static void editParameterCallback(void* ptr, uint32_t rindex, bool started)
{
uiPtr->editParameterValue(rindex, started);
}

static void setParameterCallback(void* ptr, uint32_t rindex, float value)
{
uiPtr->setParameterValue(rindex, value);
}

static void setStateCallback(void* ptr, const char* key, const char* value)
{
uiPtr->setState(key, value);
}

static void sendNoteCallback(void* ptr, uint8_t channel, uint8_t note, uint8_t velocity)
{
uiPtr->sendNote(channel, note, velocity);
}

static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height)
{
uiPtr->uiResize(width, height);
}

#undef uiPtr
};

// -----------------------------------------------------------------------

static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri, const char*, LV2UI_Write_Function writeFunction, LV2UI_Controller controller, LV2UI_Widget* widget, const LV2_Feature* const* features)
{
if (uri == nullptr || std::strcmp(uri, DISTRHO_PLUGIN_URI) != 0)
{
d_stderr("Invalid plugin URI");
return nullptr;
}

const LV2_Options_Option* options = nullptr;
const LV2_URID_Map* uridMap = nullptr;
const LV2UI_Resize* uiResize = nullptr;
const LV2UI_Touch* uiTouch = nullptr;
void* parentId = nullptr;

for (int i=0; features[i] != nullptr; ++i)
{
if (std::strcmp(features[i]->URI, LV2_OPTIONS__options) == 0)
options = (const LV2_Options_Option*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_URID__map) == 0)
uridMap = (const LV2_URID_Map*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_UI__resize) == 0)
uiResize = (const LV2UI_Resize*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_UI__parent) == 0)
parentId = features[i]->data;
}

if (options == nullptr)
{
d_stderr("Options feature missing, cannot continue!");
return nullptr;
}

if (uridMap == nullptr)
{
d_stderr("URID Map feature missing, cannot continue!");
return nullptr;
}

if (uiResize == nullptr)
{
d_stderr("UI Resize feature missing, cannot continue!");
return nullptr;
}

if (parentId == nullptr)
{
d_stderr("Parent Window Id missing, cannot continue!");
return nullptr;
}

*widget = parentId;

const intptr_t winId(*((intptr_t*)&parentId));

for (int i=0; options[i].key != 0; ++i)
{
if (options[i].key == uridMap->map(uridMap->handle, LV2_CORE__sampleRate))
{
if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Double))
d_lastUiSampleRate = *(const double*)options[i].value;
else
d_stderr("Host provides sampleRate but has wrong value type");

break;
}
}

if (d_lastUiSampleRate == 0.0)
d_lastUiSampleRate = 44100.0;

return new UiLv2(winId, uridMap, uiResize, uiTouch, controller, writeFunction);
}

#define uiPtr ((UiLv2*)ui)

static void lv2ui_cleanup(LV2UI_Handle ui)
{
delete uiPtr;
}

static void lv2ui_port_event(LV2UI_Handle ui, uint32_t portIndex, uint32_t bufferSize, uint32_t format, const void* buffer)
{
uiPtr->lv2ui_port_event(portIndex, bufferSize, format, buffer);
}

// -----------------------------------------------------------------------

static int lv2ui_idle(LV2UI_Handle ui)
{
return uiPtr->lv2ui_idle();
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
static void lv2ui_select_program(LV2UI_Handle ui, uint32_t bank, uint32_t program)
{
uiPtr->lv2ui_select_program(bank, program);
}
#endif

// -----------------------------------------------------------------------

static const void* lv2ui_extension_data(const char* uri)
{
static const LV2UI_Idle_Interface uiIdle = { lv2ui_idle };

if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
return &uiIdle;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
static const LV2_Programs_UI_Interface uiPrograms = { lv2ui_select_program };

if (std::strcmp(uri, LV2_PROGRAMS__UIInterface) == 0)
return &uiPrograms;
#endif

return nullptr;
}

#undef instancePtr

// -----------------------------------------------------------------------

static const LV2UI_Descriptor sLv2UiDescriptor = {
DISTRHO_UI_URI,
lv2ui_instantiate,
lv2ui_cleanup,
lv2ui_port_event,
lv2ui_extension_data
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

DISTRHO_PLUGIN_EXPORT
const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index)
{
USE_NAMESPACE_DISTRHO
return (index == 0) ? &sLv2UiDescriptor : nullptr;
}

// -----------------------------------------------------------------------

+ 441
- 0
libs/distrho/src/dssi/dssi.h View File

@@ -0,0 +1,441 @@
/* -*- c-basic-offset: 4 -*- */

/* dssi.h

DSSI version 1.0
Copyright (c) 2004, 2009 Chris Cannam, Steve Harris and Sean Bolton
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/

#ifndef DSSI_INCLUDED
#define DSSI_INCLUDED

#include "../ladspa/ladspa.h"
#include "seq_event-compat.h"

#define DSSI_VERSION "1.0"
#define DSSI_VERSION_MAJOR 1
#define DSSI_VERSION_MINOR 0

#ifdef __cplusplus
extern "C" {
#endif

/*
There is a need for an API that supports hosted MIDI soft synths
with GUIs in Linux audio applications. In time the GMPI initiative
should comprehensively address this need, but the requirement for
Linux applications to be able to support simple hosted synths is
here now, and GMPI is not. This proposal (the "DSSI Soft Synth
Interface" or DSSI, pronounced "dizzy") aims to provide a simple
solution in a way that we hope will prove complete and compelling
enough to support now, yet not so compelling as to supplant GMPI or
any other comprehensive future proposal.

For simplicity and familiarity, this API is based as far as
possible on existing work -- the LADSPA plugin API for control
values and audio processing, and the ALSA sequencer event types for
MIDI event communication. The GUI part of the proposal is quite
new, but may also be applicable retroactively to LADSPA plugins
that do not otherwise support this synth interface.
*/

typedef struct _DSSI_Program_Descriptor {

/** Bank number for this program. Note that DSSI does not support
MIDI-style separation of bank LSB and MSB values. There is no
restriction on the set of available banks: the numbers do not
need to be contiguous, there does not need to be a bank 0, etc. */
unsigned long Bank;

/** Program number (unique within its bank) for this program.
There is no restriction on the set of available programs: the
numbers do not need to be contiguous, there does not need to
be a program 0, etc. */
unsigned long Program;

/** Name of the program. */
const char * Name;

} DSSI_Program_Descriptor;


typedef struct _DSSI_Descriptor {

/**
* DSSI_API_Version
*
* This member indicates the DSSI API level used by this plugin.
* If we're lucky, this will never be needed. For now all plugins
* must set it to 1.
*/
int DSSI_API_Version;

/**
* LADSPA_Plugin
*
* A DSSI synth plugin consists of a LADSPA plugin plus an
* additional framework for controlling program settings and
* transmitting MIDI events. A plugin must fully implement the
* LADSPA descriptor fields as well as the required LADSPA
* functions including instantiate() and (de)activate(). It
* should also implement run(), with the same behaviour as if
* run_synth() (below) were called with no synth events.
*
* In order to instantiate a synth the host calls the LADSPA
* instantiate function, passing in this LADSPA_Descriptor
* pointer. The returned LADSPA_Handle is used as the argument
* for the DSSI functions below as well as for the LADSPA ones.
*/
const LADSPA_Descriptor *LADSPA_Plugin;

/**
* configure()
*
* This member is a function pointer that sends a piece of
* configuration data to the plugin. The key argument specifies
* some aspect of the synth's configuration that is to be changed,
* and the value argument specifies a new value for it. A plugin
* that does not require this facility at all may set this member
* to NULL.
*
* This call is intended to set some session-scoped aspect of a
* plugin's behaviour, for example to tell the plugin to load
* sample data from a particular file. The plugin should act
* immediately on the request. The call should return NULL on
* success, or an error string that may be shown to the user. The
* host will free the returned value after use if it is non-NULL.
*
* Calls to configure() are not automated as timed events.
* Instead, a host should remember the last value associated with
* each key passed to configure() during a given session for a
* given plugin instance, and should call configure() with the
* correct value for each key the next time it instantiates the
* "same" plugin instance, for example on reloading a project in
* which the plugin was used before. Plugins should note that a
* host may typically instantiate a plugin multiple times with the
* same configuration values, and should share data between
* instances where practical.
*
* Calling configure() completely invalidates the program and bank
* information last obtained from the plugin.
*
* Reserved and special key prefixes
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* The DSSI: prefix
* ----------------
* Configure keys starting with DSSI: are reserved for particular
* purposes documented in the DSSI specification. At the moment,
* there is one such key: DSSI:PROJECT_DIRECTORY. A host may call
* configure() passing this key and a directory path value. This
* indicates to the plugin and its UI that a directory at that
* path exists and may be used for project-local data. Plugins
* may wish to use the project directory as a fallback location
* when looking for other file data, or as a base for relative
* paths in other configuration values.
*
* The GLOBAL: prefix
* ------------------
* Configure keys starting with GLOBAL: may be used by the plugin
* and its UI for any purpose, but are treated specially by the
* host. When one of these keys is used in a configure OSC call
* from the plugin UI, the host makes the corresponding configure
* call (preserving the GLOBAL: prefix) not only to the target
* plugin but also to all other plugins in the same instance
* group, as well as their UIs. Note that if any instance
* returns non-NULL from configure to indicate error, the host
* may stop there (and the set of plugins on which configure has
* been called will thus depend on the host implementation).
* See also the configure OSC call documentation in RFC.txt.
*/
char *(*configure)(LADSPA_Handle Instance,
const char *Key,
const char *Value);

#define DSSI_RESERVED_CONFIGURE_PREFIX "DSSI:"
#define DSSI_GLOBAL_CONFIGURE_PREFIX "GLOBAL:"
#define DSSI_PROJECT_DIRECTORY_KEY \
DSSI_RESERVED_CONFIGURE_PREFIX "PROJECT_DIRECTORY"

/**
* get_program()
*
* This member is a function pointer that provides a description
* of a program (named preset sound) available on this synth. A
* plugin that does not support programs at all should set this
* member to NULL.
*
* The Index argument is an index into the plugin's list of
* programs, not a program number as represented by the Program
* field of the DSSI_Program_Descriptor. (This distinction is
* needed to support synths that use non-contiguous program or
* bank numbers.)
*
* This function returns a DSSI_Program_Descriptor pointer that is
* guaranteed to be valid only until the next call to get_program,
* deactivate, or configure, on the same plugin instance. This
* function must return NULL if passed an Index argument out of
* range, so that the host can use it to query the number of
* programs as well as their properties.
*/
const DSSI_Program_Descriptor *(*get_program)(LADSPA_Handle Instance,
unsigned long Index);
/**
* select_program()
*
* This member is a function pointer that selects a new program
* for this synth. The program change should take effect
* immediately at the start of the next run_synth() call. (This
* means that a host providing the capability of changing programs
* between any two notes on a track must vary the block size so as
* to place the program change at the right place. A host that
* wanted to avoid this would probably just instantiate a plugin
* for each program.)
*
* A plugin that does not support programs at all should set this
* member NULL. Plugins should ignore a select_program() call
* with an invalid bank or program.
*
* A plugin is not required to select any particular default
* program on activate(): it's the host's duty to set a program
* explicitly. The current program is invalidated by any call to
* configure().
*
* A plugin is permitted to re-write the values of its input
* control ports when select_program is called. The host should
* re-read the input control port values and update its own
* records appropriately. (This is the only circumstance in
* which a DSSI plugin is allowed to modify its own input ports.)
*/
void (*select_program)(LADSPA_Handle Instance,
unsigned long Bank,
unsigned long Program);

/**
* get_midi_controller_for_port()
*
* This member is a function pointer that returns the MIDI
* controller number or NRPN that should be mapped to the given
* input control port. If the given port should not have any MIDI
* controller mapped to it, the function should return DSSI_NONE.
* The behaviour of this function is undefined if the given port
* number does not correspond to an input control port. A plugin
* that does not want MIDI controllers mapped to ports at all may
* set this member NULL.
*
* Correct values can be got using the macros DSSI_CC(num) and
* DSSI_NRPN(num) as appropriate, and values can be combined using
* bitwise OR: e.g. DSSI_CC(23) | DSSI_NRPN(1069) means the port
* should respond to CC #23 and NRPN #1069.
*
* The host is responsible for doing proper scaling from MIDI
* controller and NRPN value ranges to port ranges according to
* the plugin's LADSPA port hints. Hosts should not deliver
* through run_synth any MIDI controller events that have already
* been mapped to control port values.
*
* A plugin should not attempt to request mappings from
* controllers 0 or 32 (MIDI Bank Select MSB and LSB).
*/
int (*get_midi_controller_for_port)(LADSPA_Handle Instance,
unsigned long Port);

/**
* run_synth()
*
* This member is a function pointer that runs a synth for a
* block. This is identical in function to the LADSPA run()
* function, except that it also supplies events to the synth.
*
* A plugin may provide this function, run_multiple_synths() (see
* below), both, or neither (if it is not in fact a synth). A
* plugin that does not provide this function must set this member
* to NULL. Authors of synth plugins are encouraged to provide
* this function if at all possible.
*
* The Events pointer points to a block of EventCount ALSA
* sequencer events, which is used to communicate MIDI and related
* events to the synth. Each event is timestamped relative to the
* start of the block, (mis)using the ALSA "tick time" field as a
* frame count. The host is responsible for ensuring that events
* with differing timestamps are already ordered by time.
*
* See also the notes on activation, port connection etc in
* ladpsa.h, in the context of the LADSPA run() function.
*
* Note Events
* ~~~~~~~~~~~
* There are two minor requirements aimed at making the plugin
* writer's life as simple as possible:
*
* 1. A host must never send events of type SND_SEQ_EVENT_NOTE.
* Notes should always be sent as separate SND_SEQ_EVENT_NOTE_ON
* and NOTE_OFF events. A plugin should discard any one-point
* NOTE events it sees.
*
* 2. A host must not attempt to switch notes off by sending
* zero-velocity NOTE_ON events. It should always send true
* NOTE_OFFs. It is the host's responsibility to remap events in
* cases where an external MIDI source has sent it zero-velocity
* NOTE_ONs.
*
* Bank and Program Events
* ~~~~~~~~~~~~~~~~~~~~~~~
* Hosts must map MIDI Bank Select MSB and LSB (0 and 32)
* controllers and MIDI Program Change events onto the banks and
* programs specified by the plugin, using the DSSI select_program
* call. No host should ever deliver a program change or bank
* select controller to a plugin via run_synth.
*/
void (*run_synth)(LADSPA_Handle Instance,
unsigned long SampleCount,
snd_seq_event_t *Events,
unsigned long EventCount);

/**
* run_synth_adding()
*
* This member is a function pointer that runs an instance of a
* synth for a block, adding its outputs to the values already
* present at the output ports. This is provided for symmetry
* with LADSPA run_adding(), and is equally optional. A plugin
* that does not provide it must set this member to NULL.
*/
void (*run_synth_adding)(LADSPA_Handle Instance,
unsigned long SampleCount,
snd_seq_event_t *Events,
unsigned long EventCount);

/**
* run_multiple_synths()
*
* This member is a function pointer that runs multiple synth
* instances for a block. This is very similar to run_synth(),
* except that Instances, Events, and EventCounts each point to
* arrays that hold the LADSPA handles, event buffers, and
* event counts for each of InstanceCount instances. That is,
* Instances points to an array of InstanceCount pointers to
* DSSI plugin instantiations, Events points to an array of
* pointers to each instantiation's respective event list, and
* EventCounts points to an array containing each instantiation's
* respective event count.
*
* A host using this function must guarantee that ALL active
* instances of the plugin are represented in each call to the
* function -- that is, a host may not call run_multiple_synths()
* for some instances of a given plugin and then call run_synth()
* as well for others. 'All .. instances of the plugin' means
* every instance sharing the same LADSPA label and shared object
* (*.so) file (rather than every instance sharing the same *.so).
* 'Active' means any instance for which activate() has been called
* but deactivate() has not.
*
* A plugin may provide this function, run_synths() (see above),
* both, or neither (if it not in fact a synth). A plugin that
* does not provide this function must set this member to NULL.
* Plugin authors implementing run_multiple_synths are strongly
* encouraged to implement run_synth as well if at all possible,
* to aid simplistic hosts, even where it would be less efficient
* to use it.
*/
void (*run_multiple_synths)(unsigned long InstanceCount,
LADSPA_Handle *Instances,
unsigned long SampleCount,
snd_seq_event_t **Events,
unsigned long *EventCounts);

/**
* run_multiple_synths_adding()
*
* This member is a function pointer that runs multiple synth
* instances for a block, adding each synth's outputs to the
* values already present at the output ports. This is provided
* for symmetry with both the DSSI run_multiple_synths() and LADSPA
* run_adding() functions, and is equally optional. A plugin
* that does not provide it must set this member to NULL.
*/
void (*run_multiple_synths_adding)(unsigned long InstanceCount,
LADSPA_Handle *Instances,
unsigned long SampleCount,
snd_seq_event_t **Events,
unsigned long *EventCounts);

/**
* set_custom_data()
*/
int (*set_custom_data)(LADSPA_Handle Instance,
void *Data,
unsigned long DataLength);

/**
* get_custom_data()
*/
int (*get_custom_data)(LADSPA_Handle Instance,
void **Data,
unsigned long *DataLength);

} DSSI_Descriptor;

/**
* DSSI supports a plugin discovery method similar to that of LADSPA:
*
* - DSSI hosts may wish to locate DSSI plugin shared object files by
* searching the paths contained in the DSSI_PATH and LADSPA_PATH
* environment variables, if they are present. Both are expected
* to be colon-separated lists of directories to be searched (in
* order), and DSSI_PATH should be searched first if both variables
* are set.
*
* - Each shared object file containing DSSI plugins must include a
* function dssi_descriptor(), with the following function prototype
* and C-style linkage. Hosts may enumerate the plugin types
* available in the shared object file by repeatedly calling
* this function with successive Index values (beginning from 0),
* until a return value of NULL indicates no more plugin types are
* available. Each non-NULL return is the DSSI_Descriptor
* of a distinct plugin type.
*/

const DSSI_Descriptor *dssi_descriptor(unsigned long Index);
typedef const DSSI_Descriptor *(*DSSI_Descriptor_Function)(unsigned long Index);

/*
* Macros to specify particular MIDI controllers in return values from
* get_midi_controller_for_port()
*/

#define DSSI_CC_BITS 0x20000000
#define DSSI_NRPN_BITS 0x40000000

#define DSSI_NONE -1
#define DSSI_CONTROLLER_IS_SET(n) (DSSI_NONE != (n))

#define DSSI_CC(n) (DSSI_CC_BITS | (n))
#define DSSI_IS_CC(n) (DSSI_CC_BITS & (n))
#define DSSI_CC_NUMBER(n) ((n) & 0x7f)

#define DSSI_NRPN(n) (DSSI_NRPN_BITS | ((n) << 7))
#define DSSI_IS_NRPN(n) (DSSI_NRPN_BITS & (n))
#define DSSI_NRPN_NUMBER(n) (((n) >> 7) & 0x3fff)

#ifdef __cplusplus
}
#endif

#endif /* DSSI_INCLUDED */

+ 272
- 0
libs/distrho/src/dssi/seq_event-compat.h View File

@@ -0,0 +1,272 @@
/*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/

#ifndef __ALSA_SEQ_EVENT_COMPAT_H
#define __ALSA_SEQ_EVENT_COMPAT_H

/**
* Sequencer event data type
*/
typedef unsigned char snd_seq_event_type_t;

/** Sequencer event type */
enum snd_seq_event_type {
/** system status; event data type = #snd_seq_result_t */
SND_SEQ_EVENT_SYSTEM = 0,
/** returned result status; event data type = #snd_seq_result_t */
SND_SEQ_EVENT_RESULT,

/** note on and off with duration; event data type = #snd_seq_ev_note_t */
SND_SEQ_EVENT_NOTE = 5,
/** note on; event data type = #snd_seq_ev_note_t */
SND_SEQ_EVENT_NOTEON,
/** note off; event data type = #snd_seq_ev_note_t */
SND_SEQ_EVENT_NOTEOFF,
/** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
SND_SEQ_EVENT_KEYPRESS,

/** controller; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_CONTROLLER = 10,
/** program change; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_PGMCHANGE,
/** channel pressure; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_CHANPRESS,
/** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
SND_SEQ_EVENT_PITCHBEND,
/** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_CONTROL14,
/** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_NONREGPARAM,
/** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_REGPARAM,

/** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_SONGPOS = 20,
/** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_SONGSEL,
/** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_QFRAME,
/** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_TIMESIGN,
/** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
SND_SEQ_EVENT_KEYSIGN,

/** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_START = 30,
/** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_CONTINUE,
/** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_STOP,
/** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_SETPOS_TICK,
/** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_SETPOS_TIME,
/** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_TEMPO,
/** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_CLOCK,
/** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_TICK,
/** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_QUEUE_SKEW,
/** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
SND_SEQ_EVENT_SYNC_POS,

/** Tune request; event data type = none */
SND_SEQ_EVENT_TUNE_REQUEST = 40,
/** Reset to power-on state; event data type = none */
SND_SEQ_EVENT_RESET,
/** Active sensing event; event data type = none */
SND_SEQ_EVENT_SENSING,

/** Echo-back event; event data type = any type */
SND_SEQ_EVENT_ECHO = 50,
/** OSS emulation raw event; event data type = any type */
SND_SEQ_EVENT_OSS,

/** New client has connected; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_CLIENT_START = 60,
/** Client has left the system; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_CLIENT_EXIT,
/** Client status/info has changed; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_CLIENT_CHANGE,
/** New port was created; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_PORT_START,
/** Port was deleted from system; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_PORT_EXIT,
/** Port status/info has changed; event data type = #snd_seq_addr_t */
SND_SEQ_EVENT_PORT_CHANGE,

/** Ports connected; event data type = #snd_seq_connect_t */
SND_SEQ_EVENT_PORT_SUBSCRIBED,
/** Ports disconnected; event data type = #snd_seq_connect_t */
SND_SEQ_EVENT_PORT_UNSUBSCRIBED,

/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR0 = 90,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR1,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR2,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR3,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR4,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR5,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR6,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR7,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR8,
/** user-defined event; event data type = any (fixed size) */
SND_SEQ_EVENT_USR9,

/** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_SYSEX = 130,
/** error event; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_BOUNCE,
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_USR_VAR0 = 135,
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_USR_VAR1,
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_USR_VAR2,
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_USR_VAR3,
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
SND_SEQ_EVENT_USR_VAR4,

/** NOP; ignored in any case */
SND_SEQ_EVENT_NONE = 255
};

/** Sequencer event address */
typedef struct snd_seq_addr {
unsigned char client; /**< Client id */
unsigned char port; /**< Port id */
} snd_seq_addr_t;

/** Connection (subscription) between ports */
typedef struct snd_seq_connect {
snd_seq_addr_t sender; /**< sender address */
snd_seq_addr_t dest; /**< destination address */
} snd_seq_connect_t;

/** Real-time data record */
typedef struct snd_seq_real_time {
unsigned int tv_sec; /**< seconds */
unsigned int tv_nsec; /**< nanoseconds */
} snd_seq_real_time_t;

/** (MIDI) Tick-time data record */
typedef unsigned int snd_seq_tick_time_t;

/** unioned time stamp */
typedef union snd_seq_timestamp {
snd_seq_tick_time_t tick; /**< tick-time */
struct snd_seq_real_time time; /**< real-time */
} snd_seq_timestamp_t;

/** Note event */
typedef struct snd_seq_ev_note {
unsigned char channel; /**< channel number */
unsigned char note; /**< note */
unsigned char velocity; /**< velocity */
unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
} snd_seq_ev_note_t;

/** Controller event */
typedef struct snd_seq_ev_ctrl {
unsigned char channel; /**< channel number */
unsigned char unused[3]; /**< reserved */
unsigned int param; /**< control parameter */
signed int value; /**< control value */
} snd_seq_ev_ctrl_t;

/** generic set of bytes (12x8 bit) */
typedef struct snd_seq_ev_raw8 {
unsigned char d[12]; /**< 8 bit value */
} snd_seq_ev_raw8_t;

/** generic set of integers (3x32 bit) */
typedef struct snd_seq_ev_raw32 {
unsigned int d[3]; /**< 32 bit value */
} snd_seq_ev_raw32_t;

/** external stored data */
typedef struct snd_seq_ev_ext {
unsigned int len; /**< length of data */
void *ptr; /**< pointer to data (note: can be 64-bit) */
} __attribute__((packed)) snd_seq_ev_ext_t;

/** Result events */
typedef struct snd_seq_result {
int event; /**< processed event type */
int result; /**< status */
} snd_seq_result_t;

/** Queue skew values */
typedef struct snd_seq_queue_skew {
unsigned int value; /**< skew value */
unsigned int base; /**< skew base */
} snd_seq_queue_skew_t;

/** queue timer control */
typedef struct snd_seq_ev_queue_control {
unsigned char queue; /**< affected queue */
unsigned char unused[3]; /**< reserved */
union {
signed int value; /**< affected value (e.g. tempo) */
snd_seq_timestamp_t time; /**< time */
unsigned int position; /**< sync position */
snd_seq_queue_skew_t skew; /**< queue skew */
unsigned int d32[2]; /**< any data */
unsigned char d8[8]; /**< any data */
} param; /**< data value union */
} snd_seq_ev_queue_control_t;

/** Sequencer event */
typedef struct snd_seq_event {
snd_seq_event_type_t type; /**< event type */
unsigned char flags; /**< event flags */
unsigned char tag; /**< tag */

unsigned char queue; /**< schedule queue */
snd_seq_timestamp_t time; /**< schedule time */

snd_seq_addr_t source; /**< source address */
snd_seq_addr_t dest; /**< destination address */

union {
snd_seq_ev_note_t note; /**< note information */
snd_seq_ev_ctrl_t control; /**< MIDI control information */
snd_seq_ev_raw8_t raw8; /**< raw8 data */
snd_seq_ev_raw32_t raw32; /**< raw32 data */
snd_seq_ev_ext_t ext; /**< external data */
snd_seq_ev_queue_control_t queue; /**< queue control */
snd_seq_timestamp_t time; /**< timestamp */
snd_seq_addr_t addr; /**< address */
snd_seq_connect_t connect; /**< connect information */
snd_seq_result_t result; /**< operation result code */
} data; /**< event data... */
} snd_seq_event_t;

#endif /* __ALSA_SEQ_EVENT_COMPAT_H */


+ 603
- 0
libs/distrho/src/ladspa/ladspa.h View File

@@ -0,0 +1,603 @@
/* ladspa.h

Linux Audio Developer's Simple Plugin API Version 1.1[LGPL].
Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
Stefan Westerfeld.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */

#ifndef LADSPA_INCLUDED
#define LADSPA_INCLUDED

#define LADSPA_VERSION "1.1"
#define LADSPA_VERSION_MAJOR 1
#define LADSPA_VERSION_MINOR 1

#ifdef __cplusplus
extern "C" {
#endif

/*****************************************************************************/

/* Overview:

There is a large number of synthesis packages in use or development
on the Linux platform at this time. This API (`The Linux Audio
Developer's Simple Plugin API') attempts to give programmers the
ability to write simple `plugin' audio processors in C/C++ and link
them dynamically (`plug') into a range of these packages (`hosts').
It should be possible for any host and any plugin to communicate
completely through this interface.

This API is deliberately short and simple. To achieve compatibility
with a range of promising Linux sound synthesis packages it
attempts to find the `greatest common divisor' in their logical
behaviour. Having said this, certain limiting decisions are
implicit, notably the use of a fixed type (LADSPA_Data) for all
data transfer and absence of a parameterised `initialisation'
phase. See below for the LADSPA_Data typedef.

Plugins are expected to distinguish between control and audio
data. Plugins have `ports' that are inputs or outputs for audio or
control data and each plugin is `run' for a `block' corresponding
to a short time interval measured in samples. Audio data is
communicated using arrays of LADSPA_Data, allowing a block of audio
to be processed by the plugin in a single pass. Control data is
communicated using single LADSPA_Data values. Control data has a
single value at the start of a call to the `run()' or `run_adding()'
function, and may be considered to remain this value for its
duration. The plugin may assume that all its input and output ports
have been connected to the relevant data location (see the
`connect_port()' function below) before it is asked to run.

Plugins will reside in shared object files suitable for dynamic
linking by dlopen() and family. The file will provide a number of
`plugin types' that can be used to instantiate actual plugins
(sometimes known as `plugin instances') that can be connected
together to perform tasks.

This API contains very limited error-handling. */

/*****************************************************************************/

/* Fundamental data type passed in and out of plugin. This data type
is used to communicate audio samples and control values. It is
assumed that the plugin will work sensibly given any numeric input
value although it may have a preferred range (see hints below).

For audio it is generally assumed that 1.0f is the `0dB' reference
amplitude and is a `normal' signal level. */

typedef float LADSPA_Data;

/*****************************************************************************/

/* Special Plugin Properties:
Optional features of the plugin type are encapsulated in the
LADSPA_Properties type. This is assembled by ORing individual
properties together. */

typedef int LADSPA_Properties;

/* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a
real-time dependency (e.g. listens to a MIDI device) and so its
output must not be cached or subject to significant latency. */
#define LADSPA_PROPERTY_REALTIME 0x1

/* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin
may cease to work correctly if the host elects to use the same data
location for both input and output (see connect_port()). This
should be avoided as enabling this flag makes it impossible for
hosts to use the plugin to process audio `in-place.' */
#define LADSPA_PROPERTY_INPLACE_BROKEN 0x2

/* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin
is capable of running not only in a conventional host but also in a
`hard real-time' environment. To qualify for this the plugin must
satisfy all of the following:

(1) The plugin must not use malloc(), free() or other heap memory
management within its run() or run_adding() functions. All new
memory used in run() must be managed via the stack. These
restrictions only apply to the run() function.

(2) The plugin will not attempt to make use of any library
functions with the exceptions of functions in the ANSI standard C
and C maths libraries, which the host is expected to provide.

(3) The plugin will not access files, devices, pipes, sockets, IPC
or any other mechanism that might result in process or thread
blocking.
(4) The plugin will take an amount of time to execute a run() or
run_adding() call approximately of form (A+B*SampleCount) where A
and B depend on the machine and host in use. This amount of time
may not depend on input signals or plugin state. The host is left
the responsibility to perform timings to estimate upper bounds for
A and B. */
#define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4

#define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME)
#define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN)
#define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE)

/*****************************************************************************/

/* Plugin Ports:

Plugins have `ports' that are inputs or outputs for audio or
data. Ports can communicate arrays of LADSPA_Data (for audio
inputs/outputs) or single LADSPA_Data values (for control
input/outputs). This information is encapsulated in the
LADSPA_PortDescriptor type which is assembled by ORing individual
properties together.

Note that a port must be an input or an output port but not both
and that a port must be a control or audio port but not both. */

typedef int LADSPA_PortDescriptor;

/* Property LADSPA_PORT_INPUT indicates that the port is an input. */
#define LADSPA_PORT_INPUT 0x1

/* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */
#define LADSPA_PORT_OUTPUT 0x2

/* Property LADSPA_PORT_CONTROL indicates that the port is a control
port. */
#define LADSPA_PORT_CONTROL 0x4

/* Property LADSPA_PORT_AUDIO indicates that the port is a audio
port. */
#define LADSPA_PORT_AUDIO 0x8

#define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT)
#define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT)
#define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL)
#define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO)

/*****************************************************************************/

/* Plugin Port Range Hints:

The host may wish to provide a representation of data entering or
leaving a plugin (e.g. to generate a GUI automatically). To make
this more meaningful, the plugin should provide `hints' to the host
describing the usual values taken by the data.
Note that these are only hints. The host may ignore them and the
plugin must not assume that data supplied to it is meaningful. If
the plugin receives invalid input data it is expected to continue
to run without failure and, where possible, produce a sensible
output (e.g. a high-pass filter given a negative cutoff frequency
might switch to an all-pass mode).
Hints are meaningful for all input and output ports but hints for
input control ports are expected to be particularly useful.
More hint information is encapsulated in the
LADSPA_PortRangeHintDescriptor type which is assembled by ORing
individual hint types together. Hints may require further
LowerBound and UpperBound information.

All the hint information for a particular port is aggregated in the
LADSPA_PortRangeHint structure. */

typedef int LADSPA_PortRangeHintDescriptor;

/* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field
of the LADSPA_PortRangeHint should be considered meaningful. The
value in this field should be considered the (inclusive) lower
bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
specified then the value of LowerBound should be multiplied by the
sample rate. */
#define LADSPA_HINT_BOUNDED_BELOW 0x1

/* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field
of the LADSPA_PortRangeHint should be considered meaningful. The
value in this field should be considered the (inclusive) upper
bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
specified then the value of UpperBound should be multiplied by the
sample rate. */
#define LADSPA_HINT_BOUNDED_ABOVE 0x2

/* Hint LADSPA_HINT_TOGGLED indicates that the data item should be
considered a Boolean toggle. Data less than or equal to zero should
be considered `off' or `false,' and data above zero should be
considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in
conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or
LADSPA_HINT_DEFAULT_1. */
#define LADSPA_HINT_TOGGLED 0x4

/* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified
should be interpreted as multiples of the sample rate. For
instance, a frequency range from 0Hz to the Nyquist frequency (half
the sample rate) could be requested by this hint in conjunction
with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds
at all must support this hint to retain meaning. */
#define LADSPA_HINT_SAMPLE_RATE 0x8

/* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the
user will find it more intuitive to view values using a logarithmic
scale. This is particularly useful for frequencies and gains. */
#define LADSPA_HINT_LOGARITHMIC 0x10

/* Hint LADSPA_HINT_INTEGER indicates that a user interface would
probably wish to provide a stepped control taking only integer
values. Any bounds set should be slightly wider than the actual
integer range required to avoid floating point rounding errors. For
instance, the integer set {0,1,2,3} might be described as [-0.1,
3.1]. */
#define LADSPA_HINT_INTEGER 0x20

/* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal'
value for the port that is sensible as a default. For instance,
this value is suitable for use as an initial value in a user
interface or as a value the host might assign to a control port
when the user has not provided one. Defaults are encoded using a
mask so only one default may be specified for a port. Some of the
hints make use of lower and upper bounds, in which case the
relevant bound or bounds must be available and
LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting
default must be rounded if LADSPA_HINT_INTEGER is present. Default
values were introduced in LADSPA v1.1. */
#define LADSPA_HINT_DEFAULT_MASK 0x3C0

/* This default values indicates that no default is provided. */
#define LADSPA_HINT_DEFAULT_NONE 0x0

/* This default hint indicates that the suggested lower bound for the
port should be used. */
#define LADSPA_HINT_DEFAULT_MINIMUM 0x40

/* This default hint indicates that a low value between the suggested
lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 +
log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper
* 0.25). */
#define LADSPA_HINT_DEFAULT_LOW 0x80

/* This default hint indicates that a middle value between the
suggested lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 +
log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper *
0.5). */
#define LADSPA_HINT_DEFAULT_MIDDLE 0xC0

/* This default hint indicates that a high value between the suggested
lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 +
log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper
* 0.75). */
#define LADSPA_HINT_DEFAULT_HIGH 0x100

/* This default hint indicates that the suggested upper bound for the
port should be used. */
#define LADSPA_HINT_DEFAULT_MAXIMUM 0x140

/* This default hint indicates that the number 0 should be used. Note
that this default may be used in conjunction with
LADSPA_HINT_TOGGLED. */
#define LADSPA_HINT_DEFAULT_0 0x200

/* This default hint indicates that the number 1 should be used. Note
that this default may be used in conjunction with
LADSPA_HINT_TOGGLED. */
#define LADSPA_HINT_DEFAULT_1 0x240

/* This default hint indicates that the number 100 should be used. */
#define LADSPA_HINT_DEFAULT_100 0x280

/* This default hint indicates that the Hz frequency of `concert A'
should be used. This will be 440 unless the host uses an unusual
tuning convention, in which case it may be within a few Hz. */
#define LADSPA_HINT_DEFAULT_440 0x2C0

#define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW)
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE)
#define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED)
#define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE)
#define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC)
#define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER)

#define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK)
#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MINIMUM)
#define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_LOW)
#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MIDDLE)
#define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_HIGH)
#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MAXIMUM)
#define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_0)
#define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_1)
#define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_100)
#define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_440)

typedef struct _LADSPA_PortRangeHint {

/* Hints about the port. */
LADSPA_PortRangeHintDescriptor HintDescriptor;

/* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When
LADSPA_HINT_SAMPLE_RATE is also active then this value should be
multiplied by the relevant sample rate. */
LADSPA_Data LowerBound;

/* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When
LADSPA_HINT_SAMPLE_RATE is also active then this value should be
multiplied by the relevant sample rate. */
LADSPA_Data UpperBound;

} LADSPA_PortRangeHint;

/*****************************************************************************/

/* Plugin Handles:

This plugin handle indicates a particular instance of the plugin
concerned. It is valid to compare this to NULL (0 for C++) but
otherwise the host should not attempt to interpret it. The plugin
may use it to reference internal instance data. */

typedef void * LADSPA_Handle;

/*****************************************************************************/

/* Descriptor for a Type of Plugin:

This structure is used to describe a plugin type. It provides a
number of functions to examine the type, instantiate it, link it to
buffers and workspaces and to run it. */

typedef struct _LADSPA_Descriptor {

/* This numeric identifier indicates the plugin type
uniquely. Plugin programmers may reserve ranges of IDs from a
central body to avoid clashes. Hosts may assume that IDs are
below 0x1000000. */
unsigned long UniqueID;

/* This identifier can be used as a unique, case-sensitive
identifier for the plugin type within the plugin file. Plugin
types should be identified by file and label rather than by index
or plugin name, which may be changed in new plugin
versions. Labels must not contain white-space characters. */
const char * Label;

/* This indicates a number of properties of the plugin. */
LADSPA_Properties Properties;

/* This member points to the null-terminated name of the plugin
(e.g. "Sine Oscillator"). */
const char * Name;

/* This member points to the null-terminated string indicating the
maker of the plugin. This can be an empty string but not NULL. */
const char * Maker;

/* This member points to the null-terminated string indicating any
copyright applying to the plugin. If no Copyright applies the
string "None" should be used. */
const char * Copyright;

/* This indicates the number of ports (input AND output) present on
the plugin. */
unsigned long PortCount;

/* This member indicates an array of port descriptors. Valid indices
vary from 0 to PortCount-1. */
const LADSPA_PortDescriptor * PortDescriptors;

/* This member indicates an array of null-terminated strings
describing ports (e.g. "Frequency (Hz)"). Valid indices vary from
0 to PortCount-1. */
const char * const * PortNames;

/* This member indicates an array of range hints for each port (see
above). Valid indices vary from 0 to PortCount-1. */
const LADSPA_PortRangeHint * PortRangeHints;

/* This may be used by the plugin developer to pass any custom
implementation data into an instantiate call. It must not be used
or interpreted by the host. It is expected that most plugin
writers will not use this facility as LADSPA_Handle should be
used to hold instance data. */
void * ImplementationData;

/* This member is a function pointer that instantiates a plugin. A
handle is returned indicating the new plugin instance. The
instantiation function accepts a sample rate as a parameter. The
plugin descriptor from which this instantiate function was found
must also be passed. This function must return NULL if
instantiation fails.

Note that instance initialisation should generally occur in
activate() rather than here. */
LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor,
unsigned long SampleRate);

/* This member is a function pointer that connects a port on an
instantiated plugin to a memory location at which a block of data
for the port will be read/written. The data location is expected
to be an array of LADSPA_Data for audio ports or a single
LADSPA_Data value for control ports. Memory issues will be
managed by the host. The plugin must read/write the data at these
locations every time run() or run_adding() is called and the data
present at the time of this connection call should not be
considered meaningful.

connect_port() may be called more than once for a plugin instance
to allow the host to change the buffers that the plugin is
reading or writing. These calls may be made before or after
activate() or deactivate() calls.

connect_port() must be called at least once for each port before
run() or run_adding() is called. When working with blocks of
LADSPA_Data the plugin should pay careful attention to the block
size passed to the run function as the block allocated may only
just be large enough to contain the block of samples.

Plugin writers should be aware that the host may elect to use the
same buffer for more than one port and even use the same buffer
for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN).
However, overlapped buffers or use of a single buffer for both
audio and control data may result in unexpected behaviour. */
void (*connect_port)(LADSPA_Handle Instance,
unsigned long Port,
LADSPA_Data * DataLocation);

/* This member is a function pointer that initialises a plugin
instance and activates it for use. This is separated from
instantiate() to aid real-time support and so that hosts can
reinitialise a plugin instance by calling deactivate() and then
activate(). In this case the plugin instance must reset all state
information dependent on the history of the plugin instance
except for any data locations provided by connect_port() and any
gain set by set_run_adding_gain(). If there is nothing for
activate() to do then the plugin writer may provide a NULL rather
than an empty function.

When present, hosts must call this function once before run() (or
run_adding()) is called for the first time. This call should be
made as close to the run() call as possible and indicates to
real-time plugins that they are now live. Plugins should not rely
on a prompt call to run() after activate(). activate() may not be
called again unless deactivate() is called first. Note that
connect_port() may be called before or after a call to
activate(). */
void (*activate)(LADSPA_Handle Instance);

/* This method is a function pointer that runs an instance of a
plugin for a block. Two parameters are required: the first is a
handle to the particular instance to be run and the second
indicates the block size (in samples) for which the plugin
instance may run.

Note that if an activate() function exists then it must be called
before run() or run_adding(). If deactivate() is called for a
plugin instance then the plugin instance may not be reused until
activate() has been called again.

If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE
then there are various things that the plugin should not do
within the run() or run_adding() functions (see above). */
void (*run)(LADSPA_Handle Instance,
unsigned long SampleCount);

/* This method is a function pointer that runs an instance of a
plugin for a block. This has identical behaviour to run() except
in the way data is output from the plugin. When run() is used,
values are written directly to the memory areas associated with
the output ports. However when run_adding() is called, values
must be added to the values already present in the memory
areas. Furthermore, output values written must be scaled by the
current gain set by set_run_adding_gain() (see below) before
addition.

run_adding() is optional. When it is not provided by a plugin,
this function pointer must be set to NULL. When it is provided,
the function set_run_adding_gain() must be provided also. */
void (*run_adding)(LADSPA_Handle Instance,
unsigned long SampleCount);

/* This method is a function pointer that sets the output gain for
use when run_adding() is called (see above). If this function is
never called the gain is assumed to default to 1. Gain
information should be retained when activate() or deactivate()
are called.

This function should be provided by the plugin if and only if the
run_adding() function is provided. When it is absent this
function pointer must be set to NULL. */
void (*set_run_adding_gain)(LADSPA_Handle Instance,
LADSPA_Data Gain);

/* This is the counterpart to activate() (see above). If there is
nothing for deactivate() to do then the plugin writer may provide
a NULL rather than an empty function.

Hosts must deactivate all activated units after they have been
run() (or run_adding()) for the last time. This call should be
made as close to the last run() call as possible and indicates to
real-time plugins that they are no longer live. Plugins should
not rely on prompt deactivation. Note that connect_port() may be
called before or after a call to deactivate().

Deactivation is not similar to pausing as the plugin instance
will be reinitialised when activate() is called to reuse it. */
void (*deactivate)(LADSPA_Handle Instance);

/* Once an instance of a plugin has been finished with it can be
deleted using the following function. The instance handle passed
ceases to be valid after this call.
If activate() was called for a plugin instance then a
corresponding call to deactivate() must be made before cleanup()
is called. */
void (*cleanup)(LADSPA_Handle Instance);

} LADSPA_Descriptor;

/**********************************************************************/

/* Accessing a Plugin: */

/* The exact mechanism by which plugins are loaded is host-dependent,
however all most hosts will need to know is the name of shared
object file containing the plugin types. To allow multiple hosts to
share plugin types, hosts may wish to check for environment
variable LADSPA_PATH. If present, this should contain a
colon-separated path indicating directories that should be searched
(in order) when loading plugin types.

A plugin programmer must include a function called
"ladspa_descriptor" with the following function prototype within
the shared object file. This function will have C-style linkage (if
you are using C++ this is taken care of by the `extern "C"' clause
at the top of the file).

A host will find the plugin shared object file by one means or
another, find the ladspa_descriptor() function, call it, and
proceed from there.

Plugin types are accessed by index (not ID) using values from 0
upwards. Out of range indexes must result in this function
returning NULL, so the plugin count can be determined by checking
for the least index that results in NULL being returned. */

const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);

/* Datatype corresponding to the ladspa_descriptor() function. */
typedef const LADSPA_Descriptor *
(*LADSPA_Descriptor_Function)(unsigned long Index);

/**********************************************************************/

#ifdef __cplusplus
}
#endif

#endif /* LADSPA_INCLUDED */

/* EOF */

+ 619
- 0
libs/distrho/src/lv2/atom-forge.h View File

@@ -0,0 +1,619 @@
/*
Copyright 2008-2012 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file forge.h An API for constructing LV2 atoms.

This file provides an API for constructing Atoms which makes it relatively
simple to build nested atoms of arbitrary complexity without requiring
dynamic memory allocation.

The API is based on successively appending the appropriate pieces to build a
complete Atom. The size of containers is automatically updated. Functions
that begin a container return (via their frame argument) a stack frame which
must be popped when the container is finished.

All output is written to a user-provided buffer or sink function. This
makes it popssible to create create atoms on the stack, on the heap, in LV2
port buffers, in a ringbuffer, or elsewhere, all using the same API.

This entire API is realtime safe if used with a buffer or a realtime safe
sink, except lv2_atom_forge_init() which is only realtime safe if the URI
map function is.

Note these functions are all static inline, do not take their address.

This header is non-normative, it is provided for convenience.
*/

#ifndef LV2_ATOM_FORGE_H
#define LV2_ATOM_FORGE_H

#include <assert.h>

#include "atom.h"
#include "atom-util.h"
#include "urid.h"

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

/** Handle for LV2_Atom_Forge_Sink. */
typedef void* LV2_Atom_Forge_Sink_Handle;

/** A reference to a chunk of written output. */
typedef intptr_t LV2_Atom_Forge_Ref;

/** Sink function for writing output. See lv2_atom_forge_set_sink(). */
typedef LV2_Atom_Forge_Ref
(*LV2_Atom_Forge_Sink)(LV2_Atom_Forge_Sink_Handle handle,
const void* buf,
uint32_t size);

/** Function for resolving a reference. See lv2_atom_forge_set_sink(). */
typedef LV2_Atom*
(*LV2_Atom_Forge_Deref_Func)(LV2_Atom_Forge_Sink_Handle handle,
LV2_Atom_Forge_Ref ref);

/** A stack frame used for keeping track of nested Atom containers. */
typedef struct _LV2_Atom_Forge_Frame {
struct _LV2_Atom_Forge_Frame* parent;
LV2_Atom_Forge_Ref ref;
} LV2_Atom_Forge_Frame;

/** A "forge" for creating atoms by appending to a buffer. */
typedef struct {
uint8_t* buf;
uint32_t offset;
uint32_t size;

LV2_Atom_Forge_Sink sink;
LV2_Atom_Forge_Deref_Func deref;
LV2_Atom_Forge_Sink_Handle handle;

LV2_Atom_Forge_Frame* stack;

LV2_URID Blank;
LV2_URID Bool;
LV2_URID Chunk;
LV2_URID Double;
LV2_URID Float;
LV2_URID Int;
LV2_URID Long;
LV2_URID Literal;
LV2_URID Path;
LV2_URID Property;
LV2_URID Resource;
LV2_URID Sequence;
LV2_URID String;
LV2_URID Tuple;
LV2_URID URI;
LV2_URID URID;
LV2_URID Vector;
} LV2_Atom_Forge;

static inline void
lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size);

/**
Initialise @p forge.

URIs will be mapped using @p map and stored, a reference to @p map itself is
not held.
*/
static inline void
lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
{
lv2_atom_forge_set_buffer(forge, NULL, 0);
forge->Blank = map->map(map->handle, LV2_ATOM__Blank);
forge->Bool = map->map(map->handle, LV2_ATOM__Bool);
forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk);
forge->Double = map->map(map->handle, LV2_ATOM__Double);
forge->Float = map->map(map->handle, LV2_ATOM__Float);
forge->Int = map->map(map->handle, LV2_ATOM__Int);
forge->Long = map->map(map->handle, LV2_ATOM__Long);
forge->Literal = map->map(map->handle, LV2_ATOM__Literal);
forge->Path = map->map(map->handle, LV2_ATOM__Path);
forge->Property = map->map(map->handle, LV2_ATOM__Property);
forge->Resource = map->map(map->handle, LV2_ATOM__Resource);
forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence);
forge->String = map->map(map->handle, LV2_ATOM__String);
forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple);
forge->URI = map->map(map->handle, LV2_ATOM__URI);
forge->URID = map->map(map->handle, LV2_ATOM__URID);
forge->Vector = map->map(map->handle, LV2_ATOM__Vector);
}

static inline LV2_Atom*
lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref)
{
if (forge->buf) {
return (LV2_Atom*)ref;
} else {
return forge->deref(forge->handle, ref);
}
}

/**
@name Object Stack
@{
*/

/**
Push a stack frame.
This is done automatically by container functions (which take a stack frame
pointer), but may be called by the user to push the top level container when
writing to an existing Atom.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_push(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
LV2_Atom_Forge_Ref ref)
{
frame->parent = forge->stack;
frame->ref = ref;
forge->stack = frame;
return ref;
}

/** Pop a stack frame. This must be called when a container is finished. */
static inline void
lv2_atom_forge_pop(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
{
assert(frame == forge->stack);
forge->stack = frame->parent;
}

/** Return true iff the top of the stack has the given type. */
static inline bool
lv2_atom_forge_top_is(LV2_Atom_Forge* forge, uint32_t type)
{
return forge->stack &&
lv2_atom_forge_deref(forge, forge->stack->ref)->type == type;
}

/**
@}
@name Output Configuration
@{
*/

/** Set the output buffer where @p forge will write atoms. */
static inline void
lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size)
{
forge->buf = buf;
forge->size = size;
forge->offset = 0;
forge->deref = NULL;
forge->sink = NULL;
forge->handle = NULL;
forge->stack = NULL;
}

/**
Set the sink function where @p forge will write output.

The return value of forge functions is an LV2_Atom_Forge_Ref which is an
integer type safe to use as a pointer but is otherwise opaque. The sink
function must return a ref that can be dereferenced to access as least
sizeof(LV2_Atom) bytes of the written data, so sizes can be updated. For
ringbuffers, this should be possible as long as the size of the buffer is a
multiple of sizeof(LV2_Atom), since atoms are always aligned.

Note that 0 is an invalid reference, so if you are using a buffer offset be
sure to offset it such that 0 is never a valid reference. You will get
confusing errors otherwise.
*/
static inline void
lv2_atom_forge_set_sink(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Sink sink,
LV2_Atom_Forge_Deref_Func deref,
LV2_Atom_Forge_Sink_Handle handle)
{
forge->buf = NULL;
forge->size = forge->offset = 0;
forge->deref = deref;
forge->sink = sink;
forge->handle = handle;
forge->stack = NULL;
}

/**
@}
@name Low Level Output
@{
*/

/**
Write raw output. This is used internally, but is also useful for writing
atom types not explicitly supported by the forge API. Note the caller is
responsible for ensuring the output is approriately padded.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size)
{
LV2_Atom_Forge_Ref out = 0;
if (forge->sink) {
out = forge->sink(forge->handle, data, size);
} else {
out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset;
uint8_t* mem = forge->buf + forge->offset;
if (forge->offset + size > forge->size) {
return 0;
}
forge->offset += size;
memcpy(mem, data, size);
}
for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
lv2_atom_forge_deref(forge, f->ref)->size += size;
}
return out;
}

/** Pad output accordingly so next write is 64-bit aligned. */
static inline void
lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written)
{
const uint64_t pad = 0;
const uint32_t pad_size = lv2_atom_pad_size(written) - written;
lv2_atom_forge_raw(forge, &pad, pad_size);
}

/** Write raw output, padding to 64-bits as necessary. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size)
{
LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
if (out) {
lv2_atom_forge_pad(forge, size);
}
return out;
}

/** Write a null-terminated string body. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_string_body(LV2_Atom_Forge* forge,
const char* str,
uint32_t len)
{
LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len);
if (out && (out = lv2_atom_forge_raw(forge, "", 1))) {
lv2_atom_forge_pad(forge, len + 1);
}
return out;
}

/**
@}
@name Atom Output
@{
*/

/** Write an atom:Atom header. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t size, uint32_t type)
{
const LV2_Atom a = { size, type };
return lv2_atom_forge_raw(forge, &a, sizeof(a));
}

/** Write a primitive (fixed-size) atom. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a)
{
if (lv2_atom_forge_top_is(forge, forge->Vector)) {
return lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size);
} else {
return lv2_atom_forge_write(forge, a, sizeof(LV2_Atom) + a->size);
}
}

/** Write an atom:Int. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_int(LV2_Atom_Forge* forge, int32_t val)
{
const LV2_Atom_Int a = { { sizeof(val), forge->Int }, val };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom:Long. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_long(LV2_Atom_Forge* forge, int64_t val)
{
const LV2_Atom_Long a = { { sizeof(val), forge->Long }, val };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom:Float. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_float(LV2_Atom_Forge* forge, float val)
{
const LV2_Atom_Float a = { { sizeof(val), forge->Float }, val };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom:Double. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_double(LV2_Atom_Forge* forge, double val)
{
const LV2_Atom_Double a = { { sizeof(val), forge->Double }, val };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom:Bool. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_bool(LV2_Atom_Forge* forge, bool val)
{
const LV2_Atom_Bool a = { { sizeof(int32_t), forge->Bool }, val ? 1 : 0 };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom:URID. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_urid(LV2_Atom_Forge* forge, LV2_URID id)
{
const LV2_Atom_URID a = { { sizeof(id), forge->URID }, id };
return lv2_atom_forge_primitive(forge, &a.atom);
}

/** Write an atom compatible with atom:String. Used internally. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_typed_string(LV2_Atom_Forge* forge,
uint32_t type,
const char* str,
uint32_t len)
{
const LV2_Atom_String a = { { len + 1, type } };
LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
if (out) {
if (!lv2_atom_forge_string_body(forge, str, len)) {
LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
atom->size = atom->type = 0;
out = 0;
}
}
return out;
}

/** Write an atom:String. Note that @p str need not be NULL terminated. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len)
{
return lv2_atom_forge_typed_string(forge, forge->String, str, len);
}

/**
Write an atom:URI. Note that @p uri need not be NULL terminated.
This does not map the URI, but writes the complete URI string. To write
a mapped URI, use lv2_atom_forge_urid().
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_uri(LV2_Atom_Forge* forge, const char* uri, uint32_t len)
{
return lv2_atom_forge_typed_string(forge, forge->URI, uri, len);
}

/** Write an atom:Path. Note that @p path need not be NULL terminated. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_path(LV2_Atom_Forge* forge, const char* path, uint32_t len)
{
return lv2_atom_forge_typed_string(forge, forge->Path, path, len);
}

/** Write an atom:Literal. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_literal(LV2_Atom_Forge* forge,
const char* str,
uint32_t len,
uint32_t datatype,
uint32_t lang)
{
const LV2_Atom_Literal a = {
{ (uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1),
forge->Literal },
{ datatype,
lang }
};
LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
if (out) {
if (!lv2_atom_forge_string_body(forge, str, len)) {
LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
atom->size = atom->type = 0;
out = 0;
}
}
return out;
}

/** Start an atom:Vector. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_vector_head(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
uint32_t child_size,
uint32_t child_type)
{
const LV2_Atom_Vector a = {
{ sizeof(LV2_Atom_Vector_Body), forge->Vector },
{ child_size, child_type }
};
return lv2_atom_forge_push(
forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}

/** Write a complete atom:Vector. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_vector(LV2_Atom_Forge* forge,
uint32_t child_size,
uint32_t child_type,
uint32_t n_elems,
const void* elems)
{
const LV2_Atom_Vector a = {
{ (uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size),
forge->Vector },
{ child_size, child_type }
};
LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
if (out) {
lv2_atom_forge_write(forge, elems, child_size * n_elems);
}
return out;
}

/**
Write the header of an atom:Tuple.

The passed frame will be initialised to represent this tuple. To complete
the tuple, write a sequence of atoms, then pop the frame with
lv2_atom_forge_pop().

For example:
@code
// Write tuple (1, 2.0)
LV2_Atom_Forge_Frame frame;
LV2_Atom* tup = (LV2_Atom*)lv2_atom_forge_tuple(forge, &frame);
lv2_atom_forge_int32(forge, 1);
lv2_atom_forge_float(forge, 2.0);
lv2_atom_forge_pop(forge, &frame);
@endcode
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
{
const LV2_Atom_Tuple a = { { 0, forge->Tuple } };
return lv2_atom_forge_push(
forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}

/**
Write the header of an atom:Resource.

The passed frame will be initialised to represent this object. To complete
the object, write a sequence of properties, then pop the frame with
lv2_atom_forge_pop().

For example:
@code
LV2_URID eg_Cat = map("http://example.org/Cat");
LV2_URID eg_name = map("http://example.org/name");

// Write object header
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_resource(forge, &frame, 1, eg_Cat);

// Write property: eg:name = "Hobbes"
lv2_atom_forge_property_head(forge, eg_name, 0);
lv2_atom_forge_string(forge, "Hobbes", strlen("Hobbes"));

// Finish object
lv2_atom_forge_pop(forge, &frame);
@endcode
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_resource(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
LV2_URID id,
LV2_URID otype)
{
const LV2_Atom_Object a = {
{ sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Resource },
{ id, otype }
};
LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
return lv2_atom_forge_push(forge, frame, out);
}

/**
The same as lv2_atom_forge_resource(), but for object:Blank.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_blank(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
uint32_t id,
LV2_URID otype)
{
const LV2_Atom_Object a = {
{ sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Blank },
{ id, otype }
};
LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
return lv2_atom_forge_push(forge, frame, out);
}

/**
Write the header for a property body (likely in an Object).
See lv2_atom_forge_resource() documentation for an example.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_property_head(LV2_Atom_Forge* forge,
LV2_URID key,
LV2_URID context)
{
const LV2_Atom_Property_Body a = { key, context, { 0, 0 } };
return lv2_atom_forge_write(forge, &a, 2 * sizeof(uint32_t));
}

/**
Write the header for a Sequence.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
uint32_t unit)
{
const LV2_Atom_Sequence a = {
{ sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom), forge->Sequence },
{ unit, 0 }
};
LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
return lv2_atom_forge_push(forge, frame, out);
}

/**
Write the time stamp header of an Event (in a Sequence) in audio frames.
After this, call the appropriate forge method(s) to write the body. Note
the returned reference is to an LV2_Event which is NOT an Atom.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames)
{
return lv2_atom_forge_write(forge, &frames, sizeof(frames));
}

/**
Write the time stamp header of an Event (in a Sequence) in beats. After
this, call the appropriate forge method(s) to write the body. Note the
returned reference is to an LV2_Event which is NOT an Atom.
*/
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, double beats)
{
return lv2_atom_forge_write(forge, &beats, sizeof(beats));
}

/**
@}
*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_ATOM_FORGE_H */

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save