34 cout<<
"\nUseage: \n"<<endl;
35 cout<<name<<
" [-t duration] [-o num] [-i num] [-O num] [-g num] "<<endl;
36 cout<<name<<
" -t num : duration in seconds"<<endl;
37 cout<<name<<
" -o num : number of output channels to open at the same time on the audio device"<<endl;
38 cout<<name<<
" -O num : total number of test output channels to record"<<endl;
39 cout<<name<<
" -i num : number of input channels to open at the same time on the audio device"<<endl;
40 cout<<name<<
" -g num : the output gain"<<endl;
44 int main(
int argc,
char *argv[]) {
49 if (op.
getArg<
string>(
"h", argc, argv, help, i=0)!=0)
55 op.
getArg<
float>(
"t", argc, argv, t, i=0);
56 cout<<
"running for "<<t<<
" seconds"<<endl;
60 op.
getArg<
float>(
"g", argc, argv, g, i=0);
61 cout<<
"using a gain="<<g<<endl;
65 op.
getArg<
int>(
"i", argc, argv, inChCnt, i=0);
66 cout<<
"recording "<<inChCnt<<
" channels of physical input audio to record each time"<<endl;
69 op.
getArg<
int>(
"o", argc, argv, outChCnt, i=0);
70 cout<<
"playing "<<outChCnt<<
" channels of output random noise"<<endl;
73 op.
getArg<
int>(
"O", argc, argv, outTestChCnt, i=0);
74 cout<<
"recording "<<outTestChCnt<<
" channels of output audio (mixer inputs) total, maximum of "<<outChCnt<<
" channels each run."<<endl;
76 mixerAudio.
setChannels(outChCnt, inChCnt, outTestChCnt);
78 cout<<
"Jack : sample rate set to : "<<mixerAudio.
getSampleRate()<<
" Hz"<<endl;
79 cout<<
"Jack : block size set to : "<<mixerAudio.
getBlockSize()<<
" samples"<<endl;
81 ofstream mFileOut(
"/tmp/MixerTester.m");
82 mFileOut<<
"function MixerTester(data)"<<endl;
83 mFileOut<<
"sampleRate="<<mixerAudio.
getSampleRate()<<
';'<<endl;
84 mFileOut<<
"[N,M]=size(data); figure(1); f=linspace(0,sampleRate,N);"<<endl;
85 mFileOut<<
"for i=2:M"<<endl;
86 mFileOut<<
" subplot(M-1,1,i-1); loglog(f, abs(fft(data(:,i))));"<<endl;
87 mFileOut<<
"end"<<endl;
88 mFileOut<<
"xlabel('f (Hz)')"<<endl;
89 mFileOut<<
"figure(2); t=(0:N-1)/sampleRate;"<<endl;
90 mFileOut<<
"for i=2:M"<<endl;
91 mFileOut<<
" subplot(M-1,1,i-1); plot(t,data(:,i));"<<endl;
92 mFileOut<<
" set(gca,'ylim',[-1.5 1.5]);"<<endl;
93 mFileOut<<
"end"<<endl;
94 mFileOut<<
"xlabel('t (s)')"<<endl;
95 mFileOut<<
"disp('paused'); pause \nend"<<endl;
98 vector<string> args(3); args[0]=string(
"--silent"); args[1]=string(
"--path"); args[2]=
"/tmp";
136 cout<<
"\r launching octave to view results "<<endl;
138 vector<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> > input(1), output;
139 input[0]=mixerAudio.
audio;
140 octave.
runM(
"MixerTester",input, output);
vector< vector< vector< TYPE > > > & runM(const char *commandName, const vector< vector< vector< TYPE > > > &in, vector< vector< vector< TYPE > > > &out)
int getArg(string key, int argc, char *argv[], TYPE &ret, int i)
Octave's octave_value_list class.
virtual int getBlockSize()
virtual int getNumberOfRecordedChannels()
#define NO_ERROR
There is no error.
int getSampleRate(void) const
int setChannels(int outCnt, int inCnt, int testOutCnt)
int main(int argc, char *argv[])
int recordNextChannelSet()
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic > audio
The first channel is the same data sent over each output channel, then the output channels...
int printUsage(string name)