MusicDeviceStartNote

Function MusicDeviceStartNote 

Source
pub unsafe extern "C-unwind" fn MusicDeviceStartNote(
    in_unit: MusicDeviceComponent,
    in_instrument: MusicDeviceInstrumentID,
    in_group_id: MusicDeviceGroupID,
    out_note_instance_id: NonNull<NoteInstanceID>,
    in_offset_sample_frame: u32,
    in_params: NonNull<MusicDeviceNoteParams>,
) -> i32
Available on crate features AUComponent and AudioComponent and MusicDevice only.
Expand description

used to start a note

This function is used to start a note. The caller must provide a NoteInstanceID to receive a token that is then used to stop the note. The MusicDeviceStopNote call should be used to stop notes started with this API. The token can also be used to address individual notes on the kAudioUnitScope_Note if the audio unit supports it. The instrumentID is no longer used and the kMusicNoteEvent_Unused constant should be specified (this takes the current patch for the specifed group as the sound to use for the note).

The Audio unit must provide an unique ID for the note instance ID. This ID must be non-zero and not 0xFFFFFFFF (any other UInt32 value is valid).

Not all Music Device audio units implement the semantics of this API (though it is strongly recommended that they do). A host application shoudl query the kMusicDeviceProperty_SupportsStartStopNote to check that this is supported.

Parameter inUnit: The audio unit

Parameter inInstrument: The instrumentID is no longer used and the kMusicNoteEvent_Unused constant should be specified (this takes the current patch for the specifed group as the sound to use for the note)

Parameter inGroupID: The group ID that this note will be attached too. As with MIDI, all notes sounding on a groupID can be controlled through the various parameters (such as pitch bend, etc) that can be specified on the Group Scope

Parameter outNoteInstanceID: A pointer to receive the token that is used to identify the note. This parameter must be specified

Parameter inOffsetSampleFrame: If you are scheduling the MIDI Event from the audio unit’s render thread, then you can supply a sample offset that the audio unit may apply when starting the note in its next audio unit render. This allows you to schedule to the sample and is particularly important when starting new notes. If you are not scheduling in the audio unit’s render thread, then you should set this value to 0

Parameter inParams: The parameters to be used when starting the note - pitch and velocity must be specified

Returns: noErr, or an audio unit error code

§Safety

  • in_unit must be a valid pointer.
  • out_note_instance_id must be a valid pointer.
  • in_params must be a valid pointer.