1/* FluidSynth - A Software Synthesizer 2 * 3 * Copyright (C) 2003 Peter Hanappe and others. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public License 7 * as published by the Free Software Foundation; either version 2 of 8 * the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the Free 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 * 02111-1307, USA 19 */ 20 21#ifndef _FLUIDSYNTH_SEQ_H 22#define _FLUIDSYNTH_SEQ_H 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28 29typedef void (*fluid_event_callback_t)(unsigned int time, fluid_event_t* event, 30 fluid_sequencer_t* seq, void* data); 31 32 33/** Allocate a new sequencer structure */ 34FLUIDSYNTH_API fluid_sequencer_t* new_fluid_sequencer(void); 35 36/** Free the sequencer structure */ 37FLUIDSYNTH_API void delete_fluid_sequencer(fluid_sequencer_t* seq); 38 39/** clients can be sources or destinations of events. These functions ensure a unique ID for any 40source or dest, for filtering purposes. 41sources only dont need to register a callback. 42*/ 43 44/** Register a client. The registration returns a unique client ID (-1 if error) */ 45FLUIDSYNTH_API 46short fluid_sequencer_register_client(fluid_sequencer_t* seq, char* name, 47 fluid_event_callback_t callback, void* data); 48 49/** Unregister a previously registered client. */ 50FLUIDSYNTH_API void fluid_sequencer_unregister_client(fluid_sequencer_t* seq, short id); 51 52/** Returns the number of register clients. */ 53FLUIDSYNTH_API int fluid_sequencer_count_clients(fluid_sequencer_t* seq); 54 55/** Returns the id of a registered client (-1 if non existing) */ 56FLUIDSYNTH_API short fluid_sequencer_get_client_id(fluid_sequencer_t* seq, int index); 57 58/** Returns the name of a registered client, given its id. */ 59FLUIDSYNTH_API char* fluid_sequencer_get_client_name(fluid_sequencer_t* seq, int id); 60 61/** Returns 1 if client is a destination (has a callback) */ 62FLUIDSYNTH_API int fluid_sequencer_client_is_dest(fluid_sequencer_t* seq, int id); 63 64 65 66/** Sending an event immediately. */ 67FLUIDSYNTH_API void fluid_sequencer_send_now(fluid_sequencer_t* seq, fluid_event_t* evt); 68 69 70/** Schedule an event for later sending. If absolute is 0, the time of 71 the event will be offset with the current tick of the 72 sequencer. If absolute is different from 0, the time will assumed 73 to be absolute (starting from the creation of the sequencer). 74 MAKES A COPY */ 75FLUIDSYNTH_API 76int fluid_sequencer_send_at(fluid_sequencer_t* seq, fluid_event_t* evt, 77 unsigned int time, int absolute); 78 79/** Remove events from the event queue. The events can be filtered on 80 the source, the destination, and the type of the event. To avoid 81 filtering, set either source, dest, or type to -1. */ 82FLUIDSYNTH_API 83void fluid_sequencer_remove_events(fluid_sequencer_t* seq, short source, short dest, int type); 84 85 86/** Get the current tick */ 87FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick(fluid_sequencer_t* seq); 88 89/** Set the conversion from tick to absolute time. scale should be 90 expressed as ticks per second. */ 91FLUIDSYNTH_API void fluid_sequencer_set_time_scale(fluid_sequencer_t* seq, double scale); 92 93/** Set the conversion from tick to absolute time (ticks per 94 second). */ 95FLUIDSYNTH_API double fluid_sequencer_get_time_scale(fluid_sequencer_t* seq); 96 97// compile in internal traceing functions 98#define FLUID_SEQ_WITH_TRACE 0 99 100#if FLUID_SEQ_WITH_TRACE 101FLUIDSYNTH_API char * fluid_seq_gettrace(fluid_sequencer_t* seq); 102FLUIDSYNTH_API void fluid_seq_cleartrace(fluid_sequencer_t* seq); 103#endif 104 105#ifdef __cplusplus 106} 107#endif 108 109#endif /* _FLUIDSYNTH_SEQ_H */ 110