diff options
author | Mathias Panzenböck <grosser.meister.morti@gmx.net> | 2011-06-24 01:11:10 +0200 |
---|---|---|
committer | Mathias Panzenböck <grosser.meister.morti@gmx.net> | 2011-06-24 01:11:10 +0200 |
commit | 9c27c45eb83453d8529bc139ed70647d6fffa624 (patch) | |
tree | c87864f04a63b495194e55c0a444da6cced536be | |
parent | e71806b6dff3ce8ad6b6e09417793042bd170cab (diff) |
IT: strings require term. NUL. mod files: tableLength -> lengthInPatterns
Also added enums for S3M/IT/XM flags.
-rw-r--r-- | taglib/it/itfile.cpp | 29 | ||||
-rw-r--r-- | taglib/it/itproperties.cpp | 21 | ||||
-rw-r--r-- | taglib/it/itproperties.h | 23 | ||||
-rw-r--r-- | taglib/mod/modfile.cpp | 2 | ||||
-rw-r--r-- | taglib/mod/modproperties.cpp | 12 | ||||
-rw-r--r-- | taglib/mod/modproperties.h | 6 | ||||
-rw-r--r-- | taglib/s3m/s3mfile.cpp | 2 | ||||
-rw-r--r-- | taglib/s3m/s3mproperties.cpp | 12 | ||||
-rw-r--r-- | taglib/s3m/s3mproperties.h | 15 | ||||
-rw-r--r-- | taglib/xm/xmfile.cpp | 34 | ||||
-rw-r--r-- | taglib/xm/xmproperties.cpp | 12 | ||||
-rw-r--r-- | taglib/xm/xmproperties.h | 25 | ||||
-rw-r--r-- | tests/test_mod.cpp | 2 | ||||
-rw-r--r-- | tests/test_s3m.cpp | 2 | ||||
-rw-r--r-- | tests/test_xm.cpp | 4 |
15 files changed, 116 insertions, 85 deletions
diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 09ff077d..ed175c85 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -78,7 +78,8 @@ bool IT::File::save() return false; } seek(4); - writeString(d->tag.title(), 26); + writeString(d->tag.title(), 25); + writeByte(0); seek(2, Current); @@ -103,9 +104,10 @@ bool IT::File::save() seek(instrumentOffset + 32); if(i < lines.size()) - writeString(lines[i], 26); + writeString(lines[i], 25); else - writeString(String::null, 26); + writeString(String::null, 25); + writeByte(0); } for(ushort i = 0; i < sampleCount; ++ i) @@ -118,9 +120,10 @@ bool IT::File::save() seek(sampleOffset + 20); if((i + instrumentCount) < lines.size()) - writeString(lines[i + instrumentCount], 26); + writeString(lines[i + instrumentCount], 25); else - writeString(String::null, 26); + writeString(String::null, 25); + writeByte(0); } // write rest as message: @@ -128,6 +131,9 @@ bool IT::File::save() for(uint i = instrumentCount + sampleCount; i < lines.size(); ++ i) messageLines.append(lines[i]); ByteVector message = messageLines.toString("\r").data(String::Latin1); + if(message.size() > 8000) + message.resize(8000); + ushort special = 0; ushort messageLength = 0; ulong messageOffset = 0; @@ -249,7 +255,7 @@ void IT::File::read(bool) if(order == 255) break; if(order != 254) ++ realLength; } - d->properties.setTableLength(realLength); + d->properties.setLengthInPatterns(realLength); StringList comment; // Note: I found files that have nil characters somewhere @@ -290,6 +296,7 @@ void IT::File::read(bool) READ_BYTE_AS(sampleFlags); READ_BYTE_AS(sampleVolume); READ_STRING_AS(sampleName, 26); + /* READ_BYTE_AS(sampleCvt); READ_BYTE_AS(samplePanning); READ_U32L_AS(sampleLength); @@ -303,15 +310,13 @@ void IT::File::read(bool) READ_BYTE_AS(vibratoDepth); READ_BYTE_AS(vibratoRate); READ_BYTE_AS(vibratoType); + */ comment.append(sampleName); } - if(comment.size() > 0 && message.size() > 0) - d->tag.setComment(comment.toString("\n") + "\n" + message); - else if(comment.size() > 0) - d->tag.setComment(comment.toString("\n")); - else - d->tag.setComment(message); + if(message.size() > 0) + comment.append(message); + d->tag.setComment(comment.toString("\n")); d->tag.setTrackerName("Impulse Tracker"); } diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index ce9cefaa..7d181d57 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -29,8 +29,7 @@ class IT::Properties::PropertiesPrivate public: PropertiesPrivate() : channels(0), - tableLength(0), - stereo(false), + lengthInPatterns(0), instrumentCount(0), sampleCount(0), patternCount(0), @@ -48,8 +47,7 @@ public: } int channels; - ushort tableLength; - bool stereo; + ushort lengthInPatterns; ushort instrumentCount; ushort sampleCount; ushort patternCount; @@ -96,14 +94,14 @@ int IT::Properties::channels() const return d->channels; } -ushort IT::Properties::tableLength() const +ushort IT::Properties::lengthInPatterns() const { - return d->tableLength; + return d->lengthInPatterns; } bool IT::Properties::stereo() const { - return d->stereo; + return d->flags & F_STEREO; } ushort IT::Properties::instrumentCount() const @@ -176,14 +174,9 @@ void IT::Properties::setChannels(int channels) d->channels = channels; } -void IT::Properties::setTableLength(ushort tableLength) +void IT::Properties::setLengthInPatterns(ushort lengthInPatterns) { - d->tableLength = tableLength; -} - -void IT::Properties::setStereo(bool stereo) -{ - d->stereo = stereo; + d->lengthInPatterns = lengthInPatterns; } void IT::Properties::setInstrumentCount(ushort instrumentCount) { diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index 5e60ec58..632b87a8 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -30,6 +30,24 @@ namespace TagLib { class TAGLIB_EXPORT Properties : public AudioProperties { friend class File; public: + /*! Flag bits. */ + enum { + F_STEREO = 1, + F_VOL0_MIX_OPT = 2, + F_INSTRUMENTS = 4, + F_LINEAR_SLIDES = 8, + F_OLD_EFFECTS = 16, + F_LINK_EFFECT = 32, + F_MIDI_PITCH_CTRL = 64, + F_EMBEDDED_MIDI_CONF = 128 + }; + + /*! Special bits. */ + enum { + S_MESSAGE = 1, + S_EMBEDDED_MIDI_CONF = 8 + }; + Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); @@ -38,7 +56,7 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort tableLength() const; + ushort lengthInPatterns() const; bool stereo() const; ushort instrumentCount() const; ushort sampleCount() const; @@ -57,8 +75,7 @@ namespace TagLib { protected: void setChannels(int channels); - void setTableLength(ushort tableLength); - void setStereo(bool stereo); + void setLengthInPatterns(ushort lengthInPatterns); void setInstrumentCount(ushort instrumentCount); void setSampleCount (ushort sampleCount); void setPatternCount(ushort patternCount); diff --git a/taglib/mod/modfile.cpp b/taglib/mod/modfile.cpp index 7047e857..9eb74f4b 100644 --- a/taglib/mod/modfile.cpp +++ b/taglib/mod/modfile.cpp @@ -178,7 +178,7 @@ void Mod::File::read(bool) comment.append(instrumentName); } - READ_BYTE(d->properties.setTableLength); + READ_BYTE(d->properties.setLengthInPatterns); d->tag.setComment(comment.toString("\n")); } diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index a6fe4739..47903454 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -30,13 +30,13 @@ public: PropertiesPrivate() : channels(0), instrumentCount(0), - tableLength(0) + lengthInPatterns(0) { } int channels; uint instrumentCount; - uchar tableLength; + uchar lengthInPatterns; }; Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -75,9 +75,9 @@ uint Mod::Properties::instrumentCount() const return d->instrumentCount; } -uchar Mod::Properties::tableLength() const +uchar Mod::Properties::lengthInPatterns() const { - return d->tableLength; + return d->lengthInPatterns; } void Mod::Properties::setChannels(int channels) @@ -90,7 +90,7 @@ void Mod::Properties::setInstrumentCount(uint instrumentCount) d->instrumentCount = instrumentCount; } -void Mod::Properties::setTableLength(uchar tableLength) +void Mod::Properties::setLengthInPatterns(uchar lengthInPatterns) { - d->tableLength = tableLength; + d->lengthInPatterns = lengthInPatterns; } diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index 40bce747..8bf3ac5e 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -38,14 +38,14 @@ namespace TagLib { int sampleRate() const; int channels() const; - uint instrumentCount() const; - uchar tableLength() const; + uint instrumentCount() const; + uchar lengthInPatterns() const; protected: void setChannels(int channels); void setInstrumentCount(uint sampleCount); - void setTableLength(uchar tableLength); + void setLengthInPatterns(uchar lengthInPatterns); private: Properties(const Properties&); diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index a739ea52..e3f9c8ec 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -191,7 +191,7 @@ void S3M::File::read(bool) if(order == 255) break; if(order != 254) ++ realLength; } - d->properties.setTableLength(realLength); + d->properties.setLengthInPatterns(realLength); seek(channels, Current); diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index d7f40c8f..8b50a60b 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -28,7 +28,7 @@ class S3M::Properties::PropertiesPrivate { public: PropertiesPrivate() : - tableLength(0), + lengthInPatterns(0), channels(0), stereo(false), sampleCount(0), @@ -43,7 +43,7 @@ public: { } - ushort tableLength; + ushort lengthInPatterns; int channels; bool stereo; ushort sampleCount; @@ -88,9 +88,9 @@ int S3M::Properties::channels() const return d->channels; } -ushort S3M::Properties::tableLength() const +ushort S3M::Properties::lengthInPatterns() const { - return d->tableLength; + return d->lengthInPatterns; } bool S3M::Properties::stereo() const @@ -143,9 +143,9 @@ uchar S3M::Properties::bpmSpeed() const return d->bpmSpeed; } -void S3M::Properties::setTableLength(ushort tableLength) +void S3M::Properties::setLengthInPatterns(ushort lengthInPatterns) { - d->tableLength = tableLength; + d->lengthInPatterns = lengthInPatterns; } void S3M::Properties::setChannels(int channels) diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index 87214770..bbfc7c61 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -30,6 +30,17 @@ namespace TagLib { class TAGLIB_EXPORT Properties : public AudioProperties { friend class File; public: + /*! Flag bits. */ + enum { + F_ST2_VIBRATO = 1, + F_ST2_TEMPO = 2, + F_AMIGA_SLIDES = 4, + F_VOL0_MIX_OPT = 8, + F_AMIGA_LIMITS = 16, + F_ENABLE_FILTER = 32, + F_CUSTOM_DATA = 128 + }; + Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); @@ -38,7 +49,7 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort tableLength() const; + ushort lengthInPatterns() const; bool stereo() const; ushort sampleCount() const; ushort patternCount() const; @@ -51,9 +62,9 @@ namespace TagLib { uchar bpmSpeed() const; protected: - void setTableLength(ushort tableLength); void setChannels(int channels); + void setLengthInPatterns (ushort lengthInPatterns); void setStereo (bool stereo); void setSampleCount (ushort sampleCount); void setPatternCount (ushort patternCount); diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 7b07d116..1ea9e027 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -465,10 +465,10 @@ bool XM::File::save() { if(sampleHeaderSize > 4U) { - ulong length = 0; - if(!readU32L(length)) + ulong sampleLength = 0; + if(!readU32L(sampleLength)) return false; - offset += length; + offset += sampleLength; seek(std::min(sampleHeaderSize, 14UL), Current); if(sampleHeaderSize > 18U) @@ -523,7 +523,7 @@ void XM::File::read(bool) READ_U32L_AS(headerSize); READ_ASSERT(headerSize >= 4); - ushort tableLength = 0; + ushort length = 0; ushort restartPosition = 0; ushort channels = 0; ushort patternCount = 0; @@ -533,7 +533,7 @@ void XM::File::read(bool) ushort bpmSpeed = 0; StructReader header; - header.u16L(tableLength) + header.u16L(length) .u16L(restartPosition) .u16L(channels) .u16L(patternCount) @@ -547,7 +547,7 @@ void XM::File::read(bool) READ_ASSERT(count == size); - d->properties.setTableLength(tableLength); + d->properties.setLengthInPatterns(length); d->properties.setRestartPosition(restartPosition); d->properties.setChannels(channels); d->properties.setPatternCount(patternCount); @@ -609,18 +609,18 @@ void XM::File::read(bool) for(ushort j = 0; j < sampleCount; ++ j) { - ulong length = 0; - ulong loopStart = 0; - ulong loopLength = 0; - uchar volume = 0; - uchar finetune = 0; - uchar sampleType = 0; - uchar panning = 0; - uchar noteNumber = 0; - uchar compression = 0; + ulong sampleLength = 0; + ulong loopStart = 0; + ulong loopLength = 0; + uchar volume = 0; + uchar finetune = 0; + uchar sampleType = 0; + uchar panning = 0; + uchar noteNumber = 0; + uchar compression = 0; String sampleName; StructReader sample; - sample.u32L(length) + sample.u32L(sampleLength) .u32L(loopStart) .u32L(loopLength) .byte(volume) @@ -636,7 +636,7 @@ void XM::File::read(bool) // skip unhandeled header proportion: seek(sampleHeaderSize - count, Current); - offset += length; + offset += sampleLength; sampleNames.append(sampleName); } } diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index c6b2b7f3..e0b489ac 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -28,7 +28,7 @@ class XM::Properties::PropertiesPrivate { public: PropertiesPrivate() : - tableLength(0), + lengthInPatterns(0), channels(0), version(0), restartPosition(0), @@ -41,7 +41,7 @@ public: { } - ushort tableLength; + ushort lengthInPatterns; int channels; ushort version; ushort restartPosition; @@ -84,9 +84,9 @@ int XM::Properties::channels() const return d->channels; } -ushort XM::Properties::tableLength() const +ushort XM::Properties::lengthInPatterns() const { - return d->tableLength; + return d->lengthInPatterns; } ushort XM::Properties::version() const @@ -129,9 +129,9 @@ ushort XM::Properties::bpmSpeed() const return d->bpmSpeed; } -void XM::Properties::setTableLength(ushort tableLength) +void XM::Properties::setLengthInPatterns(ushort lengthInPatterns) { - d->tableLength = tableLength; + d->lengthInPatterns = lengthInPatterns; } void XM::Properties::setChannels(int channels) diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index fb8397aa..f1aba404 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -31,6 +31,11 @@ namespace TagLib { class Properties : public AudioProperties { friend class File; public: + /*! Flag bits. */ + enum { + F_AMIGA_FREQ = 1 + }; + Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); @@ -39,20 +44,20 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort tableLength() const; - ushort version() const; - ushort restartPosition() const; - ushort patternCount() const; - ushort instrumentCount() const; - uint sampleCount() const; - ushort flags() const; - ushort tempo() const; - ushort bpmSpeed() const; + ushort lengthInPatterns() const; + ushort version() const; + ushort restartPosition() const; + ushort patternCount() const; + ushort instrumentCount() const; + uint sampleCount() const; + ushort flags() const; + ushort tempo() const; + ushort bpmSpeed() const; protected: void setChannels(int channels); - void setTableLength(ushort tableLength); + void setLengthInPatterns(ushort lengthInPatterns); void setVersion(ushort version); void setRestartPosition(ushort restartPosition); void setPatternCount(ushort patternCount); diff --git a/tests/test_mod.cpp b/tests/test_mod.cpp index 49a8f182..67c46f28 100644 --- a/tests/test_mod.cpp +++ b/tests/test_mod.cpp @@ -93,7 +93,7 @@ private: CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); CPPUNIT_ASSERT_EQUAL(31U, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((uchar)1, p->tableLength()); + CPPUNIT_ASSERT_EQUAL((uchar)1, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String::null, t->artist()); CPPUNIT_ASSERT_EQUAL(String::null, t->album()); diff --git a/tests/test_s3m.cpp b/tests/test_s3m.cpp index efc9745c..e2566626 100644 --- a/tests/test_s3m.cpp +++ b/tests/test_s3m.cpp @@ -98,7 +98,7 @@ private: CPPUNIT_ASSERT_EQUAL( 0, p->bitrate()); CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(16, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->tableLength()); + CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(false, p->stereo()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); diff --git a/tests/test_xm.cpp b/tests/test_xm.cpp index 3e74524d..c6af369e 100644 --- a/tests/test_xm.cpp +++ b/tests/test_xm.cpp @@ -130,7 +130,7 @@ public: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->tableLength()); + CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->version()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0 , p->restartPosition()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); @@ -176,7 +176,7 @@ private: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->tableLength()); + CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort)260, p->version()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->restartPosition()); CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); |