Automated commit for upstream build of version 0.9.0
[wdq2wav.git] / wdq2wav.cpp
index be084f8bfb91d39b164b9de0664870c3bdf99234..1c7791f8617d7b555c88259eb92b2ea996d92e8f 100644 (file)
@@ -374,19 +374,20 @@ bool read_int4 (int fd, unsigned int& n)
 
 bool read_float8 (int fd, double& f)
 {
-  unsigned char buf[8];
-  if (read (fd, &buf, 8) != 8)
+  unsigned char p[8];
+  if (read (fd, p, 8) != 8)
     return false;
 
 #if WORDS_BIG_ENDIAN
   unsigned char c;
-  c = buf[0]; buf[0] = buf[7]; buf[7] = c;
-  c = buf[1]; buf[1] = buf[6]; buf[6] = c;
-  c = buf[2]; buf[2] = buf[5]; buf[5] = c;
-  c = buf[3]; buf[3] = buf[4]; buf[4] = c;
+  c = p[0]; p[0] = p[7]; p[7] = c;
+  c = p[1]; p[1] = p[6]; p[6] = c;
+  c = p[2]; p[2] = p[5]; p[5] = c;
+  c = p[3]; p[3] = p[4]; p[4] = c;
 #endif
 
-  f = *(reinterpret_cast<double*>(buf));
+  double *pd = reinterpret_cast<double*>(&p[0]);
+  f = *pd;
 
   return true;
 }
@@ -467,7 +468,7 @@ WindaqFile::ReadHeader ()
   if (m_bLegacy_format)
      m_sample_rate = (double) m_sr_numer / (double) (m_sr_denom * m_nChannels);
   else
-         m_sample_rate = (double) m_nChannels / m_time_between_channel_samples;
+     m_sample_rate = (double) 1 / m_time_between_channel_samples;
 
   lseek (m_fd, 36, SEEK_SET);
   if (! read_int4 (m_fd, m_time_acq_start))