Format taglib sources
This commit is contained in:
332
3rdparty/taglib/xm/xmfile.cpp
vendored
332
3rdparty/taglib/xm/xmfile.cpp
vendored
@@ -64,11 +64,9 @@ using namespace XM;
|
||||
* Maybe if this is useful to other formats these classes can be moved to
|
||||
* their own public files.
|
||||
*/
|
||||
class Reader
|
||||
{
|
||||
public:
|
||||
virtual ~Reader()
|
||||
{
|
||||
class Reader {
|
||||
public:
|
||||
virtual ~Reader() {
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -83,55 +81,45 @@ public:
|
||||
virtual unsigned int size() const = 0;
|
||||
};
|
||||
|
||||
class SkipReader : public Reader
|
||||
{
|
||||
public:
|
||||
explicit SkipReader(unsigned int size) : m_size(size)
|
||||
{
|
||||
class SkipReader : public Reader {
|
||||
public:
|
||||
explicit SkipReader(unsigned int size) : m_size(size) {
|
||||
}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
unsigned int count = std::min(m_size, limit);
|
||||
file.seek(count, Strawberry_TagLib::TagLib::File::Current);
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
unsigned int m_size;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ValueReader : public Reader
|
||||
{
|
||||
public:
|
||||
explicit ValueReader(T &_value) : value(_value)
|
||||
{
|
||||
class ValueReader : public Reader {
|
||||
public:
|
||||
explicit ValueReader(T &_value) : value(_value) {
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
T &value;
|
||||
};
|
||||
|
||||
class StringReader : public ValueReader<String>
|
||||
{
|
||||
public:
|
||||
StringReader(String &string, unsigned int size) :
|
||||
ValueReader<String>(string), m_size(size)
|
||||
{
|
||||
class StringReader : public ValueReader<String> {
|
||||
public:
|
||||
StringReader(String &string, unsigned int size) : ValueReader<String>(string), m_size(size) {
|
||||
}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
ByteVector data = file.readBlock(std::min(m_size, limit));
|
||||
unsigned int count = data.size();
|
||||
int index = data.find((char) 0);
|
||||
if(index > -1) {
|
||||
int index = data.find((char)0);
|
||||
if (index > -1) {
|
||||
data.resize(index);
|
||||
}
|
||||
data.replace('\xff', ' ');
|
||||
@@ -139,101 +127,83 @@ public:
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
unsigned int m_size;
|
||||
};
|
||||
|
||||
class ByteReader : public ValueReader<unsigned char>
|
||||
{
|
||||
public:
|
||||
class ByteReader : public ValueReader<unsigned char> {
|
||||
public:
|
||||
explicit ByteReader(unsigned char &_byte) : ValueReader<unsigned char>(_byte) {}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
ByteVector data = file.readBlock(std::min(1U,limit));
|
||||
if(data.size() > 0) {
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
ByteVector data = file.readBlock(std::min(1U, limit));
|
||||
if (data.size() > 0) {
|
||||
value = data[0];
|
||||
}
|
||||
return data.size();
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class NumberReader : public ValueReader<T>
|
||||
{
|
||||
public:
|
||||
NumberReader(T &_value, bool _bigEndian) :
|
||||
ValueReader<T>(_value), bigEndian(_bigEndian)
|
||||
{
|
||||
class NumberReader : public ValueReader<T> {
|
||||
public:
|
||||
NumberReader(T &_value, bool _bigEndian) : ValueReader<T>(_value), bigEndian(_bigEndian) {
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool bigEndian;
|
||||
};
|
||||
|
||||
class U16Reader : public NumberReader<unsigned short>
|
||||
{
|
||||
public:
|
||||
class U16Reader : public NumberReader<unsigned short> {
|
||||
public:
|
||||
U16Reader(unsigned short &_value, bool _bigEndian)
|
||||
: NumberReader<unsigned short>(_value, _bigEndian) {}
|
||||
: NumberReader<unsigned short>(_value, _bigEndian) {}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
ByteVector data = file.readBlock(std::min(2U,limit));
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
ByteVector data = file.readBlock(std::min(2U, limit));
|
||||
value = data.toUShort(bigEndian);
|
||||
return data.size();
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
class U32Reader : public NumberReader<unsigned long>
|
||||
{
|
||||
public:
|
||||
U32Reader(unsigned long &_value, bool _bigEndian = true) :
|
||||
NumberReader<unsigned long>(_value, _bigEndian)
|
||||
{
|
||||
class U32Reader : public NumberReader<unsigned long> {
|
||||
public:
|
||||
U32Reader(unsigned long &_value, bool _bigEndian = true) : NumberReader<unsigned long>(_value, _bigEndian) {
|
||||
}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
ByteVector data = file.readBlock(std::min(4U,limit));
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
ByteVector data = file.readBlock(std::min(4U, limit));
|
||||
value = data.toUInt(bigEndian);
|
||||
return data.size();
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
class StructReader : public Reader
|
||||
{
|
||||
public:
|
||||
StructReader()
|
||||
{
|
||||
class StructReader : public Reader {
|
||||
public:
|
||||
StructReader() {
|
||||
m_readers.setAutoDelete(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Add a nested reader. This reader takes ownership.
|
||||
*/
|
||||
StructReader &reader(Reader *reader)
|
||||
{
|
||||
StructReader &reader(Reader *reader) {
|
||||
m_readers.append(reader);
|
||||
return *this;
|
||||
}
|
||||
@@ -241,8 +211,7 @@ public:
|
||||
/*!
|
||||
* Don't read anything but skip \a size bytes.
|
||||
*/
|
||||
StructReader &skip(unsigned int size)
|
||||
{
|
||||
StructReader &skip(unsigned int size) {
|
||||
m_readers.append(new SkipReader(size));
|
||||
return *this;
|
||||
}
|
||||
@@ -250,8 +219,7 @@ public:
|
||||
/*!
|
||||
* Read a string of \a size characters (bytes) into \a string.
|
||||
*/
|
||||
StructReader &string(String &string, unsigned int size)
|
||||
{
|
||||
StructReader &string(String &string, unsigned int size) {
|
||||
m_readers.append(new StringReader(string, size));
|
||||
return *this;
|
||||
}
|
||||
@@ -259,8 +227,7 @@ public:
|
||||
/*!
|
||||
* Read a byte into \a byte.
|
||||
*/
|
||||
StructReader &byte(unsigned char &byte)
|
||||
{
|
||||
StructReader &byte(unsigned char &byte) {
|
||||
m_readers.append(new ByteReader(byte));
|
||||
return *this;
|
||||
}
|
||||
@@ -269,8 +236,7 @@ public:
|
||||
* Read a unsigned 16 Bit integer into \a number. The byte order
|
||||
* is controlled by \a bigEndian.
|
||||
*/
|
||||
StructReader &u16(unsigned short &number, bool bigEndian)
|
||||
{
|
||||
StructReader &u16(unsigned short &number, bool bigEndian) {
|
||||
m_readers.append(new U16Reader(number, bigEndian));
|
||||
return *this;
|
||||
}
|
||||
@@ -278,16 +244,14 @@ public:
|
||||
/*!
|
||||
* Read a unsigned 16 Bit little endian integer into \a number.
|
||||
*/
|
||||
StructReader &u16L(unsigned short &number)
|
||||
{
|
||||
StructReader &u16L(unsigned short &number) {
|
||||
return u16(number, false);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Read a unsigned 16 Bit big endian integer into \a number.
|
||||
*/
|
||||
StructReader &u16B(unsigned short &number)
|
||||
{
|
||||
StructReader &u16B(unsigned short &number) {
|
||||
return u16(number, true);
|
||||
}
|
||||
|
||||
@@ -295,8 +259,7 @@ public:
|
||||
* Read a unsigned 32 Bit integer into \a number. The byte order
|
||||
* is controlled by \a bigEndian.
|
||||
*/
|
||||
StructReader &u32(unsigned long &number, bool bigEndian)
|
||||
{
|
||||
StructReader &u32(unsigned long &number, bool bigEndian) {
|
||||
m_readers.append(new U32Reader(number, bigEndian));
|
||||
return *this;
|
||||
}
|
||||
@@ -304,103 +267,89 @@ public:
|
||||
/*!
|
||||
* Read a unsigned 32 Bit little endian integer into \a number.
|
||||
*/
|
||||
StructReader &u32L(unsigned long &number)
|
||||
{
|
||||
StructReader &u32L(unsigned long &number) {
|
||||
return u32(number, false);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Read a unsigned 32 Bit big endian integer into \a number.
|
||||
*/
|
||||
StructReader &u32B(unsigned long &number)
|
||||
{
|
||||
StructReader &u32B(unsigned long &number) {
|
||||
return u32(number, true);
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
{
|
||||
unsigned int size() const {
|
||||
unsigned int size = 0;
|
||||
for(List<Reader*>::ConstIterator i = m_readers.begin();
|
||||
i != m_readers.end(); ++ i) {
|
||||
for (List<Reader *>::ConstIterator i = m_readers.begin();
|
||||
i != m_readers.end();
|
||||
++i) {
|
||||
size += (*i)->size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit)
|
||||
{
|
||||
unsigned int read(Strawberry_TagLib::TagLib::File &file, unsigned int limit) {
|
||||
unsigned int sumcount = 0;
|
||||
for(List<Reader*>::ConstIterator i = m_readers.begin();
|
||||
limit > 0 && i != m_readers.end(); ++ i) {
|
||||
for (List<Reader *>::ConstIterator i = m_readers.begin();
|
||||
limit > 0 && i != m_readers.end();
|
||||
++i) {
|
||||
unsigned int count = (*i)->read(file, limit);
|
||||
limit -= count;
|
||||
limit -= count;
|
||||
sumcount += count;
|
||||
}
|
||||
return sumcount;
|
||||
}
|
||||
|
||||
private:
|
||||
List<Reader*> m_readers;
|
||||
private:
|
||||
List<Reader *> m_readers;
|
||||
};
|
||||
|
||||
class XM::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
class XM::File::FilePrivate {
|
||||
public:
|
||||
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle)
|
||||
: tag(), properties(propertiesStyle)
|
||||
{
|
||||
: tag(), properties(propertiesStyle) {
|
||||
}
|
||||
|
||||
Mod::Tag tag;
|
||||
Mod::Tag tag;
|
||||
XM::Properties properties;
|
||||
};
|
||||
|
||||
XM::File::File(FileName file, bool readProperties,
|
||||
AudioProperties::ReadStyle propertiesStyle) :
|
||||
Mod::FileBase(file),
|
||||
d(new FilePrivate(propertiesStyle))
|
||||
{
|
||||
if(isOpen())
|
||||
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file),
|
||||
d(new FilePrivate(propertiesStyle)) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
XM::File::File(IOStream *stream, bool readProperties,
|
||||
AudioProperties::ReadStyle propertiesStyle) :
|
||||
Mod::FileBase(stream),
|
||||
d(new FilePrivate(propertiesStyle))
|
||||
{
|
||||
if(isOpen())
|
||||
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream),
|
||||
d(new FilePrivate(propertiesStyle)) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
XM::File::~File()
|
||||
{
|
||||
XM::File::~File() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
Mod::Tag *XM::File::tag() const
|
||||
{
|
||||
Mod::Tag *XM::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
PropertyMap XM::File::properties() const
|
||||
{
|
||||
PropertyMap XM::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
PropertyMap XM::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
PropertyMap XM::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag.setProperties(properties);
|
||||
}
|
||||
|
||||
XM::Properties *XM::File::audioProperties() const
|
||||
{
|
||||
XM::Properties *XM::File::audioProperties() const {
|
||||
return &d->properties;
|
||||
}
|
||||
|
||||
bool XM::File::save()
|
||||
{
|
||||
if(readOnly()) {
|
||||
bool XM::File::save() {
|
||||
if (readOnly()) {
|
||||
debug("XM::File::save() - Cannot save to a read only file.");
|
||||
return false;
|
||||
}
|
||||
@@ -413,22 +362,22 @@ bool XM::File::save()
|
||||
|
||||
seek(60);
|
||||
unsigned long headerSize = 0;
|
||||
if(!readU32L(headerSize))
|
||||
if (!readU32L(headerSize))
|
||||
return false;
|
||||
|
||||
seek(70);
|
||||
unsigned short patternCount = 0;
|
||||
unsigned short instrumentCount = 0;
|
||||
if(!readU16L(patternCount) || !readU16L(instrumentCount))
|
||||
if (!readU16L(patternCount) || !readU16L(instrumentCount))
|
||||
return false;
|
||||
|
||||
long pos = 60 + headerSize; // should be long long in taglib2.
|
||||
long pos = 60 + headerSize; // should be long long in taglib2.
|
||||
|
||||
// need to read patterns again in order to seek to the instruments:
|
||||
for(unsigned short i = 0; i < patternCount; ++ i) {
|
||||
for (unsigned short i = 0; i < patternCount; ++i) {
|
||||
seek(pos);
|
||||
unsigned long patternHeaderLength = 0;
|
||||
if(!readU32L(patternHeaderLength) || patternHeaderLength < 4)
|
||||
if (!readU32L(patternHeaderLength) || patternHeaderLength < 4)
|
||||
return false;
|
||||
|
||||
seek(pos + 7);
|
||||
@@ -441,49 +390,49 @@ bool XM::File::save()
|
||||
|
||||
const StringList lines = d->tag.comment().split("\n");
|
||||
unsigned int sampleNameIndex = instrumentCount;
|
||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
||||
for (unsigned short i = 0; i < instrumentCount; ++i) {
|
||||
seek(pos);
|
||||
unsigned long instrumentHeaderSize = 0;
|
||||
if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4)
|
||||
if (!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4)
|
||||
return false;
|
||||
|
||||
seek(pos + 4);
|
||||
const unsigned int len = std::min(22UL, instrumentHeaderSize - 4U);
|
||||
if(i >= lines.size())
|
||||
if (i >= lines.size())
|
||||
writeString(String(), len);
|
||||
else
|
||||
writeString(lines[i], len);
|
||||
|
||||
unsigned short sampleCount = 0;
|
||||
if(instrumentHeaderSize >= 29U) {
|
||||
if (instrumentHeaderSize >= 29U) {
|
||||
seek(pos + 27);
|
||||
if(!readU16L(sampleCount))
|
||||
if (!readU16L(sampleCount))
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long sampleHeaderSize = 0;
|
||||
if(sampleCount > 0) {
|
||||
if (sampleCount > 0) {
|
||||
seek(pos + 29);
|
||||
if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize))
|
||||
if (instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize))
|
||||
return false;
|
||||
}
|
||||
|
||||
pos += instrumentHeaderSize;
|
||||
|
||||
for(unsigned short j = 0; j < sampleCount; ++ j) {
|
||||
if(sampleHeaderSize > 4U) {
|
||||
for (unsigned short j = 0; j < sampleCount; ++j) {
|
||||
if (sampleHeaderSize > 4U) {
|
||||
seek(pos);
|
||||
unsigned long sampleLength = 0;
|
||||
if(!readU32L(sampleLength))
|
||||
if (!readU32L(sampleLength))
|
||||
return false;
|
||||
|
||||
if(sampleHeaderSize > 18U) {
|
||||
if (sampleHeaderSize > 18U) {
|
||||
seek(pos + 18);
|
||||
const unsigned int len2 = std::min(sampleHeaderSize - 18U, 22UL);
|
||||
if(sampleNameIndex >= lines.size())
|
||||
if (sampleNameIndex >= lines.size())
|
||||
writeString(String(), len2);
|
||||
else
|
||||
writeString(lines[sampleNameIndex ++], len2);
|
||||
writeString(lines[sampleNameIndex++], len2);
|
||||
}
|
||||
}
|
||||
pos += sampleHeaderSize;
|
||||
@@ -493,9 +442,8 @@ bool XM::File::save()
|
||||
return true;
|
||||
}
|
||||
|
||||
void XM::File::read(bool)
|
||||
{
|
||||
if(!isOpen())
|
||||
void XM::File::read(bool) {
|
||||
if (!isOpen())
|
||||
return;
|
||||
|
||||
seek(0);
|
||||
@@ -514,24 +462,24 @@ void XM::File::read(bool)
|
||||
READ_U32L_AS(headerSize);
|
||||
READ_ASSERT(headerSize >= 4);
|
||||
|
||||
unsigned short length = 0;
|
||||
unsigned short length = 0;
|
||||
unsigned short restartPosition = 0;
|
||||
unsigned short channels = 0;
|
||||
unsigned short patternCount = 0;
|
||||
unsigned short channels = 0;
|
||||
unsigned short patternCount = 0;
|
||||
unsigned short instrumentCount = 0;
|
||||
unsigned short flags = 0;
|
||||
unsigned short tempo = 0;
|
||||
unsigned short flags = 0;
|
||||
unsigned short tempo = 0;
|
||||
unsigned short bpmSpeed = 0;
|
||||
|
||||
StructReader header;
|
||||
header.u16L(length)
|
||||
.u16L(restartPosition)
|
||||
.u16L(channels)
|
||||
.u16L(patternCount)
|
||||
.u16L(instrumentCount)
|
||||
.u16L(flags)
|
||||
.u16L(tempo)
|
||||
.u16L(bpmSpeed);
|
||||
.u16L(restartPosition)
|
||||
.u16L(channels)
|
||||
.u16L(patternCount)
|
||||
.u16L(instrumentCount)
|
||||
.u16L(flags)
|
||||
.u16L(tempo)
|
||||
.u16L(bpmSpeed);
|
||||
|
||||
unsigned int count = header.read(*this, headerSize - 4U);
|
||||
unsigned int size = std::min(headerSize - 4U, (unsigned long)header.size());
|
||||
@@ -550,11 +498,11 @@ void XM::File::read(bool)
|
||||
seek(60 + headerSize);
|
||||
|
||||
// read patterns:
|
||||
for(unsigned short i = 0; i < patternCount; ++ i) {
|
||||
for (unsigned short i = 0; i < patternCount; ++i) {
|
||||
READ_U32L_AS(patternHeaderLength);
|
||||
READ_ASSERT(patternHeaderLength >= 4);
|
||||
|
||||
unsigned char packingType = 0;
|
||||
unsigned char packingType = 0;
|
||||
unsigned short rowCount = 0;
|
||||
unsigned short dataSize = 0;
|
||||
StructReader pattern;
|
||||
@@ -571,12 +519,12 @@ void XM::File::read(bool)
|
||||
unsigned int sumSampleCount = 0;
|
||||
|
||||
// read instruments:
|
||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
||||
for (unsigned short i = 0; i < instrumentCount; ++i) {
|
||||
READ_U32L_AS(instrumentHeaderSize);
|
||||
READ_ASSERT(instrumentHeaderSize >= 4);
|
||||
|
||||
String instrumentName;
|
||||
unsigned char instrumentType = 0;
|
||||
unsigned char instrumentType = 0;
|
||||
unsigned short sampleCount = 0;
|
||||
|
||||
StructReader instrument;
|
||||
@@ -587,7 +535,7 @@ void XM::File::read(bool)
|
||||
READ_ASSERT(count2 == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4));
|
||||
|
||||
long offset = 0;
|
||||
if(sampleCount > 0) {
|
||||
if (sampleCount > 0) {
|
||||
unsigned long sampleHeaderSize = 0;
|
||||
sumSampleCount += sampleCount;
|
||||
// wouldn't know which header size to assume otherwise:
|
||||
@@ -595,28 +543,28 @@ void XM::File::read(bool)
|
||||
// skip unhandled header proportion:
|
||||
seek(instrumentHeaderSize - count2 - 4, Current);
|
||||
|
||||
for(unsigned short j = 0; j < sampleCount; ++ j) {
|
||||
for (unsigned short j = 0; j < sampleCount; ++j) {
|
||||
unsigned long sampleLength = 0;
|
||||
unsigned long loopStart = 0;
|
||||
unsigned long loopLength = 0;
|
||||
unsigned char volume = 0;
|
||||
unsigned char finetune = 0;
|
||||
unsigned char sampleType = 0;
|
||||
unsigned char panning = 0;
|
||||
unsigned char noteNumber = 0;
|
||||
unsigned char compression = 0;
|
||||
unsigned long loopStart = 0;
|
||||
unsigned long loopLength = 0;
|
||||
unsigned char volume = 0;
|
||||
unsigned char finetune = 0;
|
||||
unsigned char sampleType = 0;
|
||||
unsigned char panning = 0;
|
||||
unsigned char noteNumber = 0;
|
||||
unsigned char compression = 0;
|
||||
String sampleName;
|
||||
StructReader sample;
|
||||
sample.u32L(sampleLength)
|
||||
.u32L(loopStart)
|
||||
.u32L(loopLength)
|
||||
.byte(volume)
|
||||
.byte(finetune)
|
||||
.byte(sampleType)
|
||||
.byte(panning)
|
||||
.byte(noteNumber)
|
||||
.byte(compression)
|
||||
.string(sampleName, 22);
|
||||
.u32L(loopStart)
|
||||
.u32L(loopLength)
|
||||
.byte(volume)
|
||||
.byte(finetune)
|
||||
.byte(sampleType)
|
||||
.byte(panning)
|
||||
.byte(noteNumber)
|
||||
.byte(compression)
|
||||
.string(sampleName, 22);
|
||||
|
||||
unsigned int count3 = sample.read(*this, sampleHeaderSize);
|
||||
READ_ASSERT(count3 == std::min(sampleHeaderSize, (unsigned long)sample.size()));
|
||||
@@ -636,7 +584,7 @@ void XM::File::read(bool)
|
||||
|
||||
d->properties.setSampleCount(sumSampleCount);
|
||||
String comment(intrumentNames.toString("\n"));
|
||||
if(!sampleNames.isEmpty()) {
|
||||
if (!sampleNames.isEmpty()) {
|
||||
comment += "\n";
|
||||
comment += sampleNames.toString("\n");
|
||||
}
|
||||
|
||||
64
3rdparty/taglib/xm/xmfile.h
vendored
64
3rdparty/taglib/xm/xmfile.h
vendored
@@ -36,22 +36,22 @@
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
|
||||
namespace XM {
|
||||
namespace XM {
|
||||
|
||||
class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||
public:
|
||||
/*!
|
||||
class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||
public:
|
||||
/*!
|
||||
* Constructs an Extended Module file from \a file.
|
||||
*
|
||||
* \note In the current implementation, both \a readProperties and
|
||||
* \a propertiesStyle are ignored. The audio properties are always
|
||||
* read.
|
||||
*/
|
||||
File(FileName file, bool readProperties = true,
|
||||
AudioProperties::ReadStyle propertiesStyle =
|
||||
AudioProperties::Average);
|
||||
File(FileName file, bool readProperties = true,
|
||||
AudioProperties::ReadStyle propertiesStyle =
|
||||
AudioProperties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Constructs an Extended Module file from \a stream.
|
||||
*
|
||||
* \note In the current implementation, both \a readProperties and
|
||||
@@ -61,54 +61,54 @@ namespace TagLib {
|
||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||
* responsible for deleting it after the File object.
|
||||
*/
|
||||
File(IOStream *stream, bool readProperties = true,
|
||||
AudioProperties::ReadStyle propertiesStyle =
|
||||
AudioProperties::Average);
|
||||
File(IOStream *stream, bool readProperties = true,
|
||||
AudioProperties::ReadStyle propertiesStyle =
|
||||
AudioProperties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
virtual ~File();
|
||||
|
||||
Mod::Tag *tag() const;
|
||||
Mod::Tag *tag() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* Forwards to Mod::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Forwards to Mod::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the XM::Properties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
*/
|
||||
XM::Properties *audioProperties() const;
|
||||
XM::Properties *audioProperties() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Save the file.
|
||||
* This is the same as calling save(AllTags);
|
||||
*
|
||||
* \note Saving Extended Module tags is not supported.
|
||||
*/
|
||||
bool save();
|
||||
bool save();
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void read(bool readProperties);
|
||||
void read(bool readProperties);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
};
|
||||
} // namespace XM
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
#endif
|
||||
|
||||
115
3rdparty/taglib/xm/xmproperties.cpp
vendored
115
3rdparty/taglib/xm/xmproperties.cpp
vendored
@@ -29,167 +29,136 @@
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace XM;
|
||||
|
||||
class XM::Properties::PropertiesPrivate
|
||||
{
|
||||
public:
|
||||
PropertiesPrivate() :
|
||||
lengthInPatterns(0),
|
||||
channels(0),
|
||||
version(0),
|
||||
restartPosition(0),
|
||||
patternCount(0),
|
||||
instrumentCount(0),
|
||||
sampleCount(0),
|
||||
flags(0),
|
||||
tempo(0),
|
||||
bpmSpeed(0)
|
||||
{
|
||||
class XM::Properties::PropertiesPrivate {
|
||||
public:
|
||||
PropertiesPrivate() : lengthInPatterns(0),
|
||||
channels(0),
|
||||
version(0),
|
||||
restartPosition(0),
|
||||
patternCount(0),
|
||||
instrumentCount(0),
|
||||
sampleCount(0),
|
||||
flags(0),
|
||||
tempo(0),
|
||||
bpmSpeed(0) {
|
||||
}
|
||||
|
||||
unsigned short lengthInPatterns;
|
||||
int channels;
|
||||
int channels;
|
||||
unsigned short version;
|
||||
unsigned short restartPosition;
|
||||
unsigned short patternCount;
|
||||
unsigned short instrumentCount;
|
||||
unsigned int sampleCount;
|
||||
unsigned int sampleCount;
|
||||
unsigned short flags;
|
||||
unsigned short tempo;
|
||||
unsigned short bpmSpeed;
|
||||
};
|
||||
|
||||
XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
|
||||
AudioProperties(propertiesStyle),
|
||||
d(new PropertiesPrivate())
|
||||
{
|
||||
XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle),
|
||||
d(new PropertiesPrivate()) {
|
||||
}
|
||||
|
||||
XM::Properties::~Properties()
|
||||
{
|
||||
XM::Properties::~Properties() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
int XM::Properties::length() const
|
||||
{
|
||||
int XM::Properties::length() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XM::Properties::lengthInSeconds() const
|
||||
{
|
||||
int XM::Properties::lengthInSeconds() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XM::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
int XM::Properties::lengthInMilliseconds() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XM::Properties::bitrate() const
|
||||
{
|
||||
int XM::Properties::bitrate() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XM::Properties::sampleRate() const
|
||||
{
|
||||
int XM::Properties::sampleRate() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XM::Properties::channels() const
|
||||
{
|
||||
int XM::Properties::channels() const {
|
||||
return d->channels;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::lengthInPatterns() const
|
||||
{
|
||||
unsigned short XM::Properties::lengthInPatterns() const {
|
||||
return d->lengthInPatterns;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::version() const
|
||||
{
|
||||
unsigned short XM::Properties::version() const {
|
||||
return d->version;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::restartPosition() const
|
||||
{
|
||||
unsigned short XM::Properties::restartPosition() const {
|
||||
return d->restartPosition;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::patternCount() const
|
||||
{
|
||||
unsigned short XM::Properties::patternCount() const {
|
||||
return d->patternCount;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::instrumentCount() const
|
||||
{
|
||||
unsigned short XM::Properties::instrumentCount() const {
|
||||
return d->instrumentCount;
|
||||
}
|
||||
|
||||
unsigned int XM::Properties::sampleCount() const
|
||||
{
|
||||
unsigned int XM::Properties::sampleCount() const {
|
||||
return d->sampleCount;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::flags() const
|
||||
{
|
||||
unsigned short XM::Properties::flags() const {
|
||||
return d->flags;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::tempo() const
|
||||
{
|
||||
unsigned short XM::Properties::tempo() const {
|
||||
return d->tempo;
|
||||
}
|
||||
|
||||
unsigned short XM::Properties::bpmSpeed() const
|
||||
{
|
||||
unsigned short XM::Properties::bpmSpeed() const {
|
||||
return d->bpmSpeed;
|
||||
}
|
||||
|
||||
void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns)
|
||||
{
|
||||
void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns) {
|
||||
d->lengthInPatterns = lengthInPatterns;
|
||||
}
|
||||
|
||||
void XM::Properties::setChannels(int channels)
|
||||
{
|
||||
void XM::Properties::setChannels(int channels) {
|
||||
d->channels = channels;
|
||||
}
|
||||
|
||||
void XM::Properties::setVersion(unsigned short version)
|
||||
{
|
||||
void XM::Properties::setVersion(unsigned short version) {
|
||||
d->version = version;
|
||||
}
|
||||
|
||||
void XM::Properties::setRestartPosition(unsigned short restartPosition)
|
||||
{
|
||||
void XM::Properties::setRestartPosition(unsigned short restartPosition) {
|
||||
d->restartPosition = restartPosition;
|
||||
}
|
||||
|
||||
void XM::Properties::setPatternCount(unsigned short patternCount)
|
||||
{
|
||||
void XM::Properties::setPatternCount(unsigned short patternCount) {
|
||||
d->patternCount = patternCount;
|
||||
}
|
||||
|
||||
void XM::Properties::setInstrumentCount(unsigned short instrumentCount)
|
||||
{
|
||||
void XM::Properties::setInstrumentCount(unsigned short instrumentCount) {
|
||||
d->instrumentCount = instrumentCount;
|
||||
}
|
||||
|
||||
void XM::Properties::setSampleCount(unsigned int sampleCount)
|
||||
{
|
||||
void XM::Properties::setSampleCount(unsigned int sampleCount) {
|
||||
d->sampleCount = sampleCount;
|
||||
}
|
||||
|
||||
void XM::Properties::setFlags(unsigned short flags)
|
||||
{
|
||||
void XM::Properties::setFlags(unsigned short flags) {
|
||||
d->flags = flags;
|
||||
}
|
||||
|
||||
void XM::Properties::setTempo(unsigned short tempo)
|
||||
{
|
||||
void XM::Properties::setTempo(unsigned short tempo) {
|
||||
d->tempo = tempo;
|
||||
}
|
||||
|
||||
void XM::Properties::setBpmSpeed(unsigned short bpmSpeed)
|
||||
{
|
||||
void XM::Properties::setBpmSpeed(unsigned short bpmSpeed) {
|
||||
d->bpmSpeed = bpmSpeed;
|
||||
}
|
||||
|
||||
89
3rdparty/taglib/xm/xmproperties.h
vendored
89
3rdparty/taglib/xm/xmproperties.h
vendored
@@ -32,56 +32,57 @@
|
||||
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
namespace XM {
|
||||
class TAGLIB_EXPORT Properties : public AudioProperties {
|
||||
friend class File;
|
||||
public:
|
||||
/*! Flag bits. */
|
||||
enum {
|
||||
LinearFreqTable = 1 // otherwise its the amiga freq. table
|
||||
};
|
||||
namespace XM {
|
||||
class TAGLIB_EXPORT Properties : public AudioProperties {
|
||||
friend class File;
|
||||
|
||||
Properties(AudioProperties::ReadStyle propertiesStyle);
|
||||
virtual ~Properties();
|
||||
public:
|
||||
/*! Flag bits. */
|
||||
enum {
|
||||
LinearFreqTable = 1 // otherwise its the amiga freq. table
|
||||
};
|
||||
|
||||
int length() const;
|
||||
int lengthInSeconds() const;
|
||||
int lengthInMilliseconds() const;
|
||||
int bitrate() const;
|
||||
int sampleRate() const;
|
||||
int channels() const;
|
||||
Properties(AudioProperties::ReadStyle propertiesStyle);
|
||||
virtual ~Properties();
|
||||
|
||||
unsigned short lengthInPatterns() const;
|
||||
unsigned short version() const;
|
||||
unsigned short restartPosition() const;
|
||||
unsigned short patternCount() const;
|
||||
unsigned short instrumentCount() const;
|
||||
unsigned int sampleCount() const;
|
||||
unsigned short flags() const;
|
||||
unsigned short tempo() const;
|
||||
unsigned short bpmSpeed() const;
|
||||
int length() const;
|
||||
int lengthInSeconds() const;
|
||||
int lengthInMilliseconds() const;
|
||||
int bitrate() const;
|
||||
int sampleRate() const;
|
||||
int channels() const;
|
||||
|
||||
void setChannels(int channels);
|
||||
unsigned short lengthInPatterns() const;
|
||||
unsigned short version() const;
|
||||
unsigned short restartPosition() const;
|
||||
unsigned short patternCount() const;
|
||||
unsigned short instrumentCount() const;
|
||||
unsigned int sampleCount() const;
|
||||
unsigned short flags() const;
|
||||
unsigned short tempo() const;
|
||||
unsigned short bpmSpeed() const;
|
||||
|
||||
void setLengthInPatterns(unsigned short lengthInPatterns);
|
||||
void setVersion(unsigned short version);
|
||||
void setRestartPosition(unsigned short restartPosition);
|
||||
void setPatternCount(unsigned short patternCount);
|
||||
void setInstrumentCount(unsigned short instrumentCount);
|
||||
void setSampleCount(unsigned int sampleCount);
|
||||
void setFlags(unsigned short flags);
|
||||
void setTempo(unsigned short tempo);
|
||||
void setBpmSpeed(unsigned short bpmSpeed);
|
||||
void setChannels(int channels);
|
||||
|
||||
private:
|
||||
Properties(const Properties&);
|
||||
Properties &operator=(const Properties&);
|
||||
void setLengthInPatterns(unsigned short lengthInPatterns);
|
||||
void setVersion(unsigned short version);
|
||||
void setRestartPosition(unsigned short restartPosition);
|
||||
void setPatternCount(unsigned short patternCount);
|
||||
void setInstrumentCount(unsigned short instrumentCount);
|
||||
void setSampleCount(unsigned int sampleCount);
|
||||
void setFlags(unsigned short flags);
|
||||
void setTempo(unsigned short tempo);
|
||||
void setBpmSpeed(unsigned short bpmSpeed);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
Properties(const Properties &);
|
||||
Properties &operator=(const Properties &);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
};
|
||||
} // namespace XM
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user