converted tabs to spaces

This commit is contained in:
Mathias Panzenböck
2011-06-14 01:09:55 +02:00
parent f6dbd32ed3
commit 54e9656474
20 changed files with 844 additions and 842 deletions

View File

@ -31,34 +31,34 @@ using namespace XM;
class XM::File::FilePrivate
{
public:
FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: tag(), properties(propertiesStyle)
{
}
FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: tag(), properties(propertiesStyle)
{
}
XM::Tag tag;
XM::Properties properties;
XM::Tag tag;
XM::Properties properties;
};
XM::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) :
Mod::File(file),
d(new FilePrivate(propertiesStyle))
d(new FilePrivate(propertiesStyle))
{
read(readProperties);
read(readProperties);
}
XM::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) :
Mod::File(stream),
d(new FilePrivate(propertiesStyle))
d(new FilePrivate(propertiesStyle))
{
read(readProperties);
read(readProperties);
}
XM::File::~File()
{
delete d;
delete d;
}
XM::Tag *XM::File::tag() const
@ -73,123 +73,123 @@ XM::Properties *XM::File::audioProperties() const
bool XM::File::save()
{
seek(17);
writeString(d->tag.title(), 20);
seek(1, Current);
writeString(d->tag.trackerName(), 20);
// TODO: write comment as instrument and sample names
seek(17);
writeString(d->tag.title(), 20);
seek(1, Current);
writeString(d->tag.trackerName(), 20);
// TODO: write comment as instrument and sample names
return true;
}
void XM::File::read(bool)
{
if(!isOpen())
return;
if(!isOpen())
return;
READ_ASSERT(readBlock(17) == "Extended Module: ");
READ_ASSERT(readBlock(17) == "Extended Module: ");
READ_STRING(d->tag.setTitle, 20);
READ_BYTE_AS(mark);
READ_ASSERT(mark == 0x1A);
READ_STRING(d->tag.setTrackerName, 20);
READ_U16L(d->properties.setVersion);
READ_U32L_AS(headerSize);
READ_U16L(d->properties.setSampleLength);
READ_U16L(d->properties.setRestartPosition);
READ_U16L(d->properties.setChannels);
READ_U16L_AS(patternCount);
d->properties.setPatternCount(patternCount);
READ_U16L_AS(instrumentCount);
d->properties.setInstrumentCount(instrumentCount);
READ_U16L(d->properties.setFlags);
READ_U16L(d->properties.setTempo);
READ_U16L(d->properties.setBpmSpeed);
READ_STRING(d->tag.setTitle, 20);
READ_BYTE_AS(mark);
READ_ASSERT(mark == 0x1A);
READ_STRING(d->tag.setTrackerName, 20);
READ_U16L(d->properties.setVersion);
READ_U32L_AS(headerSize);
READ_U16L(d->properties.setSampleLength);
READ_U16L(d->properties.setRestartPosition);
READ_U16L(d->properties.setChannels);
READ_U16L_AS(patternCount);
d->properties.setPatternCount(patternCount);
READ_U16L_AS(instrumentCount);
d->properties.setInstrumentCount(instrumentCount);
READ_U16L(d->properties.setFlags);
READ_U16L(d->properties.setTempo);
READ_U16L(d->properties.setBpmSpeed);
seek(60 + headerSize);
for(ushort i = 0; i < patternCount; ++ i)
{
READ_U32L_AS(patternHeaderLength);
READ_BYTE_AS(patternType);
READ_U16L_AS(rowCount);
READ_U16L_AS(patternDataSize);
seek(60 + headerSize);
for(ushort i = 0; i < patternCount; ++ i)
{
READ_U32L_AS(patternHeaderLength);
READ_BYTE_AS(patternType);
READ_U16L_AS(rowCount);
READ_U16L_AS(patternDataSize);
seek(patternHeaderLength - (4+1+2+2) + patternDataSize, Current);
}
StringList intrumentNames;
StringList sampleNames;
for(ushort i = 0; i < instrumentCount; ++ i)
{
long pos = tell();
READ_U32L_AS(instrumentSize);
seek(patternHeaderLength - (4+1+2+2) + patternDataSize, Current);
}
StringList intrumentNames;
StringList sampleNames;
for(ushort i = 0; i < instrumentCount; ++ i)
{
long pos = tell();
READ_U32L_AS(instrumentSize);
String instrumentName;
uchar instrumentType = 0;
ushort sampleCount = 0;
if(instrumentSize > 4)
{
if(!readString(instrumentName, std::min(22UL, instrumentSize-4)))
{
setValid(false);
return;
}
String instrumentName;
uchar instrumentType = 0;
ushort sampleCount = 0;
if(instrumentSize > 4)
{
if(!readString(instrumentName, std::min(22UL, instrumentSize-4)))
{
setValid(false);
return;
}
if(instrumentSize >= (4+22+1))
{
if(!readByte(instrumentType))
{
setValid(false);
return;
}
if(instrumentSize >= (4+22+1))
{
if(!readByte(instrumentType))
{
setValid(false);
return;
}
if (instrumentSize >= (4+22+1+2))
{
if(!readU16L(sampleCount))
{
setValid(false);
return;
}
}
}
}
if (instrumentSize >= (4+22+1+2))
{
if(!readU16L(sampleCount))
{
setValid(false);
return;
}
}
}
}
ulong sumSampleLength = 0;
ulong sampleHeaderSize = 0;
if (sampleCount > 0)
{
if(!readU32L(sampleHeaderSize))
{
setValid(false);
return;
}
ulong sumSampleLength = 0;
ulong sampleHeaderSize = 0;
if (sampleCount > 0)
{
if(!readU32L(sampleHeaderSize))
{
setValid(false);
return;
}
seek(pos + instrumentSize);
seek(pos + instrumentSize);
long sampleheaderPos = tell();
for (ushort j = 0; j < sampleCount; ++ j)
{
seek(sampleheaderPos + sampleHeaderSize * j);
READ_U32L_AS(length);
READ_U32L_AS(loopStart);
READ_U32L_AS(loopLength);
READ_BYTE_AS(volume);
READ_BYTE_AS(finetune);
READ_BYTE_AS(sampleType);
READ_BYTE_AS(panning);
READ_BYTE_AS(noteNumber);
READ_BYTE_AS(compression);
READ_STRING_AS(sampleName, 22);
sumSampleLength += length;
sampleNames.append(sampleName);
}
}
intrumentNames.append(instrumentName);
seek(pos + instrumentSize + sampleHeaderSize * sampleCount + sumSampleLength);
}
long sampleheaderPos = tell();
for (ushort j = 0; j < sampleCount; ++ j)
{
seek(sampleheaderPos + sampleHeaderSize * j);
READ_U32L_AS(length);
READ_U32L_AS(loopStart);
READ_U32L_AS(loopLength);
READ_BYTE_AS(volume);
READ_BYTE_AS(finetune);
READ_BYTE_AS(sampleType);
READ_BYTE_AS(panning);
READ_BYTE_AS(noteNumber);
READ_BYTE_AS(compression);
READ_STRING_AS(sampleName, 22);
sumSampleLength += length;
sampleNames.append(sampleName);
}
}
intrumentNames.append(instrumentName);
seek(pos + instrumentSize + sampleHeaderSize * sampleCount + sumSampleLength);
}
d->tag.setComment(intrumentNames.toString("\n") + "\n" + sampleNames.toString("\n"));
d->tag.setComment(intrumentNames.toString("\n") + "\n" + sampleNames.toString("\n"));
}

