Share via


IDirectMusicPerformance8::MusicToMIDI

The MusicToMIDI method converts a DirectMusic music value to a MIDI note value.

Syntax

HRESULT MusicToMIDI(
  WORD wMusicValue,
  DMUS_CHORD_KEY*  pChord,
  BYTE bPlayMode,
  BYTE bChordLevel,
  BYTE*  pbMIDIValue
);

Parameters

wMusicValue

Music value to convert. For information on music values, see DMUS_NOTE_PMSG.

pChord

Address of a DMUS_CHORD_KEY structure containing information about the chord and key structure to be used in translating the note. This includes the underlying scale. For example, if the chord is a CM7, the note is interpreted against the chord positions for root note C, chord intervals of a major seventh. The structure carries up to DMUS_MAXSUBCHORD parallel subchords, with chord intervals, root, scale, and inversion flags for each. It also carries the overall key root.

bPlayMode

Play mode determining how the music value is related to the chord. For a list of values, see DMUS_PLAYMODE_FLAGS.

bChordLevel

Subchord level, defining which subchords can be used. See DMUS_SUBCHORD.

pbMIDIValue

Address of a variable that receives the MIDI value, in the range from 0 through 127.

Return Values

If the method succeeds, the return value is one of the following. See Remarks.

Return code
S_OK
DMUS_S_OVER_CHORD
DMUS_S_DOWN_OCTAVE
DMUS_S_UP_OCTAVE

If it fails, the method can return one of the error values shown in the following table.

Return code
DMUS_E_CANNOT_CONVERT
E_INVALIDARG

Remarks

If the method fails or returns DMUS_S_OVER_CHORD, *pwMIDIValue is not changed.

The method returns DMUS_S_OVER_CHORD if no note has been calculated because the music value has the note at a position higher than the top note of the chord. This applies only to DMUS_PLAYMODE_NORMALCHORD play mode. The caller should not do anything with the note, which is not meant to be played against this chord.

If the return value is DMUS_S_UP_OCTAVE or DMUS_DOWN_OCTAVE, the note conversion generated a note value that is less than 0 or greater than 127, so it has been adjusted up or down one or more octaves to be in the proper MIDI range of 0 through 127. This can occur when using any play mode except DMUS_PLAYMODE_FIXED.

Requirements

**  Header:** Dmusici.h
  Library: Dmime.dll, Dmimed.dll

See Also

© 2004 Microsoft Corporation. All rights reserved.