added audio settings options for selection of device, samplrate and buffer size, also fixed: #65 & fixed: #64

This commit is contained in:
Dave Griffiths
2022-10-03 09:56:25 +01:00
parent fb8d607e2d
commit 4a4ab8b41a
19 changed files with 859 additions and 282 deletions

View File

@ -28,15 +28,18 @@ audio_thread::audio_thread(process_thread &p) :
m_stereo_mode(false),
m_mic_mode(false),
m_bufsize(2048),
m_samplerate(44100)
m_samplerate(44100),
m_device("")
{
start_audio();
// start_audio();
pthread_mutex_lock(m_brain_mutex);
m_left_renderer = new renderer(p.m_source,p.m_left_target);
m_right_renderer = new renderer(p.m_source,p.m_right_target);
m_block_stream = new block_stream();
pthread_mutex_unlock(m_brain_mutex);
m_osc.run();
// it this threadsafe?
// m_audio_device->report_devices();
}
static bool state = 1;
@ -54,13 +57,24 @@ void audio_thread::start_audio() {
m_audio_device->m_client.set_callback(run_audio, this);
}
void audio_thread::restart_audio(const string device, unsigned int samplerate, unsigned int bufsize) {
m_samplerate = samplerate;
m_bufsize = bufsize;
m_device = device;
m_audio_device->connect(m_device,
"samplebrain",
m_samplerate,
m_bufsize);
}
void audio_thread::run_audio(void* c, unsigned int frames) {
if (state) {
audio_thread *at = (audio_thread*)c;
at->m_audio_device->left_out.zero();
at->process(at->m_audio_device->left_in,
at->m_audio_device->right_in,
at->m_audio_device->left_out,
at->m_audio_device->right_in,
at->m_audio_device->left_out,
at->m_audio_device->right_out);
at->m_audio_device->maybe_record();
}
@ -187,12 +201,12 @@ void audio_thread::process(sample &left_in, sample &right_in, sample &left_out,
}
m_left_renderer->process(left_out.get_length(),
left_out.get_non_const_buffer(),
bs);
left_out.get_non_const_buffer(),
bs);
if (m_stereo_mode) {
m_right_renderer->process(right_out.get_length(),
right_out.get_non_const_buffer(),
bs);
right_out.get_non_const_buffer(),
bs);
} else {
right_out=left_out;
}