summaryrefslogtreecommitdiff
path: root/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase
diff options
context:
space:
mode:
Diffstat (limited to 'libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase')
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp140
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.h100
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/LockFreeFIFO.h54
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/MIDIControlHandler.h18
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.cpp50
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.h62
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthEvent.h44
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.cpp42
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.h38
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.cpp20
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.h48
11 files changed, 308 insertions, 308 deletions
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
index 1ce8b308b4..74336d92e0 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
@@ -2,14 +2,14 @@
File: AUInstrumentBase.cpp
Abstract: AUInstrumentBase.h
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include "AUInstrumentBase.h"
#include "AUMIDIDefs.h"
@@ -58,12 +58,12 @@
const UInt32 kEventQueueSize = 1024;
AUInstrumentBase::AUInstrumentBase(
- AudioComponentInstance inInstance,
+ AudioComponentInstance inInstance,
UInt32 numInputs,
UInt32 numOutputs,
UInt32 numGroups,
UInt32 numParts)
- : MusicDeviceBase(inInstance, numInputs, numOutputs, numGroups),
+ : MusicDeviceBase(inInstance, numInputs, numOutputs, numGroups),
mAbsoluteSampleFrame(0),
mEventQueue(kEventQueueSize),
mNumNotes(0),
@@ -79,7 +79,7 @@ AUInstrumentBase::AUInstrumentBase(
mFreeNotes.mState = kNoteState_Free;
SetWantsRenderThreadID(true);
}
-
+
AUInstrumentBase::~AUInstrumentBase()
{
@@ -100,12 +100,12 @@ AUElement * AUInstrumentBase::CreateElement(AudioUnitScope inScope, AudioUnitEle
return MusicDeviceBase::CreateElement(inScope, element);
}
-void AUInstrumentBase::CreateExtendedElements()
+void AUInstrumentBase::CreateExtendedElements()
{
Parts().Initialize(this, kAudioUnitScope_Part, mInitNumPartEls);
}
-AUScope * AUInstrumentBase::GetScopeExtended (AudioUnitScope inScope)
+AUScope * AUInstrumentBase::GetScopeExtended (AudioUnitScope inScope)
{
if (inScope == kAudioUnitScope_Part)
return &mPartScope;
@@ -122,7 +122,7 @@ void AUInstrumentBase::SetNotes(UInt32 inNumNotes, UInt32 inMaxActiveNotes, Syn
mMaxActiveNotes = inMaxActiveNotes;
mNoteSize = inNoteDataSize;
mNotes = inNotes;
-
+
for (UInt32 i=0; i<mNumNotes; ++i)
{
SynthNote *note = GetNote(i);
@@ -138,7 +138,7 @@ UInt32 AUInstrumentBase::CountActiveNotes()
for (UInt32 i=0; i<mNumNotes; ++i)
{
SynthNote *note = GetNote(i);
- if (note->GetState() <= kNoteState_Released)
+ if (note->GetState() <= kNoteState_Released)
sum++;
}
return sum;
@@ -165,16 +165,16 @@ OSStatus AUInstrumentBase::Initialize()
TO DO:
Currently ValidFormat will check and validate that the num channels is not being
changed if the AU doesn't support the SupportedNumChannels property - which is correct
-
+
What needs to happen here is that IFF the AU does support this property, (ie, the AU
can be configured to have different num channels than its original configuration) then
the state of the AU at Initialization needs to be validated.
-
+
This is work still to be done - see AUEffectBase for the kind of logic that needs to be applied here
*/
// override to call SetNotes
-
+
mNoteIDCounter = 128; // reset this every time we initialise
mAbsoluteSampleFrame = 0;
return noErr;
@@ -199,7 +199,7 @@ OSStatus AUInstrumentBase::Reset( AudioUnitScope inScope,
for (UInt32 i=0; i<mNumNotes; ++i)
{
SynthNote *note = GetNote(i);
- if (note->IsSounding())
+ if (note->IsSounding())
note->Kill(0);
note->ListRemove();
mFreeNotes.AddNote(note);
@@ -225,7 +225,7 @@ void AUInstrumentBase::PerformEvents(const AudioTimeStamp& inTimeStamp)
#endif
SynthEvent *event;
SynthGroupElement *group;
-
+
while ((event = mEventQueue.ReadItem()) != NULL)
{
#if DEBUG_PRINT_RENDER
@@ -270,12 +270,12 @@ void AUInstrumentBase::PerformEvents(const AudioTimeStamp& inTimeStamp)
group->ResetAllControllers(event->GetOffsetSampleFrame());
break;
}
-
+
mEventQueue.AdvanceReadPtr();
}
}
-
+
OSStatus AUInstrumentBase::Render( AudioUnitRenderActionFlags & ioActionFlags,
const AudioTimeStamp & inTimeStamp,
UInt32 inNumberFrames)
@@ -311,18 +311,18 @@ OSStatus AUInstrumentBase::Render( AudioUnitRenderActionFlags & ioActionFlag
bool AUInstrumentBase::ValidFormat( AudioUnitScope inScope,
AudioUnitElement inElement,
const CAStreamBasicDescription & inNewFormat)
-{
+{
// if the AU supports this, then we should just let this go through to the Init call
- if (SupportedNumChannels (NULL))
+ if (SupportedNumChannels (NULL))
return MusicDeviceBase::ValidFormat(inScope, inElement, inNewFormat);
bool isGood = MusicDeviceBase::ValidFormat (inScope, inElement, inNewFormat);
if (!isGood) return false;
-
+
// if we get to here, then the basic criteria is that the
// num channels cannot change on an existing bus
AUIOElement *el = GetIOElement (inScope, inElement);
- return (el->GetStreamFormat().NumberChannels() == inNewFormat.NumberChannels());
+ return (el->GetStreamFormat().NumberChannels() == inNewFormat.NumberChannels());
}
@@ -333,8 +333,8 @@ bool AUInstrumentBase::StreamFormatWritable( AudioUnitScope scope,
}
OSStatus AUInstrumentBase::RealTimeStartNote( SynthGroupElement *inGroup,
- NoteInstanceID inNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+ NoteInstanceID inNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams)
{
return noErr;
@@ -358,10 +358,10 @@ SynthGroupElement * AUInstrumentBase::GetElForGroupID (MusicDeviceGroupID inGrou
AUScope & groups = Groups();
unsigned int numEls = groups.GetNumberOfElements();
SynthGroupElement* unassignedEl = NULL;
-
+
for (unsigned int i = 0; i < numEls; ++i) {
SynthGroupElement* el = reinterpret_cast<SynthGroupElement*>(groups.GetElement(i));
- if (el->GroupID() == inGroupID)
+ if (el->GroupID() == inGroupID)
return el;
if (el->GroupID() == SynthGroupElement::kUnassignedGroup) {
unassignedEl = el;
@@ -376,14 +376,14 @@ SynthGroupElement * AUInstrumentBase::GetElForGroupID (MusicDeviceGroupID inGrou
}
OSStatus AUInstrumentBase::RealTimeStopNote(
- MusicDeviceGroupID inGroupID,
- NoteInstanceID inNoteInstanceID,
+ MusicDeviceGroupID inGroupID,
+ NoteInstanceID inNoteInstanceID,
UInt32 inOffsetSampleFrame)
{
#if DEBUG_PRINT
printf("AUInstrumentBase::RealTimeStopNote ch %d id %d\n", inGroupID, inNoteInstanceID);
#endif
-
+
SynthGroupElement *gp = (inGroupID == kMusicNoteEvent_Unused
? GetElForNoteID (inNoteInstanceID)
: GetElForGroupID(inGroupID));
@@ -391,7 +391,7 @@ OSStatus AUInstrumentBase::RealTimeStopNote(
{
gp->NoteOff (inNoteInstanceID, inOffsetSampleFrame);
}
-
+
return noErr;
}
@@ -402,7 +402,7 @@ SynthGroupElement * AUInstrumentBase::GetElForNoteID (NoteInstanceID inNoteID)
#endif
AUScope & groups = Groups();
unsigned int numEls = groups.GetNumberOfElements();
-
+
for (unsigned int i = 0; i < numEls; ++i) {
SynthGroupElement* el = reinterpret_cast<SynthGroupElement*>(groups.GetElement(i));
if (el->GetNote(inNoteID) != NULL) // searches for any note state
@@ -411,27 +411,27 @@ SynthGroupElement * AUInstrumentBase::GetElForNoteID (NoteInstanceID inNoteID)
throw static_cast<OSStatus>(kAudioUnitErr_InvalidElement);
}
-OSStatus AUInstrumentBase::StartNote( MusicDeviceInstrumentID inInstrument,
- MusicDeviceGroupID inGroupID,
- NoteInstanceID * outNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+OSStatus AUInstrumentBase::StartNote( MusicDeviceInstrumentID inInstrument,
+ MusicDeviceGroupID inGroupID,
+ NoteInstanceID * outNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams)
{
OSStatus err = noErr;
-
- NoteInstanceID noteID;
+
+ NoteInstanceID noteID;
if (outNoteInstanceID) {
noteID = NextNoteID();
*outNoteInstanceID = noteID;
} else
noteID = (UInt32)inParams.mPitch;
-
+
#if DEBUG_PRINT
printf("AUInstrumentBase::StartNote ch %u, key %u, offset %u\n", inGroupID, (unsigned) inParams.mPitch, inOffsetSampleFrame);
#endif
if (InRenderThread ())
- {
+ {
err = RealTimeStartNote(
GetElForGroupID(inGroupID),
noteID,
@@ -450,14 +450,14 @@ OSStatus AUInstrumentBase::StartNote( MusicDeviceInstrumentID inInstrument,
inOffsetSampleFrame,
&inParams
);
-
+
mEventQueue.AdvanceWritePtr();
}
return err;
}
-OSStatus AUInstrumentBase::StopNote( MusicDeviceGroupID inGroupID,
- NoteInstanceID inNoteInstanceID,
+OSStatus AUInstrumentBase::StopNote( MusicDeviceGroupID inGroupID,
+ NoteInstanceID inNoteInstanceID,
UInt32 inOffsetSampleFrame)
{
#if DEBUG_PRINT
@@ -466,7 +466,7 @@ OSStatus AUInstrumentBase::StopNote( MusicDeviceGroupID inGroupID,
OSStatus err = noErr;
if (InRenderThread ())
- {
+ {
err = RealTimeStopNote(
inGroupID,
inNoteInstanceID,
@@ -484,7 +484,7 @@ OSStatus AUInstrumentBase::StopNote( MusicDeviceGroupID inGroupID,
inOffsetSampleFrame,
NULL
);
-
+
mEventQueue.AdvanceWritePtr();
}
return err;
@@ -492,13 +492,13 @@ OSStatus AUInstrumentBase::StopNote( MusicDeviceGroupID inGroupID,
OSStatus AUInstrumentBase::SendPedalEvent(MusicDeviceGroupID inGroupID, UInt32 inEventType, UInt32 inOffsetSampleFrame)
{
-
+
if (InRenderThread ())
{
SynthGroupElement *group = GetElForGroupID(inGroupID);
if (!group)
return kAudioUnitErr_InvalidElement;
-
+
switch (inEventType)
{
case SynthEvent::kEventType_SustainOn :
@@ -532,7 +532,7 @@ OSStatus AUInstrumentBase::SendPedalEvent(MusicDeviceGroupID inGroupID, UInt32 i
if (!event) return -1; // queue full
event->Set(inEventType, inGroupID, 0, 0, NULL);
-
+
mEventQueue.AdvanceWritePtr();
}
return noErr;
@@ -576,7 +576,7 @@ OSStatus AUInstrumentBase::HandleControlChange( UInt8 inChannel,
}
return noErr;
}
-
+
OSStatus AUInstrumentBase::HandlePitchWheel( UInt8 inChannel,
UInt8 inPitch1, // LSB
UInt8 inPitch2, // MSB
@@ -592,7 +592,7 @@ OSStatus AUInstrumentBase::HandlePitchWheel( UInt8 inChannel,
return kAudioUnitErr_InvalidElement;
}
-
+
OSStatus AUInstrumentBase::HandleChannelPressure(UInt8 inChannel,
UInt8 inValue,
UInt32 inStartFrame)
@@ -647,13 +647,13 @@ OSStatus AUInstrumentBase::HandleResetAllControllers( UInt8 inChannel)
return SendPedalEvent (inChannel, SynthEvent::kEventType_ResetAllControllers, 0);
}
-
+
OSStatus AUInstrumentBase::HandleAllNotesOff( UInt8 inChannel)
{
return SendPedalEvent (inChannel, SynthEvent::kEventType_AllNotesOff, 0);
}
-
+
OSStatus AUInstrumentBase::HandleAllSoundOff( UInt8 inChannel)
{
return SendPedalEvent (inChannel, SynthEvent::kEventType_AllSoundOff, 0);
@@ -670,7 +670,7 @@ SynthNote* AUInstrumentBase::GetAFreeNote(UInt32 inFrame)
mFreeNotes.RemoveNote(note);
return note;
}
-
+
return VoiceStealing(inFrame, true);
}
@@ -724,13 +724,13 @@ SynthNote* AUInstrumentBase::VoiceStealing(UInt32 inFrame, bool inKillIt)
#if DEBUG_PRINT_NOTE
printf("no notes to steal????\n");
#endif
- return NULL; // It should be impossible to get here. It means there were no notes to kill in any state.
+ return NULL; // It should be impossible to get here. It means there were no notes to kill in any state.
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
AUMonotimbralInstrumentBase::AUMonotimbralInstrumentBase(
- AudioComponentInstance inInstance,
+ AudioComponentInstance inInstance,
UInt32 numInputs,
UInt32 numOutputs,
UInt32 numGroups,
@@ -739,28 +739,28 @@ AUMonotimbralInstrumentBase::AUMonotimbralInstrumentBase(
{
}
-OSStatus AUMonotimbralInstrumentBase::RealTimeStartNote(
- SynthGroupElement *inGroup,
- NoteInstanceID inNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+OSStatus AUMonotimbralInstrumentBase::RealTimeStartNote(
+ SynthGroupElement *inGroup,
+ NoteInstanceID inNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams)
{
#if DEBUG_PRINT_RENDER
printf("AUMonotimbralInstrumentBase::RealTimeStartNote %d\n", inNoteInstanceID);
#endif
- if (NumActiveNotes() + 1 > MaxActiveNotes())
+ if (NumActiveNotes() + 1 > MaxActiveNotes())
{
VoiceStealing(inOffsetSampleFrame, false);
}
SynthNote *note = GetAFreeNote(inOffsetSampleFrame);
if (!note) return -1;
-
+
SynthPartElement *part = GetPartElement (0); // Only one part for monotimbral
-
+
IncNumActiveNotes();
inGroup->NoteOn(note, part, inNoteInstanceID, inOffsetSampleFrame, inParams);
-
+
return noErr;
}
@@ -774,8 +774,8 @@ OSStatus AUMultitimbralInstrumentBase::GetPropertyInfo(AudioUnitPropertyID inI
Boolean & outWritable)
{
OSStatus result = noErr;
-
- switch (inID)
+
+ switch (inID)
{
#if !TARGET_OS_IPHONE
case kMusicDeviceProperty_PartGroup:
@@ -797,7 +797,7 @@ OSStatus AUMultitimbralInstrumentBase::GetProperty( AudioUnitPropertyID inID,
{
OSStatus result = noErr;
- switch (inID)
+ switch (inID)
{
#if !TARGET_OS_IPHONE
case kMusicDeviceProperty_PartGroup:
@@ -809,7 +809,7 @@ OSStatus AUMultitimbralInstrumentBase::GetProperty( AudioUnitPropertyID inID,
default:
result = AUInstrumentBase::GetProperty (inID, inScope, inElement, outData);
}
-
+
return result;
}
@@ -823,7 +823,7 @@ OSStatus AUMultitimbralInstrumentBase::SetProperty( AudioUnitPropertyID in
{
OSStatus result = noErr;
- switch (inID)
+ switch (inID)
{
#if !TARGET_OS_IPHONE
case kMusicDeviceProperty_PartGroup:
@@ -835,7 +835,7 @@ OSStatus AUMultitimbralInstrumentBase::SetProperty( AudioUnitPropertyID in
default:
result = MusicDeviceBase::SetProperty (inID, inScope, inElement, inData, inDataSize);
}
-
+
return result;
}
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.h
index 3ad7e03a66..7e3bfbf66c 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/AUInstrumentBase.h
@@ -2,14 +2,14 @@
File: AUInstrumentBase.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#ifndef __AUInstrumentBase__
#define __AUInstrumentBase__
@@ -66,7 +66,7 @@ class AUInstrumentBase : public MusicDeviceBase
{
public:
AUInstrumentBase(
- AudioComponentInstance inInstance,
+ AudioComponentInstance inInstance,
UInt32 numInputs,
UInt32 numOutputs,
UInt32 numGroups = 16,
@@ -74,7 +74,7 @@ public:
virtual ~AUInstrumentBase();
virtual OSStatus Initialize();
-
+
/*! @method Parts */
AUScope & Parts() { return mPartScope; }
@@ -92,10 +92,10 @@ public:
virtual void CreateExtendedElements();
virtual void Cleanup();
-
+
virtual OSStatus Reset( AudioUnitScope inScope,
AudioUnitElement inElement);
-
+
virtual bool ValidFormat( AudioUnitScope inScope,
AudioUnitElement inElement,
const CAStreamBasicDescription & inNewFormat);
@@ -109,35 +109,35 @@ public:
const AudioTimeStamp & inTimeStamp,
UInt32 inNumberFrames);
- virtual OSStatus StartNote( MusicDeviceInstrumentID inInstrument,
- MusicDeviceGroupID inGroupID,
- NoteInstanceID * outNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+ virtual OSStatus StartNote( MusicDeviceInstrumentID inInstrument,
+ MusicDeviceGroupID inGroupID,
+ NoteInstanceID * outNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams);
- virtual OSStatus StopNote( MusicDeviceGroupID inGroupID,
- NoteInstanceID inNoteInstanceID,
+ virtual OSStatus StopNote( MusicDeviceGroupID inGroupID,
+ NoteInstanceID inNoteInstanceID,
UInt32 inOffsetSampleFrame);
virtual OSStatus RealTimeStartNote( SynthGroupElement *inGroup,
- NoteInstanceID inNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+ NoteInstanceID inNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams);
-
- virtual OSStatus RealTimeStopNote( MusicDeviceGroupID inGroupID,
- NoteInstanceID inNoteInstanceID,
+
+ virtual OSStatus RealTimeStopNote( MusicDeviceGroupID inGroupID,
+ NoteInstanceID inNoteInstanceID,
UInt32 inOffsetSampleFrame);
-
+
virtual OSStatus HandleControlChange( UInt8 inChannel,
UInt8 inController,
UInt8 inValue,
UInt32 inStartFrame);
-
+
virtual OSStatus HandlePitchWheel( UInt8 inChannel,
UInt8 inPitch1,
UInt8 inPitch2,
UInt32 inStartFrame);
-
+
virtual OSStatus HandleChannelPressure( UInt8 inChannel,
UInt8 inValue,
UInt32 inStartFrame);
@@ -151,31 +151,31 @@ public:
UInt32 inStartFrame);
virtual OSStatus HandleResetAllControllers( UInt8 inChannel);
-
+
virtual OSStatus HandleAllNotesOff( UInt8 inChannel);
-
+
virtual OSStatus HandleAllSoundOff( UInt8 inChannel);
- SynthNote* GetNote(UInt32 inIndex)
- {
+ SynthNote* GetNote(UInt32 inIndex)
+ {
if (!mNotes)
throw std::runtime_error("no notes");
- return (SynthNote*)((char*)mNotes + inIndex * mNoteSize);
+ return (SynthNote*)((char*)mNotes + inIndex * mNoteSize);
}
-
+
SynthNote* GetAFreeNote(UInt32 inFrame);
void AddFreeNote(SynthNote* inNote);
-
+
friend class SynthGroupElement;
protected:
UInt32 NextNoteID() { return OSAtomicIncrement32((int32_t *)&mNoteIDCounter); }
-
-
- // call SetNotes in your Initialize() method to give the base class your note structures and to set the maximum
+
+
+ // call SetNotes in your Initialize() method to give the base class your note structures and to set the maximum
// number of active notes. inNoteData should be an array of size inMaxActiveNotes.
void SetNotes(UInt32 inNumNotes, UInt32 inMaxActiveNotes, SynthNote* inNotes, UInt32 inNoteSize);
-
+
void PerformEvents( const AudioTimeStamp & inTimeStamp);
OSStatus SendPedalEvent(MusicDeviceGroupID inGroupID, UInt32 inEventType, UInt32 inOffsetSampleFrame);
virtual SynthNote* VoiceStealing(UInt32 inFrame, bool inKillIt);
@@ -184,29 +184,29 @@ protected:
void IncNumActiveNotes() { ++mNumActiveNotes; }
void DecNumActiveNotes() { --mNumActiveNotes; }
UInt32 CountActiveNotes();
-
+
SynthPartElement * GetPartElement (AudioUnitElement inPartElement);
-
+
// this call throws if there's no assigned element for the group ID
virtual SynthGroupElement * GetElForGroupID (MusicDeviceGroupID inGroupID);
virtual SynthGroupElement * GetElForNoteID (NoteInstanceID inNoteID);
SInt64 mAbsoluteSampleFrame;
-
+
private:
-
+
SInt32 mNoteIDCounter;
-
+
SynthEventQueue mEventQueue;
-
+
UInt32 mNumNotes;
UInt32 mNumActiveNotes;
UInt32 mMaxActiveNotes;
- SynthNote* mNotes;
+ SynthNote* mNotes;
SynthNoteList mFreeNotes;
UInt32 mNoteSize;
-
+
AUScope mPartScope;
const UInt32 mInitNumPartEls;
};
@@ -217,15 +217,15 @@ class AUMonotimbralInstrumentBase : public AUInstrumentBase
{
public:
AUMonotimbralInstrumentBase(
- AudioComponentInstance inInstance,
+ AudioComponentInstance inInstance,
UInt32 numInputs,
UInt32 numOutputs,
UInt32 numGroups = 16,
UInt32 numParts = 1);
-
- virtual OSStatus RealTimeStartNote( SynthGroupElement *inGroup,
- NoteInstanceID inNoteInstanceID,
- UInt32 inOffsetSampleFrame,
+
+ virtual OSStatus RealTimeStartNote( SynthGroupElement *inGroup,
+ NoteInstanceID inNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams);
};
@@ -236,12 +236,12 @@ class AUMultitimbralInstrumentBase : public AUInstrumentBase
{
public:
AUMultitimbralInstrumentBase(
- AudioComponentInstance inInstance,
+ AudioComponentInstance inInstance,
UInt32 numInputs,
UInt32 numOutputs,
UInt32 numGroups,
UInt32 numParts);
-
+
virtual OSStatus GetPropertyInfo( AudioUnitPropertyID inID,
AudioUnitScope inScope,
AudioUnitElement inElement,
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/LockFreeFIFO.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/LockFreeFIFO.h
index ea6c4c26e1..f9a0ec2dfe 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/LockFreeFIFO.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/LockFreeFIFO.h
@@ -2,14 +2,14 @@
File: LockFreeFIFO.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include <libkern/OSAtomic.h>
@@ -58,22 +58,22 @@ public:
mItems = new ITEM[inMaxSize];
mMask = inMaxSize - 1;
}
-
+
~LockFreeFIFOWithFree()
{
delete [] mItems;
}
-
- void Reset()
+
+ void Reset()
{
FreeItems();
mReadIndex = 0;
mWriteIndex = 0;
mFreeIndex = 0;
}
-
- ITEM* WriteItem()
+
+ ITEM* WriteItem()
{
//printf("WriteItem %d %d\n", mReadIndex, mWriteIndex);
FreeItems(); // free items on the write thread.
@@ -81,8 +81,8 @@ public:
if (nextWriteIndex == mFreeIndex) return NULL;
return &mItems[mWriteIndex];
}
-
- ITEM* ReadItem()
+
+ ITEM* ReadItem()
{
//printf("ReadItem %d %d\n", mReadIndex, mWriteIndex);
if (mReadIndex == mWriteIndex) return NULL;
@@ -91,14 +91,14 @@ public:
void AdvanceWritePtr() { OSAtomicCompareAndSwap32(mWriteIndex, (mWriteIndex + 1) & mMask, &mWriteIndex); }
void AdvanceReadPtr() { OSAtomicCompareAndSwap32(mReadIndex, (mReadIndex + 1) & mMask, &mReadIndex); }
private:
- ITEM* FreeItem()
+ ITEM* FreeItem()
{
if (mFreeIndex == mReadIndex) return NULL;
return &mItems[mFreeIndex];
}
void AdvanceFreePtr() { OSAtomicCompareAndSwap32(mFreeIndex, (mFreeIndex + 1) & mMask, &mFreeIndex); }
-
- void FreeItems()
+
+ void FreeItems()
{
ITEM* item;
while ((item = FreeItem()) != NULL)
@@ -107,7 +107,7 @@ private:
AdvanceFreePtr();
}
}
-
+
volatile int32_t mReadIndex, mWriteIndex, mFreeIndex;
int32_t mMask;
ITEM *mItems;
@@ -129,38 +129,38 @@ public:
mItems = new ITEM[inMaxSize];
mMask = inMaxSize - 1;
}
-
+
~LockFreeFIFO()
{
delete [] mItems;
}
-
- void Reset()
+
+ void Reset()
{
mReadIndex = 0;
mWriteIndex = 0;
}
-
- ITEM* WriteItem()
+
+ ITEM* WriteItem()
{
int32_t nextWriteIndex = (mWriteIndex + 1) & mMask;
if (nextWriteIndex == mReadIndex) return NULL;
return &mItems[mWriteIndex];
}
-
- ITEM* ReadItem()
+
+ ITEM* ReadItem()
{
if (mReadIndex == mWriteIndex) return NULL;
return &mItems[mReadIndex];
}
-
+
// the CompareAndSwap will always succeed. We use CompareAndSwap because it calls the PowerPC sync instruction,
// plus any processor bug workarounds for various CPUs.
void AdvanceWritePtr() { OSAtomicCompareAndSwap32(mWriteIndex, (mWriteIndex + 1) & mMask, &mWriteIndex); }
void AdvanceReadPtr() { OSAtomicCompareAndSwap32(mReadIndex, (mReadIndex + 1) & mMask, &mReadIndex); }
-
+
private:
-
+
volatile int32_t mReadIndex, mWriteIndex;
int32_t mMask;
ITEM *mItems;
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/MIDIControlHandler.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/MIDIControlHandler.h
index 0f8003fcd5..408108c548 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/MIDIControlHandler.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/MIDIControlHandler.h
@@ -2,14 +2,14 @@
File: MIDIControlHandler.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#ifndef __MIDICONTROLHANDLER_H__
#define __MIDICONTROLHANDLER_H__
@@ -62,11 +62,11 @@ public:
virtual bool SetPolyPressure(UInt8 inKey, UInt8 inValue) = 0;
virtual bool SetController(UInt8 inControllerNumber, UInt8 inValue) = 0;
virtual bool SetSysex(void *inSysexMsg) = 0;
-
+
virtual float GetPitchBend() const = 0;
/*! Default controller values. These represent MSB values unless indicated in the name */
-
+
enum
{
kDefault_Midpoint = 0x40, //! Used for all center-null-point controllers
@@ -78,7 +78,7 @@ public:
kDefault_ChannelPressure = 0,
kDefault_ReverbSend = 40,
kDefault_ChorusSend = 0,
-
+
kDefault_RPN_LSB = 0x7f,
kDefault_RPN_MSB = 0x7f,
kDefault_PitchBendRange = 2,
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.cpp
index fd329f84e8..cef3a50bf7 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.cpp
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.cpp
@@ -2,14 +2,14 @@
File: SynthElement.cpp
Abstract: SynthElement.h
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include "SynthElement.h"
#include "AUInstrumentBase.h"
@@ -78,7 +78,7 @@ void MidiControls::Reset()
}
-SynthElement::SynthElement(AUInstrumentBase *audioUnit, UInt32 inElement)
+SynthElement::SynthElement(AUInstrumentBase *audioUnit, UInt32 inElement)
: AUElement(audioUnit), mIndex(inElement)
{
}
@@ -87,7 +87,7 @@ SynthElement::~SynthElement()
{
}
-SynthGroupElement::SynthGroupElement(AUInstrumentBase *audioUnit, UInt32 inElement, MIDIControlHandler *inHandler)
+SynthGroupElement::SynthGroupElement(AUInstrumentBase *audioUnit, UInt32 inElement, MIDIControlHandler *inHandler)
: SynthElement(audioUnit, inElement),
mCurrentAbsoluteFrame(-1),
mMidiControlHandler(inHandler),
@@ -109,7 +109,7 @@ void SynthGroupElement::SetGroupID (MusicDeviceGroupID inGroup)
mGroupID = inGroup;
}
-void SynthGroupElement::Reset()
+void SynthGroupElement::Reset()
{
#if DEBUG_PRINT
printf("SynthGroupElement::Reset\n");
@@ -119,7 +119,7 @@ void SynthGroupElement::Reset()
mNoteList[i].Empty();
}
-SynthPartElement::SynthPartElement(AUInstrumentBase *audioUnit, UInt32 inElement)
+SynthPartElement::SynthPartElement(AUInstrumentBase *audioUnit, UInt32 inElement)
: SynthElement(audioUnit, inElement)
{
}
@@ -132,7 +132,7 @@ SynthNote *SynthGroupElement::GetNote(NoteInstanceID inNoteID, bool unreleasedOn
#if DEBUG_PRINT_RENDER
printf("SynthGroupElement::GetNote %d, unreleased = %d\n", inNoteID, unreleasedOnly);
#endif
- const UInt32 lastNoteState = unreleasedOnly ?
+ const UInt32 lastNoteState = unreleasedOnly ?
(mSostenutoIsOn ? kNoteState_Sostenutoed : kNoteState_Attacked)
: kNoteState_Released;
SynthNote *note = NULL;
@@ -176,7 +176,7 @@ void SynthGroupElement::NoteOn(SynthNote *note,
}
void SynthGroupElement::NoteOff(NoteInstanceID inNoteID, UInt32 inFrame)
-{
+{
#if DEBUG_PRINT_NOTE
printf("SynthGroupElement::NoteOff %d\n", inNoteID);
#endif
@@ -217,7 +217,7 @@ void SynthGroupElement::NoteEnded(SynthNote *inNote, UInt32 inFrame)
SynthNoteList *list = &mNoteList[inNote->GetState()];
list->RemoveNote(inNote);
}
-
+
GetAUInstrument()->AddFreeNote(inNote);
}
@@ -245,7 +245,7 @@ bool SynthGroupElement::ChannelMessage(UInt16 controllerID, UInt16 inValue)
// Sustain and sostenuto are "pedal events", and are handled during render cycle
if (controllerID <= kMidiController_RPN_MSB && controllerID != kMidiController_Sustain && controllerID != kMidiController_Sostenuto)
handled = mMidiControlHandler->SetController(controllerID, UInt8(inValue));
- else
+ else
{
switch (controllerID)
{
@@ -296,7 +296,7 @@ void SynthGroupElement::SostenutoOff(UInt32 inFrame)
mMidiControlHandler->SetController(kMidiController_Sostenuto, 0);
mSostenutoIsOn = false;
mNoteList[kNoteState_Attacked].TransferAllFrom(&mNoteList[kNoteState_Sostenutoed], inFrame);
- if (mSustainIsOn)
+ if (mSustainIsOn)
mNoteList[kNoteState_ReleasedButSustained].TransferAllFrom(&mNoteList[kNoteState_ReleasedButSostenutoed], inFrame);
else
mNoteList[kNoteState_Released].TransferAllFrom(&mNoteList[kNoteState_ReleasedButSostenutoed], inFrame);
@@ -323,7 +323,7 @@ void SynthGroupElement::SustainOff(UInt32 inFrame)
if (mSustainIsOn) {
mMidiControlHandler->SetController(kMidiController_Sustain, 0);
mSustainIsOn = false;
-
+
mNoteList[kNoteState_Released].TransferAllFrom(&mNoteList[kNoteState_ReleasedButSustained], inFrame);
}
}
@@ -342,14 +342,14 @@ void SynthGroupElement::AllNotesOff(UInt32 inFrame)
while (note)
{
SynthNote *nextNote = note->mNext;
-
+
mNoteList[i].RemoveNote(note);
note->Release(inFrame);
mNoteList[newState].AddNote(note);
-
+
note = nextNote;
}
- }
+ }
}
void SynthGroupElement::AllSoundOff(UInt32 inFrame)
@@ -358,21 +358,21 @@ void SynthGroupElement::AllSoundOff(UInt32 inFrame)
printf("SynthGroupElement::AllSoundOff\n");
#endif
SynthNote *note;
-
+
for (UInt32 i=0 ; i<kNumberOfActiveNoteStates; ++i)
{
note = mNoteList[i].mHead;
while (note)
{
SynthNote *nextNote = note->mNext;
-
+
mNoteList[i].RemoveNote(note);
note->FastRelease(inFrame);
mNoteList[kNoteState_FastReleased].AddNote(note);
GetAUInstrument()->DecNumActiveNotes();
note = nextNote;
}
- }
+ }
}
void SynthGroupElement::ResetAllControllers(UInt32 inFrame)
@@ -395,7 +395,7 @@ OSStatus SynthGroupElement::Render(SInt64 inAbsoluteSampleFrame, UInt32 inNumber
{
buffArray[outBus] = &GetAudioUnit()->GetOutput(outBus)->GetBufferList();
}
-
+
for (UInt32 i=0 ; i<kNumberOfSoundingNoteStates; ++i)
{
SynthNote *note = mNoteList[i].mHead;
@@ -405,10 +405,10 @@ OSStatus SynthGroupElement::Render(SInt64 inAbsoluteSampleFrame, UInt32 inNumber
printf("SynthGroupElement::Render: state %d, note %p\n", i, note);
#endif
SynthNote *nextNote = note->mNext;
-
+
OSStatus err = note->Render(inAbsoluteSampleFrame, inNumberFrames, buffArray, numOutputs);
if (err) return err;
-
+
note = nextNote;
}
}
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.h
index 4ca3643106..8f844a5bf4 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthElement.h
@@ -2,14 +2,14 @@
File: SynthElement.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#ifndef __SynthElement__
#define __SynthElement__
@@ -62,9 +62,9 @@ public:
virtual ~SynthElement();
UInt32 GetIndex() const { return mIndex; }
-
+
AUInstrumentBase* GetAUInstrument() { return (AUInstrumentBase*)GetAudioUnit(); }
-
+
private:
UInt32 mIndex;
};
@@ -98,11 +98,11 @@ public:
virtual float GetPitchBend() const { return mFPitchBend * mFPitchBendDepth; }
- SInt16 GetHiResControl(UInt32 inIndex) const
- {
+ SInt16 GetHiResControl(UInt32 inIndex) const
+ {
return ((mControls[inIndex] & 127) << 7) | (mControls[inIndex + 32] & 127);
}
-
+
float GetControl(UInt32 inIndex) const
{
if (inIndex < 32) {
@@ -111,10 +111,10 @@ public:
return (float)mControls[inIndex];
}
}
-
-
+
+
private:
-
+
UInt8 mControls[128];
UInt8 mPolyPressure[128];
UInt8 mMonoPressure;
@@ -124,17 +124,17 @@ private:
UInt16 mActiveNRPN;
UInt16 mActiveRPValue;
UInt16 mActiveNRPValue;
-
+
UInt16 mPitchBendDepth;
float mFPitchBendDepth;
float mFPitchBend;
-
+
void SetHiResControl(UInt32 inIndex, UInt8 inMSB, UInt8 inLSB)
- {
+ {
mControls[inIndex] = inMSB;
mControls[inIndex + 32] = inLSB;
}
-
+
};
@@ -144,7 +144,7 @@ public:
enum {
kUnassignedGroup = 0xFFFFFFFF
};
-
+
SynthGroupElement(AUInstrumentBase *audioUnit, UInt32 inElement, MIDIControlHandler *inHandler);
virtual ~SynthGroupElement();
@@ -157,27 +157,27 @@ public:
void NoteEnded(SynthNote *inNote, UInt32 inFrame);
void NoteFastReleased(SynthNote *inNote);
-
+
virtual bool ChannelMessage(UInt16 controlID, UInt16 controlValue);
virtual void AllNotesOff(UInt32 inFrame);
virtual void AllSoundOff(UInt32 inFrame);
void ResetAllControllers(UInt32 inFrame);
-
+
SynthNote * GetNote(NoteInstanceID inNoteID, bool unreleasedOnly=false, UInt32 *outNoteState=NULL);
-
+
void Reset();
-
+
virtual OSStatus Render(SInt64 inAbsoluteSampleFrame, UInt32 inNumberFrames, AUScope &outputs);
-
+
float GetPitchBend() const { return mMidiControlHandler->GetPitchBend(); }
SInt64 GetCurrentAbsoluteFrame() const { return mCurrentAbsoluteFrame; }
-
+
MusicDeviceGroupID GroupID () const { return mGroupID; }
virtual void SetGroupID (MusicDeviceGroupID inGroup);
MIDIControlHandler * GetMIDIControlHandler() const { return mMidiControlHandler; }
-
-protected:
+
+protected:
SInt64 mCurrentAbsoluteFrame;
SynthNoteList mNoteList[kNumberOfSoundingNoteStates];
MIDIControlHandler *mMidiControlHandler;
@@ -186,7 +186,7 @@ private:
friend class AUInstrumentBase;
friend class AUMonotimbralInstrumentBase;
friend class AUMultitimbralInstrumentBase;
-
+
bool mSustainIsOn;
bool mSostenutoIsOn;
UInt32 mOutputBus;
@@ -213,15 +213,15 @@ public:
UInt32 GetGroupIndex() const { return mGroupIndex; }
bool InRange(Float32 inNote, Float32 inVelocity);
-
+
UInt32 GetMaxPolyphony() const { return mMaxPolyphony; }
void SetMaxPolyphony(UInt32 inMaxPolyphony) { mMaxPolyphony = inMaxPolyphony; }
-
+
private:
UInt32 mGroupIndex;
UInt32 mPatchIndex;
UInt32 mMaxPolyphony;
- SynthKeyZone mKeyZone;
+ SynthKeyZone mKeyZone;
};
#endif
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthEvent.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthEvent.h
index 9c27aee04f..abb7886b12 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthEvent.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthEvent.h
@@ -2,14 +2,14 @@
File: SynthEvent.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
/* You can either fill in code here or remove this and create or add new files. */
@@ -76,7 +76,7 @@ public:
SynthEvent() {}
~SynthEvent() {}
- void Set(
+ void Set(
UInt32 inEventType,
MusicDeviceGroupID inGroupID,
NoteInstanceID inNoteID,
@@ -88,20 +88,20 @@ public:
mGroupID = inGroupID;
mNoteID = inNoteID;
mOffsetSampleFrame = inOffsetSampleFrame;
-
+
if (inNoteParams)
{
- UInt32 paramSize = offsetof(MusicDeviceNoteParams, mControls) + (inNoteParams->argCount-2)*sizeof(NoteParamsControlValue);
- mNoteParams = inNoteParams->argCount > 3
- ? (MusicDeviceNoteParams*)malloc(paramSize)
+ UInt32 paramSize = offsetof(MusicDeviceNoteParams, mControls) + (inNoteParams->argCount-2)*sizeof(NoteParamsControlValue);
+ mNoteParams = inNoteParams->argCount > 3
+ ? (MusicDeviceNoteParams*)malloc(paramSize)
: &mSmallNoteParams;
memcpy(mNoteParams, inNoteParams, paramSize);
}
- else
+ else
mNoteParams = NULL;
}
-
-
+
+
void Free()
{
if (mNoteParams)
@@ -111,27 +111,27 @@ public:
mNoteParams = NULL;
}
}
-
+
UInt32 GetEventType() const { return mEventType; }
MusicDeviceGroupID GetGroupID() const { return mGroupID; }
NoteInstanceID GetNoteID() const { return mNoteID; }
UInt32 GetOffsetSampleFrame() const { return mOffsetSampleFrame; }
-
+
MusicDeviceNoteParams* GetParams() const { return mNoteParams; }
UInt32 GetArgCount() const { return mNoteParams->argCount; }
UInt32 NumberParameters() const { return mNoteParams->argCount - 2; }
-
+
Float32 GetNote() const { return mNoteParams->mPitch; }
Float32 GetVelocity() const { return mNoteParams->mVelocity; }
-
- NoteParamsControlValue GetParameter(UInt32 inIndex) const
+
+ NoteParamsControlValue GetParameter(UInt32 inIndex) const
{
- if (inIndex >= NumberParameters())
+ if (inIndex >= NumberParameters())
throw std::runtime_error("index out of range");
- return mNoteParams->mControls[inIndex];
+ return mNoteParams->mControls[inIndex];
}
-
+
private:
UInt32 mEventType;
MusicDeviceGroupID mGroupID;
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.cpp
index 96a24d33c2..9ecced6b73 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.cpp
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.cpp
@@ -2,14 +2,14 @@
File: SynthNote.cpp
Abstract: SynthNote.h
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include "SynthNote.h"
#include "SynthElement.h"
@@ -51,9 +51,9 @@
bool SynthNote::AttackNote(
SynthPartElement * inPart,
SynthGroupElement * inGroup,
- NoteInstanceID inNoteID,
- UInt64 inAbsoluteSampleFrame,
- UInt32 inOffsetSampleFrame,
+ NoteInstanceID inNoteID,
+ UInt64 inAbsoluteSampleFrame,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams)
{
#if DEBUG_PRINT
@@ -70,8 +70,8 @@ bool SynthNote::AttackNote(
mPitch = inParams.mPitch;
mVelocity = inParams.mVelocity;
-
-
+
+
return Attack(inParams);
}
@@ -116,25 +116,25 @@ double SynthNote::SampleRate()
return GetAudioUnit()->GetOutput(0)->GetStreamFormat().mSampleRate;
}
-AUInstrumentBase* SynthNote::GetAudioUnit() const
-{
- return (AUInstrumentBase*)mGroup->GetAudioUnit();
+AUInstrumentBase* SynthNote::GetAudioUnit() const
+{
+ return (AUInstrumentBase*)mGroup->GetAudioUnit();
}
-Float32 SynthNote::GetGlobalParameter(AudioUnitParameterID inParamID) const
+Float32 SynthNote::GetGlobalParameter(AudioUnitParameterID inParamID) const
{
return mGroup->GetAudioUnit()->Globals()->GetParameter(inParamID);
}
-void SynthNote::NoteEnded(UInt32 inFrame)
-{
+void SynthNote::NoteEnded(UInt32 inFrame)
+{
mGroup->NoteEnded(this, inFrame);
- mNoteID = 0xFFFFFFFF;
+ mNoteID = 0xFFFFFFFF;
}
-float SynthNote::GetPitchBend() const
-{
- return mGroup->GetPitchBend();
+float SynthNote::GetPitchBend() const
+{
+ return mGroup->GetPitchBend();
}
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.h
index cec6377217..89179b14f4 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNote.h
@@ -2,14 +2,14 @@
File: SynthNote.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#ifndef __SynthNote__
#define __SynthNote__
@@ -84,7 +84,7 @@ enum SynthNoteState {
end of note any state free
soft voice stealing any state fast released
hard voice stealing any state free
-
+
soft voice stealing happens when there is a note on event and NumActiveNotes > MaxActiveNotes
hard voice stealing happens when there is a note on event and NumActiveNotes == NumNotes (no free notes)
voice stealing removes the quietest note in the highest numbered state that has sounding notes.
@@ -108,20 +108,20 @@ struct SynthNote
mVelocity(0.0f)
{
}
-
+
virtual ~SynthNote() {}
-
+
virtual void Reset();
//! Returns true if active note resulted from this call, otherwise false
virtual bool AttackNote(
SynthPartElement * inPart,
SynthGroupElement * inGroup,
- NoteInstanceID inNoteID,
- UInt64 inAbsoluteSampleFrame,
- UInt32 inOffsetSampleFrame,
+ NoteInstanceID inNoteID,
+ UInt64 inAbsoluteSampleFrame,
+ UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams
);
-
+
virtual OSStatus Render(UInt64 inAbsoluteSampleFrame, UInt32 inNumFrames, AudioBufferList** inBufferList, UInt32 inOutBusCount) = 0;
//! Returns true if active note resulted from this call, otherwise false
virtual bool Attack(const MusicDeviceNoteParams &inParams) = 0;
@@ -134,7 +134,7 @@ struct SynthNote
SynthGroupElement* GetGroup() const { return mGroup; }
SynthPartElement* GetPart() const { return mPart; }
-
+
AUInstrumentBase* GetAudioUnit() const;
Float32 GetGlobalParameter(AudioUnitParameterID inParamID) const;
@@ -143,7 +143,7 @@ struct SynthNote
SynthNoteState GetState() const { return mState; }
UInt8 GetMidiKey() const { return (UInt8) mPitch; }
UInt8 GetMidiVelocity() const { return (UInt8) mVelocity; }
-
+
Boolean IsSounding() const { return mState < kNumberOfSoundingNoteStates; }
Boolean IsActive() const { return mState < kNumberOfActiveNoteStates; }
UInt64 GetAbsoluteStartFrame() const { return mAbsoluteStartFrame; }
@@ -155,7 +155,7 @@ struct SynthNote
float GetPitchBend() const;
double TuningA() const;
-
+
Float32 GetPitch() const { return mPitch; } // returns raw pitch from MusicDeviceNoteParams
virtual double Frequency(); // returns the frequency of note + pitch bend.
virtual double SampleRate();
@@ -163,7 +163,7 @@ struct SynthNote
// linked list pointers
SynthNote *mPrev;
SynthNote *mNext;
-
+
friend class SynthGroupElement;
friend struct SynthNoteList;
protected:
@@ -171,14 +171,14 @@ protected:
private:
SynthPartElement* mPart;
SynthGroupElement* mGroup;
-
+
NoteInstanceID mNoteID;
SynthNoteState mState;
UInt64 mAbsoluteStartFrame;
SInt32 mRelativeStartFrame;
SInt32 mRelativeReleaseFrame;
SInt32 mRelativeKillFrame;
-
+
Float32 mPitch;
Float32 mVelocity;
};
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.cpp
index 849abd266b..7e49da970e 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.cpp
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.cpp
@@ -2,14 +2,14 @@
File: SynthNoteList.cpp
Abstract: SynthNoteList.h
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include "SynthNoteList.h"
#include <stdexcept>
@@ -52,23 +52,23 @@ void SynthNoteList::SanityCheck() const
if (mState >= kNoteState_Unset) {
throw std::runtime_error("SanityCheck: mState is bad");
}
-
+
if (mHead == NULL) {
- if (mTail != NULL)
+ if (mTail != NULL)
throw std::runtime_error("SanityCheck: mHead is NULL but not mTail");
return;
}
if (mTail == NULL) {
throw std::runtime_error("SanityCheck: mTail is NULL but not mHead");
}
-
+
if (mHead->mPrev) {
throw std::runtime_error("SanityCheck: mHead has a mPrev");
}
if (mTail->mNext) {
throw std::runtime_error("SanityCheck: mTail has a mNext");
}
-
+
SynthNote *note = mHead;
while (note)
{
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.h
index 47a3593018..6718f18530 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.h
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUInstrumentBase/SynthNoteList.h
@@ -2,14 +2,14 @@
File: SynthNoteList.h
Abstract: Part of CoreAudio Utility Classes
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#ifndef __SynthNoteList__
#define __SynthNoteList__
@@ -61,26 +61,26 @@
struct SynthNoteList
{
SynthNoteList() : mState(kNoteState_Unset), mHead(0), mTail(0) {}
-
+
bool NotEmpty() const { return mHead != NULL; }
bool IsEmpty() const { return mHead == NULL; }
- void Empty() {
+ void Empty() {
#if USE_SANITY_CHECK
SanityCheck();
#endif
- mHead = mTail = NULL;
+ mHead = mTail = NULL;
}
-
+
UInt32 Length() const {
#if USE_SANITY_CHECK
SanityCheck();
#endif
UInt32 length = 0;
- for (SynthNote* note = mHead; note; note = note->mNext)
+ for (SynthNote* note = mHead; note; note = note->mNext)
length++;
return length;
};
-
+
void AddNote(SynthNote *inNote)
{
#if DEBUG_PRINT
@@ -92,14 +92,14 @@ struct SynthNoteList
inNote->SetState(mState);
inNote->mNext = mHead;
inNote->mPrev = NULL;
-
+
if (mHead) { mHead->mPrev = inNote; mHead = inNote; }
else mHead = mTail = inNote;
#if USE_SANITY_CHECK
SanityCheck();
#endif
}
-
+
void RemoveNote(SynthNote *inNote)
{
#if DEBUG_PRINT
@@ -113,7 +113,7 @@ struct SynthNoteList
if (inNote->mNext) inNote->mNext->mPrev = inNote->mPrev;
else mTail = inNote->mPrev;
-
+
inNote->mPrev = 0;
inNote->mNext = 0;
#if USE_SANITY_CHECK
@@ -131,7 +131,7 @@ struct SynthNoteList
inNoteList->SanityCheck();
#endif
if (!inNoteList->mTail) return;
-
+
if (mState == kNoteState_Released)
{
for (SynthNote* note = inNoteList->mHead; note; note = note->mNext)
@@ -150,14 +150,14 @@ struct SynthNoteList
note->SetState(mState);
}
}
-
+
inNoteList->mTail->mNext = mHead;
-
+
if (mHead) mHead->mPrev = inNoteList->mTail;
else mTail = inNoteList->mTail;
-
+
mHead = inNoteList->mHead;
-
+
inNoteList->mHead = NULL;
inNoteList->mTail = NULL;
#if USE_SANITY_CHECK
@@ -165,7 +165,7 @@ struct SynthNoteList
inNoteList->SanityCheck();
#endif
}
-
+
SynthNote* FindOldestNote()
{
#if DEBUG_PRINT
@@ -186,7 +186,7 @@ struct SynthNoteList
}
return oldestNote;
}
-
+
SynthNote* FindMostQuietNote()
{
#if DEBUG_PRINT
@@ -219,9 +219,9 @@ struct SynthNoteList
#endif
return mostQuietNote;
}
-
+
void SanityCheck() const;
-
+
SynthNoteState mState;
SynthNote * mHead;
SynthNote * mTail;