[Scummvm-tracker] [ScummVM :: Bugs] #13460: SCUMM: DOTT: Incorrect MIDI pitch bending
ScummVM :: Bugs
trac at scummvm.org
Fri May 6 21:53:58 UTC 2022
#13460: SCUMM: DOTT: Incorrect MIDI pitch bending
----------------------+----------------------------------
Reporter: AndywinXp | Owner: (none)
Type: defect | Status: new
Priority: normal | Component: Engine: SCUMM
Version: | Resolution:
Keywords: adlib | Game: Day of the Tentacle
----------------------+----------------------------------
Comment (by AndywinXp):
Okay, I lazily reversed what happens on Aaron Giles' interpreter (which
uses General MIDI):
These two functions appear to be called constantly during the bird event
(forgive the names, I'm directly using my mapped function names, and I'm
just putting the relevant parameters in):
{{{
IMUSE_SetTranspose(partPtr, relative, transpose) {
uint8 clampedTranspose;
clampedTranspose = transpose;
if ( transpose > 24 || transpose < -24 || relative > 1 )
return -1;
if ( relative )
clampedTranspose = IMUSE_UTILS_ClampTuning(transpose +
partPtr->effTranspose, -7, 7);
partPtr->effTranspose = clampedTranspose;
IMUSE_PART_SetTranspose(partPtr, 16, relative, clampedTranspose);
return 0;
}
}}}
{{{
IMUSE_SetDetune(partPtr, detune) {
partPtr->detune = detune;
IMUSE_PART_SetDetune(partPtr, 16, detune);
return 0;
}
}}}
These is the rest of the relevant auxiliary functions:
{{{
IMUSE_UTILS_ClampTuning(tuning, min, max)
{
if ( tuning < min )
clampedTuning = tuning + 12 * ((min - tuning + 11) / 12);
if ( tuning > max )
clampedTuning = tuning - 12 * ((tuning - max + 11) / 12);
return clampedTuning;
}
}}}
{{{
IMUSE_PART_SetTranspose(partPtr, partId, relative, transpose) {
if ( transpose <= 24 && transpose >= -24 ) {
if ( partId == 16 ) {
for ( curPart = partPtr->next; curPart; curPart = curPart->next ) {
curPart->effTranspose = IMUSE_UTILS_ClampTuning(transpose +
curPart->transpose, -12, 12);
IMUSE_PART_SendTranspose(curPart);
}
} else { /* Don't care */ }
}
}
}}}
{{{
IMUSE_PART_SetDetune(partPtr, partId, relative, transpose) {
if ( transpose <= 24 && transpose >= -24 ) {
if ( partId == 16 ) {
for ( curPart = partPtr->next; curPart ; curPart = curPart->next ) {
curPart->effDetune = CLIP(increment + curPart->detune, -128, 127);
IMUSE_PART_SendTranspose(curPart);
}
} else { /* Don't care */ }
}
}
}}}
The latter two both call this one:
{{{
IMUSE_PART_SendTransposeToMIDIDevice(partPtr) {
effTranspose = clampNumber(partPtr->pitchbend + partPtr->effDetune +
(partPtr->effTranspose * 128), -2048, 2047);
partPtr->effTranspose = effTranspose;
if ( partPtr->midiChannel) {
midiPartId = midiChannel->chanNum;
if ( midiPartsTransposeValues[midiPartId] != effTranspose ) {
midiPartsTransposeValues[midiPartId] = effTranspose;
// 8192 is added because this number appears to be the center
// value for the pitchbend in this case
sendPitchWheelValueToMIDIDevice(midiPartId, 4 *
partPtr->effTranspose + 8192);
}
}
}
}}}
Too tired to test it out for now, though
--
Ticket URL: <https://bugs.scummvm.org/ticket/13460#comment:4>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM
More information about the Scummvm-tracker
mailing list