/******************************************/ /* Example program for realtime input/output by Gary P. Scavone, 2000 This program reads N channels of realtime audio input for a specified amount of time and immediately play them back in realtime (duplex mode). This program also demonstrates the use of FIFO scheduling priority. To be run with such priority, the program must be set suid (chmod +s) and owned by root. */ /******************************************/ #include "RtDuplex.h" #if !defined(__OS_Win_) #include #endif void usage(void) { /* Error function in case of incorrect command-line argument specifications */ printf("\nuseage: ioN N time \n"); printf(" where N = number of channels,\n"); printf(" and time = the amount of time to record (in seconds).\n\n"); exit(0); } int main(int argc, char *argv[]) { int i=0; // minimal command-line checking if (argc != 3) usage(); int chans = (int) atoi(argv[1]); float time = atof(argv[2]); float sample_rate = SRATE; MY_FLOAT *inSamples; MY_FLOAT *lastSamples; // allocate the lastSamples array lastSamples = (MY_FLOAT *) new MY_FLOAT[chans]; for (i=0; imtick(lastSamples); for (int k=0; k=256) { sched_yield(); j = 0; } #endif } // Clean up delete inout; delete [] lastSamples; }