1 /******************************************/
4 by Gary P. Scavone, 2001
6 Records from default input and passes it
7 through to the output. Takes number of
8 channels and sample rate as input arguments.
9 Uses callback functionality.
11 /******************************************/
17 typedef signed long MY_TYPE;
18 #define FORMAT RTAUDIO_SINT24
21 #define FORMAT RTAUDIO_SINT8
23 typedef signed short MY_TYPE;
24 #define FORMAT RTAUDIO_SINT16
26 typedef signed long MY_TYPE;
27 #define FORMAT RTAUDIO_SINT32
29 typedef float MY_TYPE;
30 #define FORMAT RTAUDIO_FLOAT32
33 typedef double MY_TYPE;
34 #define FORMAT RTAUDIO_FLOAT64
37 /* Error function in case of incorrect command-line
38 argument specifications
40 std::cout << "\nuseage: call_inout N fs device\n";
41 std::cout << " where N = number of channels,\n";
42 std::cout << " fs = the sample rate,\n";
43 std::cout << " and device = the device to use (default = 0).\n\n";
47 int inout(char *buffer, int buffer_size, void *)
49 // Surprise!! We do nothing to pass the data through.
53 int main(int argc, char *argv[])
55 int chans, fs, device = 0;
59 // minimal command-line checking
60 if (argc != 3 && argc != 4 ) usage();
62 chans = (int) atoi(argv[1]);
63 fs = (int) atoi(argv[2]);
65 device = (int) atoi(argv[3]);
67 // Open the realtime output device
68 int buffer_size = 512;
70 audio = new RtAudio( device, chans, device, chans,
71 FORMAT, fs, &buffer_size, 8 );
73 catch (RtError &error) {
79 audio->setStreamCallback(&inout, NULL);
82 catch (RtError &error) {
87 std::cout << "\nRunning ... press <enter> to quit (buffer size = " << buffer_size << ").\n";
93 catch (RtError &error) {