cyfaust 0.1.0__cp311-cp311-macosx_15_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (693) hide show
  1. cyfaust/CMakeLists.txt +93 -0
  2. cyfaust/__init__.py +0 -0
  3. cyfaust/__main__.py +819 -0
  4. cyfaust/box.pxd +46 -0
  5. cyfaust/box.pyx +2459 -0
  6. cyfaust/common.pxd +5 -0
  7. cyfaust/common.pyx +61 -0
  8. cyfaust/cyfaust.cpython-311-darwin.so +0 -0
  9. cyfaust/faust_box.pxd +298 -0
  10. cyfaust/faust_box_oo.pyx +66 -0
  11. cyfaust/faust_gui.pxd +261 -0
  12. cyfaust/faust_interp.pxd +160 -0
  13. cyfaust/faust_player.pxd +80 -0
  14. cyfaust/faust_signal.pxd +257 -0
  15. cyfaust/gui_statics.cpp +15 -0
  16. cyfaust/interp.pyx +673 -0
  17. cyfaust/player.cpp +32519 -0
  18. cyfaust/player.pyx +191 -0
  19. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUBase.cpp +2327 -0
  20. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUBase.h +1019 -0
  21. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUDispatch.cpp +423 -0
  22. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUDispatch.h +82 -0
  23. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUInputElement.cpp +151 -0
  24. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUInputElement.h +119 -0
  25. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUOutputElement.cpp +62 -0
  26. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUOutputElement.h +66 -0
  27. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUPlugInDispatch.cpp +615 -0
  28. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUPlugInDispatch.h +128 -0
  29. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUScopeElement.cpp +512 -0
  30. cyfaust/resources/architecture/AU/AUPublic/AUBase/AUScopeElement.h +544 -0
  31. cyfaust/resources/architecture/AU/AUPublic/AUBase/ComponentBase.cpp +370 -0
  32. cyfaust/resources/architecture/AU/AUPublic/AUBase/ComponentBase.h +340 -0
  33. cyfaust/resources/architecture/AU/AUPublic/AUEffectBase/AUEffectBase.cpp +463 -0
  34. cyfaust/resources/architecture/AU/AUPublic/AUEffectBase/AUEffectBase.h +391 -0
  35. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp +837 -0
  36. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUInstrumentBase.h +267 -0
  37. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUMIDIBase.cpp +495 -0
  38. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUMIDIBase.h +213 -0
  39. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/LockFreeFIFO.h +168 -0
  40. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MIDIControlHandler.h +92 -0
  41. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MusicDeviceBase.cpp +354 -0
  42. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MusicDeviceBase.h +126 -0
  43. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthElement.cpp +419 -0
  44. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthElement.h +227 -0
  45. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthEvent.h +145 -0
  46. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNote.cpp +138 -0
  47. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNote.h +186 -0
  48. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNoteList.cpp +93 -0
  49. cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNoteList.h +232 -0
  50. cyfaust/resources/architecture/AU/AUPublic/Utility/AUBaseHelper.cpp +134 -0
  51. cyfaust/resources/architecture/AU/AUPublic/Utility/AUBaseHelper.h +80 -0
  52. cyfaust/resources/architecture/AU/AUPublic/Utility/AUBuffer.cpp +217 -0
  53. cyfaust/resources/architecture/AU/AUPublic/Utility/AUBuffer.h +267 -0
  54. cyfaust/resources/architecture/AU/AUPublic/Utility/AUMIDIDefs.h +136 -0
  55. cyfaust/resources/architecture/AU/AUPublic/Utility/AUSilentTimeout.h +93 -0
  56. cyfaust/resources/architecture/AU/English.lproj/InfoPlist.strings +0 -0
  57. cyfaust/resources/architecture/AU/FaustAU.exp +2 -0
  58. cyfaust/resources/architecture/AU/FaustAU.xcodeproj/project.pbxproj +968 -0
  59. cyfaust/resources/architecture/AU/FaustAU.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  60. cyfaust/resources/architecture/AU/FaustAUCustomView.plist +14 -0
  61. cyfaust/resources/architecture/AU/Info.plist +47 -0
  62. cyfaust/resources/architecture/AU/PublicUtility/CAAtomic.h +305 -0
  63. cyfaust/resources/architecture/AU/PublicUtility/CAAtomicStack.h +239 -0
  64. cyfaust/resources/architecture/AU/PublicUtility/CAAudioChannelLayout.cpp +153 -0
  65. cyfaust/resources/architecture/AU/PublicUtility/CAAudioChannelLayout.h +199 -0
  66. cyfaust/resources/architecture/AU/PublicUtility/CAAutoDisposer.h +508 -0
  67. cyfaust/resources/architecture/AU/PublicUtility/CABufferList.cpp +264 -0
  68. cyfaust/resources/architecture/AU/PublicUtility/CABufferList.h +319 -0
  69. cyfaust/resources/architecture/AU/PublicUtility/CAByteOrder.h +161 -0
  70. cyfaust/resources/architecture/AU/PublicUtility/CADebugMacros.cpp +88 -0
  71. cyfaust/resources/architecture/AU/PublicUtility/CADebugMacros.h +580 -0
  72. cyfaust/resources/architecture/AU/PublicUtility/CADebugPrintf.cpp +89 -0
  73. cyfaust/resources/architecture/AU/PublicUtility/CADebugPrintf.h +115 -0
  74. cyfaust/resources/architecture/AU/PublicUtility/CADebugger.cpp +77 -0
  75. cyfaust/resources/architecture/AU/PublicUtility/CADebugger.h +56 -0
  76. cyfaust/resources/architecture/AU/PublicUtility/CAException.h +83 -0
  77. cyfaust/resources/architecture/AU/PublicUtility/CAGuard.cpp +339 -0
  78. cyfaust/resources/architecture/AU/PublicUtility/CAGuard.h +133 -0
  79. cyfaust/resources/architecture/AU/PublicUtility/CAHostTimeBase.cpp +110 -0
  80. cyfaust/resources/architecture/AU/PublicUtility/CAHostTimeBase.h +231 -0
  81. cyfaust/resources/architecture/AU/PublicUtility/CALogMacros.h +140 -0
  82. cyfaust/resources/architecture/AU/PublicUtility/CAMath.h +68 -0
  83. cyfaust/resources/architecture/AU/PublicUtility/CAMutex.cpp +345 -0
  84. cyfaust/resources/architecture/AU/PublicUtility/CAMutex.h +163 -0
  85. cyfaust/resources/architecture/AU/PublicUtility/CAReferenceCounted.h +87 -0
  86. cyfaust/resources/architecture/AU/PublicUtility/CAStreamBasicDescription.cpp +795 -0
  87. cyfaust/resources/architecture/AU/PublicUtility/CAStreamBasicDescription.h +409 -0
  88. cyfaust/resources/architecture/AU/PublicUtility/CAThreadSafeList.h +255 -0
  89. cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnit.cpp +191 -0
  90. cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnit.h +100 -0
  91. cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnitTypes.h +59 -0
  92. cyfaust/resources/architecture/AU/PublicUtility/CAXException.cpp +49 -0
  93. cyfaust/resources/architecture/AU/PublicUtility/CAXException.h +338 -0
  94. cyfaust/resources/architecture/AU/SectionPatternLight.tiff +0 -0
  95. cyfaust/resources/architecture/AU/Source/AUSource/FaustAU.h +38 -0
  96. cyfaust/resources/architecture/AU/Source/AUSource/FaustAU.r +153 -0
  97. cyfaust/resources/architecture/AU/Source/AUSource/FaustAUVersion.h +64 -0
  98. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Bargraph.h +18 -0
  99. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Bargraph.m +21 -0
  100. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Button.h +20 -0
  101. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Button.m +56 -0
  102. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomView.h +87 -0
  103. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomView.m +834 -0
  104. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomViewFactory.h +13 -0
  105. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomViewFactory.m +22 -0
  106. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Knob.h +81 -0
  107. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Knob.m +199 -0
  108. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Slider.h +18 -0
  109. cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Slider.m +21 -0
  110. cyfaust/resources/architecture/AU/version.plist +16 -0
  111. cyfaust/resources/architecture/VST/Info.plist +28 -0
  112. cyfaust/resources/architecture/VST/PkgInfo +1 -0
  113. cyfaust/resources/architecture/VST/README +11 -0
  114. cyfaust/resources/architecture/VST/VST.xcode/project.pbxproj +655 -0
  115. cyfaust/resources/architecture/alsa-console.cpp +246 -0
  116. cyfaust/resources/architecture/alsa-gtk.cpp +220 -0
  117. cyfaust/resources/architecture/alsa-qt.cpp +229 -0
  118. cyfaust/resources/architecture/api/DspFaust.cpp +612 -0
  119. cyfaust/resources/architecture/api/DspFaust.h +511 -0
  120. cyfaust/resources/architecture/api/README.md +237 -0
  121. cyfaust/resources/architecture/api/doc/Generic.md +38 -0
  122. cyfaust/resources/architecture/au-effect.cpp +487 -0
  123. cyfaust/resources/architecture/au-instrument.cpp +573 -0
  124. cyfaust/resources/architecture/bench.cpp +91 -0
  125. cyfaust/resources/architecture/c-jack-gtk.c +227 -0
  126. cyfaust/resources/architecture/ca-gtk.cpp +284 -0
  127. cyfaust/resources/architecture/ca-qt.cpp +424 -0
  128. cyfaust/resources/architecture/cpal.rs +195 -0
  129. cyfaust/resources/architecture/csound.cpp +245 -0
  130. cyfaust/resources/architecture/csvplot.cpp +227 -0
  131. cyfaust/resources/architecture/daisy/Makefile +14 -0
  132. cyfaust/resources/architecture/daisy/README.md +50 -0
  133. cyfaust/resources/architecture/daisy/ex_faust.cpp +173 -0
  134. cyfaust/resources/architecture/dssi.cpp +1262 -0
  135. cyfaust/resources/architecture/dummy-mem.cpp +186 -0
  136. cyfaust/resources/architecture/dummy.cpp +294 -0
  137. cyfaust/resources/architecture/faust/au/AUUI.h +404 -0
  138. cyfaust/resources/architecture/faust/audio/alsa-dsp.h +693 -0
  139. cyfaust/resources/architecture/faust/audio/android-dsp.h +583 -0
  140. cyfaust/resources/architecture/faust/audio/audio.h +115 -0
  141. cyfaust/resources/architecture/faust/audio/channels.h +122 -0
  142. cyfaust/resources/architecture/faust/audio/coreaudio-dsp.h +1543 -0
  143. cyfaust/resources/architecture/faust/audio/coreaudio-ios-dsp.h +743 -0
  144. cyfaust/resources/architecture/faust/audio/dummy-audio.h +255 -0
  145. cyfaust/resources/architecture/faust/audio/esp32-dsp.h +284 -0
  146. cyfaust/resources/architecture/faust/audio/fpe.h +164 -0
  147. cyfaust/resources/architecture/faust/audio/jack-dsp.h +534 -0
  148. cyfaust/resources/architecture/faust/audio/juce-dsp.h +119 -0
  149. cyfaust/resources/architecture/faust/audio/netjack-dsp.h +354 -0
  150. cyfaust/resources/architecture/faust/audio/oboe-dsp.h +308 -0
  151. cyfaust/resources/architecture/faust/audio/ofaudio-dsp.h +155 -0
  152. cyfaust/resources/architecture/faust/audio/opensles-android-dsp.h +631 -0
  153. cyfaust/resources/architecture/faust/audio/osc-dsp.h +120 -0
  154. cyfaust/resources/architecture/faust/audio/portaudio-dsp.h +236 -0
  155. cyfaust/resources/architecture/faust/audio/rtaudio-dsp.h +241 -0
  156. cyfaust/resources/architecture/faust/audio/samAudio.h +140 -0
  157. cyfaust/resources/architecture/faust/audio/teensy-dsp.h +171 -0
  158. cyfaust/resources/architecture/faust/dsp/cmajor-cpp-dsp.h +253 -0
  159. cyfaust/resources/architecture/faust/dsp/cmajorpatch-dsp.h +483 -0
  160. cyfaust/resources/architecture/faust/dsp/cpp-dsp-adapter.h +38 -0
  161. cyfaust/resources/architecture/faust/dsp/dsp-adapter.h +836 -0
  162. cyfaust/resources/architecture/faust/dsp/dsp-bench.h +611 -0
  163. cyfaust/resources/architecture/faust/dsp/dsp-checker.h +115 -0
  164. cyfaust/resources/architecture/faust/dsp/dsp-combiner.h +810 -0
  165. cyfaust/resources/architecture/faust/dsp/dsp-compute-adapter.h +159 -0
  166. cyfaust/resources/architecture/faust/dsp/dsp-multi.h +702 -0
  167. cyfaust/resources/architecture/faust/dsp/dsp-multifun.h +90 -0
  168. cyfaust/resources/architecture/faust/dsp/dsp-optimizer.h +511 -0
  169. cyfaust/resources/architecture/faust/dsp/dsp-tools.h +229 -0
  170. cyfaust/resources/architecture/faust/dsp/dsp.h +321 -0
  171. cyfaust/resources/architecture/faust/dsp/fastmath.cpp +301 -0
  172. cyfaust/resources/architecture/faust/dsp/faust-dynamic-engine.cpp +494 -0
  173. cyfaust/resources/architecture/faust/dsp/faust-dynamic-engine.h +386 -0
  174. cyfaust/resources/architecture/faust/dsp/faust-engine.h +75 -0
  175. cyfaust/resources/architecture/faust/dsp/faust-poly-engine.h +638 -0
  176. cyfaust/resources/architecture/faust/dsp/interpreter-dsp-c.h +288 -0
  177. cyfaust/resources/architecture/faust/dsp/interpreter-dsp.h +362 -0
  178. cyfaust/resources/architecture/faust/dsp/interpreter-machine-dsp.h +233 -0
  179. cyfaust/resources/architecture/faust/dsp/libfaust-box-c.h +817 -0
  180. cyfaust/resources/architecture/faust/dsp/libfaust-box.h +889 -0
  181. cyfaust/resources/architecture/faust/dsp/libfaust-c.h +116 -0
  182. cyfaust/resources/architecture/faust/dsp/libfaust-signal-c.h +649 -0
  183. cyfaust/resources/architecture/faust/dsp/libfaust-signal.h +731 -0
  184. cyfaust/resources/architecture/faust/dsp/llvm-dsp-adapter.h +160 -0
  185. cyfaust/resources/architecture/faust/dsp/llvm-dsp-c.h +524 -0
  186. cyfaust/resources/architecture/faust/dsp/llvm-dsp.h +575 -0
  187. cyfaust/resources/architecture/faust/dsp/llvm-machine-dsp.h +215 -0
  188. cyfaust/resources/architecture/faust/dsp/one-sample-dsp.h +477 -0
  189. cyfaust/resources/architecture/faust/dsp/poly-dsp.h +1079 -0
  190. cyfaust/resources/architecture/faust/dsp/poly-interpreter-dsp.h +143 -0
  191. cyfaust/resources/architecture/faust/dsp/poly-llvm-dsp.h +249 -0
  192. cyfaust/resources/architecture/faust/dsp/poly-wasm-dsp.h +257 -0
  193. cyfaust/resources/architecture/faust/dsp/proxy-dsp.h +108 -0
  194. cyfaust/resources/architecture/faust/dsp/proxy-osc-dsp.h +109 -0
  195. cyfaust/resources/architecture/faust/dsp/rnbo-dsp.h +187 -0
  196. cyfaust/resources/architecture/faust/dsp/sound-player.h +428 -0
  197. cyfaust/resources/architecture/faust/dsp/timed-dsp.h +279 -0
  198. cyfaust/resources/architecture/faust/dsp/wasm-dsp-imp.h +188 -0
  199. cyfaust/resources/architecture/faust/dsp/wasm-dsp.h +309 -0
  200. cyfaust/resources/architecture/faust/dsp/ysfx-dsp.h +188 -0
  201. cyfaust/resources/architecture/faust/export.h +61 -0
  202. cyfaust/resources/architecture/faust/gui/APIUI.h +726 -0
  203. cyfaust/resources/architecture/faust/gui/BelaOSCUI.h +170 -0
  204. cyfaust/resources/architecture/faust/gui/CGlue.h +667 -0
  205. cyfaust/resources/architecture/faust/gui/CInterface.h +142 -0
  206. cyfaust/resources/architecture/faust/gui/ControlSequenceUI.h +197 -0
  207. cyfaust/resources/architecture/faust/gui/ControlUI.h +137 -0
  208. cyfaust/resources/architecture/faust/gui/DaisyControlUI.h +283 -0
  209. cyfaust/resources/architecture/faust/gui/DaisyPatchInitControlUI.h +254 -0
  210. cyfaust/resources/architecture/faust/gui/DecoratorUI.h +115 -0
  211. cyfaust/resources/architecture/faust/gui/Esp32ControlUI.h +341 -0
  212. cyfaust/resources/architecture/faust/gui/Esp32Reader.h +102 -0
  213. cyfaust/resources/architecture/faust/gui/Esp32SensorUI.h +137 -0
  214. cyfaust/resources/architecture/faust/gui/FUI.h +147 -0
  215. cyfaust/resources/architecture/faust/gui/GTKUI.h +1414 -0
  216. cyfaust/resources/architecture/faust/gui/GUI.h +465 -0
  217. cyfaust/resources/architecture/faust/gui/JSONControl.h +48 -0
  218. cyfaust/resources/architecture/faust/gui/JSONUI.h +722 -0
  219. cyfaust/resources/architecture/faust/gui/JSONUIDecoder.h +589 -0
  220. cyfaust/resources/architecture/faust/gui/JuceGUI.h +2061 -0
  221. cyfaust/resources/architecture/faust/gui/JuceOSCUI.h +163 -0
  222. cyfaust/resources/architecture/faust/gui/JuceParameterUI.h +158 -0
  223. cyfaust/resources/architecture/faust/gui/JuceReader.h +103 -0
  224. cyfaust/resources/architecture/faust/gui/JuceStateUI.h +88 -0
  225. cyfaust/resources/architecture/faust/gui/LayoutUI.h +423 -0
  226. cyfaust/resources/architecture/faust/gui/LibsndfileReader.h +366 -0
  227. cyfaust/resources/architecture/faust/gui/MapUI.h +370 -0
  228. cyfaust/resources/architecture/faust/gui/MemoryReader.h +111 -0
  229. cyfaust/resources/architecture/faust/gui/MetaDataUI.h +357 -0
  230. cyfaust/resources/architecture/faust/gui/MidiUI.h +939 -0
  231. cyfaust/resources/architecture/faust/gui/OCVUI.h +688 -0
  232. cyfaust/resources/architecture/faust/gui/OSCUI.h +219 -0
  233. cyfaust/resources/architecture/faust/gui/PathBuilder.h +228 -0
  234. cyfaust/resources/architecture/faust/gui/PresetUI.h +337 -0
  235. cyfaust/resources/architecture/faust/gui/PrintCUI.h +152 -0
  236. cyfaust/resources/architecture/faust/gui/PrintUI.h +121 -0
  237. cyfaust/resources/architecture/faust/gui/QTUI.h +1891 -0
  238. cyfaust/resources/architecture/faust/gui/RosCI.h +493 -0
  239. cyfaust/resources/architecture/faust/gui/RosUI.h +488 -0
  240. cyfaust/resources/architecture/faust/gui/SaveUI.h +163 -0
  241. cyfaust/resources/architecture/faust/gui/SimpleParser.h +583 -0
  242. cyfaust/resources/architecture/faust/gui/SoundUI.h +217 -0
  243. cyfaust/resources/architecture/faust/gui/Soundfile.h +342 -0
  244. cyfaust/resources/architecture/faust/gui/Styles/Blue.qrc +5 -0
  245. cyfaust/resources/architecture/faust/gui/Styles/Blue.qss +177 -0
  246. cyfaust/resources/architecture/faust/gui/Styles/Default.qrc +5 -0
  247. cyfaust/resources/architecture/faust/gui/Styles/Default.qss +117 -0
  248. cyfaust/resources/architecture/faust/gui/Styles/Grey.qrc +5 -0
  249. cyfaust/resources/architecture/faust/gui/Styles/Grey.qss +174 -0
  250. cyfaust/resources/architecture/faust/gui/Styles/Salmon.qrc +5 -0
  251. cyfaust/resources/architecture/faust/gui/Styles/Salmon.qss +171 -0
  252. cyfaust/resources/architecture/faust/gui/UI.h +87 -0
  253. cyfaust/resources/architecture/faust/gui/ValueConverter.h +543 -0
  254. cyfaust/resources/architecture/faust/gui/WaveReader.h +364 -0
  255. cyfaust/resources/architecture/faust/gui/console.h +322 -0
  256. cyfaust/resources/architecture/faust/gui/httpdUI.h +372 -0
  257. cyfaust/resources/architecture/faust/gui/meta.h +39 -0
  258. cyfaust/resources/architecture/faust/gui/mspUI.h +580 -0
  259. cyfaust/resources/architecture/faust/gui/qrcodegen.h +269 -0
  260. cyfaust/resources/architecture/faust/gui/qrcodegen.impl.h +1025 -0
  261. cyfaust/resources/architecture/faust/gui/ring-buffer.h +414 -0
  262. cyfaust/resources/architecture/faust/midi/RtMidi.cpp +3054 -0
  263. cyfaust/resources/architecture/faust/midi/RtMidi.h +1034 -0
  264. cyfaust/resources/architecture/faust/midi/bela-midi.h +266 -0
  265. cyfaust/resources/architecture/faust/midi/daisy-midi.h +116 -0
  266. cyfaust/resources/architecture/faust/midi/esp32-midi.h +185 -0
  267. cyfaust/resources/architecture/faust/midi/gramophone-midi.h +107 -0
  268. cyfaust/resources/architecture/faust/midi/iplug2-midi.h +148 -0
  269. cyfaust/resources/architecture/faust/midi/jack-midi.h +247 -0
  270. cyfaust/resources/architecture/faust/midi/juce-midi.h +275 -0
  271. cyfaust/resources/architecture/faust/midi/midi.h +475 -0
  272. cyfaust/resources/architecture/faust/midi/rt-midi.h +315 -0
  273. cyfaust/resources/architecture/faust/midi/teensy-midi.h +89 -0
  274. cyfaust/resources/architecture/faust/misc.h +106 -0
  275. cyfaust/resources/architecture/faust/sound-file.h +132 -0
  276. cyfaust/resources/architecture/faust/unity/AudioPluginInterface.h +301 -0
  277. cyfaust/resources/architecture/faust/vst/faust.h +141 -0
  278. cyfaust/resources/architecture/faust/vst/voice.h +43 -0
  279. cyfaust/resources/architecture/faust/vst/vstui.h +524 -0
  280. cyfaust/resources/architecture/faustvst.cpp +3435 -0
  281. cyfaust/resources/architecture/faustvstqt.h +91 -0
  282. cyfaust/resources/architecture/gen-json.cpp +76 -0
  283. cyfaust/resources/architecture/jack-console.cpp +267 -0
  284. cyfaust/resources/architecture/jack-gtk-ros.cpp +139 -0
  285. cyfaust/resources/architecture/jack-gtk.cpp +282 -0
  286. cyfaust/resources/architecture/jack-internal.cpp +560 -0
  287. cyfaust/resources/architecture/jack-qt-chain-footer.cpp +87 -0
  288. cyfaust/resources/architecture/jack-qt-chain-header.cpp +92 -0
  289. cyfaust/resources/architecture/jack-qt.cpp +281 -0
  290. cyfaust/resources/architecture/jack.rs +171 -0
  291. cyfaust/resources/architecture/juce/README.md +84 -0
  292. cyfaust/resources/architecture/juce/juce-plugin.cpp +809 -0
  293. cyfaust/resources/architecture/juce/juce-standalone.cpp +413 -0
  294. cyfaust/resources/architecture/juce/plugin/plugin-llvm.jucer +184 -0
  295. cyfaust/resources/architecture/juce/plugin/plugin.jucer +159 -0
  296. cyfaust/resources/architecture/juce/standalone/standalone-llvm.jucer +216 -0
  297. cyfaust/resources/architecture/juce/standalone/standalone.jucer +191 -0
  298. cyfaust/resources/architecture/ladspa.cpp +543 -0
  299. cyfaust/resources/architecture/latexheader.tex +65 -0
  300. cyfaust/resources/architecture/lv2.cpp +2090 -0
  301. cyfaust/resources/architecture/lv2qtgui.h +62 -0
  302. cyfaust/resources/architecture/lv2ui.cpp +1966 -0
  303. cyfaust/resources/architecture/max-msp/README.md +109 -0
  304. cyfaust/resources/architecture/max-msp/faustgen-wrapper-poly.maxpat +184 -0
  305. cyfaust/resources/architecture/max-msp/faustgen-wrapper.maxpat +163 -0
  306. cyfaust/resources/architecture/max-msp/max-msp.cpp +734 -0
  307. cyfaust/resources/architecture/max-msp/max-msp64.cpp +789 -0
  308. cyfaust/resources/architecture/max-msp/py2max/README.md +277 -0
  309. cyfaust/resources/architecture/max-msp/py2max/py2max/__init__.py +3 -0
  310. cyfaust/resources/architecture/max-msp/py2max/py2max/common.py +7 -0
  311. cyfaust/resources/architecture/max-msp/py2max/py2max/core.py +1387 -0
  312. cyfaust/resources/architecture/max-msp/py2max/py2max/maxclassdb.py +318 -0
  313. cyfaust/resources/architecture/max-msp/py2max/py2max/utils.py +20 -0
  314. cyfaust/resources/architecture/max-msp/rnbo.py +1591 -0
  315. cyfaust/resources/architecture/max-msp/sndfile/sndfile.h +857 -0
  316. cyfaust/resources/architecture/max-msp/ui.js +230 -0
  317. cyfaust/resources/architecture/max-msp/wrapper-poly.maxpat +153 -0
  318. cyfaust/resources/architecture/max-msp/wrapper.maxpat +131 -0
  319. cyfaust/resources/architecture/minimal-bench.cpp +100 -0
  320. cyfaust/resources/architecture/minimal-effect.c +149 -0
  321. cyfaust/resources/architecture/minimal-effect.cpp +70 -0
  322. cyfaust/resources/architecture/minimal-fixed-point.cpp +195 -0
  323. cyfaust/resources/architecture/minimal-static.cpp +160 -0
  324. cyfaust/resources/architecture/minimal.c +103 -0
  325. cyfaust/resources/architecture/minimal.cpp +84 -0
  326. cyfaust/resources/architecture/minimal.rs +223 -0
  327. cyfaust/resources/architecture/module.cpp +91 -0
  328. cyfaust/resources/architecture/octave.cpp +471 -0
  329. cyfaust/resources/architecture/oscio-gtk.cpp +115 -0
  330. cyfaust/resources/architecture/oscio-qt.cpp +121 -0
  331. cyfaust/resources/architecture/owl.cpp +345 -0
  332. cyfaust/resources/architecture/pa-gtk.cpp +119 -0
  333. cyfaust/resources/architecture/pa-qt.cpp +261 -0
  334. cyfaust/resources/architecture/path-printer.cpp +100 -0
  335. cyfaust/resources/architecture/plot.cpp +128 -0
  336. cyfaust/resources/architecture/portaudio.rs +192 -0
  337. cyfaust/resources/architecture/puredata.cpp +636 -0
  338. cyfaust/resources/architecture/ra-qt.cpp +238 -0
  339. cyfaust/resources/architecture/sam/fast_pow2.h +69 -0
  340. cyfaust/resources/architecture/sam/fastexp.h +140 -0
  341. cyfaust/resources/architecture/sam/samFaustDSP.cpp +125 -0
  342. cyfaust/resources/architecture/sam/samFaustDSP.h +107 -0
  343. cyfaust/resources/architecture/scheduler.cpp +1391 -0
  344. cyfaust/resources/architecture/sndfile.cpp +291 -0
  345. cyfaust/resources/architecture/supercollider.cpp +611 -0
  346. cyfaust/resources/architecture/teensy/README.md +13 -0
  347. cyfaust/resources/architecture/teensy/teensy.cpp +214 -0
  348. cyfaust/resources/architecture/teensy/teensy.h +71 -0
  349. cyfaust/resources/architecture/thread.h +373 -0
  350. cyfaust/resources/architecture/vcvrack/README.md +78 -0
  351. cyfaust/resources/architecture/vcvrack/template/.gitignore +6 -0
  352. cyfaust/resources/architecture/vcvrack/template/Makefile +22 -0
  353. cyfaust/resources/architecture/vcvrack/template/res/FaustModule.svg +299 -0
  354. cyfaust/resources/architecture/vcvrack/template/src/FaustModule.cpp +942 -0
  355. cyfaust/resources/architecture/vst.cpp +947 -0
  356. cyfaust/resources/libraries/aanl.lib +900 -0
  357. cyfaust/resources/libraries/all.lib +36 -0
  358. cyfaust/resources/libraries/analyzers.lib +980 -0
  359. cyfaust/resources/libraries/basics.lib +2681 -0
  360. cyfaust/resources/libraries/compressors.lib +1341 -0
  361. cyfaust/resources/libraries/delays.lib +401 -0
  362. cyfaust/resources/libraries/demos.lib +1556 -0
  363. cyfaust/resources/libraries/dx7.lib +1036 -0
  364. cyfaust/resources/libraries/effect.lib +1645 -0
  365. cyfaust/resources/libraries/envelopes.lib +666 -0
  366. cyfaust/resources/libraries/examples/README.md +13 -0
  367. cyfaust/resources/libraries/examples/ambisonics/fourSourcesToOcto.dsp +20 -0
  368. cyfaust/resources/libraries/examples/ambisonics/oneSourceToStereo.dsp +12 -0
  369. cyfaust/resources/libraries/examples/analysis/FFT.dsp +26 -0
  370. cyfaust/resources/libraries/examples/analysis/dbmeter.dsp +19 -0
  371. cyfaust/resources/libraries/examples/analysis/spectralLevel.dsp +8 -0
  372. cyfaust/resources/libraries/examples/analysis/spectralTiltLab.dsp +20 -0
  373. cyfaust/resources/libraries/examples/analysis/vumeter.dsp +18 -0
  374. cyfaust/resources/libraries/examples/autodiff/delay/diff.dsp +2 -0
  375. cyfaust/resources/libraries/examples/autodiff/delay/gt.dsp +2 -0
  376. cyfaust/resources/libraries/examples/autodiff/gain/diff.dsp +7 -0
  377. cyfaust/resources/libraries/examples/autodiff/gain/gt.dsp +1 -0
  378. cyfaust/resources/libraries/examples/autodiff/gain_dc/diff.dsp +7 -0
  379. cyfaust/resources/libraries/examples/autodiff/gain_dc/gt.dsp +4 -0
  380. cyfaust/resources/libraries/examples/autodiff/gain_exp/diff.dsp +9 -0
  381. cyfaust/resources/libraries/examples/autodiff/gain_exp/gt.dsp +1 -0
  382. cyfaust/resources/libraries/examples/autodiff/gain_pow/diff.dsp +9 -0
  383. cyfaust/resources/libraries/examples/autodiff/gain_pow/gt.dsp +1 -0
  384. cyfaust/resources/libraries/examples/autodiff/gain_pow_trig/diff.dsp +12 -0
  385. cyfaust/resources/libraries/examples/autodiff/gain_pow_trig/gt.dsp +1 -0
  386. cyfaust/resources/libraries/examples/autodiff/gain_sq/diff.dsp +7 -0
  387. cyfaust/resources/libraries/examples/autodiff/gain_sq/gt.dsp +1 -0
  388. cyfaust/resources/libraries/examples/autodiff/mem/diff.dsp +1 -0
  389. cyfaust/resources/libraries/examples/autodiff/mem/gt.dsp +1 -0
  390. cyfaust/resources/libraries/examples/autodiff/noise.dsp +2 -0
  391. cyfaust/resources/libraries/examples/autodiff/noop.dsp +2 -0
  392. cyfaust/resources/libraries/examples/autodiff/one_zero/diff.dsp +2 -0
  393. cyfaust/resources/libraries/examples/autodiff/one_zero/gt.dsp +2 -0
  394. cyfaust/resources/libraries/examples/autodiff/ramp.dsp +1 -0
  395. cyfaust/resources/libraries/examples/autodiff/recursion/diff.dsp +2 -0
  396. cyfaust/resources/libraries/examples/autodiff/recursion/gt.dsp +1 -0
  397. cyfaust/resources/libraries/examples/autodiff/recursion/target.dsp +13 -0
  398. cyfaust/resources/libraries/examples/autodiff/tremolo/diff.dsp +14 -0
  399. cyfaust/resources/libraries/examples/autodiff/tremolo/diffable.lib +7 -0
  400. cyfaust/resources/libraries/examples/autodiff/tremolo/gt.dsp +11 -0
  401. cyfaust/resources/libraries/examples/delayEcho/echo.dsp +15 -0
  402. cyfaust/resources/libraries/examples/delayEcho/quadEcho.dsp +21 -0
  403. cyfaust/resources/libraries/examples/delayEcho/smoothDelay.dsp +26 -0
  404. cyfaust/resources/libraries/examples/delayEcho/stereoEcho.dsp +16 -0
  405. cyfaust/resources/libraries/examples/delayEcho/tapiir.dsp +44 -0
  406. cyfaust/resources/libraries/examples/dynamic/compressor.dsp +8 -0
  407. cyfaust/resources/libraries/examples/dynamic/distortion.dsp +8 -0
  408. cyfaust/resources/libraries/examples/dynamic/gateCompressor.dsp +10 -0
  409. cyfaust/resources/libraries/examples/dynamic/noiseGate.dsp +8 -0
  410. cyfaust/resources/libraries/examples/dynamic/volume.dsp +15 -0
  411. cyfaust/resources/libraries/examples/filtering/APF.dsp +13 -0
  412. cyfaust/resources/libraries/examples/filtering/BPF.dsp +13 -0
  413. cyfaust/resources/libraries/examples/filtering/DNN.dsp +25 -0
  414. cyfaust/resources/libraries/examples/filtering/HPF.dsp +13 -0
  415. cyfaust/resources/libraries/examples/filtering/LPF.dsp +13 -0
  416. cyfaust/resources/libraries/examples/filtering/bandFilter.dsp +44 -0
  417. cyfaust/resources/libraries/examples/filtering/cryBaby.dsp +4 -0
  418. cyfaust/resources/libraries/examples/filtering/diodeLadder.dsp +12 -0
  419. cyfaust/resources/libraries/examples/filtering/filterBank.dsp +6 -0
  420. cyfaust/resources/libraries/examples/filtering/graphicEqLab.dsp +10 -0
  421. cyfaust/resources/libraries/examples/filtering/highShelf.dsp +13 -0
  422. cyfaust/resources/libraries/examples/filtering/korg35HPF.dsp +13 -0
  423. cyfaust/resources/libraries/examples/filtering/korg35LPF.dsp +13 -0
  424. cyfaust/resources/libraries/examples/filtering/lfBoost.dsp +40 -0
  425. cyfaust/resources/libraries/examples/filtering/lowBoost.dsp +40 -0
  426. cyfaust/resources/libraries/examples/filtering/lowCut.dsp +40 -0
  427. cyfaust/resources/libraries/examples/filtering/lowShelf.dsp +13 -0
  428. cyfaust/resources/libraries/examples/filtering/moogHalfLadder.dsp +12 -0
  429. cyfaust/resources/libraries/examples/filtering/moogLadder.dsp +12 -0
  430. cyfaust/resources/libraries/examples/filtering/moogVCF.dsp +6 -0
  431. cyfaust/resources/libraries/examples/filtering/multibandFilter.dsp +14 -0
  432. cyfaust/resources/libraries/examples/filtering/notch.dsp +13 -0
  433. cyfaust/resources/libraries/examples/filtering/oberheim.dsp +14 -0
  434. cyfaust/resources/libraries/examples/filtering/oberheimBPF.dsp +13 -0
  435. cyfaust/resources/libraries/examples/filtering/oberheimBSF.dsp +13 -0
  436. cyfaust/resources/libraries/examples/filtering/oberheimHPF.dsp +13 -0
  437. cyfaust/resources/libraries/examples/filtering/oberheimLPF.dsp +13 -0
  438. cyfaust/resources/libraries/examples/filtering/parametricEqLab.dsp +10 -0
  439. cyfaust/resources/libraries/examples/filtering/parametricEqualizer.dsp +6 -0
  440. cyfaust/resources/libraries/examples/filtering/peakNotch.dsp +13 -0
  441. cyfaust/resources/libraries/examples/filtering/peakingEQ.dsp +13 -0
  442. cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrder.dsp +14 -0
  443. cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderBPF.dsp +13 -0
  444. cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderHPF.dsp +13 -0
  445. cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderLPF.dsp +13 -0
  446. cyfaust/resources/libraries/examples/filtering/sallenKeyOnePole.dsp +13 -0
  447. cyfaust/resources/libraries/examples/filtering/sallenKeyOnePoleHPF.dsp +12 -0
  448. cyfaust/resources/libraries/examples/filtering/sallenKeyOnePoleLPF.dsp +12 -0
  449. cyfaust/resources/libraries/examples/filtering/spectralTilt.dsp +8 -0
  450. cyfaust/resources/libraries/examples/filtering/vcfWahLab.dsp +12 -0
  451. cyfaust/resources/libraries/examples/filtering/vocoder.dsp +8 -0
  452. cyfaust/resources/libraries/examples/filtering/wahPedal.dsp +6 -0
  453. cyfaust/resources/libraries/examples/gameaudio/bubble.dsp +42 -0
  454. cyfaust/resources/libraries/examples/gameaudio/door.dsp +58 -0
  455. cyfaust/resources/libraries/examples/gameaudio/fire.dsp +46 -0
  456. cyfaust/resources/libraries/examples/gameaudio/insects.dsp +148 -0
  457. cyfaust/resources/libraries/examples/gameaudio/rain.dsp +27 -0
  458. cyfaust/resources/libraries/examples/gameaudio/wind.dsp +23 -0
  459. cyfaust/resources/libraries/examples/generator/filterOsc.dsp +8 -0
  460. cyfaust/resources/libraries/examples/generator/noise.dsp +52 -0
  461. cyfaust/resources/libraries/examples/generator/noiseMetadata.dsp +74 -0
  462. cyfaust/resources/libraries/examples/generator/osc.dsp +17 -0
  463. cyfaust/resources/libraries/examples/generator/osci.dsp +17 -0
  464. cyfaust/resources/libraries/examples/generator/sawtoothLab.dsp +8 -0
  465. cyfaust/resources/libraries/examples/generator/virtualAnalog.dsp +8 -0
  466. cyfaust/resources/libraries/examples/generator/virtualAnalogLab.dsp +10 -0
  467. cyfaust/resources/libraries/examples/misc/UITester.dsp +71 -0
  468. cyfaust/resources/libraries/examples/misc/autopan.dsp +59 -0
  469. cyfaust/resources/libraries/examples/misc/capture.dsp +24 -0
  470. cyfaust/resources/libraries/examples/misc/drumkit.dsp +36 -0
  471. cyfaust/resources/libraries/examples/misc/guitarix.dsp +184 -0
  472. cyfaust/resources/libraries/examples/misc/matrix.dsp +17 -0
  473. cyfaust/resources/libraries/examples/misc/midiTester.dsp +122 -0
  474. cyfaust/resources/libraries/examples/misc/mixer.dsp +27 -0
  475. cyfaust/resources/libraries/examples/misc/statespace.dsp +39 -0
  476. cyfaust/resources/libraries/examples/misc/switcher.dsp +20 -0
  477. cyfaust/resources/libraries/examples/misc/tester.dsp +32 -0
  478. cyfaust/resources/libraries/examples/misc/tester2.dsp +31 -0
  479. cyfaust/resources/libraries/examples/old/README.md +5 -0
  480. cyfaust/resources/libraries/examples/old/freeverb.dsp +109 -0
  481. cyfaust/resources/libraries/examples/old/rewriting/Makefile +21 -0
  482. cyfaust/resources/libraries/examples/old/rewriting/fact.dsp +3 -0
  483. cyfaust/resources/libraries/examples/old/rewriting/fold.dsp +61 -0
  484. cyfaust/resources/libraries/examples/old/rewriting/mesh.dsp +43 -0
  485. cyfaust/resources/libraries/examples/old/rewriting/mesh.pd +37 -0
  486. cyfaust/resources/libraries/examples/old/rewriting/sample.pd +12 -0
  487. cyfaust/resources/libraries/examples/old/rewriting/serial.dsp +7 -0
  488. cyfaust/resources/libraries/examples/old/rewriting/sum.dsp +55 -0
  489. cyfaust/resources/libraries/examples/old/rewriting/test.pd +48 -0
  490. cyfaust/resources/libraries/examples/phasing/flanger.dsp +8 -0
  491. cyfaust/resources/libraries/examples/phasing/phaser.dsp +8 -0
  492. cyfaust/resources/libraries/examples/phasing/phaserFlangerLab.dsp +12 -0
  493. cyfaust/resources/libraries/examples/physicalModeling/brass.dsp +8 -0
  494. cyfaust/resources/libraries/examples/physicalModeling/brassMIDI.dsp +8 -0
  495. cyfaust/resources/libraries/examples/physicalModeling/churchBell.dsp +8 -0
  496. cyfaust/resources/libraries/examples/physicalModeling/clarinet.dsp +8 -0
  497. cyfaust/resources/libraries/examples/physicalModeling/clarinetMIDI.dsp +8 -0
  498. cyfaust/resources/libraries/examples/physicalModeling/djembeMIDI.dsp +8 -0
  499. cyfaust/resources/libraries/examples/physicalModeling/elecGuitarMIDI.dsp +10 -0
  500. cyfaust/resources/libraries/examples/physicalModeling/englishBell.dsp +8 -0
  501. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/NLFeks.dsp +91 -0
  502. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/NLFfm.dsp +70 -0
  503. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/README +125 -0
  504. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bass.dsp +84 -0
  505. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bass.h +91 -0
  506. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/blowBottle.dsp +102 -0
  507. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bowed.dsp +114 -0
  508. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/brass.dsp +103 -0
  509. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/clarinet.dsp +110 -0
  510. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/flute.dsp +116 -0
  511. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/fluteStk.dsp +121 -0
  512. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/glassHarmonica.dsp +131 -0
  513. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/harpsi.dsp +90 -0
  514. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/harpsichord.h +185 -0
  515. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/instrument.h +114 -0
  516. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/modalBar.dsp +122 -0
  517. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/modalBar.h +48 -0
  518. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/audio-out.pd +33 -0
  519. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/bottle.pd +10 -0
  520. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/clarinets.pd +15 -0
  521. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/audio-out.pd +33 -0
  522. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/bass.pd +162 -0
  523. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/canon.pd +55 -0
  524. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/flute.pd +343 -0
  525. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/pachelbel.mid +0 -0
  526. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/audio-out.pd +33 -0
  527. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/daisy.mid +0 -0
  528. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/daisy.pd +45 -0
  529. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/piano.pd +205 -0
  530. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/voiceForm.pd +340 -0
  531. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/audio-out.pd +33 -0
  532. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/blowHole.pd +330 -0
  533. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/piano.pd +205 -0
  534. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/take5.mid +0 -0
  535. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/take5.pd +45 -0
  536. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/audio-out.pd +33 -0
  537. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/harpsi.pd +204 -0
  538. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/turkish-march.mid +0 -0
  539. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/turkish-march.pd +31 -0
  540. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/audio-out.pd +33 -0
  541. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/bass.pd +162 -0
  542. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/modalBar.pd +258 -0
  543. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/piano.pd +205 -0
  544. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/what-a-friend.pd +52 -0
  545. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/what_a_friend.mid +0 -0
  546. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/flutes.pd +15 -0
  547. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fm.pd +10 -0
  548. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/glassBare.pd +10 -0
  549. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/harpsichord-poly.pd +10 -0
  550. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/ironBare.pd +10 -0
  551. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/midi-in.pd +111 -0
  552. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/modal.pd +10 -0
  553. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/osc.pd +26 -0
  554. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/piano-poly.pd +10 -0
  555. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/plucked.pd +20 -0
  556. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/saxophone.pd +10 -0
  557. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/tibetan.pd +10 -0
  558. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/trumpet.pd +10 -0
  559. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/violin.pd +10 -0
  560. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/voiceSynth.pd +10 -0
  561. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/woodenBare.pd +10 -0
  562. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/phonemes.h +189 -0
  563. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/piano.dsp +255 -0
  564. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/piano.h +751 -0
  565. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/saxophony.dsp +114 -0
  566. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/sitar.dsp +48 -0
  567. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/tibetanBowl.dsp +155 -0
  568. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/tunedBar.dsp +123 -0
  569. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/uniBar.dsp +100 -0
  570. cyfaust/resources/libraries/examples/physicalModeling/faust-stk/voiceForm.dsp +125 -0
  571. cyfaust/resources/libraries/examples/physicalModeling/fds/1dDampedWaveEquation.dsp +43 -0
  572. cyfaust/resources/libraries/examples/physicalModeling/fds/2dKirchhoffThinPlate.dsp +75 -0
  573. cyfaust/resources/libraries/examples/physicalModeling/fds/BowedString.dsp +61 -0
  574. cyfaust/resources/libraries/examples/physicalModeling/fds/ControllableNonPhysicalString.dsp +72 -0
  575. cyfaust/resources/libraries/examples/physicalModeling/fds/HammeredString.dsp +74 -0
  576. cyfaust/resources/libraries/examples/physicalModeling/fds/PianoHammeredString.dsp +85 -0
  577. cyfaust/resources/libraries/examples/physicalModeling/fds/StiffString.dsp +54 -0
  578. cyfaust/resources/libraries/examples/physicalModeling/flute.dsp +8 -0
  579. cyfaust/resources/libraries/examples/physicalModeling/fluteMIDI.dsp +8 -0
  580. cyfaust/resources/libraries/examples/physicalModeling/frenchBell.dsp +8 -0
  581. cyfaust/resources/libraries/examples/physicalModeling/germanBell.dsp +8 -0
  582. cyfaust/resources/libraries/examples/physicalModeling/guitarMIDI.dsp +8 -0
  583. cyfaust/resources/libraries/examples/physicalModeling/karplus.dsp +8 -0
  584. cyfaust/resources/libraries/examples/physicalModeling/marimbaMIDI.dsp +10 -0
  585. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator.dsp +58 -0
  586. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator2.dsp +62 -0
  587. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator3.dsp +65 -0
  588. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/01_ParamControl/paramOsc.dsp +63 -0
  589. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/02_AudioParamControl/audioParamOsc.dsp +63 -0
  590. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/03_HammerTime/hammerOsc.dsp +71 -0
  591. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/04_Gravity/bouncingOsc.dsp +64 -0
  592. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/05_PluckedOscillator/pluckedOsc.dsp +57 -0
  593. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/06_BowedOscillator/bowedOsc.dsp +65 -0
  594. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/07_NonLinearOscillator/nlOsc.dsp +78 -0
  595. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/08_TwoMassChain/2massChain.dsp +75 -0
  596. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/09_TinyString/tinyString.dsp +101 -0
  597. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/10_PluckedString/pluckedString.dsp +678 -0
  598. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/11_BowedString/bowedString.dsp +671 -0
  599. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/12_TriangleMesh/triangleMesh.dsp +448 -0
  600. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/13_Construction/construction.dsp +1036 -0
  601. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/14_Polyphonic/polyTriangle.dsp +79 -0
  602. cyfaust/resources/libraries/examples/physicalModeling/mi-faust/15_PhysicalLFO/physicalLFO.dsp +107 -0
  603. cyfaust/resources/libraries/examples/physicalModeling/modularInterpInstrMIDI.dsp +8 -0
  604. cyfaust/resources/libraries/examples/physicalModeling/nylonGuitarMIDI.dsp +8 -0
  605. cyfaust/resources/libraries/examples/physicalModeling/old/harpe.dsp +45 -0
  606. cyfaust/resources/libraries/examples/physicalModeling/old/karplus.dsp +34 -0
  607. cyfaust/resources/libraries/examples/physicalModeling/old/karplus32.dsp +47 -0
  608. cyfaust/resources/libraries/examples/physicalModeling/russianBell.dsp +8 -0
  609. cyfaust/resources/libraries/examples/physicalModeling/standardBell.dsp +8 -0
  610. cyfaust/resources/libraries/examples/physicalModeling/violin.dsp +8 -0
  611. cyfaust/resources/libraries/examples/physicalModeling/violinMIDI.dsp +8 -0
  612. cyfaust/resources/libraries/examples/physicalModeling/vocalBP.dsp +8 -0
  613. cyfaust/resources/libraries/examples/physicalModeling/vocalBPMIDI.dsp +8 -0
  614. cyfaust/resources/libraries/examples/physicalModeling/vocalFOF.dsp +8 -0
  615. cyfaust/resources/libraries/examples/physicalModeling/vocalFOFMIDI.dsp +8 -0
  616. cyfaust/resources/libraries/examples/pitchShifting/pitchShifter.dsp +20 -0
  617. cyfaust/resources/libraries/examples/psychoacoustic/harmonicExciter.dsp +10 -0
  618. cyfaust/resources/libraries/examples/quantizing/quantizedChords.dsp +49 -0
  619. cyfaust/resources/libraries/examples/reverb/dattorro.dsp +8 -0
  620. cyfaust/resources/libraries/examples/reverb/fdnRev.dsp +8 -0
  621. cyfaust/resources/libraries/examples/reverb/freeverb.dsp +8 -0
  622. cyfaust/resources/libraries/examples/reverb/greyhole.dsp +8 -0
  623. cyfaust/resources/libraries/examples/reverb/jprev.dsp +8 -0
  624. cyfaust/resources/libraries/examples/reverb/reverbDesigner.dsp +12 -0
  625. cyfaust/resources/libraries/examples/reverb/reverbTester.dsp +8 -0
  626. cyfaust/resources/libraries/examples/reverb/zitaRev.dsp +8 -0
  627. cyfaust/resources/libraries/examples/reverb/zitaRevFDN.dsp +8 -0
  628. cyfaust/resources/libraries/examples/smartKeyboard/acGuitar.dsp +100 -0
  629. cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/elecGuitarEffect.dsp +8 -0
  630. cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/myEffect.dsp +5 -0
  631. cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/reverb.dsp +5 -0
  632. cyfaust/resources/libraries/examples/smartKeyboard/bells.dsp +80 -0
  633. cyfaust/resources/libraries/examples/smartKeyboard/bowed.dsp +87 -0
  634. cyfaust/resources/libraries/examples/smartKeyboard/brass.dsp +82 -0
  635. cyfaust/resources/libraries/examples/smartKeyboard/clarinet.dsp +113 -0
  636. cyfaust/resources/libraries/examples/smartKeyboard/crazyGuiro.dsp +96 -0
  637. cyfaust/resources/libraries/examples/smartKeyboard/drums.dsp +74 -0
  638. cyfaust/resources/libraries/examples/smartKeyboard/dubDub.dsp +87 -0
  639. cyfaust/resources/libraries/examples/smartKeyboard/elecGuitar.dsp +67 -0
  640. cyfaust/resources/libraries/examples/smartKeyboard/fm.dsp +78 -0
  641. cyfaust/resources/libraries/examples/smartKeyboard/frog.dsp +74 -0
  642. cyfaust/resources/libraries/examples/smartKeyboard/harp.dsp +84 -0
  643. cyfaust/resources/libraries/examples/smartKeyboard/midiOnly.dsp +62 -0
  644. cyfaust/resources/libraries/examples/smartKeyboard/multiSynth.dsp +75 -0
  645. cyfaust/resources/libraries/examples/smartKeyboard/toy.dsp +71 -0
  646. cyfaust/resources/libraries/examples/smartKeyboard/trumpet.dsp +59 -0
  647. cyfaust/resources/libraries/examples/smartKeyboard/turenas.dsp +114 -0
  648. cyfaust/resources/libraries/examples/smartKeyboard/violin.dsp +91 -0
  649. cyfaust/resources/libraries/examples/smartKeyboard/violin2.dsp +84 -0
  650. cyfaust/resources/libraries/examples/smartKeyboard/vocal.dsp +43 -0
  651. cyfaust/resources/libraries/examples/spat/panpot.dsp +17 -0
  652. cyfaust/resources/libraries/examples/spat/spat.dsp +25 -0
  653. cyfaust/resources/libraries/fds.lib +535 -0
  654. cyfaust/resources/libraries/filter.lib +1710 -0
  655. cyfaust/resources/libraries/filters.lib +3125 -0
  656. cyfaust/resources/libraries/hoa.lib +1081 -0
  657. cyfaust/resources/libraries/instruments.lib +263 -0
  658. cyfaust/resources/libraries/interpolators.lib +675 -0
  659. cyfaust/resources/libraries/math.lib +602 -0
  660. cyfaust/resources/libraries/maths.lib +798 -0
  661. cyfaust/resources/libraries/maxmsp.lib +237 -0
  662. cyfaust/resources/libraries/mi.lib +528 -0
  663. cyfaust/resources/libraries/misceffects.lib +998 -0
  664. cyfaust/resources/libraries/music.lib +496 -0
  665. cyfaust/resources/libraries/noises.lib +487 -0
  666. cyfaust/resources/libraries/oscillator.lib +450 -0
  667. cyfaust/resources/libraries/oscillators.lib +1838 -0
  668. cyfaust/resources/libraries/phaflangers.lib +235 -0
  669. cyfaust/resources/libraries/physmodels.lib +3990 -0
  670. cyfaust/resources/libraries/platform.lib +59 -0
  671. cyfaust/resources/libraries/quantizers.lib +310 -0
  672. cyfaust/resources/libraries/reducemaps.lib +235 -0
  673. cyfaust/resources/libraries/reverbs.lib +686 -0
  674. cyfaust/resources/libraries/routes.lib +262 -0
  675. cyfaust/resources/libraries/sf.lib +53 -0
  676. cyfaust/resources/libraries/signals.lib +570 -0
  677. cyfaust/resources/libraries/soundfiles.lib +234 -0
  678. cyfaust/resources/libraries/spats.lib +173 -0
  679. cyfaust/resources/libraries/stdfaust.lib +38 -0
  680. cyfaust/resources/libraries/synths.lib +322 -0
  681. cyfaust/resources/libraries/tonestacks.lib +427 -0
  682. cyfaust/resources/libraries/tubes.lib +5039 -0
  683. cyfaust/resources/libraries/vaeffects.lib +984 -0
  684. cyfaust/resources/libraries/version.lib +22 -0
  685. cyfaust/resources/libraries/wdmodels.lib +2276 -0
  686. cyfaust/resources/libraries/webaudio.lib +402 -0
  687. cyfaust/signal.pxd +44 -0
  688. cyfaust/signal.pyx +1993 -0
  689. cyfaust-0.1.0.dist-info/METADATA +355 -0
  690. cyfaust-0.1.0.dist-info/RECORD +693 -0
  691. cyfaust-0.1.0.dist-info/WHEEL +5 -0
  692. cyfaust-0.1.0.dist-info/entry_points.txt +3 -0
  693. cyfaust-0.1.0.dist-info/licenses/LICENSE +26 -0
