Path: blob/master/libs/fluidsynth/src/rvoice/fluid_rvoice_event.h
4396 views
/* FluidSynth - A Software Synthesizer1*2* Copyright (C) 2003 Peter Hanappe and others.3*4* This library is free software; you can redistribute it and/or5* modify it under the terms of the GNU Lesser General Public License6* as published by the Free Software Foundation; either version 2.1 of7* the License, or (at your option) any later version.8*9* This library is distributed in the hope that it will be useful, but10* WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* Lesser General Public License for more details.13*14* You should have received a copy of the GNU Lesser General Public15* License along with this library; if not, write to the Free16* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA17* 02110-1301, USA18*/192021#ifndef _FLUID_RVOICE_EVENT_H22#define _FLUID_RVOICE_EVENT_H2324#include "fluidsynth_priv.h"25#include "fluid_rvoice_mixer.h"26#include "fluid_ringbuffer.h"2728typedef struct _fluid_rvoice_event_t fluid_rvoice_event_t;2930struct _fluid_rvoice_event_t31{32fluid_rvoice_function_t method;33void *object;34fluid_rvoice_param_t param[MAX_EVENT_PARAMS];35};3637/*38* Bridge between the renderer thread and the midi state thread.39* fluid_rvoice_eventhandler_fetch_all() can be called in parallel40* with fluid_rvoice_eventhandler_push/flush()41*/42struct _fluid_rvoice_eventhandler_t43{44fluid_ringbuffer_t *queue; /**< List of fluid_rvoice_event_t */45fluid_atomic_int_t queue_stored; /**< Extras pushed but not flushed */46fluid_ringbuffer_t *finished_voices; /**< return queue from handler, list of fluid_rvoice_t* */47fluid_rvoice_mixer_t *mixer;48};4950fluid_rvoice_eventhandler_t *new_fluid_rvoice_eventhandler(51int queuesize, int finished_voices_size, int bufs,52int fx_bufs, int fx_units, fluid_real_t sample_rate_max, fluid_real_t sample_rate, int, int);5354void delete_fluid_rvoice_eventhandler(fluid_rvoice_eventhandler_t *);5556int fluid_rvoice_eventhandler_dispatch_all(fluid_rvoice_eventhandler_t *);57int fluid_rvoice_eventhandler_dispatch_count(fluid_rvoice_eventhandler_t *);58void fluid_rvoice_eventhandler_finished_voice_callback(fluid_rvoice_eventhandler_t *eventhandler,59fluid_rvoice_t *rvoice);6061static FLUID_INLINE void62fluid_rvoice_eventhandler_flush(fluid_rvoice_eventhandler_t *handler)63{64int queue_stored = fluid_atomic_int_get(&handler->queue_stored);6566if(queue_stored > 0)67{68fluid_atomic_int_set(&handler->queue_stored, 0);69fluid_ringbuffer_next_inptr(handler->queue, queue_stored);70}71}7273/**74* @return next finished voice, or NULL if nothing in queue75*/76static FLUID_INLINE fluid_rvoice_t *77fluid_rvoice_eventhandler_get_finished_voice(fluid_rvoice_eventhandler_t *handler)78{79void *result = fluid_ringbuffer_get_outptr(handler->finished_voices);8081if(result == NULL)82{83return NULL;84}8586result = * (fluid_rvoice_t **) result;87fluid_ringbuffer_next_outptr(handler->finished_voices);88return result;89}909192int fluid_rvoice_eventhandler_push_int_real(fluid_rvoice_eventhandler_t *handler,93fluid_rvoice_function_t method, void *object, int intparam,94fluid_real_t realparam);9596int fluid_rvoice_eventhandler_push_ptr(fluid_rvoice_eventhandler_t *handler,97fluid_rvoice_function_t method, void *object, void *ptr);9899int fluid_rvoice_eventhandler_push(fluid_rvoice_eventhandler_t *handler,100fluid_rvoice_function_t method, void *object,101fluid_rvoice_param_t param[MAX_EVENT_PARAMS]);102103static FLUID_INLINE void104fluid_rvoice_eventhandler_add_rvoice(fluid_rvoice_eventhandler_t *handler,105fluid_rvoice_t *rvoice)106{107fluid_rvoice_eventhandler_push_ptr(handler, fluid_rvoice_mixer_add_voice,108handler->mixer, rvoice);109}110111112113#endif114115116