2 Broadcast 2.0 multitrack audio editing
3 (c) 1997 Heroine Virtual
5 This program is distributed with the intent that it will be useful, without
6 any warranty. The code is being updated and has many bugs which are
7 constantly being elucidated so changes should not be made without notifying
11 /* Run at startup to permanently allocate your DMA buffers */
13 #include <sys/soundcard.h>
18 #include <sys/ioctl.h>
21 int main(int argc, char *argv[])
25 audio_buf_info playinfo, recinfo;
26 int bufsize = 0x7FFF0000;
29 int format = AFMT_S16_LE;
31 int samplerate = 44100;
39 fragsize = atol(argv[1]);
40 if(fragsize <= 0) fragsize = 32768;
41 bufsize += (long)(log(fragsize) / log(2));
46 printf("*** Full duplex\n");
48 if((dsp = open("/dev/dsp", O_RDWR)) < 0){
49 printf("Can't open audio device.\n");
54 if (ioctl(dsp, SNDCTL_DSP_SETFRAGMENT, &bufsize))
55 printf("Couldn't set buffer parameters.\n");
57 if(duplexenable && ioctl(dsp, SNDCTL_DSP_SETDUPLEX, 0) == -1){
58 printf("Couldn't enable full duplex audio.\n");
62 if(ioctl(dsp, SNDCTL_DSP_SETFMT, &format) < 0)
63 printf("playback file format failed\n");
64 if(ioctl(dsp, SNDCTL_DSP_CHANNELS, &channels) < 0)
65 printf("playback channel allocation failed\n");
66 if(ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate) < 0)
67 printf("playback sample rate set failed\n");
69 ioctl(dsp, SNDCTL_DSP_GETOSPACE, &playinfo);
71 printf(" fragments fragstotal fragsize bytes TOTAL BYTES AVAILABLE\n");
72 printf("Playback: %9d %10d %8d %7d %12d\n", playinfo.fragments,
73 playinfo.fragstotal, playinfo.fragsize, playinfo.bytes, playinfo.bytes);
77 if(ioctl(dsp, SNDCTL_DSP_SETFMT, &format) < 0)
78 printf("record file format failed\n");
79 if(ioctl(dsp, SNDCTL_DSP_CHANNELS, &channels) < 0)
80 printf("record channel allocation failed\n");
81 if(ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate) < 0)
82 printf("record sample rate set failed\n");
84 ioctl(dsp, SNDCTL_DSP_GETISPACE, &recinfo);
86 printf("Record: %9d %10d %8d %7d %12d\n", recinfo.fragments,
87 recinfo.fragstotal, recinfo.fragsize, recinfo.bytes, recinfo.fragstotal * recinfo.fragsize);
95 printf("\n*** Half duplex\n");
97 if((dsp = open("/dev/dsp", O_WRONLY)) < 0){
98 printf("Can't open audio device.\n");
103 if (ioctl(dsp, SNDCTL_DSP_SETFRAGMENT, &bufsize))
104 printf("Couldn't set buffer parameters.\n");
106 if(duplexenable && ioctl(dsp, SNDCTL_DSP_SETDUPLEX, 0) == -1){
107 printf("Couldn't enable full duplex audio.\n");
111 if(ioctl(dsp, SNDCTL_DSP_SETFMT, &format) < 0)
112 printf("playback file format failed\n");
113 if(ioctl(dsp, SNDCTL_DSP_CHANNELS, &channels) < 0)
114 printf("playback channel allocation failed\n");
115 if(ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate) < 0)
116 printf("playback sample rate set failed\n");
118 ioctl(dsp, SNDCTL_DSP_GETOSPACE, &playinfo);
120 printf(" fragments fragstotal fragsize bytes TOTAL BYTES AVAILABLE\n");
121 printf("Playback: %9d %10d %8d %7d %12d\n", playinfo.fragments,
122 playinfo.fragstotal, playinfo.fragsize, playinfo.bytes, playinfo.bytes);
127 if((dsp = open("/dev/dsp", O_RDONLY)) < 0){
128 printf("Can't open audio device.\n");
133 if (ioctl(dsp, SNDCTL_DSP_SETFRAGMENT, &bufsize))
134 printf("Couldn't set buffer parameters.\n");
136 if(duplexenable && ioctl(dsp, SNDCTL_DSP_SETDUPLEX, 0) == -1){
137 printf("Couldn't enable full duplex audio.\n");
141 if(ioctl(dsp, SNDCTL_DSP_SETFMT, &format) < 0)
142 printf("playback file format failed\n");
143 if(ioctl(dsp, SNDCTL_DSP_CHANNELS, &channels) < 0)
144 printf("playback channel allocation failed\n");
145 if(ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate) < 0)
146 printf("playback sample rate set failed\n");
148 if(ioctl(dsp, SNDCTL_DSP_SETFMT, &format) < 0)
149 printf("record file format failed\n");
150 if(ioctl(dsp, SNDCTL_DSP_CHANNELS, &channels) < 0)
151 printf("record channel allocation failed\n");
152 if(ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate) < 0)
153 printf("record sample rate set failed\n");
158 ioctl(dsp, SNDCTL_DSP_GETISPACE, &recinfo);
160 printf("Record: %9d %10d %8d %7d %12d\n", recinfo.fragments,
161 recinfo.fragstotal, recinfo.fragsize, recinfo.bytes, recinfo.fragstotal * recinfo.fragsize);
163 ioctl(dsp, SNDCTL_DSP_RESET);