[Scummvm-cvs-logs] CVS: scummvm/sound voc.cpp,1.9,1.10 voc.h,1.7,1.8

Max Horn fingolfin at users.sourceforge.net
Fri Jan 2 16:35:17 CET 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv31055

Modified Files:
	voc.cpp voc.h 
Log Message:
added makeVOCStream() (convenience function)

Index: voc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/voc.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- voc.cpp	28 Dec 2003 09:14:00 -0000	1.9
+++ voc.cpp	3 Jan 2004 00:33:14 -0000	1.10
@@ -23,9 +23,24 @@
 #include "stdafx.h"
 #include "common/util.h"
 #include "common/file.h"
+
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
 #include "sound/voc.h"
 
 
+int getSampleRateFromVOCRate(int vocSR) {
+	if (vocSR == 0xa5 || vocSR == 0xa6 || vocSR == 0x83) {
+		return 11025;
+	} else if (vocSR == 0xd2 || vocSR == 0xd3) {
+		return 22050;
+	} else {
+		int sr = 1000000L / (256L - vocSR);
+		warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
+		return sr;
+	}
+}
+
 byte *readVOCFromMemory(byte *ptr, int &size, int &rate, int &loops) {
 	
 	assert(memcmp(ptr, "Creative Voice File\x1A", 20) == 0);
@@ -137,14 +152,17 @@
 	return data;
 }
 
-int getSampleRateFromVOCRate(int vocSR) {
-	if (vocSR == 0xa5 || vocSR == 0xa6 || vocSR == 0x83) {
-		return 11025;
-	} else if (vocSR == 0xd2 || vocSR == 0xd3) {
-		return 22050;
-	} else {
-		int sr = 1000000L / (256L - vocSR);
-		warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
-		return sr;
-	}
+AudioInputStream *makeVOCStream(byte *ptr) {
+	int size, rate, loops;
+	byte *data = readVOCFromMemory(ptr, size, rate, loops);
+
+	return makeLinearInputStream(rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, data, size, 0, 0);
 }
+
+AudioInputStream *makeVOCStream(File *file) {
+	int size, rate;
+	byte *data = loadVOCFile(file, size, rate);
+
+	return makeLinearInputStream(rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, data, size, 0, 0);
+}
+

Index: voc.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/voc.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- voc.h	27 Dec 2003 14:10:45 -0000	1.7
+++ voc.h	3 Jan 2004 00:33:14 -0000	1.8
@@ -26,6 +26,7 @@
 #include "stdafx.h"
 #include "common/scummsys.h"
 
+class AudioInputStream;
 class File;
 
 #if !defined(__GNUC__)
@@ -58,5 +59,8 @@
 
 extern byte *readVOCFromMemory(byte *ptr, int &size, int &rate, int &loops);
 extern byte *loadVOCFile(File *file, int &size, int &rate);
+
+AudioInputStream *makeVOCStream(byte *ptr);
+AudioInputStream *makeVOCStream(File *file);
 
 #endif





More information about the Scummvm-git-logs mailing list