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.
- cyfaust/CMakeLists.txt +93 -0
- cyfaust/__init__.py +0 -0
- cyfaust/__main__.py +819 -0
- cyfaust/box.pxd +46 -0
- cyfaust/box.pyx +2459 -0
- cyfaust/common.pxd +5 -0
- cyfaust/common.pyx +61 -0
- cyfaust/cyfaust.cpython-311-darwin.so +0 -0
- cyfaust/faust_box.pxd +298 -0
- cyfaust/faust_box_oo.pyx +66 -0
- cyfaust/faust_gui.pxd +261 -0
- cyfaust/faust_interp.pxd +160 -0
- cyfaust/faust_player.pxd +80 -0
- cyfaust/faust_signal.pxd +257 -0
- cyfaust/gui_statics.cpp +15 -0
- cyfaust/interp.pyx +673 -0
- cyfaust/player.cpp +32519 -0
- cyfaust/player.pyx +191 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUBase.cpp +2327 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUBase.h +1019 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUDispatch.cpp +423 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUDispatch.h +82 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUInputElement.cpp +151 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUInputElement.h +119 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUOutputElement.cpp +62 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUOutputElement.h +66 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUPlugInDispatch.cpp +615 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUPlugInDispatch.h +128 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUScopeElement.cpp +512 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/AUScopeElement.h +544 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/ComponentBase.cpp +370 -0
- cyfaust/resources/architecture/AU/AUPublic/AUBase/ComponentBase.h +340 -0
- cyfaust/resources/architecture/AU/AUPublic/AUEffectBase/AUEffectBase.cpp +463 -0
- cyfaust/resources/architecture/AU/AUPublic/AUEffectBase/AUEffectBase.h +391 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp +837 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUInstrumentBase.h +267 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUMIDIBase.cpp +495 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/AUMIDIBase.h +213 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/LockFreeFIFO.h +168 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MIDIControlHandler.h +92 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MusicDeviceBase.cpp +354 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/MusicDeviceBase.h +126 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthElement.cpp +419 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthElement.h +227 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthEvent.h +145 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNote.cpp +138 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNote.h +186 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNoteList.cpp +93 -0
- cyfaust/resources/architecture/AU/AUPublic/AUInstrumentBase/SynthNoteList.h +232 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUBaseHelper.cpp +134 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUBaseHelper.h +80 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUBuffer.cpp +217 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUBuffer.h +267 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUMIDIDefs.h +136 -0
- cyfaust/resources/architecture/AU/AUPublic/Utility/AUSilentTimeout.h +93 -0
- cyfaust/resources/architecture/AU/English.lproj/InfoPlist.strings +0 -0
- cyfaust/resources/architecture/AU/FaustAU.exp +2 -0
- cyfaust/resources/architecture/AU/FaustAU.xcodeproj/project.pbxproj +968 -0
- cyfaust/resources/architecture/AU/FaustAU.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- cyfaust/resources/architecture/AU/FaustAUCustomView.plist +14 -0
- cyfaust/resources/architecture/AU/Info.plist +47 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAAtomic.h +305 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAAtomicStack.h +239 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAAudioChannelLayout.cpp +153 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAAudioChannelLayout.h +199 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAAutoDisposer.h +508 -0
- cyfaust/resources/architecture/AU/PublicUtility/CABufferList.cpp +264 -0
- cyfaust/resources/architecture/AU/PublicUtility/CABufferList.h +319 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAByteOrder.h +161 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugMacros.cpp +88 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugMacros.h +580 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugPrintf.cpp +89 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugPrintf.h +115 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugger.cpp +77 -0
- cyfaust/resources/architecture/AU/PublicUtility/CADebugger.h +56 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAException.h +83 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAGuard.cpp +339 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAGuard.h +133 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAHostTimeBase.cpp +110 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAHostTimeBase.h +231 -0
- cyfaust/resources/architecture/AU/PublicUtility/CALogMacros.h +140 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAMath.h +68 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAMutex.cpp +345 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAMutex.h +163 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAReferenceCounted.h +87 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAStreamBasicDescription.cpp +795 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAStreamBasicDescription.h +409 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAThreadSafeList.h +255 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnit.cpp +191 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnit.h +100 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAVectorUnitTypes.h +59 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAXException.cpp +49 -0
- cyfaust/resources/architecture/AU/PublicUtility/CAXException.h +338 -0
- cyfaust/resources/architecture/AU/SectionPatternLight.tiff +0 -0
- cyfaust/resources/architecture/AU/Source/AUSource/FaustAU.h +38 -0
- cyfaust/resources/architecture/AU/Source/AUSource/FaustAU.r +153 -0
- cyfaust/resources/architecture/AU/Source/AUSource/FaustAUVersion.h +64 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Bargraph.h +18 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Bargraph.m +21 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Button.h +20 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Button.m +56 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomView.h +87 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomView.m +834 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomViewFactory.h +13 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_CustomViewFactory.m +22 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Knob.h +81 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Knob.m +199 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Slider.h +18 -0
- cyfaust/resources/architecture/AU/Source/CocoaUI/FaustAU_Slider.m +21 -0
- cyfaust/resources/architecture/AU/version.plist +16 -0
- cyfaust/resources/architecture/VST/Info.plist +28 -0
- cyfaust/resources/architecture/VST/PkgInfo +1 -0
- cyfaust/resources/architecture/VST/README +11 -0
- cyfaust/resources/architecture/VST/VST.xcode/project.pbxproj +655 -0
- cyfaust/resources/architecture/alsa-console.cpp +246 -0
- cyfaust/resources/architecture/alsa-gtk.cpp +220 -0
- cyfaust/resources/architecture/alsa-qt.cpp +229 -0
- cyfaust/resources/architecture/api/DspFaust.cpp +612 -0
- cyfaust/resources/architecture/api/DspFaust.h +511 -0
- cyfaust/resources/architecture/api/README.md +237 -0
- cyfaust/resources/architecture/api/doc/Generic.md +38 -0
- cyfaust/resources/architecture/au-effect.cpp +487 -0
- cyfaust/resources/architecture/au-instrument.cpp +573 -0
- cyfaust/resources/architecture/bench.cpp +91 -0
- cyfaust/resources/architecture/c-jack-gtk.c +227 -0
- cyfaust/resources/architecture/ca-gtk.cpp +284 -0
- cyfaust/resources/architecture/ca-qt.cpp +424 -0
- cyfaust/resources/architecture/cpal.rs +195 -0
- cyfaust/resources/architecture/csound.cpp +245 -0
- cyfaust/resources/architecture/csvplot.cpp +227 -0
- cyfaust/resources/architecture/daisy/Makefile +14 -0
- cyfaust/resources/architecture/daisy/README.md +50 -0
- cyfaust/resources/architecture/daisy/ex_faust.cpp +173 -0
- cyfaust/resources/architecture/dssi.cpp +1262 -0
- cyfaust/resources/architecture/dummy-mem.cpp +186 -0
- cyfaust/resources/architecture/dummy.cpp +294 -0
- cyfaust/resources/architecture/faust/au/AUUI.h +404 -0
- cyfaust/resources/architecture/faust/audio/alsa-dsp.h +693 -0
- cyfaust/resources/architecture/faust/audio/android-dsp.h +583 -0
- cyfaust/resources/architecture/faust/audio/audio.h +115 -0
- cyfaust/resources/architecture/faust/audio/channels.h +122 -0
- cyfaust/resources/architecture/faust/audio/coreaudio-dsp.h +1543 -0
- cyfaust/resources/architecture/faust/audio/coreaudio-ios-dsp.h +743 -0
- cyfaust/resources/architecture/faust/audio/dummy-audio.h +255 -0
- cyfaust/resources/architecture/faust/audio/esp32-dsp.h +284 -0
- cyfaust/resources/architecture/faust/audio/fpe.h +164 -0
- cyfaust/resources/architecture/faust/audio/jack-dsp.h +534 -0
- cyfaust/resources/architecture/faust/audio/juce-dsp.h +119 -0
- cyfaust/resources/architecture/faust/audio/netjack-dsp.h +354 -0
- cyfaust/resources/architecture/faust/audio/oboe-dsp.h +308 -0
- cyfaust/resources/architecture/faust/audio/ofaudio-dsp.h +155 -0
- cyfaust/resources/architecture/faust/audio/opensles-android-dsp.h +631 -0
- cyfaust/resources/architecture/faust/audio/osc-dsp.h +120 -0
- cyfaust/resources/architecture/faust/audio/portaudio-dsp.h +236 -0
- cyfaust/resources/architecture/faust/audio/rtaudio-dsp.h +241 -0
- cyfaust/resources/architecture/faust/audio/samAudio.h +140 -0
- cyfaust/resources/architecture/faust/audio/teensy-dsp.h +171 -0
- cyfaust/resources/architecture/faust/dsp/cmajor-cpp-dsp.h +253 -0
- cyfaust/resources/architecture/faust/dsp/cmajorpatch-dsp.h +483 -0
- cyfaust/resources/architecture/faust/dsp/cpp-dsp-adapter.h +38 -0
- cyfaust/resources/architecture/faust/dsp/dsp-adapter.h +836 -0
- cyfaust/resources/architecture/faust/dsp/dsp-bench.h +611 -0
- cyfaust/resources/architecture/faust/dsp/dsp-checker.h +115 -0
- cyfaust/resources/architecture/faust/dsp/dsp-combiner.h +810 -0
- cyfaust/resources/architecture/faust/dsp/dsp-compute-adapter.h +159 -0
- cyfaust/resources/architecture/faust/dsp/dsp-multi.h +702 -0
- cyfaust/resources/architecture/faust/dsp/dsp-multifun.h +90 -0
- cyfaust/resources/architecture/faust/dsp/dsp-optimizer.h +511 -0
- cyfaust/resources/architecture/faust/dsp/dsp-tools.h +229 -0
- cyfaust/resources/architecture/faust/dsp/dsp.h +321 -0
- cyfaust/resources/architecture/faust/dsp/fastmath.cpp +301 -0
- cyfaust/resources/architecture/faust/dsp/faust-dynamic-engine.cpp +494 -0
- cyfaust/resources/architecture/faust/dsp/faust-dynamic-engine.h +386 -0
- cyfaust/resources/architecture/faust/dsp/faust-engine.h +75 -0
- cyfaust/resources/architecture/faust/dsp/faust-poly-engine.h +638 -0
- cyfaust/resources/architecture/faust/dsp/interpreter-dsp-c.h +288 -0
- cyfaust/resources/architecture/faust/dsp/interpreter-dsp.h +362 -0
- cyfaust/resources/architecture/faust/dsp/interpreter-machine-dsp.h +233 -0
- cyfaust/resources/architecture/faust/dsp/libfaust-box-c.h +817 -0
- cyfaust/resources/architecture/faust/dsp/libfaust-box.h +889 -0
- cyfaust/resources/architecture/faust/dsp/libfaust-c.h +116 -0
- cyfaust/resources/architecture/faust/dsp/libfaust-signal-c.h +649 -0
- cyfaust/resources/architecture/faust/dsp/libfaust-signal.h +731 -0
- cyfaust/resources/architecture/faust/dsp/llvm-dsp-adapter.h +160 -0
- cyfaust/resources/architecture/faust/dsp/llvm-dsp-c.h +524 -0
- cyfaust/resources/architecture/faust/dsp/llvm-dsp.h +575 -0
- cyfaust/resources/architecture/faust/dsp/llvm-machine-dsp.h +215 -0
- cyfaust/resources/architecture/faust/dsp/one-sample-dsp.h +477 -0
- cyfaust/resources/architecture/faust/dsp/poly-dsp.h +1079 -0
- cyfaust/resources/architecture/faust/dsp/poly-interpreter-dsp.h +143 -0
- cyfaust/resources/architecture/faust/dsp/poly-llvm-dsp.h +249 -0
- cyfaust/resources/architecture/faust/dsp/poly-wasm-dsp.h +257 -0
- cyfaust/resources/architecture/faust/dsp/proxy-dsp.h +108 -0
- cyfaust/resources/architecture/faust/dsp/proxy-osc-dsp.h +109 -0
- cyfaust/resources/architecture/faust/dsp/rnbo-dsp.h +187 -0
- cyfaust/resources/architecture/faust/dsp/sound-player.h +428 -0
- cyfaust/resources/architecture/faust/dsp/timed-dsp.h +279 -0
- cyfaust/resources/architecture/faust/dsp/wasm-dsp-imp.h +188 -0
- cyfaust/resources/architecture/faust/dsp/wasm-dsp.h +309 -0
- cyfaust/resources/architecture/faust/dsp/ysfx-dsp.h +188 -0
- cyfaust/resources/architecture/faust/export.h +61 -0
- cyfaust/resources/architecture/faust/gui/APIUI.h +726 -0
- cyfaust/resources/architecture/faust/gui/BelaOSCUI.h +170 -0
- cyfaust/resources/architecture/faust/gui/CGlue.h +667 -0
- cyfaust/resources/architecture/faust/gui/CInterface.h +142 -0
- cyfaust/resources/architecture/faust/gui/ControlSequenceUI.h +197 -0
- cyfaust/resources/architecture/faust/gui/ControlUI.h +137 -0
- cyfaust/resources/architecture/faust/gui/DaisyControlUI.h +283 -0
- cyfaust/resources/architecture/faust/gui/DaisyPatchInitControlUI.h +254 -0
- cyfaust/resources/architecture/faust/gui/DecoratorUI.h +115 -0
- cyfaust/resources/architecture/faust/gui/Esp32ControlUI.h +341 -0
- cyfaust/resources/architecture/faust/gui/Esp32Reader.h +102 -0
- cyfaust/resources/architecture/faust/gui/Esp32SensorUI.h +137 -0
- cyfaust/resources/architecture/faust/gui/FUI.h +147 -0
- cyfaust/resources/architecture/faust/gui/GTKUI.h +1414 -0
- cyfaust/resources/architecture/faust/gui/GUI.h +465 -0
- cyfaust/resources/architecture/faust/gui/JSONControl.h +48 -0
- cyfaust/resources/architecture/faust/gui/JSONUI.h +722 -0
- cyfaust/resources/architecture/faust/gui/JSONUIDecoder.h +589 -0
- cyfaust/resources/architecture/faust/gui/JuceGUI.h +2061 -0
- cyfaust/resources/architecture/faust/gui/JuceOSCUI.h +163 -0
- cyfaust/resources/architecture/faust/gui/JuceParameterUI.h +158 -0
- cyfaust/resources/architecture/faust/gui/JuceReader.h +103 -0
- cyfaust/resources/architecture/faust/gui/JuceStateUI.h +88 -0
- cyfaust/resources/architecture/faust/gui/LayoutUI.h +423 -0
- cyfaust/resources/architecture/faust/gui/LibsndfileReader.h +366 -0
- cyfaust/resources/architecture/faust/gui/MapUI.h +370 -0
- cyfaust/resources/architecture/faust/gui/MemoryReader.h +111 -0
- cyfaust/resources/architecture/faust/gui/MetaDataUI.h +357 -0
- cyfaust/resources/architecture/faust/gui/MidiUI.h +939 -0
- cyfaust/resources/architecture/faust/gui/OCVUI.h +688 -0
- cyfaust/resources/architecture/faust/gui/OSCUI.h +219 -0
- cyfaust/resources/architecture/faust/gui/PathBuilder.h +228 -0
- cyfaust/resources/architecture/faust/gui/PresetUI.h +337 -0
- cyfaust/resources/architecture/faust/gui/PrintCUI.h +152 -0
- cyfaust/resources/architecture/faust/gui/PrintUI.h +121 -0
- cyfaust/resources/architecture/faust/gui/QTUI.h +1891 -0
- cyfaust/resources/architecture/faust/gui/RosCI.h +493 -0
- cyfaust/resources/architecture/faust/gui/RosUI.h +488 -0
- cyfaust/resources/architecture/faust/gui/SaveUI.h +163 -0
- cyfaust/resources/architecture/faust/gui/SimpleParser.h +583 -0
- cyfaust/resources/architecture/faust/gui/SoundUI.h +217 -0
- cyfaust/resources/architecture/faust/gui/Soundfile.h +342 -0
- cyfaust/resources/architecture/faust/gui/Styles/Blue.qrc +5 -0
- cyfaust/resources/architecture/faust/gui/Styles/Blue.qss +177 -0
- cyfaust/resources/architecture/faust/gui/Styles/Default.qrc +5 -0
- cyfaust/resources/architecture/faust/gui/Styles/Default.qss +117 -0
- cyfaust/resources/architecture/faust/gui/Styles/Grey.qrc +5 -0
- cyfaust/resources/architecture/faust/gui/Styles/Grey.qss +174 -0
- cyfaust/resources/architecture/faust/gui/Styles/Salmon.qrc +5 -0
- cyfaust/resources/architecture/faust/gui/Styles/Salmon.qss +171 -0
- cyfaust/resources/architecture/faust/gui/UI.h +87 -0
- cyfaust/resources/architecture/faust/gui/ValueConverter.h +543 -0
- cyfaust/resources/architecture/faust/gui/WaveReader.h +364 -0
- cyfaust/resources/architecture/faust/gui/console.h +322 -0
- cyfaust/resources/architecture/faust/gui/httpdUI.h +372 -0
- cyfaust/resources/architecture/faust/gui/meta.h +39 -0
- cyfaust/resources/architecture/faust/gui/mspUI.h +580 -0
- cyfaust/resources/architecture/faust/gui/qrcodegen.h +269 -0
- cyfaust/resources/architecture/faust/gui/qrcodegen.impl.h +1025 -0
- cyfaust/resources/architecture/faust/gui/ring-buffer.h +414 -0
- cyfaust/resources/architecture/faust/midi/RtMidi.cpp +3054 -0
- cyfaust/resources/architecture/faust/midi/RtMidi.h +1034 -0
- cyfaust/resources/architecture/faust/midi/bela-midi.h +266 -0
- cyfaust/resources/architecture/faust/midi/daisy-midi.h +116 -0
- cyfaust/resources/architecture/faust/midi/esp32-midi.h +185 -0
- cyfaust/resources/architecture/faust/midi/gramophone-midi.h +107 -0
- cyfaust/resources/architecture/faust/midi/iplug2-midi.h +148 -0
- cyfaust/resources/architecture/faust/midi/jack-midi.h +247 -0
- cyfaust/resources/architecture/faust/midi/juce-midi.h +275 -0
- cyfaust/resources/architecture/faust/midi/midi.h +475 -0
- cyfaust/resources/architecture/faust/midi/rt-midi.h +315 -0
- cyfaust/resources/architecture/faust/midi/teensy-midi.h +89 -0
- cyfaust/resources/architecture/faust/misc.h +106 -0
- cyfaust/resources/architecture/faust/sound-file.h +132 -0
- cyfaust/resources/architecture/faust/unity/AudioPluginInterface.h +301 -0
- cyfaust/resources/architecture/faust/vst/faust.h +141 -0
- cyfaust/resources/architecture/faust/vst/voice.h +43 -0
- cyfaust/resources/architecture/faust/vst/vstui.h +524 -0
- cyfaust/resources/architecture/faustvst.cpp +3435 -0
- cyfaust/resources/architecture/faustvstqt.h +91 -0
- cyfaust/resources/architecture/gen-json.cpp +76 -0
- cyfaust/resources/architecture/jack-console.cpp +267 -0
- cyfaust/resources/architecture/jack-gtk-ros.cpp +139 -0
- cyfaust/resources/architecture/jack-gtk.cpp +282 -0
- cyfaust/resources/architecture/jack-internal.cpp +560 -0
- cyfaust/resources/architecture/jack-qt-chain-footer.cpp +87 -0
- cyfaust/resources/architecture/jack-qt-chain-header.cpp +92 -0
- cyfaust/resources/architecture/jack-qt.cpp +281 -0
- cyfaust/resources/architecture/jack.rs +171 -0
- cyfaust/resources/architecture/juce/README.md +84 -0
- cyfaust/resources/architecture/juce/juce-plugin.cpp +809 -0
- cyfaust/resources/architecture/juce/juce-standalone.cpp +413 -0
- cyfaust/resources/architecture/juce/plugin/plugin-llvm.jucer +184 -0
- cyfaust/resources/architecture/juce/plugin/plugin.jucer +159 -0
- cyfaust/resources/architecture/juce/standalone/standalone-llvm.jucer +216 -0
- cyfaust/resources/architecture/juce/standalone/standalone.jucer +191 -0
- cyfaust/resources/architecture/ladspa.cpp +543 -0
- cyfaust/resources/architecture/latexheader.tex +65 -0
- cyfaust/resources/architecture/lv2.cpp +2090 -0
- cyfaust/resources/architecture/lv2qtgui.h +62 -0
- cyfaust/resources/architecture/lv2ui.cpp +1966 -0
- cyfaust/resources/architecture/max-msp/README.md +109 -0
- cyfaust/resources/architecture/max-msp/faustgen-wrapper-poly.maxpat +184 -0
- cyfaust/resources/architecture/max-msp/faustgen-wrapper.maxpat +163 -0
- cyfaust/resources/architecture/max-msp/max-msp.cpp +734 -0
- cyfaust/resources/architecture/max-msp/max-msp64.cpp +789 -0
- cyfaust/resources/architecture/max-msp/py2max/README.md +277 -0
- cyfaust/resources/architecture/max-msp/py2max/py2max/__init__.py +3 -0
- cyfaust/resources/architecture/max-msp/py2max/py2max/common.py +7 -0
- cyfaust/resources/architecture/max-msp/py2max/py2max/core.py +1387 -0
- cyfaust/resources/architecture/max-msp/py2max/py2max/maxclassdb.py +318 -0
- cyfaust/resources/architecture/max-msp/py2max/py2max/utils.py +20 -0
- cyfaust/resources/architecture/max-msp/rnbo.py +1591 -0
- cyfaust/resources/architecture/max-msp/sndfile/sndfile.h +857 -0
- cyfaust/resources/architecture/max-msp/ui.js +230 -0
- cyfaust/resources/architecture/max-msp/wrapper-poly.maxpat +153 -0
- cyfaust/resources/architecture/max-msp/wrapper.maxpat +131 -0
- cyfaust/resources/architecture/minimal-bench.cpp +100 -0
- cyfaust/resources/architecture/minimal-effect.c +149 -0
- cyfaust/resources/architecture/minimal-effect.cpp +70 -0
- cyfaust/resources/architecture/minimal-fixed-point.cpp +195 -0
- cyfaust/resources/architecture/minimal-static.cpp +160 -0
- cyfaust/resources/architecture/minimal.c +103 -0
- cyfaust/resources/architecture/minimal.cpp +84 -0
- cyfaust/resources/architecture/minimal.rs +223 -0
- cyfaust/resources/architecture/module.cpp +91 -0
- cyfaust/resources/architecture/octave.cpp +471 -0
- cyfaust/resources/architecture/oscio-gtk.cpp +115 -0
- cyfaust/resources/architecture/oscio-qt.cpp +121 -0
- cyfaust/resources/architecture/owl.cpp +345 -0
- cyfaust/resources/architecture/pa-gtk.cpp +119 -0
- cyfaust/resources/architecture/pa-qt.cpp +261 -0
- cyfaust/resources/architecture/path-printer.cpp +100 -0
- cyfaust/resources/architecture/plot.cpp +128 -0
- cyfaust/resources/architecture/portaudio.rs +192 -0
- cyfaust/resources/architecture/puredata.cpp +636 -0
- cyfaust/resources/architecture/ra-qt.cpp +238 -0
- cyfaust/resources/architecture/sam/fast_pow2.h +69 -0
- cyfaust/resources/architecture/sam/fastexp.h +140 -0
- cyfaust/resources/architecture/sam/samFaustDSP.cpp +125 -0
- cyfaust/resources/architecture/sam/samFaustDSP.h +107 -0
- cyfaust/resources/architecture/scheduler.cpp +1391 -0
- cyfaust/resources/architecture/sndfile.cpp +291 -0
- cyfaust/resources/architecture/supercollider.cpp +611 -0
- cyfaust/resources/architecture/teensy/README.md +13 -0
- cyfaust/resources/architecture/teensy/teensy.cpp +214 -0
- cyfaust/resources/architecture/teensy/teensy.h +71 -0
- cyfaust/resources/architecture/thread.h +373 -0
- cyfaust/resources/architecture/vcvrack/README.md +78 -0
- cyfaust/resources/architecture/vcvrack/template/.gitignore +6 -0
- cyfaust/resources/architecture/vcvrack/template/Makefile +22 -0
- cyfaust/resources/architecture/vcvrack/template/res/FaustModule.svg +299 -0
- cyfaust/resources/architecture/vcvrack/template/src/FaustModule.cpp +942 -0
- cyfaust/resources/architecture/vst.cpp +947 -0
- cyfaust/resources/libraries/aanl.lib +900 -0
- cyfaust/resources/libraries/all.lib +36 -0
- cyfaust/resources/libraries/analyzers.lib +980 -0
- cyfaust/resources/libraries/basics.lib +2681 -0
- cyfaust/resources/libraries/compressors.lib +1341 -0
- cyfaust/resources/libraries/delays.lib +401 -0
- cyfaust/resources/libraries/demos.lib +1556 -0
- cyfaust/resources/libraries/dx7.lib +1036 -0
- cyfaust/resources/libraries/effect.lib +1645 -0
- cyfaust/resources/libraries/envelopes.lib +666 -0
- cyfaust/resources/libraries/examples/README.md +13 -0
- cyfaust/resources/libraries/examples/ambisonics/fourSourcesToOcto.dsp +20 -0
- cyfaust/resources/libraries/examples/ambisonics/oneSourceToStereo.dsp +12 -0
- cyfaust/resources/libraries/examples/analysis/FFT.dsp +26 -0
- cyfaust/resources/libraries/examples/analysis/dbmeter.dsp +19 -0
- cyfaust/resources/libraries/examples/analysis/spectralLevel.dsp +8 -0
- cyfaust/resources/libraries/examples/analysis/spectralTiltLab.dsp +20 -0
- cyfaust/resources/libraries/examples/analysis/vumeter.dsp +18 -0
- cyfaust/resources/libraries/examples/autodiff/delay/diff.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/delay/gt.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/gain/diff.dsp +7 -0
- cyfaust/resources/libraries/examples/autodiff/gain/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/gain_dc/diff.dsp +7 -0
- cyfaust/resources/libraries/examples/autodiff/gain_dc/gt.dsp +4 -0
- cyfaust/resources/libraries/examples/autodiff/gain_exp/diff.dsp +9 -0
- cyfaust/resources/libraries/examples/autodiff/gain_exp/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/gain_pow/diff.dsp +9 -0
- cyfaust/resources/libraries/examples/autodiff/gain_pow/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/gain_pow_trig/diff.dsp +12 -0
- cyfaust/resources/libraries/examples/autodiff/gain_pow_trig/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/gain_sq/diff.dsp +7 -0
- cyfaust/resources/libraries/examples/autodiff/gain_sq/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/mem/diff.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/mem/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/noise.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/noop.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/one_zero/diff.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/one_zero/gt.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/ramp.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/recursion/diff.dsp +2 -0
- cyfaust/resources/libraries/examples/autodiff/recursion/gt.dsp +1 -0
- cyfaust/resources/libraries/examples/autodiff/recursion/target.dsp +13 -0
- cyfaust/resources/libraries/examples/autodiff/tremolo/diff.dsp +14 -0
- cyfaust/resources/libraries/examples/autodiff/tremolo/diffable.lib +7 -0
- cyfaust/resources/libraries/examples/autodiff/tremolo/gt.dsp +11 -0
- cyfaust/resources/libraries/examples/delayEcho/echo.dsp +15 -0
- cyfaust/resources/libraries/examples/delayEcho/quadEcho.dsp +21 -0
- cyfaust/resources/libraries/examples/delayEcho/smoothDelay.dsp +26 -0
- cyfaust/resources/libraries/examples/delayEcho/stereoEcho.dsp +16 -0
- cyfaust/resources/libraries/examples/delayEcho/tapiir.dsp +44 -0
- cyfaust/resources/libraries/examples/dynamic/compressor.dsp +8 -0
- cyfaust/resources/libraries/examples/dynamic/distortion.dsp +8 -0
- cyfaust/resources/libraries/examples/dynamic/gateCompressor.dsp +10 -0
- cyfaust/resources/libraries/examples/dynamic/noiseGate.dsp +8 -0
- cyfaust/resources/libraries/examples/dynamic/volume.dsp +15 -0
- cyfaust/resources/libraries/examples/filtering/APF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/BPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/DNN.dsp +25 -0
- cyfaust/resources/libraries/examples/filtering/HPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/LPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/bandFilter.dsp +44 -0
- cyfaust/resources/libraries/examples/filtering/cryBaby.dsp +4 -0
- cyfaust/resources/libraries/examples/filtering/diodeLadder.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/filterBank.dsp +6 -0
- cyfaust/resources/libraries/examples/filtering/graphicEqLab.dsp +10 -0
- cyfaust/resources/libraries/examples/filtering/highShelf.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/korg35HPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/korg35LPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/lfBoost.dsp +40 -0
- cyfaust/resources/libraries/examples/filtering/lowBoost.dsp +40 -0
- cyfaust/resources/libraries/examples/filtering/lowCut.dsp +40 -0
- cyfaust/resources/libraries/examples/filtering/lowShelf.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/moogHalfLadder.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/moogLadder.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/moogVCF.dsp +6 -0
- cyfaust/resources/libraries/examples/filtering/multibandFilter.dsp +14 -0
- cyfaust/resources/libraries/examples/filtering/notch.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/oberheim.dsp +14 -0
- cyfaust/resources/libraries/examples/filtering/oberheimBPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/oberheimBSF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/oberheimHPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/oberheimLPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/parametricEqLab.dsp +10 -0
- cyfaust/resources/libraries/examples/filtering/parametricEqualizer.dsp +6 -0
- cyfaust/resources/libraries/examples/filtering/peakNotch.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/peakingEQ.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrder.dsp +14 -0
- cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderBPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderHPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/sallenKey2ndOrderLPF.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/sallenKeyOnePole.dsp +13 -0
- cyfaust/resources/libraries/examples/filtering/sallenKeyOnePoleHPF.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/sallenKeyOnePoleLPF.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/spectralTilt.dsp +8 -0
- cyfaust/resources/libraries/examples/filtering/vcfWahLab.dsp +12 -0
- cyfaust/resources/libraries/examples/filtering/vocoder.dsp +8 -0
- cyfaust/resources/libraries/examples/filtering/wahPedal.dsp +6 -0
- cyfaust/resources/libraries/examples/gameaudio/bubble.dsp +42 -0
- cyfaust/resources/libraries/examples/gameaudio/door.dsp +58 -0
- cyfaust/resources/libraries/examples/gameaudio/fire.dsp +46 -0
- cyfaust/resources/libraries/examples/gameaudio/insects.dsp +148 -0
- cyfaust/resources/libraries/examples/gameaudio/rain.dsp +27 -0
- cyfaust/resources/libraries/examples/gameaudio/wind.dsp +23 -0
- cyfaust/resources/libraries/examples/generator/filterOsc.dsp +8 -0
- cyfaust/resources/libraries/examples/generator/noise.dsp +52 -0
- cyfaust/resources/libraries/examples/generator/noiseMetadata.dsp +74 -0
- cyfaust/resources/libraries/examples/generator/osc.dsp +17 -0
- cyfaust/resources/libraries/examples/generator/osci.dsp +17 -0
- cyfaust/resources/libraries/examples/generator/sawtoothLab.dsp +8 -0
- cyfaust/resources/libraries/examples/generator/virtualAnalog.dsp +8 -0
- cyfaust/resources/libraries/examples/generator/virtualAnalogLab.dsp +10 -0
- cyfaust/resources/libraries/examples/misc/UITester.dsp +71 -0
- cyfaust/resources/libraries/examples/misc/autopan.dsp +59 -0
- cyfaust/resources/libraries/examples/misc/capture.dsp +24 -0
- cyfaust/resources/libraries/examples/misc/drumkit.dsp +36 -0
- cyfaust/resources/libraries/examples/misc/guitarix.dsp +184 -0
- cyfaust/resources/libraries/examples/misc/matrix.dsp +17 -0
- cyfaust/resources/libraries/examples/misc/midiTester.dsp +122 -0
- cyfaust/resources/libraries/examples/misc/mixer.dsp +27 -0
- cyfaust/resources/libraries/examples/misc/statespace.dsp +39 -0
- cyfaust/resources/libraries/examples/misc/switcher.dsp +20 -0
- cyfaust/resources/libraries/examples/misc/tester.dsp +32 -0
- cyfaust/resources/libraries/examples/misc/tester2.dsp +31 -0
- cyfaust/resources/libraries/examples/old/README.md +5 -0
- cyfaust/resources/libraries/examples/old/freeverb.dsp +109 -0
- cyfaust/resources/libraries/examples/old/rewriting/Makefile +21 -0
- cyfaust/resources/libraries/examples/old/rewriting/fact.dsp +3 -0
- cyfaust/resources/libraries/examples/old/rewriting/fold.dsp +61 -0
- cyfaust/resources/libraries/examples/old/rewriting/mesh.dsp +43 -0
- cyfaust/resources/libraries/examples/old/rewriting/mesh.pd +37 -0
- cyfaust/resources/libraries/examples/old/rewriting/sample.pd +12 -0
- cyfaust/resources/libraries/examples/old/rewriting/serial.dsp +7 -0
- cyfaust/resources/libraries/examples/old/rewriting/sum.dsp +55 -0
- cyfaust/resources/libraries/examples/old/rewriting/test.pd +48 -0
- cyfaust/resources/libraries/examples/phasing/flanger.dsp +8 -0
- cyfaust/resources/libraries/examples/phasing/phaser.dsp +8 -0
- cyfaust/resources/libraries/examples/phasing/phaserFlangerLab.dsp +12 -0
- cyfaust/resources/libraries/examples/physicalModeling/brass.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/brassMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/churchBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/clarinet.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/clarinetMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/djembeMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/elecGuitarMIDI.dsp +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/englishBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/NLFeks.dsp +91 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/NLFfm.dsp +70 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/README +125 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bass.dsp +84 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bass.h +91 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/blowBottle.dsp +102 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/bowed.dsp +114 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/brass.dsp +103 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/clarinet.dsp +110 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/flute.dsp +116 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/fluteStk.dsp +121 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/glassHarmonica.dsp +131 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/harpsi.dsp +90 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/harpsichord.h +185 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/instrument.h +114 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/modalBar.dsp +122 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/modalBar.h +48 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/bottle.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/clarinets.pd +15 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/bass.pd +162 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/canon.pd +55 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/flute.pd +343 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/canon/pachelbel.mid +0 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/daisy.mid +0 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/daisy.pd +45 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/piano.pd +205 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/daisy/voiceForm.pd +340 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/blowHole.pd +330 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/piano.pd +205 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/take5.mid +0 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/take5/take5.pd +45 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/harpsi.pd +204 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/turkish-march.mid +0 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/turkish-march/turkish-march.pd +31 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/audio-out.pd +33 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/bass.pd +162 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/modalBar.pd +258 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/piano.pd +205 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/what-a-friend.pd +52 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fancy/what-a-friend/what_a_friend.mid +0 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/flutes.pd +15 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/fm.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/glassBare.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/harpsichord-poly.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/ironBare.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/midi-in.pd +111 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/modal.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/osc.pd +26 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/piano-poly.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/plucked.pd +20 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/saxophone.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/tibetan.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/trumpet.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/violin.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/voiceSynth.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/pd-patches/woodenBare.pd +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/phonemes.h +189 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/piano.dsp +255 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/piano.h +751 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/saxophony.dsp +114 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/sitar.dsp +48 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/tibetanBowl.dsp +155 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/tunedBar.dsp +123 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/uniBar.dsp +100 -0
- cyfaust/resources/libraries/examples/physicalModeling/faust-stk/voiceForm.dsp +125 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/1dDampedWaveEquation.dsp +43 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/2dKirchhoffThinPlate.dsp +75 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/BowedString.dsp +61 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/ControllableNonPhysicalString.dsp +72 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/HammeredString.dsp +74 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/PianoHammeredString.dsp +85 -0
- cyfaust/resources/libraries/examples/physicalModeling/fds/StiffString.dsp +54 -0
- cyfaust/resources/libraries/examples/physicalModeling/flute.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/fluteMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/frenchBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/germanBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/guitarMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/karplus.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/marimbaMIDI.dsp +10 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator.dsp +58 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator2.dsp +62 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator3.dsp +65 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/01_ParamControl/paramOsc.dsp +63 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/02_AudioParamControl/audioParamOsc.dsp +63 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/03_HammerTime/hammerOsc.dsp +71 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/04_Gravity/bouncingOsc.dsp +64 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/05_PluckedOscillator/pluckedOsc.dsp +57 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/06_BowedOscillator/bowedOsc.dsp +65 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/07_NonLinearOscillator/nlOsc.dsp +78 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/08_TwoMassChain/2massChain.dsp +75 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/09_TinyString/tinyString.dsp +101 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/10_PluckedString/pluckedString.dsp +678 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/11_BowedString/bowedString.dsp +671 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/12_TriangleMesh/triangleMesh.dsp +448 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/13_Construction/construction.dsp +1036 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/14_Polyphonic/polyTriangle.dsp +79 -0
- cyfaust/resources/libraries/examples/physicalModeling/mi-faust/15_PhysicalLFO/physicalLFO.dsp +107 -0
- cyfaust/resources/libraries/examples/physicalModeling/modularInterpInstrMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/nylonGuitarMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/old/harpe.dsp +45 -0
- cyfaust/resources/libraries/examples/physicalModeling/old/karplus.dsp +34 -0
- cyfaust/resources/libraries/examples/physicalModeling/old/karplus32.dsp +47 -0
- cyfaust/resources/libraries/examples/physicalModeling/russianBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/standardBell.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/violin.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/violinMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/vocalBP.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/vocalBPMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/vocalFOF.dsp +8 -0
- cyfaust/resources/libraries/examples/physicalModeling/vocalFOFMIDI.dsp +8 -0
- cyfaust/resources/libraries/examples/pitchShifting/pitchShifter.dsp +20 -0
- cyfaust/resources/libraries/examples/psychoacoustic/harmonicExciter.dsp +10 -0
- cyfaust/resources/libraries/examples/quantizing/quantizedChords.dsp +49 -0
- cyfaust/resources/libraries/examples/reverb/dattorro.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/fdnRev.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/freeverb.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/greyhole.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/jprev.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/reverbDesigner.dsp +12 -0
- cyfaust/resources/libraries/examples/reverb/reverbTester.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/zitaRev.dsp +8 -0
- cyfaust/resources/libraries/examples/reverb/zitaRevFDN.dsp +8 -0
- cyfaust/resources/libraries/examples/smartKeyboard/acGuitar.dsp +100 -0
- cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/elecGuitarEffect.dsp +8 -0
- cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/myEffect.dsp +5 -0
- cyfaust/resources/libraries/examples/smartKeyboard/associatedEffects/reverb.dsp +5 -0
- cyfaust/resources/libraries/examples/smartKeyboard/bells.dsp +80 -0
- cyfaust/resources/libraries/examples/smartKeyboard/bowed.dsp +87 -0
- cyfaust/resources/libraries/examples/smartKeyboard/brass.dsp +82 -0
- cyfaust/resources/libraries/examples/smartKeyboard/clarinet.dsp +113 -0
- cyfaust/resources/libraries/examples/smartKeyboard/crazyGuiro.dsp +96 -0
- cyfaust/resources/libraries/examples/smartKeyboard/drums.dsp +74 -0
- cyfaust/resources/libraries/examples/smartKeyboard/dubDub.dsp +87 -0
- cyfaust/resources/libraries/examples/smartKeyboard/elecGuitar.dsp +67 -0
- cyfaust/resources/libraries/examples/smartKeyboard/fm.dsp +78 -0
- cyfaust/resources/libraries/examples/smartKeyboard/frog.dsp +74 -0
- cyfaust/resources/libraries/examples/smartKeyboard/harp.dsp +84 -0
- cyfaust/resources/libraries/examples/smartKeyboard/midiOnly.dsp +62 -0
- cyfaust/resources/libraries/examples/smartKeyboard/multiSynth.dsp +75 -0
- cyfaust/resources/libraries/examples/smartKeyboard/toy.dsp +71 -0
- cyfaust/resources/libraries/examples/smartKeyboard/trumpet.dsp +59 -0
- cyfaust/resources/libraries/examples/smartKeyboard/turenas.dsp +114 -0
- cyfaust/resources/libraries/examples/smartKeyboard/violin.dsp +91 -0
- cyfaust/resources/libraries/examples/smartKeyboard/violin2.dsp +84 -0
- cyfaust/resources/libraries/examples/smartKeyboard/vocal.dsp +43 -0
- cyfaust/resources/libraries/examples/spat/panpot.dsp +17 -0
- cyfaust/resources/libraries/examples/spat/spat.dsp +25 -0
- cyfaust/resources/libraries/fds.lib +535 -0
- cyfaust/resources/libraries/filter.lib +1710 -0
- cyfaust/resources/libraries/filters.lib +3125 -0
- cyfaust/resources/libraries/hoa.lib +1081 -0
- cyfaust/resources/libraries/instruments.lib +263 -0
- cyfaust/resources/libraries/interpolators.lib +675 -0
- cyfaust/resources/libraries/math.lib +602 -0
- cyfaust/resources/libraries/maths.lib +798 -0
- cyfaust/resources/libraries/maxmsp.lib +237 -0
- cyfaust/resources/libraries/mi.lib +528 -0
- cyfaust/resources/libraries/misceffects.lib +998 -0
- cyfaust/resources/libraries/music.lib +496 -0
- cyfaust/resources/libraries/noises.lib +487 -0
- cyfaust/resources/libraries/oscillator.lib +450 -0
- cyfaust/resources/libraries/oscillators.lib +1838 -0
- cyfaust/resources/libraries/phaflangers.lib +235 -0
- cyfaust/resources/libraries/physmodels.lib +3990 -0
- cyfaust/resources/libraries/platform.lib +59 -0
- cyfaust/resources/libraries/quantizers.lib +310 -0
- cyfaust/resources/libraries/reducemaps.lib +235 -0
- cyfaust/resources/libraries/reverbs.lib +686 -0
- cyfaust/resources/libraries/routes.lib +262 -0
- cyfaust/resources/libraries/sf.lib +53 -0
- cyfaust/resources/libraries/signals.lib +570 -0
- cyfaust/resources/libraries/soundfiles.lib +234 -0
- cyfaust/resources/libraries/spats.lib +173 -0
- cyfaust/resources/libraries/stdfaust.lib +38 -0
- cyfaust/resources/libraries/synths.lib +322 -0
- cyfaust/resources/libraries/tonestacks.lib +427 -0
- cyfaust/resources/libraries/tubes.lib +5039 -0
- cyfaust/resources/libraries/vaeffects.lib +984 -0
- cyfaust/resources/libraries/version.lib +22 -0
- cyfaust/resources/libraries/wdmodels.lib +2276 -0
- cyfaust/resources/libraries/webaudio.lib +402 -0
- cyfaust/signal.pxd +44 -0
- cyfaust/signal.pyx +1993 -0
- cyfaust-0.1.0.dist-info/METADATA +355 -0
- cyfaust-0.1.0.dist-info/RECORD +693 -0
- cyfaust-0.1.0.dist-info/WHEEL +5 -0
- cyfaust-0.1.0.dist-info/entry_points.txt +3 -0
- cyfaust-0.1.0.dist-info/licenses/LICENSE +26 -0
|
@@ -0,0 +1,1543 @@
|
|
|
1
|
+
/************************** BEGIN coreaudio-dsp.h *************************
|
|
2
|
+
FAUST Architecture File
|
|
3
|
+
Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
|
|
4
|
+
---------------------------------------------------------------------
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2.1 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Lesser General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
18
|
+
|
|
19
|
+
EXCEPTION : As a special exception, you may create a larger work
|
|
20
|
+
that contains this FAUST architecture section and distribute
|
|
21
|
+
that work under terms of your choice, so long as this FAUST
|
|
22
|
+
architecture section is not modified.
|
|
23
|
+
************************************************************************/
|
|
24
|
+
|
|
25
|
+
#ifndef __coreaudio_dsp__
|
|
26
|
+
#define __coreaudio_dsp__
|
|
27
|
+
|
|
28
|
+
#include <math.h>
|
|
29
|
+
#include <stdlib.h>
|
|
30
|
+
#include <stdio.h>
|
|
31
|
+
#include <vector>
|
|
32
|
+
#include <iostream>
|
|
33
|
+
#include <sys/time.h>
|
|
34
|
+
|
|
35
|
+
#include <AudioToolbox/AudioConverter.h>
|
|
36
|
+
#include <CoreAudio/CoreAudio.h>
|
|
37
|
+
#include <AudioUnit/AudioUnit.h>
|
|
38
|
+
#include <CoreServices/CoreServices.h>
|
|
39
|
+
|
|
40
|
+
#include "faust/audio/audio.h"
|
|
41
|
+
#ifdef HAS_MATH_EXCEPTION
|
|
42
|
+
#include "faust/audio/fpe.h"
|
|
43
|
+
#endif
|
|
44
|
+
#include "faust/dsp/dsp.h"
|
|
45
|
+
|
|
46
|
+
/******************************************************************************
|
|
47
|
+
*******************************************************************************
|
|
48
|
+
|
|
49
|
+
COREAUDIO INTERNAL INTERFACE
|
|
50
|
+
|
|
51
|
+
*******************************************************************************
|
|
52
|
+
*******************************************************************************/
|
|
53
|
+
|
|
54
|
+
#define OPEN_ERR -1
|
|
55
|
+
#define CLOSE_ERR -1
|
|
56
|
+
#define NO_ERR 0
|
|
57
|
+
|
|
58
|
+
#define WAIT_NOTIFICATION_COUNTER 60
|
|
59
|
+
|
|
60
|
+
typedef UInt8 CAAudioHardwareDeviceSectionID;
|
|
61
|
+
#define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01)
|
|
62
|
+
#define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00)
|
|
63
|
+
#define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00)
|
|
64
|
+
#define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF)
|
|
65
|
+
|
|
66
|
+
class TCoreAudioRenderer;
|
|
67
|
+
typedef TCoreAudioRenderer* TCoreAudioRendererPtr;
|
|
68
|
+
|
|
69
|
+
static void PrintStreamDesc(AudioStreamBasicDescription *inDesc)
|
|
70
|
+
{
|
|
71
|
+
printf("- - - - - - - - - - - - - - - - - - - -\n");
|
|
72
|
+
printf(" Sample Rate:%f\n", inDesc->mSampleRate);
|
|
73
|
+
printf(" Format ID:%.*s\n", (int)sizeof(inDesc->mFormatID), (char*)&inDesc->mFormatID);
|
|
74
|
+
printf(" Format Flags:%lX\n", (unsigned long)inDesc->mFormatFlags);
|
|
75
|
+
printf(" Bytes per Packet:%ld\n", (long)inDesc->mBytesPerPacket);
|
|
76
|
+
printf(" Frames per Packet:%ld\n", (long)inDesc->mFramesPerPacket);
|
|
77
|
+
printf(" Bytes per Frame:%ld\n", (long)inDesc->mBytesPerFrame);
|
|
78
|
+
printf(" Channels per Frame:%ld\n", (long)inDesc->mChannelsPerFrame);
|
|
79
|
+
printf(" Bits per Channel:%ld\n", (long)inDesc->mBitsPerChannel);
|
|
80
|
+
printf("- - - - - - - - - - - - - - - - - - - -\n");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static void printError(OSStatus err)
|
|
84
|
+
{
|
|
85
|
+
switch (err) {
|
|
86
|
+
case kAudioHardwareNoError:
|
|
87
|
+
printf("error code : kAudioHardwareNoError\n");
|
|
88
|
+
break;
|
|
89
|
+
case kAudioConverterErr_FormatNotSupported:
|
|
90
|
+
printf("error code : kAudioConverterErr_FormatNotSupported\n");
|
|
91
|
+
break;
|
|
92
|
+
case kAudioConverterErr_OperationNotSupported:
|
|
93
|
+
printf("error code : kAudioConverterErr_OperationNotSupported\n");
|
|
94
|
+
break;
|
|
95
|
+
case kAudioConverterErr_PropertyNotSupported:
|
|
96
|
+
printf("error code : kAudioConverterErr_PropertyNotSupported\n");
|
|
97
|
+
break;
|
|
98
|
+
case kAudioConverterErr_InvalidInputSize:
|
|
99
|
+
printf("error code : kAudioConverterErr_InvalidInputSize\n");
|
|
100
|
+
break;
|
|
101
|
+
case kAudioConverterErr_InvalidOutputSize:
|
|
102
|
+
printf("error code : kAudioConverterErr_InvalidOutputSize\n");
|
|
103
|
+
break;
|
|
104
|
+
case kAudioConverterErr_UnspecifiedError:
|
|
105
|
+
printf("error code : kAudioConverterErr_UnspecifiedError\n");
|
|
106
|
+
break;
|
|
107
|
+
case kAudioConverterErr_BadPropertySizeError:
|
|
108
|
+
printf("error code : kAudioConverterErr_BadPropertySizeError\n");
|
|
109
|
+
break;
|
|
110
|
+
case kAudioConverterErr_RequiresPacketDescriptionsError:
|
|
111
|
+
printf("error code : kAudioConverterErr_RequiresPacketDescriptionsError\n");
|
|
112
|
+
break;
|
|
113
|
+
case kAudioConverterErr_InputSampleRateOutOfRange:
|
|
114
|
+
printf("error code : kAudioConverterErr_InputSampleRateOutOfRange\n");
|
|
115
|
+
break;
|
|
116
|
+
case kAudioConverterErr_OutputSampleRateOutOfRange:
|
|
117
|
+
printf("error code : kAudioConverterErr_OutputSampleRateOutOfRange\n");
|
|
118
|
+
break;
|
|
119
|
+
case kAudioHardwareNotRunningError:
|
|
120
|
+
printf("error code : kAudioHardwareNotRunningError\n");
|
|
121
|
+
break;
|
|
122
|
+
case kAudioHardwareUnknownPropertyError:
|
|
123
|
+
printf("error code : kAudioHardwareUnknownPropertyError\n");
|
|
124
|
+
break;
|
|
125
|
+
case kAudioHardwareIllegalOperationError:
|
|
126
|
+
printf("error code : kAudioHardwareIllegalOperationError\n");
|
|
127
|
+
break;
|
|
128
|
+
case kAudioHardwareBadDeviceError:
|
|
129
|
+
printf("error code : kAudioHardwareBadDeviceError\n");
|
|
130
|
+
break;
|
|
131
|
+
case kAudioHardwareBadStreamError:
|
|
132
|
+
printf("error code : kAudioHardwareBadStreamError\n");
|
|
133
|
+
break;
|
|
134
|
+
case kAudioDeviceUnsupportedFormatError:
|
|
135
|
+
printf("error code : kAudioDeviceUnsupportedFormatError\n");
|
|
136
|
+
break;
|
|
137
|
+
case kAudioDevicePermissionsError:
|
|
138
|
+
printf("error code : kAudioDevicePermissionsError\n");
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
printf("error code : err = %d\n", err);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static Float64 GetNominalSampleRate(AudioDeviceID inDevice)
|
|
147
|
+
{
|
|
148
|
+
Float64 sampleRate = 0;
|
|
149
|
+
UInt32 outSize = sizeof(Float64);
|
|
150
|
+
OSStatus err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
|
|
151
|
+
if (err != noErr) {
|
|
152
|
+
printf("Cannot get current sample rate\n");
|
|
153
|
+
printError(err);
|
|
154
|
+
return -1;
|
|
155
|
+
} else {
|
|
156
|
+
return sampleRate;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static CFStringRef GetDeviceName(AudioDeviceID id)
|
|
161
|
+
{
|
|
162
|
+
UInt32 size = sizeof(CFStringRef);
|
|
163
|
+
CFStringRef UIname;
|
|
164
|
+
OSStatus err = AudioDeviceGetProperty(id, 0, false, kAudioDevicePropertyDeviceUID, &size, &UIname);
|
|
165
|
+
return (err == noErr) ? UIname : NULL;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static bool CheckAvailableDeviceName(const char* device_name, AudioDeviceID* device_id, int len = -1)
|
|
169
|
+
{
|
|
170
|
+
UInt32 size;
|
|
171
|
+
Boolean isWritable;
|
|
172
|
+
int i, deviceNum;
|
|
173
|
+
OSStatus err;
|
|
174
|
+
|
|
175
|
+
err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, &isWritable);
|
|
176
|
+
if (err != noErr) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
deviceNum = size / sizeof(AudioDeviceID);
|
|
181
|
+
AudioDeviceID devices[deviceNum];
|
|
182
|
+
|
|
183
|
+
err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, devices);
|
|
184
|
+
if (err != noErr) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
for (i = 0; i < deviceNum; i++) {
|
|
189
|
+
char device_name_aux[256];
|
|
190
|
+
|
|
191
|
+
size = 256;
|
|
192
|
+
err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceName, &size, device_name_aux);
|
|
193
|
+
if (err != noErr) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (strncmp(device_name_aux, device_name, (len == -1) ? strlen(device_name) : len) == 0) {
|
|
198
|
+
*device_id = devices[i];
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
class TCoreAudioRenderer
|
|
207
|
+
{
|
|
208
|
+
|
|
209
|
+
protected:
|
|
210
|
+
|
|
211
|
+
AudioDeviceID fAggregateDeviceID;
|
|
212
|
+
AudioObjectID fAggregatePluginID; // Used for aggregate device
|
|
213
|
+
|
|
214
|
+
int fDevNumInChans;
|
|
215
|
+
int fDevNumOutChans;
|
|
216
|
+
|
|
217
|
+
int fPhysicalInputs;
|
|
218
|
+
int fPhysicalOutputs;
|
|
219
|
+
|
|
220
|
+
float** fInChannel;
|
|
221
|
+
float** fOutChannel;
|
|
222
|
+
|
|
223
|
+
int fBufferSize;
|
|
224
|
+
int fSampleRate;
|
|
225
|
+
|
|
226
|
+
bool fIsInJackDevice;
|
|
227
|
+
bool fIsOutJackDevice;
|
|
228
|
+
|
|
229
|
+
dsp* fDSP;
|
|
230
|
+
|
|
231
|
+
audio* fAudio;
|
|
232
|
+
|
|
233
|
+
AudioBufferList* fInputData;
|
|
234
|
+
AudioDeviceID fDeviceID;
|
|
235
|
+
AudioUnit fAUHAL;
|
|
236
|
+
bool fState;
|
|
237
|
+
|
|
238
|
+
OSStatus GetDefaultDeviceAndSampleRate(int inChan, int outChan, int& sample_rate, int& outChannelOffset, AudioDeviceID* device)
|
|
239
|
+
{
|
|
240
|
+
|
|
241
|
+
UInt32 theSize = sizeof(UInt32);
|
|
242
|
+
AudioDeviceID inDefault;
|
|
243
|
+
AudioDeviceID outDefault;
|
|
244
|
+
OSStatus res;
|
|
245
|
+
|
|
246
|
+
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
|
|
247
|
+
&theSize, &inDefault)) != noErr) {
|
|
248
|
+
return res;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
|
|
252
|
+
&theSize, &outDefault)) != noErr) {
|
|
253
|
+
return res;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/*
|
|
257
|
+
// TODO
|
|
258
|
+
if (inDefault == 0) {
|
|
259
|
+
printf("Error default input device is 0, will take 'Built-in'...\n");
|
|
260
|
+
if (CheckAvailableDeviceName("Built-in Microphone", &inDefault)
|
|
261
|
+
|| CheckAvailableDeviceName("Built-in Line", &inDefault)) {
|
|
262
|
+
printf("GetDefaultInputDevice : output = %ld\n", inDefault);
|
|
263
|
+
} else {
|
|
264
|
+
printf("Cannot find any input device to use...");
|
|
265
|
+
return -1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (outDefault == 0) {
|
|
270
|
+
printf("Error default ouput device is 0, will take 'Built-in'...\n");
|
|
271
|
+
if (CheckAvailableDeviceName("Built-in Output", &outDefault)) {
|
|
272
|
+
printf("GetDefaultOutputDevice : output = %ld\n", outDefault);
|
|
273
|
+
} else {
|
|
274
|
+
printf("Cannot find any output device to use...\n");
|
|
275
|
+
return -1;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
//printf("GetDefaultDevice : input = %d output = %d\n", inDefault, outDefault);
|
|
281
|
+
|
|
282
|
+
// Duplex mode
|
|
283
|
+
if (inChan > 0 && outChan > 0) {
|
|
284
|
+
// Get the device only if default input and output are the same
|
|
285
|
+
if (inDefault == outDefault) {
|
|
286
|
+
*device = inDefault;
|
|
287
|
+
goto end;
|
|
288
|
+
} else {
|
|
289
|
+
if (CreateAggregateDevice(inDefault, outDefault, sample_rate, outChannelOffset) != noErr) {
|
|
290
|
+
return kAudioHardwareBadDeviceError;
|
|
291
|
+
}
|
|
292
|
+
//printf("fAggregateDeviceID %d\n", fAggregateDeviceID);
|
|
293
|
+
*device = fAggregateDeviceID;
|
|
294
|
+
goto end;
|
|
295
|
+
}
|
|
296
|
+
} else if (inChan > 0) {
|
|
297
|
+
*device = inDefault;
|
|
298
|
+
goto end;
|
|
299
|
+
} else if (outChan > 0) {
|
|
300
|
+
*device = outDefault;
|
|
301
|
+
goto end;
|
|
302
|
+
} else {
|
|
303
|
+
return kAudioHardwareBadDeviceError;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
end:
|
|
307
|
+
|
|
308
|
+
if (sample_rate == -1) {
|
|
309
|
+
// Possible take the current sample rate
|
|
310
|
+
sample_rate = int(GetNominalSampleRate(*device));
|
|
311
|
+
} else {
|
|
312
|
+
// Otherwise force the one we want...
|
|
313
|
+
SetupSampleRateAux(*device, sample_rate);
|
|
314
|
+
}
|
|
315
|
+
//printf("samplerate %d\n", sample_rate);
|
|
316
|
+
fSampleRate = sample_rate;
|
|
317
|
+
return noErr;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
OSStatus CreateAggregateDevice(AudioDeviceID captureDeviceID, AudioDeviceID playbackDeviceID, int& sample_rate, int& outChannelOffset)
|
|
321
|
+
{
|
|
322
|
+
OSStatus err = noErr;
|
|
323
|
+
AudioObjectID sub_device[32];
|
|
324
|
+
UInt32 outSize = sizeof(sub_device);
|
|
325
|
+
|
|
326
|
+
//printf("CreateAggregateDevice : input device %d\n", captureDeviceID);
|
|
327
|
+
|
|
328
|
+
err = AudioDeviceGetProperty(captureDeviceID, 0, kAudioDeviceSectionGlobal, kAudioAggregateDevicePropertyActiveSubDeviceList, &outSize, sub_device);
|
|
329
|
+
std::vector<AudioDeviceID> captureDeviceIDArray;
|
|
330
|
+
|
|
331
|
+
if (err != noErr) {
|
|
332
|
+
//printf("Input device does not have subdevices\n");
|
|
333
|
+
captureDeviceIDArray.push_back(captureDeviceID);
|
|
334
|
+
} else {
|
|
335
|
+
int num_devices = outSize / sizeof(AudioObjectID);
|
|
336
|
+
//printf("Input device has %d subdevices\n", num_devices);
|
|
337
|
+
for (int i = 0; i < num_devices; i++) {
|
|
338
|
+
//printf("Input sub_device %d\n", sub_device[i]);
|
|
339
|
+
captureDeviceIDArray.push_back(sub_device[i]);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
outSize = sizeof(sub_device);
|
|
344
|
+
err = AudioDeviceGetProperty(playbackDeviceID, 0, kAudioDeviceSectionGlobal, kAudioAggregateDevicePropertyActiveSubDeviceList, &outSize, sub_device);
|
|
345
|
+
std::vector<AudioDeviceID> playbackDeviceIDArray;
|
|
346
|
+
|
|
347
|
+
if (err != noErr) {
|
|
348
|
+
//printf("Output device does not have subdevices\n");
|
|
349
|
+
playbackDeviceIDArray.push_back(playbackDeviceID);
|
|
350
|
+
} else {
|
|
351
|
+
int num_devices = outSize / sizeof(AudioObjectID);
|
|
352
|
+
//printf("Output device has %d subdevices\n", num_devices);
|
|
353
|
+
for (int i = 0; i < num_devices; i++) {
|
|
354
|
+
//printf("Output sub_device %d\n", sub_device[i]);
|
|
355
|
+
playbackDeviceIDArray.push_back(sub_device[i]);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return CreateAggregateDeviceAux(captureDeviceIDArray, playbackDeviceIDArray, sample_rate, outChannelOffset);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
OSStatus CreateAggregateDeviceAux(std::vector<AudioDeviceID> captureDeviceID, std::vector<AudioDeviceID> playbackDeviceID, int& sample_rate, int& outChannelOffset)
|
|
363
|
+
{
|
|
364
|
+
OSStatus osErr = noErr;
|
|
365
|
+
UInt32 outSize;
|
|
366
|
+
Boolean outWritable;
|
|
367
|
+
bool fClockDriftCompensate = true;
|
|
368
|
+
|
|
369
|
+
// Prepare sub-devices for clock drift compensation
|
|
370
|
+
// Workaround for bug in the HAL : until 10.6.2
|
|
371
|
+
AudioObjectPropertyAddress theAddressOwned = { kAudioObjectPropertyOwnedObjects, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
372
|
+
AudioObjectPropertyAddress theAddressDrift = { kAudioSubDevicePropertyDriftCompensation, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
373
|
+
UInt32 theQualifierDataSize = sizeof(AudioObjectID);
|
|
374
|
+
AudioClassID inClass = kAudioSubDeviceClassID;
|
|
375
|
+
void* theQualifierData = &inClass;
|
|
376
|
+
UInt32 subDevicesNum = 0;
|
|
377
|
+
|
|
378
|
+
//---------------------------------------------------------------------------
|
|
379
|
+
// Setup SR of both devices otherwise creating AD may fail...
|
|
380
|
+
//---------------------------------------------------------------------------
|
|
381
|
+
UInt32 keptclockdomain = 0;
|
|
382
|
+
UInt32 clockdomain = 0;
|
|
383
|
+
outSize = sizeof(UInt32);
|
|
384
|
+
bool need_clock_drift_compensation = false;
|
|
385
|
+
|
|
386
|
+
for (UInt32 i = 0; i < captureDeviceID.size(); i++) {
|
|
387
|
+
if (SetupSampleRateAux(captureDeviceID[i], sample_rate) < 0) {
|
|
388
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : cannot set SR of input device\n");
|
|
389
|
+
} else {
|
|
390
|
+
// Check clock domain
|
|
391
|
+
osErr = AudioDeviceGetProperty(captureDeviceID[i], 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyClockDomain, &outSize, &clockdomain);
|
|
392
|
+
if (osErr != 0) {
|
|
393
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : kAudioDevicePropertyClockDomain error\n");
|
|
394
|
+
printError(osErr);
|
|
395
|
+
} else {
|
|
396
|
+
keptclockdomain = (keptclockdomain == 0) ? clockdomain : keptclockdomain;
|
|
397
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : input clockdomain = %d\n", clockdomain);
|
|
398
|
+
if (clockdomain != 0 && clockdomain != keptclockdomain) {
|
|
399
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : devices do not share the same clock!! clock drift compensation would be needed...\n");
|
|
400
|
+
need_clock_drift_compensation = true;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
for (UInt32 i = 0; i < playbackDeviceID.size(); i++) {
|
|
407
|
+
if (SetupSampleRateAux(playbackDeviceID[i], sample_rate) < 0) {
|
|
408
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : cannot set SR of output device\n");
|
|
409
|
+
} else {
|
|
410
|
+
// Check clock domain
|
|
411
|
+
osErr = AudioDeviceGetProperty(playbackDeviceID[i], 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyClockDomain, &outSize, &clockdomain);
|
|
412
|
+
if (osErr != 0) {
|
|
413
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : kAudioDevicePropertyClockDomain error\n");
|
|
414
|
+
printError(osErr);
|
|
415
|
+
} else {
|
|
416
|
+
keptclockdomain = (keptclockdomain == 0) ? clockdomain : keptclockdomain;
|
|
417
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : output clockdomain = %d", clockdomain);
|
|
418
|
+
if (clockdomain != 0 && clockdomain != keptclockdomain) {
|
|
419
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : devices do not share the same clock!! clock drift compensation would be needed...\n");
|
|
420
|
+
need_clock_drift_compensation = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// If no valid clock domain was found, then assume we have to compensate...
|
|
427
|
+
if (keptclockdomain == 0) {
|
|
428
|
+
need_clock_drift_compensation = true;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
//---------------------------------------------------------------------------
|
|
432
|
+
// Start to create a new aggregate by getting the base audio hardware plugin
|
|
433
|
+
//---------------------------------------------------------------------------
|
|
434
|
+
|
|
435
|
+
char device_name[256];
|
|
436
|
+
for (UInt32 i = 0; i < captureDeviceID.size(); i++) {
|
|
437
|
+
GetDeviceNameFromID(captureDeviceID[i], device_name);
|
|
438
|
+
//printf("Separated input = '%s'\n", device_name);
|
|
439
|
+
|
|
440
|
+
// Compute the total number of output channels that the input devices have:
|
|
441
|
+
// we'll need to skip past these in our aggregate device and jump to the
|
|
442
|
+
// output channels that belong to the actual output device.
|
|
443
|
+
AudioBufferList bufferList;
|
|
444
|
+
outSize = sizeof(bufferList);
|
|
445
|
+
osErr = AudioDeviceGetProperty(captureDeviceID[i], 0, kAudioDeviceSectionGlobal,
|
|
446
|
+
kAudioDevicePropertyStreamConfiguration,
|
|
447
|
+
&outSize, &bufferList);
|
|
448
|
+
if (osErr != noErr) {
|
|
449
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : kAudioDevicePropertyStreamConfiguration error\n");
|
|
450
|
+
printError(osErr);
|
|
451
|
+
return osErr;
|
|
452
|
+
}
|
|
453
|
+
int captureDeviceOutChannels =
|
|
454
|
+
bufferList.mNumberBuffers > 0
|
|
455
|
+
? bufferList.mBuffers[0].mNumberChannels
|
|
456
|
+
: 0;
|
|
457
|
+
//printf("output channels to skip: %d\n", captureDeviceOutChannels);
|
|
458
|
+
outChannelOffset += captureDeviceOutChannels;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
for (UInt32 i = 0; i < playbackDeviceID.size(); i++) {
|
|
462
|
+
GetDeviceNameFromID(playbackDeviceID[i], device_name);
|
|
463
|
+
//printf("Separated output = '%s' \n", device_name);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
osErr = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyPlugInForBundleID, &outSize, &outWritable);
|
|
467
|
+
if (osErr != noErr) {
|
|
468
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioHardwareGetPropertyInfo kAudioHardwarePropertyPlugInForBundleID error\n");
|
|
469
|
+
printError(osErr);
|
|
470
|
+
return osErr;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
AudioValueTranslation pluginAVT;
|
|
474
|
+
CFStringRef inBundleRef = CFSTR("com.apple.audio.CoreAudio");
|
|
475
|
+
|
|
476
|
+
pluginAVT.mInputData = &inBundleRef;
|
|
477
|
+
pluginAVT.mInputDataSize = sizeof(inBundleRef);
|
|
478
|
+
pluginAVT.mOutputData = &fAggregatePluginID;
|
|
479
|
+
pluginAVT.mOutputDataSize = sizeof(fAggregatePluginID);
|
|
480
|
+
|
|
481
|
+
osErr = AudioHardwareGetProperty(kAudioHardwarePropertyPlugInForBundleID, &outSize, &pluginAVT);
|
|
482
|
+
if (osErr != noErr) {
|
|
483
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioHardwareGetProperty kAudioHardwarePropertyPlugInForBundleID error\n");
|
|
484
|
+
printError(osErr);
|
|
485
|
+
return osErr;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
//-------------------------------------------------
|
|
489
|
+
// Create a CFDictionary for our aggregate device
|
|
490
|
+
//-------------------------------------------------
|
|
491
|
+
|
|
492
|
+
CFMutableDictionaryRef aggDeviceDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
|
493
|
+
|
|
494
|
+
char buffer1[64];
|
|
495
|
+
char buffer2[64];
|
|
496
|
+
|
|
497
|
+
// generate "random" name
|
|
498
|
+
struct timeval fTv1;
|
|
499
|
+
struct timezone tz;
|
|
500
|
+
gettimeofday(&fTv1, &tz);
|
|
501
|
+
|
|
502
|
+
snprintf(buffer1, 64, "com.grame.%ld", fTv1.tv_sec + fTv1.tv_usec);
|
|
503
|
+
snprintf(buffer2, 64, "%ld", fTv1.tv_sec + fTv1.tv_usec);
|
|
504
|
+
|
|
505
|
+
CFStringRef AggregateDeviceNameRef = CFStringCreateWithCString(kCFAllocatorDefault, buffer1, CFStringGetSystemEncoding());
|
|
506
|
+
CFStringRef AggregateDeviceUIDRef = CFStringCreateWithCString(kCFAllocatorDefault, buffer2, CFStringGetSystemEncoding());
|
|
507
|
+
|
|
508
|
+
// add the name of the device to the dictionary
|
|
509
|
+
CFDictionaryAddValue(aggDeviceDict, CFSTR(kAudioAggregateDeviceNameKey), AggregateDeviceNameRef);
|
|
510
|
+
|
|
511
|
+
// add our choice of UID for the aggregate device to the dictionary
|
|
512
|
+
CFDictionaryAddValue(aggDeviceDict, CFSTR(kAudioAggregateDeviceUIDKey), AggregateDeviceUIDRef);
|
|
513
|
+
|
|
514
|
+
// add a "private aggregate key" to the dictionary
|
|
515
|
+
int value = 1;
|
|
516
|
+
CFNumberRef AggregateDeviceNumberRef = CFNumberCreate(NULL, kCFNumberIntType, &value);
|
|
517
|
+
|
|
518
|
+
SInt32 system;
|
|
519
|
+
Gestalt(gestaltSystemVersion, &system);
|
|
520
|
+
|
|
521
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : system version = %x limit = %x\n", system, 0x00001054);
|
|
522
|
+
|
|
523
|
+
// Starting with 10.5.4 systems, the AD can be internal... (better)
|
|
524
|
+
if (system < 0x00001054) {
|
|
525
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : public aggregate device....\n");
|
|
526
|
+
} else {
|
|
527
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice : private aggregate device....\n");
|
|
528
|
+
CFDictionaryAddValue(aggDeviceDict, CFSTR(kAudioAggregateDeviceIsPrivateKey), AggregateDeviceNumberRef);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Prepare sub-devices for clock drift compensation
|
|
532
|
+
CFMutableArrayRef subDevicesArrayClock = NULL;
|
|
533
|
+
|
|
534
|
+
/*
|
|
535
|
+
if (fClockDriftCompensate) {
|
|
536
|
+
if (need_clock_drift_compensation) {
|
|
537
|
+
jack_info("Clock drift compensation activated...");
|
|
538
|
+
subDevicesArrayClock = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
|
|
539
|
+
|
|
540
|
+
for (UInt32 i = 0; i < captureDeviceID.size(); i++) {
|
|
541
|
+
CFStringRef UID = GetDeviceName(captureDeviceID[i]);
|
|
542
|
+
if (UID) {
|
|
543
|
+
CFMutableDictionaryRef subdeviceAggDeviceDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
|
544
|
+
CFDictionaryAddValue(subdeviceAggDeviceDict, CFSTR(kAudioSubDeviceUIDKey), UID);
|
|
545
|
+
CFDictionaryAddValue(subdeviceAggDeviceDict, CFSTR(kAudioSubDeviceDriftCompensationKey), AggregateDeviceNumberRef);
|
|
546
|
+
//CFRelease(UID);
|
|
547
|
+
CFArrayAppendValue(subDevicesArrayClock, subdeviceAggDeviceDict);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
for (UInt32 i = 0; i < playbackDeviceID.size(); i++) {
|
|
552
|
+
CFStringRef UID = GetDeviceName(playbackDeviceID[i]);
|
|
553
|
+
if (UID) {
|
|
554
|
+
CFMutableDictionaryRef subdeviceAggDeviceDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
|
555
|
+
CFDictionaryAddValue(subdeviceAggDeviceDict, CFSTR(kAudioSubDeviceUIDKey), UID);
|
|
556
|
+
CFDictionaryAddValue(subdeviceAggDeviceDict, CFSTR(kAudioSubDeviceDriftCompensationKey), AggregateDeviceNumberRef);
|
|
557
|
+
//CFRelease(UID);
|
|
558
|
+
CFArrayAppendValue(subDevicesArrayClock, subdeviceAggDeviceDict);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// add sub-device clock array for the aggregate device to the dictionary
|
|
563
|
+
CFDictionaryAddValue(aggDeviceDict, CFSTR(kAudioAggregateDeviceSubDeviceListKey), subDevicesArrayClock);
|
|
564
|
+
} else {
|
|
565
|
+
jack_info("Clock drift compensation was asked but is not needed (devices use the same clock domain)");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
*/
|
|
569
|
+
|
|
570
|
+
//-------------------------------------------------
|
|
571
|
+
// Create a CFMutableArray for our sub-device list
|
|
572
|
+
//-------------------------------------------------
|
|
573
|
+
|
|
574
|
+
// we need to append the UID for each device to a CFMutableArray, so create one here
|
|
575
|
+
CFMutableArrayRef subDevicesArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
|
|
576
|
+
|
|
577
|
+
std::vector<CFStringRef> captureDeviceUID;
|
|
578
|
+
for (UInt32 i = 0; i < captureDeviceID.size(); i++) {
|
|
579
|
+
CFStringRef ref = GetDeviceName(captureDeviceID[i]);
|
|
580
|
+
if (ref == NULL) {
|
|
581
|
+
return -1;
|
|
582
|
+
}
|
|
583
|
+
captureDeviceUID.push_back(ref);
|
|
584
|
+
// input sub-devices in this example, so append the sub-device's UID to the CFArray
|
|
585
|
+
CFArrayAppendValue(subDevicesArray, ref);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
std::vector<CFStringRef> playbackDeviceUID;
|
|
589
|
+
for (UInt32 i = 0; i < playbackDeviceID.size(); i++) {
|
|
590
|
+
CFStringRef ref = GetDeviceName(playbackDeviceID[i]);
|
|
591
|
+
if (ref == NULL) {
|
|
592
|
+
return -1;
|
|
593
|
+
}
|
|
594
|
+
playbackDeviceUID.push_back(ref);
|
|
595
|
+
// output sub-devices in this example, so append the sub-device's UID to the CFArray
|
|
596
|
+
CFArrayAppendValue(subDevicesArray, ref);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
//-----------------------------------------------------------------------
|
|
600
|
+
// Feed the dictionary to the plugin, to create a blank aggregate device
|
|
601
|
+
//-----------------------------------------------------------------------
|
|
602
|
+
|
|
603
|
+
AudioObjectPropertyAddress pluginAOPA;
|
|
604
|
+
pluginAOPA.mSelector = kAudioPlugInCreateAggregateDevice;
|
|
605
|
+
pluginAOPA.mScope = kAudioObjectPropertyScopeGlobal;
|
|
606
|
+
pluginAOPA.mElement = kAudioObjectPropertyElementMaster;
|
|
607
|
+
UInt32 outDataSize;
|
|
608
|
+
|
|
609
|
+
osErr = AudioObjectGetPropertyDataSize(fAggregatePluginID, &pluginAOPA, 0, NULL, &outDataSize);
|
|
610
|
+
if (osErr != noErr) {
|
|
611
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioObjectGetPropertyDataSize error\n");
|
|
612
|
+
printError(osErr);
|
|
613
|
+
goto error;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
osErr = AudioObjectGetPropertyData(fAggregatePluginID, &pluginAOPA, sizeof(aggDeviceDict), &aggDeviceDict, &outDataSize, &fAggregateDeviceID);
|
|
617
|
+
if (osErr != noErr) {
|
|
618
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioObjectGetPropertyData error\n");
|
|
619
|
+
printError(osErr);
|
|
620
|
+
goto error;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// pause for a bit to make sure that everything completed correctly
|
|
624
|
+
// this is to work around a bug in the HAL where a new aggregate device seems to disappear briefly after it is created
|
|
625
|
+
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false);
|
|
626
|
+
|
|
627
|
+
//-------------------------
|
|
628
|
+
// Set the sub-device list
|
|
629
|
+
//-------------------------
|
|
630
|
+
|
|
631
|
+
pluginAOPA.mSelector = kAudioAggregateDevicePropertyFullSubDeviceList;
|
|
632
|
+
pluginAOPA.mScope = kAudioObjectPropertyScopeGlobal;
|
|
633
|
+
pluginAOPA.mElement = kAudioObjectPropertyElementMaster;
|
|
634
|
+
outDataSize = sizeof(CFMutableArrayRef);
|
|
635
|
+
osErr = AudioObjectSetPropertyData(fAggregateDeviceID, &pluginAOPA, 0, NULL, outDataSize, &subDevicesArray);
|
|
636
|
+
if (osErr != noErr) {
|
|
637
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioObjectSetPropertyData for sub-device list error\n");
|
|
638
|
+
printError(osErr);
|
|
639
|
+
goto error;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// pause again to give the changes time to take effect
|
|
643
|
+
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false);
|
|
644
|
+
|
|
645
|
+
//-----------------------
|
|
646
|
+
// Set the master device
|
|
647
|
+
//-----------------------
|
|
648
|
+
|
|
649
|
+
// set the master device manually (this is the device which will act as the master clock for the aggregate device)
|
|
650
|
+
// pass in the UID of the device you want to use
|
|
651
|
+
pluginAOPA.mSelector = kAudioAggregateDevicePropertyMasterSubDevice;
|
|
652
|
+
pluginAOPA.mScope = kAudioObjectPropertyScopeGlobal;
|
|
653
|
+
pluginAOPA.mElement = kAudioObjectPropertyElementMaster;
|
|
654
|
+
outDataSize = sizeof(CFStringRef);
|
|
655
|
+
osErr = AudioObjectSetPropertyData(fAggregateDeviceID, &pluginAOPA, 0, NULL, outDataSize, &playbackDeviceUID[0]); // First playback is master...
|
|
656
|
+
if (osErr != noErr) {
|
|
657
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux : AudioObjectSetPropertyData for master device error\n");
|
|
658
|
+
printError(osErr);
|
|
659
|
+
goto error;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// pause again to give the changes time to take effect
|
|
663
|
+
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false);
|
|
664
|
+
|
|
665
|
+
// Prepare sub-devices for clock drift compensation
|
|
666
|
+
// Workaround for bug in the HAL : until 10.6.2
|
|
667
|
+
|
|
668
|
+
if (fClockDriftCompensate) {
|
|
669
|
+
if (need_clock_drift_compensation) {
|
|
670
|
+
//printf("Clock drift compensation activated...\n");
|
|
671
|
+
|
|
672
|
+
// Get the property data size
|
|
673
|
+
osErr = AudioObjectGetPropertyDataSize(fAggregateDeviceID, &theAddressOwned, theQualifierDataSize, theQualifierData, &outSize);
|
|
674
|
+
if (osErr != noErr) {
|
|
675
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux kAudioObjectPropertyOwnedObjects error\n");
|
|
676
|
+
printError(osErr);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Calculate the number of object IDs
|
|
680
|
+
subDevicesNum = outSize / sizeof(AudioObjectID);
|
|
681
|
+
//printf("TCoreAudioRenderer::CreateAggregateDevice clock drift compensation, number of sub-devices = %d\n", subDevicesNum);
|
|
682
|
+
AudioObjectID subDevices[subDevicesNum];
|
|
683
|
+
outSize = sizeof(subDevices);
|
|
684
|
+
|
|
685
|
+
osErr = AudioObjectGetPropertyData(fAggregateDeviceID, &theAddressOwned, theQualifierDataSize, theQualifierData, &outSize, subDevices);
|
|
686
|
+
if (osErr != noErr) {
|
|
687
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux kAudioObjectPropertyOwnedObjects error\n");
|
|
688
|
+
printError(osErr);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// Set kAudioSubDevicePropertyDriftCompensation property...
|
|
692
|
+
for (UInt32 index = 0; index < subDevicesNum; ++index) {
|
|
693
|
+
UInt32 theDriftCompensationValue = 1;
|
|
694
|
+
osErr = AudioObjectSetPropertyData(subDevices[index], &theAddressDrift, 0, NULL, sizeof(UInt32), &theDriftCompensationValue);
|
|
695
|
+
if (osErr != noErr) {
|
|
696
|
+
printf("TCoreAudioRenderer::CreateAggregateDeviceAux kAudioSubDevicePropertyDriftCompensation error\n");
|
|
697
|
+
printError(osErr);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
//printf("Clock drift compensation was asked but is not needed (devices use the same clock domain)\n");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// pause again to give the changes time to take effect
|
|
706
|
+
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false);
|
|
707
|
+
|
|
708
|
+
//----------
|
|
709
|
+
// Clean up
|
|
710
|
+
//----------
|
|
711
|
+
|
|
712
|
+
// release the private AD key
|
|
713
|
+
CFRelease(AggregateDeviceNumberRef);
|
|
714
|
+
|
|
715
|
+
// release the CF objects we have created - we don't need them any more
|
|
716
|
+
CFRelease(aggDeviceDict);
|
|
717
|
+
CFRelease(subDevicesArray);
|
|
718
|
+
|
|
719
|
+
if (subDevicesArrayClock)
|
|
720
|
+
CFRelease(subDevicesArrayClock);
|
|
721
|
+
|
|
722
|
+
// release the device UID
|
|
723
|
+
for (UInt32 i = 0; i < captureDeviceUID.size(); i++) {
|
|
724
|
+
CFRelease(captureDeviceUID[i]);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
for (UInt32 i = 0; i < playbackDeviceUID.size(); i++) {
|
|
728
|
+
CFRelease(playbackDeviceUID[i]);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
//printf("New aggregate device %d\n", fAggregateDeviceID);
|
|
732
|
+
return noErr;
|
|
733
|
+
|
|
734
|
+
error:
|
|
735
|
+
DestroyAggregateDevice();
|
|
736
|
+
return -1;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
void DestroyAggregateDevice()
|
|
740
|
+
{
|
|
741
|
+
if (fAggregateDeviceID > 0) {
|
|
742
|
+
OSStatus osErr = noErr;
|
|
743
|
+
AudioObjectPropertyAddress pluginAOPA;
|
|
744
|
+
pluginAOPA.mSelector = kAudioPlugInDestroyAggregateDevice;
|
|
745
|
+
pluginAOPA.mScope = kAudioObjectPropertyScopeGlobal;
|
|
746
|
+
pluginAOPA.mElement = kAudioObjectPropertyElementMaster;
|
|
747
|
+
UInt32 outDataSize;
|
|
748
|
+
if (fAggregatePluginID > 0) {
|
|
749
|
+
osErr = AudioObjectGetPropertyDataSize(fAggregatePluginID, &pluginAOPA, 0, NULL, &outDataSize);
|
|
750
|
+
if (osErr != noErr) {
|
|
751
|
+
//printf("TCoreAudioRenderer::DestroyAggregateDevice : AudioObjectGetPropertyDataSize error\n");
|
|
752
|
+
//printError(osErr);
|
|
753
|
+
}
|
|
754
|
+
osErr = AudioObjectGetPropertyData(fAggregatePluginID, &pluginAOPA, 0, NULL, &outDataSize, &fAggregateDeviceID);
|
|
755
|
+
if (osErr != noErr) {
|
|
756
|
+
//printf("TCoreAudioRenderer::DestroyAggregateDevice : AudioObjectGetPropertyData error\n");
|
|
757
|
+
//printError(osErr);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
OSStatus GetDeviceNameFromID(AudioDeviceID id, char* name)
|
|
764
|
+
{
|
|
765
|
+
UInt32 size = 256;
|
|
766
|
+
return AudioDeviceGetProperty(id, 0, false, kAudioDevicePropertyDeviceName, &size, name);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
int SetupBufferSize(int buffer_size)
|
|
770
|
+
{
|
|
771
|
+
// Setting buffer size
|
|
772
|
+
OSStatus err = noErr;
|
|
773
|
+
UInt32 current_buffer_size = buffer_size;
|
|
774
|
+
UInt32 outSize;
|
|
775
|
+
AudioValueRange buffer_size_range;
|
|
776
|
+
|
|
777
|
+
outSize = sizeof(AudioValueRange);
|
|
778
|
+
err = AudioDeviceGetProperty(fDeviceID, 0, true, kAudioDevicePropertyBufferFrameSizeRange, &outSize, &buffer_size_range);
|
|
779
|
+
if (err != noErr) {
|
|
780
|
+
printf("Cannot get buffer size range\n");
|
|
781
|
+
printError(err);
|
|
782
|
+
return -1;
|
|
783
|
+
} else {
|
|
784
|
+
//printf("SetupBufferSize : buffer size range min = %ld max = %ld\n", (int)buffer_size_range.mMinimum, (int)buffer_size_range.mMaximum);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
outSize = sizeof(UInt32);
|
|
788
|
+
err = AudioDeviceGetProperty(fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, &outSize, ¤t_buffer_size);
|
|
789
|
+
if (err != noErr) {
|
|
790
|
+
printf("Cannot get buffer size\n");
|
|
791
|
+
printError(err);
|
|
792
|
+
return -1;
|
|
793
|
+
} else {
|
|
794
|
+
//printf("SetupBufferSize : current buffer size %ld\n", current_buffer_size);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// If needed, set new buffer size
|
|
798
|
+
if (buffer_size != current_buffer_size && buffer_size >= (int)buffer_size_range.mMinimum && buffer_size <= (int)buffer_size_range.mMaximum) {
|
|
799
|
+
current_buffer_size = buffer_size;
|
|
800
|
+
|
|
801
|
+
// To get BS change notification
|
|
802
|
+
err = AudioDeviceAddPropertyListener(fDeviceID, 0, true, kAudioDevicePropertyBufferFrameSize, BSNotificationCallback, this);
|
|
803
|
+
if (err != noErr) {
|
|
804
|
+
printf("Error calling AudioDeviceAddPropertyListener with kAudioDevicePropertyBufferFrameSize\n");
|
|
805
|
+
printError(err);
|
|
806
|
+
return -1;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// Waiting for BS change notification
|
|
810
|
+
int count = 0;
|
|
811
|
+
fState = false;
|
|
812
|
+
|
|
813
|
+
err = AudioDeviceSetProperty(fDeviceID, NULL, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, outSize, ¤t_buffer_size);
|
|
814
|
+
if (err != noErr) {
|
|
815
|
+
printf("SetupBufferSize : cannot set buffer size = %ld\n", current_buffer_size);
|
|
816
|
+
printError(err);
|
|
817
|
+
goto error;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
while (!fState && count++ < WAIT_NOTIFICATION_COUNTER) {
|
|
821
|
+
usleep(100000);
|
|
822
|
+
//printf("SetupBufferSize : wait count = %d\n", count);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (count >= WAIT_NOTIFICATION_COUNTER) {
|
|
826
|
+
printf("Did not get buffer size notification...\n");
|
|
827
|
+
goto error;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// Check new buffer size
|
|
831
|
+
outSize = sizeof(UInt32);
|
|
832
|
+
err = AudioDeviceGetProperty(fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, &outSize, ¤t_buffer_size);
|
|
833
|
+
if (err != noErr) {
|
|
834
|
+
printf("Cannot get current buffer size\n");
|
|
835
|
+
printError(err);
|
|
836
|
+
} else {
|
|
837
|
+
//printf("SetupBufferSize : checked buffer size = %ld\n", current_buffer_size);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// Remove BS change notification
|
|
841
|
+
AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioDevicePropertyBufferFrameSize, BSNotificationCallback);
|
|
842
|
+
} else {
|
|
843
|
+
//printf("Keep current buffer size = %ld\n", current_buffer_size);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
fBufferSize = current_buffer_size;
|
|
847
|
+
return 0;
|
|
848
|
+
|
|
849
|
+
error:
|
|
850
|
+
|
|
851
|
+
// Remove BS change notification
|
|
852
|
+
AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioDevicePropertyBufferFrameSize, BSNotificationCallback);
|
|
853
|
+
return -1;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
static OSStatus BSNotificationCallback(AudioDeviceID inDevice,
|
|
857
|
+
UInt32 inChannel,
|
|
858
|
+
Boolean isInput,
|
|
859
|
+
AudioDevicePropertyID inPropertyID,
|
|
860
|
+
void* inClientData)
|
|
861
|
+
{
|
|
862
|
+
TCoreAudioRenderer* driver = (TCoreAudioRenderer*)inClientData;
|
|
863
|
+
|
|
864
|
+
switch (inPropertyID) {
|
|
865
|
+
|
|
866
|
+
case kAudioDevicePropertyBufferFrameSize: {
|
|
867
|
+
//printf("BSNotificationCallback kAudioDevicePropertyBufferFrameSize\n");
|
|
868
|
+
// Check new buffer size
|
|
869
|
+
UInt32 current_buffer_size;
|
|
870
|
+
UInt32 outSize = sizeof(UInt32);
|
|
871
|
+
OSStatus err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, &outSize, ¤t_buffer_size);
|
|
872
|
+
if (err != noErr) {
|
|
873
|
+
printf("Cannot get current buffer size\n");
|
|
874
|
+
printError(err);
|
|
875
|
+
} else {
|
|
876
|
+
//printf("BSNotificationCallback : checked current buffer size = %d\n", current_buffer_size);
|
|
877
|
+
}
|
|
878
|
+
driver->fState = true;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
return noErr;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
int SetupSampleRateAux(AudioDeviceID inDevice, int& sample_rate)
|
|
887
|
+
{
|
|
888
|
+
OSStatus err = noErr;
|
|
889
|
+
UInt32 outSize = sizeof(Float64);
|
|
890
|
+
Float64 sampleRate = GetNominalSampleRate(inDevice);
|
|
891
|
+
|
|
892
|
+
if (sample_rate != -1 && sample_rate != (int)sampleRate) {
|
|
893
|
+
sampleRate = (Float64)sample_rate;
|
|
894
|
+
|
|
895
|
+
// To get SR change notification
|
|
896
|
+
err = AudioDeviceAddPropertyListener(inDevice, 0, true, kAudioDevicePropertyNominalSampleRate, SRNotificationCallback, this);
|
|
897
|
+
if (err != noErr) {
|
|
898
|
+
printf("Error calling AudioDeviceAddPropertyListener with kAudioDevicePropertyNominalSampleRate\n");
|
|
899
|
+
printError(err);
|
|
900
|
+
return -1;
|
|
901
|
+
}
|
|
902
|
+
err = AudioDeviceSetProperty(inDevice, NULL, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, outSize, &sampleRate);
|
|
903
|
+
if (err != noErr) {
|
|
904
|
+
printf("Cannot set sample rate = %d\n", sample_rate);
|
|
905
|
+
printError(err);
|
|
906
|
+
return -1;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// Waiting for SR change notification
|
|
910
|
+
int count = 0;
|
|
911
|
+
while (!fState && count++ < WAIT_NOTIFICATION_COUNTER) {
|
|
912
|
+
usleep(100000);
|
|
913
|
+
//printf("Wait count = %d\n", count);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Check new sample rate
|
|
917
|
+
outSize = sizeof(Float64);
|
|
918
|
+
err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
|
|
919
|
+
if (err != noErr) {
|
|
920
|
+
printf("Cannot get current sample rate\n");
|
|
921
|
+
printError(err);
|
|
922
|
+
} else {
|
|
923
|
+
//printf("Checked sample rate = %f\n", sampleRate);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Remove SR change notification
|
|
927
|
+
AudioDeviceRemovePropertyListener(inDevice, 0, true, kAudioDevicePropertyNominalSampleRate, SRNotificationCallback);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
sample_rate = int(sampleRate);
|
|
931
|
+
return 0;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
static OSStatus Render(void *inRefCon,
|
|
935
|
+
AudioUnitRenderActionFlags *ioActionFlags,
|
|
936
|
+
const AudioTimeStamp *inTimeStamp,
|
|
937
|
+
UInt32 inBusNumber,
|
|
938
|
+
UInt32 inNumberFrames,
|
|
939
|
+
AudioBufferList *ioData)
|
|
940
|
+
{
|
|
941
|
+
return static_cast<TCoreAudioRendererPtr>(inRefCon)->Render(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
static OSStatus SRNotificationCallback(AudioDeviceID inDevice,
|
|
945
|
+
UInt32 inChannel,
|
|
946
|
+
Boolean isInput,
|
|
947
|
+
AudioDevicePropertyID inPropertyID,
|
|
948
|
+
void* inClientData)
|
|
949
|
+
{
|
|
950
|
+
TCoreAudioRenderer* driver = (TCoreAudioRenderer*)inClientData;
|
|
951
|
+
|
|
952
|
+
switch (inPropertyID) {
|
|
953
|
+
|
|
954
|
+
case kAudioDevicePropertyNominalSampleRate: {
|
|
955
|
+
//printf("SRNotificationCallback kAudioDevicePropertyNominalSampleRate\n");
|
|
956
|
+
driver->fState = true;
|
|
957
|
+
// Check new sample rate
|
|
958
|
+
Float64 sampleRate;
|
|
959
|
+
UInt32 outSize = sizeof(Float64);
|
|
960
|
+
OSStatus err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
|
|
961
|
+
if (err != noErr) {
|
|
962
|
+
printf("Cannot get current sample rate\n");
|
|
963
|
+
printError(err);
|
|
964
|
+
} else {
|
|
965
|
+
//printf("SRNotificationCallback : checked sample rate = %f\n", sampleRate);
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return noErr;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
virtual OSStatus Render(AudioUnitRenderActionFlags *ioActionFlags,
|
|
975
|
+
const AudioTimeStamp *inTimeStamp,
|
|
976
|
+
UInt32 inNumberFrames,
|
|
977
|
+
AudioBufferList *ioData)
|
|
978
|
+
{
|
|
979
|
+
OSStatus err = noErr;
|
|
980
|
+
if (fDevNumInChans > 0) {
|
|
981
|
+
err = AudioUnitRender(fAUHAL, ioActionFlags, inTimeStamp, 1, inNumberFrames, fInputData);
|
|
982
|
+
}
|
|
983
|
+
if (err == noErr) {
|
|
984
|
+
for (int i = 0; i < fDevNumInChans; i++) {
|
|
985
|
+
fInChannel[i] = (float*)fInputData->mBuffers[i].mData;
|
|
986
|
+
}
|
|
987
|
+
for (int i = 0; i < fDevNumOutChans; i++) {
|
|
988
|
+
fOutChannel[i] = (float*)ioData->mBuffers[i].mData;
|
|
989
|
+
}
|
|
990
|
+
#ifdef HAS_MATH_EXCEPTION
|
|
991
|
+
TRY_FPE
|
|
992
|
+
#endif
|
|
993
|
+
fDSP->compute(double(AudioConvertHostTimeToNanos(inTimeStamp->mHostTime))/1000., inNumberFrames, fInChannel, fOutChannel);
|
|
994
|
+
#ifdef HAS_MATH_EXCEPTION
|
|
995
|
+
CATCH_FPE
|
|
996
|
+
#endif
|
|
997
|
+
fAudio->runControlCallbacks();
|
|
998
|
+
} else {
|
|
999
|
+
printf("AudioUnitRender error... %x\n", fInputData);
|
|
1000
|
+
printError(err);
|
|
1001
|
+
}
|
|
1002
|
+
return err;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
public:
|
|
1006
|
+
|
|
1007
|
+
TCoreAudioRenderer(audio* audio)
|
|
1008
|
+
:fAggregateDeviceID(-1),fAggregatePluginID(-1),
|
|
1009
|
+
fDevNumInChans(0),fDevNumOutChans(0),
|
|
1010
|
+
fPhysicalInputs(0), fPhysicalOutputs(0),
|
|
1011
|
+
fInChannel(0),fOutChannel(0),
|
|
1012
|
+
fBufferSize(0),fSampleRate(0),
|
|
1013
|
+
fIsInJackDevice(false),
|
|
1014
|
+
fIsOutJackDevice(false),
|
|
1015
|
+
fDSP(0),
|
|
1016
|
+
fAudio(audio),
|
|
1017
|
+
fInputData(0),
|
|
1018
|
+
fDeviceID(0),fAUHAL(0),
|
|
1019
|
+
fState(false)
|
|
1020
|
+
{}
|
|
1021
|
+
|
|
1022
|
+
virtual ~TCoreAudioRenderer()
|
|
1023
|
+
{}
|
|
1024
|
+
|
|
1025
|
+
int GetBufferSize() {return fBufferSize;}
|
|
1026
|
+
int GetSampleRate() {return fSampleRate;}
|
|
1027
|
+
|
|
1028
|
+
static OSStatus RestartProc(AudioObjectID objectID, UInt32 numberAddresses,
|
|
1029
|
+
const AudioObjectPropertyAddress inAddresses[],
|
|
1030
|
+
void *clientData)
|
|
1031
|
+
{
|
|
1032
|
+
/*
|
|
1033
|
+
TCoreAudioRenderer* renderer = (TCoreAudioRenderer*)clientData;
|
|
1034
|
+
AudioDeviceID defaultDevice;
|
|
1035
|
+
UInt32 theSize = sizeof(UInt32);
|
|
1036
|
+
OSStatus res;
|
|
1037
|
+
char device_name[256];
|
|
1038
|
+
|
|
1039
|
+
// Test if new device is "JackRouter"
|
|
1040
|
+
if (inAddresses[0].mSelector == kAudioHardwarePropertyDefaultInputDevice) {
|
|
1041
|
+
|
|
1042
|
+
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
|
|
1043
|
+
&theSize, &defaultDevice)) == noErr) {
|
|
1044
|
+
renderer->GetDeviceNameFromID(defaultDevice, device_name);
|
|
1045
|
+
renderer->fIsInJackDevice = strcmp(device_name, "JackRouter") == 0;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
} else if (inAddresses[0].mSelector == kAudioHardwarePropertyDefaultOutputDevice) {
|
|
1049
|
+
|
|
1050
|
+
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
|
|
1051
|
+
&theSize, &defaultDevice)) == noErr) {
|
|
1052
|
+
renderer->GetDeviceNameFromID(defaultDevice, device_name);
|
|
1053
|
+
renderer->fIsOutJackDevice = strcmp(device_name, "JackRouter") == 0;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// Switch only of input and output are "JackRouter"
|
|
1059
|
+
if (renderer->fIsInJackDevice && renderer->fIsOutJackDevice || !renderer->fIsInJackDevice && !renderer->fIsOutJackDevice) {
|
|
1060
|
+
renderer->Stop();
|
|
1061
|
+
renderer->Close();
|
|
1062
|
+
int sampleRate = -1; // Use the current sample rate
|
|
1063
|
+
int bufferSize = (renderer->fBufferSize > 0) ? renderer->fBufferSize : 512; // Use default if needed
|
|
1064
|
+
renderer->OpenDefault(renderer->fDSP, renderer->fDevNumInChans, renderer->fDevNumOutChans, bufferSize, sampleRate);
|
|
1065
|
+
renderer->Start();
|
|
1066
|
+
}
|
|
1067
|
+
*/
|
|
1068
|
+
return 0;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
int OpenDefault(dsp* DSP, int inChan, int outChan, int bufferSize, int& sampleRate)
|
|
1072
|
+
{
|
|
1073
|
+
fDevNumInChans = 0;
|
|
1074
|
+
fDevNumOutChans = 0;
|
|
1075
|
+
fInChannel = 0;
|
|
1076
|
+
fOutChannel = 0;
|
|
1077
|
+
fBufferSize = 0;
|
|
1078
|
+
fSampleRate = 0;
|
|
1079
|
+
fDSP = 0;
|
|
1080
|
+
fInputData = 0;
|
|
1081
|
+
fDeviceID = 0;
|
|
1082
|
+
fAUHAL = 0;
|
|
1083
|
+
fState = false;
|
|
1084
|
+
return OpenDefault(inChan, outChan, bufferSize, sampleRate);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
int OpenDefault(int inChan, int outChan, int buffer_size, int& sample_rate)
|
|
1088
|
+
{
|
|
1089
|
+
OSStatus err;
|
|
1090
|
+
UInt32 outSize;
|
|
1091
|
+
UInt32 enableIO;
|
|
1092
|
+
Boolean isWritable;
|
|
1093
|
+
AudioStreamBasicDescription srcFormat, dstFormat, sampleRate;
|
|
1094
|
+
|
|
1095
|
+
fDevNumInChans = inChan;
|
|
1096
|
+
fDevNumOutChans = outChan;
|
|
1097
|
+
|
|
1098
|
+
fInChannel = new float*[fDevNumInChans];
|
|
1099
|
+
fOutChannel = new float*[fDevNumOutChans];
|
|
1100
|
+
|
|
1101
|
+
//printf("OpenDefault inChan = %ld outChan = %ld bufferSize = %ld sample_rate = %ld\n", inChan, outChan, bufferSize, sample_rate);
|
|
1102
|
+
|
|
1103
|
+
SInt32 major;
|
|
1104
|
+
SInt32 minor;
|
|
1105
|
+
Gestalt(gestaltSystemVersionMajor, &major);
|
|
1106
|
+
Gestalt(gestaltSystemVersionMinor, &minor);
|
|
1107
|
+
|
|
1108
|
+
// Starting with 10.6 systems, the HAL notification thread is created internally
|
|
1109
|
+
if (major == 10 && minor >= 6) {
|
|
1110
|
+
CFRunLoopRef theRunLoop = NULL;
|
|
1111
|
+
AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
1112
|
+
OSStatus osErr = AudioObjectSetPropertyData (kAudioObjectSystemObject, &theAddress, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop);
|
|
1113
|
+
if (osErr != noErr) {
|
|
1114
|
+
printf("TCoreAudioRenderer::Open kAudioHardwarePropertyRunLoop error\n");
|
|
1115
|
+
printError(osErr);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
int outChannelOffset = 0;
|
|
1120
|
+
if (GetDefaultDeviceAndSampleRate(inChan, outChan, sample_rate, outChannelOffset, &fDeviceID) != noErr) {
|
|
1121
|
+
printf("Cannot open default device\n");
|
|
1122
|
+
return OPEN_ERR;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// Setting buffer size
|
|
1126
|
+
if (SetupBufferSize(buffer_size) < 0) {
|
|
1127
|
+
return OPEN_ERR;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// fBufferSize now has the real value, either 'bufferSize' (if could be changed) or driver current one
|
|
1131
|
+
|
|
1132
|
+
// AUHAL
|
|
1133
|
+
#if (defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5))
|
|
1134
|
+
AudioComponentDescription cd = {kAudioUnitType_Output, kAudioUnitSubType_HALOutput, kAudioUnitManufacturer_Apple, 0, 0};
|
|
1135
|
+
AudioComponent HALOutput = AudioComponentFindNext(NULL, &cd);
|
|
1136
|
+
err = AudioComponentInstanceNew(HALOutput, &fAUHAL);
|
|
1137
|
+
if (err != noErr) {
|
|
1138
|
+
printf("Error calling AudioComponentInstanceNew\n");
|
|
1139
|
+
printError(err);
|
|
1140
|
+
goto error;
|
|
1141
|
+
}
|
|
1142
|
+
#else
|
|
1143
|
+
ComponentDescription cd = {kAudioUnitType_Output, kAudioUnitSubType_HALOutput, kAudioUnitManufacturer_Apple, 0, 0};
|
|
1144
|
+
Component HALOutput = FindNextComponent(NULL, &cd);
|
|
1145
|
+
err = OpenAComponent(HALOutput, &fAUHAL);
|
|
1146
|
+
if (err != noErr) {
|
|
1147
|
+
printf("Error calling OpenAComponent\n");
|
|
1148
|
+
printError(err);
|
|
1149
|
+
goto error;
|
|
1150
|
+
}
|
|
1151
|
+
#endif
|
|
1152
|
+
|
|
1153
|
+
err = AudioUnitInitialize(fAUHAL);
|
|
1154
|
+
if (err != noErr) {
|
|
1155
|
+
printf("Cannot initialize AUHAL unit\n");
|
|
1156
|
+
printError(err);
|
|
1157
|
+
goto error;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if (inChan > 0) {
|
|
1161
|
+
enableIO = 1;
|
|
1162
|
+
//printf("OpenAUHAL : setup AUHAL input on\n");
|
|
1163
|
+
} else {
|
|
1164
|
+
enableIO = 0;
|
|
1165
|
+
//printf("OpenAUHAL : setup AUHAL input off\n");
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(enableIO));
|
|
1169
|
+
if (err != noErr) {
|
|
1170
|
+
printf("Error calling AudioUnitSetProperty - kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input\n");
|
|
1171
|
+
printError(err);
|
|
1172
|
+
goto error;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if (outChan > 0) {
|
|
1176
|
+
enableIO = 1;
|
|
1177
|
+
//printf("OpenAUHAL : setup AUHAL output on\n");
|
|
1178
|
+
} else {
|
|
1179
|
+
enableIO = 0;
|
|
1180
|
+
//printf("OpenAUHAL : setup AUHAL output off\n");
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(enableIO));
|
|
1184
|
+
if (err != noErr) {
|
|
1185
|
+
printf("Error calling AudioUnitSetProperty - kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output\n");
|
|
1186
|
+
printError(err);
|
|
1187
|
+
goto error;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
AudioDeviceID currAudioDeviceID;
|
|
1191
|
+
outSize = sizeof(AudioDeviceID);
|
|
1192
|
+
err = AudioUnitGetProperty(fAUHAL, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &currAudioDeviceID, &outSize);
|
|
1193
|
+
if (err != noErr) {
|
|
1194
|
+
printf("Error calling AudioUnitGetProperty - kAudioOutputUnitProperty_CurrentDevice\n");
|
|
1195
|
+
printError(err);
|
|
1196
|
+
goto error;
|
|
1197
|
+
} else {
|
|
1198
|
+
//printf("AudioUnitGetPropertyCurrentDevice = %d\n", currAudioDeviceID);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// Setup up choosen device, in both input and output cases
|
|
1202
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &fDeviceID, sizeof(AudioDeviceID));
|
|
1203
|
+
if (err != noErr) {
|
|
1204
|
+
printf("Error calling AudioUnitSetProperty - kAudioOutputUnitProperty_CurrentDevice\n");
|
|
1205
|
+
printError(err);
|
|
1206
|
+
goto error;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
if (inChan > 0) {
|
|
1210
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 1, (UInt32*)&fBufferSize, sizeof(UInt32));
|
|
1211
|
+
if (err != noErr) {
|
|
1212
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_MaximumFramesPerSlice\n");
|
|
1213
|
+
printError(err);
|
|
1214
|
+
goto error;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (outChan > 0) {
|
|
1219
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, (UInt32*)&fBufferSize, sizeof(UInt32));
|
|
1220
|
+
if (err != noErr) {
|
|
1221
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_MaximumFramesPerSlice\n");
|
|
1222
|
+
printError(err);
|
|
1223
|
+
goto error;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
err = AudioUnitGetPropertyInfo(fAUHAL, kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Input, 1, &outSize, &isWritable);
|
|
1228
|
+
if (err != noErr) {
|
|
1229
|
+
//printf("Error calling AudioUnitGetPropertyInfo - kAudioOutputUnitProperty_ChannelMap 1\n");
|
|
1230
|
+
//printError(err);
|
|
1231
|
+
} else {
|
|
1232
|
+
fPhysicalInputs = outSize / sizeof(SInt32);
|
|
1233
|
+
//printf("fPhysicalInputs = %ld\n", fPhysicalInputs);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
err = AudioUnitGetPropertyInfo(fAUHAL, kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Output, 0, &outSize, &isWritable);
|
|
1237
|
+
if (err != noErr) {
|
|
1238
|
+
//printf("Error calling AudioUnitGetPropertyInfo - kAudioOutputUnitProperty_ChannelMap 0\n");
|
|
1239
|
+
//printError(err);
|
|
1240
|
+
} else {
|
|
1241
|
+
fPhysicalOutputs = outSize / sizeof(SInt32);
|
|
1242
|
+
//printf("fPhysicalOutputs = %ld\n", fPhysicalOutputs);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/*
|
|
1246
|
+
Just ignore this case : seems to work without any further change...
|
|
1247
|
+
|
|
1248
|
+
if (outChannelOffset + outChan > fPhysicalOutputs) {
|
|
1249
|
+
printf("This device hasn't required output channels\n");
|
|
1250
|
+
goto error;
|
|
1251
|
+
}
|
|
1252
|
+
if (inChan > fPhysicalInputs) {
|
|
1253
|
+
printf("This device hasn't required input channels\n");
|
|
1254
|
+
goto error;
|
|
1255
|
+
}
|
|
1256
|
+
*/
|
|
1257
|
+
|
|
1258
|
+
if (inChan < fPhysicalInputs) {
|
|
1259
|
+
SInt32 chanArr[fPhysicalInputs];
|
|
1260
|
+
for (int i = 0; i < fPhysicalInputs; i++) {
|
|
1261
|
+
chanArr[i] = -1;
|
|
1262
|
+
}
|
|
1263
|
+
for (int i = 0; i < inChan; i++) {
|
|
1264
|
+
chanArr[i] = i;
|
|
1265
|
+
}
|
|
1266
|
+
AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_ChannelMap , kAudioUnitScope_Input, 1, chanArr, sizeof(SInt32) * fPhysicalInputs);
|
|
1267
|
+
if (err != noErr) {
|
|
1268
|
+
printf("Error calling AudioUnitSetProperty - kAudioOutputUnitProperty_ChannelMap 1\n");
|
|
1269
|
+
printError(err);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
if (outChan < fPhysicalOutputs) {
|
|
1274
|
+
SInt32 chanArr[fPhysicalOutputs];
|
|
1275
|
+
for (int i = 0; i < fPhysicalOutputs; i++) {
|
|
1276
|
+
chanArr[i] = -1;
|
|
1277
|
+
}
|
|
1278
|
+
for (int i = 0; i < outChan; i++) {
|
|
1279
|
+
// Skip past the output channels belonging to the *input* device, skip to the output channels belonging to the *output* device
|
|
1280
|
+
chanArr[outChannelOffset + i] = i;
|
|
1281
|
+
}
|
|
1282
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Output, 0, chanArr, sizeof(SInt32) * fPhysicalOutputs);
|
|
1283
|
+
if (err != noErr) {
|
|
1284
|
+
printf("Error calling AudioUnitSetProperty - kAudioOutputUnitProperty_ChannelMap 0\n");
|
|
1285
|
+
printError(err);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
if (inChan > 0) {
|
|
1290
|
+
outSize = sizeof(AudioStreamBasicDescription);
|
|
1291
|
+
err = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &srcFormat, &outSize);
|
|
1292
|
+
if (err != noErr) {
|
|
1293
|
+
printf("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output\n");
|
|
1294
|
+
printError(err);
|
|
1295
|
+
}
|
|
1296
|
+
//PrintStreamDesc(&srcFormat);
|
|
1297
|
+
|
|
1298
|
+
srcFormat.mSampleRate = sample_rate;
|
|
1299
|
+
srcFormat.mFormatID = kAudioFormatLinearPCM;
|
|
1300
|
+
srcFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved;
|
|
1301
|
+
srcFormat.mBytesPerPacket = sizeof(float);
|
|
1302
|
+
srcFormat.mFramesPerPacket = 1;
|
|
1303
|
+
srcFormat.mBytesPerFrame = sizeof(float);
|
|
1304
|
+
srcFormat.mChannelsPerFrame = inChan;
|
|
1305
|
+
srcFormat.mBitsPerChannel = 32;
|
|
1306
|
+
|
|
1307
|
+
//PrintStreamDesc(&srcFormat);
|
|
1308
|
+
|
|
1309
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &srcFormat, sizeof(AudioStreamBasicDescription));
|
|
1310
|
+
if (err != noErr) {
|
|
1311
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output\n");
|
|
1312
|
+
printError(err);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
if (outChan > 0) {
|
|
1317
|
+
outSize = sizeof(AudioStreamBasicDescription);
|
|
1318
|
+
err = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &dstFormat, &outSize);
|
|
1319
|
+
if (err != noErr) {
|
|
1320
|
+
printf("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output\n");
|
|
1321
|
+
printError(err);
|
|
1322
|
+
}
|
|
1323
|
+
//PrintStreamDesc(&dstFormat);
|
|
1324
|
+
|
|
1325
|
+
dstFormat.mSampleRate = sample_rate;
|
|
1326
|
+
dstFormat.mFormatID = kAudioFormatLinearPCM;
|
|
1327
|
+
dstFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kLinearPCMFormatFlagIsNonInterleaved;
|
|
1328
|
+
dstFormat.mBytesPerPacket = sizeof(float);
|
|
1329
|
+
dstFormat.mFramesPerPacket = 1;
|
|
1330
|
+
dstFormat.mBytesPerFrame = sizeof(float);
|
|
1331
|
+
dstFormat.mChannelsPerFrame = outChan;
|
|
1332
|
+
dstFormat.mBitsPerChannel = 32;
|
|
1333
|
+
|
|
1334
|
+
//PrintStreamDesc(&dstFormat);
|
|
1335
|
+
|
|
1336
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &dstFormat, sizeof(AudioStreamBasicDescription));
|
|
1337
|
+
if (err != noErr) {
|
|
1338
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output\n");
|
|
1339
|
+
printError(err);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
if (inChan > 0 && outChan == 0) {
|
|
1344
|
+
AURenderCallbackStruct output;
|
|
1345
|
+
output.inputProc = Render;
|
|
1346
|
+
output.inputProcRefCon = this;
|
|
1347
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &output, sizeof(output));
|
|
1348
|
+
if (err != noErr) {
|
|
1349
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_SetRenderCallback 1\n");
|
|
1350
|
+
printError(err);
|
|
1351
|
+
goto error;
|
|
1352
|
+
}
|
|
1353
|
+
} else {
|
|
1354
|
+
AURenderCallbackStruct output;
|
|
1355
|
+
output.inputProc = Render;
|
|
1356
|
+
output.inputProcRefCon = this;
|
|
1357
|
+
err = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &output, sizeof(output));
|
|
1358
|
+
if (err != noErr) {
|
|
1359
|
+
printf("Error calling AudioUnitSetProperty - kAudioUnitProperty_SetRenderCallback 0\n");
|
|
1360
|
+
printError(err);
|
|
1361
|
+
goto error;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
if (inChan > 0) {
|
|
1366
|
+
fInputData = (AudioBufferList*)malloc(sizeof(UInt32) + inChan * sizeof(AudioBuffer));
|
|
1367
|
+
assert(fInputData);
|
|
1368
|
+
fInputData->mNumberBuffers = inChan;
|
|
1369
|
+
|
|
1370
|
+
// Prepare buffers
|
|
1371
|
+
for (int i = 0; i < inChan; i++) {
|
|
1372
|
+
fInputData->mBuffers[i].mNumberChannels = 1;
|
|
1373
|
+
fInputData->mBuffers[i].mData = malloc(fBufferSize * sizeof(float));
|
|
1374
|
+
assert(fInputData->mBuffers[i].mData),
|
|
1375
|
+
fInputData->mBuffers[i].mDataByteSize = fBufferSize * sizeof(float);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
AudioObjectPropertyAddress property_address;
|
|
1380
|
+
property_address.mScope = kAudioObjectPropertyScopeGlobal;
|
|
1381
|
+
property_address.mElement = kAudioObjectPropertyElementMaster;
|
|
1382
|
+
|
|
1383
|
+
property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice;
|
|
1384
|
+
if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, RestartProc, this)) {
|
|
1385
|
+
printf("AudioObjectAddPropertyListener() failed\n");
|
|
1386
|
+
return OPEN_ERR;
|
|
1387
|
+
} else {
|
|
1388
|
+
//printf("AudioObjectAddPropertyListener() OK\n");
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
|
1392
|
+
if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, RestartProc, this)) {
|
|
1393
|
+
printf("AudioObjectAddPropertyListener() failed\n");
|
|
1394
|
+
return OPEN_ERR;
|
|
1395
|
+
} else {
|
|
1396
|
+
//printf("AudioObjectAddPropertyListener() OK\n");
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
return NO_ERR;
|
|
1400
|
+
|
|
1401
|
+
error:
|
|
1402
|
+
AudioUnitUninitialize(fAUHAL);
|
|
1403
|
+
CloseComponent(fAUHAL);
|
|
1404
|
+
fAUHAL = 0;
|
|
1405
|
+
return OPEN_ERR;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
int Close()
|
|
1409
|
+
{
|
|
1410
|
+
if (!fAUHAL) {
|
|
1411
|
+
return CLOSE_ERR;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
for (int i = 0; i < fDevNumInChans; i++) {
|
|
1415
|
+
free(fInputData->mBuffers[i].mData);
|
|
1416
|
+
}
|
|
1417
|
+
if (fInputData) {
|
|
1418
|
+
free(fInputData);
|
|
1419
|
+
}
|
|
1420
|
+
AudioUnitUninitialize(fAUHAL);
|
|
1421
|
+
CloseComponent(fAUHAL);
|
|
1422
|
+
fAUHAL = NULL;
|
|
1423
|
+
|
|
1424
|
+
DestroyAggregateDevice();
|
|
1425
|
+
|
|
1426
|
+
delete[] fInChannel;
|
|
1427
|
+
delete[] fOutChannel;
|
|
1428
|
+
|
|
1429
|
+
AudioObjectPropertyAddress property_address;
|
|
1430
|
+
property_address.mScope = kAudioObjectPropertyScopeGlobal;
|
|
1431
|
+
property_address.mElement = kAudioObjectPropertyElementMaster;
|
|
1432
|
+
|
|
1433
|
+
property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice;
|
|
1434
|
+
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, RestartProc, this);
|
|
1435
|
+
|
|
1436
|
+
property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
|
1437
|
+
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, RestartProc, this);
|
|
1438
|
+
|
|
1439
|
+
return NO_ERR;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
int Start()
|
|
1443
|
+
{
|
|
1444
|
+
if (!fAUHAL) {
|
|
1445
|
+
return OPEN_ERR;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
OSStatus err = AudioOutputUnitStart(fAUHAL);
|
|
1449
|
+
|
|
1450
|
+
if (err != noErr) {
|
|
1451
|
+
printf("Error while opening device : device open error \n");
|
|
1452
|
+
return OPEN_ERR;
|
|
1453
|
+
} else {
|
|
1454
|
+
return NO_ERR;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
int Stop()
|
|
1459
|
+
{
|
|
1460
|
+
if (!fAUHAL) {
|
|
1461
|
+
return OPEN_ERR;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
OSStatus err = AudioOutputUnitStop(fAUHAL);
|
|
1465
|
+
|
|
1466
|
+
if (err != noErr) {
|
|
1467
|
+
printf("Error while closing device : device close error \n");
|
|
1468
|
+
return OPEN_ERR;
|
|
1469
|
+
} else {
|
|
1470
|
+
return NO_ERR;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
void setDsp(dsp* DSP)
|
|
1475
|
+
{
|
|
1476
|
+
fDSP = DSP;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
int GetNumInputs() { return fPhysicalInputs; }
|
|
1480
|
+
int GetNumOutputs() { return fPhysicalOutputs; }
|
|
1481
|
+
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
/******************************************************************************
|
|
1485
|
+
*******************************************************************************
|
|
1486
|
+
|
|
1487
|
+
CORE AUDIO INTERFACE
|
|
1488
|
+
|
|
1489
|
+
*******************************************************************************
|
|
1490
|
+
*******************************************************************************/
|
|
1491
|
+
class coreaudio : public audio {
|
|
1492
|
+
|
|
1493
|
+
protected:
|
|
1494
|
+
|
|
1495
|
+
TCoreAudioRenderer fAudioDevice;
|
|
1496
|
+
int fSampleRate, fBufferSize;
|
|
1497
|
+
|
|
1498
|
+
public:
|
|
1499
|
+
|
|
1500
|
+
coreaudio(int srate, int bsize) : fAudioDevice(this), fSampleRate(srate), fBufferSize(bsize) {}
|
|
1501
|
+
coreaudio(int bsize) : fAudioDevice(this), fSampleRate(-1), fBufferSize(bsize) {}
|
|
1502
|
+
virtual ~coreaudio() { fAudioDevice.Close(); }
|
|
1503
|
+
|
|
1504
|
+
virtual bool init(const char* /*name*/, dsp* DSP)
|
|
1505
|
+
{
|
|
1506
|
+
if (fAudioDevice.OpenDefault(DSP, DSP->getNumInputs(), DSP->getNumOutputs(), fBufferSize, fSampleRate) < 0) {
|
|
1507
|
+
printf("Cannot open CoreAudio device\n");
|
|
1508
|
+
return false;
|
|
1509
|
+
}
|
|
1510
|
+
fAudioDevice.setDsp(DSP);
|
|
1511
|
+
// If -1 was given, fSampleRate will be changed by OpenDefault
|
|
1512
|
+
DSP->init(fSampleRate);
|
|
1513
|
+
return true;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
virtual bool start()
|
|
1517
|
+
{
|
|
1518
|
+
if (fAudioDevice.Start() < 0) {
|
|
1519
|
+
printf("Cannot start CoreAudio device\n");
|
|
1520
|
+
return false;
|
|
1521
|
+
}
|
|
1522
|
+
return true;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
virtual void stop()
|
|
1526
|
+
{
|
|
1527
|
+
fAudioDevice.Stop();
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
virtual int getBufferSize() { return fAudioDevice.GetBufferSize(); }
|
|
1531
|
+
virtual int getSampleRate() { return fAudioDevice.GetSampleRate(); }
|
|
1532
|
+
|
|
1533
|
+
virtual int getNumInputs() { return fAudioDevice.GetNumInputs(); }
|
|
1534
|
+
virtual int getNumOutputs() { return fAudioDevice.GetNumOutputs(); }
|
|
1535
|
+
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
#endif
|
|
1539
|
+
|
|
1540
|
+
/********************END ARCHITECTURE SECTION (part 2/2)****************/
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
/************************** END coreaudio-dsp.h **************************/
|