mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-05-12 10:37:20 +00:00
jiggery pokery and crash fixes
This commit is contained in:
parent
3f0936d7d5
commit
1f9fde78db
@ -10,11 +10,11 @@ audio_thread::audio_thread(process_thread &p) :
|
||||
m_brain_mutex(p.m_brain_mutex),
|
||||
m_osc("8888")
|
||||
{
|
||||
start_audio();
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
m_renderer = new renderer(p.m_source,p.m_target);
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
m_osc.run();
|
||||
start_audio();
|
||||
}
|
||||
|
||||
void audio_thread::start_audio() {
|
||||
|
@ -51,7 +51,7 @@ void process_thread::process() {
|
||||
m_source_block_size = cmd.get_int(0);
|
||||
}
|
||||
if (name=="/source_overlap") {
|
||||
m_source_overlap = m_source_block_size-m_source_block_size/cmd.get_float(0);
|
||||
m_source_overlap = m_source_block_size*cmd.get_float(0);
|
||||
}
|
||||
if (name=="/generate_brain") {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
@ -68,7 +68,8 @@ void process_thread::process() {
|
||||
m_target_block_size = cmd.get_int(0);
|
||||
}
|
||||
if (name=="/target_overlap") {
|
||||
m_target_overlap = m_target_block_size-m_target_block_size/cmd.get_float(0);
|
||||
m_target_overlap = m_target_block_size*cmd.get_float(0);
|
||||
cerr<<m_target_overlap<<endl;
|
||||
}
|
||||
if (name=="/generate_target") {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
|
@ -58,6 +58,7 @@ void brain::init(u32 block_size, u32 overlap, u32 env, bool ditchpcm) {
|
||||
|
||||
void brain::chop_and_add(const sample &s, u32 block_size, u32 overlap, u32 env, bool ditchpcm) {
|
||||
u32 pos=0;
|
||||
if (overlap>=block_size) overlap=0;
|
||||
while (pos+block_size-1<s.get_length()) {
|
||||
cerr<<'\r';
|
||||
cerr<<"adding: "<<pos/(float)s.get_length()*100;
|
||||
|
@ -6,6 +6,7 @@ using namespace std;
|
||||
|
||||
void renderer::init(brain &source, brain &target) {
|
||||
m_volume=1;
|
||||
m_playing=false;
|
||||
m_source=source;
|
||||
m_target=target;
|
||||
m_render_time=0;
|
||||
@ -22,8 +23,7 @@ void renderer::process(u32 nframes, float *buf) {
|
||||
u32 tgt_start = m_render_time/(float)tgt_shift;
|
||||
u32 tgt_end = (m_render_time+nframes)/(float)tgt_shift;
|
||||
|
||||
|
||||
if (tgt_end>=m_target.get_num_blocks()) {
|
||||
if (tgt_end>=m_target.get_num_blocks() || m_source.get_num_blocks()==0) {
|
||||
m_render_time=0;
|
||||
m_render_blocks.clear();
|
||||
// next time...
|
||||
|
Loading…
x
Reference in New Issue
Block a user