ConvertPitchBend

Converts a MIDI pitch bend value into frequency multiplier.

Synopsis

Err ConvertPitchBend( int32 Bend, int32 SemitoneRange,frac16 *BendFractionPtr )

Description

This function accepts a MIDI pitch bend value from 0x0 to 0x3FFF. It also accepts a pitch bend range in semitones (half steps). The range value measures the distance from normal pitch to the farthest bent pitch. For example, a pitch bend range of 12 semitones means that an instrument can be bent up in pitch by 12 semitones, and down in pitch by 12 semitones for a total range of 24 semitones (two octaves).

The pitch bend value operates within the pitch bend range: 0x0 means bend pitch all the way to the bottom of the range; 0x2000 means don't bend pitch; and 0x3FFF means bend pitch all the way to the top of the range.

ConvertPitchBend() uses the pitch bend range and the pitch bend value to calculate an internal pitch bend valuea value used to multiply the output of an instrument, bending the instrument's pitch up or down. The internal pitch bend value is written into the variable "BendFractionPtr." This bend value is the same as the bend value used for the Audio folio call BendInstrumentPitch().

Note that DSP sampled sound instruments won't bend any more than 12 semitones, so don't set the pitch bend range to a value greater than 12.

Arguments

Bend
A MIDI pitch bend value from 0x0 to 0x3FFF.
SemitoneRange
A pitch bend range value from 1 to 12, measured in semitones away from normal pitch.
BendFractionPtr
A pointer to a frac16 variable in which to store the returned frequency multiplier.

Return Value

This function returns 0 if successful or an error code (a negative value) if an error occurs.

Implementation

Convenience call implemented in music.lib V20.

Associated Files

score.h, music.lib

See Also

ChangeScorePitchBend(), GetScoreBendRange(), SetScoreBendRange()