[Scummvm-cvs-logs] SF.net SVN: scummvm:[42461] scummvm/branches/gsoc2009-mods

nolange at users.sourceforge.net nolange at users.sourceforge.net
Tue Jul 14 00:49:34 CEST 2009


Revision: 42461
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42461&view=rev
Author:   nolange
Date:     2009-07-13 22:49:34 +0000 (Mon, 13 Jul 2009)

Log Message:
-----------
cleaned up NoteOn a bit
fixed NoteOff and removed some useless variables - intro sounds fine now

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj
    scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
    scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h

Modified: scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj
===================================================================
--- scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj	2009-07-13 22:20:06 UTC (rev 42460)
+++ scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj	2009-07-13 22:49:34 UTC (rev 42461)
@@ -1155,6 +1155,14 @@
 							AssemblerOutput="2"
 						/>
 					</FileConfiguration>
+					<FileConfiguration
+						Name="Release_Command|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							AssemblerOutput="2"
+						/>
+					</FileConfiguration>
 				</File>
 				<File
 					RelativePath="..\..\sound\mods\maxtrax.h"

Modified: scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-13 22:20:06 UTC (rev 42460)
+++ scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-13 22:49:34 UTC (rev 42461)
@@ -75,9 +75,10 @@
 		if (!voice.channel || voice.stopEventCommand >= 0x80)
 			continue;
 		const int channelNo = voice.stopEventParameter;
+		assert(channelNo == voice.channel - _channelCtx);
 		voice.stopEventTime -= (channelNo < kNumChannels) ? _playerCtx.tickUnit : _playerCtx.frameUnit;
 		if (voice.stopEventTime <= 0) {
-			noteOff(_channelCtx[channelNo], voice.stopEventCommand);
+			noteOff(voice, voice.stopEventCommand);
 			voice.stopEventCommand = 0xFF;
 		}
 	}
