├── Archives ├── AudioUnitExamples.zip └── CoreAudioUtilityClasses.zip ├── Audio Unit ├── AUBase.xctemplate │ ├── AUPublic │ │ ├── AUBase │ │ │ ├── AUBase.cpp │ │ │ ├── AUBase.h │ │ │ ├── AUDispatch.cpp │ │ │ ├── AUDispatch.h │ │ │ ├── AUInputElement.cpp │ │ │ ├── AUInputElement.h │ │ │ ├── AUOutputElement.cpp │ │ │ ├── AUOutputElement.h │ │ │ ├── AUPluginDispatch.cpp │ │ │ ├── AUPluginDispatch.h │ │ │ ├── AUScopeElement.cpp │ │ │ ├── AUScopeElement.h │ │ │ ├── ComponentBase.cpp │ │ │ └── ComponentBase.h │ │ └── Utility │ │ │ ├── AUBuffer.cpp │ │ │ └── AUBuffer.h │ └── TemplateInfo.plist ├── Effect Unit.xctemplate │ ├── AUPublic │ │ ├── OtherBases │ │ │ ├── AUEffectBase.cpp │ │ │ └── AUEffectBase.h │ │ └── Utility │ │ │ ├── AUBaseHelper.cpp │ │ │ ├── AUBaseHelper.h │ │ │ └── AUSilentTimeout.h │ ├── PublicUtility │ │ ├── CAAtomic.h │ │ ├── CAAtomicStack.h │ │ ├── CAAudioChannelLayout.cpp │ │ ├── CAAudioChannelLayout.h │ │ ├── CAAutoDisposer.h │ │ ├── CABufferList.cpp │ │ ├── CABufferList.h │ │ ├── CAByteOrder.h │ │ ├── CADebugMacros.cpp │ │ ├── CADebugMacros.h │ │ ├── CADebugPrintf.h │ │ ├── CADebugger.cpp │ │ ├── CADebugger.h │ │ ├── CAException.h │ │ ├── CAGuard.cpp │ │ ├── CAGuard.h │ │ ├── CAHostTimeBase.cpp │ │ ├── CAHostTimeBase.h │ │ ├── CALogMacros.h │ │ ├── CAMath.h │ │ ├── CAMutex.cpp │ │ ├── CAMutex.h │ │ ├── CAReferenceCounted.h │ │ ├── CAStreamBasicDescription.cpp │ │ ├── CAStreamBasicDescription.h │ │ ├── CAThreadSafeList.h │ │ ├── CAVectorUnit.cpp │ │ ├── CAVectorUnit.h │ │ ├── CAVectorUnitTypes.h │ │ ├── CAXException.cpp │ │ └── CAXException.h │ ├── TemplateIcon.icns │ ├── TemplateInfo.plist │ ├── ___PACKAGENAMEASIDENTIFIER___.cpp │ ├── ___PACKAGENAMEASIDENTIFIER___.h │ ├── ___PACKAGENAMEASIDENTIFIER___Version.h │ └── ___PACKAGENAMEASIDENTIFIER____Prefix.pch └── Monotimbral Synth.xctemplate │ ├── AUPublic │ ├── AUInstrumentBase │ │ ├── AUInstrumentBase.cpp │ │ ├── AUInstrumentBase.h │ │ ├── LockFreeFIFO.h │ │ ├── MIDIControlHandler.h │ │ ├── SynthElement.cpp │ │ ├── SynthElement.h │ │ ├── SynthEvent.h │ │ ├── SynthNote.cpp │ │ ├── SynthNote.h │ │ ├── SynthNoteList.cpp │ │ └── SynthNoteList.h │ ├── OtherBases │ │ ├── AUMIDIBase.cpp │ │ ├── AUMIDIBase.h │ │ ├── MusicDeviceBase.cpp │ │ └── MusicDeviceBase.h │ └── Utility │ │ ├── AUBaseHelper.cpp │ │ ├── AUBaseHelper.h │ │ └── AUMIDIDefs.h │ ├── PublicUtility │ ├── CAAUMIDIMap.cpp │ ├── CAAUMIDIMap.h │ ├── CAAUMIDIMapManager.cpp │ ├── CAAUMIDIMapManager.h │ ├── CAAtomic.h │ ├── CAAtomicStack.h │ ├── CAAudioChannelLayout.cpp │ ├── CAAudioChannelLayout.h │ ├── CAAutoDisposer.h │ ├── CABufferList.cpp │ ├── CABufferList.h │ ├── CAByteOrder.h │ ├── CADebugMacros.h │ ├── CADebugPrintf.cpp │ ├── CADebugPrintf.h │ ├── CAException.h │ ├── CAHostTimeBase.cpp │ ├── CAHostTimeBase.h │ ├── CAMath.h │ ├── CAMutex.cpp │ ├── CAMutex.h │ ├── CAReferenceCounted.h │ ├── CAStreamBasicDescription.cpp │ ├── CAStreamBasicDescription.h │ ├── CAThreadSafeList.h │ ├── CAVectorUnit.cpp │ ├── CAVectorUnit.h │ ├── CAVectorUnitTypes.h │ ├── CAXException.cpp │ └── CAXException.h │ ├── TemplateIcon.icns │ ├── TemplateInfo.plist │ ├── ___PACKAGENAMEASIDENTIFIER___.cpp │ ├── ___PACKAGENAMEASIDENTIFIER___.h │ ├── ___PACKAGENAMEASIDENTIFIER___Version.h │ └── ___PACKAGENAMEASIDENTIFIER____Prefix.pch ├── README.md ├── install.sh └── scripts ├── README.md ├── print-source-hierarchy.py ├── read-template └── templates.py /Archives/AudioUnitExamples.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbob/AudioUnitTemplates/c7133512777705c0ae727e2df57e9ccd61088549/Archives/AudioUnitExamples.zip -------------------------------------------------------------------------------- /Archives/CoreAudioUtilityClasses.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbob/AudioUnitTemplates/c7133512777705c0ae727e2df57e9ccd61088549/Archives/CoreAudioUtilityClasses.zip -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUDispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUDispatch.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUDispatch_h__ 48 | #define __AUDispatch_h__ 49 | 50 | 51 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 52 | #include 53 | #else 54 | #include "AudioUnit.h" 55 | #endif 56 | 57 | #if !CA_USE_AUDIO_PLUGIN_ONLY 58 | /*! @function AudioUnitBaseGetParameter */ 59 | OSStatus CMgr_AudioUnitBaseGetParameter( AUBase * This, 60 | AudioUnitParameterID inID, 61 | AudioUnitScope inScope, 62 | AudioUnitElement inElement, 63 | float * outValue); 64 | 65 | /*! @function AudioUnitBaseSetParameter */ 66 | OSStatus CMgr_AudioUnitBaseSetParameter( AUBase * This, 67 | AudioUnitParameterID inID, 68 | AudioUnitScope inScope, 69 | AudioUnitElement inElement, 70 | float inValue, 71 | UInt32 inBufferOffset); 72 | 73 | /*! @function AudioUnitBaseRender */ 74 | OSStatus CMgr_AudioUnitBaseRender( AUBase * This, 75 | AudioUnitRenderActionFlags *ioActionFlags, 76 | const AudioTimeStamp * inTimeStamp, 77 | UInt32 inBusNumber, 78 | UInt32 inNumberFrames, 79 | AudioBufferList * ioData); 80 | #endif 81 | 82 | #endif // __AUDispatch_h__ 83 | -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUInputElement.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUInputElement.cpp 3 | Abstract: AUInputElement.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "AUBase.h" 48 | 49 | inline bool HasGoodBufferPointers(const AudioBufferList &abl, UInt32 nBytes) 50 | { 51 | const AudioBuffer *buf = abl.mBuffers; 52 | for (UInt32 i = abl.mNumberBuffers; i--;++buf) { 53 | if (buf->mData == NULL || buf->mDataByteSize < nBytes) 54 | return false; 55 | } 56 | return true; 57 | } 58 | 59 | 60 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 | // AUInputElement::AUInputElement 62 | // 63 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 | AUInputElement::AUInputElement(AUBase *audioUnit) : 65 | AUIOElement(audioUnit), 66 | mInputType(kNoInput) 67 | { 68 | } 69 | 70 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 71 | // AUInputElement::SetConnection 72 | // 73 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74 | void AUInputElement::SetConnection(const AudioUnitConnection &conn) 75 | { 76 | if (conn.sourceAudioUnit == 0) { 77 | Disconnect(); 78 | return; 79 | } 80 | 81 | mInputType = kFromConnection; 82 | mConnection = conn; 83 | AllocateBuffer(); 84 | 85 | mConnInstanceStorage = NULL; 86 | 87 | #if !CA_USE_AUDIO_PLUGIN_ONLY 88 | mConnRenderProc = NULL; 89 | UInt32 size = sizeof(AudioUnitRenderProc); 90 | OSStatus result = AudioUnitGetProperty( conn.sourceAudioUnit, 91 | kAudioUnitProperty_FastDispatch, 92 | kAudioUnitScope_Global, 93 | kAudioUnitRenderSelect, 94 | &mConnRenderProc, 95 | &size); 96 | if (result == noErr) 97 | mConnInstanceStorage = CMgr_GetComponentInstanceStorage (conn.sourceAudioUnit); 98 | else 99 | mConnRenderProc = NULL; 100 | #endif 101 | } 102 | 103 | void AUInputElement::Disconnect() 104 | { 105 | mInputType = kNoInput; 106 | mIOBuffer.Deallocate(); 107 | } 108 | 109 | 110 | 111 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 112 | // AUInputElement::SetInputCallback 113 | // 114 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | void AUInputElement::SetInputCallback(AURenderCallback proc, void *refCon) 116 | { 117 | if (proc == NULL) 118 | Disconnect(); 119 | else { 120 | mInputType = kFromCallback; 121 | mInputProc = proc; 122 | mInputProcRefCon = refCon; 123 | AllocateBuffer(); 124 | } 125 | } 126 | 127 | OSStatus AUInputElement::SetStreamFormat(const CAStreamBasicDescription &fmt) 128 | { 129 | OSStatus err = AUIOElement::SetStreamFormat(fmt); 130 | if (err == AUBase::noErr) 131 | AllocateBuffer(); 132 | return err; 133 | } 134 | 135 | OSStatus AUInputElement::PullInput( AudioUnitRenderActionFlags & ioActionFlags, 136 | const AudioTimeStamp & inTimeStamp, 137 | AudioUnitElement inElement, 138 | UInt32 nFrames) 139 | { 140 | if (!IsActive()) 141 | return kAudioUnitErr_NoConnection; 142 | 143 | AudioBufferList *pullBuffer; 144 | 145 | if (HasConnection() || !WillAllocateBuffer()) 146 | pullBuffer = &mIOBuffer.PrepareNullBuffer(mStreamFormat, nFrames); 147 | else 148 | pullBuffer = &mIOBuffer.PrepareBuffer(mStreamFormat, nFrames); 149 | 150 | return PullInputWithBufferList (ioActionFlags, inTimeStamp, inElement, nFrames, pullBuffer); 151 | } 152 | -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUInputElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUInputElement.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUInput_h__ 48 | #define __AUInput_h__ 49 | 50 | #include "AUScopeElement.h" 51 | #include "AUBuffer.h" 52 | 53 | /*! @class AUInputElement */ 54 | class AUInputElement : public AUIOElement { 55 | public: 56 | 57 | /*! @ctor AUInputElement */ 58 | AUInputElement(AUBase *audioUnit); 59 | /*! @dtor ~AUInputElement */ 60 | virtual ~AUInputElement() { } 61 | 62 | // AUElement override 63 | /*! @method SetStreamFormat */ 64 | virtual OSStatus SetStreamFormat(const CAStreamBasicDescription &desc); 65 | /*! @method NeedsBufferSpace */ 66 | virtual bool NeedsBufferSpace() const { return IsCallback(); } 67 | 68 | /*! @method SetConnection */ 69 | void SetConnection(const AudioUnitConnection &conn); 70 | /*! @method SetInputCallback */ 71 | void SetInputCallback(AURenderCallback proc, void *refCon); 72 | 73 | /*! @method IsActive */ 74 | bool IsActive() const { return mInputType != kNoInput; } 75 | /*! @method IsCallback */ 76 | bool IsCallback() const { return mInputType == kFromCallback; } 77 | /*! @method HasConnection */ 78 | bool HasConnection() const { return mInputType == kFromConnection; } 79 | 80 | /*! @method PullInput */ 81 | OSStatus PullInput( AudioUnitRenderActionFlags & ioActionFlags, 82 | const AudioTimeStamp & inTimeStamp, 83 | AudioUnitElement inElement, 84 | UInt32 inNumberFrames); 85 | 86 | /*! @method PullInputWithBufferList */ 87 | OSStatus PullInputWithBufferList( AudioUnitRenderActionFlags & ioActionFlags, 88 | const AudioTimeStamp & inTimeStamp, 89 | AudioUnitElement inElement, 90 | UInt32 nFrames, 91 | AudioBufferList * inBufferList); 92 | protected: 93 | /*! @method Disconnect */ 94 | void Disconnect(); 95 | 96 | enum EInputType { kNoInput, kFromConnection, kFromCallback }; 97 | 98 | /*! @var mInputType */ 99 | EInputType mInputType; 100 | 101 | // if from callback: 102 | /*! @var mInputProc */ 103 | AURenderCallback mInputProc; 104 | /*! @var mInputProcRefCon */ 105 | void * mInputProcRefCon; 106 | 107 | // if from connection: 108 | /*! @var mConnection */ 109 | AudioUnitConnection mConnection; 110 | #if !CA_USE_AUDIO_PLUGIN_ONLY 111 | /*! @var mConnRenderProc */ 112 | AudioUnitRenderProc mConnRenderProc; 113 | #endif 114 | /*! @var mConnInstanceStorage */ 115 | void * mConnInstanceStorage; // for the input component 116 | }; 117 | 118 | 119 | #endif // __AUInput_h__ 120 | -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUOutputElement.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUOutputElement.cpp 3 | Abstract: AUOutputElement.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "AUOutputElement.h" 48 | #include "AUBase.h" 49 | 50 | AUOutputElement::AUOutputElement(AUBase *audioUnit) : 51 | AUIOElement(audioUnit) 52 | { 53 | AllocateBuffer(); 54 | } 55 | 56 | OSStatus AUOutputElement::SetStreamFormat(const CAStreamBasicDescription &desc) 57 | { 58 | OSStatus result = AUIOElement::SetStreamFormat(desc); // inherited 59 | if (result == AUBase::noErr) 60 | AllocateBuffer(); 61 | return result; 62 | } 63 | -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUOutputElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUOutputElement.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUOutput_h__ 48 | #define __AUOutput_h__ 49 | 50 | #include "AUScopeElement.h" 51 | #include "AUBuffer.h" 52 | 53 | /*! @class AUOutputElement */ 54 | class AUOutputElement : public AUIOElement { 55 | public: 56 | /*! @ctor AUOutputElement */ 57 | AUOutputElement(AUBase *audioUnit); 58 | 59 | // AUElement override 60 | /*! @method SetStreamFormat */ 61 | virtual OSStatus SetStreamFormat(const CAStreamBasicDescription &desc); 62 | /*! @method NeedsBufferSpace */ 63 | virtual bool NeedsBufferSpace() const { return true; } 64 | }; 65 | 66 | #endif // __AUOutput_h__ 67 | -------------------------------------------------------------------------------- /Audio Unit/AUBase.xctemplate/AUPublic/AUBase/AUPluginDispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUPlugInDispatch.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUPlugInBase_h__ 48 | #define __AUPlugInBase_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #if !CA_BASIC_AU_FEATURES 53 | #include 54 | #endif 55 | #else 56 | #include "AudioComponent.h" 57 | #include "MusicDevice.h" 58 | #endif 59 | 60 | #include "ComponentBase.h" 61 | 62 | struct AUBaseLookup { 63 | static AudioComponentMethod Lookup (SInt16 selector); 64 | }; 65 | template 66 | class AUBaseFactory : public APFactory 67 | { 68 | }; 69 | 70 | struct AUOutputLookup { 71 | static AudioComponentMethod Lookup (SInt16 selector); 72 | }; 73 | template 74 | class AUOutputBaseFactory : public APFactory 75 | { 76 | }; 77 | 78 | struct AUComplexOutputLookup { 79 | static AudioComponentMethod Lookup (SInt16 selector); 80 | }; 81 | template 82 | class AUOutputComplexBaseFactory : public APFactory 83 | { 84 | }; 85 | 86 | struct AUBaseProcessLookup { 87 | static AudioComponentMethod Lookup (SInt16 selector); 88 | }; 89 | template 90 | class AUBaseProcessFactory : public APFactory 91 | { 92 | }; 93 | 94 | struct AUBaseProcessMultipleLookup { 95 | static AudioComponentMethod Lookup (SInt16 selector); 96 | }; 97 | template 98 | class AUBaseProcessMultipleFactory : public APFactory 99 | { 100 | }; 101 | 102 | struct AUBaseProcessAndMultipleLookup { 103 | static AudioComponentMethod Lookup (SInt16 selector); 104 | }; 105 | template 106 | class AUBaseProcessAndMultipleFactory : public APFactory 107 | { 108 | }; 109 | 110 | #if !CA_BASIC_AU_FEATURES 111 | struct AUMIDILookup { 112 | static AudioComponentMethod Lookup (SInt16 selector); 113 | }; 114 | template 115 | class AUMIDIEffectFactory : public APFactory 116 | { 117 | }; 118 | 119 | struct AUMIDIProcessLookup { 120 | static AudioComponentMethod Lookup (SInt16 selector); 121 | }; 122 | template 123 | class AUMIDIProcessFactory : public APFactory 124 | { 125 | }; 126 | 127 | struct AUMusicLookup { 128 | static AudioComponentMethod Lookup (SInt16 selector); 129 | }; 130 | template 131 | class AUMusicDeviceFactory : public APFactory 132 | { 133 | }; 134 | 135 | struct AUAuxBaseLookup { 136 | static AudioComponentMethod Lookup (SInt16 selector); 137 | }; 138 | template 139 | class AUAuxBaseFactory : public APFactory 140 | { 141 | }; 142 | #endif // CA_BASIC_AU_FEATURES 143 | 144 | #endif // __AUPlugInBase_h__ 145 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/AUPublic/Utility/AUBaseHelper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUBaseHelper.cpp 3 | Abstract: AUBaseHelper.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "AUBaseHelper.h" 48 | 49 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 50 | #include 51 | #else 52 | #include 53 | #endif 54 | 55 | OSStatus GetFileRefPath (CFDictionaryRef parent, CFStringRef frKey, CFStringRef * fPath) 56 | { 57 | static CFStringRef kFRString = CFSTR (kAUPresetExternalFileRefs); 58 | 59 | const void* frVal = CFDictionaryGetValue(parent, kFRString); 60 | if (!frVal) return kAudioUnitErr_InvalidPropertyValue; 61 | 62 | const void* frString = CFDictionaryGetValue ((CFDictionaryRef)frVal, frKey); 63 | if (!frString) return kAudioUnitErr_InvalidPropertyValue; 64 | 65 | if (fPath) 66 | *fPath = (CFStringRef)frString; 67 | 68 | return noErr; 69 | } 70 | 71 | CFMutableDictionaryRef CreateFileRefDict (CFStringRef fKey, CFStringRef fPath, CFMutableDictionaryRef fileRefDict) 72 | { 73 | if (!fileRefDict) 74 | fileRefDict = CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 75 | 76 | CFDictionarySetValue (fileRefDict, fKey, fPath); 77 | 78 | return fileRefDict; 79 | } 80 | 81 | #if TARGET_OS_MAC 82 | // check if the URL can be accessed for reading/writing. Returns 0 if yes, or the error value. 83 | int AccessURLAsset(const CFURLRef inURL, int mode) 84 | { 85 | char path[PATH_MAX]; 86 | if (CFURLGetFileSystemRepresentation(inURL, TRUE, (UInt8 *)path, PATH_MAX) == FALSE) 87 | return kAudio_FileNotFoundError; 88 | // check whether we have access 89 | int ret = access(path, mode); 90 | // syslog(LOG_CRIT, "access() error is %d for \"%s\".\n", ret, path); 91 | if (ret == 0) return 0; 92 | switch (errno) { 93 | case EACCES: 94 | case EPERM: 95 | return -54; /*permission denied error*/ 96 | case ENOENT: 97 | case ENOTDIR: 98 | case ELOOP: 99 | return kAudio_FileNotFoundError; 100 | default: 101 | return errno; 102 | } 103 | } 104 | #endif 105 | 106 | #if DEBUG 107 | //_____________________________________________________________________________ 108 | // 109 | void PrintAUParamEvent (AudioUnitParameterEvent& event, FILE* f) 110 | { 111 | bool isRamp = event.eventType == kParameterEvent_Ramped; 112 | fprintf (f, "\tParamID=%ld,Scope=%ld,Element=%ld\n", (long)event.parameter, (long)event.scope, (long)event.element); 113 | fprintf (f, "\tEvent Type:%s,", (isRamp ? "ramp" : "immediate")); 114 | if (isRamp) 115 | fprintf (f, "start=%ld,dur=%ld,startValue=%f,endValue=%f\n", 116 | (long)event.eventValues.ramp.startBufferOffset, (long)event.eventValues.ramp.durationInFrames, 117 | event.eventValues.ramp.startValue, event.eventValues.ramp.endValue); 118 | else 119 | fprintf (f, "start=%ld,value=%f\n", 120 | (long)event.eventValues.immediate.bufferOffset, 121 | event.eventValues.immediate.value); 122 | fprintf (f, "- - - - - - - - - - - - - - - -\n"); 123 | } 124 | #endif 125 | 126 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/AUPublic/Utility/AUBaseHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUBaseHelper.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUBaseHelper_h__ 48 | #define __AUBaseHelper_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #include 56 | #endif 57 | 58 | #include "AUBase.h" 59 | 60 | // helpers for dealing with the file-references dictionary in an AUPreset 61 | OSStatus GetFileRefPath (CFDictionaryRef parent, CFStringRef frKey, CFStringRef * fPath); 62 | 63 | // if fileRefDict is NULL, this call creates one 64 | // if not NULL, then the key value is added to it 65 | CFMutableDictionaryRef CreateFileRefDict (CFStringRef fKey, CFStringRef fPath, CFMutableDictionaryRef fileRefDict); 66 | 67 | int AccessURLAsset(const CFURLRef inURL, int mode); 68 | 69 | #if DEBUG 70 | void PrintAUParamEvent (AudioUnitParameterEvent& event, FILE* f); 71 | #endif 72 | 73 | 74 | 75 | #endif // __AUBaseHelper_h__ -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/AUPublic/Utility/AUSilentTimeout.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUSilentTimeout.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUSilentTimeout 48 | #define __AUSilentTimeout 49 | 50 | class AUSilentTimeout 51 | { 52 | public: 53 | AUSilentTimeout() 54 | : mTimeoutCounter(0), 55 | mResetTimer(true) 56 | {}; 57 | 58 | void Process(UInt32 inFramesToProcess, UInt32 inTimeoutLimit, bool &ioSilence ) 59 | { 60 | if(ioSilence ) 61 | { 62 | if(mResetTimer ) 63 | { 64 | mTimeoutCounter = inTimeoutLimit; 65 | mResetTimer = false; 66 | } 67 | 68 | if(mTimeoutCounter > 0 ) 69 | { 70 | mTimeoutCounter -= inFramesToProcess; 71 | ioSilence = false; 72 | } 73 | } 74 | else 75 | { 76 | // signal to reset the next time we receive silence 77 | mResetTimer = true; 78 | } 79 | } 80 | 81 | void Reset() 82 | { 83 | mResetTimer = true; 84 | }; 85 | 86 | 87 | 88 | private: 89 | SInt32 mTimeoutCounter; 90 | bool mResetTimer; 91 | }; 92 | 93 | #endif // __AUSilentTimeout 94 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAByteOrder.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAByteOrder.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CAByteOrder_h__) 48 | #define __CAByteOrder_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | // System Includes 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include "CoreFoundation.h" 59 | #endif 60 | 61 | 62 | #if defined(__cplusplus) 63 | extern "C" { 64 | #endif 65 | 66 | CF_INLINE Float32 CASwapFloat32 (Float32 arg) { 67 | union { 68 | Float32 f; 69 | UInt32 i; 70 | } flip; 71 | 72 | flip.f = arg; 73 | flip.i = CFSwapInt32 (flip.i); 74 | 75 | return flip.f; 76 | } 77 | 78 | CF_INLINE Float64 CASwapFloat64 (Float64 arg) { 79 | union { 80 | Float64 f; 81 | UInt64 i; 82 | } flip; 83 | 84 | flip.f = arg; 85 | flip.i = CFSwapInt64 (flip.i); 86 | 87 | return flip.f; 88 | } 89 | 90 | #pragma mark -Flippers 91 | 92 | CF_INLINE Float32 CASwapFloat32BigToHost(Float32 arg) { 93 | #if defined(__BIG_ENDIAN__) 94 | return arg; 95 | #else 96 | return CASwapFloat32(arg); 97 | #endif 98 | } 99 | 100 | CF_INLINE Float64 CASwapFloat64BigToHost(Float64 arg) { 101 | #if defined(__BIG_ENDIAN__) 102 | return arg; 103 | #else 104 | return CASwapFloat64(arg); 105 | #endif 106 | } 107 | 108 | CF_INLINE Float32 CASwapFloat32HostToBig(Float32 arg) { 109 | #if defined(__BIG_ENDIAN__) 110 | return arg; 111 | #else 112 | return CASwapFloat32(arg); 113 | #endif 114 | } 115 | 116 | CF_INLINE Float64 CASwapFloat64HostToBig(Float64 arg) { 117 | #if defined(__BIG_ENDIAN__) 118 | return arg; 119 | #else 120 | return CASwapFloat64(arg); 121 | #endif 122 | } 123 | 124 | CF_INLINE Float32 CASwapFloat32LittleToHost(Float32 arg) { 125 | #if defined(__LITTLE_ENDIAN__) 126 | return arg; 127 | #else 128 | return CASwapFloat32(arg); 129 | #endif 130 | } 131 | 132 | CF_INLINE Float64 CASwapFloat64LittleToHost(Float64 arg) { 133 | #if defined(__LITTLE_ENDIAN__) 134 | return arg; 135 | #else 136 | return CASwapFloat64(arg); 137 | #endif 138 | } 139 | 140 | CF_INLINE Float32 CASwapFloat32HostToLittle(Float32 arg) { 141 | #if defined(__LITTLE_ENDIAN__) 142 | return arg; 143 | #else 144 | return CASwapFloat32(arg); 145 | #endif 146 | } 147 | 148 | CF_INLINE Float64 CASwapFloat64HostToLittle(Float64 arg) { 149 | #if defined(__LITTLE_ENDIAN__) 150 | return arg; 151 | #else 152 | return CASwapFloat64(arg); 153 | #endif 154 | } 155 | 156 | 157 | #if defined(__cplusplus) 158 | } 159 | #endif 160 | 161 | #endif 162 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CADebugMacros.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugMacros.cpp 3 | Abstract: CADebugMacros.h 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "CADebugMacros.h" 48 | #include 49 | #include 50 | #if TARGET_API_MAC_OSX 51 | #include 52 | #endif 53 | 54 | #if DEBUG 55 | #include 56 | 57 | void DebugPrint(const char *fmt, ...) 58 | { 59 | va_list args; 60 | va_start(args, fmt); 61 | vprintf(fmt, args); 62 | va_end(args); 63 | } 64 | #endif // DEBUG 65 | 66 | void LogError(const char *fmt, ...) 67 | { 68 | va_list args; 69 | va_start(args, fmt); 70 | #if DEBUG 71 | vprintf(fmt, args); 72 | #endif 73 | #if TARGET_API_MAC_OSX 74 | vsyslog(LOG_ERR, fmt, args); 75 | #endif 76 | va_end(args); 77 | } 78 | 79 | void LogWarning(const char *fmt, ...) 80 | { 81 | va_list args; 82 | va_start(args, fmt); 83 | #if DEBUG 84 | vprintf(fmt, args); 85 | #endif 86 | #if TARGET_API_MAC_OSX 87 | vsyslog(LOG_WARNING, fmt, args); 88 | #endif 89 | va_end(args); 90 | } 91 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CADebugPrintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugPrintf.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CADebugPrintf_h__) 48 | #define __CADebugPrintf_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 55 | #include 56 | #else 57 | #include "CoreAudioTypes.h" 58 | #endif 59 | 60 | //============================================================================= 61 | // Macros to redirect debugging output to various logging services 62 | //============================================================================= 63 | 64 | //#define CoreAudio_UseSysLog 1 65 | //#define CoreAudio_UseSideFile "/CoreAudio-%d.txt" 66 | 67 | #if DEBUG || CoreAudio_Debug 68 | 69 | #if TARGET_OS_WIN32 70 | #if defined(__cplusplus) 71 | extern "C" 72 | #endif 73 | extern int CAWin32DebugPrintf(char* inFormat, ...); 74 | #define DebugPrintfRtn CAWin32DebugPrintf 75 | #define DebugPrintfFile 76 | #define DebugPrintfLineEnding "\n" 77 | #define DebugPrintfFileComma 78 | #else 79 | #if CoreAudio_UseSysLog 80 | #include 81 | #define DebugPrintfRtn syslog 82 | #define DebugPrintfFile LOG_NOTICE 83 | #define DebugPrintfLineEnding "" 84 | #define DebugPrintfFileComma DebugPrintfFile, 85 | #elif defined(CoreAudio_UseSideFile) 86 | #include 87 | #if defined(__cplusplus) 88 | extern "C" 89 | #endif 90 | void OpenDebugPrintfSideFile(); 91 | extern FILE* sDebugPrintfSideFile; 92 | #define DebugPrintfRtn fprintf 93 | #define DebugPrintfFile ((sDebugPrintfSideFile != NULL) ? sDebugPrintfSideFile : stderr) 94 | #define DebugPrintfLineEnding "\n" 95 | #define DebugPrintfFileComma DebugPrintfFile, 96 | #else 97 | #include 98 | #define DebugPrintfRtn fprintf 99 | #define DebugPrintfFile stderr 100 | #define DebugPrintfLineEnding "\n" 101 | #define DebugPrintfFileComma DebugPrintfFile, 102 | #endif 103 | #endif 104 | 105 | #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__) 106 | #else 107 | #define DebugPrintfRtn 108 | #define DebugPrintfFile 109 | #define DebugPrintfLineEnding 110 | #define DebugPrintfFileComma 111 | #define DebugPrintf(inFormat, ...) 112 | #endif 113 | 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CADebugger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugger.cpp 3 | Abstract: CADebugger.h 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | //============================================================================= 48 | // Includes 49 | //============================================================================= 50 | 51 | #include "CADebugger.h" 52 | 53 | //============================================================================= 54 | // CADebugger 55 | //============================================================================= 56 | 57 | #if TARGET_API_MAC_OSX 58 | 59 | #include 60 | #include 61 | #include 62 | 63 | bool CAIsDebuggerAttached(void) 64 | { 65 | int mib[4]; 66 | struct kinfo_proc info; 67 | size_t size; 68 | 69 | mib[0] = CTL_KERN; 70 | mib[1] = KERN_PROC; 71 | mib[2] = KERN_PROC_PID; 72 | mib[3] = getpid(); 73 | size = sizeof(info); 74 | info.kp_proc.p_flag = 0; 75 | 76 | sysctl(mib, 4, &info, &size, NULL, 0); 77 | 78 | return (info.kp_proc.p_flag & P_TRACED) == P_TRACED; 79 | } 80 | 81 | #endif 82 | 83 | void CADebuggerStop(void) 84 | { 85 | #if CoreAudio_Debug 86 | #if TARGET_API_MAC_OSX 87 | if(CAIsDebuggerAttached()) 88 | { 89 | #if defined(__i386__) || defined(__x86_64__) 90 | asm("int3"); 91 | #else 92 | __builtin_trap(); 93 | #endif 94 | } 95 | else 96 | { 97 | abort(); 98 | } 99 | #else 100 | __debugbreak(); 101 | #endif 102 | #endif 103 | } 104 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CADebugger.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugger.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CADebugger_h__) 48 | #define __CADebugger_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 55 | #include 56 | #else 57 | #include 58 | #endif 59 | 60 | //============================================================================= 61 | // CADebugger 62 | //============================================================================= 63 | 64 | #if TARGET_API_MAC_OSX 65 | extern bool CAIsDebuggerAttached(void); 66 | #endif 67 | extern void CADebuggerStop(void); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAException.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAException.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CAException_h__) 48 | #define __CAException_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 55 | #include 56 | #else 57 | #include "CoreAudioTypes.h" 58 | #endif 59 | 60 | //============================================================================= 61 | // CAException 62 | //============================================================================= 63 | 64 | class CAException 65 | { 66 | 67 | public: 68 | CAException(OSStatus inError) : mError(inError) {} 69 | CAException(const CAException& inException) : mError(inException.mError) {} 70 | CAException& operator=(const CAException& inException) { mError = inException.mError; return *this; } 71 | ~CAException() {} 72 | 73 | OSStatus GetError() const { return mError; } 74 | 75 | protected: 76 | OSStatus mError; 77 | }; 78 | 79 | #define CATry try{ 80 | #define CACatch } catch(...) {} 81 | #define CASwallowException(inExpression) try { inExpression; } catch(...) {} 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAGuard.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAGuard.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CAGuard_h__) 48 | #define __CAGuard_h__ 49 | 50 | //================================================================================================== 51 | // Includes 52 | //============================================================================= 53 | 54 | // Super Class Includes 55 | #include "CAMutex.h" 56 | 57 | #if CoreAudio_Debug 58 | // #define Log_Average_Latency 1 59 | #endif 60 | 61 | //================================================================================================== 62 | // CAGuard 63 | // 64 | // This is your typical mutex with signalling implemented via pthreads. 65 | // Lock() will return true if and only if the guard is locked on that call. 66 | // A thread that already has the guard will receive 'false' if it locks it 67 | // again. Use of the stack-based CAGuard::Locker class is highly recommended 68 | // to properly manage the recursive nesting. The Wait calls with timeouts 69 | // will return true if and only if the timeout period expired. They will 70 | // return false if they receive notification any other way. 71 | //================================================================================================== 72 | 73 | class CAGuard : public CAMutex 74 | { 75 | 76 | // Construction/Destruction 77 | public: 78 | CAGuard(const char* inName); 79 | virtual ~CAGuard(); 80 | 81 | // Actions 82 | public: 83 | virtual void Wait(); 84 | virtual bool WaitFor(UInt64 inNanos); 85 | virtual bool WaitUntil(UInt64 inNanos); 86 | 87 | virtual void Notify(); 88 | virtual void NotifyAll(); 89 | 90 | // Implementation 91 | protected: 92 | #if TARGET_OS_MAC 93 | pthread_cond_t mCondVar; 94 | #else 95 | HANDLE mEvent; 96 | #endif 97 | #if Log_Average_Latency 98 | Float64 mAverageLatencyAccumulator; 99 | UInt32 mAverageLatencyCount; 100 | #endif 101 | 102 | // Helper class to manage taking and releasing recursively 103 | public: 104 | class Locker 105 | { 106 | 107 | // Construction/Destruction 108 | public: 109 | Locker(CAGuard& inGuard) : mGuard(inGuard), mNeedsRelease(false) { mNeedsRelease = mGuard.Lock(); } 110 | ~Locker() { if(mNeedsRelease) { mGuard.Unlock(); } } 111 | 112 | private: 113 | Locker(const Locker&); 114 | Locker& operator=(const Locker&); 115 | 116 | // Actions 117 | public: 118 | void Wait() { mGuard.Wait(); } 119 | bool WaitFor(UInt64 inNanos) { return mGuard.WaitFor(inNanos); } 120 | bool WaitUntil(UInt64 inNanos) { return mGuard.WaitUntil(inNanos); } 121 | 122 | void Notify() { mGuard.Notify(); } 123 | void NotifyAll() { mGuard.NotifyAll(); } 124 | 125 | // Implementation 126 | private: 127 | CAGuard& mGuard; 128 | bool mNeedsRelease; 129 | }; 130 | 131 | }; 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAHostTimeBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAHostTimeBase.cpp 3 | Abstract: CAHostTimeBase.h 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | //============================================================================= 48 | // Includes 49 | //============================================================================= 50 | 51 | #include "CAHostTimeBase.h" 52 | 53 | Float64 CAHostTimeBase::sFrequency = 0; 54 | Float64 CAHostTimeBase::sInverseFrequency = 0; 55 | UInt32 CAHostTimeBase::sMinDelta = 0; 56 | UInt32 CAHostTimeBase::sToNanosNumerator = 0; 57 | UInt32 CAHostTimeBase::sToNanosDenominator = 0; 58 | pthread_once_t CAHostTimeBase::sIsInited = PTHREAD_ONCE_INIT; 59 | #if Track_Host_TimeBase 60 | UInt64 CAHostTimeBase::sLastTime = 0; 61 | #endif 62 | 63 | //============================================================================= 64 | // CAHostTimeBase 65 | // 66 | // This class provides platform independent access to the host's time base. 67 | //============================================================================= 68 | 69 | void CAHostTimeBase::Initialize() 70 | { 71 | // get the info about Absolute time 72 | #if TARGET_OS_MAC 73 | struct mach_timebase_info theTimeBaseInfo; 74 | mach_timebase_info(&theTimeBaseInfo); 75 | sMinDelta = 1; 76 | sToNanosNumerator = theTimeBaseInfo.numer; 77 | sToNanosDenominator = theTimeBaseInfo.denom; 78 | 79 | // the frequency of that clock is: (sToNanosDenominator / sToNanosNumerator) * 10^9 80 | sFrequency = static_cast(sToNanosDenominator) / static_cast(sToNanosNumerator); 81 | sFrequency *= 1000000000.0; 82 | #elif TARGET_OS_WIN32 83 | LARGE_INTEGER theFrequency; 84 | QueryPerformanceFrequency(&theFrequency); 85 | sMinDelta = 1; 86 | sToNanosNumerator = 1000000000ULL; 87 | sToNanosDenominator = *((UInt64*)&theFrequency); 88 | sFrequency = static_cast(*((UInt64*)&theFrequency)); 89 | #endif 90 | sInverseFrequency = 1.0 / sFrequency; 91 | 92 | #if Log_Host_Time_Base_Parameters 93 | DebugPrintf("Host Time Base Parameters"); 94 | DebugPrintf(" Minimum Delta: %lu", (unsigned long)sMinDelta); 95 | DebugPrintf(" Frequency: %f", sFrequency); 96 | DebugPrintf(" To Nanos Numerator: %lu", (unsigned long)sToNanosNumerator); 97 | DebugPrintf(" To Nanos Denominator: %lu", (unsigned long)sToNanosDenominator); 98 | #endif 99 | } 100 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAMath.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAMath_h__ 48 | #define __CAMath_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #else 53 | #include 54 | #endif 55 | 56 | inline bool fiszero(Float64 f) { return (f == 0.); } 57 | inline bool fiszero(Float32 f) { return (f == 0.f); } 58 | 59 | inline bool fnonzero(Float64 f) { return !fiszero(f); } 60 | inline bool fnonzero(Float32 f) { return !fiszero(f); } 61 | 62 | inline bool fequal(const Float64 &a, const Float64 &b) { return a == b; } 63 | inline bool fequal(const Float32 &a, const Float32 &b) { return a == b; } 64 | 65 | inline bool fnotequal(const Float64 &a, const Float64 &b) { return !fequal(a, b); } 66 | inline bool fnotequal(const Float32 &a, const Float32 &b) { return !fequal(a, b); } 67 | 68 | #endif // __CAMath_h__ 69 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAMutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAMutex.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAMutex_h__ 48 | #define __CAMutex_h__ 49 | 50 | //================================================================================================== 51 | // Includes 52 | //================================================================================================== 53 | 54 | // System Includes 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include 59 | #endif 60 | 61 | #if TARGET_OS_MAC 62 | #include 63 | #elif TARGET_OS_WIN32 64 | #include 65 | #else 66 | #error Unsupported operating system 67 | #endif 68 | 69 | //================================================================================================== 70 | // A recursive mutex. 71 | //================================================================================================== 72 | 73 | class CAMutex 74 | { 75 | // Construction/Destruction 76 | public: 77 | CAMutex(const char* inName); 78 | virtual ~CAMutex(); 79 | 80 | // Actions 81 | public: 82 | virtual bool Lock(); 83 | virtual void Unlock(); 84 | virtual bool Try(bool& outWasLocked); // returns true if lock is free, false if not 85 | 86 | virtual bool IsFree() const; 87 | virtual bool IsOwnedByCurrentThread() const; 88 | 89 | // Implementation 90 | protected: 91 | const char* mName; 92 | #if TARGET_OS_MAC 93 | pthread_t mOwner; 94 | pthread_mutex_t mMutex; 95 | #elif TARGET_OS_WIN32 96 | UInt32 mOwner; 97 | HANDLE mMutex; 98 | #endif 99 | 100 | // Helper class to manage taking and releasing recursively 101 | public: 102 | class Locker 103 | { 104 | 105 | // Construction/Destruction 106 | public: 107 | Locker(CAMutex& inMutex) : mMutex(&inMutex), mNeedsRelease(false) { mNeedsRelease = mMutex->Lock(); } 108 | Locker(CAMutex* inMutex) : mMutex(inMutex), mNeedsRelease(false) { mNeedsRelease = (mMutex != NULL && mMutex->Lock()); } 109 | // in this case the mutex can be null 110 | ~Locker() { if(mNeedsRelease) { mMutex->Unlock(); } } 111 | 112 | 113 | private: 114 | Locker(const Locker&); 115 | Locker& operator=(const Locker&); 116 | 117 | // Implementation 118 | private: 119 | CAMutex* mMutex; 120 | bool mNeedsRelease; 121 | 122 | }; 123 | 124 | // Unlocker 125 | class Unlocker 126 | { 127 | public: 128 | Unlocker(CAMutex& inMutex); 129 | ~Unlocker(); 130 | 131 | private: 132 | CAMutex& mMutex; 133 | bool mNeedsLock; 134 | 135 | // Hidden definitions of copy ctor, assignment operator 136 | Unlocker(const Unlocker& copy); // Not implemented 137 | Unlocker& operator=(const Unlocker& copy); // Not implemented 138 | }; 139 | 140 | // you can use this with Try - if you take the lock in try, pass in the outWasLocked var 141 | class Tryer { 142 | 143 | // Construction/Destruction 144 | public: 145 | Tryer (CAMutex &mutex) : mMutex(mutex), mNeedsRelease(false), mHasLock(false) { mHasLock = mMutex.Try (mNeedsRelease); } 146 | ~Tryer () { if (mNeedsRelease) mMutex.Unlock(); } 147 | 148 | bool HasLock () const { return mHasLock; } 149 | 150 | private: 151 | Tryer(const Tryer&); 152 | Tryer& operator=(const Tryer&); 153 | 154 | // Implementation 155 | private: 156 | CAMutex & mMutex; 157 | bool mNeedsRelease; 158 | bool mHasLock; 159 | }; 160 | }; 161 | 162 | 163 | #endif // __CAMutex_h__ 164 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAReferenceCounted.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAReferenceCounted.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAReferenceCounted_h__ 48 | #define __CAReferenceCounted_h__ 49 | 50 | #include "CAAtomic.h" 51 | 52 | // base class for reference-counted objects 53 | class CAReferenceCounted { 54 | public: 55 | CAReferenceCounted() : mRefCount(1) {} 56 | 57 | void retain() { CAAtomicIncrement32(&mRefCount); } 58 | 59 | void release() 60 | { 61 | SInt32 rc = CAAtomicDecrement32(&mRefCount); 62 | if (rc == 0) { 63 | releaseObject(); 64 | } 65 | } 66 | 67 | 68 | class Retainer { 69 | public: 70 | Retainer(CAReferenceCounted *obj) : mObject(obj) { mObject->retain(); } 71 | ~Retainer() { mObject->release(); } 72 | 73 | private: 74 | CAReferenceCounted * mObject; 75 | }; 76 | 77 | protected: 78 | virtual ~CAReferenceCounted() { } 79 | 80 | virtual void releaseObject () 81 | { 82 | delete this; 83 | } 84 | 85 | #if DEBUG 86 | public: 87 | #endif 88 | SInt32 GetReferenceCount() const { return mRefCount; } 89 | private: 90 | SInt32 mRefCount; 91 | 92 | CAReferenceCounted(const CAReferenceCounted &a); 93 | CAReferenceCounted &operator=(const CAReferenceCounted &a); 94 | }; 95 | 96 | 97 | #endif // __CAReferenceCounted_h__ 98 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAVectorUnit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnit.cpp 3 | Abstract: CAVectorUnit.h 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "CAVectorUnit.h" 48 | 49 | #if !TARGET_OS_WIN32 50 | #include 51 | #elif HAS_IPP 52 | #include "ippdefs.h" 53 | #include "ippcore.h" 54 | #endif 55 | 56 | int gCAVectorUnitType = kVecUninitialized; 57 | 58 | #if TARGET_OS_WIN32 59 | // Use cpuid to check if SSE2 is available. 60 | // Before calling this function make sure cpuid is available 61 | static SInt32 IsSSE2Available() 62 | { 63 | int return_value; 64 | 65 | { 66 | int r_edx; 67 | _asm 68 | { 69 | mov eax, 0x01 70 | cpuid 71 | mov r_edx, edx 72 | } 73 | return_value = (r_edx >> 26) & 0x1; 74 | } 75 | return return_value; 76 | } 77 | 78 | // Use cpuid to check if SSE3 is available. 79 | // Before calling this function make sure cpuid is available 80 | static SInt32 IsSSE3Available() 81 | { 82 | SInt32 return_value; 83 | 84 | { 85 | SInt32 r_ecx; 86 | _asm 87 | { 88 | mov eax, 0x01 89 | cpuid 90 | mov r_ecx, ecx 91 | } 92 | return_value = r_ecx & 0x1; 93 | } 94 | return return_value; 95 | } 96 | 97 | // Return true if the cpuid instruction is available. 98 | // The cpuid instruction is available if bit 21 in the EFLAGS register can be changed 99 | // This function may not work on Intel CPUs prior to Pentium (didn't test) 100 | static bool IsCpuidAvailable() 101 | { 102 | SInt32 return_value = 0x0; 103 | _asm{ 104 | pushfd ; //push original EFLAGS 105 | pop eax ; //get original EFLAGS 106 | mov ecx, eax ; //save original EFLAGS 107 | xor eax, 200000h ; //flip ID bit in EFLAGS 108 | push eax ; //save new EFLAGS value on stack 109 | popfd ; //replace current EFLAGS value 110 | pushfd ; //get new EFLAGS 111 | pop eax ; //store new EFLAGS in EAX 112 | xor eax, ecx ; 113 | je end_cpuid_identify ; //can't toggle ID bit 114 | mov return_value, 0x1; 115 | end_cpuid_identify: 116 | nop; 117 | } 118 | return return_value; 119 | } 120 | 121 | #endif 122 | 123 | SInt32 CAVectorUnit_Examine() 124 | { 125 | int result = kVecNone; 126 | 127 | #if TARGET_OS_WIN32 128 | #if HAS_IPP 129 | // Initialize the static IPP library! This needs to be done before 130 | // any IPP function calls, otherwise we may have a performance penalty 131 | int status = ippStaticInit(); 132 | if ( status == ippStsNonIntelCpu ) 133 | { 134 | IppCpuType cpuType = ippGetCpuType(); 135 | if ( cpuType >= ippCpuSSE || cpuType <= ippCpuSSE42 ) 136 | ippStaticInitCpu( cpuType ); 137 | } 138 | #endif 139 | { 140 | // On Windows we use cpuid to detect the vector unit because it works on Intel and AMD. 141 | // The IPP library does not detect SSE on AMD processors. 142 | if (IsCpuidAvailable()) 143 | { 144 | if(IsSSE3Available()) 145 | { 146 | result = kVecSSE3; 147 | } 148 | else if(IsSSE2Available()) 149 | { 150 | result = kVecSSE2; 151 | } 152 | } 153 | } 154 | #elif TARGET_OS_MAC 155 | #if DEBUG 156 | if (getenv("CA_NoVector")) { 157 | fprintf(stderr, "CA_NoVector set; Vector unit optimized routines will be bypassed\n"); 158 | return result; 159 | } 160 | else 161 | #endif 162 | { 163 | #if (TARGET_CPU_PPC || TARGET_CPU_PPC64) 164 | int sels[2] = { CTL_HW, HW_VECTORUNIT }; 165 | int vType = 0; //0 == scalar only 166 | size_t length = sizeof(vType); 167 | int error = sysctl(sels, 2, &vType, &length, NULL, 0); 168 | if (!error && vType > 0) 169 | result = kVecAltivec; 170 | #elif (TARGET_CPU_X86 || TARGET_CPU_X86_64) 171 | static const struct { const char* kName; const int kVectype; } kStringVectypes[] = { 172 | { "hw.optional.avx1_0", kVecAVX1 }, { "hw.optional.sse3", kVecSSE3 }, { "hw.optional.sse2", kVecSSE2 } 173 | }; 174 | static const size_t kNumStringVectypes = sizeof(kStringVectypes)/sizeof(kStringVectypes[0]); 175 | int i = 0, answer = 0; 176 | while(i != kNumStringVectypes) 177 | { 178 | size_t length = sizeof(answer); 179 | int error = sysctlbyname(kStringVectypes[i].kName, &answer, &length, NULL, 0); 180 | if (!error && answer) 181 | { 182 | result = kStringVectypes[i].kVectype; 183 | break; 184 | } 185 | ++i; 186 | }; 187 | #elif CA_ARM_NEON 188 | result = kVecNeon; 189 | #endif 190 | } 191 | #endif 192 | gCAVectorUnitType = result; 193 | return result; 194 | } 195 | 196 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAVectorUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnit.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAVectorUnit_h__ 48 | #define __CAVectorUnit_h__ 49 | 50 | #include 51 | #include "CAVectorUnitTypes.h" 52 | #include 53 | #include 54 | 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include "CFBase.h" 59 | #endif 60 | 61 | // Unify checks for vector units. 62 | // Allow setting an environment variable "CA_NoVector" to turn off vectorized code at runtime (very useful for performance testing). 63 | 64 | extern int gCAVectorUnitType; 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | extern SInt32 CAVectorUnit_Examine(); // expensive. use GetType() for lazy initialization and caching. 71 | 72 | static inline SInt32 CAVectorUnit_GetType() 73 | { 74 | int x = gCAVectorUnitType; 75 | return (x != kVecUninitialized) ? x : CAVectorUnit_Examine(); 76 | } 77 | 78 | static inline Boolean CAVectorUnit_HasVectorUnit() 79 | { 80 | return CAVectorUnit_GetType() > kVecNone; 81 | } 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | 88 | #ifdef __cplusplus 89 | class CAVectorUnit { 90 | public: 91 | static SInt32 GetVectorUnitType() { return CAVectorUnit_GetType(); } 92 | static bool HasVectorUnit() { return GetVectorUnitType() > kVecNone; } 93 | static bool HasAltivec() { return GetVectorUnitType() == kVecAltivec; } 94 | static bool HasSSE2() { return GetVectorUnitType() >= kVecSSE2; } 95 | static bool HasSSE3() { return GetVectorUnitType() >= kVecSSE3; } 96 | static bool HasAVX1() { return GetVectorUnitType() >= kVecAVX1; } 97 | static bool HasNeon() { return GetVectorUnitType() == kVecNeon; } 98 | }; 99 | #endif 100 | 101 | #endif // __CAVectorUnit_h__ 102 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAVectorUnitTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnitTypes.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAVectorUnitTypes_h__ 48 | #define __CAVectorUnitTypes_h__ 49 | 50 | enum { 51 | kVecUninitialized = -1, 52 | kVecNone = 0, 53 | kVecAltivec = 1, 54 | kVecSSE2 = 100, 55 | kVecSSE3 = 101, 56 | kVecAVX1 = 110, 57 | kVecNeon = 200 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/PublicUtility/CAXException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAXException.cpp 3 | Abstract: CAXException.h 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "CAXException.h" 48 | 49 | CAXException::WarningHandler CAXException::sWarningHandler = NULL; 50 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbob/AudioUnitTemplates/c7133512777705c0ae727e2df57e9ccd61088549/Audio Unit/Effect Unit.xctemplate/TemplateIcon.icns -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/___PACKAGENAMEASIDENTIFIER___.h: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PACKAGENAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | #include "AUEffectBase.h" 10 | #include "___PACKAGENAMEASIDENTIFIER___Version.h" 11 | 12 | #if AU_DEBUG_DISPATCHER 13 | #include "AUDebugDispatcher.h" 14 | #endif 15 | 16 | #ifndef _____FILEBASENAME_____ 17 | #define _____FILEBASENAME_____ 18 | 19 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 | // Constants for parameters and factory presets 21 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 | #pragma mark _______PACKAGENAMEASIDENTIFIER___ Parameter Constants 23 | 24 | // Define constants to identify the parameters; 25 | // define the total number of parameters. 26 | enum { 27 | // kParameter_Example = 0, 28 | kNumberOfParameters 29 | }; 30 | 31 | // Define name, default, min, and max for each parameter. 32 | // static CFStringRef kParamName_Example = CFSTR("Example"); 33 | // static const float kDefaultValue_Example = 2.0; 34 | // static const float kMinimumValue_Example = 0.5; 35 | // static const float kMaximumValue_Example = 20.0; 36 | 37 | #pragma mark _______PACKAGENAMEASIDENTIFIER___ Factory Preset Constants 38 | 39 | // Define constants to identify factory presets. 40 | enum { 41 | kPreset_Default = 0, 42 | // kPreset_Example2 = 1, 43 | kNumberOfPresets 44 | }; 45 | 46 | // Define values for each preset/parameter pair. 47 | // static const float kParameter_Preset_Default_Example = 2.0; 48 | // static const float kParameter_Preset_Example2_Example = 3.0; 49 | 50 | // Define the presets. 51 | static AUPreset kPresets [kNumberOfPresets] = { 52 | { kPreset_Default, CFSTR("Factory Default") }, 53 | // { kPreset_Example2, CFSTR("Example 2") }, 54 | }; 55 | 56 | 57 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 58 | // ___PACKAGENAMEASIDENTIFIER___ class 59 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | #pragma mark _______PACKAGENAMEASIDENTIFIER___ 61 | 62 | class ___PACKAGENAMEASIDENTIFIER___ : public AUEffectBase { 63 | 64 | public: 65 | ___PACKAGENAMEASIDENTIFIER___ (AudioUnit component); 66 | 67 | #if AU_DEBUG_DISPATCHER 68 | virtual ~___PACKAGENAMEASIDENTIFIER___ () {delete mDebugDispatcher;} 69 | #endif 70 | 71 | virtual AUKernelBase *NewKernel (); 72 | 73 | virtual ComponentResult GetParameterInfo ( 74 | AudioUnitScope inScope, 75 | AudioUnitParameterID inParameterID, 76 | AudioUnitParameterInfo &outParameterInfo 77 | ); 78 | 79 | virtual ComponentResult GetParameterValueStrings ( 80 | AudioUnitScope inScope, 81 | AudioUnitParameterID inParameterID, 82 | CFArrayRef *outStrings 83 | ); 84 | 85 | virtual ComponentResult GetPropertyInfo ( 86 | AudioUnitPropertyID inID, 87 | AudioUnitScope inScope, 88 | AudioUnitElement inElement, 89 | UInt32 &outDataSize, 90 | Boolean &outWritable 91 | ); 92 | 93 | virtual ComponentResult GetProperty ( 94 | AudioUnitPropertyID inID, 95 | AudioUnitScope inScope, 96 | AudioUnitElement inElement, 97 | void *outData 98 | ); 99 | 100 | // Report that the audio unit supports the 101 | // kAudioUnitProperty_TailTime property. 102 | virtual bool SupportsTail () 103 | { 104 | return true; 105 | } 106 | 107 | // Provide the audio unit version information. 108 | virtual ComponentResult Version () 109 | { 110 | return k___PACKAGENAMEASIDENTIFIER___Version; 111 | } 112 | 113 | // Declare the GetPresets method (for setting up the factory 114 | // presets), overriding the method from the AUBase superclass. 115 | virtual ComponentResult GetPresets ( 116 | CFArrayRef *outData 117 | ) const; 118 | 119 | // Declare the NewFactoryPresetSet method (for setting a factory 120 | // preset when requested by the host application), overriding the 121 | // method from the AUBase superclass. 122 | virtual OSStatus NewFactoryPresetSet ( 123 | const AUPreset &inNewFactoryPreset 124 | ); 125 | 126 | protected: 127 | class Kernel; 128 | 129 | }; 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/___PACKAGENAMEASIDENTIFIER___Version.h: -------------------------------------------------------------------------------- 1 | #ifndef _____FILEBASENAME_____ 2 | #define _____FILEBASENAME_____ 3 | 4 | #ifdef DEBUG 5 | #define k___PACKAGENAMEASIDENTIFIER___Version 0xFFFFFFFF 6 | #else 7 | #define k___PACKAGENAMEASIDENTIFIER___Version 0x00010000 8 | #endif 9 | 10 | #endif /* _____FILEBASENAME_____ */ 11 | 12 | -------------------------------------------------------------------------------- /Audio Unit/Effect Unit.xctemplate/___PACKAGENAMEASIDENTIFIER____Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files. 3 | // 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/AUInstrumentBase/LockFreeFIFO.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: LockFreeFIFO.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include 48 | 49 | template 50 | class LockFreeFIFOWithFree 51 | { 52 | LockFreeFIFOWithFree(); // private, unimplemented. 53 | public: 54 | LockFreeFIFOWithFree(UInt32 inMaxSize) 55 | : mReadIndex(0), mWriteIndex(0), mFreeIndex(0) 56 | { 57 | //assert(IsPowerOfTwo(inMaxSize)); 58 | mItems = new ITEM[inMaxSize]; 59 | mMask = inMaxSize - 1; 60 | } 61 | 62 | ~LockFreeFIFOWithFree() 63 | { 64 | delete [] mItems; 65 | } 66 | 67 | 68 | void Reset() 69 | { 70 | FreeItems(); 71 | mReadIndex = 0; 72 | mWriteIndex = 0; 73 | mFreeIndex = 0; 74 | } 75 | 76 | ITEM* WriteItem() 77 | { 78 | //printf("WriteItem %d %d\n", mReadIndex, mWriteIndex); 79 | FreeItems(); // free items on the write thread. 80 | int32_t nextWriteIndex = (mWriteIndex + 1) & mMask; 81 | if (nextWriteIndex == mFreeIndex) return NULL; 82 | return &mItems[mWriteIndex]; 83 | } 84 | 85 | ITEM* ReadItem() 86 | { 87 | //printf("ReadItem %d %d\n", mReadIndex, mWriteIndex); 88 | if (mReadIndex == mWriteIndex) return NULL; 89 | return &mItems[mReadIndex]; 90 | } 91 | void AdvanceWritePtr() { OSAtomicCompareAndSwap32(mWriteIndex, (mWriteIndex + 1) & mMask, &mWriteIndex); } 92 | void AdvanceReadPtr() { OSAtomicCompareAndSwap32(mReadIndex, (mReadIndex + 1) & mMask, &mReadIndex); } 93 | private: 94 | ITEM* FreeItem() 95 | { 96 | if (mFreeIndex == mReadIndex) return NULL; 97 | return &mItems[mFreeIndex]; 98 | } 99 | void AdvanceFreePtr() { OSAtomicCompareAndSwap32(mFreeIndex, (mFreeIndex + 1) & mMask, &mFreeIndex); } 100 | 101 | void FreeItems() 102 | { 103 | ITEM* item; 104 | while ((item = FreeItem()) != NULL) 105 | { 106 | item->Free(); 107 | AdvanceFreePtr(); 108 | } 109 | } 110 | 111 | volatile int32_t mReadIndex, mWriteIndex, mFreeIndex; 112 | int32_t mMask; 113 | ITEM *mItems; 114 | }; 115 | 116 | 117 | 118 | // Same as above but no free. 119 | 120 | template 121 | class LockFreeFIFO 122 | { 123 | LockFreeFIFO(); // private, unimplemented. 124 | public: 125 | LockFreeFIFO(UInt32 inMaxSize) 126 | : mReadIndex(0), mWriteIndex(0) 127 | { 128 | //assert(IsPowerOfTwo(inMaxSize)); 129 | mItems = new ITEM[inMaxSize]; 130 | mMask = inMaxSize - 1; 131 | } 132 | 133 | ~LockFreeFIFO() 134 | { 135 | delete [] mItems; 136 | } 137 | 138 | void Reset() 139 | { 140 | mReadIndex = 0; 141 | mWriteIndex = 0; 142 | } 143 | 144 | ITEM* WriteItem() 145 | { 146 | int32_t nextWriteIndex = (mWriteIndex + 1) & mMask; 147 | if (nextWriteIndex == mReadIndex) return NULL; 148 | return &mItems[mWriteIndex]; 149 | } 150 | 151 | ITEM* ReadItem() 152 | { 153 | if (mReadIndex == mWriteIndex) return NULL; 154 | return &mItems[mReadIndex]; 155 | } 156 | 157 | // the CompareAndSwap will always succeed. We use CompareAndSwap because it calls the PowerPC sync instruction, 158 | // plus any processor bug workarounds for various CPUs. 159 | void AdvanceWritePtr() { OSAtomicCompareAndSwap32(mWriteIndex, (mWriteIndex + 1) & mMask, &mWriteIndex); } 160 | void AdvanceReadPtr() { OSAtomicCompareAndSwap32(mReadIndex, (mReadIndex + 1) & mMask, &mReadIndex); } 161 | 162 | private: 163 | 164 | volatile int32_t mReadIndex, mWriteIndex; 165 | int32_t mMask; 166 | ITEM *mItems; 167 | }; 168 | 169 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/AUInstrumentBase/MIDIControlHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: MIDIControlHandler.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __MIDICONTROLHANDLER_H__ 48 | #define __MIDICONTROLHANDLER_H__ 49 | 50 | #include 51 | 52 | /*! Abstract interface base class for classes which handle all incoming MIDI data */ 53 | 54 | class MIDIControlHandler 55 | { 56 | public: 57 | virtual ~MIDIControlHandler() {} 58 | virtual void Reset() = 0; //! Restore all state to defaults 59 | virtual bool SetProgramChange(UInt16 inProgram) = 0; 60 | virtual bool SetPitchWheel(UInt16 inValue) = 0; 61 | virtual bool SetChannelPressure(UInt8 inValue) = 0; 62 | virtual bool SetPolyPressure(UInt8 inKey, UInt8 inValue) = 0; 63 | virtual bool SetController(UInt8 inControllerNumber, UInt8 inValue) = 0; 64 | virtual bool SetSysex(void *inSysexMsg) = 0; 65 | 66 | virtual float GetPitchBend() const = 0; 67 | 68 | /*! Default controller values. These represent MSB values unless indicated in the name */ 69 | 70 | enum 71 | { 72 | kDefault_Midpoint = 0x40, //! Used for all center-null-point controllers 73 | kDefault_Volume = 100, 74 | kDefault_Pan = kDefault_Midpoint, 75 | kDefault_ModWheel = 0, 76 | kDefault_Pitch = kDefault_Midpoint, 77 | kDefault_Expression = 0x7f, 78 | kDefault_ChannelPressure = 0, 79 | kDefault_ReverbSend = 40, 80 | kDefault_ChorusSend = 0, 81 | 82 | kDefault_RPN_LSB = 0x7f, 83 | kDefault_RPN_MSB = 0x7f, 84 | kDefault_PitchBendRange = 2, 85 | kDefault_FineTuning = kDefault_Midpoint, 86 | kDefault_CoarseTuning = kDefault_Midpoint, 87 | kDefault_ModDepthRange = 0, 88 | kDefault_ModDepthRangeLSB = kDefault_Midpoint 89 | }; 90 | }; 91 | 92 | #endif // __MIDICONTROLHANDLER_H__ 93 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/AUInstrumentBase/SynthEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: SynthEvent.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | /* You can either fill in code here or remove this and create or add new files. */ 48 | 49 | #ifndef __SynthEvent__ 50 | #define __SynthEvent__ 51 | 52 | #include 53 | #include 54 | #include "MusicDeviceBase.h" 55 | #include 56 | 57 | //////////////////////////////////////////////////////////////////////////////////////////////////////////// 58 | 59 | 60 | class SynthEvent 61 | { 62 | public: 63 | enum { 64 | kEventType_NoteOn = 1, 65 | kEventType_NoteOff = 2, 66 | kEventType_SustainOn = 3, 67 | kEventType_SustainOff = 4, 68 | kEventType_SostenutoOn = 5, 69 | kEventType_SostenutoOff = 6, 70 | kEventType_AllNotesOff = 7, 71 | kEventType_AllSoundOff = 8, 72 | kEventType_ResetAllControllers = 9 73 | }; 74 | 75 | 76 | SynthEvent() {} 77 | ~SynthEvent() {} 78 | 79 | void Set( 80 | UInt32 inEventType, 81 | MusicDeviceGroupID inGroupID, 82 | NoteInstanceID inNoteID, 83 | UInt32 inOffsetSampleFrame, 84 | const MusicDeviceNoteParams* inNoteParams 85 | ) 86 | { 87 | mEventType = inEventType; 88 | mGroupID = inGroupID; 89 | mNoteID = inNoteID; 90 | mOffsetSampleFrame = inOffsetSampleFrame; 91 | 92 | if (inNoteParams) 93 | { 94 | UInt32 paramSize = offsetof(MusicDeviceNoteParams, mControls) + (inNoteParams->argCount-2)*sizeof(NoteParamsControlValue); 95 | mNoteParams = inNoteParams->argCount > 3 96 | ? (MusicDeviceNoteParams*)malloc(paramSize) 97 | : &mSmallNoteParams; 98 | memcpy(mNoteParams, inNoteParams, paramSize); 99 | } 100 | else 101 | mNoteParams = NULL; 102 | } 103 | 104 | 105 | void Free() 106 | { 107 | if (mNoteParams) 108 | { 109 | if (mNoteParams->argCount > 3) 110 | free(mNoteParams); 111 | mNoteParams = NULL; 112 | } 113 | } 114 | 115 | UInt32 GetEventType() const { return mEventType; } 116 | MusicDeviceGroupID GetGroupID() const { return mGroupID; } 117 | NoteInstanceID GetNoteID() const { return mNoteID; } 118 | UInt32 GetOffsetSampleFrame() const { return mOffsetSampleFrame; } 119 | 120 | MusicDeviceNoteParams* GetParams() const { return mNoteParams; } 121 | 122 | UInt32 GetArgCount() const { return mNoteParams->argCount; } 123 | UInt32 NumberParameters() const { return mNoteParams->argCount - 2; } 124 | 125 | Float32 GetNote() const { return mNoteParams->mPitch; } 126 | Float32 GetVelocity() const { return mNoteParams->mVelocity; } 127 | 128 | NoteParamsControlValue GetParameter(UInt32 inIndex) const 129 | { 130 | if (inIndex >= NumberParameters()) 131 | throw std::runtime_error("index out of range"); 132 | return mNoteParams->mControls[inIndex]; 133 | } 134 | 135 | private: 136 | UInt32 mEventType; 137 | MusicDeviceGroupID mGroupID; 138 | NoteInstanceID mNoteID; 139 | UInt32 mOffsetSampleFrame; 140 | MusicDeviceNoteParams* mNoteParams; 141 | MusicDeviceNoteParams mSmallNoteParams; // inline a small one to eliminate malloc for the simple case. 142 | }; 143 | 144 | //////////////////////////////////////////////////////////////////////////////////////////////////////////// 145 | #endif 146 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/AUInstrumentBase/SynthNote.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: SynthNote.cpp 3 | Abstract: SynthNote.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "SynthNote.h" 48 | #include "SynthElement.h" 49 | #include "AUInstrumentBase.h" 50 | 51 | bool SynthNote::AttackNote( 52 | SynthPartElement * inPart, 53 | SynthGroupElement * inGroup, 54 | NoteInstanceID inNoteID, 55 | UInt64 inAbsoluteSampleFrame, 56 | UInt32 inOffsetSampleFrame, 57 | const MusicDeviceNoteParams &inParams) 58 | { 59 | #if DEBUG_PRINT 60 | printf("SynthNote::AttackNote %lu %lu abs frame %llu rel frame %lu\n", (UInt32)inGroup->GroupID(), (UInt32)inNoteID, inAbsoluteSampleFrame, inOffsetSampleFrame); 61 | #endif 62 | mPart = inPart; 63 | mGroup = inGroup; 64 | mNoteID = inNoteID; 65 | 66 | mAbsoluteStartFrame = inAbsoluteSampleFrame; 67 | mRelativeStartFrame = inOffsetSampleFrame; 68 | mRelativeReleaseFrame = -1; 69 | mRelativeKillFrame = -1; 70 | 71 | mPitch = inParams.mPitch; 72 | mVelocity = inParams.mVelocity; 73 | 74 | 75 | return Attack(inParams); 76 | } 77 | 78 | 79 | void SynthNote::Reset() 80 | { 81 | mPart = 0; 82 | mGroup = 0; 83 | mAbsoluteStartFrame = 0; 84 | mRelativeStartFrame = 0; 85 | mRelativeReleaseFrame = 0; 86 | mRelativeKillFrame = 0; 87 | } 88 | 89 | void SynthNote::Kill(UInt32 inFrame) 90 | { 91 | mRelativeKillFrame = inFrame; 92 | } 93 | 94 | void SynthNote::Release(UInt32 inFrame) 95 | { 96 | mRelativeReleaseFrame = inFrame; 97 | } 98 | 99 | void SynthNote::FastRelease(UInt32 inFrame) 100 | { 101 | mRelativeReleaseFrame = inFrame; 102 | } 103 | 104 | double SynthNote::TuningA() const 105 | { 106 | return 440.0; 107 | } 108 | 109 | double SynthNote::Frequency() 110 | { 111 | return TuningA() * pow(2., (mPitch - 69. + GetPitchBend()) / 12.); 112 | } 113 | 114 | double SynthNote::SampleRate() 115 | { 116 | return GetAudioUnit()->GetOutput(0)->GetStreamFormat().mSampleRate; 117 | } 118 | 119 | AUInstrumentBase* SynthNote::GetAudioUnit() const 120 | { 121 | return (AUInstrumentBase*)mGroup->GetAudioUnit(); 122 | } 123 | 124 | Float32 SynthNote::GetGlobalParameter(AudioUnitParameterID inParamID) const 125 | { 126 | return mGroup->GetAudioUnit()->Globals()->GetParameter(inParamID); 127 | } 128 | 129 | void SynthNote::NoteEnded(UInt32 inFrame) 130 | { 131 | mGroup->NoteEnded(this, inFrame); 132 | mNoteID = 0xFFFFFFFF; 133 | } 134 | 135 | float SynthNote::GetPitchBend() const 136 | { 137 | return mGroup->GetPitchBend(); 138 | } 139 | 140 | 141 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/AUInstrumentBase/SynthNoteList.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: SynthNoteList.cpp 3 | Abstract: SynthNoteList.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "SynthNoteList.h" 48 | #include 49 | 50 | void SynthNoteList::SanityCheck() const 51 | { 52 | if (mState >= kNoteState_Unset) { 53 | throw std::runtime_error("SanityCheck: mState is bad"); 54 | } 55 | 56 | if (mHead == NULL) { 57 | if (mTail != NULL) 58 | throw std::runtime_error("SanityCheck: mHead is NULL but not mTail"); 59 | return; 60 | } 61 | if (mTail == NULL) { 62 | throw std::runtime_error("SanityCheck: mTail is NULL but not mHead"); 63 | } 64 | 65 | if (mHead->mPrev) { 66 | throw std::runtime_error("SanityCheck: mHead has a mPrev"); 67 | } 68 | if (mTail->mNext) { 69 | throw std::runtime_error("SanityCheck: mTail has a mNext"); 70 | } 71 | 72 | SynthNote *note = mHead; 73 | while (note) 74 | { 75 | if (note->mState != mState) 76 | throw std::runtime_error("SanityCheck: note in wrong state"); 77 | if (note->mNext) { 78 | if (note->mNext->mPrev != note) 79 | throw std::runtime_error("SanityCheck: bad link 1"); 80 | } else { 81 | if (mTail != note) 82 | throw std::runtime_error("SanityCheck: note->mNext is nil, but mTail != note"); 83 | } 84 | if (note->mPrev) { 85 | if (note->mPrev->mNext != note) 86 | throw std::runtime_error("SanityCheck: bad link 2"); 87 | } else { 88 | if (mHead != note) 89 | throw std::runtime_error("SanityCheck: note->mPrev is nil, but mHead != note"); 90 | } 91 | note = note->mNext; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/OtherBases/MusicDeviceBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: MusicDeviceBase.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __MusicDeviceBase_h__ 48 | #define __MusicDeviceBase_h__ 49 | 50 | #include "AUMIDIBase.h" 51 | 52 | // ________________________________________________________________________ 53 | // MusicDeviceBase 54 | // 55 | 56 | /*! @class MusicDeviceBase */ 57 | class MusicDeviceBase : public AUBase, public AUMIDIBase { 58 | public: 59 | /*! @ctor MusicDeviceBase */ 60 | MusicDeviceBase( AudioComponentInstance inInstance, 61 | UInt32 numInputs, 62 | UInt32 numOutputs, 63 | UInt32 numGroups = 0); 64 | 65 | 66 | virtual OSStatus MIDIEvent( UInt32 inStatus, 67 | UInt32 inData1, 68 | UInt32 inData2, 69 | UInt32 inOffsetSampleFrame) 70 | { 71 | return AUMIDIBase::MIDIEvent (inStatus, inData1, inData2, inOffsetSampleFrame); 72 | } 73 | 74 | /*! @method SysEx */ 75 | virtual OSStatus SysEx( const UInt8 * inData, 76 | UInt32 inLength) 77 | { 78 | return AUMIDIBase::SysEx (inData, inLength); 79 | } 80 | 81 | /*! @method GetPropertyInfo */ 82 | virtual OSStatus GetPropertyInfo(AudioUnitPropertyID inID, 83 | AudioUnitScope inScope, 84 | AudioUnitElement inElement, 85 | UInt32 & outDataSize, 86 | Boolean & outWritable); 87 | 88 | /*! @method GetProperty */ 89 | virtual OSStatus GetProperty( AudioUnitPropertyID inID, 90 | AudioUnitScope inScope, 91 | AudioUnitElement inElement, 92 | void * outData); 93 | 94 | /*! @method SetProperty */ 95 | virtual OSStatus SetProperty( AudioUnitPropertyID inID, 96 | AudioUnitScope inScope, 97 | AudioUnitElement inElement, 98 | const void * inData, 99 | UInt32 inDataSize); 100 | 101 | /*! @method HandleNoteOn */ 102 | virtual OSStatus HandleNoteOn( UInt8 inChannel, 103 | UInt8 inNoteNumber, 104 | UInt8 inVelocity, 105 | UInt32 inStartFrame); 106 | 107 | /*! @method HandleNoteOff */ 108 | virtual OSStatus HandleNoteOff( UInt8 inChannel, 109 | UInt8 inNoteNumber, 110 | UInt8 inVelocity, 111 | UInt32 inStartFrame); 112 | 113 | /*! @method GetInstrumentCount */ 114 | virtual OSStatus GetInstrumentCount ( UInt32 &outInstCount) const; 115 | 116 | #if !CA_USE_AUDIO_PLUGIN_ONLY 117 | // component dispatcher 118 | /*! @method ComponentEntryDispatch */ 119 | static OSStatus ComponentEntryDispatch( ComponentParameters * params, 120 | MusicDeviceBase * This); 121 | #endif 122 | private: 123 | OSStatus HandleStartNoteMessage (MusicDeviceInstrumentID inInstrument, MusicDeviceGroupID inGroupID, NoteInstanceID *outNoteInstanceID, UInt32 inOffsetSampleFrame, const MusicDeviceNoteParams *inParams); 124 | }; 125 | 126 | #endif // __MusicDeviceBase_h__ 127 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/Utility/AUBaseHelper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUBaseHelper.cpp 3 | Abstract: AUBaseHelper.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "AUBaseHelper.h" 48 | 49 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 50 | #include 51 | #else 52 | #include 53 | #endif 54 | 55 | OSStatus GetFileRefPath (CFDictionaryRef parent, CFStringRef frKey, CFStringRef * fPath) 56 | { 57 | static CFStringRef kFRString = CFSTR (kAUPresetExternalFileRefs); 58 | 59 | const void* frVal = CFDictionaryGetValue(parent, kFRString); 60 | if (!frVal) return kAudioUnitErr_InvalidPropertyValue; 61 | 62 | const void* frString = CFDictionaryGetValue ((CFDictionaryRef)frVal, frKey); 63 | if (!frString) return kAudioUnitErr_InvalidPropertyValue; 64 | 65 | if (fPath) 66 | *fPath = (CFStringRef)frString; 67 | 68 | return noErr; 69 | } 70 | 71 | CFMutableDictionaryRef CreateFileRefDict (CFStringRef fKey, CFStringRef fPath, CFMutableDictionaryRef fileRefDict) 72 | { 73 | if (!fileRefDict) 74 | fileRefDict = CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 75 | 76 | CFDictionarySetValue (fileRefDict, fKey, fPath); 77 | 78 | return fileRefDict; 79 | } 80 | 81 | #if TARGET_OS_MAC 82 | // check if the URL can be accessed for reading/writing. Returns 0 if yes, or the error value. 83 | int AccessURLAsset(const CFURLRef inURL, int mode) 84 | { 85 | char path[PATH_MAX]; 86 | if (CFURLGetFileSystemRepresentation(inURL, TRUE, (UInt8 *)path, PATH_MAX) == FALSE) 87 | return kAudio_FileNotFoundError; 88 | // check whether we have access 89 | int ret = access(path, mode); 90 | // syslog(LOG_CRIT, "access() error is %d for \"%s\".\n", ret, path); 91 | if (ret == 0) return 0; 92 | switch (errno) { 93 | case EACCES: 94 | case EPERM: 95 | return -54; /*permission denied error*/ 96 | case ENOENT: 97 | case ENOTDIR: 98 | case ELOOP: 99 | return kAudio_FileNotFoundError; 100 | default: 101 | return errno; 102 | } 103 | } 104 | #endif 105 | 106 | #if DEBUG 107 | //_____________________________________________________________________________ 108 | // 109 | void PrintAUParamEvent (AudioUnitParameterEvent& event, FILE* f) 110 | { 111 | bool isRamp = event.eventType == kParameterEvent_Ramped; 112 | fprintf (f, "\tParamID=%ld,Scope=%ld,Element=%ld\n", (long)event.parameter, (long)event.scope, (long)event.element); 113 | fprintf (f, "\tEvent Type:%s,", (isRamp ? "ramp" : "immediate")); 114 | if (isRamp) 115 | fprintf (f, "start=%ld,dur=%ld,startValue=%f,endValue=%f\n", 116 | (long)event.eventValues.ramp.startBufferOffset, (long)event.eventValues.ramp.durationInFrames, 117 | event.eventValues.ramp.startValue, event.eventValues.ramp.endValue); 118 | else 119 | fprintf (f, "start=%ld,value=%f\n", 120 | (long)event.eventValues.immediate.bufferOffset, 121 | event.eventValues.immediate.value); 122 | fprintf (f, "- - - - - - - - - - - - - - - -\n"); 123 | } 124 | #endif 125 | 126 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/Utility/AUBaseHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUBaseHelper.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUBaseHelper_h__ 48 | #define __AUBaseHelper_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #include 56 | #endif 57 | 58 | #include "AUBase.h" 59 | 60 | // helpers for dealing with the file-references dictionary in an AUPreset 61 | OSStatus GetFileRefPath (CFDictionaryRef parent, CFStringRef frKey, CFStringRef * fPath); 62 | 63 | // if fileRefDict is NULL, this call creates one 64 | // if not NULL, then the key value is added to it 65 | CFMutableDictionaryRef CreateFileRefDict (CFStringRef fKey, CFStringRef fPath, CFMutableDictionaryRef fileRefDict); 66 | 67 | int AccessURLAsset(const CFURLRef inURL, int mode); 68 | 69 | #if DEBUG 70 | void PrintAUParamEvent (AudioUnitParameterEvent& event, FILE* f); 71 | #endif 72 | 73 | 74 | 75 | #endif // __AUBaseHelper_h__ -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/AUPublic/Utility/AUMIDIDefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUMIDIDefs.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __AUMIDIDefs_h__ 48 | #define __AUMIDIDefs_h__ 49 | 50 | #if !defined(__TMidiMessage) /* DAS HACK */ 51 | enum 52 | { 53 | kMidiMessage_NoteOff = 0x80, 54 | kMidiMessage_NoteOn = 0x90, 55 | kMidiMessage_PolyPressure = 0xA0, 56 | kMidiMessage_ControlChange = 0xB0, 57 | kMidiMessage_ProgramChange = 0xC0, 58 | kMidiMessage_ChannelPressure = 0xD0, 59 | kMidiMessage_PitchWheel = 0xE0, 60 | kMidiMessage_SysEx = 0xF0, 61 | kMidiMessage_SysEx_End = 0xF7, 62 | kMidiMessage_MetaEvent = 0xFF 63 | }; 64 | #endif 65 | 66 | enum 67 | { 68 | kMidiController_BankSelect = 0, 69 | kMidiController_ModWheel = 1, 70 | kMidiController_Breath = 2, 71 | kMidiController_Foot = 4, 72 | kMidiController_PortamentoTime = 5, 73 | kMidiController_DataEntry = 6, 74 | kMidiController_Volume = 7, 75 | kMidiController_Balance = 8, 76 | kMidiController_Pan = 10, 77 | kMidiController_Expression = 11, 78 | 79 | // these controls have a (0-63) == off, (64-127) == on 80 | kMidiController_Sustain = 64, //hold1 81 | kMidiController_Portamento = 65, 82 | kMidiController_Sostenuto = 66, 83 | kMidiController_Soft = 67, 84 | kMidiController_LegatoPedal = 68, 85 | kMidiController_Hold2Pedal = 69, 86 | kMidiController_FilterResonance = 71, 87 | kMidiController_ReleaseTime = 72, 88 | kMidiController_AttackTime = 73, 89 | kMidiController_Brightness = 74, 90 | kMidiController_DecayTime = 75, 91 | kMidiController_VibratoRate = 76, 92 | kMidiController_VibratoDepth = 77, 93 | kMidiController_VibratoDelay = 78, 94 | 95 | // these controls have a 0-127 range and in MIDI they have no LSB (so fractional values are lost in MIDI) 96 | kMidiController_ReverbLevel = 91, 97 | kMidiController_ChorusLevel = 93, 98 | 99 | kMidiController_RPN_LSB = 100, 100 | kMidiController_RPN_MSB = 101, 101 | 102 | kMidiController_AllSoundOff = 120, 103 | kMidiController_ResetAllControllers = 121, 104 | kMidiController_AllNotesOff = 123, 105 | kMidiController_OmniModeOff = 124, 106 | kMidiController_OmniModeOn = 125, 107 | kMidiController_MonoModeOn = 126, 108 | kMidiController_MonoModeOff = 127 109 | }; 110 | 111 | // RPN values 112 | enum 113 | { 114 | kMidiControllerValue_RPNPitchBendSensitivity = 0, 115 | kMidiControllerValue_RPNChannelFineTuning = 1, 116 | kMidiControllerValue_RPNChannelCoarseTuning = 2, 117 | kMidiControllerValue_RPNModDepthRange = 5, 118 | kMidiControllerValue_RPNNull = 0x3fff //! 0x7f/0x7f 119 | }; 120 | 121 | // GM2 Sound Bank Constants 122 | enum 123 | { 124 | kGM2MelodicBank = 0x7900, 125 | kGM2PercussionBank = 0x7800, 126 | kGSPercussionBank = 0x7f00, 127 | kXGSFXBank = 0x7E00, 128 | kXGPercussionBank = kGSPercussionBank, 129 | kBankMSBMask = 0xff00 130 | }; 131 | 132 | enum 133 | { 134 | kMSBController_MidPoint = 0x40 135 | }; 136 | 137 | #endif // __AUMIDIDefs_h__ 138 | 139 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAAUMIDIMapManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAAUMIDIMapManager.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAAUMIDIMapManager_h_ 48 | #define __CAAUMIDIMapManager_h_ 49 | 50 | #include "AUBase.h" 51 | #include "CAAUMIDIMap.h" 52 | #include 53 | #include 54 | 55 | class CAAUMIDIMapManager { 56 | 57 | protected: 58 | 59 | typedef std::vector ParameterMaps; 60 | ParameterMaps mParameterMaps; 61 | 62 | bool hotMapping; 63 | AUParameterMIDIMapping mHotMap; 64 | 65 | public: 66 | 67 | CAAUMIDIMapManager(); 68 | 69 | UInt32 NumMaps(){return static_cast(mParameterMaps.size());} 70 | void GetMaps(AUParameterMIDIMapping* maps); 71 | 72 | int FindParameterIndex(AUParameterMIDIMapping &map); 73 | 74 | void GetHotParameterMap(AUParameterMIDIMapping &outMap); 75 | 76 | void SortedRemoveFromParameterMaps (AUParameterMIDIMapping *maps, UInt32 inNumMaps, bool &outMapDidChange); 77 | OSStatus SortedInsertToParamaterMaps (AUParameterMIDIMapping *maps, UInt32 inNumMaps, AUBase &That); 78 | 79 | void ReplaceAllMaps (AUParameterMIDIMapping* inMappings, UInt32 inNumMaps, AUBase &That); 80 | 81 | bool IsHotMapping(){return hotMapping;} 82 | void SetHotMapping (AUParameterMIDIMapping &inMap){hotMapping = true; mHotMap = inMap; } 83 | 84 | bool HandleHotMapping( UInt8 inStatus, 85 | UInt8 inChannel, 86 | UInt8 inData1, 87 | AUBase &That); 88 | 89 | 90 | bool FindParameterMapEventMatch(UInt8 inStatus, 91 | UInt8 inChannel, 92 | UInt8 inData1, 93 | UInt8 inData2, 94 | UInt32 inBufferOffset, 95 | AUBase& inAUBase); 96 | #if DEBUG 97 | void Print(); 98 | #endif 99 | }; 100 | 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAByteOrder.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAByteOrder.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CAByteOrder_h__) 48 | #define __CAByteOrder_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | // System Includes 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include "CoreFoundation.h" 59 | #endif 60 | 61 | 62 | #if defined(__cplusplus) 63 | extern "C" { 64 | #endif 65 | 66 | CF_INLINE Float32 CASwapFloat32 (Float32 arg) { 67 | union { 68 | Float32 f; 69 | UInt32 i; 70 | } flip; 71 | 72 | flip.f = arg; 73 | flip.i = CFSwapInt32 (flip.i); 74 | 75 | return flip.f; 76 | } 77 | 78 | CF_INLINE Float64 CASwapFloat64 (Float64 arg) { 79 | union { 80 | Float64 f; 81 | UInt64 i; 82 | } flip; 83 | 84 | flip.f = arg; 85 | flip.i = CFSwapInt64 (flip.i); 86 | 87 | return flip.f; 88 | } 89 | 90 | #pragma mark -Flippers 91 | 92 | CF_INLINE Float32 CASwapFloat32BigToHost(Float32 arg) { 93 | #if defined(__BIG_ENDIAN__) 94 | return arg; 95 | #else 96 | return CASwapFloat32(arg); 97 | #endif 98 | } 99 | 100 | CF_INLINE Float64 CASwapFloat64BigToHost(Float64 arg) { 101 | #if defined(__BIG_ENDIAN__) 102 | return arg; 103 | #else 104 | return CASwapFloat64(arg); 105 | #endif 106 | } 107 | 108 | CF_INLINE Float32 CASwapFloat32HostToBig(Float32 arg) { 109 | #if defined(__BIG_ENDIAN__) 110 | return arg; 111 | #else 112 | return CASwapFloat32(arg); 113 | #endif 114 | } 115 | 116 | CF_INLINE Float64 CASwapFloat64HostToBig(Float64 arg) { 117 | #if defined(__BIG_ENDIAN__) 118 | return arg; 119 | #else 120 | return CASwapFloat64(arg); 121 | #endif 122 | } 123 | 124 | CF_INLINE Float32 CASwapFloat32LittleToHost(Float32 arg) { 125 | #if defined(__LITTLE_ENDIAN__) 126 | return arg; 127 | #else 128 | return CASwapFloat32(arg); 129 | #endif 130 | } 131 | 132 | CF_INLINE Float64 CASwapFloat64LittleToHost(Float64 arg) { 133 | #if defined(__LITTLE_ENDIAN__) 134 | return arg; 135 | #else 136 | return CASwapFloat64(arg); 137 | #endif 138 | } 139 | 140 | CF_INLINE Float32 CASwapFloat32HostToLittle(Float32 arg) { 141 | #if defined(__LITTLE_ENDIAN__) 142 | return arg; 143 | #else 144 | return CASwapFloat32(arg); 145 | #endif 146 | } 147 | 148 | CF_INLINE Float64 CASwapFloat64HostToLittle(Float64 arg) { 149 | #if defined(__LITTLE_ENDIAN__) 150 | return arg; 151 | #else 152 | return CASwapFloat64(arg); 153 | #endif 154 | } 155 | 156 | 157 | #if defined(__cplusplus) 158 | } 159 | #endif 160 | 161 | #endif -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CADebugPrintf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugPrintf.cpp 3 | Abstract: CADebugPrintf.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | //================================================================================================== 48 | // Includes 49 | //================================================================================================== 50 | 51 | // Self Include 52 | #include "CADebugPrintf.h" 53 | 54 | #if DEBUG || CoreAudio_Debug 55 | 56 | #if TARGET_OS_WIN32 57 | #include 58 | #include 59 | #include 60 | extern "C" 61 | int CAWin32DebugPrintf(char* inFormat, ...) 62 | { 63 | char theMessage[1024]; 64 | va_list theArguments; 65 | va_start(theArguments, inFormat); 66 | _vsnprintf(theMessage, 1024, inFormat, theArguments); 67 | va_end(theArguments); 68 | OutputDebugString(theMessage); 69 | return 0; 70 | } 71 | #endif 72 | 73 | #if defined(CoreAudio_UseSideFile) 74 | #include 75 | FILE* sDebugPrintfSideFile = NULL; 76 | extern "C" 77 | void OpenDebugPrintfSideFile() 78 | { 79 | if(sDebugPrintfSideFile == NULL) 80 | { 81 | char theFileName[1024]; 82 | snprintf(theFileName, sizeof(theFileName), CoreAudio_UseSideFile, getpid()); 83 | sDebugPrintfSideFile = fopen(theFileName, "a+"); 84 | DebugPrintfRtn(DebugPrintfFileComma "\n------------------------------\n"); 85 | } 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CADebugPrintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugPrintf.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CADebugPrintf_h__) 48 | #define __CADebugPrintf_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 55 | #include 56 | #else 57 | #include "CoreAudioTypes.h" 58 | #endif 59 | 60 | //============================================================================= 61 | // Macros to redirect debugging output to various logging services 62 | //============================================================================= 63 | 64 | //#define CoreAudio_UseSysLog 1 65 | //#define CoreAudio_UseSideFile "/CoreAudio-%d.txt" 66 | 67 | #if DEBUG || CoreAudio_Debug 68 | 69 | #if TARGET_OS_WIN32 70 | #if defined(__cplusplus) 71 | extern "C" 72 | #endif 73 | extern int CAWin32DebugPrintf(char* inFormat, ...); 74 | #define DebugPrintfRtn CAWin32DebugPrintf 75 | #define DebugPrintfFile 76 | #define DebugPrintfLineEnding "\n" 77 | #define DebugPrintfFileComma 78 | #else 79 | #if CoreAudio_UseSysLog 80 | #include 81 | #define DebugPrintfRtn syslog 82 | #define DebugPrintfFile LOG_NOTICE 83 | #define DebugPrintfLineEnding "" 84 | #define DebugPrintfFileComma DebugPrintfFile, 85 | #elif defined(CoreAudio_UseSideFile) 86 | #include 87 | #if defined(__cplusplus) 88 | extern "C" 89 | #endif 90 | void OpenDebugPrintfSideFile(); 91 | extern FILE* sDebugPrintfSideFile; 92 | #define DebugPrintfRtn fprintf 93 | #define DebugPrintfFile ((sDebugPrintfSideFile != NULL) ? sDebugPrintfSideFile : stderr) 94 | #define DebugPrintfLineEnding "\n" 95 | #define DebugPrintfFileComma DebugPrintfFile, 96 | #else 97 | #include 98 | #define DebugPrintfRtn fprintf 99 | #define DebugPrintfFile stderr 100 | #define DebugPrintfLineEnding "\n" 101 | #define DebugPrintfFileComma DebugPrintfFile, 102 | #endif 103 | #endif 104 | 105 | #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__) 106 | #else 107 | #define DebugPrintfRtn 108 | #define DebugPrintfFile 109 | #define DebugPrintfLineEnding 110 | #define DebugPrintfFileComma 111 | #define DebugPrintf(inFormat, ...) 112 | #endif 113 | 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAException.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAException.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #if !defined(__CAException_h__) 48 | #define __CAException_h__ 49 | 50 | //============================================================================= 51 | // Includes 52 | //============================================================================= 53 | 54 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 55 | #include 56 | #else 57 | #include "CoreAudioTypes.h" 58 | #endif 59 | 60 | //============================================================================= 61 | // CAException 62 | //============================================================================= 63 | 64 | class CAException 65 | { 66 | 67 | public: 68 | CAException(OSStatus inError) : mError(inError) {} 69 | CAException(const CAException& inException) : mError(inException.mError) {} 70 | CAException& operator=(const CAException& inException) { mError = inException.mError; return *this; } 71 | ~CAException() {} 72 | 73 | OSStatus GetError() const { return mError; } 74 | 75 | protected: 76 | OSStatus mError; 77 | }; 78 | 79 | #define CATry try{ 80 | #define CACatch } catch(...) {} 81 | #define CASwallowException(inExpression) try { inExpression; } catch(...) {} 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAHostTimeBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAHostTimeBase.cpp 3 | Abstract: CAHostTimeBase.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | //============================================================================= 48 | // Includes 49 | //============================================================================= 50 | 51 | #include "CAHostTimeBase.h" 52 | 53 | Float64 CAHostTimeBase::sFrequency = 0; 54 | Float64 CAHostTimeBase::sInverseFrequency = 0; 55 | UInt32 CAHostTimeBase::sMinDelta = 0; 56 | UInt32 CAHostTimeBase::sToNanosNumerator = 0; 57 | UInt32 CAHostTimeBase::sToNanosDenominator = 0; 58 | pthread_once_t CAHostTimeBase::sIsInited = PTHREAD_ONCE_INIT; 59 | #if Track_Host_TimeBase 60 | UInt64 CAHostTimeBase::sLastTime = 0; 61 | #endif 62 | 63 | //============================================================================= 64 | // CAHostTimeBase 65 | // 66 | // This class provides platform independent access to the host's time base. 67 | //============================================================================= 68 | 69 | void CAHostTimeBase::Initialize() 70 | { 71 | // get the info about Absolute time 72 | #if TARGET_OS_MAC 73 | struct mach_timebase_info theTimeBaseInfo; 74 | mach_timebase_info(&theTimeBaseInfo); 75 | sMinDelta = 1; 76 | sToNanosNumerator = theTimeBaseInfo.numer; 77 | sToNanosDenominator = theTimeBaseInfo.denom; 78 | 79 | // the frequency of that clock is: (sToNanosDenominator / sToNanosNumerator) * 10^9 80 | sFrequency = static_cast(sToNanosDenominator) / static_cast(sToNanosNumerator); 81 | sFrequency *= 1000000000.0; 82 | #elif TARGET_OS_WIN32 83 | LARGE_INTEGER theFrequency; 84 | QueryPerformanceFrequency(&theFrequency); 85 | sMinDelta = 1; 86 | sToNanosNumerator = 1000000000ULL; 87 | sToNanosDenominator = *((UInt64*)&theFrequency); 88 | sFrequency = static_cast(*((UInt64*)&theFrequency)); 89 | #endif 90 | sInverseFrequency = 1.0 / sFrequency; 91 | 92 | #if Log_Host_Time_Base_Parameters 93 | DebugPrintf("Host Time Base Parameters"); 94 | DebugPrintf(" Minimum Delta: %lu", (unsigned long)sMinDelta); 95 | DebugPrintf(" Frequency: %f", sFrequency); 96 | DebugPrintf(" To Nanos Numerator: %lu", (unsigned long)sToNanosNumerator); 97 | DebugPrintf(" To Nanos Denominator: %lu", (unsigned long)sToNanosDenominator); 98 | #endif 99 | } 100 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAMath.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAMath_h__ 48 | #define __CAMath_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #else 53 | #include 54 | #endif 55 | 56 | inline bool fiszero(Float64 f) { return (f == 0.); } 57 | inline bool fiszero(Float32 f) { return (f == 0.f); } 58 | 59 | inline bool fnonzero(Float64 f) { return !fiszero(f); } 60 | inline bool fnonzero(Float32 f) { return !fiszero(f); } 61 | 62 | inline bool fequal(const Float64 &a, const Float64 &b) { return a == b; } 63 | inline bool fequal(const Float32 &a, const Float32 &b) { return a == b; } 64 | 65 | inline bool fnotequal(const Float64 &a, const Float64 &b) { return !fequal(a, b); } 66 | inline bool fnotequal(const Float32 &a, const Float32 &b) { return !fequal(a, b); } 67 | 68 | #endif // __CAMath_h__ 69 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAMutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAMutex.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAMutex_h__ 48 | #define __CAMutex_h__ 49 | 50 | //================================================================================================== 51 | // Includes 52 | //================================================================================================== 53 | 54 | // System Includes 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include 59 | #endif 60 | 61 | #if TARGET_OS_MAC 62 | #include 63 | #elif TARGET_OS_WIN32 64 | #include 65 | #else 66 | #error Unsupported operating system 67 | #endif 68 | 69 | //================================================================================================== 70 | // A recursive mutex. 71 | //================================================================================================== 72 | 73 | class CAMutex 74 | { 75 | // Construction/Destruction 76 | public: 77 | CAMutex(const char* inName); 78 | virtual ~CAMutex(); 79 | 80 | // Actions 81 | public: 82 | virtual bool Lock(); 83 | virtual void Unlock(); 84 | virtual bool Try(bool& outWasLocked); // returns true if lock is free, false if not 85 | 86 | virtual bool IsFree() const; 87 | virtual bool IsOwnedByCurrentThread() const; 88 | 89 | // Implementation 90 | protected: 91 | const char* mName; 92 | #if TARGET_OS_MAC 93 | pthread_t mOwner; 94 | pthread_mutex_t mMutex; 95 | #elif TARGET_OS_WIN32 96 | UInt32 mOwner; 97 | HANDLE mMutex; 98 | #endif 99 | 100 | // Helper class to manage taking and releasing recursively 101 | public: 102 | class Locker 103 | { 104 | 105 | // Construction/Destruction 106 | public: 107 | Locker(CAMutex& inMutex) : mMutex(&inMutex), mNeedsRelease(false) { mNeedsRelease = mMutex->Lock(); } 108 | Locker(CAMutex* inMutex) : mMutex(inMutex), mNeedsRelease(false) { mNeedsRelease = (mMutex != NULL && mMutex->Lock()); } 109 | // in this case the mutex can be null 110 | ~Locker() { if(mNeedsRelease) { mMutex->Unlock(); } } 111 | 112 | 113 | private: 114 | Locker(const Locker&); 115 | Locker& operator=(const Locker&); 116 | 117 | // Implementation 118 | private: 119 | CAMutex* mMutex; 120 | bool mNeedsRelease; 121 | 122 | }; 123 | 124 | // Unlocker 125 | class Unlocker 126 | { 127 | public: 128 | Unlocker(CAMutex& inMutex); 129 | ~Unlocker(); 130 | 131 | private: 132 | CAMutex& mMutex; 133 | bool mNeedsLock; 134 | 135 | // Hidden definitions of copy ctor, assignment operator 136 | Unlocker(const Unlocker& copy); // Not implemented 137 | Unlocker& operator=(const Unlocker& copy); // Not implemented 138 | }; 139 | 140 | // you can use this with Try - if you take the lock in try, pass in the outWasLocked var 141 | class Tryer { 142 | 143 | // Construction/Destruction 144 | public: 145 | Tryer (CAMutex &mutex) : mMutex(mutex), mNeedsRelease(false), mHasLock(false) { mHasLock = mMutex.Try (mNeedsRelease); } 146 | ~Tryer () { if (mNeedsRelease) mMutex.Unlock(); } 147 | 148 | bool HasLock () const { return mHasLock; } 149 | 150 | private: 151 | Tryer(const Tryer&); 152 | Tryer& operator=(const Tryer&); 153 | 154 | // Implementation 155 | private: 156 | CAMutex & mMutex; 157 | bool mNeedsRelease; 158 | bool mHasLock; 159 | }; 160 | }; 161 | 162 | 163 | #endif // __CAMutex_h__ 164 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAReferenceCounted.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAReferenceCounted.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAReferenceCounted_h__ 48 | #define __CAReferenceCounted_h__ 49 | 50 | #include "CAAtomic.h" 51 | 52 | // base class for reference-counted objects 53 | class CAReferenceCounted { 54 | public: 55 | CAReferenceCounted() : mRefCount(1) {} 56 | 57 | void retain() { CAAtomicIncrement32(&mRefCount); } 58 | 59 | void release() 60 | { 61 | SInt32 rc = CAAtomicDecrement32(&mRefCount); 62 | if (rc == 0) { 63 | releaseObject(); 64 | } 65 | } 66 | 67 | 68 | class Retainer { 69 | public: 70 | Retainer(CAReferenceCounted *obj) : mObject(obj) { mObject->retain(); } 71 | ~Retainer() { mObject->release(); } 72 | 73 | private: 74 | CAReferenceCounted * mObject; 75 | }; 76 | 77 | protected: 78 | virtual ~CAReferenceCounted() { } 79 | 80 | virtual void releaseObject () 81 | { 82 | delete this; 83 | } 84 | 85 | #if DEBUG 86 | public: 87 | #endif 88 | SInt32 GetReferenceCount() const { return mRefCount; } 89 | private: 90 | SInt32 mRefCount; 91 | 92 | CAReferenceCounted(const CAReferenceCounted &a); 93 | CAReferenceCounted &operator=(const CAReferenceCounted &a); 94 | }; 95 | 96 | 97 | #endif // __CAReferenceCounted_h__ 98 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAVectorUnit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnit.cpp 3 | Abstract: CAVectorUnit.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "CAVectorUnit.h" 48 | 49 | #if !TARGET_OS_WIN32 50 | #include 51 | #elif HAS_IPP 52 | #include "ippdefs.h" 53 | #include "ippcore.h" 54 | #endif 55 | 56 | int gCAVectorUnitType = kVecUninitialized; 57 | 58 | #if TARGET_OS_WIN32 59 | // Use cpuid to check if SSE2 is available. 60 | // Before calling this function make sure cpuid is available 61 | static SInt32 IsSSE2Available() 62 | { 63 | int return_value; 64 | 65 | { 66 | int r_edx; 67 | _asm 68 | { 69 | mov eax, 0x01 70 | cpuid 71 | mov r_edx, edx 72 | } 73 | return_value = (r_edx >> 26) & 0x1; 74 | } 75 | return return_value; 76 | } 77 | 78 | // Use cpuid to check if SSE3 is available. 79 | // Before calling this function make sure cpuid is available 80 | static SInt32 IsSSE3Available() 81 | { 82 | SInt32 return_value; 83 | 84 | { 85 | SInt32 r_ecx; 86 | _asm 87 | { 88 | mov eax, 0x01 89 | cpuid 90 | mov r_ecx, ecx 91 | } 92 | return_value = r_ecx & 0x1; 93 | } 94 | return return_value; 95 | } 96 | 97 | // Return true if the cpuid instruction is available. 98 | // The cpuid instruction is available if bit 21 in the EFLAGS register can be changed 99 | // This function may not work on Intel CPUs prior to Pentium (didn't test) 100 | static bool IsCpuidAvailable() 101 | { 102 | SInt32 return_value = 0x0; 103 | _asm{ 104 | pushfd ; //push original EFLAGS 105 | pop eax ; //get original EFLAGS 106 | mov ecx, eax ; //save original EFLAGS 107 | xor eax, 200000h ; //flip ID bit in EFLAGS 108 | push eax ; //save new EFLAGS value on stack 109 | popfd ; //replace current EFLAGS value 110 | pushfd ; //get new EFLAGS 111 | pop eax ; //store new EFLAGS in EAX 112 | xor eax, ecx ; 113 | je end_cpuid_identify ; //can't toggle ID bit 114 | mov return_value, 0x1; 115 | end_cpuid_identify: 116 | nop; 117 | } 118 | return return_value; 119 | } 120 | 121 | #endif 122 | 123 | SInt32 CAVectorUnit_Examine() 124 | { 125 | int result = kVecNone; 126 | 127 | #if TARGET_OS_WIN32 128 | #if HAS_IPP 129 | // Initialize the static IPP library! This needs to be done before 130 | // any IPP function calls, otherwise we may have a performance penalty 131 | int status = ippStaticInit(); 132 | if ( status == ippStsNonIntelCpu ) 133 | { 134 | IppCpuType cpuType = ippGetCpuType(); 135 | if ( cpuType >= ippCpuSSE || cpuType <= ippCpuSSE42 ) 136 | ippStaticInitCpu( cpuType ); 137 | } 138 | #endif 139 | { 140 | // On Windows we use cpuid to detect the vector unit because it works on Intel and AMD. 141 | // The IPP library does not detect SSE on AMD processors. 142 | if (IsCpuidAvailable()) 143 | { 144 | if(IsSSE3Available()) 145 | { 146 | result = kVecSSE3; 147 | } 148 | else if(IsSSE2Available()) 149 | { 150 | result = kVecSSE2; 151 | } 152 | } 153 | } 154 | #elif TARGET_OS_MAC 155 | #if DEBUG 156 | if (getenv("CA_NoVector")) { 157 | fprintf(stderr, "CA_NoVector set; Vector unit optimized routines will be bypassed\n"); 158 | return result; 159 | } 160 | else 161 | #endif 162 | { 163 | #if (TARGET_CPU_PPC || TARGET_CPU_PPC64) 164 | int sels[2] = { CTL_HW, HW_VECTORUNIT }; 165 | int vType = 0; //0 == scalar only 166 | size_t length = sizeof(vType); 167 | int error = sysctl(sels, 2, &vType, &length, NULL, 0); 168 | if (!error && vType > 0) 169 | result = kVecAltivec; 170 | #elif (TARGET_CPU_X86 || TARGET_CPU_X86_64) 171 | static const struct { const char* kName; const int kVectype; } kStringVectypes[] = { 172 | { "hw.optional.avx1_0", kVecAVX1 }, { "hw.optional.sse3", kVecSSE3 }, { "hw.optional.sse2", kVecSSE2 } 173 | }; 174 | static const size_t kNumStringVectypes = sizeof(kStringVectypes)/sizeof(kStringVectypes[0]); 175 | int i = 0, answer = 0; 176 | while(i != kNumStringVectypes) 177 | { 178 | size_t length = sizeof(answer); 179 | int error = sysctlbyname(kStringVectypes[i].kName, &answer, &length, NULL, 0); 180 | if (!error && answer) 181 | { 182 | result = kStringVectypes[i].kVectype; 183 | break; 184 | } 185 | ++i; 186 | }; 187 | #elif CA_ARM_NEON 188 | result = kVecNeon; 189 | #endif 190 | } 191 | #endif 192 | gCAVectorUnitType = result; 193 | return result; 194 | } 195 | 196 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAVectorUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnit.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAVectorUnit_h__ 48 | #define __CAVectorUnit_h__ 49 | 50 | #include 51 | #include "CAVectorUnitTypes.h" 52 | #include 53 | #include 54 | 55 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 56 | #include 57 | #else 58 | #include "CFBase.h" 59 | #endif 60 | 61 | // Unify checks for vector units. 62 | // Allow setting an environment variable "CA_NoVector" to turn off vectorized code at runtime (very useful for performance testing). 63 | 64 | extern int gCAVectorUnitType; 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | extern SInt32 CAVectorUnit_Examine(); // expensive. use GetType() for lazy initialization and caching. 71 | 72 | static inline SInt32 CAVectorUnit_GetType() 73 | { 74 | int x = gCAVectorUnitType; 75 | return (x != kVecUninitialized) ? x : CAVectorUnit_Examine(); 76 | } 77 | 78 | static inline Boolean CAVectorUnit_HasVectorUnit() 79 | { 80 | return CAVectorUnit_GetType() > kVecNone; 81 | } 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | 88 | #ifdef __cplusplus 89 | class CAVectorUnit { 90 | public: 91 | static SInt32 GetVectorUnitType() { return CAVectorUnit_GetType(); } 92 | static bool HasVectorUnit() { return GetVectorUnitType() > kVecNone; } 93 | static bool HasAltivec() { return GetVectorUnitType() == kVecAltivec; } 94 | static bool HasSSE2() { return GetVectorUnitType() >= kVecSSE2; } 95 | static bool HasSSE3() { return GetVectorUnitType() >= kVecSSE3; } 96 | static bool HasAVX1() { return GetVectorUnitType() >= kVecAVX1; } 97 | static bool HasNeon() { return GetVectorUnitType() == kVecNeon; } 98 | }; 99 | #endif 100 | 101 | #endif // __CAVectorUnit_h__ 102 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAVectorUnitTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnitTypes.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAVectorUnitTypes_h__ 48 | #define __CAVectorUnitTypes_h__ 49 | 50 | enum { 51 | kVecUninitialized = -1, 52 | kVecNone = 0, 53 | kVecAltivec = 1, 54 | kVecSSE2 = 100, 55 | kVecSSE3 = 101, 56 | kVecAVX1 = 110, 57 | kVecNeon = 200 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/PublicUtility/CAXException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAXException.cpp 3 | Abstract: CAXException.h 4 | Version: 1.0.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #include "CAXException.h" 48 | 49 | CAXException::WarningHandler CAXException::sWarningHandler = NULL; 50 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbob/AudioUnitTemplates/c7133512777705c0ae727e2df57e9ccd61088549/Audio Unit/Monotimbral Synth.xctemplate/TemplateIcon.icns -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/___PACKAGENAMEASIDENTIFIER___.h: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PACKAGENAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | #ifndef _____FILEBASENAME_____ 10 | #define _____FILEBASENAME_____ 11 | 12 | #include "AUInstrumentBase.h" 13 | #include "___PACKAGENAMEASIDENTIFIER___Version.h" 14 | 15 | static const UInt32 kNumNotes = 12; 16 | 17 | // Define constants to identify the parameters. 18 | enum Parameter { 19 | // kParameter_Zero = 0, 20 | // kParameter_One = 1, 21 | kNumberOfParameters 22 | }; 23 | 24 | // Define constants to identify factory presets. 25 | enum Preset { 26 | kPreset_Default = 0, 27 | // kPreset_One = 1, 28 | // kPreset_Two = 2, 29 | kNumberOfPresets 30 | }; 31 | 32 | struct ___PACKAGENAMEASIDENTIFIER___Note : public SynthNote { 33 | 34 | public: 35 | virtual ~___PACKAGENAMEASIDENTIFIER___Note() {} 36 | 37 | virtual bool Attack(const MusicDeviceNoteParams &inParams); 38 | virtual void Kill(UInt32 inFrame); // voice is being stolen. 39 | virtual void Release(UInt32 inFrame); 40 | virtual void FastRelease(UInt32 inFrame); 41 | virtual Float32 Amplitude(); 42 | virtual OSStatus Render(UInt64 inAbsoluteSampleFrame, 43 | UInt32 inNumFrames, 44 | AudioBufferList** inBufferList, 45 | UInt32 inOutBusCount); 46 | 47 | private: 48 | double phase, amp, maxamp; 49 | double up_slope, dn_slope, fast_dn_slope; 50 | 51 | }; 52 | 53 | class ___PACKAGENAMEASIDENTIFIER___ : public AUMonotimbralInstrumentBase 54 | { 55 | public: 56 | ___PACKAGENAMEASIDENTIFIER___(AudioUnit inComponentInstance); 57 | virtual ~___PACKAGENAMEASIDENTIFIER___(); 58 | 59 | virtual OSStatus Initialize(); 60 | virtual void Cleanup(); 61 | virtual OSStatus Version() { return k___PACKAGENAMEASIDENTIFIER___Version; } 62 | 63 | virtual AUElement *CreateElement(AudioUnitScope scope, 64 | AudioUnitElement element); 65 | 66 | virtual OSStatus GetParameterInfo(AudioUnitScope inScope, 67 | AudioUnitParameterID inParameterID, 68 | AudioUnitParameterInfo &outParameterInfo); 69 | 70 | private: 71 | ___PACKAGENAMEASIDENTIFIER___Note mNotes[kNumNotes]; 72 | 73 | }; 74 | 75 | #endif /* !_____FILEBASENAME_____ */ 76 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/___PACKAGENAMEASIDENTIFIER___Version.h: -------------------------------------------------------------------------------- 1 | #ifndef _____FILEBASENAME_____ 2 | #define _____FILEBASENAME_____ 3 | 4 | #ifdef DEBUG 5 | #define k___PACKAGENAMEASIDENTIFIER___Version 0xFFFFFFFF 6 | #else 7 | #define k___PACKAGENAMEASIDENTIFIER___Version 0x00010000 8 | #endif 9 | 10 | #endif /* _____FILEBASENAME_____ */ 11 | -------------------------------------------------------------------------------- /Audio Unit/Monotimbral Synth.xctemplate/___PACKAGENAMEASIDENTIFIER____Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files. 3 | // 4 | 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Audio Unit Templates for OS X 2 | 3 | Easily create Audio Units in Xcode. 4 | 5 | These templates customize Xcode's New Project dialog to create Audio 6 | Unit projects. At the moment, only Audio Effect and Monotimbral Synth 7 | units are implemented. 8 | 9 | ## How to Use 10 | 11 | Open Xcode. Create a new project. Select Audio Unit as the project 12 | category, then select the type of unit. 13 | 14 | See the [Audio Unit Programming Guide](https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/Introduction/Introduction.html) for more information. 15 | 16 | ## How to Install 17 | 18 | Copy the `Audio Unit` folder into your 19 | `~/Library/Developer/Xcode/Templates` folder. 20 | 21 | 22 | ## Compatibility 23 | 24 | It works on my Mac running OS X 10.10 "Yosemite" and Xcode Version 6.1 25 | (6A1052d). It might possibly work on some other Mac or software version. 26 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dest="$HOME/Library/Developer/Xcode/Templates/Audio Unit" 4 | 5 | rm -rf "$dest" 6 | cp -a "Audio Unit" "$dest" 7 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | Good luck figuring these out. I wrote these scripts two years ago, 2 | and I don't really remember what they do. 3 | 4 | I think templates.py looks through all the Xcode project templates it 5 | can find and prints things about them; I used it to reverse engineer 6 | the template format. 7 | 8 | And print-source-hierarchy creates a plist-XML snippet that was pasted 9 | into the .plist files at some point. 10 | -------------------------------------------------------------------------------- /scripts/print-source-hierarchy.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | aubase_path = ''' 4 | AUPublic/AUBase/AUBase.cpp 5 | AUPublic/AUBase/AUBase.h 6 | AUPublic/AUBase/AUDispatch.cpp 7 | AUPublic/AUBase/AUDispatch.h 8 | AUPublic/AUBase/AUInputElement.cpp 9 | AUPublic/AUBase/AUInputElement.h 10 | AUPublic/AUBase/AUOutputElement.cpp 11 | AUPublic/AUBase/AUOutputElement.h 12 | AUPublic/AUBase/AUPluginDispatch.cpp 13 | AUPublic/AUBase/AUPluginDispatch.h 14 | AUPublic/AUBase/AUScopeElement.cpp 15 | AUPublic/AUBase/AUScopeElement.h 16 | AUPublic/AUBase/ComponentBase.cpp 17 | AUPublic/AUBase/ComponentBase.h 18 | AUPublic/Utility/AUBuffer.cpp 19 | AUPublic/Utility/AUBuffer.h 20 | '''.split() 21 | 22 | aufx_paths = ''' 23 | AUPublic/OtherBases/AUEffectBase.cpp 24 | AUPublic/OtherBases/AUEffectBase.h 25 | AUPublic/Utility/AUBaseHelper.cpp 26 | AUPublic/Utility/AUBaseHelper.h 27 | AUPublic/Utility/AUSilentTimeout.h 28 | PublicUtility/CAAtomic.h 29 | PublicUtility/CAAtomicStack.h 30 | PublicUtility/CAAudioChannelLayout.cpp 31 | PublicUtility/CAAudioChannelLayout.h 32 | PublicUtility/CAAutoDisposer.h 33 | PublicUtility/CABufferList.cpp 34 | PublicUtility/CABufferList.h 35 | PublicUtility/CAByteOrder.h 36 | PublicUtility/CADebugMacros.cpp 37 | PublicUtility/CADebugMacros.h 38 | PublicUtility/CADebugPrintf.h 39 | PublicUtility/CADebugger.cpp 40 | PublicUtility/CADebugger.h 41 | PublicUtility/CAException.h 42 | PublicUtility/CAGuard.cpp 43 | PublicUtility/CAGuard.h 44 | PublicUtility/CAHostTimeBase.cpp 45 | PublicUtility/CAHostTimeBase.h 46 | PublicUtility/CALogMacros.h 47 | PublicUtility/CAMath.h 48 | PublicUtility/CAMutex.cpp 49 | PublicUtility/CAMutex.h 50 | PublicUtility/CAReferenceCounted.h 51 | PublicUtility/CAStreamBasicDescription.cpp 52 | PublicUtility/CAStreamBasicDescription.h 53 | PublicUtility/CAThreadSafeList.h 54 | PublicUtility/CAVectorUnit.cpp 55 | PublicUtility/CAVectorUnit.h 56 | PublicUtility/CAVectorUnitTypes.h 57 | PublicUtility/CAXException.cpp 58 | PublicUtility/CAXException.h 59 | '''.split() 60 | 61 | aumf_paths = ''' 62 | AUPublic/AUInstrumentBase/AUInstrumentBase.cpp 63 | AUPublic/AUInstrumentBase/AUInstrumentBase.h 64 | AUPublic/AUInstrumentBase/LockFreeFIFO.h 65 | AUPublic/AUInstrumentBase/MIDIControlHandler.h 66 | AUPublic/AUInstrumentBase/SynthElement.cpp 67 | AUPublic/AUInstrumentBase/SynthElement.h 68 | AUPublic/AUInstrumentBase/SynthEvent.h 69 | AUPublic/AUInstrumentBase/SynthNote.cpp 70 | AUPublic/AUInstrumentBase/SynthNote.h 71 | AUPublic/AUInstrumentBase/SynthNoteList.cpp 72 | AUPublic/AUInstrumentBase/SynthNoteList.h 73 | AUPublic/OtherBases/AUMIDIBase.cpp 74 | AUPublic/OtherBases/AUMIDIBase.h 75 | AUPublic/OtherBases/MusicDeviceBase.cpp 76 | AUPublic/OtherBases/MusicDeviceBase.h 77 | AUPublic/Utility/AUBaseHelper.cpp 78 | AUPublic/Utility/AUBaseHelper.h 79 | AUPublic/Utility/AUMIDIDefs.h 80 | PublicUtility/CAAUMIDIMap.cpp 81 | PublicUtility/CAAUMIDIMap.h 82 | PublicUtility/CAAUMIDIMapManager.cpp 83 | PublicUtility/CAAUMIDIMapManager.h 84 | PublicUtility/CAAtomic.h 85 | PublicUtility/CAAtomicStack.h 86 | PublicUtility/CAByteOrder.h 87 | PublicUtility/CAAudioChannelLayout.cpp 88 | PublicUtility/CAAudioChannelLayout.h 89 | PublicUtility/CAAutoDisposer.h 90 | PublicUtility/CABufferList.cpp 91 | PublicUtility/CABufferList.h 92 | PublicUtility/CADebugMacros.h 93 | PublicUtility/CADebugPrintf.cpp 94 | PublicUtility/CADebugPrintf.h 95 | PublicUtility/CAException.h 96 | PublicUtility/CAHostTimeBase.cpp 97 | PublicUtility/CAHostTimeBase.h 98 | PublicUtility/CAMath.h 99 | PublicUtility/CAMutex.cpp 100 | PublicUtility/CAMutex.h 101 | PublicUtility/CAReferenceCounted.h 102 | PublicUtility/CAStreamBasicDescription.cpp 103 | PublicUtility/CAStreamBasicDescription.h 104 | PublicUtility/CAThreadSafeList.h 105 | PublicUtility/CAVectorUnit.cpp 106 | PublicUtility/CAVectorUnit.h 107 | PublicUtility/CAVectorUnitTypes.h 108 | PublicUtility/CAXException.cpp 109 | PublicUtility/CAXException.h 110 | '''.split() 111 | 112 | paths = aumf_paths 113 | 114 | x = ''' 115 | %(path)s 116 | 117 | Path 118 | %(path)s 119 | Group 120 | 121 | %(dstrings)s 122 | 123 | 124 | 125 | '''.strip('\n') 126 | 127 | for path in paths: 128 | print(' %s' % path) 129 | 130 | print() 131 | 132 | for path in paths: 133 | dir, file = os.path.split(path) 134 | dstrings = '\n '.join('%s' % d 135 | for d in dir.split('/')) 136 | print(x % locals()) 137 | 138 | -------------------------------------------------------------------------------- /scripts/read-template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import fileinput 4 | import pprint 5 | import subprocess 6 | import sys 7 | import xml.etree.ElementTree as ET 8 | 9 | 10 | def hands_of_blue(seq): 11 | for i, item in enumerate(seq): 12 | if i % 2 == 0: 13 | prev = item 14 | else: 15 | yield (prev, item) 16 | del prev 17 | assert 'prev' not in locals() 18 | 19 | 20 | class PList: 21 | def __init__(self, node): 22 | self.tag = node.tag 23 | self.attrib = node.attrib 24 | self.children = [type(self).from_XML_tree(c) for c in node] 25 | 26 | def __iter__(self): 27 | return iter(self.children) 28 | 29 | def __str__(self): 30 | return 'PList' + str(self.attrib) 31 | 32 | @classmethod 33 | def from_XML_tree(cls, node): 34 | if node.tag == 'plist': 35 | return cls(node) 36 | if node.tag == 'dict': 37 | return dict((k.text, cls.from_XML_tree(v)) 38 | for (k, v) in hands_of_blue(node)) 39 | elif node.tag == 'array': 40 | return [cls.from_XML_tree(child) for child in node] 41 | elif node.tag == 'string': 42 | return str(node.text) 43 | elif node.tag == 'integer': 44 | return int(node.text) 45 | elif node.tag == 'real': 46 | return float(node.text) 47 | elif node.tag == 'true': 48 | return True 49 | elif node.tag == 'false': 50 | return False 51 | else: 52 | assert False, node.tag 53 | 54 | 55 | def process_stream(s, name): 56 | try: 57 | e = ET.fromstringlist(s) 58 | except: 59 | print('XML error in ' + name, file=sys.stderr) 60 | raise 61 | ie = PList.from_XML_tree(e) 62 | assert(type(ie) is PList) 63 | assert(len(ie.children) == 1) 64 | assert(type(ie.children[0]) is dict) 65 | pprint.pprint(ie.children[0]) 66 | # for k in ie.children[0]: 67 | # print(k) 68 | 69 | 70 | def process_file(file): 71 | cmd = 'plutil -convert xml1 -o -'.split() + [file or '-'] 72 | with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc: 73 | process_stream(proc.stdout, file or 'standard input') 74 | 75 | 76 | def main(argv): 77 | if len(argv) == 1: 78 | process_file(None) 79 | else: 80 | for file in argv[1:]: 81 | process_file(file) 82 | 83 | if __name__ == '__main__': 84 | main(sys.argv) 85 | --------------------------------------------------------------------------------