comment writing support and more tests for mod and xm

This commit is contained in:
Mathias Panzenböck
2011-06-19 04:27:51 +02:00
parent 0143c3ee63
commit 6afb7c04b3
11 changed files with 755 additions and 128 deletions

View File

@ -79,7 +79,19 @@ bool Mod::File::save()
}
seek(0);
writeString(d->tag.title(), 20);
// TODO: write comment as instrument names
StringList lines = d->tag.comment().split("\n");
uint n = std::min(lines.size(), d->properties.instrumentCount());
for(uint i = 0; i < n; ++ i)
{
writeString(lines[i], 22);
seek(8, Current);
}
for(uint i = n; i < d->properties.instrumentCount(); ++ i)
{
writeString(String::null, 22);
seek(8, Current);
}
return true;
}
@ -92,8 +104,8 @@ void Mod::File::read(bool)
ByteVector modId = readBlock(4);
READ_ASSERT(modId.size() == 4);
int channels = 4;
int instruments = 31;
int channels = 4;
uint instruments = 31;
if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.")
{
d->tag.setTrackerName("ProTracker");
@ -143,7 +155,7 @@ void Mod::File::read(bool)
READ_STRING(d->tag.setTitle, 20);
StringList comment;
for(int i = 0; i < instruments; ++ i)
for(uint i = 0; i < instruments; ++ i)
{
READ_STRING_AS(instrumentName, 22);
// value in words, * 2 (<< 1) for bytes:
@ -151,7 +163,7 @@ void Mod::File::read(bool)
READ_BYTE_AS(fineTuneByte);
int fineTune = fineTuneByte & 0xF;
// > 7 means nagative value
// > 7 means negative value
if(fineTune > 7) fineTune -= 16;
READ_BYTE_AS(volume);

View File

@ -19,6 +19,7 @@
* MA 02110-1301 USA *
***************************************************************************/
#include "tdebug.h"
#include "modfilebase.h"
using namespace TagLib;

View File

@ -25,22 +25,26 @@
#include "taglib.h"
#include "tfile.h"
#include "tstring.h"
#include "tlist.h"
#include "taglib_export.h"
#include <algorithm>
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT FileBase : public TagLib::File {
protected:
FileBase(FileName file);
FileBase(IOStream *stream);
class TAGLIB_EXPORT FileBase : public TagLib::File
{
protected:
FileBase(FileName file);
FileBase(IOStream *stream);
void writeString(const String &s, ulong size, char padding = 0);
bool readString(String &s, ulong size);
bool readByte(uchar &byte);
bool readU16L(ushort &number);
bool readU32L(ulong &number);
bool readU16B(ushort &number);
bool readU32B(ulong &number);
void writeString(const String &s, ulong size, char padding = 0);
bool readString(String &s, ulong size);
bool readByte(uchar &byte);
bool readU16L(ushort &number);
bool readU32L(ulong &number);
bool readU16B(ushort &number);
bool readU32B(ulong &number);
};
}
}