]> granicus.if.org Git - taglib/commitdiff
IT: support channels property
authorMathias Panzenböck <grosser.meister.morti@gmx.net>
Mon, 20 Jun 2011 00:19:16 +0000 (02:19 +0200)
committerMathias Panzenböck <grosser.meister.morti@gmx.net>
Mon, 20 Jun 2011 00:19:16 +0000 (02:19 +0200)
taglib/it/itfile.cpp
taglib/it/itproperties.cpp
taglib/it/itproperties.h
taglib/mod/modproperties.cpp
taglib/mod/modproperties.h
tests/test_mod.cpp

index 1ec693137ae1181713db74f9344b20561122b4d7..d8040cdbfba4b693f5813d364fbc494e2a8f2867 100644 (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
index d74779c8ab07509e733009df52aec8ed69200ab0..84d69da91a8ba699df61584486017cefdf76622a 100644 (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;
index dfcf3a62033793bc30eba82efeef2ab001ade464..fcf18dfc60c018a510fafeab37217edbdc841caa 100644 (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);
index 65215d16690cedfcee4d4abc855cc79c618c236c..a6fe47391ea54e6e8743ec895c7aad58c452ed6c 100644 (file)
@@ -34,9 +34,9 @@ public:
   {
   }
   
-  int  channels;
-  uint instrumentCount;
-  uint tableLength;
+  int   channels;
+  uint  instrumentCount;
+  uchar tableLength;
 };
 
 Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
@@ -75,7 +75,7 @@ uint Mod::Properties::instrumentCount() const
   return d->instrumentCount;
 }
 
-uint Mod::Properties::tableLength() const
+uchar Mod::Properties::tableLength() const
 {
   return d->tableLength;
 }
@@ -90,7 +90,7 @@ void Mod::Properties::setInstrumentCount(uint instrumentCount)
   d->instrumentCount = instrumentCount;
 }
 
-void Mod::Properties::setTableLength(uint tableLength)
+void Mod::Properties::setTableLength(uchar tableLength)
 {
   d->tableLength = tableLength;
 }
index c92fd0228fddaa6e24833024dbb8ba79c10c7687..40bce747f2e441638c24f5f78dad4be28cbe29f1 100644 (file)
@@ -38,14 +38,14 @@ namespace TagLib {
       int sampleRate() const;
       int channels()   const;
 
-      uint instrumentCount() const;
-      uint tableLength()     const;
+      uint  instrumentCount() const;
+      uchar tableLength()     const;
 
     protected:
       void setChannels(int channels);
 
       void setInstrumentCount(uint sampleCount);
-      void setTableLength(uint tableLength);
+      void setTableLength(uchar tableLength);
 
     private:
       Properties(const Properties&);
index 2f6ff92f88c0e122e3f96f63d4a549fd71a9cc91..49a8f182349c5836e0cc32126f61a5468b76eb08 100644 (file)
@@ -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(1U, p->tableLength());
+    CPPUNIT_ASSERT_EQUAL((uchar)1, p->tableLength());
     CPPUNIT_ASSERT_EQUAL(title, t->title());
     CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
     CPPUNIT_ASSERT_EQUAL(String::null, t->album());