X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=wdq2wav.cpp;h=1c7791f8617d7b555c88259eb92b2ea996d92e8f;hb=e4d1f87e6c740b201571d14ada9b9dd6f9516949;hp=b72d6fa95b9b7a292aa59d8de444a58bf3afafc0;hpb=f7a2760c0c2cf784090cf5619a43532804ee079b;p=wdq2wav.git diff --git a/wdq2wav.cpp b/wdq2wav.cpp index b72d6fa..1c7791f 100644 --- a/wdq2wav.cpp +++ b/wdq2wav.cpp @@ -8,8 +8,6 @@ ** ** Copyright (c) 2003 Kevin Rosenberg ** -** $Id$ -** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as ** published by the Free Software Foundation. @@ -24,6 +22,7 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ +#include #include const char* g_szIdStr = "$Id$"; @@ -375,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(buf)); + double *pd = reinterpret_cast(&p[0]); + f = *pd; return true; } @@ -468,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)) @@ -807,10 +807,10 @@ WavFile::WriteFile () return true; } -#ifdef WIN32 +#ifdef _WIN32 #include #include -#elif defined(LINUX) +#elif defined(__linux__) #include #include #endif @@ -818,10 +818,10 @@ WavFile::WriteFile () bool WavFile::Play () { -#ifdef WIN32 +#ifdef _WIN32 if (PlaySound ((LPCSTR) m_data, 0, SND_MEMORY | SND_NODEFAULT)) return true; -#elif defined(LINUX) +#elif defined(__linux__) int fd; if ((fd = open ("/dev/dsp",O_WRONLY)) == -1) { error_msg ("Error opening /dev/dsp");