Daniel J Sebald wrote:
Attached is a patch that enables auload to read WAV files with 24-bit
data width.
Here's a version where I simply added "int24" to the list in documentation.
I looked at ausave(). However, that doesn't use "int16", "int32", etc. to specify format. Rather,
it uses only "short", "long", etc.
Dan
--- auload.m.orig 2008-02-21 00:37:27.000000000 -0600
+++ auload.m 2008-02-26 15:49:51.779385580 -0600
@@ -19,7 +19,7 @@
## Reads an audio waveform from a file given by the string @var{filename}.
## Returns the audio samples in data, one column per channel, one row per
## time slice. Also returns the sample rate and stored format (one of ulaw,
-## alaw, char, int16, int32, float, double). The sample value will be
+## alaw, char, int16, int24, int32, float, double). The sample value will be
## normalized to the range [-1,1] regardless of the stored format.
##
## @example
@@ -132,6 +132,10 @@
sampleformat = 'int16';
precision = 'int16';
samples = len/2;
+ elseif bits == 24
+ sampleformat = 'int24';
+ precision = 'int24';
+ samples = len/3;
elseif bits == 32
sampleformat = 'int32';
precision = 'int32';
@@ -325,7 +329,16 @@
## suck in all the samples
if (samples <= 0) samples = Inf; end
- data = fread(file, samples, precision, 0, arch);
+ if (precision == 'int24')
+ data = fread(file, 3*samples, 'uint8', 0, arch);
+ if (arch == 'ieee-le')
+ data = data(1:3:end) + data(2:3:end) * 2^8 +
cast(typecast(cast(data(3:3:end), 'uint8'), 'int8'), 'double') * 2^16;
+ else
+ data = data(3:3:end) + data(2:3:end) * 2^8 +
cast(typecast(cast(data(1:3:end), 'uint8'), 'int8'), 'double') * 2^16;
+ endif
+ else
+ data = fread(file, samples, precision, 0, arch);
+ endif
fclose(file);
## convert samples into range [-1, 1)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev