]> granicus.if.org Git - taglib/commitdiff
XM: forgot smaple count
authorMathias Panzenböck <grosser.meister.morti@gmx.net>
Mon, 20 Jun 2011 00:31:17 +0000 (02:31 +0200)
committerMathias Panzenböck <grosser.meister.morti@gmx.net>
Mon, 20 Jun 2011 00:31:17 +0000 (02:31 +0200)
taglib/xm/xmfile.cpp
taglib/xm/xmproperties.cpp
taglib/xm/xmproperties.h

index c5e0627d12bdef3aa1ad0e830f17c37496f66e1e..7b07d116b656c1596dc92e6b6384bac97a8b3105 100644 (file)
@@ -445,10 +445,10 @@ bool XM::File::save()
     else
       writeString(lines[i], len);
 
-    ushort sampleCount = 0;
     long offset = 0;
     if(instrumentHeaderSize >= 29U)
     {
+      ushort sampleCount = 0;
       seek(1, Current);
       if(!readU16L(sampleCount))
         return false;
@@ -578,6 +578,7 @@ void XM::File::read(bool)
     
   StringList intrumentNames;
   StringList sampleNames;
+  uint sumSampleCount = 0;
 
   // read instruments:
   for(ushort i = 0; i < instrumentCount; ++ i)
@@ -600,6 +601,7 @@ void XM::File::read(bool)
     long offset = 0;
     if(sampleCount > 0)
     {
+      sumSampleCount += sampleCount;
       // wouldn't know which header size to assume otherwise:
       READ_ASSERT(instrumentHeaderSize >= count + 4 && readU32L(sampleHeaderSize));
       // skip unhandeled header proportion:
@@ -646,6 +648,7 @@ void XM::File::read(bool)
     seek(offset, Current);
   }
 
+  d->properties.setSampleCount(sumSampleCount);
   String comment(intrumentNames.toString("\n"));
   if(sampleNames.size() > 0)
   {
index b7466f88e5e80fe010976eeeaa5b4ed23307d072..c6b2b7f3b10affb2e280e2b6f72bb412b228974c 100644 (file)
@@ -34,6 +34,7 @@ public:
     restartPosition(0),
     patternCount(0),
     instrumentCount(0),
+    sampleCount(0),
     flags(0),
     tempo(0),
     bpmSpeed(0)
@@ -46,6 +47,7 @@ public:
   ushort restartPosition;
   ushort patternCount;
   ushort instrumentCount;
+  uint   sampleCount;
   ushort flags;
   ushort tempo;
   ushort bpmSpeed;
@@ -107,6 +109,11 @@ ushort XM::Properties::instrumentCount() const
   return d->instrumentCount;
 }
 
+uint XM::Properties::sampleCount() const
+{
+  return d->sampleCount;
+}
+
 ushort XM::Properties::flags() const
 {
   return d->flags;
@@ -152,6 +159,11 @@ void XM::Properties::setInstrumentCount(ushort instrumentCount)
   d->instrumentCount = instrumentCount;
 }
 
+void XM::Properties::setSampleCount(uint sampleCount)
+{
+  d->sampleCount = sampleCount;
+}
+
 void XM::Properties::setFlags(ushort flags)
 {
   d->flags = flags;
index 208e166cdf924acdd5e57d3917fc768a3c0460f5..717775c632d919543366353c02ec08fc6b7bf44f 100644 (file)
@@ -44,6 +44,7 @@ namespace TagLib {
       ushort restartPosition() const;
       ushort patternCount()    const;
       ushort instrumentCount() const;
+      uint   sampleCount()     const;
       ushort flags()           const;
       ushort tempo()           const;
       ushort bpmSpeed()        const;
@@ -56,6 +57,7 @@ namespace TagLib {
       void setRestartPosition(ushort restartPosition);
       void setPatternCount(ushort patternCount);
       void setInstrumentCount(ushort instrumentCount);
+      void setSampleCount(uint sampleCount);
       void setFlags(ushort flags);
       void setTempo(ushort tempo);
       void setBpmSpeed(ushort bpmSpeed);