const char* pbackslash = strrchr (filename, '\\');
const char* p = filename;
if (pbackslash && (! pslash || pbackslash >= pslash))
const char* pbackslash = strrchr (filename, '\\');
const char* p = filename;
if (pbackslash && (! pslash || pbackslash >= pslash))
while ((c = getopt (argc, argv, "rqvzmdph")) != -1) {
switch (c) {
case 'r':
std::cout << "Version " << g_szIdStr << std::endl;
while ((c = getopt (argc, argv, "rqvzmdph")) != -1) {
switch (c) {
case 'r':
std::cout << "Version " << g_szIdStr << std::endl;
std::cout << "Enter channel number: ";
std::cin.getline (channel_buf, MAX_INPUT_STR);
}
std::cout << "Enter channel number: ";
std::cin.getline (channel_buf, MAX_INPUT_STR);
}
char *channel_endptr;
int channel = static_cast<int>(strtol (channel_buf, &channel_endptr, 10));
if (*channel_endptr != 0) {
char *channel_endptr;
int channel = static_cast<int>(strtol (channel_buf, &channel_endptr, 10));
if (*channel_endptr != 0) {
std::cout << "Enter output wav filename: ";
std::cin.getline (wav_fname, MAX_INPUT_STR);
}
std::cout << "Enter output wav filename: ";
std::cin.getline (wav_fname, MAX_INPUT_STR);
}
if (! wdq2wav (wdq_fname, channel, wav_fname, play))
return 1;
if (! wdq2wav (wdq_fname, channel, wav_fname, play))
return 1;
- std::ostringstream os;
- os << "File contains 'packed' channels." << std::endl;
- os << "Convert to 'Advanced CODAS headers' before processing with wdq2wav.";
- error_msg (os.str().c_str());
- return false;
+ std::ostringstream os;
+ os << "File contains 'packed' channels." << std::endl;
+ os << "Convert to 'Advanced CODAS headers' before processing with wdq2wav.";
+ error_msg (os.str().c_str());
+ return false;
- std::ostringstream os;
- os << "Legacy Format: ";
- if (wdq.m_bLegacy_format)
- os << "Yes";
- else
- os << "No";
- info_msg(os.str().c_str());
+ std::ostringstream os;
+ os << "Legacy Format: ";
+ if (wdq.m_bLegacy_format)
+ os << "Yes";
+ else
+ os << "No";
+ info_msg(os.str().c_str());
", Sample Rate: " << wdq.m_sample_rate;
info_msg (os4.str().c_str());
}
", Sample Rate: " << wdq.m_sample_rate;
info_msg (os4.str().c_str());
}
WindaqChannel wdq_channel (wdq, channel);
if (! wdq_channel.m_valid) {
error_msg ("Error reading data from channel");
WindaqChannel wdq_channel (wdq, channel);
if (! wdq_channel.m_valid) {
error_msg ("Error reading data from channel");
", maximum: " << wdq_channel.m_max_raw_data;
info_msg (os3.str().c_str());
}
", maximum: " << wdq_channel.m_max_raw_data;
info_msg (os3.str().c_str());
}
short unsigned int byte1 = (element1 & 0xFF00) >> 8;
short unsigned int byte2 = element1 & 0xFF;
if (byte1 == 0 || byte1 == 1) {
short unsigned int byte1 = (element1 & 0xFF00) >> 8;
short unsigned int byte2 = element1 & 0xFF;
if (byte1 == 0 || byte1 == 1) {
unsigned char element3;
if (! read_int1 (m_fd, element3))
return false;
m_channel_offset = element3;
if (g_debug)
unsigned char element3;
if (! read_int1 (m_fd, element3))
return false;
m_channel_offset = element3;
if (g_debug)
unsigned char element4;
if (! read_int1 (m_fd, element4))
return false;
m_nBytes_channel_header = element4;
if (g_debug)
unsigned char element4;
if (! read_int1 (m_fd, element4))
return false;
m_nBytes_channel_header = element4;
if (g_debug)
unsigned short int element5;
if (! read_int2 (m_fd, element5))
return false;
m_nHeader_bytes = element5;
if (g_debug)
unsigned short int element5;
if (! read_int2 (m_fd, element5))
return false;
m_nHeader_bytes = element5;
if (g_debug)
m_nSamples = (m_nData_bytes / m_nChannels) / 2;
lseek (m_fd, 28, SEEK_SET);
double element13;
if (! read_float8 (m_fd, element13))
m_nSamples = (m_nData_bytes / m_nChannels) / 2;
lseek (m_fd, 28, SEEK_SET);
double element13;
if (! read_float8 (m_fd, element13))
m_time_between_channel_samples = element13;
if (m_bLegacy_format)
m_sample_rate = (double) m_sr_numer / (double) (m_sr_denom * m_nChannels);
m_time_between_channel_samples = element13;
if (m_bLegacy_format)
m_sample_rate = (double) m_sr_numer / (double) (m_sr_denom * m_nChannels);
lseek (m_fd, 36, SEEK_SET);
if (! read_int4 (m_fd, m_time_acq_start))
lseek (m_fd, 36, SEEK_SET);
if (! read_int4 (m_fd, m_time_acq_start))
lseek (m_fd, 100, SEEK_SET);
unsigned short int element27;
if (! read_int2 (m_fd, element27))
lseek (m_fd, 100, SEEK_SET);
unsigned short int element27;
if (! read_int2 (m_fd, element27))
lseek (m_fd, iStart + 31, SEEK_SET);
unsigned char iReadings_per_data_point;
if (! read_int1 (m_fd, iReadings_per_data_point))
lseek (m_fd, iStart + 31, SEEK_SET);
unsigned char iReadings_per_data_point;
if (! read_int1 (m_fd, iReadings_per_data_point))
- lseek (fd, r_wdq.m_channel_offset + 8 +
- (m_channel - 1) * r_wdq.m_nBytes_channel_header,
- SEEK_SET);
+ lseek (fd, r_wdq.m_channel_offset + 8 +
+ (m_channel - 1) * r_wdq.m_nBytes_channel_header,
+ SEEK_SET);
long int row_bytes = 2 * r_wdq.m_nChannels;
signed short int *sample_row = new signed short int [row_bytes];
long int row_bytes = 2 * r_wdq.m_nChannels;
signed short int *sample_row = new signed short int [row_bytes];
signed short int* psample = &sample_row[m_channel - 1];
lseek (fd, r_wdq.m_nHeader_bytes, SEEK_SET);
signed short int* psample = &sample_row[m_channel - 1];
lseek (fd, r_wdq.m_nHeader_bytes, SEEK_SET);
int mean = nearest<int>(dmean);
std::cout << "Removing mean: " << (dmean * m_slope) + m_intercept <<
" " << m_units << std::endl;
int mean = nearest<int>(dmean);
std::cout << "Removing mean: " << (dmean * m_slope) + m_intercept <<
" " << m_units << std::endl;
if (g_ignore_zero) {
data_offset = -wdq_channel.m_min_scaled_data;
if (wdq_channel.m_max_scaled_data != wdq_channel.m_min_scaled_data)
if (g_ignore_zero) {
data_offset = -wdq_channel.m_min_scaled_data;
if (wdq_channel.m_max_scaled_data != wdq_channel.m_min_scaled_data)
} else {
double max_value = fabs(wdq_channel.m_max_scaled_data);
if (fabs (wdq_channel.m_min_scaled_data) > max_value)
} else {
double max_value = fabs(wdq_channel.m_max_scaled_data);
if (fabs (wdq_channel.m_min_scaled_data) > max_value)
if (g_debug) {
std::ostringstream os;
os << " Wav data_scale: " << data_scale << ", data_offset: " << data_offset;
info_msg (os.str().c_str());
}
if (g_debug) {
std::ostringstream os;
os << " Wav data_scale: " << data_scale << ", data_offset: " << data_offset;
info_msg (os.str().c_str());
}
m_nHeaderBytes = 44;
m_nDataBytes = m_nSamples * m_nBytesPerSample * m_nChannels;
m_nFileBytes = m_nHeaderBytes + m_nDataBytes;
m_nHeaderBytes = 44;
m_nDataBytes = m_nSamples * m_nBytesPerSample * m_nChannels;
m_nFileBytes = m_nHeaderBytes + m_nDataBytes;
signed short int* output = &m_data[nHeaderShortInts];
double slope = wdq_channel.m_slope;
double intercept = wdq_channel.m_intercept;
signed short int* output = &m_data[nHeaderShortInts];
double slope = wdq_channel.m_slope;
double intercept = wdq_channel.m_intercept;
signed short int v = static_cast<signed short int>(value);
#if WORDS_BIG_ENDIAN
unsigned char* p = reinterpret_cast<unsigned char*>(&v);
signed short int v = static_cast<signed short int>(value);
#if WORDS_BIG_ENDIAN
unsigned char* p = reinterpret_cast<unsigned char*>(&v);
put_int4 (pData + 28, static_cast<int> (m_rate * m_nBytesPerSample + 0.5));
// Bytes per sample
put_int2 (pData + 32, m_nBytesPerSample * m_nChannels);
put_int4 (pData + 28, static_cast<int> (m_rate * m_nBytesPerSample + 0.5));
// Bytes per sample
put_int2 (pData + 32, m_nBytesPerSample * m_nChannels);
put_int2 (pData + 34, m_nBitsPerSample);
strncpy (pData + 36, "data", 4);
put_int2 (pData + 34, m_nBitsPerSample);
strncpy (pData + 36, "data", 4);
int format = AFMT_S16_LE;
if (ioctl (fd, SNDCTL_DSP_SETFMT, &format) == -1) {
error_msg ("Error setting DSP format");
int format = AFMT_S16_LE;
if (ioctl (fd, SNDCTL_DSP_SETFMT, &format) == -1) {
error_msg ("Error setting DSP format");
unsigned int channels = m_nChannels;
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &format) == -1) {
error_msg ("Error setting number of channels");
unsigned int channels = m_nChannels;
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &format) == -1) {
error_msg ("Error setting number of channels");
os << "Warning: Sample rate set to " << speed << ", not " << m_rate;
error_msg (os.str().c_str());
}
os << "Warning: Sample rate set to " << speed << ", not " << m_rate;
error_msg (os.str().c_str());
}
if (write (fd, reinterpret_cast<char*>(m_data) + m_nHeaderBytes, m_nDataBytes) !=
m_nDataBytes) {
error_msg ("Error writing audio samples");
if (write (fd, reinterpret_cast<char*>(m_data) + m_nHeaderBytes, m_nDataBytes) !=
m_nDataBytes) {
error_msg ("Error writing audio samples");