mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Automated formatting fix
This commit is contained in:
+142
-142
@@ -1,142 +1,142 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_DECODER_H
|
||||
#define LOVE_SOUND_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Object.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
/**
|
||||
* Decoder objects are responsible for decoding audio files. They maintain
|
||||
* an interal buffer into which they write raw decoded audio data.
|
||||
**/
|
||||
class Decoder : public Object
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Indicates how many bytes of raw data should be generated at each
|
||||
* call to Decode.
|
||||
**/
|
||||
static const int DEFAULT_BUFFER_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* Indicates the quality of the sound.
|
||||
**/
|
||||
static const int DEFAULT_SAMPLE_RATE = 44100;
|
||||
|
||||
/**
|
||||
* Default is stereo.
|
||||
**/
|
||||
static const int DEFAULT_CHANNELS = 2;
|
||||
|
||||
/**
|
||||
* 16 bit audio is the default.
|
||||
**/
|
||||
static const int DEFAULT_BITS = 16;
|
||||
|
||||
/**
|
||||
* Creates a deep of itself. The sound stream can (and should) be
|
||||
* rewound, and does not have to be at the same place.
|
||||
* @return A new Decoder object.
|
||||
**/
|
||||
virtual Decoder * clone() = 0;
|
||||
|
||||
/**
|
||||
* Destructor. Should free internal buffer.
|
||||
**/
|
||||
virtual ~Decoder(){};
|
||||
|
||||
/**
|
||||
* Decodes the next chunk of the music stream, this will usually be
|
||||
* bufferSize amount of bytes, unless EOF occurs. Zero or negative values
|
||||
* indicate EOF or errors.
|
||||
* @return The number of bytes actually decoded.
|
||||
**/
|
||||
virtual int decode() = 0;
|
||||
|
||||
/**
|
||||
* Gets the size of the buffer (NOT the size of the entire stream).
|
||||
* @return The size of the buffer.
|
||||
**/
|
||||
virtual int getSize() const = 0;
|
||||
|
||||
/**
|
||||
* Gets a pointer to the actual data. The contents of this buffer will
|
||||
* change with each call to decode, so the client must copy the data.
|
||||
* @return A buffer to raw sound data.
|
||||
**/
|
||||
virtual void * getBuffer() const = 0;
|
||||
|
||||
/**
|
||||
* Seeks to the specified position, if possible.
|
||||
* @param s The position in the stream in seconds.
|
||||
* @return True if success, false on fail/unsupported.
|
||||
**/
|
||||
virtual bool seek(float s) = 0;
|
||||
|
||||
/**
|
||||
* Rewinds the stream to the start.
|
||||
* @return True if success, false on fail/unsupported.
|
||||
**/
|
||||
virtual bool rewind() = 0;
|
||||
|
||||
/**
|
||||
* Checks whether a stream is seekable.
|
||||
* @return True if seekable, false otherwise.
|
||||
**/
|
||||
virtual bool isSeekable() = 0;
|
||||
|
||||
/**
|
||||
* Checks whether a stream has more data to decode or not. Use
|
||||
* rewind to start the stream again.
|
||||
* @return False if there is more data, true on EOF.
|
||||
**/
|
||||
virtual bool isFinished() = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of channels in a stream. Supported values are 1 (mono) or 2 (stereo).
|
||||
* @return Either 1 for mono, 2 for stereo, or 0 on errors.
|
||||
**/
|
||||
virtual int getChannels() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of bits per sample. Supported values are 8 or 16.
|
||||
* @return Either 8, 16, or 0 if unsupported.
|
||||
**/
|
||||
virtual int getBits() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the sample rate for the Decoder, that is, samples per second.
|
||||
* @return The sample rate, eg. 44100.
|
||||
**/
|
||||
virtual int getSampleRate() const = 0;
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_DECODER_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_DECODER_H
|
||||
#define LOVE_SOUND_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Object.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
/**
|
||||
* Decoder objects are responsible for decoding audio files. They maintain
|
||||
* an interal buffer into which they write raw decoded audio data.
|
||||
**/
|
||||
class Decoder : public Object
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Indicates how many bytes of raw data should be generated at each
|
||||
* call to Decode.
|
||||
**/
|
||||
static const int DEFAULT_BUFFER_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* Indicates the quality of the sound.
|
||||
**/
|
||||
static const int DEFAULT_SAMPLE_RATE = 44100;
|
||||
|
||||
/**
|
||||
* Default is stereo.
|
||||
**/
|
||||
static const int DEFAULT_CHANNELS = 2;
|
||||
|
||||
/**
|
||||
* 16 bit audio is the default.
|
||||
**/
|
||||
static const int DEFAULT_BITS = 16;
|
||||
|
||||
/**
|
||||
* Creates a deep of itself. The sound stream can (and should) be
|
||||
* rewound, and does not have to be at the same place.
|
||||
* @return A new Decoder object.
|
||||
**/
|
||||
virtual Decoder * clone() = 0;
|
||||
|
||||
/**
|
||||
* Destructor. Should free internal buffer.
|
||||
**/
|
||||
virtual ~Decoder(){};
|
||||
|
||||
/**
|
||||
* Decodes the next chunk of the music stream, this will usually be
|
||||
* bufferSize amount of bytes, unless EOF occurs. Zero or negative values
|
||||
* indicate EOF or errors.
|
||||
* @return The number of bytes actually decoded.
|
||||
**/
|
||||
virtual int decode() = 0;
|
||||
|
||||
/**
|
||||
* Gets the size of the buffer (NOT the size of the entire stream).
|
||||
* @return The size of the buffer.
|
||||
**/
|
||||
virtual int getSize() const = 0;
|
||||
|
||||
/**
|
||||
* Gets a pointer to the actual data. The contents of this buffer will
|
||||
* change with each call to decode, so the client must copy the data.
|
||||
* @return A buffer to raw sound data.
|
||||
**/
|
||||
virtual void * getBuffer() const = 0;
|
||||
|
||||
/**
|
||||
* Seeks to the specified position, if possible.
|
||||
* @param s The position in the stream in seconds.
|
||||
* @return True if success, false on fail/unsupported.
|
||||
**/
|
||||
virtual bool seek(float s) = 0;
|
||||
|
||||
/**
|
||||
* Rewinds the stream to the start.
|
||||
* @return True if success, false on fail/unsupported.
|
||||
**/
|
||||
virtual bool rewind() = 0;
|
||||
|
||||
/**
|
||||
* Checks whether a stream is seekable.
|
||||
* @return True if seekable, false otherwise.
|
||||
**/
|
||||
virtual bool isSeekable() = 0;
|
||||
|
||||
/**
|
||||
* Checks whether a stream has more data to decode or not. Use
|
||||
* rewind to start the stream again.
|
||||
* @return False if there is more data, true on EOF.
|
||||
**/
|
||||
virtual bool isFinished() = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of channels in a stream. Supported values are 1 (mono) or 2 (stereo).
|
||||
* @return Either 1 for mono, 2 for stereo, or 0 on errors.
|
||||
**/
|
||||
virtual int getChannels() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of bits per sample. Supported values are 8 or 16.
|
||||
* @return Either 8, 16, or 0 if unsupported.
|
||||
**/
|
||||
virtual int getBits() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the sample rate for the Decoder, that is, samples per second.
|
||||
* @return The sample rate, eg. 44100.
|
||||
**/
|
||||
virtual int getSampleRate() const = 0;
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_DECODER_H
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -35,18 +35,18 @@ namespace sound
|
||||
|
||||
/**
|
||||
* The Sound module is responsible for decoding sound data. It is
|
||||
* not responsible for playing it.
|
||||
* not responsible for playing it.
|
||||
**/
|
||||
class Sound : public Module
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
virtual ~Sound();
|
||||
|
||||
|
||||
/**
|
||||
* Creates new SoundData from a decoder. Fully expands the
|
||||
* encoded sound data into raw sound data. Not recommended
|
||||
@@ -59,8 +59,8 @@ namespace sound
|
||||
/**
|
||||
* Creates a new SoundData with the specified number of samples and format.
|
||||
* @param duration In seconds.
|
||||
* @param sampleRate Number of samples per second.
|
||||
* @param bits Bits per sample (8 or 16).
|
||||
* @param sampleRate Number of samples per second.
|
||||
* @param bits Bits per sample (8 or 16).
|
||||
* @param channels Either 1 for mono, or 2 for stereo.
|
||||
* @return A new SoundData object, or zero in case of errors.
|
||||
**/
|
||||
|
||||
+157
-157
@@ -1,157 +1,157 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "SoundData.h"
|
||||
|
||||
// C
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// STL
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData::SoundData(Decoder * decoder)
|
||||
: data(0), size(0), sampleRate(Decoder::DEFAULT_SAMPLE_RATE), bits(0), channels(0)
|
||||
{
|
||||
int decoded = decoder->decode();
|
||||
|
||||
while(decoded > 0)
|
||||
{
|
||||
// Expand or allocate buffer. Note that realloc may move
|
||||
// memory to other locations.
|
||||
data = (char*)realloc(data, size + decoder->getSize());
|
||||
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory."); // I know, I know, little memory, creating objects..
|
||||
|
||||
// Copy memory into new part of memory.
|
||||
memcpy(data + size, decoder->getBuffer(), decoded);
|
||||
|
||||
// Keep this up to date.
|
||||
size += decoded;
|
||||
|
||||
decoded = decoder->decode();
|
||||
}
|
||||
|
||||
channels = decoder->getChannels();
|
||||
bits = decoder->getBits();
|
||||
sampleRate = decoder->getSampleRate();
|
||||
}
|
||||
|
||||
SoundData::SoundData(int samples, int sampleRate, int bits, int channels)
|
||||
: data(0), size(samples*(bits/8)*channels), sampleRate(sampleRate), bits(bits), channels(channels)
|
||||
{
|
||||
double realsize = samples;
|
||||
realsize *= (bits/8)*channels;
|
||||
if (realsize > INT_MAX)
|
||||
throw love::Exception("Data is too big!");
|
||||
data = (char*)malloc(size);
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory.");
|
||||
}
|
||||
|
||||
SoundData::SoundData(void * d, int samples, int sampleRate, int bits, int channels)
|
||||
: data(0), size(samples*(bits/8)*channels), sampleRate(sampleRate), bits(bits), channels(channels)
|
||||
{
|
||||
double realsize = samples;
|
||||
realsize *= (bits/8)*channels;
|
||||
if (realsize > INT_MAX)
|
||||
throw love::Exception("Data is too big!");
|
||||
data = (char*)malloc(size);
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory.");
|
||||
memcpy(data, d, size);
|
||||
}
|
||||
|
||||
SoundData::~SoundData()
|
||||
{
|
||||
if(data != 0)
|
||||
free(data);
|
||||
}
|
||||
|
||||
void * SoundData::getData() const
|
||||
{
|
||||
return (void*)data;
|
||||
}
|
||||
|
||||
int SoundData::getSize() const
|
||||
{
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
int SoundData::getChannels() const
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
|
||||
int SoundData::getBits() const
|
||||
{
|
||||
return bits;
|
||||
}
|
||||
|
||||
int SoundData::getSampleRate() const
|
||||
{
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
void SoundData::setSample(int i, float sample)
|
||||
{
|
||||
// Check range.
|
||||
if(i < 0 || i >= size/(bits/8))
|
||||
return;
|
||||
|
||||
if(bits == 16)
|
||||
{
|
||||
short * s = (short *)data;
|
||||
s[i] = (short)(sample*(float)SHRT_MAX);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i] = (char)(sample*(float)CHAR_MAX);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float SoundData::getSample(int i) const
|
||||
{
|
||||
// Check range.
|
||||
if(i < 0 || i >= size/(bits/8))
|
||||
return 0;
|
||||
|
||||
if(bits == 16)
|
||||
{
|
||||
short * s = (short *)data;
|
||||
return (float)s[i]/(float)SHRT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (float)data[i]/(float)CHAR_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "SoundData.h"
|
||||
|
||||
// C
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// STL
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData::SoundData(Decoder * decoder)
|
||||
: data(0), size(0), sampleRate(Decoder::DEFAULT_SAMPLE_RATE), bits(0), channels(0)
|
||||
{
|
||||
int decoded = decoder->decode();
|
||||
|
||||
while (decoded > 0)
|
||||
{
|
||||
// Expand or allocate buffer. Note that realloc may move
|
||||
// memory to other locations.
|
||||
data = (char*)realloc(data, size + decoder->getSize());
|
||||
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory."); // I know, I know, little memory, creating objects..
|
||||
|
||||
// Copy memory into new part of memory.
|
||||
memcpy(data + size, decoder->getBuffer(), decoded);
|
||||
|
||||
// Keep this up to date.
|
||||
size += decoded;
|
||||
|
||||
decoded = decoder->decode();
|
||||
}
|
||||
|
||||
channels = decoder->getChannels();
|
||||
bits = decoder->getBits();
|
||||
sampleRate = decoder->getSampleRate();
|
||||
}
|
||||
|
||||
SoundData::SoundData(int samples, int sampleRate, int bits, int channels)
|
||||
: data(0), size(samples*(bits/8)*channels), sampleRate(sampleRate), bits(bits), channels(channels)
|
||||
{
|
||||
double realsize = samples;
|
||||
realsize *= (bits/8)*channels;
|
||||
if (realsize > INT_MAX)
|
||||
throw love::Exception("Data is too big!");
|
||||
data = (char*)malloc(size);
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory.");
|
||||
}
|
||||
|
||||
SoundData::SoundData(void * d, int samples, int sampleRate, int bits, int channels)
|
||||
: data(0), size(samples*(bits/8)*channels), sampleRate(sampleRate), bits(bits), channels(channels)
|
||||
{
|
||||
double realsize = samples;
|
||||
realsize *= (bits/8)*channels;
|
||||
if (realsize > INT_MAX)
|
||||
throw love::Exception("Data is too big!");
|
||||
data = (char*)malloc(size);
|
||||
if (!data)
|
||||
throw love::Exception("Not enough memory.");
|
||||
memcpy(data, d, size);
|
||||
}
|
||||
|
||||
SoundData::~SoundData()
|
||||
{
|
||||
if (data != 0)
|
||||
free(data);
|
||||
}
|
||||
|
||||
void * SoundData::getData() const
|
||||
{
|
||||
return (void*)data;
|
||||
}
|
||||
|
||||
int SoundData::getSize() const
|
||||
{
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
int SoundData::getChannels() const
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
|
||||
int SoundData::getBits() const
|
||||
{
|
||||
return bits;
|
||||
}
|
||||
|
||||
int SoundData::getSampleRate() const
|
||||
{
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
void SoundData::setSample(int i, float sample)
|
||||
{
|
||||
// Check range.
|
||||
if (i < 0 || i >= size/(bits/8))
|
||||
return;
|
||||
|
||||
if (bits == 16)
|
||||
{
|
||||
short * s = (short *)data;
|
||||
s[i] = (short)(sample*(float)SHRT_MAX);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i] = (char)(sample*(float)CHAR_MAX);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float SoundData::getSample(int i) const
|
||||
{
|
||||
// Check range.
|
||||
if (i < 0 || i >= size/(bits/8))
|
||||
return 0;
|
||||
|
||||
if (bits == 16)
|
||||
{
|
||||
short * s = (short *)data;
|
||||
return (float)s[i]/(float)SHRT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (float)data[i]/(float)CHAR_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_DATA_H
|
||||
#define LOVE_SOUND_SOUND_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <filesystem/File.h>
|
||||
|
||||
#include "Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
class SoundData : public love::Data
|
||||
{
|
||||
private:
|
||||
|
||||
char * data;
|
||||
int size;
|
||||
|
||||
int sampleRate;
|
||||
int bits;
|
||||
int channels;
|
||||
|
||||
public:
|
||||
|
||||
SoundData(Decoder * decoder);
|
||||
SoundData(int samples, int sampleRate, int bits, int channels);
|
||||
SoundData(void * d, int samples, int sampleRate, int bits, int channels);
|
||||
|
||||
virtual ~SoundData();
|
||||
|
||||
// Implements Data.
|
||||
void * getData() const;
|
||||
int getSize() const;
|
||||
|
||||
virtual int getChannels() const;
|
||||
virtual int getBits() const;
|
||||
virtual int getSampleRate() const;
|
||||
|
||||
void setSample(int i, float sample);
|
||||
float getSample(int i) const;
|
||||
|
||||
}; // SoundData
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_SOUND_DATA_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_DATA_H
|
||||
#define LOVE_SOUND_SOUND_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <filesystem/File.h>
|
||||
|
||||
#include "Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
class SoundData : public love::Data
|
||||
{
|
||||
private:
|
||||
|
||||
char * data;
|
||||
int size;
|
||||
|
||||
int sampleRate;
|
||||
int bits;
|
||||
int channels;
|
||||
|
||||
public:
|
||||
|
||||
SoundData(Decoder * decoder);
|
||||
SoundData(int samples, int sampleRate, int bits, int channels);
|
||||
SoundData(void * d, int samples, int sampleRate, int bits, int channels);
|
||||
|
||||
virtual ~SoundData();
|
||||
|
||||
// Implements Data.
|
||||
void * getData() const;
|
||||
int getSize() const;
|
||||
|
||||
virtual int getChannels() const;
|
||||
virtual int getBits() const;
|
||||
virtual int getSampleRate() const;
|
||||
|
||||
void setSample(int i, float sample);
|
||||
float getSample(int i) const;
|
||||
|
||||
}; // SoundData
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_SOUND_DATA_H
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Decoder.h"
|
||||
|
||||
#include <common/Exception.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
Decoder::~Decoder()
|
||||
{
|
||||
if(buffer != 0)
|
||||
delete [] (char*) buffer;
|
||||
if(data != 0)
|
||||
data->release();
|
||||
}
|
||||
|
||||
void * Decoder::getBuffer() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int Decoder::getSize() const
|
||||
{
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
int Decoder::getSampleRate() const
|
||||
{
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
bool Decoder::isFinished()
|
||||
{
|
||||
return eof;
|
||||
}
|
||||
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Decoder.h"
|
||||
|
||||
#include <common/Exception.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
Decoder::~Decoder()
|
||||
{
|
||||
if (buffer != 0)
|
||||
delete [] (char*) buffer;
|
||||
if (data != 0)
|
||||
data->release();
|
||||
}
|
||||
|
||||
void * Decoder::getBuffer() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int Decoder::getSize() const
|
||||
{
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
int Decoder::getSampleRate() const
|
||||
{
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
bool Decoder::isFinished()
|
||||
{
|
||||
return eof;
|
||||
}
|
||||
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_LULLABY_DECODER_H
|
||||
#define LOVE_SOUND_LULLABY_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <sound/Decoder.h>
|
||||
#include <filesystem/File.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
class Decoder : public love::sound::Decoder
|
||||
{
|
||||
protected:
|
||||
|
||||
// The encoded data. This should be replaced with buffered file
|
||||
// reads in the future.
|
||||
Data * data;
|
||||
|
||||
// File extension.
|
||||
std::string ext;
|
||||
|
||||
// When the decoder decodes data incrementally, it writes
|
||||
// this many bytes at a time (at most).
|
||||
int bufferSize;
|
||||
|
||||
// The desired frequency of the samples. 44100, 22050, or 11025.
|
||||
int sampleRate;
|
||||
|
||||
// Holds internal memory.
|
||||
void * buffer;
|
||||
|
||||
// Set this to true when eof has been reached.
|
||||
bool eof;
|
||||
|
||||
public:
|
||||
|
||||
Decoder(Data * data, const std::string & ext, int bufferSize);
|
||||
|
||||
virtual ~Decoder();
|
||||
|
||||
// Implement some of love::sound::Decoder, but allow subclasses
|
||||
// to override them.
|
||||
virtual void * getBuffer() const;
|
||||
virtual int getSize() const;
|
||||
virtual int getSampleRate() const;
|
||||
virtual bool isFinished();
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_LULLABY_DECODER_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_LULLABY_DECODER_H
|
||||
#define LOVE_SOUND_LULLABY_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <sound/Decoder.h>
|
||||
#include <filesystem/File.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
class Decoder : public love::sound::Decoder
|
||||
{
|
||||
protected:
|
||||
|
||||
// The encoded data. This should be replaced with buffered file
|
||||
// reads in the future.
|
||||
Data * data;
|
||||
|
||||
// File extension.
|
||||
std::string ext;
|
||||
|
||||
// When the decoder decodes data incrementally, it writes
|
||||
// this many bytes at a time (at most).
|
||||
int bufferSize;
|
||||
|
||||
// The desired frequency of the samples. 44100, 22050, or 11025.
|
||||
int sampleRate;
|
||||
|
||||
// Holds internal memory.
|
||||
void * buffer;
|
||||
|
||||
// Set this to true when eof has been reached.
|
||||
bool eof;
|
||||
|
||||
public:
|
||||
|
||||
Decoder(Data * data, const std::string & ext, int bufferSize);
|
||||
|
||||
virtual ~Decoder();
|
||||
|
||||
// Implement some of love::sound::Decoder, but allow subclasses
|
||||
// to override them.
|
||||
virtual void * getBuffer() const;
|
||||
virtual int getSize() const;
|
||||
virtual int getSampleRate() const;
|
||||
virtual bool isFinished();
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_LULLABY_DECODER_H
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace lullaby
|
||||
"flac", ""
|
||||
};
|
||||
|
||||
for(int i = 0; !(supported[i].empty()); i++)
|
||||
for (int i = 0; !(supported[i].empty()); i++)
|
||||
{
|
||||
if(supported[i].compare(ext) == 0)
|
||||
if (supported[i].compare(ext) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -40,11 +40,11 @@ namespace lullaby
|
||||
{
|
||||
private:
|
||||
int pos;
|
||||
|
||||
|
||||
public:
|
||||
FLACDecoder(Data * data, const std::string & ext, int bufferSize);
|
||||
~FLACDecoder();
|
||||
|
||||
|
||||
static bool accepts(const std::string &ext);
|
||||
love::sound::Decoder *clone();
|
||||
int decode();
|
||||
@@ -54,7 +54,7 @@ namespace lullaby
|
||||
int getChannels() const;
|
||||
int getBits() const;
|
||||
int getSampleRate() const;
|
||||
|
||||
|
||||
//needed for FLAC
|
||||
FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
|
||||
FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 offset);
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
#include <common/config.h>
|
||||
#include "ModPlugDecoder.h"
|
||||
|
||||
#include <common/Exception.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize)
|
||||
: Decoder(data, ext, bufferSize), plug(0)
|
||||
{
|
||||
|
||||
// Set some ModPlug settings.
|
||||
settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING | MODPLUG_ENABLE_NOISE_REDUCTION;
|
||||
settings.mChannels = 2;
|
||||
settings.mBits = 16;
|
||||
settings.mFrequency = sampleRate;
|
||||
settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
|
||||
|
||||
// fill with modplug defaults (modplug _memsets_, so we could get
|
||||
// garbage settings when the struct is only partially initialized)
|
||||
// This does not exist yet on Windows.
|
||||
settings.mStereoSeparation = 128;
|
||||
settings.mMaxMixChannels = 32;
|
||||
settings.mReverbDepth = 0;
|
||||
settings.mReverbDelay = 0;
|
||||
settings.mBassAmount = 0;
|
||||
settings.mBassRange = 0;
|
||||
settings.mSurroundDepth = 0;
|
||||
settings.mSurroundDelay = 0;
|
||||
settings.mLoopCount = 0;
|
||||
|
||||
ModPlug_SetSettings(&settings);
|
||||
|
||||
// Load the module.
|
||||
plug = ModPlug_Load(data->getData(), data->getSize());
|
||||
|
||||
if(plug == 0)
|
||||
throw love::Exception("Could not load file with ModPlug.");
|
||||
|
||||
// set master volume for delicate ears
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
}
|
||||
|
||||
ModPlugDecoder::~ModPlugDecoder()
|
||||
{
|
||||
if(plug != 0)
|
||||
ModPlug_Unload(plug);
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::accepts(const std::string & ext)
|
||||
{
|
||||
static const std::string supported[] = {
|
||||
"699", "abc", "amf", "ams", "dbm", "dmf",
|
||||
"dsm", "far", "it", "j2b", "mdl", "med",
|
||||
"mid", "mod", "mt2", "mtm", "okt", "pat",
|
||||
"psm", "s3m", "stm", "ult", "umx", "wav",
|
||||
"xm", ""
|
||||
};
|
||||
|
||||
for(int i = 0; !(supported[i].empty()); i++)
|
||||
{
|
||||
if(supported[i].compare(ext) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
love::sound::Decoder * ModPlugDecoder::clone()
|
||||
{
|
||||
return new ModPlugDecoder(data, ext, bufferSize);
|
||||
}
|
||||
|
||||
int ModPlugDecoder::decode()
|
||||
{
|
||||
int r = ModPlug_Read(plug, buffer, bufferSize);
|
||||
|
||||
if(r == 0)
|
||||
eof = true;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::seek(float s)
|
||||
{
|
||||
ModPlug_Seek(plug, (int)(s*1000.0f));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::rewind()
|
||||
{
|
||||
// Let's reload.
|
||||
ModPlug_Unload(plug);
|
||||
plug = ModPlug_Load(data->getData(), data->getSize());
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
eof = false;
|
||||
return (plug != 0);
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::isSeekable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int ModPlugDecoder::getChannels() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int ModPlugDecoder::getBits() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
#include <common/config.h>
|
||||
#include "ModPlugDecoder.h"
|
||||
|
||||
#include <common/Exception.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize)
|
||||
: Decoder(data, ext, bufferSize), plug(0)
|
||||
{
|
||||
|
||||
// Set some ModPlug settings.
|
||||
settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING | MODPLUG_ENABLE_NOISE_REDUCTION;
|
||||
settings.mChannels = 2;
|
||||
settings.mBits = 16;
|
||||
settings.mFrequency = sampleRate;
|
||||
settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
|
||||
|
||||
// fill with modplug defaults (modplug _memsets_, so we could get
|
||||
// garbage settings when the struct is only partially initialized)
|
||||
// This does not exist yet on Windows.
|
||||
settings.mStereoSeparation = 128;
|
||||
settings.mMaxMixChannels = 32;
|
||||
settings.mReverbDepth = 0;
|
||||
settings.mReverbDelay = 0;
|
||||
settings.mBassAmount = 0;
|
||||
settings.mBassRange = 0;
|
||||
settings.mSurroundDepth = 0;
|
||||
settings.mSurroundDelay = 0;
|
||||
settings.mLoopCount = 0;
|
||||
|
||||
ModPlug_SetSettings(&settings);
|
||||
|
||||
// Load the module.
|
||||
plug = ModPlug_Load(data->getData(), data->getSize());
|
||||
|
||||
if (plug == 0)
|
||||
throw love::Exception("Could not load file with ModPlug.");
|
||||
|
||||
// set master volume for delicate ears
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
}
|
||||
|
||||
ModPlugDecoder::~ModPlugDecoder()
|
||||
{
|
||||
if (plug != 0)
|
||||
ModPlug_Unload(plug);
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::accepts(const std::string & ext)
|
||||
{
|
||||
static const std::string supported[] = {
|
||||
"699", "abc", "amf", "ams", "dbm", "dmf",
|
||||
"dsm", "far", "it", "j2b", "mdl", "med",
|
||||
"mid", "mod", "mt2", "mtm", "okt", "pat",
|
||||
"psm", "s3m", "stm", "ult", "umx", "wav",
|
||||
"xm", ""
|
||||
};
|
||||
|
||||
for (int i = 0; !(supported[i].empty()); i++)
|
||||
{
|
||||
if (supported[i].compare(ext) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
love::sound::Decoder * ModPlugDecoder::clone()
|
||||
{
|
||||
return new ModPlugDecoder(data, ext, bufferSize);
|
||||
}
|
||||
|
||||
int ModPlugDecoder::decode()
|
||||
{
|
||||
int r = ModPlug_Read(plug, buffer, bufferSize);
|
||||
|
||||
if (r == 0)
|
||||
eof = true;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::seek(float s)
|
||||
{
|
||||
ModPlug_Seek(plug, (int)(s*1000.0f));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::rewind()
|
||||
{
|
||||
// Let's reload.
|
||||
ModPlug_Unload(plug);
|
||||
plug = ModPlug_Load(data->getData(), data->getSize());
|
||||
ModPlug_SetMasterVolume(plug, 128);
|
||||
eof = false;
|
||||
return (plug != 0);
|
||||
}
|
||||
|
||||
bool ModPlugDecoder::isSeekable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int ModPlugDecoder::getChannels() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int ModPlugDecoder::getBits() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_LULLABY_MODPLUG_DECODER_H
|
||||
#define LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Data.h>
|
||||
#include "Decoder.h"
|
||||
|
||||
// SDL_sound
|
||||
#include <libmodplug/modplug.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
class ModPlugDecoder : public Decoder
|
||||
{
|
||||
private:
|
||||
|
||||
ModPlugFile * plug;
|
||||
ModPlug_Settings settings;
|
||||
|
||||
public:
|
||||
|
||||
ModPlugDecoder(Data * data, const std::string & ext, int bufferSize);
|
||||
virtual ~ModPlugDecoder();
|
||||
|
||||
static bool accepts(const std::string & ext);
|
||||
|
||||
love::sound::Decoder * clone();
|
||||
int decode();
|
||||
bool seek(float s);
|
||||
bool rewind();
|
||||
bool isSeekable();
|
||||
int getChannels() const;
|
||||
int getBits() const;
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_LULLABY_MODPLUG_DECODER_H
|
||||
#define LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Data.h>
|
||||
#include "Decoder.h"
|
||||
|
||||
// SDL_sound
|
||||
#include <libmodplug/modplug.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
namespace lullaby
|
||||
{
|
||||
class ModPlugDecoder : public Decoder
|
||||
{
|
||||
private:
|
||||
|
||||
ModPlugFile * plug;
|
||||
ModPlug_Settings settings;
|
||||
|
||||
public:
|
||||
|
||||
ModPlugDecoder(Data * data, const std::string & ext, int bufferSize);
|
||||
virtual ~ModPlugDecoder();
|
||||
|
||||
static bool accepts(const std::string & ext);
|
||||
|
||||
love::sound::Decoder * clone();
|
||||
int decode();
|
||||
bool seek(float s);
|
||||
bool rewind();
|
||||
bool isSeekable();
|
||||
int getChannels() const;
|
||||
int getBits() const;
|
||||
|
||||
}; // Decoder
|
||||
|
||||
} // lullaby
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace lullaby
|
||||
|
||||
int ret;
|
||||
|
||||
if(!inited)
|
||||
if (!inited)
|
||||
{
|
||||
ret = mpg123_init();
|
||||
if (ret != MPG123_OK)
|
||||
@@ -76,9 +76,9 @@ namespace lullaby
|
||||
"mp3", ""
|
||||
};
|
||||
|
||||
for(int i = 0; !(supported[i].empty()); i++)
|
||||
for (int i = 0; !(supported[i].empty()); i++)
|
||||
{
|
||||
if(supported[i].compare(ext) == 0)
|
||||
if (supported[i].compare(ext) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace lullaby
|
||||
|
||||
void Mpg123Decoder::quit()
|
||||
{
|
||||
if(inited)
|
||||
if (inited)
|
||||
mpg123_exit();
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace lullaby
|
||||
int size = 0;
|
||||
bool done = false;
|
||||
|
||||
while(size < bufferSize && !done && !eof)
|
||||
while (size < bufferSize && !done && !eof)
|
||||
{
|
||||
size_t numbytes = 0;
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace lullaby
|
||||
case MPG123_OK:
|
||||
continue;
|
||||
case MPG123_DONE:
|
||||
if(numbytes == 0)
|
||||
if (numbytes == 0)
|
||||
eof = true;
|
||||
break;
|
||||
default:
|
||||
@@ -166,10 +166,10 @@ namespace lullaby
|
||||
{
|
||||
off_t offset = static_cast<off_t>(s * static_cast<float>(sampleRate));
|
||||
|
||||
if(offset < 0)
|
||||
if (offset < 0)
|
||||
return false;
|
||||
|
||||
if(mpg123_feedseek(handle, offset, SEEK_SET, &offset) >= 0)
|
||||
if (mpg123_feedseek(handle, offset, SEEK_SET, &offset) >= 0)
|
||||
{
|
||||
data_offset = offset;
|
||||
eof = false;
|
||||
@@ -184,7 +184,7 @@ namespace lullaby
|
||||
eof = false;
|
||||
off_t offset;
|
||||
|
||||
if(mpg123_feedseek(handle, 0, SEEK_SET, &offset) >= 0)
|
||||
if (mpg123_feedseek(handle, 0, SEEK_SET, &offset) >= 0)
|
||||
{
|
||||
data_offset = offset;
|
||||
return true;
|
||||
@@ -212,14 +212,14 @@ namespace lullaby
|
||||
{
|
||||
int remaining = data_size - data_offset;
|
||||
|
||||
if(remaining <= 0)
|
||||
if (remaining <= 0)
|
||||
return MPG123_DONE;
|
||||
|
||||
int feed_bytes = remaining < bytes ? remaining : bytes;
|
||||
|
||||
int r = mpg123_feed(handle, (unsigned char*)data->getData() + data_offset, feed_bytes);
|
||||
|
||||
if(r == MPG123_OK || r == MPG123_DONE)
|
||||
if (r == MPG123_OK || r == MPG123_DONE)
|
||||
data_offset += feed_bytes;
|
||||
|
||||
return r;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -49,20 +49,20 @@ namespace lullaby
|
||||
{
|
||||
Data * data = file->read();
|
||||
std::string ext = file->getExtension();
|
||||
|
||||
|
||||
sound::Decoder * decoder = 0;
|
||||
|
||||
// Find a suitable decoder here, and return it.
|
||||
if(ModPlugDecoder::accepts(ext))
|
||||
if (ModPlugDecoder::accepts(ext))
|
||||
decoder = new ModPlugDecoder(data, ext, bufferSize);
|
||||
else if(Mpg123Decoder::accepts(ext))
|
||||
else if (Mpg123Decoder::accepts(ext))
|
||||
decoder = new Mpg123Decoder(data, ext, bufferSize);
|
||||
else if(VorbisDecoder::accepts(ext))
|
||||
else if (VorbisDecoder::accepts(ext))
|
||||
decoder = new VorbisDecoder(data, ext, bufferSize);
|
||||
/*else if (FLACDecoder::accepts(ext))
|
||||
decoder = new FLACDecoder(data, ext, bufferSize);*/
|
||||
|
||||
// else if(OtherDecoder::accept(ext))
|
||||
// else if (OtherDecoder::accept(ext))
|
||||
|
||||
data->release();
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -36,9 +36,9 @@ namespace lullaby
|
||||
/**
|
||||
* The love.sound.lullaby module is the custom sound decoder module for LOVE. Instead
|
||||
* of using an intermediate library like SDL_sound, it interfaces with relevant libraries
|
||||
* directly (libmpg123, libmodplug, libFLAC, etc).
|
||||
*
|
||||
* It was Mike that came up with the name Lullaby, which we both instantly recognized as awesome.
|
||||
* directly (libmpg123, libmodplug, libFLAC, etc).
|
||||
*
|
||||
* It was Mike that came up with the name Lullaby, which we both instantly recognized as awesome.
|
||||
**/
|
||||
class Sound : public love::sound::Sound
|
||||
{
|
||||
@@ -56,7 +56,7 @@ namespace lullaby
|
||||
|
||||
/// @copydoc love::Module::getName
|
||||
const char * getName() const;
|
||||
|
||||
|
||||
/// @copydoc love::sound::Sound::newDecoder
|
||||
sound::Decoder * newDecoder(love::filesystem::File * file, int bufferSize);
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace lullaby
|
||||
oggFile.dataRead = 0;
|
||||
|
||||
// Open Vorbis handle
|
||||
if(ov_open_callbacks(&oggFile, &handle, NULL, 0, vorbisCallbacks) < 0)
|
||||
if (ov_open_callbacks(&oggFile, &handle, NULL, 0, vorbisCallbacks) < 0)
|
||||
throw love::Exception("Could not read Ogg bitstream");
|
||||
|
||||
// Get info and comments
|
||||
@@ -166,9 +166,9 @@ namespace lullaby
|
||||
"ogg", "oga", ""
|
||||
};
|
||||
|
||||
for(int i = 0; !(supported[i].empty()); i++)
|
||||
for (int i = 0; !(supported[i].empty()); i++)
|
||||
{
|
||||
if(supported[i].compare(ext) == 0)
|
||||
if (supported[i].compare(ext) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -184,20 +184,20 @@ namespace lullaby
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
while(size < bufferSize)
|
||||
while (size < bufferSize)
|
||||
{
|
||||
int result = ov_read(&handle, (char*) buffer + size, bufferSize - size, endian, (getBits() == 16 ? 2 : 1), 1, 0);
|
||||
|
||||
if(result == OV_HOLE)
|
||||
if (result == OV_HOLE)
|
||||
continue;
|
||||
else if(result <= OV_EREAD)
|
||||
else if (result <= OV_EREAD)
|
||||
return -1;
|
||||
else if(result == 0)
|
||||
else if (result == 0)
|
||||
{
|
||||
eof = true;
|
||||
break;
|
||||
}
|
||||
else if(result > 0)
|
||||
else if (result > 0)
|
||||
size += result;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace lullaby
|
||||
{
|
||||
int result = ov_time_seek(&handle, s);
|
||||
|
||||
if(result == 0)
|
||||
if (result == 0)
|
||||
{
|
||||
eof = false;
|
||||
return true;
|
||||
@@ -221,7 +221,7 @@ namespace lullaby
|
||||
{
|
||||
int result = ov_pcm_seek(&handle, 0);
|
||||
|
||||
if(result == 0)
|
||||
if (result == 0)
|
||||
{
|
||||
eof = false;
|
||||
return true;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -57,7 +57,7 @@ namespace lullaby
|
||||
|
||||
VorbisDecoder(Data * data, const std::string & ext, int bufferSize);
|
||||
virtual ~VorbisDecoder();
|
||||
|
||||
|
||||
static bool accepts(const std::string & ext);
|
||||
|
||||
love::sound::Decoder * clone();
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
|
||||
}
|
||||
|
||||
int w_Decoder_getChannels(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Decoder_getBits(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Decoder_getSampleRate(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getChannels", w_Decoder_getChannels },
|
||||
{ "getBits", w_Decoder_getBits },
|
||||
{ "getSampleRate", w_Decoder_getSampleRate },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_decoder(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Decoder", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
|
||||
}
|
||||
|
||||
int w_Decoder_getChannels(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Decoder_getBits(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Decoder_getSampleRate(lua_State * L)
|
||||
{
|
||||
Decoder * t = luax_checkdecoder(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getChannels", w_Decoder_getChannels },
|
||||
{ "getBits", w_Decoder_getBits },
|
||||
{ "getSampleRate", w_Decoder_getSampleRate },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_decoder(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Decoder", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_DECODER_H
|
||||
#define LOVE_SOUND_WRAP_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx);
|
||||
int w_Decoder_getChannels(lua_State * L);
|
||||
int w_Decoder_getBits(lua_State * L);
|
||||
int w_Decoder_getSampleRate(lua_State * L);
|
||||
int luaopen_decoder(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_DECODER_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_DECODER_H
|
||||
#define LOVE_SOUND_WRAP_DECODER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
Decoder * luax_checkdecoder(lua_State * L, int idx);
|
||||
int w_Decoder_getChannels(lua_State * L);
|
||||
int w_Decoder_getBits(lua_State * L);
|
||||
int w_Decoder_getSampleRate(lua_State * L);
|
||||
int luaopen_decoder(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_DECODER_H
|
||||
|
||||
+144
-144
@@ -1,144 +1,144 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_Sound.h"
|
||||
|
||||
// Implementations.
|
||||
#include "lullaby/Sound.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
static Sound * instance = 0;
|
||||
|
||||
int w_newSoundData(lua_State * L)
|
||||
{
|
||||
SoundData * t = 0;
|
||||
|
||||
if(lua_isnumber(L, 1))
|
||||
{
|
||||
int samples = luaL_checkint(L, 1);
|
||||
int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
|
||||
int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS);
|
||||
int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS);
|
||||
|
||||
try
|
||||
{
|
||||
t = instance->newSoundData(samples, sampleRate, bits, channels);
|
||||
}
|
||||
catch(love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
}
|
||||
// Must be string or decoder.
|
||||
else
|
||||
{
|
||||
|
||||
// Convert to Decoder, if necessary.
|
||||
if(!luax_istype(L, 1, SOUND_DECODER_T))
|
||||
{
|
||||
w_newDecoder(L);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
t = instance->newSoundData(luax_checkdecoder(L, 1));
|
||||
}
|
||||
catch(love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newDecoder(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
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);
|
||||
|
||||
try
|
||||
{
|
||||
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);
|
||||
}
|
||||
catch(love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "newSoundData", w_newSoundData },
|
||||
{ "newDecoder", w_newDecoder },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_sounddata,
|
||||
luaopen_decoder,
|
||||
0
|
||||
};
|
||||
|
||||
int luaopen_love_sound(lua_State * L)
|
||||
{
|
||||
if(instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new lullaby::Sound();
|
||||
}
|
||||
catch(Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_Sound.h"
|
||||
|
||||
// Implementations.
|
||||
#include "lullaby/Sound.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
static Sound * instance = 0;
|
||||
|
||||
int w_newSoundData(lua_State * L)
|
||||
{
|
||||
SoundData * t = 0;
|
||||
|
||||
if (lua_isnumber(L, 1))
|
||||
{
|
||||
int samples = luaL_checkint(L, 1);
|
||||
int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
|
||||
int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS);
|
||||
int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS);
|
||||
|
||||
try
|
||||
{
|
||||
t = instance->newSoundData(samples, sampleRate, bits, channels);
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
}
|
||||
// Must be string or decoder.
|
||||
else
|
||||
{
|
||||
|
||||
// Convert to Decoder, if necessary.
|
||||
if (!luax_istype(L, 1, SOUND_DECODER_T))
|
||||
{
|
||||
w_newDecoder(L);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
t = instance->newSoundData(luax_checkdecoder(L, 1));
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newDecoder(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
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);
|
||||
|
||||
try
|
||||
{
|
||||
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);
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "newSoundData", w_newSoundData },
|
||||
{ "newDecoder", w_newDecoder },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const lua_CFunction types[] = {
|
||||
luaopen_sounddata,
|
||||
luaopen_decoder,
|
||||
0
|
||||
};
|
||||
|
||||
int luaopen_love_sound(lua_State * L)
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new lullaby::Sound();
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_SOUND_H
|
||||
#define LOVE_SOUND_WRAP_SOUND_H
|
||||
|
||||
// LOVE
|
||||
#include <common/config.h>
|
||||
#include "Sound.h"
|
||||
#include "wrap_SoundData.h"
|
||||
#include "wrap_Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
int w_newSoundData(lua_State * L);
|
||||
int w_newDecoder(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_SOUND_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_SOUND_H
|
||||
#define LOVE_SOUND_WRAP_SOUND_H
|
||||
|
||||
// LOVE
|
||||
#include <common/config.h>
|
||||
#include "Sound.h"
|
||||
#include "wrap_SoundData.h"
|
||||
#include "wrap_Decoder.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
int w_newSoundData(lua_State * L);
|
||||
int w_newDecoder(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_SOUND_H
|
||||
|
||||
@@ -1,92 +1,92 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_SoundData.h"
|
||||
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
|
||||
}
|
||||
|
||||
int w_SoundData_getChannels(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_getBits(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_getSampleRate(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_setSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
float sample = (float)lua_tonumber(L, 3);
|
||||
sd->setSample(i, sample);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_SoundData_getSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
lua_pushnumber(L, sd->getSample(i));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
|
||||
// Data
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
|
||||
{ "getChannels", w_SoundData_getChannels },
|
||||
{ "getBits", w_SoundData_getBits },
|
||||
{ "getSampleRate", w_SoundData_getSampleRate },
|
||||
{ "setSample", w_SoundData_setSample },
|
||||
{ "getSample", w_SoundData_getSample },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_sounddata(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "SoundData", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "wrap_SoundData.h"
|
||||
|
||||
#include <common/wrap_Data.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
|
||||
}
|
||||
|
||||
int w_SoundData_getChannels(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getChannels());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_getBits(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getBits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_getSampleRate(lua_State * L)
|
||||
{
|
||||
SoundData * t = luax_checksounddata(L, 1);
|
||||
lua_pushinteger(L, t->getSampleRate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_SoundData_setSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
float sample = (float)lua_tonumber(L, 3);
|
||||
sd->setSample(i, sample);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_SoundData_getSample(lua_State * L)
|
||||
{
|
||||
SoundData * sd = luax_checksounddata(L, 1);
|
||||
int i = (int)lua_tointeger(L, 2);
|
||||
lua_pushnumber(L, sd->getSample(i));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
|
||||
// Data
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
|
||||
{ "getChannels", w_SoundData_getChannels },
|
||||
{ "getBits", w_SoundData_getBits },
|
||||
{ "getSampleRate", w_SoundData_getSampleRate },
|
||||
{ "setSample", w_SoundData_setSample },
|
||||
{ "getSample", w_SoundData_getSample },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_sounddata(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "SoundData", functions);
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_SOUND_DATA_H
|
||||
#define LOVE_SOUND_WRAP_SOUND_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "SoundData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx);
|
||||
int w_getPointer(lua_State * L);
|
||||
int w_getSize(lua_State * L);
|
||||
int w_getChannels(lua_State * L);
|
||||
int w_getBits(lua_State * L);
|
||||
int w_getSampleRate(lua_State * L);
|
||||
int w_setSample(lua_State * L);
|
||||
int w_getSample(lua_State * L);
|
||||
int luaopen_sounddata(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_SOUND_DATA_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_WRAP_SOUND_DATA_H
|
||||
#define LOVE_SOUND_WRAP_SOUND_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "SoundData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
SoundData * luax_checksounddata(lua_State * L, int idx);
|
||||
int w_getPointer(lua_State * L);
|
||||
int w_getSize(lua_State * L);
|
||||
int w_getChannels(lua_State * L);
|
||||
int w_getBits(lua_State * L);
|
||||
int w_getSampleRate(lua_State * L);
|
||||
int w_setSample(lua_State * L);
|
||||
int w_getSample(lua_State * L);
|
||||
int luaopen_sounddata(lua_State * L);
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
#endif // LOVE_SOUND_WRAP_SOUND_DATA_H
|
||||
|
||||
Reference in New Issue
Block a user