1 /* test_streams - Simple test pattern generator
2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 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 _MSC_VER && !defined __MINGW32__
40 #define GET_RANDOM_BYTE (((unsigned)random()) & 0xff)
42 #define GET_RANDOM_BYTE (((unsigned)rand()) & 0xff)
45 static FLAC__bool is_big_endian_host
;
48 static FLAC__bool
write_little_endian(FILE *f
, FLAC__int32 x
, size_t bytes
)
51 if(fputc(x
, f
) == EOF
)
59 static FLAC__bool
write_little_endian_uint16(FILE *f
, FLAC__uint16 x
)
63 fputc(x
>> 8, f
) != EOF
67 static FLAC__bool
write_little_endian_int16(FILE *f
, FLAC__int16 x
)
69 return write_little_endian_uint16(f
, (FLAC__uint16
)x
);
72 static FLAC__bool
write_little_endian_uint24(FILE *f
, FLAC__uint32 x
)
76 fputc(x
>> 8, f
) != EOF
&&
77 fputc(x
>> 16, f
) != EOF
81 static FLAC__bool
write_little_endian_int24(FILE *f
, FLAC__int32 x
)
83 return write_little_endian_uint24(f
, (FLAC__uint32
)x
);
86 static FLAC__bool
write_little_endian_uint32(FILE *f
, FLAC__uint32 x
)
90 fputc(x
>> 8, f
) != EOF
&&
91 fputc(x
>> 16, f
) != EOF
&&
92 fputc(x
>> 24, f
) != EOF
97 /* @@@ not used (yet) */
98 static FLAC__bool
write_little_endian_int32(FILE *f
, FLAC__int32 x
)
100 return write_little_endian_uint32(f
, (FLAC__uint32
)x
);
104 static FLAC__bool
write_big_endian(FILE *f
, FLAC__int32 x
, size_t bytes
)
109 if(fputc(x
>>24, f
) == EOF
)
117 static FLAC__bool
write_big_endian_uint16(FILE *f
, FLAC__uint16 x
)
120 fputc(x
>> 8, f
) != EOF
&&
126 /* @@@ not used (yet) */
127 static FLAC__bool
write_big_endian_int16(FILE *f
, FLAC__int16 x
)
129 return write_big_endian_uint16(f
, (FLAC__uint16
)x
);
134 /* @@@ not used (yet) */
135 static FLAC__bool
write_big_endian_uint24(FILE *f
, FLAC__uint32 x
)
138 fputc(x
>> 16, f
) != EOF
&&
139 fputc(x
>> 8, f
) != EOF
&&
146 /* @@@ not used (yet) */
147 static FLAC__bool
write_big_endian_int24(FILE *f
, FLAC__int32 x
)
149 return write_big_endian_uint24(f
, (FLAC__uint32
)x
);
153 static FLAC__bool
write_big_endian_uint32(FILE *f
, FLAC__uint32 x
)
156 fputc(x
>> 24, f
) != EOF
&&
157 fputc(x
>> 16, f
) != EOF
&&
158 fputc(x
>> 8, f
) != EOF
&&
164 /* @@@ not used (yet) */
165 static FLAC__bool
write_big_endian_int32(FILE *f
, FLAC__int32 x
)
167 return write_big_endian_uint32(f
, (FLAC__uint32
)x
);
171 static FLAC__bool
write_sane_extended(FILE *f
, unsigned val
)
172 /* Write to 'f' a SANE extended representation of 'val'. Return false if
173 * the write succeeds; return true otherwise.
175 * SANE extended is an 80-bit IEEE-754 representation with sign bit, 15 bits
176 * of exponent, and 64 bits of significand (mantissa). Unlike most IEEE-754
177 * representations, it does not imply a 1 above the MSB of the significand.
183 unsigned int shift
, exponent
;
185 FLAC__ASSERT(val
!=0U); /* handling 0 would require a special case */
187 for(shift
= 0U; (val
>>(31-shift
))==0U; ++shift
)
190 exponent
= 63U-(shift
+32U); /* add 32 for unused second word */
192 if(!write_big_endian_uint16(f
, (FLAC__uint16
)(exponent
+0x3FFF)))
194 if(!write_big_endian_uint32(f
, val
))
196 if(!write_big_endian_uint32(f
, 0)) /* unused second word */
202 /* a mono one-sample 16bps stream */
203 static FLAC__bool
generate_01(void)
206 FLAC__int16 x
= -32768;
208 if(0 == (f
= fopen("test01.raw", "wb")))
211 if(!write_little_endian_int16(f
, x
))
221 /* a stereo one-sample 16bps stream */
222 static FLAC__bool
generate_02(void)
225 FLAC__int16 xl
= -32768, xr
= 32767;
227 if(0 == (f
= fopen("test02.raw", "wb")))
230 if(!write_little_endian_int16(f
, xl
))
232 if(!write_little_endian_int16(f
, xr
))
242 /* a mono five-sample 16bps stream */
243 static FLAC__bool
generate_03(void)
246 FLAC__int16 x
[] = { -25, 0, 25, 50, 100 };
249 if(0 == (f
= fopen("test03.raw", "wb")))
252 for(i
= 0; i
< 5; i
++)
253 if(!write_little_endian_int16(f
, x
[i
]))
263 /* a stereo five-sample 16bps stream */
264 static FLAC__bool
generate_04(void)
267 FLAC__int16 x
[] = { -25, 500, 0, 400, 25, 300, 50, 200, 100, 100 };
270 if(0 == (f
= fopen("test04.raw", "wb")))
273 for(i
= 0; i
< 10; i
++)
274 if(!write_little_endian_int16(f
, x
[i
]))
284 /* a mono full-scale deflection 8bps stream */
285 static FLAC__bool
generate_fsd8(const char *fn
, const int pattern
[], unsigned reps
)
290 FLAC__ASSERT(pattern
!= 0);
292 if(0 == (f
= fopen(fn
, "wb")))
295 for(rep
= 0; rep
< reps
; rep
++) {
296 for(p
= 0; pattern
[p
]; p
++) {
297 signed char x
= pattern
[p
] > 0? 127 : -128;
298 if(fwrite(&x
, sizeof(x
), 1, f
) < 1)
310 /* a mono full-scale deflection 16bps stream */
311 static FLAC__bool
generate_fsd16(const char *fn
, const int pattern
[], unsigned reps
)
316 FLAC__ASSERT(pattern
!= 0);
318 if(0 == (f
= fopen(fn
, "wb")))
321 for(rep
= 0; rep
< reps
; rep
++) {
322 for(p
= 0; pattern
[p
]; p
++) {
323 FLAC__int16 x
= pattern
[p
] > 0? 32767 : -32768;
324 if(!write_little_endian_int16(f
, x
))
336 /* a stereo wasted-bits-per-sample 16bps stream */
337 static FLAC__bool
generate_wbps16(const char *fn
, unsigned samples
)
342 if(0 == (f
= fopen(fn
, "wb")))
345 for(sample
= 0; sample
< samples
; sample
++) {
346 FLAC__int16 l
= (sample
% 2000) << 2;
347 FLAC__int16 r
= (sample
% 1000) << 3;
348 if(!write_little_endian_int16(f
, l
))
350 if(!write_little_endian_int16(f
, r
))
361 /* a mono full-scale deflection 24bps stream */
362 static FLAC__bool
generate_fsd24(const char *fn
, const int pattern
[], unsigned reps
)
367 FLAC__ASSERT(pattern
!= 0);
369 if(0 == (f
= fopen(fn
, "wb")))
372 for(rep
= 0; rep
< reps
; rep
++) {
373 for(p
= 0; pattern
[p
]; p
++) {
374 FLAC__int32 x
= pattern
[p
] > 0? 8388607 : -8388608;
375 if(!write_little_endian_int24(f
, x
))
387 /* a mono sine-wave 8bps stream */
388 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
)
390 const FLAC__int8 full_scale
= 127;
391 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
392 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
394 double theta1
, theta2
;
397 if(0 == (f
= fopen(fn
, "wb")))
400 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
401 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
402 FLAC__int8 v
= (FLAC__int8
)(val
+ 0.5);
403 if(fwrite(&v
, sizeof(v
), 1, f
) < 1)
414 /* a stereo sine-wave 8bps stream */
415 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
)
417 const FLAC__int8 full_scale
= 127;
418 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
419 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
421 double theta1
, theta2
;
424 if(0 == (f
= fopen(fn
, "wb")))
427 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
428 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
429 FLAC__int8 v
= (FLAC__int8
)(val
+ 0.5);
430 if(fwrite(&v
, sizeof(v
), 1, f
) < 1)
432 val
= -(a1
*sin(theta1
*fmult
) + a2
*sin(theta2
*fmult
))*(double)full_scale
;
433 v
= (FLAC__int8
)(val
+ 0.5);
434 if(fwrite(&v
, sizeof(v
), 1, f
) < 1)
445 /* a mono sine-wave 16bps stream */
446 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
)
448 const FLAC__int16 full_scale
= 32767;
449 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
450 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
452 double theta1
, theta2
;
455 if(0 == (f
= fopen(fn
, "wb")))
458 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
459 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
460 FLAC__int16 v
= (FLAC__int16
)(val
+ 0.5);
461 if(!write_little_endian_int16(f
, v
))
472 /* a stereo sine-wave 16bps stream */
473 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
)
475 const FLAC__int16 full_scale
= 32767;
476 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
477 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
479 double theta1
, theta2
;
482 if(0 == (f
= fopen(fn
, "wb")))
485 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
486 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
487 FLAC__int16 v
= (FLAC__int16
)(val
+ 0.5);
488 if(!write_little_endian_int16(f
, v
))
490 val
= -(a1
*sin(theta1
*fmult
) + a2
*sin(theta2
*fmult
))*(double)full_scale
;
491 v
= (FLAC__int16
)(val
+ 0.5);
492 if(!write_little_endian_int16(f
, v
))
503 /* a mono sine-wave 24bps stream */
504 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
)
506 const FLAC__int32 full_scale
= 0x7fffff;
507 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
508 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
510 double theta1
, theta2
;
513 if(0 == (f
= fopen(fn
, "wb")))
516 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
517 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
518 FLAC__int32 v
= (FLAC__int32
)(val
+ 0.5);
519 if(!write_little_endian_int24(f
, v
))
530 /* a stereo sine-wave 24bps stream */
531 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
)
533 const FLAC__int32 full_scale
= 0x7fffff;
534 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
535 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
537 double theta1
, theta2
;
540 if(0 == (f
= fopen(fn
, "wb")))
543 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
544 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
545 FLAC__int32 v
= (FLAC__int32
)(val
+ 0.5);
546 if(!write_little_endian_int24(f
, v
))
548 val
= -(a1
*sin(theta1
*fmult
) + a2
*sin(theta2
*fmult
))*(double)full_scale
;
549 v
= (FLAC__int32
)(val
+ 0.5);
550 if(!write_little_endian_int24(f
, v
))
561 static FLAC__bool
generate_noise(const char *fn
, unsigned bytes
)
566 if(0 == (f
= fopen(fn
, "wb")))
569 for(b
= 0; b
< bytes
; b
++) {
570 #if !defined _MSC_VER && !defined __MINGW32__
571 FLAC__byte x
= (FLAC__byte
)(((unsigned)random()) & 0xff);
573 FLAC__byte x
= (FLAC__byte
)(((unsigned)rand()) & 0xff);
575 if(fwrite(&x
, sizeof(x
), 1, f
) < 1)
586 static FLAC__bool
generate_raw(const char *filename
, unsigned channels
, unsigned bytes_per_sample
, unsigned samples
)
588 const FLAC__int32 full_scale
= (1 << (bytes_per_sample
*8-1)) - 1;
589 const double f1
= 441.0, a1
= 0.61, f2
= 661.5, a2
= 0.37;
590 const double delta1
= 2.0 * M_PI
/ ( 44100.0 / f1
);
591 const double delta2
= 2.0 * M_PI
/ ( 44100.0 / f2
);
592 double theta1
, theta2
;
596 if(0 == (f
= fopen(filename
, "wb")))
599 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
600 for(j
= 0; j
< channels
; j
++) {
601 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
602 FLAC__int32 v
= (FLAC__int32
)(val
+ 0.5) + ((GET_RANDOM_BYTE
>>4)-8);
603 if(!write_little_endian(f
, v
, bytes_per_sample
))
615 static FLAC__bool
generate_aiff(const char *filename
, unsigned sample_rate
, unsigned channels
, unsigned bps
, unsigned samples
)
617 const unsigned bytes_per_sample
= (bps
+7)/8;
618 const unsigned true_size
= channels
* bytes_per_sample
* samples
;
619 const unsigned padded_size
= (true_size
+ 1) & (~1u);
620 const unsigned shift
= (bps
%8)? 8 - (bps
%8) : 0;
621 const FLAC__int32 full_scale
= (1 << (bps
-1)) - 1;
622 const double f1
= 441.0, a1
= 0.61, f2
= 661.5, a2
= 0.37;
623 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
624 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
625 double theta1
, theta2
;
629 if(0 == (f
= fopen(filename
, "wb")))
631 if(fwrite("FORM", 1, 4, f
) < 4)
633 if(!write_big_endian_uint32(f
, padded_size
+ 46))
635 if(fwrite("AIFFCOMM\000\000\000\022", 1, 12, f
) < 12)
637 if(!write_big_endian_uint16(f
, (FLAC__uint16
)channels
))
639 if(!write_big_endian_uint32(f
, samples
))
641 if(!write_big_endian_uint16(f
, (FLAC__uint16
)bps
))
643 if(!write_sane_extended(f
, sample_rate
))
645 if(fwrite("SSND", 1, 4, f
) < 4)
647 if(!write_big_endian_uint32(f
, true_size
+ 8))
649 if(fwrite("\000\000\000\000\000\000\000\000", 1, 8, f
) < 8)
652 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
653 for(j
= 0; j
< channels
; j
++) {
654 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
655 FLAC__int32 v
= ((FLAC__int32
)(val
+ 0.5) + ((GET_RANDOM_BYTE
>>4)-8)) << shift
;
656 if(!write_big_endian(f
, v
, bytes_per_sample
))
660 for(i
= true_size
; i
< padded_size
; i
++)
661 if(fputc(0, f
) == EOF
)
671 static FLAC__bool
generate_wav(const char *filename
, unsigned sample_rate
, unsigned channels
, unsigned bps
, unsigned samples
, FLAC__bool strict
)
673 const FLAC__bool waveformatextensible
= strict
&& (channels
> 2 || (bps
%8));
675 * (bps%8) allows 24 bps which is technically supposed to be WAVEFORMATEXTENSIBLE but we
676 * write 24bps as WAVEFORMATEX since it's unambiguous and matches how flac writes it
678 const unsigned bytes_per_sample
= (bps
+7)/8;
679 const unsigned true_size
= channels
* bytes_per_sample
* samples
;
680 const unsigned padded_size
= (true_size
+ 1) & (~1u);
681 const unsigned shift
= (bps
%8)? 8 - (bps
%8) : 0;
682 const FLAC__int32 full_scale
= (1 << (bps
-1)) - 1;
683 const double f1
= 441.0, a1
= 0.61, f2
= 661.5, a2
= 0.37;
684 const double delta1
= 2.0 * M_PI
/ ( sample_rate
/ f1
);
685 const double delta2
= 2.0 * M_PI
/ ( sample_rate
/ f2
);
686 double theta1
, theta2
;
690 if(0 == (f
= fopen(filename
, "wb")))
692 if(fwrite("RIFF", 1, 4, f
) < 4)
694 if(!write_little_endian_uint32(f
, padded_size
+ (waveformatextensible
?60:36)))
696 if(fwrite("WAVEfmt ", 1, 8, f
) < 8)
698 if(!write_little_endian_uint32(f
, waveformatextensible
?40:16))
700 if(!write_little_endian_uint16(f
, (FLAC__uint16
)(waveformatextensible
?65534:1)))
702 if(!write_little_endian_uint16(f
, (FLAC__uint16
)channels
))
704 if(!write_little_endian_uint32(f
, sample_rate
))
706 if(!write_little_endian_uint32(f
, sample_rate
* channels
* bytes_per_sample
))
708 if(!write_little_endian_uint16(f
, (FLAC__uint16
)(channels
* bytes_per_sample
))) /* block align */
710 if(!write_little_endian_uint16(f
, (FLAC__uint16
)(bps
+shift
)))
712 if(waveformatextensible
) {
713 if(!write_little_endian_uint16(f
, (FLAC__uint16
)22)) /* cbSize */
715 if(!write_little_endian_uint16(f
, (FLAC__uint16
)bps
)) /* validBitsPerSample */
717 if(!write_little_endian_uint32(f
, 0)) /* channelMask */
719 /* GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} */
720 if(fwrite("\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71", 1, 16, f
) != 16)
723 if(fwrite("data", 1, 4, f
) < 4)
725 if(!write_little_endian_uint32(f
, true_size
))
728 for(i
= 0, theta1
= theta2
= 0.0; i
< samples
; i
++, theta1
+= delta1
, theta2
+= delta2
) {
729 for(j
= 0; j
< channels
; j
++) {
730 double val
= (a1
*sin(theta1
) + a2
*sin(theta2
))*(double)full_scale
;
731 FLAC__int32 v
= ((FLAC__int32
)(val
+ 0.5) + ((GET_RANDOM_BYTE
>>4)-8)) << shift
;
732 if(!write_little_endian(f
, v
, bytes_per_sample
))
736 for(i
= true_size
; i
< padded_size
; i
++)
737 if(fputc(0, f
) == EOF
)
747 static FLAC__bool
generate_wackywavs(void)
751 'R', 'I', 'F', 'F', 76, 0, 0, 0,
752 'W', 'A', 'V', 'E', 'f', 'a', 'c', 't',
753 4, 0, 0, 0 , 'b', 'l', 'a', 'h',
754 'p', 'a', 'd', ' ', 4, 0, 0, 0,
755 'B', 'L', 'A', 'H', 'f', 'm', 't', ' ',
756 16, 0, 0, 0, 1, 0, 1, 0,
757 0x44,0xAC, 0, 0, 0, 0, 0, 0,
758 2, 0, 16, 0, 'd', 'a', 't', 'a',
759 16, 0, 0, 0, 0, 0, 1, 0,
760 4, 0, 9, 0, 16, 0, 25, 0,
761 36, 0, 49, 0, 'p', 'a', 'd', ' ',
762 4, 0, 0, 0, 'b', 'l', 'a', 'h'
765 if(0 == (f
= fopen("wacky1.wav", "wb")))
767 if(fwrite(wav
, 1, 84, f
) < 84)
772 if(0 == (f
= fopen("wacky2.wav", "wb")))
774 if(fwrite(wav
, 1, 96, f
) < 96)
784 int main(int argc
, char *argv
[])
786 FLAC__uint32 test
= 1;
789 int pattern01
[] = { 1, -1, 0 };
790 int pattern02
[] = { 1, 1, -1, 0 };
791 int pattern03
[] = { 1, -1, -1, 0 };
792 int pattern04
[] = { 1, -1, 1, -1, 0 };
793 int pattern05
[] = { 1, -1, -1, 1, 0 };
794 int pattern06
[] = { 1, -1, 1, 1, -1, 0 };
795 int pattern07
[] = { 1, -1, -1, 1, -1, 0 };
799 is_big_endian_host
= (*((FLAC__byte
*)(&test
)))? false : true;
801 #if !defined _MSC_VER && !defined __MINGW32__
805 if(gettimeofday(&tv
, 0) < 0) {
806 fprintf(stderr
, "WARNING: couldn't seed RNG with time\n");
812 srand((unsigned)time(0));
815 if(!generate_01()) return 1;
816 if(!generate_02()) return 1;
817 if(!generate_03()) return 1;
818 if(!generate_04()) return 1;
820 if(!generate_fsd8("fsd8-01.raw", pattern01
, 100)) return 1;
821 if(!generate_fsd8("fsd8-02.raw", pattern02
, 100)) return 1;
822 if(!generate_fsd8("fsd8-03.raw", pattern03
, 100)) return 1;
823 if(!generate_fsd8("fsd8-04.raw", pattern04
, 100)) return 1;
824 if(!generate_fsd8("fsd8-05.raw", pattern05
, 100)) return 1;
825 if(!generate_fsd8("fsd8-06.raw", pattern06
, 100)) return 1;
826 if(!generate_fsd8("fsd8-07.raw", pattern07
, 100)) return 1;
828 if(!generate_fsd16("fsd16-01.raw", pattern01
, 100)) return 1;
829 if(!generate_fsd16("fsd16-02.raw", pattern02
, 100)) return 1;
830 if(!generate_fsd16("fsd16-03.raw", pattern03
, 100)) return 1;
831 if(!generate_fsd16("fsd16-04.raw", pattern04
, 100)) return 1;
832 if(!generate_fsd16("fsd16-05.raw", pattern05
, 100)) return 1;
833 if(!generate_fsd16("fsd16-06.raw", pattern06
, 100)) return 1;
834 if(!generate_fsd16("fsd16-07.raw", pattern07
, 100)) return 1;
836 if(!generate_fsd24("fsd24-01.raw", pattern01
, 100)) return 1;
837 if(!generate_fsd24("fsd24-02.raw", pattern02
, 100)) return 1;
838 if(!generate_fsd24("fsd24-03.raw", pattern03
, 100)) return 1;
839 if(!generate_fsd24("fsd24-04.raw", pattern04
, 100)) return 1;
840 if(!generate_fsd24("fsd24-05.raw", pattern05
, 100)) return 1;
841 if(!generate_fsd24("fsd24-06.raw", pattern06
, 100)) return 1;
842 if(!generate_fsd24("fsd24-07.raw", pattern07
, 100)) return 1;
844 if(!generate_wbps16("wbps16-01.raw", 1000)) return 1;
846 if(!generate_sine8_1("sine8-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
847 if(!generate_sine8_1("sine8-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
848 if(!generate_sine8_1("sine8-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
849 if(!generate_sine8_1("sine8-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
850 if(!generate_sine8_1("sine8-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
852 if(!generate_sine8_2("sine8-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
853 if(!generate_sine8_2("sine8-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
854 if(!generate_sine8_2("sine8-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
855 if(!generate_sine8_2("sine8-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
856 if(!generate_sine8_2("sine8-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
857 if(!generate_sine8_2("sine8-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
858 if(!generate_sine8_2("sine8-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
859 if(!generate_sine8_2("sine8-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
860 if(!generate_sine8_2("sine8-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
861 if(!generate_sine8_2("sine8-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
863 if(!generate_sine16_1("sine16-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
864 if(!generate_sine16_1("sine16-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
865 if(!generate_sine16_1("sine16-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
866 if(!generate_sine16_1("sine16-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
867 if(!generate_sine16_1("sine16-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
869 if(!generate_sine16_2("sine16-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
870 if(!generate_sine16_2("sine16-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
871 if(!generate_sine16_2("sine16-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
872 if(!generate_sine16_2("sine16-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
873 if(!generate_sine16_2("sine16-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
874 if(!generate_sine16_2("sine16-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
875 if(!generate_sine16_2("sine16-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
876 if(!generate_sine16_2("sine16-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
877 if(!generate_sine16_2("sine16-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
878 if(!generate_sine16_2("sine16-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
880 if(!generate_sine24_1("sine24-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1;
881 if(!generate_sine24_1("sine24-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1;
882 if(!generate_sine24_1("sine24-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1;
883 if(!generate_sine24_1("sine24-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1;
884 if(!generate_sine24_1("sine24-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1;
886 if(!generate_sine24_2("sine24-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1;
887 if(!generate_sine24_2("sine24-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1;
888 if(!generate_sine24_2("sine24-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1;
889 if(!generate_sine24_2("sine24-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1;
890 if(!generate_sine24_2("sine24-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1;
891 if(!generate_sine24_2("sine24-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1;
892 if(!generate_sine24_2("sine24-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1;
893 if(!generate_sine24_2("sine24-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1;
894 if(!generate_sine24_2("sine24-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1;
895 if(!generate_sine24_2("sine24-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1;
897 /* WATCHOUT: the size of noise.raw is hardcoded into test/test_flac.sh */
898 if(!generate_noise("noise.raw", 65536 * 8 * 3)) return 1;
899 if(!generate_noise("noise8m32.raw", 32)) return 1;
900 if(!generate_wackywavs()) return 1;
901 for(channels
= 1; channels
<= 8; channels
++) {
902 unsigned bits_per_sample
;
903 for(bits_per_sample
= 4; bits_per_sample
<= 24; bits_per_sample
++) {
904 static const unsigned nsamples
[] = { 1, 111, 4777 } ;
906 for(samples
= 0; samples
< sizeof(nsamples
)/sizeof(nsamples
[0]); samples
++) {
909 sprintf(fn
, "rt-%u-%u-%u.aiff", channels
, bits_per_sample
, nsamples
[samples
]);
910 if(!generate_aiff(fn
, 44100, channels
, bits_per_sample
, nsamples
[samples
]))
913 sprintf(fn
, "rt-%u-%u-%u.wav", channels
, bits_per_sample
, nsamples
[samples
]);
914 if(!generate_wav(fn
, 44100, channels
, bits_per_sample
, nsamples
[samples
], /*strict=*/true))
917 if(bits_per_sample
% 8 == 0) {
918 sprintf(fn
, "rt-%u-%u-%u.raw", channels
, bits_per_sample
, nsamples
[samples
]);
919 if(!generate_raw(fn
, channels
, bits_per_sample
/8, nsamples
[samples
]))