43 #ifndef __SynthEvent__
44 #define __SynthEvent__
46 #include <Carbon/Carbon.h>
47 #include <AudioUnit/AudioUnit.h>
48 #include <CoreAudio/CoreAudio.h>
49 #include "MusicDeviceBase.h"
59 kEventType_NoteOn = 1,
60 kEventType_NoteOff = 2,
61 kEventType_SustainOn = 3,
62 kEventType_SustainOff = 4,
63 kEventType_SostenutoOn = 5,
64 kEventType_SostenutoOff = 6,
65 kEventType_AllNotesOff = 7,
66 kEventType_AllSoundOff = 8,
67 kEventType_ResetAllControllers = 9
76 MusicDeviceGroupID inGroupID,
77 NoteInstanceID inNoteID,
78 UInt32 inOffsetSampleFrame,
79 const MusicDeviceNoteParams* inNoteParams
82 mEventType = inEventType;
85 mOffsetSampleFrame = inOffsetSampleFrame;
89 UInt32 paramSize = offsetof(MusicDeviceNoteParams, mControls) + (inNoteParams->argCount-2)*
sizeof(NoteParamsControlValue);
90 mNoteParams = inNoteParams->argCount > 3
91 ? (MusicDeviceNoteParams*)malloc(paramSize)
93 memcpy(mNoteParams, inNoteParams, paramSize);
104 if (mNoteParams->argCount > 3)
110 UInt32 GetEventType()
const {
return mEventType; }
111 MusicDeviceGroupID GetGroupID()
const {
return mGroupID; }
112 NoteInstanceID GetNoteID()
const {
return mNoteID; }
113 UInt32 GetOffsetSampleFrame()
const {
return mOffsetSampleFrame; }
115 MusicDeviceNoteParams* GetParams()
const {
return mNoteParams; }
117 UInt32 GetArgCount()
const {
return mNoteParams->argCount; }
118 UInt32 NumberParameters()
const {
return mNoteParams->argCount - 2; }
120 Float32 GetNote()
const {
return mNoteParams->mPitch; }
121 Float32 GetVelocity()
const {
return mNoteParams->mVelocity; }
123 NoteParamsControlValue GetParameter(UInt32 inIndex)
const
125 if (inIndex >= NumberParameters())
126 throw std::runtime_error(
"index out of range");
127 return mNoteParams->mControls[inIndex];
132 MusicDeviceGroupID mGroupID;
133 NoteInstanceID mNoteID;
134 UInt32 mOffsetSampleFrame;
135 MusicDeviceNoteParams* mNoteParams;
136 MusicDeviceNoteParams mSmallNoteParams;