Format taglib sources

This commit is contained in:
Jonas Kvinge
2020-06-13 19:02:42 +02:00
parent 72bff7fa35
commit 4ce099294c
224 changed files with 12905 additions and 15623 deletions

View File

@@ -35,64 +35,52 @@
using namespace Strawberry_TagLib::TagLib;
using namespace S3M;
class S3M::File::FilePrivate
{
public:
class S3M::File::FilePrivate {
public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: properties(propertiesStyle)
{
: properties(propertiesStyle) {
}
Mod::Tag tag;
Mod::Tag tag;
S3M::Properties properties;
};
S3M::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);
}
S3M::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);
}
S3M::File::~File()
{
S3M::File::~File() {
delete d;
}
Mod::Tag *S3M::File::tag() const
{
Mod::Tag *S3M::File::tag() const {
return &d->tag;
}
PropertyMap S3M::File::properties() const
{
PropertyMap S3M::File::properties() const {
return d->tag.properties();
}
PropertyMap S3M::File::setProperties(const PropertyMap &properties)
{
PropertyMap S3M::File::setProperties(const PropertyMap &properties) {
return d->tag.setProperties(properties);
}
S3M::Properties *S3M::File::audioProperties() const
{
S3M::Properties *S3M::File::audioProperties() const {
return &d->properties;
}
bool S3M::File::save()
{
if(readOnly()) {
bool S3M::File::save() {
if (readOnly()) {
debug("S3M::File::save() - Cannot save to a read only file.");
return false;
}
@@ -108,35 +96,35 @@ bool S3M::File::save()
unsigned short length = 0;
unsigned short sampleCount = 0;
if(!readU16L(length) || !readU16L(sampleCount))
if (!readU16L(length) || !readU16L(sampleCount))
return false;
seek(28, Current);
int channels = 0;
for(int i = 0; i < 32; ++ i) {
for (int i = 0; i < 32; ++i) {
unsigned char setting = 0;
if(!readByte(setting))
if (!readByte(setting))
return false;
// or if(setting >= 128)?
// or channels = i + 1;?
// need a better spec!
if(setting != 0xff) ++ channels;
if (setting != 0xff) ++channels;
}
seek(channels, Current);
StringList lines = d->tag.comment().split("\n");
// write comment as sample names:
for(unsigned short i = 0; i < sampleCount; ++ i) {
for (unsigned short i = 0; i < sampleCount; ++i) {
seek(96L + length + ((long)i << 1));
unsigned short instrumentOffset = 0;
if(!readU16L(instrumentOffset))
if (!readU16L(instrumentOffset))
return false;
seek(((long)instrumentOffset << 4) + 48);
if(i < lines.size())
if (i < lines.size())
writeString(lines[i], 27);
else
writeString(String(), 27);
@@ -146,9 +134,8 @@ bool S3M::File::save()
return true;
}
void S3M::File::read(bool)
{
if(!isOpen())
void S3M::File::read(bool) {
if (!isOpen())
return;
READ_STRING(d->tag.setTitle, 28);
@@ -188,21 +175,21 @@ void S3M::File::read(bool)
seek(12, Current);
int channels = 0;
for(int i = 0; i < 32; ++ i) {
for (int i = 0; i < 32; ++i) {
READ_BYTE_AS(setting);
// or if(setting >= 128)?
// or channels = i + 1;?
// need a better spec!
if(setting != 0xff) ++ channels;
if (setting != 0xff) ++channels;
}
d->properties.setChannels(channels);
seek(96);
unsigned short realLength = 0;
for(unsigned short i = 0; i < length; ++ i) {
for (unsigned short i = 0; i < length; ++i) {
READ_BYTE_AS(order);
if(order == 255) break;
if(order != 254) ++ realLength;
if (order == 255) break;
if (order != 254) ++realLength;
}
d->properties.setLengthInPatterns(realLength);
@@ -213,7 +200,7 @@ void S3M::File::read(bool)
// However, there I never found instruments (SCRI) but
// instead samples (SCRS).
StringList comment;
for(unsigned short i = 0; i < sampleCount; ++ i) {
for (unsigned short i = 0; i < sampleCount; ++i) {
seek(96L + length + ((long)i << 1));
READ_U16L_AS(sampleHeaderOffset);

View File

@@ -36,22 +36,22 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace S3M {
namespace S3M {
class TAGLIB_EXPORT File : public Mod::FileBase {
public:
/*!
class TAGLIB_EXPORT File : public Mod::FileBase {
public:
/*!
* Constructs a ScreamTracker III 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 a ScreamTracker III 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 S3M::Properties for this file. If no audio properties
* were read then this will return a null pointer.
*/
S3M::Properties *audioProperties() const;
S3M::Properties *audioProperties() const;
/*!
/*!
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving ScreamTracker III 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 S3M
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -29,191 +29,156 @@
using namespace Strawberry_TagLib::TagLib;
using namespace S3M;
class S3M::Properties::PropertiesPrivate
{
public:
PropertiesPrivate() :
lengthInPatterns(0),
channels(0),
stereo(false),
sampleCount(0),
patternCount(0),
flags(0),
trackerVersion(0),
fileFormatVersion(0),
globalVolume(0),
masterVolume(0),
tempo(0),
bpmSpeed(0)
{
class S3M::Properties::PropertiesPrivate {
public:
PropertiesPrivate() : lengthInPatterns(0),
channels(0),
stereo(false),
sampleCount(0),
patternCount(0),
flags(0),
trackerVersion(0),
fileFormatVersion(0),
globalVolume(0),
masterVolume(0),
tempo(0),
bpmSpeed(0) {
}
unsigned short lengthInPatterns;
int channels;
bool stereo;
int channels;
bool stereo;
unsigned short sampleCount;
unsigned short patternCount;
unsigned short flags;
unsigned short trackerVersion;
unsigned short fileFormatVersion;
unsigned char globalVolume;
unsigned char masterVolume;
unsigned char tempo;
unsigned char bpmSpeed;
unsigned char globalVolume;
unsigned char masterVolume;
unsigned char tempo;
unsigned char bpmSpeed;
};
S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
AudioProperties(propertiesStyle),
d(new PropertiesPrivate())
{
S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle),
d(new PropertiesPrivate()) {
}
S3M::Properties::~Properties()
{
S3M::Properties::~Properties() {
delete d;
}
int S3M::Properties::length() const
{
int S3M::Properties::length() const {
return 0;
}
int S3M::Properties::lengthInSeconds() const
{
int S3M::Properties::lengthInSeconds() const {
return 0;
}
int S3M::Properties::lengthInMilliseconds() const
{
int S3M::Properties::lengthInMilliseconds() const {
return 0;
}
int S3M::Properties::bitrate() const
{
int S3M::Properties::bitrate() const {
return 0;
}
int S3M::Properties::sampleRate() const
{
int S3M::Properties::sampleRate() const {
return 0;
}
int S3M::Properties::channels() const
{
int S3M::Properties::channels() const {
return d->channels;
}
unsigned short S3M::Properties::lengthInPatterns() const
{
unsigned short S3M::Properties::lengthInPatterns() const {
return d->lengthInPatterns;
}
bool S3M::Properties::stereo() const
{
bool S3M::Properties::stereo() const {
return d->stereo;
}
unsigned short S3M::Properties::sampleCount() const
{
unsigned short S3M::Properties::sampleCount() const {
return d->sampleCount;
}
unsigned short S3M::Properties::patternCount() const
{
unsigned short S3M::Properties::patternCount() const {
return d->patternCount;
}
unsigned short S3M::Properties::flags() const
{
unsigned short S3M::Properties::flags() const {
return d->flags;
}
unsigned short S3M::Properties::trackerVersion() const
{
unsigned short S3M::Properties::trackerVersion() const {
return d->trackerVersion;
}
unsigned short S3M::Properties::fileFormatVersion() const
{
unsigned short S3M::Properties::fileFormatVersion() const {
return d->fileFormatVersion;
}
unsigned char S3M::Properties::globalVolume() const
{
unsigned char S3M::Properties::globalVolume() const {
return d->globalVolume;
}
unsigned char S3M::Properties::masterVolume() const
{
unsigned char S3M::Properties::masterVolume() const {
return d->masterVolume;
}
unsigned char S3M::Properties::tempo() const
{
unsigned char S3M::Properties::tempo() const {
return d->tempo;
}
unsigned char S3M::Properties::bpmSpeed() const
{
unsigned char S3M::Properties::bpmSpeed() const {
return d->bpmSpeed;
}
void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns)
{
void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns) {
d->lengthInPatterns = lengthInPatterns;
}
void S3M::Properties::setChannels(int channels)
{
void S3M::Properties::setChannels(int channels) {
d->channels = channels;
}
void S3M::Properties::setStereo(bool stereo)
{
void S3M::Properties::setStereo(bool stereo) {
d->stereo = stereo;
}
void S3M::Properties::setSampleCount(unsigned short sampleCount)
{
void S3M::Properties::setSampleCount(unsigned short sampleCount) {
d->sampleCount = sampleCount;
}
void S3M::Properties::setPatternCount(unsigned short patternCount)
{
void S3M::Properties::setPatternCount(unsigned short patternCount) {
d->patternCount = patternCount;
}
void S3M::Properties::setFlags(unsigned short flags)
{
void S3M::Properties::setFlags(unsigned short flags) {
d->flags = flags;
}
void S3M::Properties::setTrackerVersion(unsigned short trackerVersion)
{
void S3M::Properties::setTrackerVersion(unsigned short trackerVersion) {
d->trackerVersion = trackerVersion;
}
void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion)
{
void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion) {
d->fileFormatVersion = fileFormatVersion;
}
void S3M::Properties::setGlobalVolume(unsigned char globalVolume)
{
void S3M::Properties::setGlobalVolume(unsigned char globalVolume) {
d->globalVolume = globalVolume;
}
void S3M::Properties::setMasterVolume(unsigned char masterVolume)
{
void S3M::Properties::setMasterVolume(unsigned char masterVolume) {
d->masterVolume = masterVolume;
}
void S3M::Properties::setTempo(unsigned char tempo)
{
void S3M::Properties::setTempo(unsigned char tempo) {
d->tempo = tempo;
}
void S3M::Properties::setBpmSpeed(unsigned char bpmSpeed)
{
void S3M::Properties::setBpmSpeed(unsigned char bpmSpeed) {
d->bpmSpeed = bpmSpeed;
}

View File

@@ -31,66 +31,67 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace S3M {
class TAGLIB_EXPORT Properties : public AudioProperties {
friend class File;
public:
/*! Flag bits. */
enum {
ST2Vibrato = 1,
ST2Tempo = 2,
AmigaSlides = 4,
Vol0MixOptimizations = 8,
AmigaLimits = 16,
EnableFilter = 32,
CustomData = 128
};
namespace S3M {
class TAGLIB_EXPORT Properties : public AudioProperties {
friend class File;
Properties(AudioProperties::ReadStyle propertiesStyle);
virtual ~Properties();
public:
/*! Flag bits. */
enum {
ST2Vibrato = 1,
ST2Tempo = 2,
AmigaSlides = 4,
Vol0MixOptimizations = 8,
AmigaLimits = 16,
EnableFilter = 32,
CustomData = 128
};
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;
bool stereo() const;
unsigned short sampleCount() const;
unsigned short patternCount() const;
unsigned short flags() const;
unsigned short trackerVersion() const;
unsigned short fileFormatVersion() const;
unsigned char globalVolume() const;
unsigned char masterVolume() const;
unsigned char tempo() const;
unsigned char 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;
bool stereo() const;
unsigned short sampleCount() const;
unsigned short patternCount() const;
unsigned short flags() const;
unsigned short trackerVersion() const;
unsigned short fileFormatVersion() const;
unsigned char globalVolume() const;
unsigned char masterVolume() const;
unsigned char tempo() const;
unsigned char bpmSpeed() const;
void setLengthInPatterns (unsigned short lengthInPatterns);
void setStereo (bool stereo);
void setSampleCount (unsigned short sampleCount);
void setPatternCount (unsigned short patternCount);
void setFlags (unsigned short flags);
void setTrackerVersion (unsigned short trackerVersion);
void setFileFormatVersion(unsigned short fileFormatVersion);
void setGlobalVolume (unsigned char globalVolume);
void setMasterVolume (unsigned char masterVolume);
void setTempo (unsigned char tempo);
void setBpmSpeed (unsigned char bpmSpeed);
void setChannels(int channels);
private:
Properties(const Properties&);
Properties &operator=(const Properties&);
void setLengthInPatterns(unsigned short lengthInPatterns);
void setStereo(bool stereo);
void setSampleCount(unsigned short sampleCount);
void setPatternCount(unsigned short patternCount);
void setFlags(unsigned short flags);
void setTrackerVersion(unsigned short trackerVersion);
void setFileFormatVersion(unsigned short fileFormatVersion);
void setGlobalVolume(unsigned char globalVolume);
void setMasterVolume(unsigned char masterVolume);
void setTempo(unsigned char tempo);
void setBpmSpeed(unsigned char bpmSpeed);
class PropertiesPrivate;
PropertiesPrivate *d;
};
}
}
}
private:
Properties(const Properties &);
Properties &operator=(const Properties &);
class PropertiesPrivate;
PropertiesPrivate *d;
};
} // namespace S3M
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif