/* * Multi channel audio test. * * This program is intended to test playback of 16 bit samples using 4 or more * channels at 48000 Hz. The program plays sine wave pulses sequentially on * channels 0 to N-1. * * Arguments: * * 1: Number of channelts (default is 8). * 2: Audio device (/dev/dsp by default). * 3-N: Options * -b Bypass virtual mixer * -r Raw mode (disables automatic sample rate/format conversions) */ #include #include #include #include #include #include static int sinedata[48] = { 0, 4276, 8480, 12539, 16383, 19947, 23169, 25995, 28377, 30272, 31650, 32486, 32767, 32486, 31650, 30272, 28377, 25995, 23169, 19947, 16383, 12539, 8480, 4276, 0, -4276, -8480, -12539, -16383, -19947, -23169, -25995, -28377, -30272, -31650, -32486, -32767, -32486, -31650, -30272, -28377, -25995, -23169, -19947, -16383, -12539, -8480, -4276 }; int main (int argc, char *argv[]) { char *dev = "/dev/dsp"; int fd, l, i, n = 0, ch, p = 0, phase = 0, arg, channels, srate, thisch = 0; int tick = 0; int nch = 8; int bypass_vmix=0; int disable_format_conversions=0; short buf[1024]; if (argc > 1) if (sscanf (argv[1], "%d", &nch) != 1) nch = 2; if (argc > 2) dev = argv[2]; for (i=3;i 10 * channels) { thisch = (thisch + 1) % channels; tick = 0; } } else buf[p] = 0; p++; if (p >= sizeof (buf) / 2) { if (write (fd, buf, p * 2) != p * 2) perror ("write"); p = 0; tick++; } } n++; } exit (0); }