At one time GoldWave was used to screen data files, and to convert them to a format readable by SETIEasy for automated screening. The data analysts switched to CoolEdit 2000 for the most part, largely because that program's frequency analysis and extended integration features permitted detection of smaller signals and more precise frequency measurements. The code in WAV2RAW was subsequently incorporated into SETIEasy with the permission of Dan Kennedy.


From: Dan Kennedy
Date: 3/4/00
Time: 2:14:16 AM

I have a test executable for converting WAV files to ASCII Float RAW files. It works well in batch files.

Usage: wav2raw sourcefile.wav sourcefile.raw

The sourcefile.wav should be replaced with the name of the downloaded WAV file. The sourcefile.raw should be the filename you want as the raw file.

For example.

wav2raw Feb_28_2000_01_17_00_utc_2.wav Feb_28_2000_01_17_00_utc_2.raw

It runs fairly quickly. It converts the 7 Mb 15 minute files in 3 minutes. GoldWave can do the same file in 1 and a half minutes. But the batch capability is what we were looking for.

If an error occurs, the program returns an errorlevel that can be detected in batch files. The following batch file will run SETIEasy only if wav2raw succeeds.

wav2raw Feb_28_2000_01_17_00_utc_2.wav Feb_28_2000_01_17_00_utc_2.raw
if errorlevel 1 echo Wav2RAW failed
if NOT errorlevel 1 SETIEasy_v123.exe Feb_28_2000_01_17_00_utc_2.raw Feb_28_2000_01_17_00_utc_2.txt Feb_28_2000_01_17_00_utc_2g.txt

A sequence of these in a batch file will run multiple files into setieasy. Only files that succeed the conversion will run in setieasy.

The source code for wav2raw.c follows. This Windows executable can be found at wav2raw.exe . If anyone compiles the file for other platforms, you could email the executable to me and I will make it available on the server here. We should test and refine this first of course.

One improvement comes to mind right away. The code could search a directory and convert all wav files that do not already have raw counterparts. 

- Dan

#include<stdio.h>
#include<stdlib.h>

void main( int argc, char *argv[ ]) {

FILE *infile, *outfile;
char prefix[4];
char fileFormat[8];
unsigned char ch;
float byteValue;
unsigned int i;
char ckID[4];
unsigned long nChunkSize;
short int wFormatTag;
short int nChannels;
unsigned long nSamplesPerSecond;
unsigned long nAvgBytesPerSecond;
short int nBlockAlign;
short int nBitsPerSample;

/* Print a copyright. */
printf("WAV to Raw ASCII file Conversion Utility\n");
printf(" Copyright: Dan Kennedy. All are free to use this.\n\n");

/* Test for two files as arguments */
if (argc != 3) {
  printf("Usage: wav2raw sourceWavFile destRawFile\n");
  printf("Success returns errorlevel 0. Error return greater than zero.\n");
  exit(1);
}

/* Open source for binary read (will fail if file does not exist) */
if( (infile = fopen( argv[1], "rb" )) == NULL ) {
  printf( "The source file %s was not opened\n",argv[1] );
  exit(2);
}
else 
  printf( "The source file %s was opened\n",argv[1] );

/* Open output for write */
if( (outfile = fopen( argv[2], "w" )) == NULL ) {
  printf( "The output file %s was not opened\n",argv[2] );
  exit(3);
}
else
  printf( "The output file %s was opened\n",argv[2] );

/* Read the header bytes. */
fscanf( infile, "%4c", prefix );
fscanf( infile, "%4c", &nChunkSize );
fscanf( infile, "%8c", fileFormat );
fscanf( infile, "%4c", &nChunkSize );
fscanf( infile, "%2c", &wFormatTag );
fscanf( infile, "%2c", &nChannels );
fscanf( infile, "%4c", &nSamplesPerSecond );
fscanf( infile, "%4c", &nAvgBytesPerSecond );
fscanf( infile, "%2c", &nBlockAlign );
fscanf( infile, "%2c", &nBitsPerSample );
fscanf( infile, "%4s", &ckID );
fscanf( infile, "%4c", &nChunkSize );

/* Testing on the file format variables would go here.

/* Scan and convert the bytes. */
for( i = 0; (i < nChunkSize);i++ ) {
  fscanf( infile, "%1c", &ch );
  byteValue = ((float)ch-128)/128;
  fprintf(outfile,"%g\n",byteValue);
}

/* All files are closed: */
_fcloseall( );

exit(0);

}