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
Use blocking 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
39
/* Error function in case of incorrect command-line
40
argument specifications
42
std::cout << "\nuseage: in_out N fs <device>\n";
43
std::cout << " where N = number of channels,\n";
44
std::cout << " fs = the sample rate,\n";
45
std::cout << " and device = the device to use (default = 0).\n\n";
49
int main(int argc, char *argv[])
51
int chans, fs, buffer_size, device = 0;
52
long frames, counter = 0;
56
// minimal command-line checking
57
if (argc != 3 && argc != 4 ) usage();
59
chans = (int) atoi(argv[1]);
60
fs = (int) atoi(argv[2]);
62
device = (int) atoi(argv[3]);
64
// Open the realtime output device
67
audio = new RtAudio(device, chans, device, chans,
68
FORMAT, fs, &buffer_size, 8);
70
catch (RtError &error) {
75
frames = (long) (fs * TIME);
78
buffer = (MY_TYPE *) audio->getStreamBuffer();
81
catch (RtError &error) {
86
std::cout << "\nRunning for " << TIME << " seconds ... fragment_size = " << buffer_size << std::endl;
87
while (counter < frames) {
92
catch (RtError &error) {
96
counter += buffer_size;
102
catch (RtError &error) {
103
error.printMessage();
107
audio->closeStream();