AU and Notes (Was Re: AudioUnits & midi)
AU and Notes (Was Re: AudioUnits & midi)
- Subject: AU and Notes (Was Re: AudioUnits & midi)
- From: William Stewart <email@hidden>
- Date: Thu, 29 Apr 2004 16:50:19 -0700
The API should tell you... but here's a quick summary:
midi note on: note num, velocity
ext note on: note num(float), velocity (float) - this is the typical
usage....
Basically you need to take care of both the MIDI and ExtNoteOn. Your
sub-class takes:
Float32 noteNum (0 < 128)
Float32 velocity (0 < 128)
If you don't deal with fractional noteOn values, then just truncate
down to the integer note num.
So - your synth class would define:
ComponentResult MySynth::StartNote( MusicDeviceInstrumentID
inInstrument,
MusicDeviceGroupID inGroupID,
NoteInstanceID &outNoteInstanceID,
UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams &inParams)
{
...
}
ComponentResult MySynth::StopNote( MusicDeviceGroupID inGroupID,
NoteInstanceID inNoteInstanceID,
UInt32 inOffsetSampleFrame)
{
...
}
And you define:
virtual void HandleNoteOn( int inChannel,
UInt8 inNoteNumber,
UInt8 inVelocity,
long inStartFrame)
{
MusicDeviceNoteParams params;
params.argCount = 2;
params.mPitch = inNoteNumber;
params.mVelocity = inVelocity;
NoteInstanceID id;
StartNote(kMusicNoteEvent_UseGroupInstrument, inChannel, id,
inStartFrame, params);
}
/*! @method HandleNoteOff */
virtual void HandleNoteOff( int inChannel,
UInt8 inNoteNumber,
UInt8 inVelocity,
long inStartFrame)
{
StopNote(inChannel, inNoteNumber, inStartFrame);
}
The one remaining question is what is this noteInstanceID...
In the case where this is an integer, then we use that note num as the
instance ID - this note num is then what is given back to you to turn a
note off (along with the groupID (midi channel number)).
If the noteNum is not integral, then we generate unique integers and
associate those unique ID's with that floating point note... then your
caller gets that, and uses that to turn the note off (they have to be
using the extended API anyway to do this, so there's nothing for your
code to be worried about here).
- is defined in MusicDevice.h and means to use the currently selected
patch for the group (midi channel)
Hope that helps
Bill
On 28/04/2004, at 3:11 AM, nick wrote:
>
I see... so should i implement AUMIDIBase::HandleNoteOn() or
>
MusicDeviceBase::StartNote() to recieve midi note data? and if both,
>
what is the difference between the two?
>
>
Nick
>
>
On 27 Apr 2004, at 20:03, William Stewart wrote:
>
>
> Not quite...
>
>
>
> Music Device Base is *required* for any au instrument - where it
>
> contains implementations for both a MIDI message note on and the
>
> extended API for turning notes on with more parameters, micro-note
>
> numbers, etc... Both are required.
>
>
>
> In our implementations we've unified both of these into a single
>
> method that a subclass implements to create a note object. We don't
>
> have that code in the SDK yet unfortunately, but this is something we
>
> are looking into
>
>
>
> Bill
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.