View File

@ -33,59 +33,59 @@
namespace TagLib {
namespace XM {
namespace XM {
class TAGLIB_EXPORT File : public Mod::File {
public:
/*!
* Contructs a Extended Module file from \a file. If \a readProperties
* is true the file's audio properties will also be read using
* \a propertiesStyle. If false, \a propertiesStyle is ignored.
*/
File(FileName file, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
class TAGLIB_EXPORT File : public Mod::File {
public:
/*!
* Contructs a Extended Module file from \a file. If \a readProperties
* is true the file's audio properties will also be read using
* \a propertiesStyle. If false, \a propertiesStyle is ignored.
*/
File(FileName file, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
/*!
* Contructs a Extended Module file from \a stream. If \a readProperties
* is true the file's audio properties will also be read using
* \a propertiesStyle. If false, \a propertiesStyle is ignored.
*/
File(IOStream *stream, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
/*!
* Contructs a Extended Module file from \a stream. If \a readProperties
* is true the file's audio properties will also be read using
* \a propertiesStyle. If false, \a propertiesStyle is ignored.
*/
File(IOStream *stream, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
virtual ~File();
/*!
* Destroys this instance of the File.
*/
virtual ~File();
XM::Tag *tag() const;
XM::Tag *tag() const;
/*!
* Returns the XM::Properties for this file. If no audio properties
* were read then this will return a null pointer.
*/
XM::Properties *audioProperties() const;
/*!
* Returns the XM::Properties for this file. If no audio properties
* were read then this will return a null pointer.
*/
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();
/*!
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving Extended Module tags is not supported.
*/
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;
};
}
}
#endif

View File

@ -27,142 +27,142 @@ using namespace XM;
class XM::Properties::PropertiesPrivate
{
public:
PropertiesPrivate() :
sampleLength(0),
channels(0),
version(0),
restartPosition(0),
patternCount(0),
instrumentCount(0),
flags(0),
tempo(0),
bpmSpeed(0)
{
}
ushort sampleLength;
int channels;
ushort version;
ushort restartPosition;
ushort patternCount;
ushort instrumentCount;
ushort flags;
ushort tempo;
ushort bpmSpeed;
PropertiesPrivate() :
sampleLength(0),
channels(0),
version(0),
restartPosition(0),
patternCount(0),
instrumentCount(0),
flags(0),
tempo(0),
bpmSpeed(0)
{
}
ushort sampleLength;
int channels;
ushort version;
ushort restartPosition;
ushort patternCount;
ushort instrumentCount;
ushort flags;
ushort tempo;
ushort bpmSpeed;
};
XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
AudioProperties(propertiesStyle),
d(new PropertiesPrivate)
AudioProperties(propertiesStyle),
d(new PropertiesPrivate)
{
}
}
XM::Properties::~Properties()
{
delete d;
delete d;
}
int XM::Properties::length() const
{
return 0;
return 0;
}
int XM::Properties::bitrate() const
{
return 0;
return 0;
}
int XM::Properties::sampleRate() const
{
return 0;
return 0;
}
int XM::Properties::channels() const
{
return d->channels;
return d->channels;
}
ushort XM::Properties::sampleLength() const
{
return d->sampleLength;
return d->sampleLength;
}
ushort XM::Properties::version() const
{
return d->version;
return d->version;
}
ushort XM::Properties::restartPosition() const
{
return d->restartPosition;
return d->restartPosition;
}
ushort XM::Properties::patternCount() const
{
return d->patternCount;
return d->patternCount;
}
ushort XM::Properties::instrumentCount() const
{
return d->instrumentCount;
return d->instrumentCount;
}
ushort XM::Properties::flags() const
{
return d->flags;
return d->flags;
}
ushort XM::Properties::tempo() const
{
return d->tempo;
return d->tempo;
}
ushort XM::Properties::bpmSpeed() const
{
return d->bpmSpeed;
return d->bpmSpeed;
}
void XM::Properties::setSampleLength(int sampleLength)
{
d->sampleLength = sampleLength;
d->sampleLength = sampleLength;
}
void XM::Properties::setChannels(int channels)
{
d->channels = channels;
d->channels = channels;
}
void XM::Properties::setVersion(ushort version)
{
d->version = version;
d->version = version;
}
void XM::Properties::setRestartPosition(ushort restartPosition)
{
d->restartPosition = restartPosition;
d->restartPosition = restartPosition;
}
void XM::Properties::setPatternCount(ushort patternCount)
{
d->patternCount = patternCount;
d->patternCount = patternCount;
}
void XM::Properties::setInstrumentCount(ushort instrumentCount)
{
d->instrumentCount = instrumentCount;
d->instrumentCount = instrumentCount;
}
void XM::Properties::setFlags(ushort flags)
{
d->flags = flags;
d->flags = flags;
}
void XM::Properties::setTempo(ushort tempo)
{
d->tempo = tempo;
d->tempo = tempo;
}
void XM::Properties::setBpmSpeed(ushort bpmSpeed)
{
d->bpmSpeed = bpmSpeed;
d->bpmSpeed = bpmSpeed;
}

View File

@ -27,47 +27,47 @@
#include "audioproperties.h"
namespace TagLib {
namespace XM {
class Properties : public AudioProperties {
friend class File;
public:
Properties(AudioProperties::ReadStyle propertiesStyle);
virtual ~Properties();
int length() const;
int bitrate() const;
int sampleRate() const;
int channels() const;
namespace XM {
class Properties : public AudioProperties {
friend class File;
public:
Properties(AudioProperties::ReadStyle propertiesStyle);
virtual ~Properties();
int length() const;
int bitrate() const;
int sampleRate() const;
int channels() const;
ushort sampleLength() const;
ushort version() const;
ushort restartPosition() const;
ushort patternCount() const;
ushort instrumentCount() const;
ushort flags() const;
ushort tempo() const;
ushort bpmSpeed() const;
ushort sampleLength() const;
ushort version() const;
ushort restartPosition() const;
ushort patternCount() const;
ushort instrumentCount() const;
ushort flags() const;
ushort tempo() const;
ushort bpmSpeed() const;
protected:
void setSampleLength(int sampleLength);
void setChannels(int channels);
protected:
void setSampleLength(int sampleLength);
void setChannels(int channels);
void setVersion(ushort version);
void setRestartPosition(ushort restartPosition);
void setPatternCount(ushort patternCount);
void setInstrumentCount(ushort instrumentCount);
void setFlags(ushort flags);
void setTempo(ushort tempo);
void setBpmSpeed(ushort bpmSpeed);
void setVersion(ushort version);
void setRestartPosition(ushort restartPosition);
void setPatternCount(ushort patternCount);
void setInstrumentCount(ushort instrumentCount);
void setFlags(ushort flags);
void setTempo(ushort tempo);
void setBpmSpeed(ushort bpmSpeed);
private:
Properties(const Properties&);
Properties &operator=(const Properties&);
private:
Properties(const Properties&);
Properties &operator=(const Properties&);
class PropertiesPrivate;
PropertiesPrivate *d;
};
}
class PropertiesPrivate;
PropertiesPrivate *d;
};
}
}
#endif

View File

@ -27,66 +27,66 @@ using namespace XM;
class XM::Tag::TagPrivate
{
public:
TagPrivate() {}
TagPrivate() {}
String title;
String comment;
String trackerName;
String title;
String comment;
String trackerName;
};
XM::Tag::Tag() : TagLib::Tag()
{
d = new TagPrivate;
d = new TagPrivate;
}
XM::Tag::~Tag()
{
delete d;
delete d;
}
String XM::Tag::title() const
{
return d->title;
return d->title;
}
String XM::Tag::artist() const
{
return String::null;
return String::null;
}
String XM::Tag::album() const
{
return String::null;
return String::null;
}
String XM::Tag::comment() const
{
return d->comment;
return d->comment;
}
String XM::Tag::genre() const
{
return String::null;
return String::null;
}
uint XM::Tag::year() const
{
return 0;
return 0;
}
uint XM::Tag::track() const
{
return 0;
return 0;
}
String XM::Tag::trackerName() const
{
return d->trackerName;
return d->trackerName;
}
void XM::Tag::setTitle(const String &title)
{
d->title = title;
d->title = title;
}
void XM::Tag::setArtist(const String &)
@ -99,7 +99,7 @@ void XM::Tag::setAlbum(const String &)
void XM::Tag::setComment(const String &comment)
{
d->comment = comment;
d->comment = comment;
}
void XM::Tag::setGenre(const String &)
@ -116,5 +116,5 @@ void XM::Tag::setTrack(uint)
void XM::Tag::setTrackerName(const String &trackerName)
{
d->trackerName = trackerName;
d->trackerName = trackerName;
}

View File

@ -25,38 +25,38 @@
#include "modtag.h"
namespace TagLib {
namespace XM {
class Tag : public TagLib::Tag {
public:
Tag();
virtual ~Tag();
namespace XM {
class Tag : public TagLib::Tag {
public:
Tag();
virtual ~Tag();
String title() const;
String artist() const;
String album() const;
String comment() const;
String genre() const;
uint year() const;
uint track() const;
String trackerName() const;
String title() const;
String artist() const;
String album() const;
String comment() const;
String genre() const;
uint year() const;
uint track() const;
String trackerName() const;
void setTitle (const String &title);
void setArtist (const String &artist);
void setAlbum (const String &album);
void setComment(const String &comment);
void setGenre (const String &genre);
void setYear (uint year);
void setTrack(uint track);
void setTrackerName(const String &trackerName);
void setTitle (const String &title);
void setArtist (const String &artist);
void setAlbum (const String &album);
void setComment(const String &comment);
void setGenre (const String &genre);
void setYear (uint year);
void setTrack(uint track);
void setTrackerName(const String &trackerName);
private:
Tag(const Tag &);
Tag &operator=(const Tag &);
private:
Tag(const Tag &);
Tag &operator=(const Tag &);
class TagPrivate;
TagPrivate *d;
};
}
class TagPrivate;
TagPrivate *d;
};
}
}
#endif