mirror of
https://github.com/taglib/taglib.git
synced 2025-08-15 10:44:39 -04:00
comment writing support and more tests for mod and xm
This commit is contained in:
@ -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);
|
||||
|
@ -19,6 +19,7 @@
|
||||
* MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "tdebug.h"
|
||||
#include "modfilebase.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user