Commits

Bill Meltsner committed d67e77b

removed user-specified sample rates for Decoders

Comments (0)

Files changed (14)

src/modules/sound/Sound.h

-/**
-* Copyright (c) 2006-2010 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
+/**
+* Copyright (c) 2006-2010 LOVE Development Team
+* 
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* 
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
 **/
 
 #ifndef LOVE_SOUND_SOUND_H
 		* @param sampleRate Samples per second, or quality of the audio. 44100 is a good value.
 		* @return A Decoder object on success, or zero if no decoder could be found.
 		**/
-		virtual Decoder * newDecoder(filesystem::File * file, int bufferSize, int sampleRate) = 0;
+		virtual Decoder * newDecoder(filesystem::File * file, int bufferSize) = 0;
 
 	}; // Sound
 

src/modules/sound/lullaby/Decoder.cpp

 {
 namespace lullaby
 {
-	Decoder::Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate)
-		:data(data), ext(ext), bufferSize(bufferSize), sampleRate(sampleRate), buffer(0), eof(false)
+	Decoder::Decoder(Data * data, const std::string & ext, int bufferSize)
+		:data(data), ext(ext), bufferSize(bufferSize), sampleRate(DEFAULT_SAMPLE_RATE), buffer(0), eof(false)
 	{
 		data->retain();
 		buffer = new char[bufferSize];

src/modules/sound/lullaby/Decoder.h

 
 	public:
 
-		Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate);
+		Decoder(Data * data, const std::string & ext, int bufferSize);
 
 		virtual ~Decoder();
 

src/modules/sound/lullaby/FLACDecoder.cpp

 {
 namespace lullaby
 {
-	FLACDecoder::FLACDecoder(Data * data, const std::string & ext, int nbufferSize, int sampleRate)
-		: Decoder(data, ext, nbufferSize, sampleRate), pos(0)
+	FLACDecoder::FLACDecoder(Data * data, const std::string & ext, int nbufferSize)
+		: Decoder(data, ext, nbufferSize), pos(0)
 	{
 		init();
 		init_ogg();

src/modules/sound/lullaby/FLACDecoder.h

 			int pos;
 			
 		public:
-			FLACDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate);
+			FLACDecoder(Data * data, const std::string & ext, int bufferSize);
 			~FLACDecoder();
 			
 			static bool accepts(const std::string &ext);

src/modules/sound/lullaby/ModPlugDecoder.cpp

 {
 namespace lullaby
 {
-	ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate)
-		: Decoder(data, ext, bufferSize, sampleRate), plug(0)
+	ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize)
+		: Decoder(data, ext, bufferSize), plug(0)
 	{
 
 		// Set some ModPlug settings.
 
 	love::sound::Decoder * ModPlugDecoder::clone()
 	{
-		return new ModPlugDecoder(data, ext, bufferSize, settings.mFrequency);
+		return new ModPlugDecoder(data, ext, bufferSize);
 	}
 
 	int ModPlugDecoder::decode()

src/modules/sound/lullaby/ModPlugDecoder.h

 
 	public:
 
-		ModPlugDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate);
+		ModPlugDecoder(Data * data, const std::string & ext, int bufferSize);
 		virtual ~ModPlugDecoder();
 
 		static bool accepts(const std::string & ext);

src/modules/sound/lullaby/Mpg123Decoder.cpp

 
 	bool Mpg123Decoder::inited = false;
 
-	Mpg123Decoder::Mpg123Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate)
-		: Decoder(data, ext, bufferSize, sampleRate), handle(0), channels(MPG123_STEREO)
+	Mpg123Decoder::Mpg123Decoder(Data * data, const std::string & ext, int bufferSize)
+		: Decoder(data, ext, bufferSize), handle(0), channels(MPG123_STEREO)
 	{
 
 		data_size = data->getSize();
 
 	love::sound::Decoder * Mpg123Decoder::clone()
 	{
-		return new Mpg123Decoder(data, ext, bufferSize, sampleRate);
+		return new Mpg123Decoder(data, ext, bufferSize);
 	}
 
 	int Mpg123Decoder::decode()

src/modules/sound/lullaby/Mpg123Decoder.h

 
 	public:
 
-		Mpg123Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate);
+		Mpg123Decoder(Data * data, const std::string & ext, int bufferSize);
 		virtual ~Mpg123Decoder();
 
 		static bool accepts(const std::string & ext);

src/modules/sound/lullaby/Sound.cpp

 		return "love.sound.lullaby";
 	}
 
-	sound::Decoder * Sound::newDecoder(love::filesystem::File * file, int bufferSize, int sampleRate)
+	sound::Decoder * Sound::newDecoder(love::filesystem::File * file, int bufferSize)
 	{
 		Data * data = file->read();
 		std::string ext = file->getExtension();
 
 		// Find a suitable decoder here, and return it.
 		if(ModPlugDecoder::accepts(ext))
-			decoder = new ModPlugDecoder(data, ext, bufferSize, sampleRate);
+			decoder = new ModPlugDecoder(data, ext, bufferSize);
 		else if(Mpg123Decoder::accepts(ext))
-			decoder = new Mpg123Decoder(data, ext, bufferSize, sampleRate);
+			decoder = new Mpg123Decoder(data, ext, bufferSize);
 		else if(VorbisDecoder::accepts(ext))
-			decoder = new VorbisDecoder(data, ext, bufferSize, sampleRate);
+			decoder = new VorbisDecoder(data, ext, bufferSize);
 		/*else if (FLACDecoder::accepts(ext))
-			decoder = new FLACDecoder(data, ext, bufferSize, sampleRate);*/
+			decoder = new FLACDecoder(data, ext, bufferSize);*/
 
 		// else if(OtherDecoder::accept(ext))
 

src/modules/sound/lullaby/Sound.h

-/**
-* Copyright (c) 2006-2010 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
+/**
+* Copyright (c) 2006-2010 LOVE Development Team
+* 
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* 
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
 **/
 
 
 		const char * getName() const;
 		
 		/// @copydoc love::sound::Sound::newDecoder
-		sound::Decoder * newDecoder(love::filesystem::File * file, int bufferSize, int sampleRate);
+		sound::Decoder * newDecoder(love::filesystem::File * file, int bufferSize);
 
 	}; // Sound
 

src/modules/sound/lullaby/VorbisDecoder.cpp

 	* END CALLBACK FUNCTIONS
 	**/
 
-	VorbisDecoder::VorbisDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate)
-		: Decoder(data, ext, bufferSize, sampleRate)
+	VorbisDecoder::VorbisDecoder(Data * data, const std::string & ext, int bufferSize)
+		: Decoder(data, ext, bufferSize)
 	{
 		// Initialize callbacks
 		vorbisCallbacks.close_func = vorbisClose;
 
 	love::sound::Decoder * VorbisDecoder::clone()
 	{
-		return new VorbisDecoder(data, ext, bufferSize, sampleRate);
+		return new VorbisDecoder(data, ext, bufferSize);
 	}
 
 	int VorbisDecoder::decode()

src/modules/sound/lullaby/VorbisDecoder.h

 
 	public:
 
-		VorbisDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate);
+		VorbisDecoder(Data * data, const std::string & ext, int bufferSize);
 		virtual ~VorbisDecoder();
 		
 		static bool accepts(const std::string & ext);

src/modules/sound/wrap_Sound.cpp

 
 		love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
 		int bufferSize = luaL_optint(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
-		int sampleRate = luaL_optint(L, 3, Decoder::DEFAULT_SAMPLE_RATE);
 
 		try
 		{
-			Decoder * t = instance->newDecoder(file, bufferSize, sampleRate);
+			Decoder * t = instance->newDecoder(file, bufferSize);
 			if(t == 0)
 				return luaL_error(L, "Extension \"%s\" not supported.", file->getExtension().c_str());
 			luax_newtype(L, "Decoder", SOUND_DECODER_T, (void*)t);
 			instance->retain();
 
 
-		WrappedModule w;
-		w.module = instance;
-		w.name = "sound";
-		w.flags = MODULE_SOUND_T;
-		w.functions = functions;
-		w.types = types;
-
+		WrappedModule w;
+		w.module = instance;
+		w.name = "sound";
+		w.flags = MODULE_SOUND_T;
+		w.functions = functions;
+		w.types = types;
+
 		return luax_register_module(L, w);
 	}