@@ -95,7 +96,6 @@
 			debug("CurTime, EventTime, NextEvent: %d, %d, %d", millis, eventTime, eventTime + curEvent[1].startTime );
 
 			if (cmd < 0x80) {
-				_playerCtx.addedNote = false;
 				const uint16 vol = (data & 0xF0) >> 1;
 
 				const int8 voiceIndex = noteOn(channel, cmd, vol, kPriorityScore);
@@ -128,7 +128,7 @@
 					break;
 				case 0xE0:	// BEND
 					channel.pitchBend = ((stopTime & 0x7F00) >> 1) | (stopTime & 0x7f);
-					// channel.pitchReal = ((int32)(channel.pitchBendRange << 8) * (channel.pitchBend - (64 << 7))) / (64 << 7);
+					channel.pitchReal = ((int32)(channel.pitchBendRange << 8) * (channel.pitchBend - (64 << 7))) / (64 << 7);
 					channel.pitchReal = ((channel.pitchBendRange * channel.pitchBend) >> 5) - (channel.pitchBendRange << 8);
 					channel.flags |= ChannelContext::kFlagAltered;
 					break;
@@ -177,8 +177,7 @@
 		byte newVolume = 0xFF; // if set to 0 this means skip recalc
 		switch (voice.status) {
 		case VoiceContext::kStatusSustain:
-			// and no modulation 
-			if ((channel.flags & ChannelContext::kFlagAltered) == 0 && (voice.flags & VoiceContext::kFlagPortamento) == 0)
+			if ((channel.flags & (ChannelContext::kFlagAltered | VoiceContext::kFlagPortamento)) == 0 && !channel.modulation)
 				continue;
 			// goto .l18
 			envHandling = false;
@@ -273,19 +272,18 @@
 				vol = (vol * voice.channel->volume) >> 7;
 
 			newVolume = (byte)MIN(vol, (uint16)0x64);
-			voice.lastVolume = newVolume;
+			voice.lastVolume = newVolume = 0x64;
 
 			if ((voice.flags & VoiceContext::kFlagPortamento) != 0) {
 				voice.portaTicks += _playerCtx.tickUnit;
-				if ((uint16)(voice.portaTicks >> 8) >= channel.portamento) {
+				if ((uint16)(voice.portaTicks >> 8) >= channel.portamentoTime) {
 					voice.flags &= ~VoiceContext::kFlagPortamento;
 					voice.baseNote = voice.endNote;
 				}
 				voice.flags |= VoiceContext::kFlagRecalc;
 				calcNote(voice);
 			} else {
-				// modulation
-				if ((channel.flags & ChannelContext::kFlagAltered) != 0) {
+				if ((channel.flags & ChannelContext::kFlagAltered) != 0 || channel.modulation) {
 					voice.flags |= VoiceContext::kFlagRecalc;
 					calcNote(voice);
 				}
@@ -392,7 +390,7 @@
 	if ((voice.flags & VoiceContext::kFlagPortamento) != 0) {
 		// microtonal crap
 
-		bend = (int16)((int8)(voice.endNote - voice.baseNote) * voice.portaTicks) / channel.portamento;
+		bend = (int16)(((int8)(voice.endNote - voice.baseNote)) * voice.portaTicks) / channel.portamentoTime;
 	}
 	// modulation
 	if (channel.modulation && (channel.flags & ChannelContext::kFlagModVolume) == 0) {
@@ -445,110 +443,103 @@
 		return -1;
 	int8 voiceNum = -1;
 	if ((channel.flags & ChannelContext::kFlagMono) != 0  && channel.voicesActive) {
-		for (voiceNum = ARRAYSIZE(_voiceCtx) - 1; voiceNum >= 0 && _voiceCtx[voiceNum].channel != &channel; --voiceNum)
+		VoiceContext *voice = _voiceCtx + ARRAYSIZE(_voiceCtx) - 1;
+		for (voiceNum = ARRAYSIZE(_voiceCtx) - 1; voiceNum >= 0 && voice->channel != &channel; --voiceNum, --voice)
 			;
-		if (voiceNum < 0)
-			return -1;
-
-		VoiceContext &voice = _voiceCtx[voiceNum];
-		if (voice.status >= VoiceContext::kStatusSustain && (channel.flags & ChannelContext::kFlagPortamento) != 0) {
+		if (voiceNum >= 0 && voice->status >= VoiceContext::kStatusSustain && (channel.flags & ChannelContext::kFlagPortamento) != 0) {
 			// reset previous porta
-			if ((voice.flags & VoiceContext::kFlagPortamento) != 0)
-				voice.baseNote = voice.endNote;
-			voice.portaTicks = 0;
-			voice.flags |= VoiceContext::kFlagPortamento;
-			voice.endNote = channel.lastNote = note;
-			voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
-			_playerCtx.addedNote = true;
-			_playerCtx.lastVoice = voiceNum;
+			if ((voice->flags & VoiceContext::kFlagPortamento) != 0)
+				voice->baseNote = voice->endNote;
+			voice->portaTicks = 0;
+			voice->flags |= VoiceContext::kFlagPortamento;
+			voice->endNote = channel.lastNote = note;
+			voice->noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
 			return voiceNum;
 		}
+
 	} else {
 		voiceNum = pickvoice(_voiceCtx, (channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 1 : 0, pri);
-		if (voiceNum < 0)
-			return voiceNum;
-	}
-	assert(voiceNum >= 0 && voiceNum < ARRAYSIZE(_voiceCtx));
+		if (voiceNum >= 0) {
+			VoiceContext &voice = _voiceCtx[voiceNum];
+			voice.flags = 0;
+			if (voice.channel) {
+				killVoice(voiceNum);
+				voice.flags |= VoiceContext::kFlagStolen;
+			}
+			voice.channel = &channel;
+			voice.patch = &patch;
+			voice.baseNote = note;
 
-	VoiceContext &voice = _voiceCtx[voiceNum];
-	voice.flags = 0;
-	if (voice.channel) {
-		killVoice(voiceNum);
-		voice.flags |= VoiceContext::kFlagStolen;
-	}
-	voice.channel = &channel;
-	voice.patch = &patch;
-	voice.baseNote = note;
+			int useOctave = calcNote(voice);
+			voice.priority = (byte)pri;
+			voice.status = VoiceContext::kStatusStart;
 
-	int useOctave = calcNote(voice);
-	voice.priority = (byte)pri;
-	voice.status = VoiceContext::kStatusStart;
+			voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
 
-	voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
+			// ifeq HAS_FULLCHANVOL macro
+			if (channel.volume < 128)
+				voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
 
-	// ifeq HAS_FULLCHANVOL macro
-	if (channel.volume < 128)
-		voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
+			voice.baseVolume = 0;
+			voice.lastTicks = 0;
 
-	voice.baseVolume = 0;
-	voice.lastTicks = 0;
+			uint16 period = voice.lastPeriod;
+			if (!period)
+				period = 1000;
 
-	uint16 period = voice.lastPeriod;
-	if (!period)
-		period = 1000;
+			// TODO: since the original player is using the OS-functions, more than 1 sample could be queued up already
+			// get samplestart for the given octave
+			const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
+			if (patch.sampleAttackLen) {
+				Paula::setChannelSampleStart(voiceNum, samplePtr);
+				Paula::setChannelSampleLen(voiceNum, (patch.sampleAttackLen << useOctave) / 2);
+				Paula::setChannelPeriod(voiceNum, period);
+				Paula::setChannelVolume(voiceNum, 0);
 
-	// TODO: since the original player is using the OS-functions, more than 1 sample could be queued up already
-	// get samplestart for the given octave
-	const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
-	if (patch.sampleAttackLen) {
-		Paula::setChannelSampleStart(voiceNum, samplePtr);
-		Paula::setChannelSampleLen(voiceNum, (patch.sampleAttackLen << useOctave) / 2);
-		Paula::setChannelPeriod(voiceNum, period);
-		Paula::setChannelVolume(voiceNum, 0);
+				Paula::enableChannel(voiceNum);
+				// wait  for dma-clear
+				// FIXME: this is a workaround to enable oneshot-samples and it currently might crash Paula
+				if (patch.sampleTotalLen == patch.sampleAttackLen) {
+					Paula::setChannelSampleStart(voiceNum, 0);
+					Paula::setChannelSampleLen(voiceNum, 0);
+				}
+			}
 
-		Paula::enableChannel(voiceNum);
-		// wait  for dma-clear
-		// FIXME: this is a workaround to enable oneshot-samples and it currently might crash Paula
-		if (patch.sampleTotalLen == patch.sampleAttackLen) {
-			Paula::setChannelSampleStart(voiceNum, 0);
-			Paula::setChannelSampleLen(voiceNum, 0);
-		}
-	}
+			if (patch.sampleTotalLen > patch.sampleAttackLen) {
+				Paula::setChannelSampleStart(voiceNum, samplePtr + (patch.sampleAttackLen << useOctave));
+				Paula::setChannelSampleLen(voiceNum, ((patch.sampleTotalLen - patch.sampleAttackLen) << useOctave) / 2);
+				if (!patch.sampleAttackLen) {
+					// need to enable channel
+					Paula::setChannelPeriod(voiceNum, period);
+					Paula::setChannelVolume(voiceNum, 0);
 
-	if (patch.sampleTotalLen > patch.sampleAttackLen) {
-		Paula::setChannelSampleStart(voiceNum, samplePtr + (patch.sampleAttackLen << useOctave));
-		Paula::setChannelSampleLen(voiceNum, ((patch.sampleTotalLen - patch.sampleAttackLen) << useOctave) / 2);
-		if (!patch.sampleAttackLen) {
-			// need to enable channel
-			Paula::setChannelPeriod(voiceNum, period);
-			Paula::setChannelVolume(voiceNum, 0);
+					Paula::enableChannel(voiceNum);
+				}
+				// another pointless wait for DMA-Clear???
+			}
 
-			Paula::enableChannel(voiceNum);
+			channel.voicesActive++;
+			if (&channel < &_channelCtx[kNumChannels]) {
+				if ((channel.flags & ChannelContext::kFlagPortamento) != 0) {
+					if ((channel.flags & ChannelContext::kFlagMono) != 0 && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
+						voice.portaTicks = 0;
+						voice.endNote = voice.baseNote;
+						voice.baseNote = channel.lastNote;
+						voice.flags |= VoiceContext::kFlagPortamento;
+					}
+					channel.lastNote = note;
+				}
+			}
 		}
-		// another pointless wait for DMA-Clear???
 	}
-
-	channel.voicesActive++;
-	if (&channel < &_channelCtx[kNumChannels]) {
-		const byte flagsSet = ChannelContext::kFlagMono | ChannelContext::kFlagPortamento;
-		if ((channel.flags & flagsSet) == flagsSet && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
-			voice.portaTicks = 0;
-			voice.endNote = voice.baseNote;
-			voice.baseNote = channel.lastNote;
-			voice.flags |= VoiceContext::kFlagPortamento;
-		}
-		if ((channel.flags & ChannelContext::kFlagPortamento) != 0)
-			channel.lastNote = note;
-	}
-	_playerCtx.addedNote = true;
-	_playerCtx.lastVoice = voiceNum;
 	return voiceNum;
 }
 
-void MaxTrax::noteOff(ChannelContext &channel, const byte note) {
-	VoiceContext &voice = _voiceCtx[_playerCtx.lastVoice];
-	if (channel.voicesActive && voice.channel == &channel && voice.status != VoiceContext::kStatusRelease) {
+void MaxTrax::noteOff(VoiceContext &voice, const byte note) {
+	ChannelContext &channel = *voice.channel;
+	if (channel.voicesActive && voice.status != VoiceContext::kStatusRelease) {
 		const byte refNote = ((voice.flags & VoiceContext::kFlagPortamento) != 0) ? voice.endNote : voice.baseNote;
+		assert(refNote == note);
 		if (refNote == note) {
 			if ((channel.flags & ChannelContext::kFlagDamper) != 0)
 				voice.flags |= VoiceContext::kFlagDamper;
@@ -562,7 +553,7 @@
 	chan.modulation = 0;
 	chan.modulationTime = 1000;
 	chan.microtonal = -1;
-	chan.portamento = 500;
+	chan.portamentoTime = 500;
 	chan.pitchBend = 64 << 7;
 	chan.pitchReal = 0;
 	chan.pitchBendRange = 24;

Modified: scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h	2009-07-13 22:20:06 UTC (rev 42460)
+++ scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h	2009-07-13 22:49:34 UTC (rev 42461)
@@ -121,7 +121,7 @@
 
 		int16	microtonal;
 
-		uint16	portamento;
+		uint16	portamentoTime;
 
 		int16	pitchBend;
 		int16	pitchReal;
@@ -207,7 +207,7 @@
 	static int8 MaxTrax::pickvoice(const VoiceContext voice[4], uint pick, int16 pri);
 	int calcNote(VoiceContext &voice);
 	int8 noteOn(ChannelContext &channel, byte note, uint16 volume, uint16 pri);
-	void noteOff(ChannelContext &channel, byte note);
+	void noteOff(VoiceContext &voice, byte note);
 	void killVoice(byte num);
 
 	void setTempo(const uint16 tempo) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list