29 #define MAX_CHANNELS 12
31 static unsigned int myrnd(
unsigned int *seed_ptr,
int n)
47 #define FRAC_ONE (1 << FRAC_BITS)
49 #define COS_TABLE_BITS 7
53 0x8000, 0x7ffe, 0x7ff6, 0x7fea, 0x7fd9, 0x7fc2, 0x7fa7, 0x7f87,
54 0x7f62, 0x7f38, 0x7f0a, 0x7ed6, 0x7e9d, 0x7e60, 0x7e1e, 0x7dd6,
55 0x7d8a, 0x7d3a, 0x7ce4, 0x7c89, 0x7c2a, 0x7bc6, 0x7b5d, 0x7aef,
56 0x7a7d, 0x7a06, 0x798a, 0x790a, 0x7885, 0x77fb, 0x776c, 0x76d9,
57 0x7642, 0x75a6, 0x7505, 0x7460, 0x73b6, 0x7308, 0x7255, 0x719e,
58 0x70e3, 0x7023, 0x6f5f, 0x6e97, 0x6dca, 0x6cf9, 0x6c24, 0x6b4b,
59 0x6a6e, 0x698c, 0x68a7, 0x67bd, 0x66d0, 0x65de, 0x64e9, 0x63ef,
60 0x62f2, 0x61f1, 0x60ec, 0x5fe4, 0x5ed7, 0x5dc8, 0x5cb4, 0x5b9d,
61 0x5a82, 0x5964, 0x5843, 0x571e, 0x55f6, 0x54ca, 0x539b, 0x5269,
62 0x5134, 0x4ffb, 0x4ec0, 0x4d81, 0x4c40, 0x4afb, 0x49b4, 0x486a,
63 0x471d, 0x45cd, 0x447b, 0x4326, 0x41ce, 0x4074, 0x3f17, 0x3db8,
64 0x3c57, 0x3af3, 0x398d, 0x3825, 0x36ba, 0x354e, 0x33df, 0x326e,
65 0x30fc, 0x2f87, 0x2e11, 0x2c99, 0x2b1f, 0x29a4, 0x2827, 0x26a8,
66 0x2528, 0x23a7, 0x2224, 0x209f, 0x1f1a, 0x1d93, 0x1c0c, 0x1a83,
67 0x18f9, 0x176e, 0x15e2, 0x1455, 0x12c8, 0x113a, 0x0fab, 0x0e1c,
68 0x0c8c, 0x0afb, 0x096b, 0x07d9, 0x0648, 0x04b6, 0x0324, 0x0192,
72 #define CSHIFT (FRAC_BITS - COS_TABLE_BITS - 2)
77 const unsigned short *p;
90 v = p[0] + (((p[1] - p[0]) *
f + (1 << (
CSHIFT - 1))) >>
CSHIFT);
101 fputc((v >> 8) & 0xff,
outfile);
107 fputc((v >> 8) & 0xff,
outfile);
108 fputc((v >> 16) & 0xff,
outfile);
109 fputc((v >> 24) & 0xff,
outfile);
112 #define HEADER_SIZE 46
114 #define SAMPLE_SIZE 2
115 #define WFORMAT_PCM 0x0001
120 int data_size = block_align * nb_samples;
137 int main(
int argc,
char **argv)
139 int i,
a, v, j,
f, amp, ampa;
140 unsigned int seed = 1;
147 if (argc < 2 || argc > 5) {
148 printf(
"usage: %s file [<sample rate> [<channels>] [<random seed>]]\n"
149 "generate a test raw 16 bit audio stream\n"
150 "If the file extension is .wav a WAVE header will be added.\n"
151 "default: 44100 Hz stereo\n", argv[0]);
158 fprintf(stderr,
"invalid sample rate: %d\n",
sample_rate);
166 fprintf(stderr,
"invalid number of channels: %d\n",
nb_channels);
172 seed = atoi(argv[4]);
174 outfile = fopen(argv[1],
"wb");
180 if ((ext = strrchr(argv[1],
'.')) && !strcmp(ext,
".wav"))