[Scummvm-cvs-logs] scummvm master -> 05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8

m-kiewitz m_kiewitz at users.sourceforge.net
Tue Jan 19 03:20:18 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
05fb12eb63 AGI: reverse stereo for Apple IIgs + cleanup


Commit: 05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8
    https://github.com/scummvm/scummvm/commit/05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-01-19T03:19:13+01:00

Commit Message:
AGI: reverse stereo for Apple IIgs + cleanup

According to Apple IIgs emulator and recorded music on Apple IIgs,
it seems that stereo was reversed. Melody in games seems to be
playing on left channel and not on the right one.

Changed paths:
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h



diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index e054c16..af1ff43 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -206,16 +206,16 @@ uint SoundGen2GS::generateOutput() {
 
 			// Take envelope and MIDI volume information into account.
 			// Also amplify.
-			s0 *= vol * g->vel / 127 * 80 / 256;
-			s1 *= vol * g->vel / 127 * 80 / 256;
+			s0 *= vol * g->velocity / 127 * 80 / 256;
+			s1 *= vol * g->velocity / 127 * 80 / 256;
 
 			// Select output channel.
-			if (g->osc[0].chn)
+			if (g->osc[0].rightChannel)
 				outl += s0;
 			else
 				outr += s0;
 
-			if (g->osc[1].chn)
+			if (g->osc[1].rightChannel)
 				outl += s1;
 			else
 				outr += s1;
@@ -361,7 +361,7 @@ void SoundGen2GS::advanceMidiPlayer() {
 void SoundGen2GS::midiNoteOff(int channel, int note, int velocity) {
 	// Release keys within the given MIDI channel
 	for (int i = 0; i < MAX_GENERATORS; i++) {
-		if (_generators[i].chn == channel && _generators[i].key == note)
+		if (_generators[i].channel == channel && _generators[i].key == note)
 			_generators[i].seg = _generators[i].ins->seg;
 	}
 }
@@ -384,8 +384,8 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
 		velocity = 127;
 
 	g->key = note;
-	g->vel = velocity * _channels[channel].getVolume() / 127;
-	g->chn = channel;
+	g->velocity = velocity * _channels[channel].getVolume() / 127;
+	g->channel = channel;
 
 	// Instruments can define different samples to be used based on
 	// what the key is. Find the correct samples for our key.
@@ -404,7 +404,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
 	g->osc[0].halt	= i->wave[0][wa].halt;
 	g->osc[0].loop	= i->wave[0][wa].loop;
 	g->osc[0].swap	= i->wave[0][wa].swap;
-	g->osc[0].chn	= i->wave[0][wa].chn;
+	g->osc[0].rightChannel = i->wave[0][wa].rightChannel;
 
 	g->osc[1].base	= i->base + i->wave[1][wb].offset;
 	g->osc[1].size	= i->wave[1][wb].size;
@@ -413,7 +413,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
 	g->osc[1].halt	= i->wave[1][wb].halt;
 	g->osc[1].loop	= i->wave[1][wb].loop;
 	g->osc[1].swap	= i->wave[1][wb].swap;
-	g->osc[1].chn	= i->wave[1][wb].chn;
+	g->osc[1].rightChannel = i->wave[1][wb].rightChannel;
 
 	g->seg	= 0;
 	g->a	= 0;
@@ -551,7 +551,12 @@ bool IIgsInstrumentHeader::read(Common::SeekableReadStream &stream, bool ignoreA
 			wave[i][k].halt = b & 0x1;			// Bit 0     = HALT
 			wave[i][k].loop = !(b & 0x2);		// Bit 1     =!LOOP
 			wave[i][k].swap = (b & 0x6) == 0x6;	// Bit 1&2   = SWAP
-			wave[i][k].chn = (b >> 4) > 0;		// Output channel (left or right)
+			// channels seem to be reversed, verified with emulator + captured apple IIgs music
+			if (b >> 4) {
+				wave[i][k].rightChannel = false; // Bit 4 set = left channel
+			} else {
+				wave[i][k].rightChannel = true; // Bit 4 not set = right channel
+			}
 		}
 	}
 
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 4eaba52..51426e0 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -85,7 +85,7 @@ struct IIgsInstrumentHeader {
 		bool halt;		///< Oscillator halted?
 		bool loop;		///< Loop mode?
 		bool swap;		///< Swap mode?
-		bool chn;		///< Output channel (left / right)
+		bool rightChannel;	///< Output channel (left / right)
 		int16 tune;		///< Fine tune in semitones (8.8 fixed point)
 	} wave[2][MAX_OSCILLATOR_WAVES];
 
@@ -122,7 +122,7 @@ struct IIgsSampleHeader {
 
 class IIgsGenerator {
 public:
-	IIgsGenerator() : ins(NULL), key(-1), chn(-1) {
+	IIgsGenerator() : ins(NULL), key(-1), channel(-1) {
 		memset(&osc, 0, sizeof(osc));
 		seg = 0;
 		a = 0;
@@ -130,8 +130,8 @@ public:
 
 	const IIgsInstrumentHeader *ins; ///< Currently used instrument
 	int key;		///< MIDI key
-	int vel;		///< MIDI velocity (& channel volume)
-	int chn;		///< MIDI channel
+	int velocity;	///< MIDI velocity (& channel volume)
+	int channel;	///< MIDI channel
 	struct {
 		int8 *base;	///< Sample base pointer
 		uint size;	///< Sample size
@@ -140,7 +140,7 @@ public:
 		bool halt;	///< Is oscillator halted?
 		bool loop;	///< Is looping enabled?
 		bool swap;	///< Is swapping enabled?
-		bool chn;	///< Output channel (left / right)
+		bool rightChannel;	///< Output channel (left / right)
 	} osc[2];
 	int seg;		///< Current envelope segment
 	frac_t a;		///< Current envelope amplitude






More information about the Scummvm-git-logs mailing list