44 #include <Carbon/Carbon.h>
45 #include <AudioUnit/AudioUnit.h>
46 #include <CoreAudio/CoreAudio.h>
47 #include "MusicDeviceBase.h"
52 kNoteState_Attacked = 0,
53 kNoteState_Sostenutoed = 1,
54 kNoteState_ReleasedButSostenutoed = 2,
55 kNoteState_ReleasedButSustained = 3,
56 kNoteState_Released = 4,
57 kNoteState_FastReleased = 5,
59 kNumberOfActiveNoteStates = 5,
60 kNumberOfSoundingNoteStates = 6,
61 kNumberOfNoteStates = 7
87 class SynthGroupElement;
88 class SynthPartElement;
89 class AUInstrumentBase;
94 mPrev(0), mNext(0), mState(kNoteState_Free),
95 mRelativeStartFrame(0),
96 mRelativeReleaseFrame(-1),
97 mRelativeKillFrame(-1)
101 virtual ~SynthNote() {}
103 virtual void Reset();
104 virtual void AttackNote(
105 SynthPartElement * inPart,
106 SynthGroupElement * inGroup,
107 NoteInstanceID inNoteID,
108 SInt64 inAbsoluteSampleFrame,
109 UInt32 inOffsetSampleFrame,
110 const MusicDeviceNoteParams &inParams
113 virtual OSStatus Render(UInt32 inNumFrames, AudioBufferList& inBufferList)=0;
114 virtual void Attack(
const MusicDeviceNoteParams &inParams) = 0;
115 virtual void Kill(UInt32 inFrame);
116 virtual void Release(UInt32 inFrame);
117 virtual void FastRelease(UInt32 inFrame);
118 virtual Float32 Amplitude() = 0;
120 virtual void NoteEnded(UInt32 inFrame);
122 SynthGroupElement* GetGroup()
const {
return mGroup; }
123 SynthPartElement* GetPart()
const {
return mPart; }
125 AUInstrumentBase* GetAudioUnit()
const;
127 Float32 GetGlobalParameter(AudioUnitParameterID inParamID)
const;
129 NoteInstanceID GetNoteID()
const {
return mNoteID; }
130 UInt32 GetState()
const {
return mState; }
131 Boolean IsSounding()
const {
return mState < kNumberOfSoundingNoteStates; }
132 Boolean IsActive()
const {
return mState < kNumberOfActiveNoteStates; }
133 SInt64 GetAbsoluteStartFrame()
const {
return mAbsoluteStartFrame; }
134 SInt32 GetRelativeStartFrame()
const {
return mRelativeStartFrame; }
135 SInt32 GetRelativeReleaseFrame()
const {
return mRelativeReleaseFrame; }
136 SInt32 GetRelativeKillFrame()
const {
return mRelativeKillFrame; }
138 void ListRemove() { mPrev = mNext = 0; }
140 float PitchBend()
const;
141 double TuningA()
const;
143 virtual double Frequency();
153 SynthPartElement* mPart;
154 SynthGroupElement* mGroup;
156 NoteInstanceID mNoteID;
158 SInt64 mAbsoluteStartFrame;
159 SInt32 mRelativeStartFrame;
160 SInt32 mRelativeReleaseFrame;
161 SInt32 mRelativeKillFrame;