/* Callback for sample timer */ int fluid_seqbind_timer_callback(void* data, unsigned int msec) { fluid_seqbind_t* seqbind = (fluid_seqbind_t *) data; fluid_sequencer_process(seqbind->seq, msec); return 1; }
static void RT_process(SoundPlugin *plugin, int64_t time, int num_frames, float **inputs, float **outputs){ Data *data = (Data*)plugin->data; //data =NULL; // crashreporter test. //printf("telling sequencer that it is time %d\n",(int)data->time); fluid_sequencer_process(data->sequencer, get_fluidsynth_time(data,data->time)); data->time += num_frames; // What's the difference between fluid_synth_write_float and fluid_synth_nwrite_float? Sounds to me like they produce exactly the same sound. #if 0 if(fluid_synth_write_float(data->synth,num_frames,outputs[0],0,1,outputs[1],0,1)==FLUID_FAILED) printf("fluid_synth_write_float failed\n"); #else if(fluid_synth_nwrite_float(data->synth,num_frames, &outputs[0], &outputs[1], NULL, NULL)==FLUID_FAILED) printf("fluid_synth_write_float failed\n"); #endif if(data->new_data != NULL){ RT_fade_out(outputs[0],num_frames); RT_fade_out(outputs[1],num_frames); plugin->data = data->new_data; // hmm. data->new_data = NULL; RSEMAPHORE_signal(data->signal_from_RT,1); } }
/* Callback from timer (may be in a different thread, or in an interrupt) */ static int _fluid_seq_queue_process(void* data, unsigned int msec) { fluid_sequencer_t* seq = (fluid_sequencer_t *)data; fluid_sequencer_process(seq, msec); /* continue timer */ return 1; }
static void midoflus_start(void) { S_printf("MIDI: starting fluidsynth\n"); mf_time_base = GETusTIME(0); pthread_mutex_lock(&syn_mtx); pcm_prepare_stream(pcm_stream); fluid_sequencer_process(sequencer, 0); output_running = 1; pthread_mutex_unlock(&syn_mtx); }
static void midoflus_write(unsigned char val) { int ret; unsigned long long now = GETusTIME(0); int msec = (now - mf_time_base) / 1000; if (!output_running) midoflus_start(); fluid_sequencer_process(sequencer, msec); ret = fluid_sequencer_add_midi_data_to_buffer(synthSeqID, &val, 1); if (ret != FLUID_OK) S_printf("MIDI: failed sending midi event\n"); }
static void midoflus_stop(void *arg) { long long now; int msec; if (!output_running) return; now = GETusTIME(0); msec = (now - mf_time_base) / 1000; S_printf("MIDI: stopping fluidsynth at msec=%i\n", msec); pthread_mutex_lock(&syn_mtx); /* advance past last event */ fluid_sequencer_process(sequencer, msec); /* shut down all active notes */ fluid_synth_system_reset(synth); if (pcm_running) pcm_flush(pcm_stream); pcm_running = 0; output_running = 0; pthread_mutex_unlock(&syn_mtx); }