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,2327 @@
1
+ /*
2
+ File: AUBase.cpp
3
+ Abstract: AUBase.h
4
+ Version: 1.01
5
+
6
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7
+ Inc. ("Apple") in consideration of your agreement to the following
8
+ terms, and your use, installation, modification or redistribution of
9
+ this Apple software constitutes acceptance of these terms. If you do
10
+ not agree with these terms, please do not use, install, modify or
11
+ redistribute this Apple software.
12
+
13
+ In consideration of your agreement to abide by the following terms, and
14
+ subject to these terms, Apple grants you a personal, non-exclusive
15
+ license, under Apple's copyrights in this original Apple software (the
16
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
17
+ Software, with or without modifications, in source and/or binary forms;
18
+ provided that if you redistribute the Apple Software in its entirety and
19
+ without modifications, you must retain this notice and the following
20
+ text and disclaimers in all such redistributions of the Apple Software.
21
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
22
+ be used to endorse or promote products derived from the Apple Software
23
+ without specific prior written permission from Apple. Except as
24
+ expressly stated in this notice, no other rights or licenses, express or
25
+ implied, are granted by Apple herein, including but not limited to any
26
+ patent rights that may be infringed by your derivative works or by other
27
+ works in which the Apple Software may be incorporated.
28
+
29
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34
+
35
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42
+ POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ Copyright (C) 2012 Apple Inc. All Rights Reserved.
45
+
46
+ */
47
+ #include "AUBase.h"
48
+ #include "AUDispatch.h"
49
+ #include "AUInputElement.h"
50
+ #include "AUOutputElement.h"
51
+ #include <algorithm>
52
+ #include "CAAudioChannelLayout.h"
53
+ #include "CAHostTimeBase.h"
54
+ #include "CAVectorUnit.h"
55
+ #include "CAXException.h"
56
+
57
+
58
+
59
+ #if TARGET_OS_MAC && (TARGET_CPU_X86 || TARGET_CPU_X86_64)
60
+ // our compiler does ALL floating point with SSE
61
+ inline int GETCSR () { int _result; asm volatile ("stmxcsr %0" : "=m" (*&_result) ); return _result; }
62
+ inline void SETCSR (int a) { int _temp = a; asm volatile( "ldmxcsr %0" : : "m" (*&_temp ) ); }
63
+
64
+ #define DISABLE_DENORMALS int _savemxcsr = GETCSR(); SETCSR(_savemxcsr | 0x8040);
65
+ #define RESTORE_DENORMALS SETCSR(_savemxcsr);
66
+ #else
67
+ #define DISABLE_DENORMALS
68
+ #define RESTORE_DENORMALS
69
+ #endif
70
+
71
+ static bool sAUBaseCFStringsInitialized = false;
72
+ // this is used for the presets
73
+ static CFStringRef kUntitledString = NULL;
74
+ //these are the current keys for the class info document
75
+ static CFStringRef kVersionString = NULL;
76
+ static CFStringRef kTypeString = NULL;
77
+ static CFStringRef kSubtypeString = NULL;
78
+ static CFStringRef kManufacturerString = NULL;
79
+ static CFStringRef kDataString = NULL;
80
+ static CFStringRef kNameString = NULL;
81
+ static CFStringRef kRenderQualityString = NULL;
82
+ static CFStringRef kCPULoadString = NULL;
83
+ static CFStringRef kElementNameString = NULL;
84
+ static CFStringRef kPartString = NULL;
85
+
86
+ SInt32 AUBase::sVectorUnitType = kVecUninitialized;
87
+
88
+ //_____________________________________________________________________________
89
+ //
90
+ AUBase::AUBase( AudioComponentInstance inInstance,
91
+ UInt32 numInputElements,
92
+ UInt32 numOutputElements,
93
+ UInt32 numGroupElements) :
94
+ ComponentBase(inInstance),
95
+ mElementsCreated(false),
96
+ mInitialized(false),
97
+ mHasBegunInitializing(false),
98
+ mInitNumInputEls(numInputElements), mInitNumOutputEls(numOutputElements),
99
+ #if !CA_BASIC_AU_FEATURES
100
+ mInitNumGroupEls(numGroupElements),
101
+ #endif
102
+ mRenderCallbacksTouched(false),
103
+ mRenderThreadID (NULL),
104
+ mWantsRenderThreadID (false),
105
+ mLastRenderError(0),
106
+ mBuffersAllocated(false),
107
+ mLogString (NULL)
108
+ #if !CA_NO_AU_UI_FEATURES
109
+ ,
110
+ mContextName(NULL)
111
+ #endif
112
+ {
113
+ ResetRenderTime ();
114
+
115
+ if(!sAUBaseCFStringsInitialized)
116
+ {
117
+ kUntitledString = CFSTR("Untitled");
118
+ kVersionString = CFSTR(kAUPresetVersionKey);
119
+ kTypeString = CFSTR(kAUPresetTypeKey);
120
+ kSubtypeString = CFSTR(kAUPresetSubtypeKey);
121
+ kManufacturerString = CFSTR(kAUPresetManufacturerKey);
122
+ kDataString = CFSTR(kAUPresetDataKey);
123
+ kNameString = CFSTR(kAUPresetNameKey);
124
+ kRenderQualityString = CFSTR(kAUPresetRenderQualityKey);
125
+ kCPULoadString = CFSTR(kAUPresetCPULoadKey);
126
+ kElementNameString = CFSTR(kAUPresetElementNameKey);
127
+ kPartString = CFSTR(kAUPresetPartKey);
128
+ sAUBaseCFStringsInitialized = true;
129
+ }
130
+
131
+ if (sVectorUnitType == kVecUninitialized) {
132
+ sVectorUnitType = CAVectorUnit::GetVectorUnitType() ;
133
+ }
134
+
135
+ mAudioUnitAPIVersion = 2;
136
+
137
+ SetMaxFramesPerSlice(kAUDefaultMaxFramesPerSlice);
138
+
139
+ GlobalScope().Initialize(this, kAudioUnitScope_Global, 1);
140
+
141
+ if (mAudioUnitAPIVersion > 1)
142
+ mParamList.reserve (24);
143
+
144
+ #if !CA_NO_AU_UI_FEATURES
145
+ memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
146
+ #endif
147
+
148
+
149
+ mCurrentPreset.presetNumber = -1;
150
+ mCurrentPreset.presetName = kUntitledString;
151
+ CFRetain (mCurrentPreset.presetName);
152
+ }
153
+
154
+ //_____________________________________________________________________________
155
+ //
156
+ AUBase::~AUBase()
157
+ {
158
+ if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
159
+ #if !CA_NO_AU_UI_FEATURES
160
+ if (mContextName) CFRelease (mContextName);
161
+ #endif
162
+ if (mLogString) delete [] mLogString;
163
+ }
164
+
165
+ //_____________________________________________________________________________
166
+ //
167
+ void AUBase::CreateElements()
168
+ {
169
+ if (!mElementsCreated) {
170
+ Inputs().Initialize(this, kAudioUnitScope_Input, mInitNumInputEls);
171
+ Outputs().Initialize(this, kAudioUnitScope_Output, mInitNumOutputEls);
172
+ #if !CA_BASIC_AU_FEATURES
173
+ Groups().Initialize(this, kAudioUnitScope_Group, mInitNumGroupEls);
174
+ #endif
175
+ CreateExtendedElements();
176
+
177
+ mElementsCreated = true;
178
+ }
179
+ }
180
+
181
+ //_____________________________________________________________________________
182
+ //
183
+ void AUBase::SetMaxFramesPerSlice(UInt32 nFrames)
184
+ {
185
+ mMaxFramesPerSlice = nFrames;
186
+ if (mBuffersAllocated)
187
+ ReallocateBuffers();
188
+ PropertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
189
+ }
190
+
191
+ //_____________________________________________________________________________
192
+ //
193
+ OSStatus AUBase::CanSetMaxFrames() const
194
+ {
195
+ return IsInitialized() ? kAudioUnitErr_Initialized : OSStatus(noErr);
196
+ }
197
+
198
+ //_____________________________________________________________________________
199
+ //
200
+ void AUBase::ReallocateBuffers()
201
+ {
202
+ CreateElements();
203
+
204
+ int i;
205
+ int nOutputs = Outputs().GetNumberOfElements();
206
+ for (i = 0; i < nOutputs; ++i) {
207
+ AUOutputElement *output = GetOutput(i);
208
+ output->AllocateBuffer(); // does no work if already allocated
209
+ }
210
+ int nInputs = Inputs().GetNumberOfElements();
211
+ for (i = 0; i < nInputs; ++i) {
212
+ AUInputElement *input = GetInput(i);
213
+ input->AllocateBuffer(); // does no work if already allocated
214
+ }
215
+ mBuffersAllocated = true;
216
+ }
217
+
218
+ //_____________________________________________________________________________
219
+ //
220
+ OSStatus AUBase::DoInitialize()
221
+ {
222
+ OSStatus result = noErr;
223
+
224
+ if (!mInitialized) {
225
+ result = Initialize();
226
+ if (result == noErr) {
227
+ mHasBegunInitializing = true;
228
+ ReallocateBuffers(); // calls CreateElements()
229
+ mInitialized = true; // signal that it's okay to render
230
+ CAMemoryBarrier();
231
+ }
232
+ }
233
+
234
+ return result;
235
+ }
236
+
237
+ //_____________________________________________________________________________
238
+ //
239
+ OSStatus AUBase::Initialize()
240
+ {
241
+ return noErr;
242
+ }
243
+
244
+ //_____________________________________________________________________________
245
+ //
246
+ void AUBase::PreDestructor()
247
+ {
248
+ DoCleanup();
249
+ }
250
+
251
+ //_____________________________________________________________________________
252
+ //
253
+ void AUBase::DoCleanup()
254
+ {
255
+ if (mInitialized)
256
+ Cleanup();
257
+
258
+ ResetRenderTime ();
259
+
260
+ mInitialized = false;
261
+ mHasBegunInitializing = false;
262
+ }
263
+
264
+ //_____________________________________________________________________________
265
+ //
266
+ void AUBase::Cleanup()
267
+ {
268
+ }
269
+
270
+ //_____________________________________________________________________________
271
+ //
272
+ OSStatus AUBase::Reset( AudioUnitScope inScope,
273
+ AudioUnitElement inElement)
274
+ {
275
+ ResetRenderTime ();
276
+ return noErr;
277
+ }
278
+
279
+ //_____________________________________________________________________________
280
+ //
281
+ OSStatus AUBase::DispatchGetPropertyInfo(AudioUnitPropertyID inID,
282
+ AudioUnitScope inScope,
283
+ AudioUnitElement inElement,
284
+ UInt32 & outDataSize,
285
+ Boolean & outWritable)
286
+ {
287
+ OSStatus result = noErr;
288
+ bool validateElement = true;
289
+
290
+ switch (inID) {
291
+ case kAudioUnitProperty_MakeConnection:
292
+ ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
293
+ outDataSize = sizeof(AudioUnitConnection);
294
+ outWritable = true;
295
+ break;
296
+
297
+
298
+ case kAudioUnitProperty_SetRenderCallback:
299
+ ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
300
+ ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
301
+ outDataSize = sizeof(AURenderCallbackStruct);
302
+ outWritable = true;
303
+ break;
304
+
305
+ case kAudioUnitProperty_StreamFormat:
306
+ outDataSize = sizeof(CAStreamBasicDescription);
307
+ outWritable = IsStreamFormatWritable(inScope, inElement);
308
+ break;
309
+
310
+ case kAudioUnitProperty_SampleRate:
311
+ outDataSize = sizeof(Float64);
312
+ outWritable = IsStreamFormatWritable(inScope, inElement);
313
+ break;
314
+
315
+ case kAudioUnitProperty_ClassInfo:
316
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
317
+ outDataSize = sizeof(CFPropertyListRef);
318
+ outWritable = true;
319
+ break;
320
+
321
+ case kAudioUnitProperty_FactoryPresets:
322
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
323
+ result = GetPresets(NULL);
324
+ if (!result) {
325
+ outDataSize = sizeof(CFArrayRef);
326
+ outWritable = false;
327
+ }
328
+ break;
329
+
330
+ case kAudioUnitProperty_PresentPreset:
331
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
332
+ #ifndef __LP64__
333
+ case kAudioUnitProperty_CurrentPreset:
334
+ #endif
335
+ #endif
336
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
337
+ outDataSize = sizeof(AUPreset);
338
+ outWritable = true;
339
+ break;
340
+
341
+ case kAudioUnitProperty_ElementName:
342
+ outDataSize = sizeof (CFStringRef);
343
+ outWritable = true;
344
+ break;
345
+
346
+ case kAudioUnitProperty_ParameterList:
347
+ {
348
+ UInt32 nparams = 0;
349
+ result = GetParameterList(inScope, NULL, nparams);
350
+
351
+ outDataSize = sizeof(AudioUnitParameterID) * nparams;
352
+ outWritable = false;
353
+ validateElement = false;
354
+ }
355
+ break;
356
+
357
+ case kAudioUnitProperty_ParameterInfo:
358
+ outDataSize = sizeof(AudioUnitParameterInfo);
359
+ outWritable = false;
360
+ validateElement = false;
361
+ break;
362
+
363
+ case kAudioUnitProperty_ParameterHistoryInfo:
364
+ outDataSize = sizeof(AudioUnitParameterHistoryInfo);
365
+ outWritable = false;
366
+ validateElement = false;
367
+ break;
368
+
369
+ case kAudioUnitProperty_ElementCount:
370
+ outDataSize = sizeof(UInt32);
371
+ outWritable = BusCountWritable(inScope);
372
+ validateElement = false;
373
+ break;
374
+
375
+ case kAudioUnitProperty_Latency:
376
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
377
+ outDataSize = sizeof(Float64);
378
+ outWritable = false;
379
+ break;
380
+
381
+ case kAudioUnitProperty_TailTime:
382
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
383
+ if (SupportsTail()) {
384
+ outDataSize = sizeof(Float64);
385
+ outWritable = false;
386
+ } else
387
+ goto InvalidProperty;
388
+ break;
389
+
390
+ case kAudioUnitProperty_MaximumFramesPerSlice:
391
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
392
+ outDataSize = sizeof(UInt32);
393
+ outWritable = true;
394
+ break;
395
+
396
+ case kAudioUnitProperty_LastRenderError:
397
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
398
+ outDataSize = sizeof(OSStatus);
399
+ outWritable = false;
400
+ break;
401
+
402
+ case kAudioUnitProperty_SupportedNumChannels:
403
+ {
404
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
405
+ UInt32 num = SupportedNumChannels (NULL);
406
+ if (num) {
407
+ outDataSize = sizeof (AUChannelInfo) * num;
408
+ result = noErr;
409
+ } else
410
+ goto InvalidProperty;
411
+ outWritable = false;
412
+ break;
413
+ }
414
+
415
+ case kAudioUnitProperty_SupportedChannelLayoutTags:
416
+ {
417
+ UInt32 numLayouts = GetChannelLayoutTags(inScope, inElement, NULL);
418
+ if (numLayouts) {
419
+ outDataSize = numLayouts * sizeof(AudioChannelLayoutTag);
420
+ result = noErr;
421
+ } else
422
+ goto InvalidProperty;
423
+ outWritable = false;
424
+ validateElement = false; //already done it
425
+ break;
426
+ }
427
+
428
+ case kAudioUnitProperty_AudioChannelLayout:
429
+ {
430
+ outWritable = false;
431
+ outDataSize = GetAudioChannelLayout(inScope, inElement, NULL, outWritable);
432
+ if (outDataSize) {
433
+ result = noErr;
434
+ } else {
435
+ if (GetChannelLayoutTags(inScope, inElement, NULL) == 0)
436
+ goto InvalidProperty;
437
+ else
438
+ result = kAudioUnitErr_InvalidPropertyValue;
439
+ }
440
+ validateElement = false; //already done it
441
+ break;
442
+ }
443
+
444
+ #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
445
+ case kAudioUnitProperty_ShouldAllocateBuffer:
446
+ ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
447
+ outWritable = true;
448
+ outDataSize = sizeof(UInt32);
449
+ break;
450
+ #endif
451
+
452
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
453
+ case kAudioUnitProperty_FastDispatch:
454
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
455
+ if (!IsCMgrObject()) goto InvalidProperty;
456
+ outDataSize = sizeof(void *);
457
+ outWritable = false;
458
+ validateElement = false;
459
+ break;
460
+
461
+ case kAudioUnitProperty_GetUIComponentList:
462
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
463
+ outDataSize = GetNumCustomUIComponents();
464
+ if (outDataSize == 0)
465
+ goto InvalidProperty;
466
+ outDataSize *= sizeof (AudioComponentDescription);
467
+
468
+ outWritable = false;
469
+ break;
470
+ #endif
471
+
472
+ #if !CA_NO_AU_UI_FEATURES
473
+ case kAudioUnitProperty_ContextName:
474
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
475
+ outDataSize = sizeof(CFStringRef);
476
+ outWritable = true;
477
+ break;
478
+
479
+ case kAudioUnitProperty_ParameterValueStrings:
480
+ result = GetParameterValueStrings(inScope, inElement, NULL);
481
+ if (result == noErr) {
482
+ outDataSize = sizeof(CFArrayRef);
483
+ outWritable = false;
484
+ validateElement = false;
485
+ }
486
+ break;
487
+
488
+ case kAudioUnitProperty_HostCallbacks:
489
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
490
+ outDataSize = sizeof (HostCallbackInfo);
491
+ outWritable = true;
492
+ break;
493
+
494
+ case kAudioUnitProperty_IconLocation:
495
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
496
+ outWritable = false;
497
+ if (!HasIcon())
498
+ goto InvalidProperty;
499
+ outDataSize = sizeof(CFURLRef);
500
+ break;
501
+
502
+ case kAudioUnitProperty_ParameterClumpName:
503
+ outDataSize = sizeof(AudioUnitParameterNameInfo );
504
+ outWritable = false;
505
+ break;
506
+
507
+ #endif // !CA_NO_AU_UI_FEATURES
508
+
509
+ case 'lrst' : // kAudioUnitProperty_LastRenderedSampleTime
510
+ outDataSize = sizeof(Float64);
511
+ outWritable = false;
512
+ break;
513
+
514
+ default:
515
+ result = GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable);
516
+ validateElement = false;
517
+ break;
518
+ }
519
+
520
+ if (result == noErr && validateElement) {
521
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
522
+ }
523
+
524
+ return result;
525
+ InvalidProperty:
526
+ return kAudioUnitErr_InvalidProperty;
527
+ InvalidScope:
528
+ return kAudioUnitErr_InvalidScope;
529
+ InvalidElement:
530
+ return kAudioUnitErr_InvalidElement;
531
+ }
532
+
533
+ //_____________________________________________________________________________
534
+ //
535
+ OSStatus AUBase::DispatchGetProperty( AudioUnitPropertyID inID,
536
+ AudioUnitScope inScope,
537
+ AudioUnitElement inElement,
538
+ void * outData)
539
+ {
540
+ // NOTE: We're currently only called from AUBase::ComponentEntryDispatch, which
541
+ // calls DispatchGetPropertyInfo first, which performs validation of the scope/element,
542
+ // and ensures that the outData buffer is non-null and large enough.
543
+ OSStatus result = noErr;
544
+
545
+ switch (inID) {
546
+ case kAudioUnitProperty_StreamFormat:
547
+ *(CAStreamBasicDescription *)outData = GetStreamFormat(inScope, inElement);
548
+ break;
549
+
550
+ case kAudioUnitProperty_SampleRate:
551
+ *(Float64 *)outData = GetStreamFormat(inScope, inElement).mSampleRate;
552
+ break;
553
+
554
+ case kAudioUnitProperty_ParameterList:
555
+ {
556
+ UInt32 nparams = 0;
557
+ result = GetParameterList(inScope, (AudioUnitParameterID *)outData, nparams);
558
+ }
559
+ break;
560
+
561
+ case kAudioUnitProperty_ParameterInfo:
562
+ result = GetParameterInfo(inScope, inElement, *(AudioUnitParameterInfo *)outData);
563
+ break;
564
+
565
+ case kAudioUnitProperty_ParameterHistoryInfo:
566
+ {
567
+ AudioUnitParameterHistoryInfo* info = (AudioUnitParameterHistoryInfo*)outData;
568
+ result = GetParameterHistoryInfo(inScope, inElement, info->updatesPerSecond, info->historyDurationInSeconds);
569
+ }
570
+ break;
571
+
572
+ case kAudioUnitProperty_ClassInfo:
573
+ {
574
+ *(CFPropertyListRef *)outData = NULL;
575
+ result = SaveState((CFPropertyListRef *)outData);
576
+ }
577
+ break;
578
+
579
+ case kAudioUnitProperty_FactoryPresets:
580
+ {
581
+ *(CFArrayRef *)outData = NULL;
582
+ result = GetPresets ((CFArrayRef *)outData);
583
+ }
584
+ break;
585
+
586
+ case kAudioUnitProperty_PresentPreset:
587
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
588
+ #ifndef __LP64__
589
+ case kAudioUnitProperty_CurrentPreset:
590
+ #endif
591
+ #endif
592
+ {
593
+ *(AUPreset *)outData = mCurrentPreset;
594
+
595
+ // retain current string (as client owns a reference to it and will release it)
596
+ if (inID == kAudioUnitProperty_PresentPreset && mCurrentPreset.presetName)
597
+ CFRetain (mCurrentPreset.presetName);
598
+
599
+ result = noErr;
600
+ }
601
+ break;
602
+
603
+ case kAudioUnitProperty_ElementName:
604
+ {
605
+ AUElement * element = GetElement(inScope, inElement);
606
+ if (element->HasName()) {
607
+ *(CFStringRef *)outData = element->GetName();
608
+ CFRetain (element->GetName());
609
+ result = noErr;
610
+ } else
611
+ result = kAudioUnitErr_InvalidPropertyValue;
612
+ }
613
+ break;
614
+
615
+ case kAudioUnitProperty_ElementCount:
616
+ *(UInt32 *)outData = GetScope(inScope).GetNumberOfElements();
617
+ break;
618
+
619
+ case kAudioUnitProperty_Latency:
620
+ *(Float64 *)outData = GetLatency();
621
+ break;
622
+
623
+ case kAudioUnitProperty_TailTime:
624
+ if (SupportsTail())
625
+ *(Float64 *)outData = GetTailTime();
626
+ else
627
+ result = kAudioUnitErr_InvalidProperty;
628
+ break;
629
+
630
+ case kAudioUnitProperty_MaximumFramesPerSlice:
631
+ *(UInt32 *)outData = mMaxFramesPerSlice;
632
+ break;
633
+
634
+ case kAudioUnitProperty_LastRenderError:
635
+ *(OSStatus *)outData = mLastRenderError;
636
+ mLastRenderError = 0;
637
+ break;
638
+
639
+ case kAudioUnitProperty_SupportedNumChannels:
640
+ {
641
+ const AUChannelInfo* infoPtr;
642
+ UInt32 num = SupportedNumChannels (&infoPtr);
643
+ memcpy (outData, infoPtr, num * sizeof (AUChannelInfo));
644
+ }
645
+ break;
646
+
647
+ case kAudioUnitProperty_SupportedChannelLayoutTags:
648
+ {
649
+ AudioChannelLayoutTag* ptr = outData ? static_cast<AudioChannelLayoutTag*>(outData) : NULL;
650
+ UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, ptr);
651
+ if (numLayouts == 0)
652
+ result = kAudioUnitErr_InvalidProperty;
653
+ }
654
+ break;
655
+
656
+ case kAudioUnitProperty_AudioChannelLayout:
657
+ {
658
+ AudioChannelLayout* ptr = outData ? static_cast<AudioChannelLayout*>(outData) : NULL;
659
+ Boolean writable;
660
+ UInt32 dataSize = GetAudioChannelLayout(inScope, inElement, ptr, writable);
661
+ if (!dataSize) {
662
+ result = kAudioUnitErr_InvalidProperty;
663
+ }
664
+ break;
665
+ }
666
+
667
+ #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
668
+ case kAudioUnitProperty_ShouldAllocateBuffer:
669
+ {
670
+ AUIOElement * element = GetIOElement(inScope, inElement);
671
+ *(UInt32*)outData = element->WillAllocateBuffer();
672
+ break;
673
+ }
674
+ #endif
675
+
676
+
677
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
678
+ case kAudioUnitProperty_FastDispatch:
679
+ if (!IsCMgrObject()) result = kAudioUnitErr_InvalidProperty;
680
+ else {
681
+ switch (inElement) {
682
+ case kAudioUnitGetParameterSelect:
683
+ *(AudioUnitGetParameterProc *)outData = (AudioUnitGetParameterProc)CMgr_AudioUnitBaseGetParameter;
684
+ break;
685
+ case kAudioUnitSetParameterSelect:
686
+ *(AudioUnitSetParameterProc *)outData = (AudioUnitSetParameterProc)CMgr_AudioUnitBaseSetParameter;
687
+ break;
688
+ case kAudioUnitRenderSelect:
689
+ if (AudioUnitAPIVersion() > 1)
690
+ *(AudioUnitRenderProc *)outData = (AudioUnitRenderProc)CMgr_AudioUnitBaseRender;
691
+ else result = kAudioUnitErr_InvalidElement;
692
+ break;
693
+ default:
694
+ result = GetProperty(inID, inScope, inElement, outData);
695
+ break;
696
+ }
697
+ }
698
+ break;
699
+
700
+ case kAudioUnitProperty_GetUIComponentList:
701
+ GetUIComponentDescs ((ComponentDescription*)outData);
702
+ break;
703
+ #endif
704
+
705
+ #if !CA_NO_AU_UI_FEATURES
706
+ case kAudioUnitProperty_ParameterValueStrings:
707
+ result = GetParameterValueStrings(inScope, inElement, (CFArrayRef *)outData);
708
+ break;
709
+
710
+ case kAudioUnitProperty_IconLocation:
711
+ {
712
+ CFURLRef iconLocation = CopyIconLocation();
713
+ if (iconLocation) {
714
+ *(CFURLRef*)outData = iconLocation;
715
+ } else
716
+ result = kAudioUnitErr_InvalidProperty;
717
+ }
718
+ break;
719
+
720
+ case kAudioUnitProperty_HostCallbacks:
721
+ *(HostCallbackInfo *)outData = mHostCallbackInfo;
722
+ break;
723
+
724
+ case kAudioUnitProperty_ContextName:
725
+ *(CFStringRef *)outData = mContextName;
726
+ if (mContextName) {
727
+ CFRetain(mContextName);
728
+ // retain CFString (if exists) since client will be responsible for its release
729
+ result = noErr;
730
+ } else {
731
+ result = kAudioUnitErr_InvalidPropertyValue;
732
+ }
733
+ break;
734
+
735
+ case kAudioUnitProperty_ParameterClumpName:
736
+ {
737
+ AudioUnitParameterNameInfo * ioClumpInfo = (AudioUnitParameterNameInfo*) outData;
738
+ if (ioClumpInfo->inID == kAudioUnitClumpID_System) // this ID value is reserved
739
+ result = kAudioUnitErr_InvalidPropertyValue;
740
+ else
741
+ {
742
+ result = CopyClumpName(inScope, ioClumpInfo->inID, ioClumpInfo->inDesiredLength, &ioClumpInfo->outName);
743
+
744
+ // this is provided for compatbility with existing implementations that don't know
745
+ // about this new mechanism
746
+ if (result == kAudioUnitErr_InvalidProperty)
747
+ result = GetProperty (inID, inScope, inElement, outData);
748
+ }
749
+ }
750
+ break;
751
+
752
+ #endif // !CA_NO_AU_UI_FEATURES
753
+
754
+ case 'lrst' : // kAudioUnitProperty_LastRenderedSampleTime
755
+ *(Float64*)outData = mCurrentRenderTime.mSampleTime;
756
+ break;
757
+
758
+ default:
759
+ result = GetProperty(inID, inScope, inElement, outData);
760
+ break;
761
+ }
762
+ return result;
763
+ }
764
+
765
+
766
+ //_____________________________________________________________________________
767
+ //
768
+ OSStatus AUBase::DispatchSetProperty( AudioUnitPropertyID inID,
769
+ AudioUnitScope inScope,
770
+ AudioUnitElement inElement,
771
+ const void * inData,
772
+ UInt32 inDataSize)
773
+ {
774
+ OSStatus result = noErr;
775
+
776
+ switch (inID) {
777
+ case kAudioUnitProperty_MakeConnection:
778
+ ca_require(inDataSize >= sizeof(AudioUnitConnection), InvalidPropertyValue);
779
+ {
780
+ AudioUnitConnection &connection = *(AudioUnitConnection *)inData;
781
+ result = SetConnection(connection);
782
+ }
783
+ break;
784
+
785
+
786
+ case kAudioUnitProperty_SetRenderCallback:
787
+ {
788
+ ca_require(inDataSize >= sizeof(AURenderCallbackStruct), InvalidPropertyValue);
789
+ ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
790
+ AURenderCallbackStruct &callback = *(AURenderCallbackStruct*)inData;
791
+ result = SetInputCallback(kAudioUnitProperty_SetRenderCallback, inElement, callback.inputProc, callback.inputProcRefCon);
792
+ }
793
+ break;
794
+
795
+ case kAudioUnitProperty_ElementCount:
796
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
797
+ ca_require(BusCountWritable(inScope), NotWritable);
798
+ result = SetBusCount(inScope, *(UInt32*)inData);
799
+ if (result == noErr) {
800
+ PropertyChanged(inID, inScope, inElement);
801
+ }
802
+ break;
803
+
804
+ case kAudioUnitProperty_MaximumFramesPerSlice:
805
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
806
+ result = CanSetMaxFrames();
807
+ if (result) return result;
808
+ SetMaxFramesPerSlice(*(UInt32 *)inData);
809
+ break;
810
+
811
+ case kAudioUnitProperty_StreamFormat:
812
+ {
813
+ if (inDataSize < 36) goto InvalidPropertyValue;
814
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
815
+
816
+ CAStreamBasicDescription newDesc;
817
+ // now we're going to be ultra conservative! because of discrepancies between
818
+ // sizes of this struct based on aligment padding inconsistencies
819
+ memset (&newDesc, 0, sizeof(newDesc));
820
+ memcpy (&newDesc, inData, 36);
821
+
822
+ ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
823
+
824
+ const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
825
+
826
+ if ( !curDesc.IsEqual(newDesc, false) ) {
827
+ ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
828
+ result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
829
+ }
830
+ }
831
+ break;
832
+
833
+ case kAudioUnitProperty_SampleRate:
834
+ {
835
+ ca_require(inDataSize == sizeof(Float64), InvalidPropertyValue);
836
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
837
+
838
+ const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
839
+ CAStreamBasicDescription newDesc = curDesc;
840
+ newDesc.mSampleRate = *(Float64 *)inData;
841
+
842
+ ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
843
+
844
+ if ( !curDesc.IsEqual(newDesc, false) ) {
845
+ ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
846
+ result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
847
+ }
848
+ }
849
+ break;
850
+
851
+ case kAudioUnitProperty_AudioChannelLayout:
852
+ {
853
+ const AudioChannelLayout *layout = static_cast<const AudioChannelLayout *>(inData);
854
+ ca_require(inDataSize >= offsetof(AudioChannelLayout, mChannelDescriptions) + layout->mNumberChannelDescriptions * sizeof(AudioChannelDescription), InvalidPropertyValue);
855
+ result = SetAudioChannelLayout(inScope, inElement, layout);
856
+ if (result == noErr)
857
+ PropertyChanged(inID, inScope, inElement);
858
+ break;
859
+ }
860
+
861
+ case kAudioUnitProperty_ClassInfo:
862
+ ca_require(inDataSize == sizeof(CFPropertyListRef *), InvalidPropertyValue);
863
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
864
+ result = RestoreState(*(CFPropertyListRef *)inData);
865
+ break;
866
+
867
+ case kAudioUnitProperty_PresentPreset:
868
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
869
+ #ifndef __LP64__
870
+ case kAudioUnitProperty_CurrentPreset:
871
+ #endif
872
+ #endif
873
+ {
874
+ ca_require(inDataSize == sizeof(AUPreset), InvalidPropertyValue);
875
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
876
+ AUPreset & newPreset = *(AUPreset *)inData;
877
+
878
+ if (newPreset.presetNumber >= 0)
879
+ {
880
+ result = NewFactoryPresetSet(newPreset);
881
+ // NewFactoryPresetSet SHOULD call SetAFactoryPreset if the preset is valid
882
+ // from its own list of preset number->name
883
+ if (!result)
884
+ PropertyChanged(inID, inScope, inElement);
885
+ }
886
+ else if (newPreset.presetName)
887
+ {
888
+ CFRelease (mCurrentPreset.presetName);
889
+ mCurrentPreset = newPreset;
890
+ CFRetain (mCurrentPreset.presetName);
891
+ PropertyChanged(inID, inScope, inElement);
892
+ }
893
+ else
894
+ result = kAudioUnitErr_InvalidPropertyValue;
895
+ }
896
+ break;
897
+
898
+ case kAudioUnitProperty_ElementName:
899
+ {
900
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
901
+ ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
902
+ AUElement * element = GetScope(inScope).GetElement (inElement);
903
+ element->SetName (*(CFStringRef *)inData);
904
+ PropertyChanged(inID, inScope, inElement);
905
+ }
906
+ break;
907
+
908
+ #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
909
+ case kAudioUnitProperty_ShouldAllocateBuffer:
910
+ {
911
+ ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
912
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
913
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
914
+ ca_require(!IsInitialized(), Initialized);
915
+
916
+ AUIOElement * element = GetIOElement(inScope, inElement);
917
+ element->SetWillAllocateBuffer(*(UInt32 *)inData != 0);
918
+ }
919
+ break;
920
+ #endif
921
+
922
+ #if !CA_NO_AU_UI_FEATURES
923
+ case kAudioUnitProperty_SetExternalBuffer:
924
+ ca_require(inDataSize >= sizeof(AudioUnitExternalBuffer), InvalidPropertyValue);
925
+ ca_require(IsInitialized(), Uninitialized);
926
+ {
927
+ AudioUnitExternalBuffer &buf = *(AudioUnitExternalBuffer*)inData;
928
+ if (intptr_t(buf.buffer) & 0x0F) result = kAudio_ParamError;
929
+ else if (inScope == kAudioUnitScope_Input) {
930
+ AUInputElement *input = GetInput(inElement);
931
+ input->UseExternalBuffer(buf);
932
+ } else {
933
+ AUOutputElement *output = GetOutput(inElement);
934
+ output->UseExternalBuffer(buf);
935
+ }
936
+ }
937
+ break;
938
+
939
+ case kAudioUnitProperty_ContextName:
940
+ {
941
+ ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
942
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
943
+ CFStringRef inStr = *(CFStringRef *)inData;
944
+ if (mContextName) CFRelease(mContextName);
945
+ if (inStr) CFRetain(inStr);
946
+ mContextName = inStr;
947
+ PropertyChanged(inID, inScope, inElement);
948
+ }
949
+ break;
950
+
951
+ case kAudioUnitProperty_HostCallbacks:
952
+ {
953
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
954
+ UInt32 availSize = (inDataSize < sizeof (mHostCallbackInfo) ? inDataSize : sizeof (mHostCallbackInfo));
955
+ bool hasChanged = !memcmp (&mHostCallbackInfo, inData, availSize);
956
+ memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
957
+ memcpy (&mHostCallbackInfo, inData, availSize);
958
+ if (hasChanged)
959
+ PropertyChanged(inID, inScope, inElement);
960
+ break;
961
+ }
962
+ #endif // !CA_NO_AU_UI_FEATURES
963
+
964
+ default:
965
+ result = SetProperty(inID, inScope, inElement, inData, inDataSize);
966
+ if (result == noErr)
967
+ PropertyChanged(inID, inScope, inElement);
968
+
969
+ break;
970
+ }
971
+ return result;
972
+ NotWritable:
973
+ return kAudioUnitErr_PropertyNotWritable;
974
+ InvalidFormat:
975
+ return kAudioUnitErr_FormatNotSupported;
976
+ #if !CA_NO_AU_UI_FEATURES
977
+ Uninitialized:
978
+ return kAudioUnitErr_Uninitialized;
979
+ #endif
980
+ #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || CA_USE_AUDIO_PLUGIN_ONLY
981
+ Initialized:
982
+ return kAudioUnitErr_Initialized;
983
+ #endif
984
+ InvalidScope:
985
+ return kAudioUnitErr_InvalidScope;
986
+ InvalidProperty:
987
+ return kAudioUnitErr_InvalidProperty;
988
+ InvalidPropertyValue:
989
+ return kAudioUnitErr_InvalidPropertyValue;
990
+ InvalidElement:
991
+ return kAudioUnitErr_InvalidElement;
992
+ }
993
+
994
+ //_____________________________________________________________________________
995
+ //
996
+ OSStatus AUBase::DispatchRemovePropertyValue (AudioUnitPropertyID inID,
997
+ AudioUnitScope inScope,
998
+ AudioUnitElement inElement)
999
+ {
1000
+ OSStatus result = noErr;
1001
+ switch (inID)
1002
+ {
1003
+ case kAudioUnitProperty_AudioChannelLayout:
1004
+ {
1005
+ result = RemoveAudioChannelLayout(inScope, inElement);
1006
+ if (result == noErr)
1007
+ PropertyChanged(inID, inScope, inElement);
1008
+ break;
1009
+ }
1010
+
1011
+ #if !CA_NO_AU_UI_FEATURES
1012
+ case kAudioUnitProperty_ContextName:
1013
+ if (mContextName) CFRelease(mContextName);
1014
+ mContextName = NULL;
1015
+ result = noErr;
1016
+ break;
1017
+
1018
+ case kAudioUnitProperty_HostCallbacks:
1019
+ {
1020
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
1021
+ bool hasValue = false;
1022
+ void* ptr = &mHostCallbackInfo;
1023
+ for (unsigned int i = 0; i < sizeof (HostCallbackInfo); ++i) {
1024
+ if (static_cast<char*>(ptr)[i]) {
1025
+ hasValue = true;
1026
+ break;
1027
+ }
1028
+ }
1029
+ if (hasValue) {
1030
+ memset (&mHostCallbackInfo, 0, sizeof (HostCallbackInfo));
1031
+ PropertyChanged(inID, inScope, inElement);
1032
+ }
1033
+ break;
1034
+ }
1035
+ #endif // !CA_NO_AU_UI_FEATURES
1036
+
1037
+ default:
1038
+ result = RemovePropertyValue (inID, inScope, inElement);
1039
+ break;
1040
+ }
1041
+
1042
+ return result;
1043
+ #if !CA_NO_AU_UI_FEATURES
1044
+ InvalidScope:
1045
+ return kAudioUnitErr_InvalidScope;
1046
+ #endif
1047
+ }
1048
+
1049
+ //_____________________________________________________________________________
1050
+ //
1051
+ OSStatus AUBase::GetPropertyInfo( AudioUnitPropertyID inID,
1052
+ AudioUnitScope inScope,
1053
+ AudioUnitElement inElement,
1054
+ UInt32 & outDataSize,
1055
+ Boolean & outWritable)
1056
+ {
1057
+ return kAudioUnitErr_InvalidProperty;
1058
+ }
1059
+
1060
+
1061
+ //_____________________________________________________________________________
1062
+ //
1063
+ OSStatus AUBase::GetProperty( AudioUnitPropertyID inID,
1064
+ AudioUnitScope inScope,
1065
+ AudioUnitElement inElement,
1066
+ void * outData)
1067
+ {
1068
+ return kAudioUnitErr_InvalidProperty;
1069
+ }
1070
+
1071
+
1072
+ //_____________________________________________________________________________
1073
+ //
1074
+ OSStatus AUBase::SetProperty( AudioUnitPropertyID inID,
1075
+ AudioUnitScope inScope,
1076
+ AudioUnitElement inElement,
1077
+ const void * inData,
1078
+ UInt32 inDataSize)
1079
+ {
1080
+ return kAudioUnitErr_InvalidProperty;
1081
+ }
1082
+
1083
+ //_____________________________________________________________________________
1084
+ //
1085
+ OSStatus AUBase::RemovePropertyValue ( AudioUnitPropertyID inID,
1086
+ AudioUnitScope inScope,
1087
+ AudioUnitElement inElement)
1088
+ {
1089
+ return kAudioUnitErr_InvalidPropertyValue;
1090
+ }
1091
+
1092
+ //_____________________________________________________________________________
1093
+ //
1094
+ OSStatus AUBase::AddPropertyListener( AudioUnitPropertyID inID,
1095
+ AudioUnitPropertyListenerProc inProc,
1096
+ void * inProcRefCon)
1097
+ {
1098
+ PropertyListener pl;
1099
+
1100
+ pl.propertyID = inID;
1101
+ pl.listenerProc = inProc;
1102
+ pl.listenerRefCon = inProcRefCon;
1103
+
1104
+ if (mPropertyListeners.empty())
1105
+ mPropertyListeners.reserve(32);
1106
+ mPropertyListeners.push_back(pl);
1107
+
1108
+ return noErr;
1109
+ }
1110
+
1111
+ //_____________________________________________________________________________
1112
+ //
1113
+ OSStatus AUBase::RemovePropertyListener( AudioUnitPropertyID inID,
1114
+ AudioUnitPropertyListenerProc inProc,
1115
+ void * inProcRefCon,
1116
+ bool refConSpecified)
1117
+ {
1118
+ // iterate in reverse so that it's safe to erase in the middle of the vector
1119
+ for (int i = mPropertyListeners.size(); --i >=0; ) {
1120
+ PropertyListeners::iterator it = mPropertyListeners.begin() + i;
1121
+ if ((*it).propertyID == inID && (*it).listenerProc == inProc && (!refConSpecified || (*it).listenerRefCon == inProcRefCon))
1122
+ mPropertyListeners.erase(it);
1123
+ }
1124
+ return noErr;
1125
+ }
1126
+
1127
+ //_____________________________________________________________________________
1128
+ //
1129
+ void AUBase::PropertyChanged( AudioUnitPropertyID inID,
1130
+ AudioUnitScope inScope,
1131
+ AudioUnitElement inElement)
1132
+ {
1133
+ for (PropertyListeners::iterator it = mPropertyListeners.begin(); it != mPropertyListeners.end(); ++it)
1134
+ if ((*it).propertyID == inID)
1135
+ ((*it).listenerProc)((*it).listenerRefCon, mComponentInstance, inID, inScope, inElement);
1136
+ }
1137
+
1138
+ //_____________________________________________________________________________
1139
+ //
1140
+ OSStatus AUBase::SetRenderNotification( AURenderCallback inProc,
1141
+ void * inRefCon)
1142
+ {
1143
+ if (inProc == NULL)
1144
+ return kAudio_ParamError;
1145
+
1146
+ mRenderCallbacksTouched = true;
1147
+ mRenderCallbacks.deferred_add(RenderCallback(inProc, inRefCon));
1148
+ // this will do nothing if it's already in the list
1149
+ return noErr;
1150
+ }
1151
+
1152
+ //_____________________________________________________________________________
1153
+ //
1154
+ OSStatus AUBase::RemoveRenderNotification( AURenderCallback inProc,
1155
+ void * inRefCon)
1156
+ {
1157
+ mRenderCallbacks.deferred_remove(RenderCallback(inProc, inRefCon));
1158
+ return noErr; // error?
1159
+ }
1160
+
1161
+ //_____________________________________________________________________________
1162
+ //
1163
+ OSStatus AUBase::GetParameter( AudioUnitParameterID inID,
1164
+ AudioUnitScope inScope,
1165
+ AudioUnitElement inElement,
1166
+ AudioUnitParameterValue & outValue)
1167
+ {
1168
+ AUElement *elem = SafeGetElement(inScope, inElement);
1169
+ outValue = elem->GetParameter(inID);
1170
+ return noErr;
1171
+ }
1172
+
1173
+
1174
+ //_____________________________________________________________________________
1175
+ //
1176
+ OSStatus AUBase::SetParameter( AudioUnitParameterID inID,
1177
+ AudioUnitScope inScope,
1178
+ AudioUnitElement inElement,
1179
+ AudioUnitParameterValue inValue,
1180
+ UInt32 inBufferOffsetInFrames)
1181
+ {
1182
+ AUElement *elem = SafeGetElement(inScope, inElement);
1183
+ elem->SetParameter(inID, inValue);
1184
+ return noErr;
1185
+ }
1186
+
1187
+ //_____________________________________________________________________________
1188
+ //
1189
+ OSStatus AUBase::ScheduleParameter ( const AudioUnitParameterEvent *inParameterEvent,
1190
+ UInt32 inNumEvents)
1191
+ {
1192
+ for (UInt32 i = 0; i < inNumEvents; ++i)
1193
+ {
1194
+ if (inParameterEvent[i].eventType == kParameterEvent_Immediate)
1195
+ {
1196
+ SetParameter (inParameterEvent[i].parameter,
1197
+ inParameterEvent[i].scope,
1198
+ inParameterEvent[i].element,
1199
+ inParameterEvent[i].eventValues.immediate.value,
1200
+ inParameterEvent[i].eventValues.immediate.bufferOffset);
1201
+ }
1202
+ mParamList.push_back (inParameterEvent[i]);
1203
+ }
1204
+
1205
+ return noErr;
1206
+ }
1207
+
1208
+ // ____________________________________________________________________________
1209
+ //
1210
+ static bool SortParameterEventList(const AudioUnitParameterEvent &ev1, const AudioUnitParameterEvent &ev2 )
1211
+ {
1212
+ int offset1 = ev1.eventType == kParameterEvent_Immediate ? ev1.eventValues.immediate.bufferOffset : ev1.eventValues.ramp.startBufferOffset;
1213
+ int offset2 = ev2.eventType == kParameterEvent_Immediate ? ev2.eventValues.immediate.bufferOffset : ev2.eventValues.ramp.startBufferOffset;
1214
+
1215
+ if(offset1 < offset2) return true;
1216
+ return false;
1217
+ }
1218
+
1219
+
1220
+ // ____________________________________________________________________________
1221
+ //
1222
+ OSStatus AUBase::ProcessForScheduledParams( ParameterEventList &inParamList,
1223
+ UInt32 inFramesToProcess,
1224
+ void *inUserData )
1225
+ {
1226
+ OSStatus result = noErr;
1227
+
1228
+ int totalFramesToProcess = inFramesToProcess;
1229
+
1230
+ int framesRemaining = totalFramesToProcess;
1231
+
1232
+ unsigned int currentStartFrame = 0; // start of the whole buffer
1233
+
1234
+
1235
+
1236
+ // sort the ParameterEventList by startBufferOffset
1237
+ std::sort(inParamList.begin(), inParamList.end(), SortParameterEventList);
1238
+
1239
+ ParameterEventList::iterator iter = inParamList.begin();
1240
+
1241
+
1242
+ while(framesRemaining > 0 )
1243
+ {
1244
+ // first of all, go through the ramped automation events and find out where the next
1245
+ // division of our whole buffer will be
1246
+
1247
+ int currentEndFrame = totalFramesToProcess; // start out assuming we'll process all the way to
1248
+ // the end of the buffer
1249
+
1250
+ iter = inParamList.begin();
1251
+
1252
+ // find the next break point
1253
+ while(iter != inParamList.end() )
1254
+ {
1255
+ AudioUnitParameterEvent &event = *iter;
1256
+
1257
+ int offset = event.eventType == kParameterEvent_Immediate ? event.eventValues.immediate.bufferOffset : event.eventValues.ramp.startBufferOffset;
1258
+
1259
+ if(offset > (int)currentStartFrame && offset < currentEndFrame )
1260
+ {
1261
+ currentEndFrame = offset;
1262
+ break;
1263
+ }
1264
+
1265
+ // consider ramp end to be a possible choice (there may be gaps in the supplied ramp events)
1266
+ if(event.eventType == kParameterEvent_Ramped )
1267
+ {
1268
+ offset = event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames;
1269
+
1270
+ if(offset > (int)currentStartFrame && offset < currentEndFrame )
1271
+ {
1272
+ currentEndFrame = offset;
1273
+ }
1274
+ }
1275
+
1276
+ iter++;
1277
+ }
1278
+
1279
+ int framesThisTime = currentEndFrame - currentStartFrame;
1280
+
1281
+ // next, setup the parameter maps to be current for the ramp parameters active during
1282
+ // this time segment...
1283
+
1284
+ for(ParameterEventList::iterator iter2 = inParamList.begin(); iter2 != inParamList.end(); iter2++ )
1285
+ {
1286
+ AudioUnitParameterEvent &event = *iter2;
1287
+
1288
+ bool eventFallsInSlice;
1289
+
1290
+
1291
+ if(event.eventType == kParameterEvent_Ramped)
1292
+ eventFallsInSlice = event.eventValues.ramp.startBufferOffset < currentEndFrame
1293
+ && event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames > currentStartFrame;
1294
+ else /* kParameterEvent_Immediate */
1295
+ // actually, for the same parameter, there may be future immediate events which override this one,
1296
+ // but it's OK since the event list is sorted in time order, we're guaranteed to end up with the current one
1297
+ eventFallsInSlice = event.eventValues.immediate.bufferOffset <= currentStartFrame;
1298
+
1299
+ if(eventFallsInSlice)
1300
+ {
1301
+ AUElement *element = GetElement(event.scope, event.element );
1302
+
1303
+ if(element) element->SetScheduledEvent( event.parameter,
1304
+ event,
1305
+ currentStartFrame,
1306
+ currentEndFrame - currentStartFrame );
1307
+ }
1308
+ }
1309
+
1310
+
1311
+
1312
+ // Finally, actually do the processing for this slice.....
1313
+
1314
+ result = ProcessScheduledSlice( inUserData,
1315
+ currentStartFrame,
1316
+ framesThisTime,
1317
+ inFramesToProcess );
1318
+
1319
+ if(result != noErr) break;
1320
+
1321
+ framesRemaining -= framesThisTime;
1322
+ currentStartFrame = currentEndFrame; // now start from where we left off last time
1323
+ }
1324
+
1325
+ return result;
1326
+ }
1327
+
1328
+ //_____________________________________________________________________________
1329
+ //
1330
+ void AUBase::SetWantsRenderThreadID (bool inFlag)
1331
+ {
1332
+ if (inFlag == mWantsRenderThreadID)
1333
+ return;
1334
+
1335
+ mWantsRenderThreadID = inFlag;
1336
+ if (!mWantsRenderThreadID)
1337
+ mRenderThreadID = NULL;
1338
+ }
1339
+
1340
+ //_____________________________________________________________________________
1341
+ //
1342
+
1343
+ //_____________________________________________________________________________
1344
+ //
1345
+ OSStatus AUBase::DoRender( AudioUnitRenderActionFlags & ioActionFlags,
1346
+ const AudioTimeStamp & inTimeStamp,
1347
+ UInt32 inBusNumber,
1348
+ UInt32 inFramesToProcess,
1349
+ AudioBufferList & ioData)
1350
+ {
1351
+ OSStatus theError;
1352
+ RenderCallbackList::iterator rcit;
1353
+
1354
+ AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (intptr_t)this, inBusNumber, inFramesToProcess, 0);
1355
+ DISABLE_DENORMALS
1356
+
1357
+ try {
1358
+ ca_require(IsInitialized(), Uninitialized);
1359
+ ca_require(mAudioUnitAPIVersion >= 2, ParamErr);
1360
+ ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
1361
+
1362
+ AUOutputElement *output = GetOutput(inBusNumber); // will throw if non-existant
1363
+ if (output->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
1364
+ DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
1365
+ __FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
1366
+ goto ParamErr;
1367
+ }
1368
+
1369
+ unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
1370
+ for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
1371
+ AudioBuffer &buf = ioData.mBuffers[ibuf];
1372
+ if (buf.mData != NULL) {
1373
+ // only care about the size if the buffer is non-null
1374
+ if (buf.mDataByteSize < expectedBufferByteSize) {
1375
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
1376
+ DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
1377
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
1378
+ goto ParamErr;
1379
+ }
1380
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
1381
+ // We will generally set the buffer size at the end of rendering, before we return.
1382
+ // However we should ensure that no one, DURING rendering, READS a
1383
+ // potentially incorrect size. This can lead to doing too much work, or
1384
+ // reading past the end of an input buffer into unmapped memory.
1385
+ buf.mDataByteSize = expectedBufferByteSize;
1386
+ }
1387
+ }
1388
+
1389
+ if (WantsRenderThreadID())
1390
+ {
1391
+ #if TARGET_OS_MAC
1392
+ mRenderThreadID = pthread_self();
1393
+ #elif TARGET_OS_WIN32
1394
+ mRenderThreadID = GetCurrentThreadId();
1395
+ #endif
1396
+ }
1397
+
1398
+ AudioUnitRenderActionFlags flags;
1399
+ if (mRenderCallbacksTouched) {
1400
+ mRenderCallbacks.update();
1401
+ flags = ioActionFlags | kAudioUnitRenderAction_PreRender;
1402
+ for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
1403
+ RenderCallback &rc = *rcit;
1404
+ AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
1405
+ (*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon,
1406
+ &flags,
1407
+ &inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
1408
+ AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
1409
+ }
1410
+ }
1411
+
1412
+ theError = DoRenderBus(ioActionFlags, inTimeStamp, inBusNumber, output, inFramesToProcess, ioData);
1413
+
1414
+ flags = ioActionFlags | kAudioUnitRenderAction_PostRender;
1415
+
1416
+ if (SetRenderError (theError)) {
1417
+ flags |= kAudioUnitRenderAction_PostRenderError;
1418
+ }
1419
+
1420
+ if (mRenderCallbacksTouched) {
1421
+ for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
1422
+ RenderCallback &rc = *rcit;
1423
+ AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
1424
+ (*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon,
1425
+ &flags,
1426
+ &inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
1427
+ AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
1428
+ }
1429
+ }
1430
+
1431
+ // The vector's being emptied
1432
+ // because these events should only apply to this Render cycle, so anything
1433
+ // left over is from a preceding cycle and should be dumped. New scheduled
1434
+ // parameters must be scheduled from the next pre-render callback.
1435
+ if (!mParamList.empty())
1436
+ mParamList.clear();
1437
+
1438
+ }
1439
+ catch (OSStatus err) {
1440
+ theError = err;
1441
+ goto errexit;
1442
+ }
1443
+ catch (...) {
1444
+ theError = -1;
1445
+ goto errexit;
1446
+ }
1447
+ done:
1448
+ RESTORE_DENORMALS
1449
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, ioData.mBuffers[0].mData != NULL ? *(int64_t *)ioData.mBuffers[0].mData : 0);
1450
+
1451
+ return theError;
1452
+
1453
+ Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
1454
+ ParamErr: theError = kAudio_ParamError; goto errexit;
1455
+ TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
1456
+ errexit:
1457
+ DebugMessageN2 (" from %s, render err: %d", GetLoggingString(), (int)theError);
1458
+ SetRenderError(theError);
1459
+ goto done;
1460
+ }
1461
+
1462
+ //_____________________________________________________________________________
1463
+ //
1464
+ OSStatus AUBase::DoProcess ( AudioUnitRenderActionFlags & ioActionFlags,
1465
+ const AudioTimeStamp & inTimeStamp,
1466
+ UInt32 inFramesToProcess,
1467
+ AudioBufferList & ioData)
1468
+ {
1469
+ OSStatus theError;
1470
+ AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (intptr_t)this, inFramesToProcess, 0, 0);
1471
+ DISABLE_DENORMALS
1472
+
1473
+ try {
1474
+
1475
+ if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
1476
+ ca_require(IsInitialized(), Uninitialized);
1477
+ ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
1478
+
1479
+ AUInputElement *input = GetInput(0); // will throw if non-existant
1480
+ if (input->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
1481
+ DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
1482
+ __FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
1483
+ goto ParamErr;
1484
+ }
1485
+
1486
+ unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
1487
+ for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
1488
+ AudioBuffer &buf = ioData.mBuffers[ibuf];
1489
+ if (buf.mData != NULL) {
1490
+ // only care about the size if the buffer is non-null
1491
+ if (buf.mDataByteSize < expectedBufferByteSize) {
1492
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
1493
+ DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
1494
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
1495
+ goto ParamErr;
1496
+ }
1497
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
1498
+ // We will generally set the buffer size at the end of rendering, before we return.
1499
+ // However we should ensure that no one, DURING rendering, READS a
1500
+ // potentially incorrect size. This can lead to doing too much work, or
1501
+ // reading past the end of an input buffer into unmapped memory.
1502
+ buf.mDataByteSize = expectedBufferByteSize;
1503
+ }
1504
+ }
1505
+ }
1506
+
1507
+ if (WantsRenderThreadID())
1508
+ {
1509
+ #if TARGET_OS_MAC
1510
+ mRenderThreadID = pthread_self();
1511
+ #elif TARGET_OS_WIN32
1512
+ mRenderThreadID = GetCurrentThreadId();
1513
+ #endif
1514
+ }
1515
+
1516
+ if (NeedsToRender (inTimeStamp)) {
1517
+ theError = ProcessBufferLists (ioActionFlags, ioData, ioData, inFramesToProcess);
1518
+ } else
1519
+ theError = noErr;
1520
+
1521
+ }
1522
+ catch (OSStatus err) {
1523
+ theError = err;
1524
+ goto errexit;
1525
+ }
1526
+ catch (...) {
1527
+ theError = -1;
1528
+ goto errexit;
1529
+ }
1530
+ done:
1531
+ RESTORE_DENORMALS
1532
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, ioData.mBuffers[0].mData != NULL ? *(int64_t *)ioData.mBuffers[0].mData : 0);
1533
+
1534
+ return theError;
1535
+
1536
+ Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
1537
+ ParamErr: theError = kAudio_ParamError; goto errexit;
1538
+ TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
1539
+ errexit:
1540
+ DebugMessageN2 (" from %s, process err: %d", GetLoggingString(), (int)theError);
1541
+ SetRenderError(theError);
1542
+ goto done;
1543
+ }
1544
+
1545
+ OSStatus AUBase::DoProcessMultiple ( AudioUnitRenderActionFlags & ioActionFlags,
1546
+ const AudioTimeStamp & inTimeStamp,
1547
+ UInt32 inFramesToProcess,
1548
+ UInt32 inNumberInputBufferLists,
1549
+ const AudioBufferList ** inInputBufferLists,
1550
+ UInt32 inNumberOutputBufferLists,
1551
+ AudioBufferList ** ioOutputBufferLists)
1552
+ {
1553
+ OSStatus theError;
1554
+ DISABLE_DENORMALS
1555
+
1556
+ try {
1557
+
1558
+ if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
1559
+ ca_require(IsInitialized(), Uninitialized);
1560
+ ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
1561
+
1562
+ for (unsigned ibl = 0; ibl < inNumberInputBufferLists; ++ibl) {
1563
+ if (inInputBufferLists[ibl] != NULL) {
1564
+ AUInputElement *input = GetInput(ibl); // will throw if non-existant
1565
+ unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
1566
+
1567
+ if (input->GetStreamFormat().NumberChannelStreams() != inInputBufferLists[ibl]->mNumberBuffers) {
1568
+ DebugMessageN5("%s:%d inInputBufferLists[%u]->mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
1569
+ __FILE__, __LINE__, ibl, (unsigned)inInputBufferLists[ibl]->mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
1570
+ goto ParamErr;
1571
+ }
1572
+
1573
+ for (unsigned ibuf = 0; ibuf < inInputBufferLists[ibl]->mNumberBuffers; ++ibuf) {
1574
+ const AudioBuffer &buf = inInputBufferLists[ibl]->mBuffers[ibuf];
1575
+ if (buf.mData != NULL) {
1576
+ if (buf.mDataByteSize < expectedBufferByteSize) {
1577
+ // the buffer is too small
1578
+ DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; inInputBufferLists[%u].mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
1579
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibl, ibuf, (unsigned)buf.mDataByteSize);
1580
+ goto ParamErr;
1581
+ }
1582
+ } else {
1583
+ // the buffer must exist
1584
+ goto ParamErr;
1585
+ }
1586
+ }
1587
+ } else {
1588
+ // skip NULL input audio buffer list
1589
+ }
1590
+ }
1591
+
1592
+ for (unsigned obl = 0; obl < inNumberOutputBufferLists; ++obl) {
1593
+ if (ioOutputBufferLists[obl] != NULL) {
1594
+ AUOutputElement *output = GetOutput(obl); // will throw if non-existant
1595
+ unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
1596
+
1597
+ if (output->GetStreamFormat().NumberChannelStreams() != ioOutputBufferLists[obl]->mNumberBuffers) {
1598
+ DebugMessageN5("%s:%d ioOutputBufferLists[%u]->mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
1599
+ __FILE__, __LINE__, obl, (unsigned)ioOutputBufferLists[obl]->mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
1600
+ goto ParamErr;
1601
+ }
1602
+
1603
+ for (unsigned obuf = 0; obuf < ioOutputBufferLists[obl]->mNumberBuffers; ++obuf) {
1604
+ AudioBuffer &buf = ioOutputBufferLists[obl]->mBuffers[obuf];
1605
+ if (buf.mData != NULL) {
1606
+ // only care about the size if the buffer is non-null
1607
+ if (buf.mDataByteSize < expectedBufferByteSize) {
1608
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
1609
+ DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioOutputBufferLists[%u]->mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
1610
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, obl, obuf, (unsigned)buf.mDataByteSize);
1611
+ goto ParamErr;
1612
+ }
1613
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
1614
+ // We will generally set the buffer size at the end of rendering, before we return.
1615
+ // However we should ensure that no one, DURING rendering, READS a
1616
+ // potentially incorrect size. This can lead to doing too much work, or
1617
+ // reading past the end of an input buffer into unmapped memory.
1618
+ buf.mDataByteSize = expectedBufferByteSize;
1619
+ }
1620
+ }
1621
+ } else {
1622
+ // skip NULL output audio buffer list
1623
+ }
1624
+ }
1625
+ }
1626
+
1627
+ if (WantsRenderThreadID())
1628
+ {
1629
+ #if TARGET_OS_MAC
1630
+ mRenderThreadID = pthread_self();
1631
+ #elif TARGET_OS_WIN32
1632
+ mRenderThreadID = GetCurrentThreadId();
1633
+ #endif
1634
+ }
1635
+
1636
+ if (NeedsToRender (inTimeStamp)) {
1637
+ if (inNumberInputBufferLists == 1 && inNumberOutputBufferLists == 1)
1638
+ theError = ProcessBufferLists (ioActionFlags, *inInputBufferLists[0], *ioOutputBufferLists[0], inFramesToProcess);
1639
+ else {
1640
+ theError = ProcessMultipleBufferLists (ioActionFlags, inFramesToProcess, inNumberInputBufferLists, inInputBufferLists, inNumberOutputBufferLists, ioOutputBufferLists);
1641
+ }
1642
+ } else
1643
+ theError = noErr;
1644
+ }
1645
+ catch (OSStatus err) {
1646
+ theError = err;
1647
+ goto errexit;
1648
+ }
1649
+ catch (...) {
1650
+ theError = -1;
1651
+ goto errexit;
1652
+ }
1653
+ done:
1654
+ RESTORE_DENORMALS
1655
+
1656
+ return theError;
1657
+
1658
+ Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
1659
+ ParamErr: theError = kAudio_ParamError; goto errexit;
1660
+ TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
1661
+ errexit:
1662
+ DebugMessageN2 (" from %s, processmultiple err: %d", GetLoggingString(), (int)theError);
1663
+ SetRenderError(theError);
1664
+ goto done;
1665
+ }
1666
+
1667
+ //_____________________________________________________________________________
1668
+ //
1669
+ OSStatus AUBase::SetInputCallback( UInt32 inPropertyID,
1670
+ AudioUnitElement inElement,
1671
+ AURenderCallback inProc,
1672
+ void * inRefCon)
1673
+ {
1674
+ AUInputElement *input = GetInput(inElement); // may throw
1675
+
1676
+ input->SetInputCallback(inProc, inRefCon);
1677
+ PropertyChanged(inPropertyID, kAudioUnitScope_Input, inElement);
1678
+
1679
+ return noErr;
1680
+ }
1681
+
1682
+ //_____________________________________________________________________________
1683
+ //
1684
+ OSStatus AUBase::SetConnection( const AudioUnitConnection & inConnection)
1685
+ {
1686
+
1687
+ OSStatus err;
1688
+ AUInputElement *input = GetInput(inConnection.destInputNumber); // may throw
1689
+
1690
+ if (inConnection.sourceAudioUnit) {
1691
+ // connecting, not disconnecting
1692
+ CAStreamBasicDescription sourceDesc;
1693
+ UInt32 size = sizeof(CAStreamBasicDescription);
1694
+ ca_require_noerr(err = AudioUnitGetProperty(
1695
+ inConnection.sourceAudioUnit,
1696
+ kAudioUnitProperty_StreamFormat,
1697
+ kAudioUnitScope_Output,
1698
+ inConnection.sourceOutputNumber,
1699
+ &sourceDesc,
1700
+ &size), errexit);
1701
+ ca_require_noerr(err = DispatchSetProperty (kAudioUnitProperty_StreamFormat,
1702
+ kAudioUnitScope_Input, inConnection.destInputNumber,
1703
+ &sourceDesc, sizeof(CAStreamBasicDescription)), errexit);
1704
+ }
1705
+ input->SetConnection(inConnection);
1706
+
1707
+ PropertyChanged(kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input, inConnection.destInputNumber);
1708
+ return noErr;
1709
+
1710
+ errexit:
1711
+ return err;
1712
+ }
1713
+
1714
+ //_____________________________________________________________________________
1715
+ //
1716
+ UInt32 AUBase::SupportedNumChannels ( const AUChannelInfo** outInfo)
1717
+ {
1718
+ return 0;
1719
+ }
1720
+
1721
+ //_____________________________________________________________________________
1722
+ //
1723
+ bool AUBase::ValidFormat( AudioUnitScope inScope,
1724
+ AudioUnitElement inElement,
1725
+ const CAStreamBasicDescription & inNewFormat)
1726
+ {
1727
+ return FormatIsCanonical(inNewFormat);
1728
+ }
1729
+
1730
+ //_____________________________________________________________________________
1731
+ //
1732
+ bool AUBase::IsStreamFormatWritable( AudioUnitScope scope,
1733
+ AudioUnitElement element)
1734
+ {
1735
+ switch (scope) {
1736
+ case kAudioUnitScope_Input:
1737
+ {
1738
+ AUInputElement *input = GetInput(element);
1739
+ if (input->HasConnection()) return false; // can't write format when input comes from connection
1740
+ }
1741
+ // ... fall ...
1742
+ case kAudioUnitScope_Output:
1743
+ return StreamFormatWritable(scope, element);
1744
+
1745
+ //#warning "aliasing of global scope format should be pushed to subclasses"
1746
+ case kAudioUnitScope_Global:
1747
+ return StreamFormatWritable(kAudioUnitScope_Output, 0);
1748
+ }
1749
+ return false;
1750
+ }
1751
+
1752
+ //_____________________________________________________________________________
1753
+ //
1754
+ const CAStreamBasicDescription &
1755
+ AUBase::GetStreamFormat( AudioUnitScope inScope,
1756
+ AudioUnitElement inElement)
1757
+ {
1758
+ //#warning "aliasing of global scope format should be pushed to subclasses"
1759
+ AUIOElement *element;
1760
+
1761
+ switch (inScope) {
1762
+ case kAudioUnitScope_Input:
1763
+ element = Inputs().GetIOElement(inElement);
1764
+ break;
1765
+ case kAudioUnitScope_Output:
1766
+ element = Outputs().GetIOElement(inElement);
1767
+ break;
1768
+ case kAudioUnitScope_Global: // global stream description is an alias for that of output 0
1769
+ element = Outputs().GetIOElement(0);
1770
+ break;
1771
+ default:
1772
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
1773
+ }
1774
+ return element->GetStreamFormat();
1775
+ }
1776
+
1777
+ OSStatus AUBase::SetBusCount( AudioUnitScope inScope,
1778
+ UInt32 inCount)
1779
+ {
1780
+ if (IsInitialized())
1781
+ return kAudioUnitErr_Initialized;
1782
+
1783
+ GetScope(inScope).SetNumberOfElements(inCount);
1784
+ return noErr;
1785
+ }
1786
+
1787
+ //_____________________________________________________________________________
1788
+ //
1789
+ OSStatus AUBase::ChangeStreamFormat( AudioUnitScope inScope,
1790
+ AudioUnitElement inElement,
1791
+ const CAStreamBasicDescription & inPrevFormat,
1792
+ const CAStreamBasicDescription & inNewFormat)
1793
+ {
1794
+ //#warning "aliasing of global scope format should be pushed to subclasses"
1795
+ AUIOElement *element;
1796
+
1797
+ switch (inScope) {
1798
+ case kAudioUnitScope_Input:
1799
+ element = Inputs().GetIOElement(inElement);
1800
+ break;
1801
+ case kAudioUnitScope_Output:
1802
+ element = Outputs().GetIOElement(inElement);
1803
+ break;
1804
+ case kAudioUnitScope_Global:
1805
+ element = Outputs().GetIOElement(0);
1806
+ break;
1807
+ default:
1808
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
1809
+ }
1810
+ element->SetStreamFormat(inNewFormat);
1811
+ PropertyChanged(kAudioUnitProperty_StreamFormat, inScope, inElement);
1812
+ return noErr;
1813
+ }
1814
+
1815
+ UInt32 AUBase::GetChannelLayoutTags( AudioUnitScope inScope,
1816
+ AudioUnitElement inElement,
1817
+ AudioChannelLayoutTag * outLayoutTags)
1818
+ {
1819
+ return GetIOElement(inScope, inElement)->GetChannelLayoutTags(outLayoutTags);
1820
+ }
1821
+
1822
+ UInt32 AUBase::GetAudioChannelLayout( AudioUnitScope scope,
1823
+ AudioUnitElement element,
1824
+ AudioChannelLayout * outLayoutPtr,
1825
+ Boolean & outWritable)
1826
+ {
1827
+ AUIOElement * el = GetIOElement(scope, element);
1828
+ return el->GetAudioChannelLayout(outLayoutPtr, outWritable);
1829
+ }
1830
+
1831
+ OSStatus AUBase::RemoveAudioChannelLayout( AudioUnitScope inScope,
1832
+ AudioUnitElement inElement)
1833
+ {
1834
+ OSStatus result = noErr;
1835
+ AUIOElement * el = GetIOElement(inScope, inElement);
1836
+ Boolean writable;
1837
+ if (el->GetAudioChannelLayout(NULL, writable)) {
1838
+ result = el->RemoveAudioChannelLayout();
1839
+ }
1840
+ return result;
1841
+ }
1842
+
1843
+ OSStatus AUBase::SetAudioChannelLayout( AudioUnitScope inScope,
1844
+ AudioUnitElement inElement,
1845
+ const AudioChannelLayout * inLayout)
1846
+ {
1847
+ AUIOElement* ioEl = GetIOElement (inScope, inElement);
1848
+
1849
+ // the num channels of the layout HAS TO MATCH the current channels of the Element's stream format
1850
+ UInt32 currentChannels = ioEl->GetStreamFormat().NumberChannels();
1851
+ UInt32 numChannelsInLayout = CAAudioChannelLayout::NumberChannels(*inLayout);
1852
+ if (currentChannels != numChannelsInLayout)
1853
+ return kAudioUnitErr_InvalidPropertyValue;
1854
+
1855
+ UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, NULL);
1856
+ if (numLayouts == 0)
1857
+ return kAudioUnitErr_InvalidProperty;
1858
+ AudioChannelLayoutTag *tags = (AudioChannelLayoutTag *)CA_malloc (numLayouts * sizeof (AudioChannelLayoutTag));
1859
+ GetChannelLayoutTags (inScope, inElement, tags);
1860
+ bool foundTag = false;
1861
+ for (unsigned int i = 0; i < numLayouts; ++i) {
1862
+ if (tags[i] == inLayout->mChannelLayoutTag || tags[i] == kAudioChannelLayoutTag_UseChannelDescriptions) {
1863
+ foundTag = true;
1864
+ break;
1865
+ }
1866
+ }
1867
+ free(tags);
1868
+
1869
+ if (foundTag == false)
1870
+ return kAudioUnitErr_InvalidPropertyValue;
1871
+
1872
+ return ioEl->SetAudioChannelLayout(*inLayout);
1873
+ }
1874
+
1875
+ static void AddNumToDictionary (CFMutableDictionaryRef dict, CFStringRef key, SInt32 value)
1876
+ {
1877
+ CFNumberRef num = CFNumberCreate (NULL, kCFNumberSInt32Type, &value);
1878
+ CFDictionarySetValue (dict, key, num);
1879
+ CFRelease (num);
1880
+ }
1881
+
1882
+ #define kCurrentSavedStateVersion 0
1883
+
1884
+ OSStatus AUBase::SaveState( CFPropertyListRef * outData)
1885
+ {
1886
+ AudioComponentDescription desc = GetComponentDescription();
1887
+
1888
+ CFMutableDictionaryRef dict = CFDictionaryCreateMutable (NULL, 0,
1889
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1890
+
1891
+ // first step -> save the version to the data ref
1892
+ SInt32 value = kCurrentSavedStateVersion;
1893
+ AddNumToDictionary (dict, kVersionString, value);
1894
+
1895
+ // second step -> save the component type, subtype, manu to the data ref
1896
+ value = desc.componentType;
1897
+ AddNumToDictionary (dict, kTypeString, value);
1898
+
1899
+ value = desc.componentSubType;
1900
+ AddNumToDictionary (dict, kSubtypeString, value);
1901
+
1902
+ value = desc.componentManufacturer;
1903
+ AddNumToDictionary (dict, kManufacturerString, value);
1904
+
1905
+ // fourth step -> save the state of all parameters on all scopes and elements
1906
+ CFMutableDataRef data = CFDataCreateMutable(NULL, 0);
1907
+ for (AudioUnitScope iscope = 0; iscope < 3; ++iscope) {
1908
+ AUScope &scope = GetScope(iscope);
1909
+ AudioUnitElement nElems = scope.GetNumberOfElements();
1910
+ for (AudioUnitElement ielem = 0; ielem < nElems; ++ielem) {
1911
+ AUElement *element = scope.GetElement(ielem);
1912
+ UInt32 nparams = element->GetNumberOfParameters();
1913
+ if (nparams > 0) {
1914
+ struct {
1915
+ UInt32 scope;
1916
+ UInt32 element;
1917
+ } hdr;
1918
+
1919
+ hdr.scope = CFSwapInt32HostToBig(iscope);
1920
+ hdr.element = CFSwapInt32HostToBig(ielem);
1921
+ CFDataAppendBytes(data, (UInt8 *)&hdr, sizeof(hdr));
1922
+
1923
+ element->SaveState(data);
1924
+ }
1925
+ }
1926
+ }
1927
+
1928
+ // save all this in the data section of the dictionary
1929
+ CFDictionarySetValue(dict, kDataString, data);
1930
+ CFRelease (data);
1931
+
1932
+ //OK - now we're going to do some properties
1933
+ //save the preset name...
1934
+ CFDictionarySetValue (dict, kNameString, mCurrentPreset.presetName);
1935
+
1936
+ // Does the unit support the RenderQuality property - if so, save it...
1937
+ value = 0;
1938
+ OSStatus result = DispatchGetProperty (kAudioUnitProperty_RenderQuality,
1939
+ kAudioUnitScope_Global,
1940
+ 0,
1941
+ &value);
1942
+
1943
+ if (result == noErr) {
1944
+ AddNumToDictionary (dict, kRenderQualityString, value);
1945
+ }
1946
+
1947
+ // Does the unit support the CPULoad Quality property - if so, save it...
1948
+ Float32 cpuLoad;
1949
+ result = DispatchGetProperty (6/*kAudioUnitProperty_CPULoad*/,
1950
+ kAudioUnitScope_Global,
1951
+ 0,
1952
+ &cpuLoad);
1953
+
1954
+ if (result == noErr) {
1955
+ CFNumberRef num = CFNumberCreate (NULL, kCFNumberFloatType, &cpuLoad);
1956
+ CFDictionarySetValue (dict, kCPULoadString, num);
1957
+ CFRelease (num);
1958
+ }
1959
+
1960
+ // Do we have any element names for any of our scopes?
1961
+ // first check to see if we have any names...
1962
+ bool foundName = false;
1963
+ for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
1964
+ foundName = GetScope (i).HasElementWithName();
1965
+ if (foundName)
1966
+ break;
1967
+ }
1968
+ // OK - we found a name away we go...
1969
+ if (foundName) {
1970
+ CFMutableDictionaryRef nameDict = CFDictionaryCreateMutable (NULL, 0,
1971
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1972
+ for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
1973
+ GetScope (i).AddElementNamesToDict (nameDict);
1974
+ }
1975
+
1976
+ CFDictionarySetValue (dict, kElementNameString, nameDict);
1977
+ CFRelease (nameDict);
1978
+ }
1979
+
1980
+ // we're done!!!
1981
+ *outData = dict;
1982
+
1983
+ return noErr;
1984
+ }
1985
+
1986
+ //_____________________________________________________________________________
1987
+ //
1988
+ OSStatus AUBase::RestoreState( CFPropertyListRef plist)
1989
+ {
1990
+ if (CFGetTypeID(plist) != CFDictionaryGetTypeID()) return kAudioUnitErr_InvalidPropertyValue;
1991
+
1992
+ AudioComponentDescription desc = GetComponentDescription();
1993
+
1994
+ CFDictionaryRef dict = static_cast<CFDictionaryRef>(plist);
1995
+
1996
+ // zeroeth step - make sure the Part key is NOT present, as this method is used
1997
+ // to restore the GLOBAL state of the dictionary
1998
+ if (CFDictionaryContainsKey (dict, kPartString))
1999
+ return kAudioUnitErr_InvalidPropertyValue;
2000
+
2001
+ // first step -> check the saved version in the data ref
2002
+ // at this point we're only dealing with version==0
2003
+ CFNumberRef cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kVersionString));
2004
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
2005
+ SInt32 value;
2006
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
2007
+ if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
2008
+
2009
+ // second step -> check that this data belongs to this kind of audio unit
2010
+ // by checking the component subtype and manuID
2011
+ // We're not checking the type, since there may be different versions (effect, format-converter, offline)
2012
+ // of essentially the same AU
2013
+ cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kSubtypeString));
2014
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
2015
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
2016
+ if (UInt32(value) != desc.componentSubType) return kAudioUnitErr_InvalidPropertyValue;
2017
+
2018
+ cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kManufacturerString));
2019
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
2020
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
2021
+ if (UInt32(value) != desc.componentManufacturer) return kAudioUnitErr_InvalidPropertyValue;
2022
+
2023
+ // fourth step -> restore the state of all of the parameters for each scope and element
2024
+ CFDataRef data = reinterpret_cast<CFDataRef>(CFDictionaryGetValue (dict, kDataString));
2025
+ if (data != NULL)
2026
+ {
2027
+ const UInt8 *p, *pend;
2028
+
2029
+ p = CFDataGetBytePtr(data);
2030
+ pend = p + CFDataGetLength(data);
2031
+
2032
+ // we have a zero length data, which may just mean there were no parameters to save!
2033
+ // if (p >= pend) return noErr;
2034
+
2035
+ while (p < pend) {
2036
+ struct {
2037
+ UInt32 scope;
2038
+ UInt32 element;
2039
+ } hdr;
2040
+
2041
+ hdr.scope = CFSwapInt32BigToHost(*(UInt32 *)p); p += sizeof(UInt32);
2042
+ hdr.element = CFSwapInt32BigToHost(*(UInt32 *)p); p += sizeof(UInt32);
2043
+
2044
+ AUScope &scope = GetScope(hdr.scope);
2045
+ AUElement *element = scope.GetElement(hdr.element);
2046
+ // $$$ order of operations issue: what if the element does not yet exist?
2047
+ // then we just break out of the loop
2048
+ if (!element)
2049
+ break;
2050
+ p = element->RestoreState(p);
2051
+ }
2052
+ }
2053
+
2054
+ //OK - now we're going to do some properties
2055
+ //restore the preset name...
2056
+ CFStringRef name = reinterpret_cast<CFStringRef>(CFDictionaryGetValue (dict, kNameString));
2057
+ if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
2058
+ if (name)
2059
+ {
2060
+ mCurrentPreset.presetName = name;
2061
+ mCurrentPreset.presetNumber = -1;
2062
+ }
2063
+ else { // no name entry make the default one
2064
+ mCurrentPreset.presetName = kUntitledString;
2065
+ mCurrentPreset.presetNumber = -1;
2066
+ }
2067
+
2068
+ CFRetain (mCurrentPreset.presetName);
2069
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
2070
+ #ifndef __LP64__
2071
+ PropertyChanged(kAudioUnitProperty_CurrentPreset, kAudioUnitScope_Global, 0);
2072
+ #endif
2073
+ #endif
2074
+ PropertyChanged(kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0);
2075
+
2076
+ // Does the dict contain render quality information?
2077
+ if (CFDictionaryGetValueIfPresent (dict, kRenderQualityString, reinterpret_cast<const void**>(&cfnum)))
2078
+ {
2079
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
2080
+ DispatchSetProperty (kAudioUnitProperty_RenderQuality,
2081
+ kAudioUnitScope_Global,
2082
+ 0,
2083
+ &value,
2084
+ sizeof(value));
2085
+ }
2086
+
2087
+ // Does the unit support the CPULoad Quality property - if so, save it...
2088
+ if (CFDictionaryGetValueIfPresent (dict, kCPULoadString, reinterpret_cast<const void**>(&cfnum)))
2089
+ {
2090
+ Float32 floatValue;
2091
+ CFNumberGetValue (cfnum, kCFNumberFloatType, &floatValue);
2092
+ DispatchSetProperty (6/*kAudioUnitProperty_CPULoad*/,
2093
+ kAudioUnitScope_Global,
2094
+ 0,
2095
+ &floatValue,
2096
+ sizeof(floatValue));
2097
+ }
2098
+
2099
+ // Do we have any element names for any of our scopes?
2100
+ CFDictionaryRef nameDict;
2101
+ if (CFDictionaryGetValueIfPresent (dict, kElementNameString, reinterpret_cast<const void**>(&nameDict)))
2102
+ {
2103
+ char string[64];
2104
+ for (int i = 0; i < kNumScopes; ++i)
2105
+ {
2106
+ sprintf (string, "%d", i);
2107
+ CFStringRef key = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
2108
+ CFDictionaryRef elementDict;
2109
+ if (CFDictionaryGetValueIfPresent (nameDict, key, reinterpret_cast<const void**>(&elementDict)))
2110
+ {
2111
+ bool didAddElements = GetScope (i).RestoreElementNames (elementDict);
2112
+ if (didAddElements)
2113
+ PropertyChanged (kAudioUnitProperty_ElementCount, i, 0);
2114
+ }
2115
+ CFRelease (key);
2116
+ }
2117
+ }
2118
+
2119
+ return noErr;
2120
+ }
2121
+
2122
+ OSStatus AUBase::GetPresets ( CFArrayRef * outData) const
2123
+ {
2124
+ return kAudioUnitErr_InvalidProperty;
2125
+ }
2126
+
2127
+ OSStatus AUBase::NewFactoryPresetSet (const AUPreset & inNewFactoryPreset)
2128
+ {
2129
+ return kAudioUnitErr_InvalidProperty;
2130
+ }
2131
+
2132
+ // set the default preset for the unit -> the number of the preset MUST be >= 0
2133
+ // and the name should be valid, or the preset WON'T take
2134
+ bool AUBase::SetAFactoryPresetAsCurrent (const AUPreset & inPreset)
2135
+ {
2136
+ if (inPreset.presetNumber < 0 || inPreset.presetName == NULL) return false;
2137
+ CFRelease (mCurrentPreset.presetName);
2138
+ mCurrentPreset = inPreset;
2139
+ CFRetain (mCurrentPreset.presetName);
2140
+ return true;
2141
+ }
2142
+
2143
+ #if !CA_USE_AUDIO_PLUGIN_ONLY
2144
+ int AUBase::GetNumCustomUIComponents ()
2145
+ {
2146
+ return 0;
2147
+ }
2148
+
2149
+ void AUBase::GetUIComponentDescs (ComponentDescription* inDescArray) {}
2150
+ #endif
2151
+
2152
+ bool AUBase::HasIcon ()
2153
+ {
2154
+ #if !CA_NO_AU_UI_FEATURES
2155
+ CFURLRef url = CopyIconLocation();
2156
+ if (url) {
2157
+ CFRelease (url);
2158
+ return true;
2159
+ }
2160
+ #endif
2161
+ return false;
2162
+ }
2163
+
2164
+ CFURLRef AUBase::CopyIconLocation ()
2165
+ {
2166
+ return NULL;
2167
+ }
2168
+
2169
+ //_____________________________________________________________________________
2170
+ //
2171
+ OSStatus AUBase::GetParameterList( AudioUnitScope inScope,
2172
+ AudioUnitParameterID * outParameterList,
2173
+ UInt32 & outNumParameters)
2174
+ {
2175
+ AUScope &scope = GetScope(inScope);
2176
+ AUElement *elementWithMostParameters = NULL;
2177
+ UInt32 maxNumParams = 0;
2178
+
2179
+ int nElems = scope.GetNumberOfElements();
2180
+ for (int ielem = 0; ielem < nElems; ++ielem) {
2181
+ AUElement *element = scope.GetElement(ielem);
2182
+ UInt32 nParams = element->GetNumberOfParameters();
2183
+ if (nParams > maxNumParams) {
2184
+ maxNumParams = nParams;
2185
+ elementWithMostParameters = element;
2186
+ }
2187
+ }
2188
+
2189
+ if (outParameterList != NULL && elementWithMostParameters != NULL)
2190
+ elementWithMostParameters->GetParameterList(outParameterList);
2191
+
2192
+ outNumParameters = maxNumParams;
2193
+ return noErr;
2194
+ }
2195
+
2196
+ //_____________________________________________________________________________
2197
+ //
2198
+ OSStatus AUBase::GetParameterInfo( AudioUnitScope inScope,
2199
+ AudioUnitParameterID inParameterID,
2200
+ AudioUnitParameterInfo &outParameterInfo )
2201
+ {
2202
+ return kAudioUnitErr_InvalidParameter;
2203
+ }
2204
+
2205
+ //_____________________________________________________________________________
2206
+ //
2207
+ OSStatus AUBase::GetParameterValueStrings(AudioUnitScope inScope,
2208
+ AudioUnitParameterID inParameterID,
2209
+ CFArrayRef * outStrings)
2210
+ {
2211
+ return kAudioUnitErr_InvalidProperty;
2212
+ }
2213
+
2214
+ //_____________________________________________________________________________
2215
+ //
2216
+ OSStatus AUBase::GetParameterHistoryInfo( AudioUnitScope inScope,
2217
+ AudioUnitParameterID inParameterID,
2218
+ Float32 & outUpdatesPerSecond,
2219
+ Float32 & outHistoryDurationInSeconds)
2220
+ {
2221
+ return kAudioUnitErr_InvalidProperty;
2222
+ }
2223
+
2224
+
2225
+ //_____________________________________________________________________________
2226
+ //
2227
+ OSStatus AUBase::CopyClumpName( AudioUnitScope inScope,
2228
+ UInt32 inClumpID,
2229
+ UInt32 inDesiredNameLength,
2230
+ CFStringRef * outClumpName)
2231
+ {
2232
+ return kAudioUnitErr_InvalidProperty;
2233
+ }
2234
+
2235
+ //_____________________________________________________________________________
2236
+ //
2237
+ void AUBase::SetNumberOfElements( AudioUnitScope inScope,
2238
+ UInt32 numElements)
2239
+ {
2240
+ if (inScope == kAudioUnitScope_Global && numElements != 1)
2241
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
2242
+
2243
+ GetScope(inScope).SetNumberOfElements(numElements);
2244
+ }
2245
+
2246
+ //_____________________________________________________________________________
2247
+ //
2248
+ AUElement * AUBase::CreateElement( AudioUnitScope scope,
2249
+ AudioUnitElement element)
2250
+ {
2251
+ switch (scope) {
2252
+ case kAudioUnitScope_Global:
2253
+ return new AUElement(this);
2254
+ case kAudioUnitScope_Input:
2255
+ return new AUInputElement(this);
2256
+ case kAudioUnitScope_Output:
2257
+ return new AUOutputElement(this);
2258
+ #if !CA_BASIC_AU_FEATURES
2259
+ case kAudioUnitScope_Group:
2260
+ return new AUElement(this);
2261
+ case kAudioUnitScope_Part:
2262
+ return new AUElement(this);
2263
+ #endif
2264
+ }
2265
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
2266
+
2267
+ return NULL; // get rid of compiler warning
2268
+ }
2269
+
2270
+ //_____________________________________________________________________________
2271
+ //
2272
+ bool AUBase::FormatIsCanonical( const CAStreamBasicDescription &f)
2273
+ {
2274
+ return (f.mFormatID == kAudioFormatLinearPCM
2275
+ && f.mFramesPerPacket == 1
2276
+ && f.mBytesPerPacket == f.mBytesPerFrame
2277
+ // && f.mChannelsPerFrame >= 0 -- this is always true since it's unsigned
2278
+ // so far, it's a valid PCM format
2279
+ #if CA_PREFER_FIXED_POINT
2280
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsFloat) == 0
2281
+ && (((f.mFormatFlags & kLinearPCMFormatFlagsSampleFractionMask) >> kLinearPCMFormatFlagsSampleFractionShift) == kAudioUnitSampleFractionBits)
2282
+ #else
2283
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0
2284
+ #endif
2285
+ && ((f.mChannelsPerFrame == 1) || ((f.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0) == (mAudioUnitAPIVersion == 1))
2286
+ #if TARGET_RT_BIG_ENDIAN
2287
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) != 0
2288
+ #else
2289
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) == 0
2290
+ #endif
2291
+ && f.mBitsPerChannel == 8 * sizeof(AudioUnitSampleType)
2292
+ && f.mBytesPerFrame == f.NumberInterleavedChannels() * sizeof(AudioUnitSampleType)
2293
+ );
2294
+ }
2295
+
2296
+ //_____________________________________________________________________________
2297
+ //
2298
+ void AUBase::MakeCanonicalFormat( CAStreamBasicDescription & f,
2299
+ int nChannels)
2300
+ {
2301
+ f.SetAUCanonical(nChannels, mAudioUnitAPIVersion < 2); // interleaved for v1, non for v2
2302
+ f.mSampleRate = 0.0;
2303
+ }
2304
+
2305
+ const Float64 AUBase::kNoLastRenderedSampleTime = -1.;
2306
+
2307
+ #include "AUBaseHelper.h"
2308
+
2309
+ char* AUBase::GetLoggingString () const
2310
+ {
2311
+ if (mLogString) return mLogString;
2312
+
2313
+ AudioComponentDescription desc = GetComponentDescription();
2314
+
2315
+ const_cast<AUBase*>(this)->mLogString = new char[256];
2316
+ char str[24];
2317
+ char str1[24];
2318
+ char str2[24];
2319
+ sprintf (const_cast<AUBase*>(this)->mLogString, "AU (%p): %s %s %s",
2320
+ GetComponentInstance(),
2321
+ CAStringForOSType(desc.componentType, str),
2322
+ CAStringForOSType(desc.componentSubType, str1),
2323
+ CAStringForOSType(desc.componentManufacturer, str2));
2324
+
2325
+ return mLogString;
2326
+ }
2327
+