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

nolange at users.sourceforge.net nolange at users.sourceforge.net
Fri Jul 17 02:58:26 CEST 2009


Revision: 42553
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42553&view=rev
Author:   nolange
Date:     2009-07-17 00:58:26 +0000 (Fri, 17 Jul 2009)

Log Message:
-----------
avoid some calculations from being done every time in CalcNote

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
    scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h

Modified: scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-17 00:55:56 UTC (rev 42552)
+++ scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-17 00:58:26 UTC (rev 42553)
@@ -276,6 +276,7 @@
 				if ((uint16)(voice.portaTicks >> 8) >= channel.portamentoTime) {
 					voice.hasPortamento = false;
 					voice.baseNote = voice.endNote;
+					voice.preCalcNote = precalcNote(voice.baseNote, patch.tune);
 				}
 				voice.lastPeriod = calcNote(voice);
 			} else if (channel.isAltered || channel.modulation)
@@ -329,7 +330,7 @@
 	voice.flags = 0;
 	voice.hasPortamento = false;
 	voice.priority = 0;
-	voice.uinqueId = 0;
+	//voice.uinqueId = 0;
 
 	// "stop" voice, set period to 1, vol to 0
 	Paula::disableChannel(num);
@@ -385,10 +386,8 @@
 	const ChannelContext &channel = *voice.channel;
 	int16 bend = channel.pitchReal;
 	if (voice.hasPortamento)
-		bend = (int16)(((int8)(voice.endNote - voice.baseNote)) * voice.portaTicks) / channel.portamentoTime;
+		bend += (int16)(((int8)(voice.endNote - voice.baseNote)) * voice.portaTicks) / channel.portamentoTime;
 
-	const Patch &patch = *voice.patch;
-
 	// 0x9fd77 ~ log2(1017)  MIDI F5 ?
 	// 0x8fd77 ~ log2(508.5) MIDI F4 ?
 	// 0x6f73d ~ log2(125) ~ 5675Hz
@@ -396,11 +395,12 @@
 
 	// tone = voice.baseNote << 8 + microtonal
 	// bend = channelPitch + porta + modulation
-	int32 tone = K_VALUE + 0x3C000 - ((voice.baseNote << 14) + (bend << 6) + (patch.tune << 14) / 24) / 3;
 
+	int32 tone = voice.preCalcNote + (bend << 6) / 3;
+
 	// calculate which sample to use
 	if (offset) {
-		*offset = (tone <= PREF_PERIOD) ? 0 : MIN((int32)((tone + 0xFFFF - PREF_PERIOD) >> 16), (int32)(patch.sampleOctaves - 1)) << 16;
+		*offset = (tone <= PREF_PERIOD) ? 0 : MIN((int32)((tone + 0xFFFF - PREF_PERIOD) >> 16), (int32)(voice.patch->sampleOctaves - 1)) << 16;
 		tone -= *offset;
 	} else
 		tone -= voice.periodOffset;
@@ -432,6 +432,7 @@
 			// reset previous porta
 			if (voice->hasPortamento)
 				voice->baseNote = voice->endNote;
+			voice->preCalcNote = precalcNote(voice->baseNote, patch.tune);
 			voice->portaTicks = 0;
 			voice->hasPortamento = true;
 			voice->endNote = channel.lastNote = note;
@@ -450,6 +451,7 @@
 			voice.channel = &channel;
 			voice.patch = &patch;
 			voice.baseNote = note;
+			voice.preCalcNote = precalcNote(voice.baseNote, patch.tune);
 			voice.hasPortamento = false;
 
 			
@@ -507,6 +509,7 @@
 						voice.portaTicks = 0;
 						voice.endNote = voice.baseNote;
 						voice.baseNote = channel.lastNote;
+						voice.preCalcNote = precalcNote(voice.baseNote, patch.tune);
 						voice.hasPortamento = true;
 					}
 					channel.lastNote = note;

Modified: scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h	2009-07-17 00:55:56 UTC (rev 42552)
+++ scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.h	2009-07-17 00:58:26 UTC (rev 42553)
@@ -147,8 +147,8 @@
 		ChannelContext *channel;
 		const Patch	*patch;
 		const Envelope *envelope;
-		uint32	uinqueId;
-		uint32	lastTicks;
+//		uint32	uinqueId;
+		int32	preCalcNote;
 		uint32	ticksLeft;
 		int32	portaTicks;
 		int32	incrVolume;
@@ -213,6 +213,10 @@
 		_playerCtx.tickUnit = (int32)(((uint32)(tempo & 0xFFF0) << 8) / (uint16)(5 * _playerCtx.vBlankFreq));
 	}
 
+	static int32 precalcNote(byte baseNote, int16 tune) {
+		return 0x9fd77 + 0x3C000 - ((baseNote << 14) + (tune << 11) / 3) / 3;
+	}
+
 	static void outPutEvent(const Event &ev, int num = -1) {
 		struct {
 			byte cmd;


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