1 /* test_streams - Simple test pattern generator
2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #if defined _MSC_VER || defined __MINGW32__
31 #include "FLAC/assert.h"
32 #include "FLAC/ordinals.h"
35 /* math.h in VC++ doesn't seem to have this (how Microsoft is that?) */
36 #define M_PI 3.14159265358979323846
39 #if defined _WIN32 || defined __EMX__
40 static const char *mode = "wb";
42 static const char *mode = "w";
45 #if !defined _MSC_VER && !defined __MINGW32__
46 #define GET_RANDOM_BYTE (((unsigned)random()) & 0xff)
48 #define GET_RANDOM_BYTE (((unsigned)rand()) & 0xff)
51 static FLAC__bool is_big_endian_host;
54 static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 x)
58 fputc(x >> 8, f) != EOF
62 static FLAC__bool write_little_endian_int16(FILE *f, FLAC__int16 x)
64 return write_little_endian_uint16(f, (FLAC__uint16)x);
67 static FLAC__bool write_little_endian_uint24(FILE *f, FLAC__uint32 x)
71 fputc(x >> 8, f) != EOF &&
72 fputc(x >> 16, f) != EOF
76 static FLAC__bool write_little_endian_int24(FILE *f, FLAC__int32 x)
78 return write_little_endian_uint24(f, (FLAC__uint32)x);
81 static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x)
85 fputc(x >> 8, f) != EOF &&
86 fputc(x >> 16, f) != EOF &&
87 fputc(x >> 24, f) != EOF
92 /* @@@ not used (yet) */
93 static FLAC__bool write_little_endian_int32(FILE *f, FLAC__int32 x)
95 return write_little_endian_uint32(f, (FLAC__uint32)x);
99 static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 x)
102 fputc(x >> 8, f) != EOF &&
108 /* @@@ not used (yet) */
109 static FLAC__bool write_big_endian_int16(FILE *f, FLAC__int16 x)
111 return write_big_endian_uint16(f, (FLAC__uint16)x);
116 /* @@@ not used (yet) */
117 static FLAC__bool write_big_endian_uint24(FILE *f, FLAC__uint32 x)
120 fputc(x >> 16, f) != EOF &&
121 fputc(x >> 8, f) != EOF &&
128 /* @@@ not used (yet) */
129 static FLAC__bool write_big_endian_int24(FILE *f, FLAC__int32 x)
131 return write_big_endian_uint24(f, (FLAC__uint32)x);
135 static FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 x)
138 fputc(x >> 24, f) != EOF &&
139 fputc(x >> 16, f) != EOF &&
140 fputc(x >> 8, f) != EOF &&
146 /* @@@ not used (yet) */
147 static FLAC__bool write_big_endian_int32(FILE *f, FLAC__int32 x)
149 return write_big_endian_uint32(f, (FLAC__uint32)x);
153 static FLAC__bool write_sane_extended(FILE *f, unsigned val)
154 /* Write to 'f' a SANE extended representation of 'val'. Return false if
155 * the write succeeds; return true otherwise.
157 * SANE extended is an 80-bit IEEE-754 representation with sign bit, 15 bits
158 * of exponent, and 64 bits of significand (mantissa). Unlike most IEEE-754
159 * representations, it does not imply a 1 above the MSB of the significand.
165 unsigned int shift, exponent;
167 FLAC__ASSERT(val!=0U); /* handling 0 would require a special case */
169 for(shift= 0U; (val>>(31-shift))==0U; ++shift)
172 exponent= 63U-(shift+32U); /* add 32 for unused second word */
174 if(!write_big_endian_uint16(f, (FLAC__uint16)(exponent+0x3FFF)))
176 if(!write_big_endian_uint32(f, val))
178 if(!write_big_endian_uint32(f, 0)) /* unused second word */
184 /* a mono one-sample 16bps stream */
185 static FLAC__bool generate_01(void)
188 FLAC__int16 x = -32768;
190 if(0 == (f = fopen("test01.raw", mode)))
193 if(!write_little_endian_int16(f, x))
203 /* a stereo one-sample 16bps stream */
204 static FLAC__bool generate_02(void)
207 FLAC__int16 xl = -32768, xr = 32767;
209 if(0 == (f = fopen("test02.raw", mode)))
212 if(!write_little_endian_int16(f, xl))
214 if(!write_little_endian_int16(f, xr))
224 /* a mono five-sample 16bps stream */
225 static FLAC__bool generate_03(void)
228 FLAC__int16 x[] = { -25, 0, 25, 50, 100 };
231 if(0 == (f = fopen("test03.raw", mode)))
234 for(i = 0; i < 5; i++)
235 if(!write_little_endian_int16(f, x[i]))
245 /* a stereo five-sample 16bps stream */
246 static FLAC__bool generate_04(void)
249 FLAC__int16 x[] = { -25, 500, 0, 400, 25, 300, 50, 200, 100, 100 };
252 if(0 == (f = fopen("test04.raw", mode)))
255 for(i = 0; i < 10; i++)
256 if(!write_little_endian_int16(f, x[i]))
266 /* a mono full-scale deflection 8bps stream */
267 static FLAC__bool generate_fsd8(const char *fn, const int pattern[], unsigned reps)
272 FLAC__ASSERT(pattern != 0);
274 if(0 == (f = fopen(fn, mode)))
277 for(rep = 0; rep < reps; rep++) {
278 for(p = 0; pattern[p]; p++) {
279 signed char x = pattern[p] > 0? 127 : -128;
280 if(fwrite(&x, sizeof(x), 1, f) < 1)
292 /* a mono full-scale deflection 16bps stream */
293 static FLAC__bool generate_fsd16(const char *fn, const int pattern[], unsigned reps)
298 FLAC__ASSERT(pattern != 0);
300 if(0 == (f = fopen(fn, mode)))
303 for(rep = 0; rep < reps; rep++) {
304 for(p = 0; pattern[p]; p++) {
305 FLAC__int16 x = pattern[p] > 0? 32767 : -32768;
306 if(!write_little_endian_int16(f, x))
318 /* a stereo wasted-bits-per-sample 16bps stream */
319 static FLAC__bool generate_wbps16(const char *fn, unsigned samples)
324 if(0 == (f = fopen(fn, mode)))
327 for(sample = 0; sample < samples; sample++) {
328 FLAC__int16 l = (sample % 2000) << 2;
329 FLAC__int16 r = (sample % 1000) << 3;
330 if(!write_little_endian_int16(f, l))
332 if(!write_little_endian_int16(f, r))
343 /* a mono full-scale deflection 24bps stream */
344 static FLAC__bool generate_fsd24(const char *fn, const int pattern[], unsigned reps)
349 FLAC__ASSERT(pattern != 0);
351 if(0 == (f = fopen(fn, mode)))
354 for(rep = 0; rep < reps; rep++) {
355 for(p = 0; pattern[p]; p++) {
356 FLAC__int32 x = pattern[p] > 0? 8388607 : -8388608;
357 if(!write_little_endian_int24(f, x))
369 /* a mono sine-wave 8bps stream */
370 static FLAC__bool generate_sine8_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2)
372 const FLAC__int8 full_scale = 127;
373 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
374 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
376 double theta1, theta2;
379 if(0 == (f = fopen(fn, mode)))
382 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
383 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
384 FLAC__int8 v = (FLAC__int8)(val + 0.5);
385 if(fwrite(&v, sizeof(v), 1, f) < 1)
396 /* a stereo sine-wave 8bps stream */
397 static FLAC__bool generate_sine8_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)
399 const FLAC__int8 full_scale = 127;
400 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
401 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
403 double theta1, theta2;
406 if(0 == (f = fopen(fn, mode)))
409 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
410 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
411 FLAC__int8 v = (FLAC__int8)(val + 0.5);
412 if(fwrite(&v, sizeof(v), 1, f) < 1)
414 val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale;
415 v = (FLAC__int8)(val + 0.5);
416 if(fwrite(&v, sizeof(v), 1, f) < 1)
427 /* a mono sine-wave 16bps stream */
428 static FLAC__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)
430 const FLAC__int16 full_scale = 32767;
431 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
432 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
434 double theta1, theta2;
437 if(0 == (f = fopen(fn, mode)))
440 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
441 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
442 FLAC__int16 v = (FLAC__int16)(val + 0.5);
443 if(!write_little_endian_int16(f, v))
454 /* a stereo sine-wave 16bps stream */
455 static FLAC__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)
457 const FLAC__int16 full_scale = 32767;
458 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
459 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
461 double theta1, theta2;
464 if(0 == (f = fopen(fn, mode)))
467 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
468 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
469 FLAC__int16 v = (FLAC__int16)(val + 0.5);
470 if(!write_little_endian_int16(f, v))
472 val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale;
473 v = (FLAC__int16)(val + 0.5);
474 if(!write_little_endian_int16(f, v))
485 /* a mono sine-wave 24bps stream */
486 static FLAC__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)
488 const FLAC__int32 full_scale = 0x7fffff;
489 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
490 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
492 double theta1, theta2;
495 if(0 == (f = fopen(fn, mode)))
498 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
499 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
500 FLAC__int32 v = (FLAC__int32)(val + 0.5);
501 if(!write_little_endian_int24(f, v))
512 /* a stereo sine-wave 24bps stream */
513 static FLAC__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)
515 const FLAC__int32 full_scale = 0x7fffff;
516 const double delta1 = 2.0 * M_PI / ( sample_rate / f1);
517 const double delta2 = 2.0 * M_PI / ( sample_rate / f2);
519 double theta1, theta2;
522 if(0 == (f = fopen(fn, mode)))
525 for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) {
526 double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale;
527 FLAC__int32 v = (FLAC__int32)(val + 0.5);
528 if(!write_little_endian_int24(f, v))
530 val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale;
531 v = (FLAC__int32)(val + 0.5);
532 if(!write_little_endian_int24(f, v))
543 static FLAC__bool generate_noise(const char *fn, unsigned bytes)
548 if(0 == (f = fopen(fn, mode)))
551 for(b = 0; b < bytes; b++) {
552 #if !defined _MSC_VER && !defined __MINGW32__
553 FLAC__byte x = (FLAC__byte)(((unsigned)random()) & 0xff);
555 FLAC__byte x = (FLAC__byte)(((unsigned)rand()) & 0xff);
557 if(fwrite(&x, sizeof(x), 1, f) < 1)
568 static FLAC__bool generate_aiff(const char *filename, unsigned sample_rate, unsigned channels, unsigned bps, unsigned samples)
570 const unsigned true_size = channels * ((bps+7)/8) * samples;
571 const unsigned padded_size = (true_size + 1) & (~1u);
572 const unsigned shift = 8 - (bps%8);
576 if(0 == (f = fopen(filename, mode)))
578 if(fwrite("FORM", 1, 4, f) < 4)
580 if(!write_big_endian_uint32(f, padded_size + 46))
582 if(fwrite("AIFFCOMM\000\000\000\022", 1, 12, f) < 12)
584 if(!write_big_endian_uint16(f, (FLAC__uint16)channels))
586 if(!write_big_endian_uint32(f, samples))
588 if(!write_big_endian_uint16(f, (FLAC__uint16)bps))
590 if(!write_sane_extended(f, sample_rate))
592 if(fwrite("SSND", 1, 4, f) < 4)
594 if(!write_big_endian_uint32(f, true_size + 8))
596 if(fwrite("\000\000\000\000\000\000\000\000", 1, 8, f) < 8)
599 for(i = 0; i < true_size; i++)
600 if(fputc(GET_RANDOM_BYTE<<shift, f) == EOF)
602 for( ; i < padded_size; i++)
603 if(fputc(0, f) == EOF)
613 static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsigned channels, unsigned bps, unsigned samples, FLAC__bool strict)
615 const FLAC__bool waveformatextensible = strict && (channels > 2 || (bps%8));
617 * (bps%8) allows 24 bps which is technically supposed to be WAVEFORMATEXTENSIBLE but we
618 * write 24bps as WAVEFORMATEX since it's unambiguous and matches how flac writes it
620 const unsigned true_size = channels * ((bps+7)/8) * samples;
621 const unsigned padded_size = (true_size + 1) & (~1u);
622 const unsigned shift = (bps%8)? 8 - (bps%8) : 0;
626 if(0 == (f = fopen(filename, mode)))
628 if(fwrite("RIFF", 1, 4, f) < 4)
630 if(!write_little_endian_uint32(f, padded_size + (waveformatextensible?60:36)))
632 if(fwrite("WAVEfmt ", 1, 8, f) < 8)
634 if(!write_little_endian_uint32(f, waveformatextensible?40:16))
636 if(!write_little_endian_uint16(f, (FLAC__uint16)(waveformatextensible?65534:1)))
638 if(!write_little_endian_uint16(f, (FLAC__uint16)channels))
640 if(!write_little_endian_uint32(f, sample_rate))
642 if(!write_little_endian_uint32(f, sample_rate * channels * ((bps+7)/8)))
644 if(!write_little_endian_uint16(f, (FLAC__uint16)(channels * ((bps+7)/8)))) /* block align */
646 if(!write_little_endian_uint16(f, (FLAC__uint16)(bps+shift)))
648 if(waveformatextensible) {
649 if(!write_little_endian_uint16(f, (FLAC__uint16)22)) /* cbSize */
651 if(!write_little_endian_uint16(f, (FLAC__uint16)bps)) /* validBitsPerSample */
653 if(!write_little_endian_uint32(f, 0)) /* channelMask */
655 /* GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} */
656 if(fwrite("\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71", 1, 16, f) != 16)
659 if(fwrite("data", 1, 4, f) < 4)
661 if(!write_little_endian_uint32(f, true_size))
664 for(i = 0; i < true_size; i++)
665 if(fputc(GET_RANDOM_BYTE<<shift, f) == EOF)
667 for( ; i < padded_size; i++)
668 if(fputc(0, f) == EOF)
678 static FLAC__bool generate_wackywavs(void)
682 'R', 'I', 'F', 'F', 76, 0, 0, 0,
683 'W', 'A', 'V', 'E', 'f', 'a', 'c', 't',
684 4, 0, 0, 0 , 'b', 'l', 'a', 'h',
685 'p', 'a', 'd', ' ', 4, 0, 0, 0,
686 'B', 'L', 'A', 'H', 'f', 'm', 't', ' ',
687 16, 0, 0, 0, 1, 0, 1, 0,
688 0x44,0xAC, 0, 0, 0, 0, 0, 0,
689 2, 0, 16, 0, 'd', 'a', 't', 'a',
690 16, 0, 0, 0, 0, 0, 1, 0,
691 4, 0, 9, 0, 16, 0, 25, 0,
692 36, 0, 49, 0, 'p', 'a', 'd', ' ',
693 4, 0, 0, 0, 'b', 'l', 'a', 'h'
696 if(0 == (f = fopen("wacky1.wav", mode)))
698 if(fwrite(wav, 1, 84, f) < 84)
703 if(0 == (f = fopen("wacky2.wav", mode)))
705 if(fwrite(wav, 1, 96, f) < 96)
715 int main(int argc, char *argv[])
717 FLAC__uint32 test = 1;
720 int pattern01[] = { 1, -1, 0 };
721 int pattern02[] = { 1, 1, -1, 0 };
722 int pattern03[] = { 1, -1, -1, 0 };
723 int pattern04[] = { 1, -1, 1, -1, 0 };
724 int pattern05[] = { 1, -1, -1, 1, 0 };
725 int pattern06[] = { 1, -1, 1, 1, -1, 0 };
726 int pattern07[] = { 1, -1, -1, 1, -1, 0 };
730 is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true;
732 #if !defined _MSC_VER && !defined __MINGW32__
736 if(gettimeofday(&tv, 0) < 0) {
737 fprintf(stderr, "WARNING: couldn't seed RNG with time\n");
746 if(!generate_01()) return 1;
747 if(!generate_02()) return 1;
748 if(!generate_03()) return 1;
749 if(!generate_04()) return 1;
751 if(!generate_fsd8("fsd8-01.raw", pattern01, 100)) return 1;
752 if(!generate_fsd8("fsd8-02.raw", pattern02, 100)) return 1;
753 if(!generate_fsd8("fsd8-03.raw", pattern03, 100)) return 1;
754 if(!generate_fsd8("fsd8-04.raw", pattern04, 100)) return 1;
755 if(!generate_fsd8("fsd8-05.raw", pattern05, 100)) return 1;
756 if(!generate_fsd8("fsd8-06.raw", pattern06, 100)) return 1;
757 if(!generate_fsd8("fsd8-07.raw", pattern07, 100)) return 1;
759 if(!generate_fsd16("fsd16-01.raw", pattern01, 100)) return 1;
760 if(!generate_fsd16("fsd16-02.raw", pattern02, 100)) return 1;
761 if(!generate_fsd16("fsd16-03.raw", pattern03, 100)) return 1;
762 if(!generate_fsd16("fsd16-04.raw", pattern04, 100)) return 1;
763 if(!generate_fsd16("fsd16-05.raw", pattern05, 100)) return 1;
764 if(!generate_fsd16("fsd16-06.raw", pattern06, 100)) return 1;
765 if(!generate_fsd16("fsd16-07.raw", pattern07, 100)) return 1;
767 if(!generate_fsd24("fsd24-01.raw", pattern01, 100)) return 1;
768 if(!generate_fsd24("fsd24-02.raw", pattern02, 100)) return 1;
769 if(!generate_fsd24("fsd24-03.raw", pattern03, 100)) return 1;
770 if(!generate_fsd24("fsd24-04.raw", pattern04, 100)) return 1;
771 if(!generate_fsd24("fsd24-05.raw", pattern05, 100)) return 1;
772 if(!generate_fsd24("fsd24-06.raw", pattern06, 100)) return 1;
773 if(!generate_fsd24("fsd24-07.raw", pattern07, 100)) return 1;
775 if(!generate_wbps16("wbps16-01.raw", 1000)) return 1;
777 if(!generate_sine8_1("sine8-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
778 if(!generate_sine8_1("sine8-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
779 if(!generate_sine8_1("sine8-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
780 if(!generate_sine8_1("sine8-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
781 if(!generate_sine8_1("sine8-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
783 if(!generate_sine8_2("sine8-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
784 if(!generate_sine8_2("sine8-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
785 if(!generate_sine8_2("sine8-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
786 if(!generate_sine8_2("sine8-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
787 if(!generate_sine8_2("sine8-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
788 if(!generate_sine8_2("sine8-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
789 if(!generate_sine8_2("sine8-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
790 if(!generate_sine8_2("sine8-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
791 if(!generate_sine8_2("sine8-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
792 if(!generate_sine8_2("sine8-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
794 if(!generate_sine16_1("sine16-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
795 if(!generate_sine16_1("sine16-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
796 if(!generate_sine16_1("sine16-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
797 if(!generate_sine16_1("sine16-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
798 if(!generate_sine16_1("sine16-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
800 if(!generate_sine16_2("sine16-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
801 if(!generate_sine16_2("sine16-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
802 if(!generate_sine16_2("sine16-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
803 if(!generate_sine16_2("sine16-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
804 if(!generate_sine16_2("sine16-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
805 if(!generate_sine16_2("sine16-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
806 if(!generate_sine16_2("sine16-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
807 if(!generate_sine16_2("sine16-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
808 if(!generate_sine16_2("sine16-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
809 if(!generate_sine16_2("sine16-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
811 if(!generate_sine24_1("sine24-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
812 if(!generate_sine24_1("sine24-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
813 if(!generate_sine24_1("sine24-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
814 if(!generate_sine24_1("sine24-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
815 if(!generate_sine24_1("sine24-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
817 if(!generate_sine24_2("sine24-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
818 if(!generate_sine24_2("sine24-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
819 if(!generate_sine24_2("sine24-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
820 if(!generate_sine24_2("sine24-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
821 if(!generate_sine24_2("sine24-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
822 if(!generate_sine24_2("sine24-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
823 if(!generate_sine24_2("sine24-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
824 if(!generate_sine24_2("sine24-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
825 if(!generate_sine24_2("sine24-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
826 if(!generate_sine24_2("sine24-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
828 /* WATCHOUT: the size of noise.raw is hardcoded into test/test_flac.sh */
829 if(!generate_noise("noise.raw", 65536 * 8 * 3)) return 1;
830 if(!generate_noise("noise8m32.raw", 32)) return 1;
831 if(!generate_wackywavs()) return 1;
832 for(channels = 1; channels <= 8; channels++) {
833 unsigned bits_per_sample;
834 for(bits_per_sample = 4; bits_per_sample <= 24; bits_per_sample++) {
835 static const unsigned nsamples[] = { 1, 111, 4777 } ;
837 for(samples = 0; samples < sizeof(nsamples)/sizeof(nsamples[0]); samples++) {
840 sprintf(fn, "rt-%u-%u-%u.aiff", channels, bits_per_sample, nsamples[samples]);
841 if(!generate_aiff(fn, 44100, channels, bits_per_sample, nsamples[samples]))
844 sprintf(fn, "rt-%u-%u-%u.wav", channels, bits_per_sample, nsamples[samples]);
845 if(!generate_wav(fn, 44100, channels, bits_per_sample, nsamples[samples], /*strict=*/true))
848 if(bits_per_sample % 8 == 0) {
849 sprintf(fn, "rt-%u-%u-%u.raw", channels, bits_per_sample, nsamples[samples]);
850 if(!generate_noise(fn, channels * bits_per_sample/8 * nsamples[samples]))