IT: support channels property

This commit is contained in:
Mathias Panzenböck
2011-06-20 02:19:16 +02:00
parent 4b44f25048
commit d1cb8ae09d
6 changed files with 40 additions and 15 deletions

View File

@ -176,6 +176,23 @@ void IT::File::read(bool)
}
*/
seek(64);
ByteVector pannings = readBlock(64);
ByteVector volumes = readBlock(64);
READ_ASSERT(pannings.size() == 64 && volumes.size() == 64);
int channels = 0;
for(int i = 0; i < 64; ++ i)
{
// Strictly speaking an IT file has always 64 channels, but
// I don't count disabled and muted channels.
// But this always gives 64 channels for all my files anyway.
// Strangely VLC does report other values. I wonder how VLC
// gets it's values.
if(pannings[i] < 128 && volumes[i] > 0) ++ channels;
}
d->properties.setChannels(channels);
StringList comment;
// Note: I found files that have nil characters somewhere
// in the instrument/sample names and more characters

View File

@ -28,6 +28,7 @@ class IT::Properties::PropertiesPrivate
{
public:
PropertiesPrivate() :
channels(0),
tableLength(0),
stereo(false),
instrumentCount(0),
@ -41,11 +42,12 @@ public:
mixVolume(0),
tempo(0),
bpmSpeed(0),
panningSeparation(0),
pitchWheelDepth(0)
panningSeparation(0),
pitchWheelDepth(0)
{
}
int channels;
ushort tableLength;
bool stereo;
ushort instrumentCount;
@ -91,7 +93,7 @@ int IT::Properties::sampleRate() const
int IT::Properties::channels() const
{
return d->stereo ? 2 : 1;
return d->channels;
}
ushort IT::Properties::tableLength() const
@ -169,6 +171,11 @@ uchar IT::Properties::pitchWheelDepth() const
return d->pitchWheelDepth;
}
void IT::Properties::setChannels(int channels)
{
d->channels = channels;
}
void IT::Properties::setTableLength(ushort tableLength)
{
d->tableLength = tableLength;

View File

@ -51,13 +51,14 @@ namespace TagLib {
ushort mixVolume() const;
uchar tempo() const;
uchar bpmSpeed() const;
uchar panningSeparation() const;
uchar pitchWheelDepth() const;
uchar panningSeparation() const;
uchar pitchWheelDepth() const;
protected:
void setChannels(int channels);
void setTableLength(ushort tableLength);
void setStereo(bool stereo);
void setInstrumentCount(ushort instrumentCount);
void setSampleCount (ushort sampleCount);
void setPatternCount(ushort patternCount);