@@ -0,0 +1,2276 @@
1
+ //#################################### wdmodels.lib ##############################################################################
2
+ // A library of basic adaptors and methods to help construct Wave Digital Filter models in Faust. Its official prefix is `wd`.
3
+
4
+ // ## Library Readme
5
+
6
+ // This library is intended for use for creating Wave Digital (WD) based models of audio circuitry for real-time audio processing within the Faust programming language. The goal is to provide a framework to create real-time virtual-analog audio effects and synthesizers using WD models without the use of C++. Furthermore, we seek to provide access to the technique of WD modeling to those without extensive knowledge of advanced digital signal processing techniques. Finally, we hope to provide a library which can integrate with all aspects of Faust, thus creating a platform for virtual circuit bending.
7
+ // The library itself is written in Faust to maintain portability.
8
+ //
9
+ // This library is heavily based on Kurt Werner's Dissertation, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters." I have tried to maintain consistent notation between the adaptors appearing within thesis and my adaptor code. The majority of the adaptors found in chapter 1 and chapter 3 are currently supported.
10
+ //
11
+ // For inquires about use of this library in a commercial product, please contact dirk [dot] roosenburg [dot] 30 [at] gmail [dot] com.
12
+ // This documentation is taken directly from the [readme](https://github.com/droosenb/faust-wdf-library). Please refer to it for a more updated version.
13
+ //
14
+ // Many of the more in depth comments within the library include jargon. I plan to create videos detailing the theory of WD models.
15
+ // For now I recommend Kurt Werner's PhD, [Virtual analog modeling of Audio circuitry using Wave Digital Filters](https://searchworks.stanford.edu/view/11891203).
16
+ // I have tried to maintain consistent syntax and notation to the thesis.
17
+ // This library currently includes the majority of the adaptors covered in chapter 1 and some from chapter 3.
18
+ //
19
+ //
20
+ // ## Using this Library
21
+ //
22
+ // Use of this library expects some level of familiarity with WDF techniques, especially simplification and decomposition of electronic circuits into WDF connection trees. I plan to create video to cover both these techniques and use of the library.
23
+ //
24
+ // ### Quick Start
25
+ //
26
+ // To get a quick overview of the library, start with the `secondOrderFilters.dsp` code found in [examples](https://github.com/droosenb/faust-wdf-library/tree/main/examples).
27
+ // Note that the `wdmodels.lib` library is now embedded in the [online Faust IDE](https://faustide.grame.fr/).
28
+ //
29
+ // ### A Simple RC Filter Model
30
+ //
31
+ // Creating a model using this library consists fo three steps. First, declare a set of components.
32
+ // Second, model the relationship between them using a tree. Finally, build the tree using the libraries build functions.
33
+ //
34
+ // First, a set of components is declared using adaptors from the library.
35
+ // This list of components is created based on analysis of the circuit using WDF techniques,
36
+ // though generally each circuit element (resistor, capacitor, diode, etc.) can be expected to appear
37
+ // within the component set. For example, first order RC lowpass filter would require an unadapted voltage source,
38
+ // a 47k resistor, and a 10nF capacitor which outputs the voltage across itself. These can be declared with:
39
+ //
40
+ // ```
41
+ // vs1(i) = wd.u_voltage(i, no.noise);
42
+ // r1(i) = wd.resistor(i, 47*10^3);
43
+ // c1(i) = wd.capacitor_Vout(i, 10*10^-9);
44
+ // ```
45
+ //
46
+ // Note that the first argument, i, is left un-parametrized. Components must be declared in this form, as the build algorithm expects to receive adaptors which have exactly one parameter.
47
+ //
48
+ // Also note that we have chosen to declare a white noise function as the input to our voltage source.
49
+ // We could potentially declare this as a direct input to our model, but to do so is more complicated
50
+ // process which cannot be covered within this tutorial. For information on how to do this see
51
+ // [Declaring Model Parameters as Inputs](#declaring-model-parameters-as-inputs) or see various implementations
52
+ // in [examples](https://github.com/droosenb/faust-wdf-library/tree/main/examples).
53
+ //
54
+ // Second, the declared components and interconnection/structural adaptors (i.e. series, parallel, etc) are arranged
55
+ // into the connection tree which is produced from performing WD analysis on the modeled circuit.
56
+ // For example, to produce our first order RC lowpass circuit model, the following tree is declared:
57
+ //
58
+ // `tree_lowpass = vs1 : wd.series : (r1, c1);`
59
+ //
60
+ // For more information on how to represent trees in Faust, see [Trees in Faust](#trees-in-faust).
61
+ //
62
+ // Finally, the tree is built using the the `buildtree` function. To build and compute our first order
63
+ // RC lowpass circuit model, we use:
64
+ //
65
+ // `process = wd.buildtree(tree_lowpass);`
66
+ //
67
+ // More information about build functions, see [Model Building Functions](#model-building-functions).
68
+ //
69
+ // ### Building a Model
70
+ //
71
+ // After creating a connection tree which consists of WD adaptors, the connection tree must be passed
72
+ // to a build function in order to build the model.
73
+ //
74
+ // ##### Automatic model building
75
+ //
76
+ // `buildtree(connection_tree)`
77
+ //
78
+ // The simplest build function for use with basic models. This automatically implements `buildup`, `builddown`,
79
+ // and `buildout` to create a working model. However, it gives minimum control to the user and cannot
80
+ // currently be used on trees which have parameters declared as inputs.
81
+ //
82
+ // ##### Manual model building
83
+ //
84
+ // Wave Digital Filters are an explicit state-space model, meaning they use a previous system state
85
+ // in order to calculate the current output. This is achieved in Faust by using a single global feedback operator.
86
+ // The models feed-forward terms are generated using `builddown` and the models feedback terms are generated
87
+ // using `buildup`. Thus, the most common model implementation (the method used by `buildtree`) is:
88
+ //
89
+ // `builddown(connection_tree)~buildup(connection_tree) : buildout(connection_tree)`
90
+ //
91
+ // Since the `~` operator in Faust will leave feedback terms hanging as outputs, `buildout` is a function provided for convenience.
92
+ // It automatically truncates the hanging outputs by identifying leaf components which have an intended output
93
+ // and generating an output matrix.
94
+ //
95
+ // Building the model manually allows for greater user control and is often very helpful in testing.
96
+ // Also provided for testing are the `getres` and `parres` functions, which can be used to determine
97
+ // the upward-facing port resistance of an element.
98
+ //
99
+ // ### Declaring Model Parameters as Inputs
100
+ //
101
+ // When possible, parameters of components should be declared explicitly, meaning they are dependent on a function with no inputs.
102
+ // This might be something as simple as integer(declaring a static component), a function dependent on a UI input (declaring a component with variable value),
103
+ // or even a time-dependent function like an oscillator (declaring an audio input or circuit bending).
104
+ //
105
+ // However, it is often necessary to declare parameters as input. To achieve this there are two possible methods.
106
+ // The first and recommended option is to create a separate model function and declare parameters which will later
107
+ // be implemented as inputs. This allows inputs to be explicitly declared as component parameters.
108
+ // For example, one might use:
109
+ //
110
+ // ```
111
+ // model(in1) = buildtree(tree)
112
+ // with {
113
+ // ...
114
+ // vin(i) = wd.u_voltage(i, in1);
115
+ // ...
116
+ // tree = vin : ...;
117
+ // };
118
+ // ```
119
+ //
120
+ // In order to simulate an audio input to the circuit.
121
+ //
122
+ // Note that the tree and components must be declared inside a `with {...}` statement, or the model's parameters will not be accessible.
123
+ //
124
+ // ##### The Empty Signal Operator
125
+ //
126
+ // The Empty signal operator, `_` should NEVER be used to declare a parameter as in input in a wave-digital model.
127
+ //
128
+ // Using it will result on breaking the internal routing of the model and thus breaks the model.
129
+ // Instead, use explicit declaration as shown directly above.
130
+ //
131
+ // ### Trees in Faust
132
+ //
133
+ // Since WD models use connection trees to represent relationships of elements, a comprehensive way to represent trees is critical.
134
+ // As there is no current convention for creating trees in Faust, I've developed a method using the existing series and parallel/list
135
+ // methods in Faust.
136
+ //
137
+ // The series operator ` : ` is used to separate parent and child elements. For example the tree:
138
+ //
139
+ // ```
140
+ // A
141
+ // |
142
+ // B
143
+ // ```
144
+ //
145
+ // is represented by `A : B` in Faust.
146
+ //
147
+ // To denote a parent element with multiple child elements, simply use a list `(a1, a2, ... an)` of children connected to a single parent. `
148
+ // For example the tree:
149
+ //
150
+ // ```
151
+ // A
152
+ // / \
153
+ // B C
154
+ //
155
+ // ```
156
+ // is represented by:
157
+ //
158
+ // `A : (B, C)`
159
+ //
160
+ // Finally, for a tree with many levels, simply break the tree into subtrees following the above rules and connect
161
+ // the subtree as if it was an individual node. For example the tree:
162
+ //
163
+ // ```
164
+ // A
165
+ // / \
166
+ // B C
167
+ // / / \
168
+ // X Y Z
169
+ // ```
170
+ //
171
+ // can be represented by:
172
+ //
173
+ // ```
174
+ // B_sub = B : X; //B subtree
175
+ // C_sub = C : (Y, Z); //C subtree
176
+ // tree = A : (B_sub, C_sub); //full tree
177
+ // ```
178
+ //
179
+ // or more simply, using parentheses:
180
+ //
181
+ // `A : ((B : X), (C : (Y, Z)))`
182
+
183
+ // ### How Adaptors are Structured
184
+
185
+ // In wave digital filters, adaptors can be described by the form `b = Sa` where `b` is a vector of output waves `b = (b0, b1, b2, ... bn)`, `a` is a vector of input waves`a = (a0, a1, a2, ... an)`, and `S` is an n x n scattering matrix.
186
+ // `S` is dependent on `R`, a list of port resistances `(R0, R1, R2, ... Rn)`.
187
+ //
188
+ // The output wave vector `b` can be divided into downward-going and upward-going waves
189
+ // (downward-going waves travel down the connection tree, upward-going waves travel up).
190
+ // For adapted adaptors, with the zeroth port being the upward-facing port, the downward-going wave vector is `(b1, b2, ... bn)` and the upward-going wave vector is `(b0)`.
191
+ // For unadapted adaptors, there are no upward-going waves, so the downward-going wave vector is simply `b = (b0, b1, b2, ... bn)`.
192
+ //
193
+ // In order for adaptors to be interpretable by the compiler, they must be structured in a specific way.
194
+ // Each adaptor is divided into three cases by their first parameter. This parameter, while accessible by the user, should only be set by the compiler/builder.
195
+ //
196
+ // All other parameters are value declarations (for components), inputs (for voltage or current ins), or parameter controls (for potentiometers/variable capacitors/variable inductors).
197
+ //
198
+ // ##### First case - downward going waves
199
+ //
200
+ // `(0, params) => downward-going(R1, ... Rn, a0, a1, ... an)`
201
+ // outputs: `(b1, b2, ... bn)`
202
+ // this function takes any number of port resistances, the downward going wave, and any number of upward going waves as inputs.
203
+ // These values/waves are used to calculate the downward going waves coming from this adaptor.
204
+ //
205
+ // ##### Second case
206
+ //
207
+ // `(1, params) => upward-going(R1, ... Rn, a1, ... an)`
208
+ // outputs : `(b0)`
209
+ // this function takes any number of port resistances and any number of upward going waves as inputs.
210
+ // These values/waves are used to calculate the upward going wave coming from this adaptor.
211
+ //
212
+ // ##### Third case
213
+ //
214
+ // `(2, params) => port-resistance(R1, ... Rn)`
215
+ // outputs: `(R0)`
216
+ // this function takes any number of port resistances as inputs.
217
+ // These values are used to calculate the upward going port resistance of the element.
218
+ //
219
+ // ##### Unadapted Adaptors
220
+ //
221
+ // Unadapted adaptor's names will always begin `u_`
222
+ // An unadapted adaptor MUST be used as the root of the WD connection tree.
223
+ // Unadapted adaptors can ONLY be used as a root of the WD connection tree.
224
+ // While unadapted adaptors contain all three cases, the second and third are purely structural.
225
+ // Only the first case should contain computational information.
226
+ //
227
+ // ### How the Build Functions Work
228
+ //
229
+ // Expect this section to be added soon! It's currently in progress.
230
+ //
231
+ // ### Acknowledgements
232
+ //
233
+ // Many thanks to Kurt Werner for helping me to understand wave digital filter models. Without his publications and consultations, the library would not exist.
234
+ // Thanks also to my advisors, Rob Owen and Eli Stine whose input was critical to the development of the library.
235
+ // Finally, thanks to Romain Michon, Stephane Letz, and the Faust Slack for contributing to testing, development, and inspiration when creating the library.
236
+ //
237
+ // #### References
238
+ // * <https://github.com/grame-cncm/faustlibraries/blob/master/wdmodels.lib>
239
+ //################################################################################################################################
240
+
241
+ ba = library("basics.lib");
242
+ ro = library("routes.lib");
243
+ ma = library("maths.lib");
244
+ si = library("signals.lib");
245
+
246
+ declare name "Faust Wave Digital Model Library";
247
+ declare version "1.2.1";
248
+
249
+
250
+ //=============================Algebraic One Port Adaptors=================================
251
+ //=========================================================================================
252
+
253
+ //----------------------`(wd.)resistor`--------------------------
254
+ // Adapted Resistor.
255
+ //
256
+ // A basic node implementing a resistor for use within Wave Digital Filter connection trees.
257
+ //
258
+ // It should be used as a leaf/terminating element of the connection tree.
259
+ //
260
+ // #### Usage
261
+ //
262
+ // ```
263
+ // r1(i) = resistor(i, R);
264
+ // buildtree( A : r1 );
265
+ // ```
266
+ //
267
+ // Where:
268
+ //
269
+ // * `i`: index used by model-building functions. Should never be user declared.
270
+ // * `R` : Resistance/Impedance of the resistor being modeled in Ohms.
271
+ //
272
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
273
+ // Correct implementation is shown above.
274
+ //
275
+ // #### Reference
276
+ //
277
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.1
278
+ //----------------------------------------------------------
279
+ declare resistor author "Dirk Roosenburg";
280
+ declare resistor copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
281
+ declare resistor license "MIT-style STK-4.3 license";
282
+ resistor =
283
+ case{
284
+ (0, R) => !, 0;
285
+ (1, R) => _;
286
+ (2, R) => R0
287
+ with{
288
+ R0 = R;
289
+ };
290
+ };
291
+
292
+
293
+ //----------------------`(wd.)resistor_Vout`--------------------------
294
+ // Adapted Resistor + voltage Out.
295
+ //
296
+ // A basic adaptor implementing a resistor for use within Wave Digital Filter connection trees.
297
+ //
298
+ // It should be used as a leaf/terminating element of the connection tree.
299
+ // The resistor will also pass the voltage across itself as an output of the model.
300
+ //
301
+ // #### Usage
302
+ //
303
+ // ```
304
+ // rout(i) = resistor_Vout(i, R);
305
+ // buildtree( A : rout ) : _
306
+ // ```
307
+ //
308
+ // Where:
309
+ //
310
+ // * `i`: index used by model-building functions. Should never be user declared.
311
+ // * `R` : Resistance/Impedance of the resistor being modeled in Ohms.
312
+ //
313
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
314
+ // Correct implementation is shown above.
315
+ //
316
+ // #### Reference
317
+ //
318
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.1
319
+ //----------------------------------------------------------
320
+ declare resistor_Vout author "Dirk Roosenburg";
321
+ declare resistor_Vout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
322
+ declare resistor_Vout license "MIT-style STK-4.3 license";
323
+ resistor_Vout =
324
+ case{
325
+ (0, R) => 0, _*.5;
326
+ (1, R) => _, !;
327
+ (2, R) => R0
328
+ with{
329
+ R0 = R;
330
+ };
331
+ }with{
332
+ rho = 1;
333
+ };
334
+
335
+
336
+ //----------------------`(wd.)resistor_Iout`--------------------------
337
+ // Resistor + current Out.
338
+ //
339
+ // A basic adaptor implementing a resistor for use within Wave Digital Filter connection trees.
340
+ //
341
+ // It should be used as a leaf/terminating element of the connection tree.
342
+ // The resistor will also pass the current through itself as an output of the model.
343
+ //
344
+ // #### Usage
345
+ //
346
+ // ```
347
+ // rout(i) = resistor_Iout(i, R);
348
+ // buildtree( A : rout ) : _
349
+ // ```
350
+ //
351
+ // Where:
352
+ //
353
+ // * `i`: index used by model-building functions. Should never be user declared.
354
+ // * `R` : Resistance/Impedance of the resistor being modeled in Ohms.
355
+ //
356
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
357
+ // Correct implementation is shown above.
358
+ //
359
+ // #### Reference
360
+ //
361
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.1
362
+ //----------------------------------------------------------
363
+ declare resistor_Iout author "Dirk Roosenburg";
364
+ declare resistor_Iout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
365
+ declare resistor_Iout license "MIT-style STK-4.3 license";
366
+ resistor_Iout =
367
+ case{
368
+ (0, R) => 0, _*.5/R;
369
+ (1, R) => _, !;
370
+ (2, R) => R0
371
+ with{
372
+ R0 = R;
373
+ };
374
+ };
375
+
376
+
377
+ //----------------------`(wd.)u_voltage`--------------------------
378
+ // Unadapted Ideal Voltage Source.
379
+ //
380
+ // An adaptor implementing an ideal voltage source within Wave Digital Filter connection trees.
381
+ //
382
+ // It should be used as the root/top element of the connection tree.
383
+ // Can be used for either DC (constant) or AC (signal) voltage sources.
384
+ //
385
+ // #### Usage
386
+ //
387
+ // ```
388
+ // v1(i) = u_Voltage(i, ein);
389
+ // buildtree( v1 : B );
390
+ // ```
391
+ //
392
+ // Where:
393
+ //
394
+ // * `i`: index used by model-building functions. Should never be user declared.
395
+ // * `ein` : Voltage/Potential across ideal voltage source in Volts
396
+ //
397
+ // Note: only usable as the root of a tree.
398
+ // The adaptor must be declared as a separate function before integration into the connection tree.
399
+ // Correct implementation is shown above.
400
+ //
401
+ // #### Reference
402
+ //
403
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.2
404
+ //----------------------------------------------------------
405
+ declare u_voltage author "Dirk Roosenburg";
406
+ declare u_voltage copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
407
+ declare u_voltage license "MIT-style STK-4.3 license";
408
+ u_voltage =
409
+ case{
410
+ (0 , ein) => b0
411
+ with{
412
+ b0(R0, a0) = 2*R0^(rho-1)*ein -a0;
413
+ };
414
+ (1, ein) => !, !;
415
+ (2, ein) => 0;
416
+ }with{
417
+ rho = 1;
418
+ };
419
+
420
+
421
+ //----------------------`(wd.)u_current`--------------------------
422
+ // Unadapted Ideal Current Source.
423
+ //
424
+ // An unadapted adaptor implementing an ideal current source within Wave Digital Filter connection trees.
425
+ //
426
+ // It should be used as the root/top element of the connection tree.
427
+ // Can be used for either DC (constant) or AC (signal) current sources.
428
+ //
429
+ // #### Usage
430
+ //
431
+ // ```
432
+ // i1(i) = u_current(i, jin);
433
+ // buildtree( i1 : B );
434
+ // ```
435
+ //
436
+ // Where:
437
+ //
438
+ // * `i`: index used by model-building functions. Should never be user declared.
439
+ // * `jin` : Current through the ideal current source in Amps
440
+ //
441
+ // Note: only usable as the root of a tree.
442
+ // The adaptor must be declared as a separate function before integration into the connection tree.
443
+ // Correct implementation is shown above.
444
+ //
445
+ // #### Reference
446
+ //
447
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.3
448
+ //----------------------------------------------------------
449
+ declare u_current author "Dirk Roosenburg";
450
+ declare u_current copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
451
+ declare u_current license "MIT-style STK-4.3 license";
452
+ u_current =
453
+ case{
454
+ (0 , jin) => b0
455
+ with{
456
+ b0(R0, a0) = 2*R0^(rho)*jin + a0;
457
+ };
458
+ (1, jin) => !, !;
459
+ (2, jin) => 0;
460
+ }with{
461
+ rho = 1;
462
+ };
463
+
464
+ //----------------------`(wd.)resVoltage`--------------------------
465
+ // Adapted Resistive Voltage Source.
466
+ //
467
+ // An adaptor implementing a resistive voltage source within Wave Digital Filter connection trees.
468
+ //
469
+ // It should be used as a leaf/terminating element of the connection tree.
470
+ // It is comprised of an ideal voltage source in series with a resistor.
471
+ // Can be used for either DC (constant) or AC (signal) voltage sources.
472
+ //
473
+ // #### Usage
474
+ //
475
+ // ```
476
+ // v1(i) = resVoltage(i, R, ein);
477
+ // buildtree( A : v1 );
478
+ // ```
479
+ //
480
+ // Where:
481
+ //
482
+ // * `i`: index used by model-building functions. Should never be user declared
483
+ // * `R` : Resistance/Impedance of the series resistor in Ohms
484
+ // * `ein` : Voltage/Potential of the ideal voltage source in Volts
485
+ //
486
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
487
+ // Correct implementation is shown above.
488
+ //
489
+ // #### Reference
490
+ //
491
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.4
492
+ //----------------------------------------------------------
493
+ declare resVoltage author "Dirk Roosenburg";
494
+ declare resVoltage copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
495
+ declare resVoltage license "MIT-style STK-4.3 license";
496
+ resVoltage =
497
+ case{
498
+ (0, R, ein) => !, R^(1-rho)*ein;
499
+ (1, R, ein) => _;
500
+ (2, R, ein) => R0
501
+ with {
502
+ R0 = R;
503
+ };
504
+ }with{
505
+ rho = 1;
506
+ };
507
+
508
+ //----------------------`(wd.)resVoltage_Vout`--------------------------
509
+ // Adapted Resistive Voltage Source + voltage output.
510
+ //
511
+ // An adaptor implementing an adapted resistive voltage source within Wave Digital Filter connection trees.
512
+ //
513
+ // It should be used as a leaf/terminating element of the connection tree.
514
+ // It is comprised of an ideal voltage source in series with a resistor.
515
+ // Can be used for either DC (constant) or AC (signal) voltage sources.
516
+ // The resistive voltage source will also pass the voltage across it as an output of the model.
517
+ //
518
+ // #### Usage
519
+ //
520
+ // ```
521
+ // vout(i) = resVoltage_Vout(i, R, ein);
522
+ // buildtree( A : vout ) : _
523
+ // ```
524
+ //
525
+ // Where:
526
+ //
527
+ // * `i`: index used by model-building functions. Should never be user declared
528
+ // * `R` : Resistance/Impedance of the series resistor in Ohms
529
+ // * `ein` : Voltage/Potential across ideal voltage source in Volts
530
+ //
531
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
532
+ // Correct implementation is shown above.
533
+ //
534
+ // #### Reference
535
+ //
536
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.4
537
+ //----------------------------------------------------------
538
+ declare resVoltage_Vout author "Dirk Roosenburg";
539
+ declare resVoltage_Vout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
540
+ declare resVoltage_Vout license "MIT-style STK-4.3 license";
541
+ resVoltage_Vout =
542
+ case{
543
+ (0, R, ein) => R^(1-rho)*ein, _*.5 + R^(1-rho)*ein*.5;
544
+ (1, R, ein) => _, !;
545
+ (2, R, ein) => R0
546
+ with {
547
+ R0 = R;
548
+ };
549
+ }with{
550
+ rho = 1;
551
+ };
552
+
553
+ //----------------------`(wd.)u_resVoltage`--------------------------
554
+ // Unadapted Resistive Voltage Source.
555
+ //
556
+ // An unadapted adaptor implementing a resistive voltage source within Wave Digital Filter connection trees.
557
+ //
558
+ // It should be used as the root/top element of the connection tree.
559
+ // It is comprised of an ideal voltage source in series with a resistor.
560
+ // Can be used for either DC (constant) or AC (signal) voltage sources.
561
+ //
562
+ // #### Usage
563
+ //
564
+ // ```
565
+ // v1(i) = u_resVoltage(i, R, ein);
566
+ // buildtree( v1 : B );
567
+ // ```
568
+ //
569
+ // Where:
570
+ //
571
+ // * `i`: index used by model-building functions. Should never be user declared
572
+ // * `R` : Resistance/Impedance of the series resistor in Ohms
573
+ // * `ein` : Voltage/Potential across ideal voltage source in Volts
574
+ //
575
+ // Note: only usable as the root of a tree.
576
+ // The adaptor must be declared as a separate function before integration into the connection tree.
577
+ // Correct implementation is shown above.
578
+ //
579
+ // #### Reference
580
+ //
581
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.4
582
+ //----------------------------------------------------------
583
+ declare u_resVoltage author "Dirk Roosenburg";
584
+ declare u_resVoltage copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
585
+ declare u_resVoltage license "MIT-style STK-4.3 license";
586
+ u_resVoltage =
587
+ case {
588
+ (0, R, ein) => b0
589
+ with{
590
+ b0(R0, a0) = a0*(R - R0)/(R+R0) + ein*(2*R0^rho)/(R + R0);
591
+ };
592
+ (1, R, ein) => !, !;
593
+ (2, R, ein) => 0;
594
+
595
+ }with{
596
+ rho = 1;
597
+ };
598
+
599
+
600
+ //----------------------`(wd.)resCurrent`--------------------------
601
+ // Adapted Resistive Current Source.
602
+ //
603
+ // An adaptor implementing a resistive current source within Wave Digital Filter connection trees.
604
+ //
605
+ // It should be used as a leaf/terminating element of the connection tree.
606
+ // It is comprised of an ideal current source in parallel with a resistor.
607
+ // Can be used for either DC (constant) or AC (signal) current sources.
608
+ //
609
+ // #### Usage
610
+ //
611
+ // ```
612
+ // i1(i) = resCurrent(i, R, jin);
613
+ // buildtree( A : i1 );
614
+ // ```
615
+ //
616
+ // Where:
617
+ //
618
+ // * `i`: index used by model-building functions. Should never be user declared.
619
+ // * `R` : Resistance/Impedance of the parallel resistor in Ohms
620
+ // * `jin` : Current through the ideal current source in Amps
621
+ //
622
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
623
+ // Correct implementation is shown above.
624
+ //
625
+ // #### Reference
626
+ //
627
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.5
628
+ //----------------------------------------------------------
629
+ declare resCurrent author "Dirk Roosenburg";
630
+ declare resCurrent copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
631
+ declare resCurrent license "MIT-style STK-4.3 license";
632
+ resCurrent =
633
+ case {
634
+ (0, R, jin) => !, R^(rho)*jin;
635
+ (1, R, jin) => _;
636
+ (2, R, jin) => R0
637
+ with {
638
+ R0 = R;
639
+ };
640
+ }with{
641
+ rho = 1; //assume voltage waves
642
+ };
643
+
644
+ //----------------------`(wd.)u_resCurrent`--------------------------
645
+ // Unadapted Resistive Current Source.
646
+ //
647
+ // An unadapted adaptor implementing a resistive current source within Wave Digital Filter connection trees.
648
+ //
649
+ // It should be used as the root/top element of the connection tree.
650
+ // It is comprised of an ideal current source in parallel with a resistor.
651
+ // Can be used for either DC (constant) or AC (signal) current sources.
652
+ //
653
+ // #### Usage
654
+ //
655
+ // ```
656
+ // i1(i) = u_resCurrent(i, R, jin);
657
+ // buildtree( i1 : B );
658
+ // ```
659
+ //
660
+ // Where:
661
+ //
662
+ // * `i`: index used by model-building functions. Should never be user declared.
663
+ // * `R` : Resistance/Impedance of the series resistor in Ohms
664
+ // * `jin` : Current through the ideal current source in Amps
665
+ //
666
+ // Note: only usable as the root of a tree.
667
+ // The adaptor must be declared as a separate function before integration into the connection tree.
668
+ // Correct implementation is shown above.
669
+ //
670
+ // #### Reference
671
+ //
672
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.5
673
+ //----------------------------------------------------------
674
+ declare u_resCurrent author "Dirk Roosenburg";
675
+ declare u_resCurrent copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
676
+ declare u_resCurrent license "MIT-style STK-4.3 license";
677
+ u_resCurrent =
678
+ case {
679
+ (0, R, jin) => b0
680
+ with{
681
+ b0(R0, a0) = a0*(R - R0)/(R + R0) + jin*(2*R*R0^rho)/(R + R0);
682
+ };
683
+ (1, R, jin) => !, !;
684
+ (2, R, jin) => 0;
685
+
686
+ }with{
687
+ rho = 1; //assume voltage waves
688
+ };
689
+
690
+ //TODO
691
+ //add short circuit (1.2.6), add open circuit (1.2.7)
692
+
693
+ //----------------------`(wd.)u_switch`--------------------------
694
+ // Unadapted Ideal Switch.
695
+ //
696
+ // An unadapted adaptor implementing an ideal switch for Wave Digital Filter connection trees.
697
+ //
698
+ // It should be used as the root/top element of the connection tree
699
+ //
700
+ // #### Usage
701
+ //
702
+ // ```
703
+ // s1(i) = u_resCurrent(i, lambda);
704
+ // buildtree( s1 : B );
705
+ // ```
706
+ //
707
+ // Where:
708
+ //
709
+ // * `i`: index used by model-building functions. Should never be user declared.
710
+ // * `lambda` : switch state control. -1 for closed switch, 1 for open switch.
711
+ //
712
+ // Note: only usable as the root of a tree.
713
+ // The adaptor must be declared as a separate function before integration into the connection tree.
714
+ // Correct implementation is shown above.
715
+ //
716
+ // #### Reference
717
+ //
718
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.2.8
719
+ //----------------------------------------------------------
720
+ declare u_switch author "Dirk Roosenburg";
721
+ declare u_switch copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
722
+ declare u_switch license "MIT-style STK-4.3 license";
723
+ u_switch =
724
+ case {
725
+ (0, lambda) => b0
726
+ with{
727
+ b0(R0, a0) = a0*lambda;
728
+ };
729
+ (1, lambda) => !, !;
730
+ (2, lambda) => 0;
731
+ };
732
+
733
+ //=============================Reactive One Port Adaptors=================================
734
+ //========================================================================================
735
+ //TODO - add mobius transform and alpha transform digitizations
736
+
737
+ //----------------------`(wd.)capacitor`--------------------------
738
+ // Adapted Capacitor.
739
+ //
740
+ // A basic adaptor implementing a capacitor for use within Wave Digital Filter connection trees.
741
+ //
742
+ // It should be used as a leaf/terminating element of the connection tree.
743
+ // This capacitor model was digitized using the bi-linear transform.
744
+ //
745
+ // #### Usage
746
+ //
747
+ // ```
748
+ // c1(i) = capacitor(i, R);
749
+ // buildtree( A : c1 ) : _
750
+ // ```
751
+ //
752
+ // Where:
753
+ //
754
+ // * `i`: index used by model-building functions. Should never be user declared.
755
+ // * `R` : Capacitance/Impedance of the capacitor being modeled in Farads.
756
+ //
757
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
758
+ // Correct implementation is shown above.
759
+ //
760
+ // #### Reference
761
+ //
762
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.3.1
763
+ //----------------------------------------------------------
764
+ declare capacitor author "Dirk Roosenburg";
765
+ declare capacitor copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
766
+ declare capacitor license "MIT-style STK-4.3 license";
767
+ capacitor =
768
+ case{
769
+ (0, R) => _*1;
770
+ (1, R) => _;
771
+ (2, R) => R0
772
+ with {
773
+ R0 = t/(2*R);
774
+ };
775
+ }with{
776
+ t = 1/ma.SR; //sampling interval
777
+ };
778
+
779
+ //----------------------`(wd.)capacitor_Vout`--------------------------
780
+ // Adapted Capacitor + voltage out.
781
+ //
782
+ // A basic adaptor implementing a capacitor for use within Wave Digital Filter connection trees.
783
+ //
784
+ // It should be used as a leaf/terminating element of the connection tree.
785
+ // The capacitor will also pass the voltage across itself as an output of the model.
786
+ // This capacitor model was digitized using the bi-linear transform.
787
+ //
788
+ // #### Usage
789
+ //
790
+ // ```
791
+ // cout(i) = capacitor_Vout(i, R);
792
+ // buildtree( A : cout ) : _
793
+ // ```
794
+ //
795
+ // Where:
796
+ //
797
+ // * `i`: index used by model-building functions. Should never be user declared
798
+ // * `R` : Capacitance/Impedence of the capacitor being modeled in Farads
799
+ //
800
+ // Note: the adaptor must be declared as a seperate function before integration into the connection tree.
801
+ // Correct implementation is shown above.
802
+ //
803
+ // #### Reference
804
+ //
805
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.3.1
806
+ //----------------------------------------------------------
807
+ declare capacitor_Vout author "Dirk Roosenburg";
808
+ declare capacitor_Vout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
809
+ declare capacitor_Vout license "MIT-style STK-4.3 license";
810
+ capacitor_Vout =
811
+ case{
812
+ (0, R) => b0
813
+ with{
814
+ b0(a1) = a1*1, a1*.5 + (a1')*.5;
815
+ };
816
+ (1, R) => _, !;
817
+ (2, R) => R0
818
+ with {
819
+ R0 = t/(2*R);
820
+ };
821
+ }with{
822
+ t = 1/ma.SR; //sampling interval
823
+ };
824
+
825
+ //----------------------`(wd.)inductor`--------------------------
826
+ // Unadapted Inductor.
827
+ //
828
+ // A basic adaptor implementing an inductor for use within Wave Digital Filter connection trees.
829
+ //
830
+ // It should be used as a leaf/terminating element of the connection tree.
831
+ // This inductor model was digitized using the bi-linear transform.
832
+ //
833
+ // #### Usage
834
+ //
835
+ // ```
836
+ // l1(i) = inductor(i, R);
837
+ // buildtree( A : l1 );
838
+ // ```
839
+ //
840
+ // Where:
841
+ //
842
+ // * `i`: index used by model-building functions. Should never be user declared
843
+ // * `R` : Inductance/Impedance of the inductor being modeled in Henries
844
+ //
845
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
846
+ // Correct implementation is shown above.
847
+ //
848
+ // #### Reference
849
+ //
850
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.3.2
851
+ //----------------------------------------------------------
852
+ declare inductor author "Dirk Roosenburg";
853
+ declare inductor copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
854
+ declare inductor license "MIT-style STK-4.3 license";
855
+ inductor =
856
+ case{
857
+ (0, R) => _*(-1);
858
+ (1, R) => _;
859
+ (2, R) => R0
860
+ with {
861
+ R0 = (2*R)/t;
862
+ };
863
+ }with{
864
+ t = 1/ma.SR; //sampling interval
865
+ };
866
+
867
+ //----------------------`(wd.)inductor_Vout`--------------------------
868
+ // Unadapted Inductor + Voltage out.
869
+ //
870
+ // A basic adaptor implementing an inductor for use within Wave Digital Filter connection trees.
871
+ //
872
+ // It should be used as a leaf/terminating element of the connection tree.
873
+ // The inductor will also pass the voltage across itself as an output of the model.
874
+ // This inductor model was digitized using the bi-linear transform.
875
+ //
876
+ // #### Usage
877
+ //
878
+ // ```
879
+ // lout(i) = inductor_Vout(i, R);
880
+ // buildtree( A : lout ) : _
881
+ // ```
882
+ //
883
+ // Where:
884
+ //
885
+ // * `i`: index used by model-building functions. Should never be user declared
886
+ // * `R` : Inductance/Impedance of the inductor being modeled in Henries
887
+ //
888
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
889
+ // Correct implementation is shown above.
890
+ //
891
+ // #### Reference
892
+ //
893
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.3.2
894
+ //----------------------------------------------------------
895
+ declare inductor_Vout author "Dirk Roosenburg";
896
+ declare inductor_Vout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
897
+ declare inductor_Vout license "MIT-style STK-4.3 license";
898
+ inductor_Vout =
899
+ case{
900
+ (0, R) => b0
901
+ with{
902
+ b0(a1) = a1*(-1), a1*.5 - (a1')*.5;
903
+ };
904
+ (1, R) => _, !;
905
+ (2, R) => R0
906
+ with {
907
+ R0 = (2*R)/t;
908
+ };
909
+ }with{
910
+ t = 1/ma.SR; //sampling interval
911
+ };
912
+
913
+ //===============================Nonlinear One Port Adaptors==============================
914
+ //========================================================================================
915
+
916
+ //----------------------`(wd.)u_idealDiode`--------------------------
917
+ // Unadapted Ideal Diode.
918
+ //
919
+ // An unadapted adaptor implementing an ideal diode for Wave Digital Filter connection trees.
920
+ //
921
+ // It should be used as the root/top element of the connection tree.
922
+ //
923
+ // #### Usage
924
+ //
925
+ // ```
926
+ // buildtree( u_idealDiode : B );
927
+ // ```
928
+ //
929
+ // Note: only usable as the root of a tree.
930
+ // Correct implementation is shown above.
931
+ //
932
+ // #### Reference
933
+ //
934
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 3.2.3
935
+ //----------------------------------------------------------
936
+ declare u_idealDiode author "Dirk Roosenburg";
937
+ declare u_idealDiode copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
938
+ declare u_idealDiode license "MIT-style STK-4.3 license";
939
+ u_idealDiode =
940
+ case{
941
+ (0) => b1
942
+ with{
943
+ b1(R1, a0) = a0 : abs : *(-1);
944
+ };
945
+ (1) => !, !;
946
+ (2) => 0;
947
+ };
948
+
949
+ //----------------------`(wd.)u_chua`--------------------------
950
+ // Unadapted Chua Diode.
951
+ //
952
+ // An adaptor implementing the chua diode / non-linear resistor within Wave Digital Filter connection trees.
953
+ //
954
+ // It should be used as the root/top element of the connection tree.
955
+ //
956
+ // #### Usage
957
+ //
958
+ // ```
959
+ // chua1(i) = u_chua(i, G1, G2, V0);
960
+ // buildtree( chua1 : B );
961
+ // ```
962
+ //
963
+ // Where:
964
+ //
965
+ // * `i`: index used by model-building functions. Should never be user declared
966
+ // * `G1` : resistance parameter 1 of the chua diode
967
+ // * `G2` : resistance parameter 2 of the chua diode
968
+ // * `V0` : voltage parameter of the chua diode
969
+ //
970
+ // Note: only usable as the root of a tree.
971
+ // The adaptor must be declared as a separate function before integration into the connection tree.
972
+ // Correct implementation is shown above.
973
+ //
974
+ // #### Reference
975
+ //
976
+ // Meerkotter and Scholz, "Digital Simulation of Nonlinear Circuits by Wave Digital Filter Principles"
977
+ //----------------------------------------------------------
978
+ declare u_chua author "Dirk Roosenburg";
979
+ declare u_chua copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
980
+ declare u_chua license "MIT-style STK-4.3 license";
981
+ u_chua =
982
+ case{
983
+ (0, G1, G2, V0) => b1
984
+ with{
985
+ b1(R1, a0) = g_1*a0 + 1/2*(g_2 - g_1)*(((a0 + a_0) : abs) - ((a0 - a_0): abs))
986
+ with{
987
+ g_1 = (1-G1*R1)/(1+G1*R1);
988
+ g_2 = (1-G2*R1)/(1+G2*R1);
989
+ a_0 = V0*(1+G2*R1);
990
+ };
991
+ };
992
+ (1, G1, G2, V0) => !, !;
993
+ (2, G1, G2, V0) => 0;
994
+ };
995
+
996
+
997
+ //----------------------`(wd.)lambert`--------------------------
998
+ // An implementation of the lambert function.
999
+ // It uses Halley's method of iteration to approximate the output.
1000
+ // Included in the WD library for use in non-linear diode models.
1001
+ // Adapted from K M Brigg's c++ lambert function approximation.
1002
+ //
1003
+ // #### Usage
1004
+ //
1005
+ // ```
1006
+ // lambert(n, itr) : _
1007
+ // ```
1008
+ //
1009
+ // Where:
1010
+ // * `n`: value at which the lambert function will be evaluated
1011
+ // * `itr`: number of iterations before output
1012
+ //
1013
+ //----------------------------------------------------------
1014
+ declare lambert author "Dirk Roosenburg";
1015
+ declare lambert copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1016
+ declare lambert license "MIT-style STK-4.3 license";
1017
+ lambert(z, itr) = ba.if((z<(-em1+.0001)), less_approx, greater_approx)
1018
+ with{
1019
+ less_approx = -1.0
1020
+ +2.331643981597124203363536062168*r
1021
+ -1.812187885639363490240191647568*q
1022
+ +1.936631114492359755363277457668*r*q
1023
+ -2.353551201881614516821543561516*q2
1024
+ with{
1025
+ q = z+em1;
1026
+ r = sqrt(q);
1027
+ q2 = q*q;
1028
+ };
1029
+ eps=4.0e-16;
1030
+ em1=0.3678794411714423215955237701614608;
1031
+ greater_approx = z : init : seq(i, itr, approx)
1032
+ with{
1033
+ init(w) = ba.if((z<1), init1, init2)
1034
+ with{
1035
+ init1 = -1.0+p*(1.0+p*(-0.333333333333333333333+p*0.152777777777777777777777))
1036
+ with{
1037
+ p = sqrt(2.0*(2.7182818284590452353602874713526625*z+1.0));
1038
+ };
1039
+ init2 = log(abs(z));
1040
+ };
1041
+ approx(w) = w-t
1042
+ with{
1043
+ e = exp(w);
1044
+ t = (w*e-z)/(e*p-.5*(p+1.0)*(w*e-z)/p);
1045
+ p = w+1;
1046
+ };
1047
+ };
1048
+ };
1049
+
1050
+
1051
+ //----------------------`(wd.)u_diodePair`--------------------------
1052
+ // Unadapted pair of diodes facing in opposite directions.
1053
+ //
1054
+ // An unadapted adaptor implementing two antiparallel diodes for Wave Digital Filter connection trees.
1055
+ // The behavior is approximated using Schottkey's ideal diode law.
1056
+ //
1057
+ // #### Usage
1058
+ //
1059
+ // ```
1060
+ // d1(i) = u_diodePair(i, Is, Vt);
1061
+ // buildtree( d1 : B );
1062
+ // ```
1063
+ //
1064
+ // Where:
1065
+ //
1066
+ // * `i`: index used by model-building functions. Should never be user declared
1067
+ // * `Is` : saturation current of the diodes
1068
+ // * `Vt` : thermal resistances of the diodes
1069
+ //
1070
+ // Note: only usable as the root of a tree.
1071
+ // Correct implementation is shown above.
1072
+ //
1073
+ // #### Reference
1074
+ //
1075
+ // K. Werner et al. "An Improved and Generalized Diode Clipper Model for Wave Digital Filters"
1076
+ //----------------------------------------------------------
1077
+ declare u_diodePair author "Dirk Roosenburg";
1078
+ declare u_diodePair copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1079
+ declare u_diodePair license "MIT-style STK-4.3 license";
1080
+ u_diodePair =
1081
+ case{
1082
+ (0, Is, Vt) => b1
1083
+ with{
1084
+ b1(R1, a1) = a1 + 2*R1*Is - 2*Vt*lambert((R1*Is/Vt*(((a1+R1*Is)/Vt), 3) : exp));
1085
+ };
1086
+ (1, Is, Vt) => !, !;
1087
+ (2, Is, Vt) => 0;
1088
+ };
1089
+
1090
+
1091
+ //----------------------`(wd.)u_diodeSingle`--------------------------
1092
+ // Unadapted single diode.
1093
+ //
1094
+ // An unadapted adaptor implementing a single diode for Wave Digital Filter connection trees.
1095
+ // The behavior is approximated using Schottkey's ideal diode law.
1096
+ //
1097
+ // #### Usage
1098
+ //
1099
+ // ```
1100
+ // d1(i) = u_diodeSingle(i, Is, Vt);
1101
+ // buildtree( d1 : B );
1102
+ // ```
1103
+ //
1104
+ // Where:
1105
+ //
1106
+ // * `i`: index used by model-building functions. Should never be user declared
1107
+ // * `Is` : saturation current of the diodes
1108
+ // * `Vt` : thermal resistances of the diodes
1109
+ //
1110
+ // Note: only usable as the root of a tree.
1111
+ // Correct implementation is shown above.
1112
+ //
1113
+ // #### Reference
1114
+ //
1115
+ // K. Werner et al. "An Improved and Generalized Diode Clipper Model for Wave Digital Filters"
1116
+ //----------------------------------------------------------
1117
+ declare u_diodeSingle author "Dirk Roosenburg";
1118
+ declare u_diodeSingle copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1119
+ declare u_diodeSingle license "MIT-style STK-4.3 license";
1120
+ u_diodeSingle =
1121
+ case{
1122
+ (0, Is, Vt) => b1
1123
+ with{
1124
+ b1(R1, a1) = ma.signum(a1)*((a1 : abs) + 2*R1*Is - 2*Vt*(lambert((R1*Is/Vt*((((a1 : abs)+R1*Is)/Vt) : exp)),3) + lambert((-R1*Is/Vt*(((-1*(a1 : abs)+R1*Is)/Vt) : exp)),3)));
1125
+ };
1126
+ (1, Is, Vt) => !, !;
1127
+ (2, Is, Vt) => 0;
1128
+ };
1129
+
1130
+ //----------------------`(wd.)u_diodeAntiparallel`--------------------------
1131
+ // Unadapted set of antiparallel diodes with M diodes facing forwards and N diodes facing backwards.
1132
+ //
1133
+ // An unadapted adaptor implementing antiparallel diodes for Wave Digital Filter connection trees.
1134
+ // The behavior is approximated using Schottkey's ideal diode law.
1135
+ //
1136
+ // #### Usage
1137
+ //
1138
+ // ```
1139
+ // d1(i) = u_diodeAntiparallel(i, Is, Vt);
1140
+ // buildtree( d1 : B );
1141
+ // ```
1142
+ //
1143
+ // Where:
1144
+ //
1145
+ // * `i`: index used by model-building functions. Should never be user declared
1146
+ // * `Is` : saturation current of the diodes
1147
+ // * `Vt` : thermal resistances of the diodes
1148
+ //
1149
+ // Note: only usable as the root of a tree.
1150
+ // Correct implementation is shown above.
1151
+ //
1152
+ // #### Reference
1153
+ //
1154
+ // K. Werner et al. "An Improved and Generalized Diode Clipper Model for Wave Digital Filters"
1155
+ //----------------------------------------------------------
1156
+ declare u_diodeAntiparallel author "Dirk Roosenburg";
1157
+ declare u_diodeAntiparallel copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1158
+ declare u_diodeAntiparallel license "MIT-style STK-4.3 license";
1159
+ u_diodeAntiparallel =
1160
+ case{
1161
+ (0, Is, Vt, M, N) => b1
1162
+ with{
1163
+ b1(R1, a1) = a1 - 2*lam*Vt*(mu0* lambert(((R1*Is)/(mu0*Vt) * exp((lam*a1)/(mu0*Vt))), 3) +
1164
+ mu1* lambert(((-R1*Is)/(mu1*Vt) * exp((-lam*a1)/(mu1*Vt))), 3))
1165
+ with{
1166
+ lam = ma.signum(a1);
1167
+ mu0 = ba.if((a1 < 0), N, M);
1168
+ mu1 = ba.if((a1 > 0), M, N);
1169
+ };
1170
+ };
1171
+ (1, Is, Vt, M, N) => !, !;
1172
+ (2, Is, Vt, M, N) => 0;
1173
+ };
1174
+
1175
+
1176
+ //=============================Two Port Adaptors==========================================
1177
+ //========================================================================================
1178
+
1179
+
1180
+ //----------------------`(wd.)u_parallel2Port`--------------------------
1181
+ // Unadapted 2-port parallel connection.
1182
+ //
1183
+ // An unadapted adaptor implementing a 2-port parallel connection between adaptors for Wave Digital Filter connection trees.
1184
+ // Elements connected to this adaptor will behave as if connected in parallel in circuit.
1185
+ //
1186
+ // #### Usage
1187
+ //
1188
+ // ```
1189
+ // buildtree( u_parallel2Port : (A, B) );
1190
+ // ```
1191
+ //
1192
+ // Note: only usable as the root of a tree.
1193
+ // This adaptor has no user-accessible parameters.
1194
+ // Correct implementation is shown above.
1195
+ //
1196
+ // #### Reference
1197
+ //
1198
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.1
1199
+ //----------------------------------------------------------
1200
+ declare u_parallel2Port author "Dirk Roosenburg";
1201
+ declare u_parallel2Port copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1202
+ declare u_parallel2Port license "MIT-style STK-4.3 license";
1203
+ u_parallel2Port =
1204
+ case{
1205
+ (0) => u_par
1206
+ with{
1207
+ u_par = si.bus(4) <: b0, b1;
1208
+ b0(R0, R1, a0, a1) = (-a0*(R0-R1) + a1*(2*R0^rho*R1^(1-rho)))/(R0+R1);
1209
+ b1(R0, R1, a0, a1) = (a1*(R0-R1) + a0*(2*R0^(1-rho)*R1^rho))/(R0+R1);
1210
+ };
1211
+ (1) => !, !, !, !;
1212
+ (2) => 0;
1213
+ }with{
1214
+ rho = 1; //assume voltage waves
1215
+ };
1216
+
1217
+
1218
+ //----------------------`(wd.)parallel2Port`--------------------------
1219
+ // Adapted 2-port parallel connection.
1220
+ //
1221
+ // An adaptor implementing a 2-port parallel connection between adaptors for Wave Digital Filter connection trees.
1222
+ // Elements connected to this adaptor will behave as if connected in parallel in circuit.
1223
+ //
1224
+ // #### Usage
1225
+ //
1226
+ // ```
1227
+ // buildtree( A : parallel2Port : B );
1228
+ // ```
1229
+ //
1230
+ // Note: this adaptor has no user-accessible parameters.
1231
+ // It should be used within the connection tree with one previous and one forward adaptor.
1232
+ // Correct implementation is shown above.
1233
+ //
1234
+ // #### Reference
1235
+ //
1236
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.1
1237
+ //----------------------------------------------------------
1238
+ declare parallel2Port author "Dirk Roosenburg";
1239
+ declare parallel2Port copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1240
+ declare parallel2Port license "MIT-style STK-4.3 license";
1241
+ parallel2Port =
1242
+ case{
1243
+ (0) => par_down
1244
+ with{
1245
+ par_down = b1;
1246
+ b1(R1, a0, a1) = a0;
1247
+ };
1248
+ (1) => par_up
1249
+ with{
1250
+ par_up = b0;
1251
+ b0(R1, a1) = a1;
1252
+ };
1253
+ (2) => R0
1254
+ with{
1255
+ R0(R1) = R1;
1256
+ };
1257
+ };
1258
+
1259
+ //----------------------`(wd.)u_series2Port`--------------------------
1260
+ // Unadapted 2-port series connection.
1261
+ //
1262
+ // An unadapted adaptor implementing a 2-port series connection between adaptors for Wave Digital Filter connection trees.
1263
+ // Elements connected to this adaptor will behave as if connected in series in circuit.
1264
+ //
1265
+ // #### Usage
1266
+ //
1267
+ // ```
1268
+ // buildtree( u_series2Port : (A, B) );
1269
+ // ```
1270
+ //
1271
+ // Note: only usable as the root of a tree.
1272
+ // This adaptor has no user-accessible parameters.
1273
+ // Correct implementation is shown above.
1274
+ //
1275
+ // #### Reference
1276
+ //
1277
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.1
1278
+ //----------------------------------------------------------
1279
+ declare u_series2Port author "Dirk Roosenburg";
1280
+ declare u_series2Port copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1281
+ declare u_series2Port license "MIT-style STK-4.3 license";
1282
+ u_series2Port =
1283
+ case{
1284
+ (0) => u_ser
1285
+ with{
1286
+ u_ser = si.bus(4) <: b0, b1;
1287
+ b0(R0, R1, a0, a1) = (-a0*(R0-R1) - a1*(2*R0^rho*R1^(1-rho)))/(R0+R1);
1288
+ b1(R0, R1, a0, a1) = (a1*(R0-R1) - a0*(2*R0^(1-rho)*R1^rho))/(R0+R1);
1289
+ };
1290
+ (1) => !, !, !, !;
1291
+ (2) => 0;
1292
+ }with{
1293
+ rho = 1; //assume voltage waves
1294
+ };
1295
+
1296
+
1297
+ //----------------------`(wd.)series2Port`--------------------------
1298
+ // Adapted 2-port series connection.
1299
+ //
1300
+ // An adaptor implementing a 2-port series connection between adaptors for Wave Digital Filter connection trees.
1301
+ // Elements connected to this adaptor will behave as if connected in series in circuit.
1302
+ //
1303
+ // #### Usage
1304
+ //
1305
+ // ```
1306
+ // buildtree( A : series2Port : B );
1307
+ // ```
1308
+ //
1309
+ // Note: this adaptor has no user-accessible parameters.
1310
+ // It should be used within the connection tree with one previous and one forward adaptor.
1311
+ // Correct implementation is shown above.
1312
+ //
1313
+ // #### Reference
1314
+ //
1315
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.1
1316
+ //----------------------------------------------------------
1317
+ declare series2Port author "Dirk Roosenburg";
1318
+ declare series2Port copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1319
+ declare series2Port license "MIT-style STK-4.3 license";
1320
+ series2Port =
1321
+ case{
1322
+ (0) => ser_down
1323
+ with{
1324
+ ser_down = b1;
1325
+ b1(R1, a0, a1) = -a0;
1326
+ };
1327
+ (1) => ser_up
1328
+ with{
1329
+ ser_up = b0;
1330
+ b0(R1, a1) = -a1;
1331
+ };
1332
+ (2) => R0
1333
+ with{
1334
+ R0(R1) = R1;
1335
+ };
1336
+ };
1337
+
1338
+
1339
+ //----------------------`(wd.)parallelCurrent`--------------------------
1340
+ // Adapted 2-port parallel connection + ideal current source.
1341
+ //
1342
+ // An adaptor implementing a 2-port series connection and internal idealized current source between adaptors for Wave Digital Filter connection trees.
1343
+ // This adaptor connects the two connected elements and an additional ideal current source in parallel.
1344
+ //
1345
+ // #### Usage
1346
+ //
1347
+ // ```
1348
+ // i1(i) = parallelCurrent(i, jin);
1349
+ // buildtree(A : i1 : B);
1350
+ // ```
1351
+ //
1352
+ // Where:
1353
+ //
1354
+ // * `i`: index used by model-building functions. Should never be user declared
1355
+ // * `jin` : Current through the ideal current source in Amps
1356
+ //
1357
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1358
+ // It should be used within a connection tree with one previous and one forward adaptor.
1359
+ // Correct implementation is shown above.
1360
+ //
1361
+ // #### Reference
1362
+ //
1363
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.2
1364
+ //----------------------------------------------------------
1365
+ declare parallelCurrent author "Dirk Roosenburg";
1366
+ declare parallelCurrent copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1367
+ declare parallelCurrent license "MIT-style STK-4.3 license";
1368
+ parallelCurrent =
1369
+ case{
1370
+ (0, jin) => par_current_down
1371
+ with{
1372
+ par_current_down = b1;
1373
+ b1(R1, a0, a1) = a0 + R1^rho*jin;
1374
+ };
1375
+ (1, jin) => par_current_up
1376
+ with{
1377
+ par_current_up = b0;
1378
+ b0(R1, a1) = a1 + R1^rho*jin;
1379
+ };
1380
+ (2, jin) => R0
1381
+ with{
1382
+ R0(R1) = R1;
1383
+ };
1384
+ }with{
1385
+ rho = 1; //assume voltage waves
1386
+ };
1387
+
1388
+
1389
+ //----------------------`(wd.)seriesVoltage`--------------------------
1390
+ // Adapted 2-port series connection + ideal voltage source.
1391
+ //
1392
+ // An adaptor implementing a 2-port series connection and internal ideal voltage source between adaptors for Wave Digital Filter connection trees.
1393
+ // This adaptor connects the two connected adaptors and an additional ideal voltage source in series.
1394
+ //
1395
+ // #### Usage
1396
+ //
1397
+ // ```
1398
+ // v1(i) = seriesVoltage(i, vin)
1399
+ // buildtree( A : v1 : B );
1400
+ // ```
1401
+ //
1402
+ // Where:
1403
+ //
1404
+ // * `i`: index used by model-building functions. Should never be user declared
1405
+ // * `vin` : voltage across the ideal current source in Volts
1406
+ //
1407
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1408
+ // It should be used within the connection tree with one previous and one forward adaptor.
1409
+ //
1410
+ // #### Reference
1411
+ //
1412
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.2
1413
+ //----------------------------------------------------------
1414
+ declare seriesVoltage author "Dirk Roosenburg";
1415
+ declare seriesVoltage copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1416
+ declare seriesVoltage license "MIT-style STK-4.3 license";
1417
+ seriesVoltage =
1418
+ case{
1419
+ (0, vin) => ser_down
1420
+ with{
1421
+ ser_down = b1;
1422
+ b1(R1, a0, a1) = -a0 - R1^(rho-1)*vin;
1423
+ };
1424
+ (1, vin) => ser_up
1425
+ with{
1426
+ ser_up = b0;
1427
+ b0(R1, a1) = -a1 - R1^(rho-1)*vin;
1428
+ };
1429
+ (2, vin) => R0
1430
+ with{
1431
+ R0(R1) = R1;
1432
+ };
1433
+ }with{
1434
+ rho = 1; //assume voltage waves
1435
+ };
1436
+
1437
+ //----------------------`(wd.)u_transformer`--------------------------
1438
+ // Unadapted ideal transformer.
1439
+ //
1440
+ // An adaptor implementing an ideal transformer for Wave Digital Filter connection trees.
1441
+ // The first downward-facing port corresponds to the primary winding connections, and the second downward-facing port to the secondary winding connections.
1442
+ //
1443
+ // #### Usage
1444
+ //
1445
+ // ```
1446
+ // t1(i) = u_transformer(i, tr);
1447
+ // buildtree(t1 : (A , B));
1448
+ // ```
1449
+ //
1450
+ // Where:
1451
+ //
1452
+ // * `i`: index used by model-building functions. Should never be user declared
1453
+ // * `tr` : the turn ratio between the windings on the primary and secondary coils
1454
+ //
1455
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1456
+ // It may only be used as the root of the connection tree with two forward nodes.
1457
+ //
1458
+ // #### Reference
1459
+ //
1460
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.3
1461
+ //----------------------------------------------------------
1462
+ declare u_transformer author "Dirk Roosenburg";
1463
+ declare u_transformer copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1464
+ declare u_transformer license "MIT-style STK-4.3 license";
1465
+ u_transformer(i, n) = u_genericNode(i, transformer_scatter)
1466
+ with{
1467
+ matrix(M,N,f) = si.bus(N) <: ro.interleave(N,M) : par(n,N, par(m,M,*(f(m+1,n+1)))) :> si.bus(M);
1468
+
1469
+ transformer_scatter(R0, R1) = matrix(2, 2, s)
1470
+ with{
1471
+ s(1,1) =-1*(R0-n^2*R1)/(R0+n^2*R1);
1472
+ s(1,2) = (2*n*R0^rho*R1^(1-rho))/(R0+n^2*R1);
1473
+ s(2,1) = (2*n*R0^(1-rho)*R1^rho)/(R0+n^2*R1);
1474
+ s(2,2) = (R0-n^2*R1)/(R0+n^2*R1);
1475
+ s(i,j) = 10;
1476
+
1477
+ rho = 1; //assume voltage waves
1478
+ };
1479
+ };
1480
+
1481
+ //----------------------`(wd.)transformer`--------------------------
1482
+ // Adapted ideal transformer.
1483
+ //
1484
+ // An adaptor implementing an ideal transformer for Wave Digital Filter connection trees.
1485
+ // The upward-facing port corresponds to the primary winding connections, and the downward-facing port to the secondary winding connections
1486
+ //
1487
+ // #### Usage
1488
+ //
1489
+ // ```
1490
+ // t1(i) = transformer(i, tr);
1491
+ // buildtree(A : t1 : B);
1492
+ // ```
1493
+ //
1494
+ // Where:
1495
+ //
1496
+ // * `i`: index used by model-building functions. Should never be user declared
1497
+ // * `tr` : the turn ratio between the windings on the primary and secondary coils
1498
+ //
1499
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1500
+ // It should be used within the connection tree with one backward and one forward nodes.
1501
+ //
1502
+ // #### Reference
1503
+ //
1504
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.3
1505
+ //----------------------------------------------------------
1506
+ declare transformer author "Dirk Roosenburg";
1507
+ declare transformer copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1508
+ declare transformer license "MIT-style STK-4.3 license";
1509
+ transformer(i, n) = genericNode(i, transformer_scatter, transformer_upPortRes)
1510
+ with{
1511
+ matrix(M,N,f) = si.bus(N) <: ro.interleave(N,M) : par(n,N, par(m,M,*(f(m+1,n+1)))) :> si.bus(M);
1512
+
1513
+ transformer_upPortRes(R1) = n^2*R1; //equation for upward-facing port resistance
1514
+
1515
+ transformer_scatter(R1) = matrix(2, 2, s)
1516
+ with{
1517
+ s(1,1) =-1*(R0-n^2*R1)/(R0+n^2*R1);
1518
+ s(1,2) = (2*n*R0^rho*R1^(1-rho))/(R0+n^2*R1);
1519
+ s(2,1) = (2*n*R0^(1-rho)*R1^rho)/(R0+n^2*R1);
1520
+ s(2,2) = (R0-n^2*R1)/(R0+n^2*R1);
1521
+ s(i,j) = 10;
1522
+
1523
+ rho = 1; //assume voltage waves
1524
+
1525
+ R0 = n^2*R1; //adapting condition
1526
+ };
1527
+ };
1528
+
1529
+
1530
+ //----------------------`(wd.)u_transformerActive`--------------------------
1531
+ // Unadapted ideal active transformer.
1532
+ //
1533
+ // An adaptor implementing an ideal transformer for Wave Digital Filter connection trees.
1534
+ // The first downward-facing port corresponds to the primary winding connections, and the second downward-facing port to the secondary winding connections.
1535
+ //
1536
+ // #### Usage
1537
+ //
1538
+ // ```
1539
+ // t1(i) = u_transformerActive(i, gamma1, gamma2);
1540
+ // buildtree(t1 : (A , B));
1541
+ // ```
1542
+ //
1543
+ // Where:
1544
+ //
1545
+ // * `i`: index used by model-building functions. Should never be user declared
1546
+ // * `gamma1` : the turn ratio describing the voltage relationship between the primary and secondary coils
1547
+ // * `gamma2` : the turn ratio describing the current relationship between the primary and secondary coils
1548
+ //
1549
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1550
+ // It may only be used as the root of the connection tree with two forward nodes.
1551
+ //
1552
+ // #### Reference
1553
+ //
1554
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.3
1555
+ //----------------------------------------------------------
1556
+ declare u_transformerActive author "Dirk Roosenburg";
1557
+ declare u_transformerActive copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1558
+ declare u_transformerActive license "MIT-style STK-4.3 license";
1559
+ u_transformerActive(i, gamma1, gamma2) = u_genericNode(i, transformerActive_scatter)
1560
+ with{
1561
+ matrix(M,N,f) = si.bus(N) <: ro.interleave(N,M) : par(n,N, par(m,M,*(f(m+1,n+1)))) :> si.bus(M);
1562
+
1563
+ transformerActive_scatter(R0, R1) = matrix(2, 2, s)
1564
+ with{
1565
+ s(1,1) =-1*(R0-gamma1*gamma2*R1)/(R0+gamma1*gamma2*R1);
1566
+ s(1,2) = (2*gamma1*R0^rho*R1^(1-rho))/(R0+gamma1*gamma2*R1);
1567
+ s(2,1) = (2*gamma2*R0^(1-rho)*R1^rho)/(R0+gamma1*gamma2*R1);
1568
+ s(2,2) = (R0-gamma1*gamma2*R1)/(R0+gamma1*gamma2*R1);
1569
+ s(i,j) = 10;
1570
+
1571
+ rho = 1; //assume voltage waves
1572
+ };
1573
+ };
1574
+
1575
+
1576
+ //----------------------`(wd.)transformerActive`--------------------------
1577
+ // Adapted ideal active transformer.
1578
+ //
1579
+ // An adaptor implementing an ideal active transformer for Wave Digital Filter connection trees.
1580
+ // The upward-facing port corresponds to the primary winding connections, and the downward-facing port to the secondary winding connections
1581
+ //
1582
+ // #### Usage
1583
+ //
1584
+ // ```
1585
+ // t1(i) = transformerActive(i, gamma1, gamma2);
1586
+ // buildtree(A : t1 : B);
1587
+ // ```
1588
+ //
1589
+ // Where:
1590
+ //
1591
+ // * `i`: index used by model-building functions. Should never be user declared
1592
+ // * `gamma1` : the turn ratio describing the voltage relationship between the primary and secondary coils
1593
+ // * `gamma2` : the turn ratio describing the current relationship between the primary and secondary coils
1594
+ //
1595
+ // Note: the adaptor must be declared as a separate function before integration into the connection tree.
1596
+ // It should be used within the connection tree with two forward nodes.
1597
+ //
1598
+ // #### Reference
1599
+ //
1600
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.4.3
1601
+ //----------------------------------------------------------
1602
+ declare transformerActive author "Dirk Roosenburg";
1603
+ declare transformerActive copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1604
+ declare transformerActive license "MIT-style STK-4.3 license";
1605
+ transformerActive(i, gamma1, gamma2) = genericNode(i, transformerActive_scatter, transformerActive_upPortRes)
1606
+ with{
1607
+ matrix(M,N,f) = si.bus(N) <: ro.interleave(N,M) : par(n,N, par(m,M,*(f(m+1,n+1)))) :> si.bus(M);
1608
+
1609
+ transformerActive_upPortRes(R1) = gamma1*gamma2*R1; //equation for upward-facing port resistance
1610
+
1611
+ transformerActive_scatter(R1) = matrix(2, 2, s)
1612
+ with{
1613
+ s(1,1) =-1*(R0-gamma1*gamma2*R1)/(R0+gamma1*gamma2*R1);
1614
+ s(1,2) = (2*gamma1*R0^rho*R1^(1-rho))/(R0+gamma1*gamma2*R1);
1615
+ s(2,1) = (2*gamma2*R0^(1-rho)*R1^rho)/(R0+gamma1*gamma2*R1);
1616
+ s(2,2) = (R0-gamma1*gamma2*R1)/(R0+gamma1*gamma2*R1);
1617
+ s(i,j) = 10;
1618
+
1619
+ rho = 1; //assume voltage waves
1620
+
1621
+ R0 = gamma1*gamma2*R1; //adapting condition
1622
+ };
1623
+ };
1624
+
1625
+
1626
+ //===============================Three Port Adaptors======================================
1627
+ //========================================================================================
1628
+
1629
+
1630
+ //----------------------`(wd.)parallel`--------------------------
1631
+ // Adapted 3-port parallel connection.
1632
+ //
1633
+ // An adaptor implementing a 3-port parallel connection between adaptors for Wave Digital Filter connection trees.
1634
+ // This adaptor is used to connect adaptors simulating components connected in parallel in the circuit.
1635
+ //
1636
+ // #### Usage
1637
+ //
1638
+ // ```
1639
+ // buildtree( A : parallel : (B, C) );
1640
+ // ```
1641
+ //
1642
+ // Note: this adaptor has no user-accessible parameters.
1643
+ // It should be used within the connection tree with one previous and two forward adaptors.
1644
+ //
1645
+ // #### Reference
1646
+ //
1647
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.5.1
1648
+ //----------------------------------------------------------
1649
+ declare parallel author "Dirk Roosenburg";
1650
+ declare parallel copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1651
+ declare parallel license "MIT-style STK-4.3 license";
1652
+ parallel=
1653
+ case{
1654
+ (0) => par_down
1655
+ with{
1656
+ par_down = si.bus(5) <: b1, b2;
1657
+ b1(R1, R2, a0, a1, a2) = a0 + a1 * -R1/(R1 + R2) + a2 * R1/(R1 + R2);
1658
+ b2(R1, R2, a0, a1, a2) = a0 + a1 * R2/(R1 + R2) + a2 * -R2/(R1 + R2);
1659
+ };
1660
+ (1) => par_up
1661
+ with{
1662
+ par_up = b0;
1663
+ b0(R1, R2, a1, a2) = a1 * R2/(R1 + R2) + a2 * R1/(R1 + R2);
1664
+ };
1665
+ (2) => R0
1666
+ with{
1667
+ R0(R1, R2) = 1/(1/R1+1/R2);
1668
+ };
1669
+
1670
+ };
1671
+
1672
+
1673
+ //----------------------`(wd.)series`--------------------------
1674
+ // Adapted 3-port series connection.
1675
+ //
1676
+ // An adaptor implementing a 3-port series connection between adaptors for Wave Digital Filter connection trees.
1677
+ // This adaptor is used to connect adaptors simulating components connected in series in the circuit.
1678
+ //
1679
+ // #### Usage
1680
+ //
1681
+ // ```
1682
+ //
1683
+ // tree = A : (series : (B, C));
1684
+ // ```
1685
+ //
1686
+ // Note: this adaptor has no user-accessible parameters.
1687
+ // It should be used within the connection tree with one previous and two forward adaptors.
1688
+ //
1689
+ // #### Reference
1690
+ //
1691
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 1.5.2
1692
+ //----------------------------------------------------------
1693
+ declare series author "Dirk Roosenburg";
1694
+ declare series copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1695
+ declare series license "MIT-style STK-4.3 license";
1696
+ series =
1697
+ case{
1698
+
1699
+ (0) => ser_down
1700
+ with{
1701
+ ser_down = si.bus(5)<: b1, b2;
1702
+ b1(R1, R2, a0, a1, a2) = a0 * -R1/(R1+R2) + a1 * R2/(R1+R2) + a2 *-R1/(R1+R2);
1703
+ b2(R1, R2, a0, a1, a2) = a0 * -R2/(R1+R2) + a1 * -R2/(R1+R2) + a2 * R1/(R1+R2);
1704
+ };
1705
+ (1) => ser_up
1706
+ with{
1707
+ ser_up = b0;
1708
+ b0(R1, R2, a1, a2) = -a1 - a2;
1709
+ };
1710
+ (2) => R0
1711
+ with{
1712
+ R0(R1, R2) = R1 + R2;
1713
+ };
1714
+ };
1715
+
1716
+ //====================================R-Type Adaptors=====================================
1717
+ //========================================================================================
1718
+
1719
+
1720
+ //----------------------`(wd.)u_sixportPassive`--------------------------
1721
+ // Unadapted six-port rigid connection.
1722
+ //
1723
+ // An adaptor implementing a six-port passive rigid connection between elements.
1724
+ // It implements the simplest possible rigid connection found in the Fender Bassman Tonestack circuit.
1725
+ //
1726
+ //
1727
+ // #### Usage
1728
+ //
1729
+ // ```
1730
+ //
1731
+ // tree = u_sixportPassive : (A, B, C, D, E, F));
1732
+ // ```
1733
+ //
1734
+ // Note: this adaptor has no user-accessible parameters.
1735
+ // It should be used within the connection tree with six forward adaptors.
1736
+ //
1737
+ // #### Reference
1738
+ //
1739
+ // K. Werner, "Virtual Analog Modeling of Audio Circuitry Using Wave Digital Filters", 2.1.5
1740
+ //----------------------------------------------------------
1741
+ declare u_sixportPassive author "Dirk Roosenburg";
1742
+ declare u_sixportPassive copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1743
+ declare u_sixportPassive license "MIT-style STK-4.3 license";
1744
+ u_sixportPassive(i) = genericNode(i, sixport_scatter)
1745
+ with{
1746
+ sixport_scatter(Ra, Rb, Rc, Rd, Re, Rf) = matrix(6, 6, mtx)
1747
+ with{
1748
+ mtx =
1749
+ case{
1750
+ (1, 1) => ((-Ra)*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1751
+ (1, 2) => (2*Ra*((Rc + Re)*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1752
+ (1, 3) => (2*Ra*(Rb*Rd + Re*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1753
+ (1, 4) => (-1)*((2*Ra*(Rb*(Rc + Re) + Rc*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1754
+ (1, 5) => (2*Ra*(Rb*Rd - Rc*Rf))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1755
+ (1, 6) => (-1)*((2*Ra*(Rc*Re + Rb*(Rc + Rd + Re)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1756
+ (2, 1) => (2*Rb*((Rc + Re)*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1757
+ (2, 2) => (Ra*(Rd*Re - Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) - Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1758
+ (2, 3) => (-1)*((2*Rb*(Ra*Re + Re*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1759
+ (2, 4) => (-2*Ra*Rb*Re + 2*Rb*Rc*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1760
+ (2, 5) => (2*Rb*(Ra*(Rc + Rd) + Rc*(Rd + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1761
+ (2, 6) => (-1)*((2*Rb*(Rc*Rd + Ra*(Rc + Rd + Re)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1762
+ (3, 1) => (2*Rc*(Rb*Rd + Re*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1763
+ (3, 2) => (-1)*((2*Rc*(Ra*Re + Re*Rf + Rd*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1764
+ (3, 3) => 1 - (2*Rc*(Rd*Re + Rd*Rf + Re*Rf + Rb*(Rd + Rf) + Ra*(Rb + Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1765
+ (3, 4) => (-1)*((2*Rc*(Rb*Rf + Ra*(Rb + Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1766
+ (3, 5) => (-1)*((2*Rc*(Ra*(Rb + Rf) + Rb*(Rd + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1767
+ (3, 6) => (2*Rc*(Rb*Rd - Ra*Re))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1768
+ (4, 1) => (-1)*((2*Rd*(Rb*(Rc + Re) + Rc*(Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1769
+ (4, 2) => (-2*Ra*Rd*Re + 2*Rc*Rd*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1770
+ (4, 3) => (-1)*((2*Rd*(Rb*Rf + Ra*(Rb + Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1771
+ (4, 4) => 1 - (2*Rd*(Rc*(Re + Rf) + Ra*(Rb + Re + Rf) + Rb*(Rc + Re + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1772
+ (4, 5) => (-1)*((2*Rd*((Rb + Rc)*Rf + Ra*(Rb + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1773
+ (4, 6) => (-1)*((2*Rd*((Ra + Rc)*Re + Rb*(Rc + Re)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1774
+ (5, 1) => (2*Re*(Rb*Rd - Rc*Rf))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1775
+ (5, 2) => (2*Re*(Ra*(Rc + Rd) + Rc*(Rd + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1776
+ (5, 3) => (-1)*((2*Re*(Ra*(Rb + Rf) + Rb*(Rd + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1777
+ (5, 4) => (-1)*((2*Re*((Rb + Rc)*Rf + Ra*(Rb + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1778
+ (5, 5) => 1 - (2*Re*((Rb + Rc)*(Rd + Rf) + Ra*(Rb + Rc + Rd + Rf)))/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1779
+ (5, 6) => (2*((Rb + Rc)*Rd + Ra*(Rc + Rd))*Re)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1780
+ (6, 1) => (-1)*((2*(Rc*Re + Rb*(Rc + Rd + Re))*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1781
+ (6, 2) => (-1)*((2*(Rc*Rd + Ra*(Rc + Rd + Re))*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1782
+ (6, 3) => (2*(Rb*Rd - Ra*Re)*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1783
+ (6, 4) => (-1)*((2*((Ra + Rc)*Re + Rb*(Rc + Re))*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf))));
1784
+ (6, 5) => (2*((Rb + Rc)*Rd + Ra*(Rc + Rd))*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1785
+ (6, 6) => 1 - (2*(Rc*(Rd + Re) + Ra*(Rc + Rd + Re) + Rb*(Rc + Rd + Re))*Rf)/(Ra*(Rd*Re + Rb*(Rc + Rd + Re) + Rd*Rf + Re*Rf + Rc*(Re + Rf)) + Rc*(Re*Rf + Rd*(Re + Rf)) + Rb*(Re*Rf + Rc*(Rd + Rf) + Rd*(Re + Rf)));
1786
+ (i, j) => 10;
1787
+ };
1788
+ matrix(M,N,f) = si.bus(N) <: ro.interleave(N,M) : par(n,N, par(m,M,*(f(m+1,n+1)))) :> si.bus(M);
1789
+ };
1790
+ };
1791
+
1792
+ //===============================Node Creating Functions==================================
1793
+ //========================================================================================
1794
+
1795
+ //----------------------`(wd.)genericNode`--------------------------
1796
+ // Function for generating an adapted node from another faust function or scattering matrix.
1797
+ //
1798
+ // This function generates a node which is suitable for use in the connection tree structure.
1799
+ // `genericNode` separates the function that it is passed into upward-going and downward-going waves.
1800
+ //
1801
+ // #### Usage
1802
+ //
1803
+ // ```
1804
+ // n1(i) = genericNode(i, scatter, upRes);
1805
+ // ```
1806
+ //
1807
+ // Where:
1808
+ //
1809
+ // * `i`: index used by model-building functions. Should never be user declared
1810
+ // * `scatter` : the function which describes the the node's scattering behavior
1811
+ // * `upRes` : the function which describes the node's upward-facing port-resistance
1812
+ //
1813
+ // Note: `scatter` must be a function with n inputs, n outputs, and n-1 parameter inputs.
1814
+ // input/output 1 will be used as the adapted upward-facing port of the node, ports 2 to n will all be downward-facing.
1815
+ // The first input/output pair is assumed to already be adapted - i.e. the output 1 is not dependent on input 1.
1816
+ // The parameter inputs will receive the port resistances of the downward-facing ports.
1817
+ //
1818
+ // `upRes` must be a function with n-1 parameter inputs and 1 output.
1819
+ // The parameter inputs will receive the port resistances of the downward-facing ports.
1820
+ // The output should give the upward-facing port resistance of the node based on the upward-facing port resistances of the input.
1821
+ //
1822
+ // If used on a leaf element (n=1), the model will automatically introduce a one-sample delay.
1823
+ // Thus, the output of the node at sample t based on the input, a[t], should be the output one sample ahead, b[t+1].
1824
+ // This may require transformation of the output signal.
1825
+ //
1826
+ //----------------------------------------------------------
1827
+ declare genericNode author "Dirk Roosenburg";
1828
+ declare genericNode copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1829
+ declare genericNode license "MIT-style STK-4.3 license";
1830
+ genericNode =
1831
+ case{
1832
+ (0, scatter, upRes) => down(inputs(scatter))
1833
+ with{
1834
+ down(1) = scatter; //leaf node case
1835
+ down(n) = scatter : !, bus(outputs(scatter)-1); //internal node case
1836
+ };
1837
+ (1, scatter, upRes) => up(inputs(scatter))
1838
+ with{
1839
+ up(1) = _; //leaf node case
1840
+ up(n) = bus(inputs(upRes)), 0 , bus(outputs(scatter)-1) : scatter : _, block(outputs(scatter)-1); //internal node case
1841
+ };
1842
+ (2, scatter, upRes) => upRes;
1843
+ }
1844
+ with{
1845
+ bus(0) = 0:!;
1846
+ bus(x) = si.bus(x);
1847
+ block(0) = 0:!;
1848
+ block(x) = si.block(x);
1849
+ };
1850
+
1851
+
1852
+ //----------------------`(wd.)genericNode_Vout`--------------------------
1853
+ // Function for generating a terminating/leaf node which gives the voltage across itself as a model output.
1854
+ //
1855
+ // This function generates a node which is suitable for use in the connection tree structure.
1856
+ // It also calculates the voltage across the element and gives it as a model output.
1857
+ //
1858
+ // #### Usage
1859
+ //
1860
+ // ```
1861
+ // n1(i) = genericNode_Vout(i, scatter, upRes);
1862
+ // ```
1863
+ //
1864
+ // Where:
1865
+ //
1866
+ // * `i`: index used by model-building functions. Should never be user declared
1867
+ // * `scatter` : the function which describes the the node's scattering behavior
1868
+ // * `upRes` : the function which describes the node's upward-facing port-resistance
1869
+ //
1870
+ // Note: `scatter` must be a function with 1 input and 1 output.
1871
+ // It should give the output from the node based on the incident wave.
1872
+ //
1873
+ // The model will automatically introduce a one-sample delay to the output of the function
1874
+ // Thus, the output of the node at sample t based on the input, a[t], should be the output one sample ahead, b[t+1].
1875
+ // This may require transformation of the output signal.
1876
+ //
1877
+ // `upRes` must be a function with no inputs and 1 output.
1878
+ // The output should give the upward-facing port resistance of the node.
1879
+ //
1880
+ //----------------------------------------------------------
1881
+ declare genericNode_Vout author "Dirk Roosenburg";
1882
+ declare genericNode_Vout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1883
+ declare genericNode_Vout license "MIT-style STK-4.3 license";
1884
+ genericNode_Vout =
1885
+ case{
1886
+ (0, scatter, upRes) => _ <: b, voltage
1887
+ with{
1888
+ b(a) = a : scatter;
1889
+ voltage(a) = 1/2*(a + b(a)');
1890
+ };
1891
+ (1, scatter, upRes) => _, !;
1892
+ (2, scatter, upRes) => upRes;
1893
+ };
1894
+
1895
+ //----------------------`(wd.)genericNode_Iout`--------------------------
1896
+ // Function for generating a terminating/leaf node which gives the current through itself as a model output.
1897
+ //
1898
+ // This function generates a node which is suitable for use in the connection tree structure.
1899
+ // It also calculates the current through the element and gives it as a model output.
1900
+ //
1901
+ // #### Usage
1902
+ //
1903
+ // ```
1904
+ // n1(i) = genericNode_Iout(i, scatter, upRes);
1905
+ // ```
1906
+ //
1907
+ // Where:
1908
+ //
1909
+ // * `i`: index used by model-building functions. Should never be user declared
1910
+ // * `scatter` : the function which describes the the node's scattering behavior
1911
+ // * `upRes` : the function which describes the node's upward-facing port-resistance
1912
+ //
1913
+ // Note: `scatter` must be a function with 1 input and 1 output.
1914
+ // It should give the output from the node based on the incident wave.
1915
+ //
1916
+ // The model will automatically introduce a one-sample delay to the output of the function.
1917
+ // Thus, the output of the node at sample t based on the input, a[t], should be the output one sample ahead, b[t+1].
1918
+ // This may require transformation of the output signal.
1919
+ //
1920
+ // `upRes` must be a function with no inputs and 1 output.
1921
+ // The output should give the upward-facing port resistance of the node.
1922
+ //
1923
+ //----------------------------------------------------------
1924
+ declare genericNode_Iout author "Dirk Roosenburg";
1925
+ declare genericNode_Iout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1926
+ declare genericNode_Iout license "MIT-style STK-4.3 license";
1927
+ genericNode_Iout =
1928
+ case{
1929
+ (0, scatter, upRes) => _ <: b, current
1930
+ with{
1931
+ b(a) = a : scatter;
1932
+ current(a) = 1/2/upRes*(a - b(a)');
1933
+ };
1934
+ (1, scatter, upRes) => _, !;
1935
+ (2, scatter, upRes) => upRes;
1936
+ };
1937
+
1938
+
1939
+ //----------------------`(wd.)u_genericNode`--------------------------
1940
+ // Function for generating an unadapted node from another Faust function or scattering matrix.
1941
+ //
1942
+ // This function generates a node which is suitable for use as the root of the connection tree structure.
1943
+ //
1944
+ // #### Usage
1945
+ //
1946
+ // ```
1947
+ // n1(i) = u_genericNode(i, scatter);
1948
+ // ```
1949
+ //
1950
+ // Where:
1951
+ //
1952
+ // * `i`: index used by model-building functions. Should never be user declared
1953
+ // * `scatter` : the function which describes the the node's scattering behavior
1954
+ //
1955
+ // Note:
1956
+ // `scatter` must be a function with n inputs, n outputs, and n parameter inputs.
1957
+ // each input/output pair will be used as a downward-facing port of the node
1958
+ // the parameter inputs will receive the port resistances of the downward-facing ports.
1959
+ //
1960
+ //----------------------------------------------------------
1961
+ declare u_genericNode author "Dirk Roosenburg";
1962
+ declare u_genericNode copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1963
+ declare u_genericNode license "MIT-style STK-4.3 license";
1964
+ u_genericNode =
1965
+ case{
1966
+ (0, scatter) => scatter;
1967
+ (1, scatter) => block(inputs(scatter));
1968
+ (2, scatter) => 1234;
1969
+ }
1970
+ with{
1971
+ block(0) = 0:!;
1972
+ block(x) = si.block(x);
1973
+ };
1974
+
1975
+
1976
+ //===============================Model Building Functions=================================
1977
+ //========================================================================================
1978
+
1979
+
1980
+ //----------------------`(wd.)builddown`--------------------------
1981
+ // Function for building the structure for calculating waves traveling down the WD connection tree.
1982
+ //
1983
+ // It recursively steps through the given tree, parametrizes the adaptors, and builds an algorithm.
1984
+ // It is used in conjunction with the buildup() function to create a model.
1985
+ //
1986
+ // #### Usage
1987
+ //
1988
+ // ```
1989
+ // builddown(A : B)~buildup(A : B);
1990
+ // ```
1991
+ //
1992
+ // Where:
1993
+ // `(A : B)` : is a connection tree composed of WD adaptors
1994
+ //----------------------------------------------------------
1995
+ declare builddown author "Dirk Roosenburg";
1996
+ declare builddown copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
1997
+ declare builddown license "MIT-style STK-4.3 license";
1998
+ builddown(A : As) = ((upPortRes, addins(inputs(A(0)) - outputs(upPortRes))) : A(0)) , addins(inputs(pardown(As)) - outputs(A(0))) : route(mtxsum(s_mtx(As)), mtxsum(s_mtx(As)), gencross(0, 0, 0, 0, 0, s_mtx(As))) : pardown(As)
1999
+ with{
2000
+
2001
+ //substitute for si.bus which can accept an argument of 0
2002
+ addins =
2003
+ case{
2004
+ (0) => 0 : !;
2005
+ (x) => si.bus(x);
2006
+ };
2007
+
2008
+ //recursively build in parallel
2009
+ pardown =
2010
+ case{
2011
+ ((Ax, Axx)) => builddown(Ax), pardown(Axx);
2012
+ (Ax) => builddown(Ax);
2013
+ };
2014
+
2015
+ //generate a list of inputs from the next stage down the tree
2016
+ s_mtx =
2017
+ case{
2018
+ ((Ax, Axx)) => inputs(builddown(Ax)), s_mtx(Axx);
2019
+ (Ax) => inputs(builddown(Ax));
2020
+ };
2021
+
2022
+ //take the sum of the list
2023
+ mtxsum(t_mtx) = sum(i, ba.count(t_mtx), ba.take(i+1, t_mtx));
2024
+
2025
+ upPortRes = parres(As);
2026
+
2027
+ //generate a crossover matrix for the route object based on a list of i/o dimensions
2028
+ gencross =
2029
+ case{
2030
+ (0, 0, 0, 0, 0, (1, 1)) => 1, 1, 2, 2;
2031
+ (0, 0, 0, 0, 0, (xs, xxs)) => (1, 1), gencross(2, xs+1, ba.count((xs, xxs))-1, 2, mtxsum((xs, xxs)), xxs);
2032
+
2033
+ (0, 0, 0, 0, 0, 0) => 0 : !;
2034
+ (0, 0, 0, 0, 0, x) => par(i, x, i+1, i+1);
2035
+
2036
+ //((out, next, norm_index, spec_index, sum), (xs, xxs))
2037
+
2038
+ (msum, msum, count, fcount, msum, xs) => (fcount, msum); //output is a special output
2039
+ (msum, next, count, fcount, msum, xs) => (msum, msum-count); //escape case, reached end of bus
2040
+
2041
+ (out, out, count, fcount, msum, (xs, xxs)) => (fcount, out), gencross(out+1, xs+out, count-1, fcount+1, msum, xxs);
2042
+ (out, out, count, fcount, msum, xs) => (fcount, out), gencross(out+1, xs+out, count-1, fcount+1, msum, 0); //output is a special output
2043
+
2044
+ (out, next, count, fcount, msum, xs) => ((count+out), out), gencross(out+1, next, count, fcount, msum, xs); //output is not a special output
2045
+ };
2046
+ };
2047
+
2048
+ builddown(A) = A(0);
2049
+
2050
+
2051
+ //----------------------`(wd.)buildup`--------------------------
2052
+ // Function for building the structure for calculating waves traveling up the WD connection tree.
2053
+ //
2054
+ // It recursively steps through the given tree, parametrizes the adaptors, and builds an algorithm.
2055
+ // It is used in conjunction with the builddown() function to create a full structure.
2056
+ //
2057
+ // #### Usage
2058
+ //
2059
+ // ```
2060
+ // builddown(A : B)~buildup(A : B);
2061
+ // ```
2062
+ //
2063
+ // Where:
2064
+ // `(A : B)` : is a connection tree composed of WD adaptors
2065
+ //----------------------------------------------------------
2066
+ declare builddown author "Dirk Roosenburg";
2067
+ declare builddown copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
2068
+ declare builddown license "MIT-style STK-4.3 license";
2069
+ buildup(A : As) = upPortRes, (parup(As) : route(mtxsum(s_mtx(As)), mtxsum(s_mtx(As)), gencross_up(0, 0, 0, 0, 0, s_mtx(As))) : split(s_mtx(As))) : A(1), addins(outputs(split(s_mtx(As))) + outputs(upPortRes) - inputs(A(1)))
2070
+ with{
2071
+
2072
+ //substitute for si.bus which can accept an argument of 0
2073
+ addins =
2074
+ case{
2075
+ (0) => 0 : !;
2076
+ (x) => si.bus(x);
2077
+ };
2078
+
2079
+ //recursively build in parallel
2080
+ parup = //<: crossover(out_list(Ap)) : split(out_list(Ap))
2081
+ case{
2082
+ ((Ax, Axx)) => buildup(Ax), parup(Axx);
2083
+ (Ax) => buildup(Ax);
2084
+ };
2085
+
2086
+ //generate a list of outputs from the next stage down the tree
2087
+ s_mtx =
2088
+ case{
2089
+ ((Ax, Axx)) => outputs(buildup(Ax)), s_mtx(Axx);
2090
+ (Ax) => outputs(buildup(Ax));
2091
+ };
2092
+
2093
+ //take the sum of a list
2094
+ mtxsum(t_mtx) = sum(i, ba.count(t_mtx), ba.take(i+1, t_mtx));
2095
+
2096
+ //split based on a list of i/o dimensions
2097
+ split(inl) = (si.bus(n) <: si.bus(n), si.bus(n)), (addins(s-n))
2098
+ with{
2099
+ n = ba.count(inl);
2100
+ s = inl :> _;
2101
+ };
2102
+
2103
+ //generate a crossover matrix based for the route object based on a list of i/o dimensions
2104
+ gencross_up =
2105
+ case{
2106
+ //corner case which must be coded manually
2107
+ (0, 0, 0, 0, 0, (1, 1)) => 1, 1, 2, 2;
2108
+ //user access function
2109
+ (0, 0, 0, 0, 0, (xs, xxs)) => (1, 1), gencross_up(2, xs+1, ba.count((xs, xxs))-1, 2, mtxsum((xs, xxs)), xxs);
2110
+
2111
+ //more corner cases
2112
+ (0, 0, 0, 0, 0, 0) => 0: !;
2113
+ (0, 0, 0, 0, 0, x) => par(i, x, i+1, i+1);
2114
+
2115
+ //((out, next, norm_index, spec_index, sum), (xs, xxs))
2116
+
2117
+ (msum, msum, count, fcount, msum, xs) => (msum, fcount); //output is a special output
2118
+ (msum, next, count, fcount, msum, xs) => (msum-count, msum); //escape case, reached end of bus
2119
+
2120
+ (out, out, count, fcount, msum, (xs, xxs)) => (out, fcount), gencross_up(out+1, xs+out, count-1, fcount+1, msum, xxs);
2121
+ (out, out, count, fcount, msum, xs) => (out, fcount), gencross_up(out+1, xs+out, count-1, fcount+1, msum, 0); //output is a special output
2122
+
2123
+ (out, next, count, fcount, msum, xs) => (out, (count+out)), gencross_up(out+1, next, count, fcount, msum, xs); //output is not a special output
2124
+ };
2125
+
2126
+ upPortRes = parres(As);
2127
+ };
2128
+
2129
+ buildup(A) = A(1);
2130
+
2131
+ //----------------------`(wd.)getres`--------------------------
2132
+ // Function for determining the upward-facing port resistance of a partial WD connection tree.
2133
+ //
2134
+ // It recursively steps through the given tree, parametrizes the adaptors, and builds an algorithm.
2135
+ // It is used by the buildup and builddown functions but is also helpful in testing.
2136
+ //
2137
+ // #### Usage
2138
+ //
2139
+ // ```
2140
+ // getres(A : B)~getres(A : B);
2141
+ // ```
2142
+ //
2143
+ // Where:
2144
+ // `(A : B)` : is a partial connection tree composed of WD adaptors
2145
+ //
2146
+ // Note:
2147
+ // This function cannot be used on a complete WD tree. When called on an unadapted adaptor (u_ prefix), it will create errors.
2148
+ //----------------------------------------------------------
2149
+ declare getres author "Dirk Roosenburg";
2150
+ declare getres copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
2151
+ declare getres license "MIT-style STK-4.3 license";
2152
+ getres(A: As) = parres(As) : A(2);
2153
+ getres(A) = A(2);
2154
+
2155
+
2156
+ //----------------------`(wd.)parres`--------------------------
2157
+ // Function for determining the upward-facing port resistance of a partial WD connection tree.
2158
+ //
2159
+ // It recursively steps through the given tree, parametrizes the adaptors, and builds an algorithm.
2160
+ // It is used by the buildup and builddown functions but is also helpful in testing.
2161
+ // This function is a parallelized version of `getres`.
2162
+ //
2163
+ // #### Usage
2164
+ //
2165
+ // ```
2166
+ // parres((A , B))~parres((A , B));
2167
+ // ```
2168
+ //
2169
+ // Where:
2170
+ // `(A , B)` : is a partial connection tree composed of WD adaptors
2171
+ //
2172
+ // Note: this function cannot be used on a complete WD tree. When called on an unadapted adaptor (u_ prefix), it will create errors.
2173
+ //----------------------------------------------------------
2174
+ declare parres author "Dirk Roosenburg";
2175
+ declare parres copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
2176
+ declare parres license "MIT-style STK-4.3 license";
2177
+ parres((Ap1, Ap2)) = getres(Ap1) , parres(Ap2);
2178
+ parres(Ap) = getres(Ap);
2179
+
2180
+
2181
+ //----------------------`(wd.)buildout`--------------------------
2182
+ // Function for creating the output matrix for a WD model from a WD connection tree.
2183
+ //
2184
+ // It recursively steps through the given tree and creates an output matrix passing only outputs.
2185
+ //
2186
+ // #### Usage
2187
+ //
2188
+ // ```
2189
+ // buildout( A : B );
2190
+ // ```
2191
+ //
2192
+ // Where:
2193
+ // `(A : B)` : is a connection tree composed of WD adaptors
2194
+ //
2195
+ //----------------------------------------------------------
2196
+ declare buildout author "Dirk Roosenburg";
2197
+ declare buildout copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
2198
+ declare buildout license "MIT-style STK-4.3 license";
2199
+ buildout(A: As) = parout(As)
2200
+ with{
2201
+ parout((A, Ap)) = buildout(A), parout(Ap);
2202
+ parout(A) = buildout(A);
2203
+ };
2204
+ buildout(A) = outmtx(outputs(A(0)))
2205
+ with{
2206
+ outmtx(1) = !;
2207
+ outmtx(2) = !, _;
2208
+ };
2209
+
2210
+
2211
+ //----------------------`(wd.)buildtree`--------------------------
2212
+ // Function for building the DSP model from a WD connection tree structure.
2213
+ //
2214
+ // It recursively steps through the given tree, parametrizes the adaptors, and builds the algorithm.
2215
+ //
2216
+ // #### Usage
2217
+ //
2218
+ // ```
2219
+ // buildtree(A : B);
2220
+ // ```
2221
+ //
2222
+ // Where:
2223
+ // `(A : B)` : a connection tree composed of WD adaptors
2224
+ //----------------------------------------------------------
2225
+ declare buildtree author "Dirk Roosenburg";
2226
+ declare buildtree copyright "Copyright (C) 2020 by Dirk Roosenburg <dirk.roosenburg.30@gmail.com>";
2227
+ declare buildtree license "MIT-style STK-4.3 license";
2228
+ buildtree((A : B)) = builddown(A : B)~buildup(A : B) : buildout(A : B);
2229
+
2230
+
2231
+ /*******************************************************************************
2232
+ # Licenses
2233
+
2234
+ ## STK 4.3 License
2235
+
2236
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
2237
+ this software and associated documentation files (the "Software"), to deal in
2238
+ the Software without restriction, including without limitation the rights to
2239
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
2240
+ of the Software, and to permit persons to whom the Software is furnished to do
2241
+ so, subject to the following conditions:
2242
+
2243
+ The above copyright notice and this permission notice shall be included in all
2244
+ copies or substantial portions of the Software.
2245
+
2246
+ Any person wishing to distribute modifications to the Software is asked to send
2247
+ the modifications to the original developer so that they can be incorporated
2248
+ into the canonical version. For software copyrighted by Dirk Roosenburg,
2249
+ email your modifications to <dirk.roosenburg.30@gmail.com>. This is, however, not a
2250
+ binding provision of this license.
2251
+
2252
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2253
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2254
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2255
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2256
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2257
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2258
+ SOFTWARE.
2259
+
2260
+ --------------------------------------------------------------------------------
2261
+
2262
+ ## LGPL License
2263
+
2264
+ This program is free software; you can redistribute it and/or modify it under
2265
+ the terms of the GNU Lesser General Public License as published by the Free
2266
+ Software Foundation; either version 2.1 of the License, or (at your option) any
2267
+ later version.
2268
+
2269
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
2270
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
2271
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
2272
+
2273
+ You should have received a copy of the GNU Lesser General Public License along
2274
+ with the GNU C Library; if not, write to the Free Software Foundation, Inc.,
2275
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2276
+ *******************************************************************************/