}
}
+static void swap24(byte *x)
+{
+ if(is_big_endian_host) {
+ x[0] = x[1];
+ x[1] = x[2];
+ x[2] = x[3];
+ }
+ else {
+ byte b = x[0];
+ x[0] = x[2];
+ x[2] = b;
+ }
+}
+
/* a mono one-sample 16bps stream */
static bool generate_01()
{
return false;
}
+/* a mono full-scale deflection 24bps stream */
+static bool generate_fsd24(const char *fn, const int pattern[], unsigned reps)
+{
+ FILE *f;
+ unsigned rep, p;
+
+ assert(pattern != 0);
+
+ if(0 == (f = fopen(fn, mode)))
+ return false;
+
+ for(rep = 0; rep < reps; rep++) {
+ for(p = 0; pattern[p]; p++) {
+ int32 x = pattern[p] > 0? 8388607 : -8388608;
+ byte *b = (byte*)(&x);
+ swap24(b);
+ if(fwrite(b, 3, 1, f) < 1)
+ goto foo;
+ }
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
/* a mono sine-wave 16bps stream */
static bool generate_sine16_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2)
{
- const signed short full_scale = 32767;
+ const int16 full_scale = 32767;
const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
FILE *f;
/* a stereo sine-wave 16bps stream */
static bool generate_sine16_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult)
{
- const signed short full_scale = 32767;
+ const int16 full_scale = 32767;
const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
FILE *f;
return false;
}
+/* a mono sine-wave 24bps stream */
+static bool generate_sine24_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2)
+{
+ const int32 full_scale = 0x7fffff;
+ const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
+ const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
+ FILE *f;
+ double theta1, theta2;
+ unsigned i;
+
+ if(0 == (f = fopen(fn, mode)))
+ return false;
+
+ for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
+ double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
+ int32 v = (int32)(val + 0.5);
+ byte *b = (byte*)(&v);
+ swap24(b);
+ if(fwrite(b, 3, 1, f) < 1)
+ goto foo;
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
+/* a stereo sine-wave 24bps stream */
+static bool generate_sine24_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult)
+{
+ const int32 full_scale = 0x7fffff;
+ const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
+ const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
+ FILE *f;
+ double theta1, theta2;
+ unsigned i;
+
+ if(0 == (f = fopen(fn, mode)))
+ return false;
+
+ for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
+ double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
+ int32 v = (int32)(val + 0.5);
+ byte *b = (byte*)(&v);
+ swap24(b);
+ if(fwrite(b, 3, 1, f) < 1)
+ goto foo;
+ val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale;
+ v = (int32)(val + 0.5);
+ swap24(b);
+ if(fwrite(b, 3, 1, f) < 1)
+ goto foo;
+ }
+
+ fclose(f);
+ return true;
+foo:
+ fclose(f);
+ return false;
+}
+
static bool generate_noise(const char *fn, unsigned bytes)
{
FILE *f;
if(!generate_fsd16("fsd16-06.raw", pattern06, 100)) return 1;
if(!generate_fsd16("fsd16-07.raw", pattern07, 100)) return 1;
- if(!generate_sine16_1("sine-00.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49)) return 1;
- if(!generate_sine16_1("sine-01.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37)) return 1;
- if(!generate_sine16_1("sine-02.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49)) return 1;
- if(!generate_sine16_1("sine-03.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49)) return 1;
- if(!generate_sine16_1("sine-04.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
-
- if(!generate_sine16_2("sine-10.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
- if(!generate_sine16_2("sine-11.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
- if(!generate_sine16_2("sine-12.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
- if(!generate_sine16_2("sine-13.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
- if(!generate_sine16_2("sine-14.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
- if(!generate_sine16_2("sine-15.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
- if(!generate_sine16_2("sine-16.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
- if(!generate_sine16_2("sine-17.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
- if(!generate_sine16_2("sine-18.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
- if(!generate_sine16_2("sine-19.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
-
- if(!generate_noise("noise.raw", 65536 * 2)) return 1;
+ if(!generate_fsd24("fsd24-01.raw", pattern01, 100)) return 1;
+ if(!generate_fsd24("fsd24-02.raw", pattern02, 100)) return 1;
+ if(!generate_fsd24("fsd24-03.raw", pattern03, 100)) return 1;
+ if(!generate_fsd24("fsd24-04.raw", pattern04, 100)) return 1;
+ if(!generate_fsd24("fsd24-05.raw", pattern05, 100)) return 1;
+ if(!generate_fsd24("fsd24-06.raw", pattern06, 100)) return 1;
+ if(!generate_fsd24("fsd24-07.raw", pattern07, 100)) return 1;
+
+ if(!generate_sine16_1("sine16-00.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49)) return 1;
+ if(!generate_sine16_1("sine16-01.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37)) return 1;
+ if(!generate_sine16_1("sine16-02.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49)) return 1;
+ if(!generate_sine16_1("sine16-03.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49)) return 1;
+ if(!generate_sine16_1("sine16-04.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
+
+ if(!generate_sine16_2("sine16-10.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
+ if(!generate_sine16_2("sine16-11.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
+ if(!generate_sine16_2("sine16-12.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
+ if(!generate_sine16_2("sine16-13.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
+ if(!generate_sine16_2("sine16-14.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
+ if(!generate_sine16_2("sine16-15.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
+ if(!generate_sine16_2("sine16-16.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
+ if(!generate_sine16_2("sine16-17.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
+ if(!generate_sine16_2("sine16-18.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
+ if(!generate_sine16_2("sine16-19.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
+
+ if(!generate_sine24_1("sine24-00.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49)) return 1;
+ if(!generate_sine24_1("sine24-01.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37)) return 1;
+ if(!generate_sine24_1("sine24-02.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49)) return 1;
+ if(!generate_sine24_1("sine24-03.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49)) return 1;
+ if(!generate_sine24_1("sine24-04.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
+
+ if(!generate_sine24_2("sine24-10.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
+ if(!generate_sine24_2("sine24-11.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
+ if(!generate_sine24_2("sine24-12.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
+ if(!generate_sine24_2("sine24-13.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
+ if(!generate_sine24_2("sine24-14.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
+ if(!generate_sine24_2("sine24-15.raw", 44100.0, 80000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
+ if(!generate_sine24_2("sine24-16.raw", 44100.0, 80000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
+ if(!generate_sine24_2("sine24-17.raw", 44100.0, 80000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
+ if(!generate_sine24_2("sine24-18.raw", 44100.0, 80000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
+ if(!generate_sine24_2("sine24-19.raw", 44100.0, 50000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
+
+ if(!generate_noise("noise.raw", 65536 * 8 * 3)) return 1;
return 0;
}
export LD_LIBRARY_PATH
PATH=../src/flac:../src/test_streams:../obj/bin:$PATH
+echo "Generating streams..."
if test_streams ; then : ; else
echo "ERROR during test_streams" 1>&2
exit 1
test_file fsd16-$b 1 16 "-0 -l 8 -m -e -q 15"
done
-echo "Testing sine wave streams..."
-for b in 00 01 02 03 04 ; do
- test_file sine-$b 1 16 "-0 -l 8 -m -e"
+echo "Testing 24-bit full-scale deflection streams..."
+for b in 01 02 03 04 05 06 07 ; do
+ test_file fsd24-$b 1 24 "-0 -l 8 -m -e -q 7"
done
-for b in 10 11 12 13 14 15 16 17 18 19 ; do
- test_file sine-$b 2 16 "-0 -l 8 -m -e"
+
+for bps in 16 24 ; do
+ echo "Testing $bps-bit sine wave streams..."
+ for b in 00 01 02 03 04 ; do
+ test_file sine${bps}-$b 1 $bps "-0 -l 8 -m -e"
+ done
+ for b in 10 11 12 13 14 15 16 17 18 19 ; do
+ test_file sine${bps}-$b 2 $bps "-0 -l 8 -m -e"
+ done
done
echo "Testing some frame header variations..."
-test_file sine-01 1 16 "-0 -l 8 -m -e --lax -b 16"
-test_file sine-01 1 16 "-0 -l 8 -m -e --lax -b 65535"
-test_file sine-01 1 16 "-0 -l 8 -m -e -b 16"
-test_file sine-01 1 16 "-0 -l 8 -m -e -b 65535"
-test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 9"
-test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 90"
-test_file sine-01 1 16 "-0 -l 8 -m -e --lax -fs 90000"
-test_file sine-01 1 16 "-0 -l 8 -m -e -fs 9"
-test_file sine-01 1 16 "-0 -l 8 -m -e -fs 90"
-test_file sine-01 1 16 "-0 -l 8 -m -e -fs 90000"
+test_file sine16-01 1 16 "-0 -l 8 -m -e --lax -b 16"
+test_file sine16-01 1 16 "-0 -l 8 -m -e --lax -b 65535"
+test_file sine16-01 1 16 "-0 -l 8 -m -e -b 16"
+test_file sine16-01 1 16 "-0 -l 8 -m -e -b 65535"
+test_file sine16-01 1 16 "-0 -l 8 -m -e --lax -fs 9"
+test_file sine16-01 1 16 "-0 -l 8 -m -e --lax -fs 90"
+test_file sine16-01 1 16 "-0 -l 8 -m -e --lax -fs 90000"
+test_file sine16-01 1 16 "-0 -l 8 -m -e -fs 9"
+test_file sine16-01 1 16 "-0 -l 8 -m -e -fs 90"
+test_file sine16-01 1 16 "-0 -l 8 -m -e -fs 90000"
echo "Testing option variations..."
for f in 00 01 02 03 04 ; do
for opt in 0 1 2 4 5 6 8 ; do
for extras in '' '-p' '-e' ; do
- test_file sine-$f 1 16 "-$opt $extras"
+ test_file sine16-$f 1 16 "-$opt $extras"
done
done
done
for f in 10 11 12 13 14 15 16 17 18 19 ; do
for opt in 0 1 2 4 5 6 8 ; do
for extras in '' '-p' '-e' ; do
- test_file sine-$f 2 16 "-$opt $extras"
+ test_file sine16-$f 2 16 "-$opt $extras"
done
done
done
for opt in 0 1 2 4 5 6 8 ; do
for extras in '' '-p' '-e' ; do
for blocksize in '' '-b 32' '-b 32768' '-b 65535' ; do
- for channels in 1 2 4 ; do
- for bps in 8 16 ; do
+ for channels in 1 2 5 8 ; do
+ for bps in 8 16 24 ; do
test_file noise $channels $bps "-$opt $extras $blocksize"
done
done