- Fixed: OPLMIDIDevice sent the wrong pitch wheel value to the player code.

Missimp.mid sounds a lot better now, though still a little off.
- Fixed: MIDI files that had ticks with nothing but meta-events did not play
  properly. (fixes sonic3_finalboss.mid)


SVN r868 (trunk)
This commit is contained in:
Randy Heit 2008-03-30 02:51:34 +00:00
commit f23e9df084
6 changed files with 71 additions and 42 deletions

View file

@ -95,20 +95,19 @@ int musicBlock::occupyChannel(uint slot, uint channel,
int note, int volume, struct OP2instrEntry *instrument, uchar secondary)
{
struct OPL2instrument *instr;
struct OPLdata *data = &driverdata;
struct channelEntry *ch = &channels[slot];
ch->channel = channel;
ch->note = note;
ch->flags = secondary ? CH_SECONDARY : 0;
if (data->channelModulation[channel] >= MOD_MIN)
if (driverdata.channelModulation[channel] >= MOD_MIN)
ch->flags |= CH_VIBRATO;
ch->time = MLtime;
if (volume == -1)
volume = data->channelLastVolume[channel];
volume = driverdata.channelLastVolume[channel];
else
data->channelLastVolume[channel] = volume;
ch->realvolume = calcVolume(data->channelVolume[channel], 256, ch->volume = volume);
driverdata.channelLastVolume[channel] = volume;
ch->realvolume = calcVolume(driverdata.channelVolume[channel], 256, ch->volume = volume);
if (instrument->flags & FL_FIXED_PITCH)
note = instrument->note;
else if (channel == PERCUSSION)
@ -117,7 +116,7 @@ int musicBlock::occupyChannel(uint slot, uint channel,
ch->finetune = (instrument->finetune - 0x80) >> 1;
else
ch->finetune = 0;
ch->pitch = ch->finetune + data->channelPitch[channel];
ch->pitch = ch->finetune + driverdata.channelPitch[channel];
if (secondary)
instr = &instrument->instr[1];
else
@ -135,7 +134,7 @@ int musicBlock::occupyChannel(uint slot, uint channel,
io->OPLwriteInstrument(slot, instr);
if (ch->flags & CH_VIBRATO)
writeModulation(slot, instr, 1);
io->OPLwritePan(slot, instr, data->channelPan[channel]);
io->OPLwritePan(slot, instr, driverdata.channelPan[channel]);
io->OPLwriteVolume(slot, instr, ch->realvolume);
writeFrequency(slot, note, ch->pitch, 1);
return slot;
@ -254,8 +253,7 @@ void musicBlock::OPLreleaseNote(uint channel, uchar note)
{
uint i;
uint id = channel;
struct OPLdata *data = &driverdata;
uint sustain = data->channelSustain[channel];
uint sustain = driverdata.channelSustain[channel];
for(i = 0; i < io->OPLchannels; i++)
{
@ -274,11 +272,9 @@ void musicBlock::OPLpitchWheel(uint channel, int pitch)
{
uint i;
uint id = channel;
struct OPLdata *data = &driverdata;
//pitch -= 0x80;
pitch >>= 1;
data->channelPitch[channel] = pitch;
pitch >>= 7;
driverdata.channelPitch[channel] = pitch;
for(i = 0; i < io->OPLchannels; i++)
{
struct channelEntry *ch = &channels[i];
@ -365,14 +361,13 @@ void musicBlock::OPLprogramChange(uint channel, int value)
void musicBlock::OPLplayMusic(int vol)
{
uint i;
struct OPLdata *data = &driverdata;
for (i = 0; i < CHANNELS; i++)
{
data->channelVolume[i] = vol; /* default volume 127 for MUS (full volume) */
data->channelSustain[i] = 0;
data->channelLastVolume[i] = 64;
data->channelPitch[i] = 64;
driverdata.channelVolume[i] = vol; /* default volume 127 for MUS (full volume) */
driverdata.channelSustain[i] = 0;
driverdata.channelLastVolume[i] = 64;
driverdata.channelPitch[i] = 64;
}
}