annotate plugin/api/new_dssi_transport_patch @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents fc9323a41f5a
children
rev   line source
lbajardsilogic@0 1 diff -r dssi-CVS-20051012=0.9.1/dssi/dssi.h _dssi-transport-mine-new/dssi/dssi.h
lbajardsilogic@0 2 5,6c5,6
lbajardsilogic@0 3 < DSSI version 0.9
lbajardsilogic@0 4 < Copyright (c) 2004 Chris Cannam, Steve Harris and Sean Bolton
lbajardsilogic@0 5 ---
lbajardsilogic@0 6 > DSSI version 0.10
lbajardsilogic@0 7 > Copyright (c) 2004,2005 Chris Cannam, Steve Harris and Sean Bolton
lbajardsilogic@0 8 30c30
lbajardsilogic@0 9 < #define DSSI_VERSION "0.9"
lbajardsilogic@0 10 ---
lbajardsilogic@0 11 > #define DSSI_VERSION "0.10"
lbajardsilogic@0 12 32c32
lbajardsilogic@0 13 < #define DSSI_VERSION_MINOR 9
lbajardsilogic@0 14 ---
lbajardsilogic@0 15 > #define DSSI_VERSION_MINOR 10
lbajardsilogic@0 16 76a77,152
lbajardsilogic@0 17 > #define DSSI_TRANSPORT_VALID_STATE 0x01
lbajardsilogic@0 18 > #define DSSI_TRANSPORT_VALID_BPM 0x02
lbajardsilogic@0 19 > #define DSSI_TRANSPORT_VALID_BBT 0x10
lbajardsilogic@0 20 > #define DSSI_TRANSPORT_VALID_TIME 0x20
lbajardsilogic@0 21 >
lbajardsilogic@0 22 > #define DSSI_TRANSPORT_STATE_STOPPED 0
lbajardsilogic@0 23 > #define DSSI_TRANSPORT_STATE_RUNNING 1
lbajardsilogic@0 24 > #define DSSI_TRANSPORT_STATE_FREEWHEELING 2
lbajardsilogic@0 25 > #define DSSI_TRANSPORT_STATE_OTHER 3 /* waiting for sync, ? */
lbajardsilogic@0 26 >
lbajardsilogic@0 27 > typedef struct _DSSI_Transport_Info {
lbajardsilogic@0 28 >
lbajardsilogic@0 29 > /** The value of this field indicates which of the following
lbajardsilogic@0 30 > * transport information fields contain valid values. It is
lbajardsilogic@0 31 > * the logical OR of the DSSI_TRANSPORT_VALID_* bits defined
lbajardsilogic@0 32 > * above, and may be zero. */
lbajardsilogic@0 33 > int Valid;
lbajardsilogic@0 34 >
lbajardsilogic@0 35 >
lbajardsilogic@0 36 > /** This field is valid when (Valid & DSSI_TRANSPORT_VALID_STATE)
lbajardsilogic@0 37 > * is true:
lbajardsilogic@0 38 > *
lbajardsilogic@0 39 > * ---- The current transport state, one of the DSSI_TRANSPORT_STATE_*
lbajardsilogic@0 40 > * values defined above. */
lbajardsilogic@0 41 > int State;
lbajardsilogic@0 42 >
lbajardsilogic@0 43 >
lbajardsilogic@0 44 > /** This field is valid when (Valid & DSSI_TRANSPORT_VALID_BPM)
lbajardsilogic@0 45 > * is true:
lbajardsilogic@0 46 > *
lbajardsilogic@0 47 > * ---- The current tempo, in beats per minute. */
lbajardsilogic@0 48 > double Beats_Per_Minute;
lbajardsilogic@0 49 >
lbajardsilogic@0 50 >
lbajardsilogic@0 51 > /** These six fields are valid when (Valid & DSSI_TRANSPORT_VALID_BBT)
lbajardsilogic@0 52 > * is true:
lbajardsilogic@0 53 > *
lbajardsilogic@0 54 > * ---- The bar number at the beginning of the current process cycle. */
lbajardsilogic@0 55 > unsigned long Bar;
lbajardsilogic@0 56 >
lbajardsilogic@0 57 > * ---- The beat within that Bar. */
lbajardsilogic@0 58 > unsigned long Beat;
lbajardsilogic@0 59 >
lbajardsilogic@0 60 > /** ---- The tick within that Beat. */
lbajardsilogic@0 61 > unsigned long Tick;
lbajardsilogic@0 62 >
lbajardsilogic@0 63 > /** ---- The (possibly fractional) tick count since transport 'start'
lbajardsilogic@0 64 > * and the beginning of the current Bar. */
lbajardsilogic@0 65 > double Bar_Start_Tick;
lbajardsilogic@0 66 >
lbajardsilogic@0 67 > /** ---- The number of beats per bar. */
lbajardsilogic@0 68 > float Beats_Per_Bar;
lbajardsilogic@0 69 >
lbajardsilogic@0 70 > /** ---- The number of ticks for each beat. */
lbajardsilogic@0 71 > double Ticks_Per_Beat;
lbajardsilogic@0 72 >
lbajardsilogic@0 73 > /* [Sean says: I left out the 'beat_type' (time signature "denominator")
lbajardsilogic@0 74 > * field of the jack_position_t structure, because I think it's useless
lbajardsilogic@0 75 > * except to a notation program. Does anybody else feel like we need it?]
lbajardsilogic@0 76 >
lbajardsilogic@0 77 >
lbajardsilogic@0 78 > /** These two fields are valid when (Valid & DSSI_TRANSPORT_VALID_TIME)
lbajardsilogic@0 79 > * is true:
lbajardsilogic@0 80 > *
lbajardsilogic@0 81 > * ---- The transport time at the beginning of the current process
lbajardsilogic@0 82 > * cycle, in seconds. */
lbajardsilogic@0 83 > double Current_Time;
lbajardsilogic@0 84 >
lbajardsilogic@0 85 > /** ---- The transport time at the beginning of the next process
lbajardsilogic@0 86 > cycle, unless repositioning occurs. */
lbajardsilogic@0 87 > double Next_Time;
lbajardsilogic@0 88 >
lbajardsilogic@0 89 > } DSSI_Transport_Info;
lbajardsilogic@0 90 >
lbajardsilogic@0 91 > typedef struct _DSSI_Host_Descriptor DSSI_Host_Descriptor; /* below */
lbajardsilogic@0 92 >
lbajardsilogic@0 93 83,84c159,161
lbajardsilogic@0 94 < * If we're lucky, this will never be needed. For now all plugins
lbajardsilogic@0 95 < * must set it to 1.
lbajardsilogic@0 96 ---
lbajardsilogic@0 97 > * All plugins must set this to 1 or 2. The version 1 API contains
lbajardsilogic@0 98 > * all DSSI_Descriptor fields through run_multiple_synths_adding(),
lbajardsilogic@0 99 > * while the version 2 API adds the receive_host_descriptor().
lbajardsilogic@0 100 376a454,472
lbajardsilogic@0 101 >
lbajardsilogic@0 102 > /**
lbajardsilogic@0 103 > * receive_host_descriptor()
lbajardsilogic@0 104 > *
lbajardsilogic@0 105 > * This member is a function pointer by which a host may provide
lbajardsilogic@0 106 > * a plugin with a pointer to its DSSI_Host_Descriptor. Hosts
lbajardsilogic@0 107 > * which provide host descriptor support must call this function
lbajardsilogic@0 108 > * once per plugin shared object file, before any calls to
lbajardsilogic@0 109 > * instantiate().
lbajardsilogic@0 110 > *
lbajardsilogic@0 111 > * NOTE: This field was added in version 2 of the DSSI API. Hosts
lbajardsilogic@0 112 > * supporting version 2 must not access this field in a plugin
lbajardsilogic@0 113 > * whose DSSI_API_Version is 1, and plugins supporting version 2
lbajardsilogic@0 114 > * should behave reasonably under hosts (of any version) which do
lbajardsilogic@0 115 > * not implement this function. A version 2 plugin that does not
lbajardsilogic@0 116 > * provide this function must set this member to NULL.
lbajardsilogic@0 117 > */
lbajardsilogic@0 118 > void (*receive_host_descriptor)(DSSI_Host_Descriptor *Descriptor);
lbajardsilogic@0 119 >
lbajardsilogic@0 120 377a474,598
lbajardsilogic@0 121 >
lbajardsilogic@0 122 > struct _DSSI_Host_Descriptor {
lbajardsilogic@0 123 >
lbajardsilogic@0 124 > /**
lbajardsilogic@0 125 > * DSSI_API_Version
lbajardsilogic@0 126 > *
lbajardsilogic@0 127 > * This member indicates the DSSI API level used by this host.
lbajardsilogic@0 128 > * All hosts must set this to 2. Hopefully, we'll get this right
lbajardsilogic@0 129 > * the first time, and this will never be needed.
lbajardsilogic@0 130 > */
lbajardsilogic@0 131 > int DSSI_API_Version;
lbajardsilogic@0 132 >
lbajardsilogic@0 133 > /**
lbajardsilogic@0 134 > * request_tranport_information()
lbajardsilogic@0 135 > *
lbajardsilogic@0 136 > * This member is a function pointer by which a plugin instance may
lbajardsilogic@0 137 > * request that a host begin providing transport information (if
lbajardsilogic@0 138 > * Request is non-zero), or notify the host that it no longer needs
lbajardsilogic@0 139 > * transport information (if Request is zero). Upon receiving a
lbajardsilogic@0 140 > * non-zero request, the host should return a pointer to a
lbajardsilogic@0 141 > * DSSI_Transport_Info structure if it is able to provide transport
lbajardsilogic@0 142 > * information, or NULL otherwise.
lbajardsilogic@0 143 > *
lbajardsilogic@0 144 > * Once a plugin instance has received a non-null transport
lbajardsilogic@0 145 > * information pointer, it may read from the structure at any time
lbajardsilogic@0 146 > * within the execution of an audio class function (see doc/RFC.txt).
lbajardsilogic@0 147 > * It should not consider the structure contents to be meaningful
lbajardsilogic@0 148 > * while within a instantiation or control class function. Also,
lbajardsilogic@0 149 > * since the validity of fields within the structure may change
lbajardsilogic@0 150 > * between each new invocation of an audio class function, a plugin
lbajardsilogic@0 151 > * instance must check the Valid field of the structure accordingly
lbajardsilogic@0 152 > * before using the structure's other contents.
lbajardsilogic@0 153 > *
lbajardsilogic@0 154 > * A host which does not support this function must set this member
lbajardsilogic@0 155 > * to NULL.
lbajardsilogic@0 156 > */
lbajardsilogic@0 157 > DSSI_Transport_Info *
lbajardsilogic@0 158 > (*request_transport_information)(LADSPA_Handle Instance,
lbajardsilogic@0 159 > int Request);
lbajardsilogic@0 160 >
lbajardsilogic@0 161 > /**
lbajardsilogic@0 162 > * request_midi_send()
lbajardsilogic@0 163 > *
lbajardsilogic@0 164 > * This member is a function pointer that allows a plugin to
lbajardsilogic@0 165 > * request the ability to send MIDI events to the host.
lbajardsilogic@0 166 > *
lbajardsilogic@0 167 > * While the interpretation of plugin-generated MIDI events is
lbajardsilogic@0 168 > * host implementation specific, a mechanism exists by which a
lbajardsilogic@0 169 > * plugin may declare to the host the number of destination
lbajardsilogic@0 170 > * 'ports' and MIDI channels it can expect will be used in the
lbajardsilogic@0 171 > * plugin-generated events. Plugins which generate unchannelized
lbajardsilogic@0 172 > * MIDI should supply zero for both Ports and Channels, otherwise
lbajardsilogic@0 173 > * they should supply the maximum numbers for Ports and Channels
lbajardsilogic@0 174 > * they expect to use.
lbajardsilogic@0 175 > *
lbajardsilogic@0 176 > * A plugin instance must call this function during instantiate().
lbajardsilogic@0 177 > * [Sean says: this restriction seems reasonable to me, since
lbajardsilogic@0 178 > * the host may need to create output ports, etc., and instantiate()
lbajardsilogic@0 179 > * seems like a good place to do such things. I'm sure I haven't
lbajardsilogic@0 180 > * fully thought through all the details, though....]
lbajardsilogic@0 181 > *
lbajardsilogic@0 182 > * The host should return a non-zero value if it is able to
lbajardsilogic@0 183 > * provide MIDI send for the plugin instance, otherwise it should
lbajardsilogic@0 184 > * return zero, and the plugin instance may not subsequently call
lbajardsilogic@0 185 > * midi_send().
lbajardsilogic@0 186 > *
lbajardsilogic@0 187 > * A host which does not support the MIDI send function must set
lbajardsilogic@0 188 > * both this member and (*midi_send)() below to NULL.
lbajardsilogic@0 189 > */
lbajardsilogic@0 190 > int (*request_midi_send)(LADSPA_Handle Instance,
lbajardsilogic@0 191 > unsigned char Ports,
lbajardsilogic@0 192 > unsigned char Channels);
lbajardsilogic@0 193 >
lbajardsilogic@0 194 > /**
lbajardsilogic@0 195 > * midi_send()
lbajardsilogic@0 196 > *
lbajardsilogic@0 197 > * This member is a function pointer by which a plugin actually
lbajardsilogic@0 198 > * sends MIDI events to the host (provided it has received a non-
lbajardsilogic@0 199 > * zero return from request_midi_send()). As in the run_synth()
lbajardsilogic@0 200 > * functions, the Event pointer points to a block of EventCount
lbajardsilogic@0 201 > * ALSA sequencer events. The dest.port and data.*.channel fields
lbajardsilogic@0 202 > * of each event are used to specify destination port and channel,
lbajardsilogic@0 203 > * respectively, when the plugin is supplying channelized events.
lbajardsilogic@0 204 > *
lbajardsilogic@0 205 > * A plugin may only call this function from within the execution
lbajardsilogic@0 206 > * of the audio class run_*() or select_program() functions. When
lbajardsilogic@0 207 > * called from a run_*() functions, the events are timestamped
lbajardsilogic@0 208 > * relative to the start of the block, (mis)using the ALSA "tick
lbajardsilogic@0 209 > * time" field as a frame count. The plugin is responsible for
lbajardsilogic@0 210 > * ensuring that events with differing timestamps are already
lbajardsilogic@0 211 > * ordered by time, and that timestamps across multiple calls to
lbajardsilogic@0 212 > * midi_send() from within the same run_*() invocation are
lbajardsilogic@0 213 > * monotonic. When midi_send() is called from within
lbajardsilogic@0 214 > * select_program(), the timestamps are ignored, and the events
lbajardsilogic@0 215 > * are considered to originate at the same frame time as the
lbajardsilogic@0 216 > * select_program() call, if such a timing can be considered
lbajardsilogic@0 217 > * meaningful.
lbajardsilogic@0 218 > *
lbajardsilogic@0 219 > * The memory pointed to by Event belongs to the plugin, and it is
lbajardsilogic@0 220 > * the host's responsibility to copy the events as needed before
lbajardsilogic@0 221 > * returning from the midi_send() call.
lbajardsilogic@0 222 > *
lbajardsilogic@0 223 > * A host which does not support the MIDI send function must set
lbajardsilogic@0 224 > * both this member and (*request_midi_send)() above to NULL.
lbajardsilogic@0 225 > */
lbajardsilogic@0 226 > void (*midi_send)(LADSPA_Handle Instance,
lbajardsilogic@0 227 > snd_seq_event_t *Event,
lbajardsilogic@0 228 > unsigned long EventCount);
lbajardsilogic@0 229 >
lbajardsilogic@0 230 > /**
lbajardsilogic@0 231 > * . . . additional fields could follow here, possibly supporting:
lbajardsilogic@0 232 > *
lbajardsilogic@0 233 > * - a facility by which a plugin instance may request from a
lbajardsilogic@0 234 > * host a non-realtime thread in which to do off-line
lbajardsilogic@0 235 > * rendering, I/O, etc., thus (hopefully) avoiding the
lbajardsilogic@0 236 > * crashes that seem to occur when plugins create their own
lbajardsilogic@0 237 > * threads. I got this idea after noticing that ZynAddSubFX
lbajardsilogic@0 238 > * achieves its gorgeous textures while remaining very
lbajardsilogic@0 239 > * responsive by doing a lot of non-real-time rendering.
lbajardsilogic@0 240 > * Several other uses for it have been mentioned on the DSSI
lbajardsilogic@0 241 > * list; I forget what.
lbajardsilogic@0 242 > *
lbajardsilogic@0 243 > * - per-voice audio output
lbajardsilogic@0 244 > */
lbajardsilogic@0 245 > };