33 cout<<
"\nUseage: \n"<<endl;
34 cout<<name<<
" [-t duration] outputFileName.ext : the output file name with ext replaced by a known output format extension (see below)"<<endl;
35 cout<<name<<
" -t num : duration in seconds"<<endl;
38 cout<<
"The known output file extensions (output file formats) are the following :"<<endl;
39 for (
int i=0; i<formats.size(); i++)
40 cout<<formats[i]<<
' ';
51 vector<vector<jack_default_audio_sample_t> >
audioData;
54 float w=2.*M_PI*1.e3/(float)getSampleRate();
57 for (
uint i=0; i<outputPorts.size(); i++) {
58 jack_default_audio_sample_t *out = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( outputPorts[i], nframes );
59 for (
uint j=0; j<nframes; j++)
60 audioData[i][j]=out[j]=sin((i+1)*w*(float)j+phase);
65 for (
uint i=0; i<inputPorts.size(); i++) {
66 jack_default_audio_sample_t *in = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( inputPorts[i], nframes );
67 for (
uint j=0; j<nframes; j++)
68 audioData[outputPorts.size()+i][j]=in[j];
70 phase=fmod(phase+w*(
float)(nframes), 2.*M_PI);
73 cout<<
"nframes "<<nframes<<
'\n';
84 int inChCnt, outChCnt;
85 getPhysicalPortCount(inChCnt, outChCnt);
86 int chCnt=inChCnt+outChCnt;
91 audioData.resize(chCnt);
92 for (
int i=0; i<chCnt; i++)
93 audioData[i].resize(getBlockSize());
97 int main(
int argc,
char *argv[]) {
103 if (op.
getArg<
string>(
"h", argc, argv, help, i=0)!=0 || argc < 2)
109 int res=jackClient.
connect(
"jack test client");
113 cout<<
"Jack : sample rate set to : "<<jackClient.
getSampleRate()<<
" Hz"<<endl;
114 cout<<
"Jack : block size set to : "<<jackClient.
getBlockSize()<<
" samples"<<endl;
119 int inChCnt, outChCnt;
121 cout<<
"Jack : "<<inChCnt<<
" physical input channels"<<endl;
122 cout<<
"Jack : "<<outChCnt<<
" physical output channels"<<endl;
123 res=jackClient.
createPorts(
"in ", inChCnt,
"out ", outChCnt);
128 res=jackClient.
startClient(inChCnt, outChCnt,
true);
133 op.
getArg<
float>(
"t", argc, argv, t, i=0);
134 cout<<
"running for "<<t<<
" seconds"<<endl;
virtual int openWrite(const string &fileName, double fs, int channels, double maxVal)
FullDuplexTones()
Constructor.
virtual int createPorts(string inName, int inCnt, string outName, int outCnt)
int getArg(string key, int argc, char *argv[], TYPE &ret, int i)
virtual int getBlockSize()
virtual int evaluateError(int errorNum)
void getPhysicalPortCount(int &in, int &out)
virtual int startClient()
vector< string > availableFormats(void)
float phase
The tone phase.
int main(int argc, char *argv[])
int processAudio(jack_nframes_t nframes)
vector< vector< jack_default_audio_sample_t > > audioData
int printUsage(string name)
int getSampleRate(void) const
virtual int connect(string clientName_)
virtual int openWrite(const string &fileName)