ref: 25efd2a029c8ac262f84f92a49fe4c13a323f148
parent: c61a5fec6258b484fc7e5fbd2a088eff1c4571be
author: cbagwell <cbagwell>
date: Sun Mar 14 15:30:51 EST 1999
Adding new formats to wav and fixed ctrl-c problem in hardware modules
--- a/TODO
+++ b/TODO
@@ -7,7 +7,13 @@
But of course, MS is pushing very hard to make their version the
standard, weither inferer or not.
- o Add GSM support to WAV format.
+ o I've add the most common and public standard FormatTags to the
+ .wav file detection. A lot of them should be implemented since
+ you can grab the source code from the .au handler and software
+ is avaliable from public sources for the rest.
+
+ o Add GSM support to WAV format. Goes with the above but used
+ most often.
o highpass and lowpass filters don't let you specify the cut
of freq. Need some improvements to these filters.
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -131,6 +131,9 @@
r_params.fragments_min = 1;
ioctl(fileno(ft->fp), SND_PCM_IOCTL_RECORD_PARAMS, &r_params);
+ /* Change to non-buffered I/O */
+ setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
+
sigintreg(ft); /* Prepare to catch SIGINT */
}
@@ -221,7 +224,8 @@
p_params.fragments_room = 1;
ioctl(fileno(ft->fp), SND_PCM_IOCTL_PLAYBACK_PARAMS, &p_params);
- sigintreg(ft);
+ /* Change to non-buffered I/O */
+ setvbuf(ft->fp, NULL, _IONBUF, sizeof(char) * ft->file.size);
}
#endif
--- a/src/oss.c
+++ b/src/oss.c
@@ -111,6 +111,9 @@
ft->info.rate = tmp;
}
+ /* Change to unbuffered mode*/
+ setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
+
sigintreg(ft); /* Prepare to catch SIGINT */
}
@@ -194,6 +197,9 @@
ft->info.rate, tmp);
ft->info.rate = tmp;
}
+
+ /* Change to non-buffered I/O */
+ setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
}
#endif
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -113,6 +113,8 @@
if (audio_if.record.encoding != encoding) {
fail("Unable to initialize style for /dev/audio");
}
+ /* Change to non-buffered I/O*/
+ setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
sigintreg(ft); /* Prepare to catch SIGINT */
}
@@ -191,7 +193,8 @@
if (audio_if.play.encoding != encoding) {
fail("Unable to initialize style for /dev/audio");
}
- sigintreg(ft);
+ /* Change to non-buffered I/O */
+ setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
}
#endif
--- a/src/wav.c
+++ b/src/wav.c
@@ -51,10 +51,20 @@
* User options should override file header - we assumed user knows what
* they are doing if they specify options.
* Enhancements and clean up by Graeme W. Gill, 93/5/17
+ *
+ * Info for format tags can be found at:
+ * http://www.microsoft.com/asf/resources/draft-ietf-fleischman-codec-subtree-01.txt
+ *
*/
#include <string.h> /* Included for strncmp */
#include <stdlib.h> /* Included for malloc and free */
+#include <stdio.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* For SEEK_* defines if not found in stdio */
+#endif
+
#include "st.h"
#include "wav.h"
@@ -511,6 +521,9 @@
else
warn("User options overriding style read in .wav header");
break;
+
+ case WAVE_FORMAT_IEEE_FLOAT:
+ fail("Sorry, this WAV file is in IEEE Float format.");
case WAVE_FORMAT_ALAW:
if (ft->info.style == -1 || ft->info.style == ALAW)
@@ -532,12 +545,26 @@
fail("Sorry, this WAV file is in Digistd format.");
case WAVE_FORMAT_DIGIFIX:
fail("Sorry, this WAV file is in Digifix format.");
- case IBM_FORMAT_MULAW:
- fail("Sorry, this WAV file is in IBM U-law format.");
- case IBM_FORMAT_ALAW:
- fail("Sorry, this WAV file is in IBM A-law format.");
- case IBM_FORMAT_ADPCM:
- fail("Sorry, this WAV file is in IBM ADPCM format.");
+ case WAVE_FORMAT_DOLBY_AC2:
+ fail("Sorry, this WAV file is in Dolby AC2 format.");
+ case WAVE_FORMAT_GSM610:
+ fail("Sorry, this WAV file is in GSM 6.10 format.");
+ case WAVE_FORMAT_ROCKWELL_ADPCM:
+ fail("Sorry, this WAV file is in Rockwell ADPCM format.");
+ case WAVE_FORMAT_ROCKWELL_DIGITALK:
+ fail("Sorry, this WAV file is in Rockwell DIGITALK format.");
+ case WAVE_FORMAT_G721_ADPCM:
+ fail("Sorry, this WAV file is in G.721 ADPCM format.");
+ case WAVE_FORMAT_G728_CELP:
+ fail("Sorry, this WAV file is in G.728 CELP format.");
+ case WAVE_FORMAT_MPEG:
+ fail("Sorry, this WAV file is in MPEG format.");
+ case WAVE_FORMAT_MPEGLAYER3:
+ fail("Sorry, this WAV file is in MPEG Layer 3 format.");
+ case WAVE_FORMAT_G726_ADPCM:
+ fail("Sorry, this WAV file is in G.726 ADPCM format.");
+ case WAVE_FORMAT_G722_ADPCM:
+ fail("Sorry, this WAV file is in G.722 ADPCM format.");
default: fail("WAV file has unknown format type of %x",wav->formatTag);
}
@@ -953,7 +980,7 @@
/* the number of samples in a field, seek back and write them here. */
if (!ft->seekable)
return;
- if (fseek(ft->fp, 0L, 0) != 0)
+ if (fseek(ft->fp, 0L, SEEK_SET) != 0)
fail("Sorry, can't rewind output file to rewrite .wav header.");
((wav_t) ft->priv)->second_header = 1;
wavwritehdr(ft);
@@ -974,6 +1001,8 @@
return "Microsoft PCM";
case WAVE_FORMAT_ADPCM:
return "Microsoft ADPCM";
+ case WAVE_FORMAT_IEEE_FLOAT:
+ return "IEEE Float";
case WAVE_FORMAT_ALAW:
return "Microsoft A-law";
case WAVE_FORMAT_MULAW:
@@ -986,12 +1015,26 @@
return "Digistd format.";
case WAVE_FORMAT_DIGIFIX:
return "Digifix format.";
- case IBM_FORMAT_MULAW:
- return "IBM U-law format.";
- case IBM_FORMAT_ALAW:
- return "IBM A-law";
- case IBM_FORMAT_ADPCM:
- return "IBM ADPCM";
+ case WAVE_FORMAT_DOLBY_AC2:
+ return "Dolby AC2";
+ case WAVE_FORMAT_GSM610:
+ return "GSM 6.10";
+ case WAVE_FORMAT_ROCKWELL_ADPCM:
+ return "Rockwell ADPCM";
+ case WAVE_FORMAT_ROCKWELL_DIGITALK:
+ return "Rockwell DIGITALK";
+ case WAVE_FORMAT_G721_ADPCM:
+ return "G.721 ADPCM";
+ case WAVE_FORMAT_G728_CELP:
+ return "G.728 CELP";
+ case WAVE_FORMAT_MPEG:
+ return "MPEG";
+ case WAVE_FORMAT_MPEGLAYER3:
+ return "MPEG Layer 3";
+ case WAVE_FORMAT_G726_ADPCM:
+ return "G.726 ADPCM";
+ case WAVE_FORMAT_G722_ADPCM:
+ return "G.722 ADPCM";
default:
return "Unknown";
}
--- a/src/wav.h
+++ b/src/wav.h
@@ -8,6 +8,7 @@
#define WAVE_FORMAT_UNKNOWN (0x0000)
#define WAVE_FORMAT_PCM (0x0001)
#define WAVE_FORMAT_ADPCM (0x0002)
+#define WAVE_FORMAT_IEEE_FLOAT (0x0003)
#define WAVE_FORMAT_ALAW (0x0006)
#define WAVE_FORMAT_MULAW (0x0007)
#define WAVE_FORMAT_OKI_ADPCM (0x0010)
@@ -14,9 +15,16 @@
#define WAVE_FORMAT_IMA_ADPCM (0x0011)
#define WAVE_FORMAT_DIGISTD (0x0015)
#define WAVE_FORMAT_DIGIFIX (0x0016)
-#define IBM_FORMAT_MULAW (0x0101)
-#define IBM_FORMAT_ALAW (0x0102)
-#define IBM_FORMAT_ADPCM (0x0103)
+#define WAVE_FORMAT_DOLBY_AC2 (0x0030)
+#define WAVE_FORMAT_GSM610 (0x0031)
+#define WAVE_FORMAT_ROCKWELL_ADPCM (0x003b)
+#define WAVE_FORMAT_ROCKWELL_DIGITALK (0x003c)
+#define WAVE_FORMAT_G721_ADPCM (0x0040)
+#define WAVE_FORMAT_G728_CELP (0x0041)
+#define WAVE_FORMAT_MPEG (0x0050)
+#define WAVE_FORMAT_MPEGLAYER3 (0x0055)
+#define WAVE_FORMAT_G726_ADPCM (0x0064)
+#define WAVE_FORMAT_G722_ADPCM (0x0065)
typedef struct MsState {
LONG index; /* Index into step size table */