#include <iostream>
#include <math.h>
#include <unistd.h>
float phase;
int processAudio(jack_nframes_t nframes) {
float w=2.*M_PI*1.e3/(float)getSampleRate();
for (
uint i=0; i<outputPorts.size(); i++) {
jack_default_audio_sample_t *out = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( outputPorts[i], nframes );
for (
uint j=0; j<nframes; j++)
out[j]=sin(w*(float)j+phase);
}
float rms=0.;
for (
uint i=0; i<inputPorts.size(); i++) {
jack_default_audio_sample_t *in = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( inputPorts[i], nframes );
for (
uint j=0; j<nframes; j++)
rms+=in[j]*in[j];
cout<<"input ch "<<i<<" rms = "<<sqrt(rms/nframes)<<'\t';
}
cout<<'\n';
phase=fmod(phase+w*(float)(nframes), 2.*M_PI);
return 0;
}
public:
phase=0.;
}
};
int main(
int argc,
char *argv[]) {
int res=jackClient.
connect(
"jack test client");
if (res!=0)
cout<<
"Jack : sample rate set to : "<<jackClient.
getSampleRate()<<
" Hz"<<endl;
cout<<
"Jack : block size set to : "<<jackClient.
getBlockSize()<<
" samples"<<endl;
if (res!=0)
if (res!=0)
sleep(10);
return 0;
}