~ubuntu-branches/ubuntu/utopic/glame/utopic

« back to all changes in this revision

Viewing changes to doc/gpsm.texi

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-09 17:14:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020409171412-jzpnov7mbz2w6zsr
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@comment $Id: gpsm.texi,v 1.2 2001/05/04 08:02:10 richi Exp $
 
2
 
 
3
@node GLAME Project Structure Management, Plugin Interface, Swapfile API, Top
 
4
@chapter GLAME Project Structure Management
 
5
 
 
6
The project structure management including track metadata and coupling
 
7
with the swapfile/filter API.
 
8
 
 
9
The structure is build out of gpsm-items which can be either groups
 
10
(gpsm_grp_t) or swapfile files (gpsm_swfile_t). Think of the structure
 
11
as of a tree with leafs all being swapfile files (or equivalent types,
 
12
if they ever will appear) and the interior nodes being groups. Groups
 
13
(generic: items) have horizontal (samples) and vertical (tracks) extend,
 
14
items have horizontal (samples) and vertical (track) positions.
 
15
 
 
16
Usage of the gpsm API is by the various GUI widgets that handle the
 
17
swapfile and the filters such as the swapfile gui and the timeline
 
18
gui. Also use by the scheme scripts is the preferred way to work on the
 
19
swapfile.  Consistent updating of all interfaces can be realized by
 
20
registering appropriate signal handlers to the gpsm-items
 
21
emitter. Signals are sent out by all gpsm API functions and have to be
 
22
sent out manually by everyone operating on the swapfile/gpsm-items _not_
 
23
using the gpsm API functions.
 
24
 
 
25
 
 
26
@menu
 
27
* Generic operations on items::
 
28
* The group item::
 
29
* The swfile item::
 
30
* GPSM signals and their semantics::
 
31
* Undo and redo support::
 
32
@end menu
 
33
 
 
34
 
 
35
@node Generic operations on items, The group item, , GLAME Project Structure Management
 
36
@section Generic operations on items
 
37
 
 
38
Every item in the project tree has information of its parent, a signal
 
39
emitter where you can attach handlers to, a label and last but not least
 
40
a 2D position and a 2D size. Those elements can be accessed using the
 
41
following functions:
 
42
 
 
43
@tindex gpsm_item_t
 
44
@deftypefun {gpsm_item_t *} gpsm_item_parent (gpsm_item_t *@var{item})
 
45
Returns the parent item of the provided item or NULL, if the item is
 
46
the root of a gpsm tree.
 
47
@end deftypefun
 
48
 
 
49
@tindex gpsm_item_t
 
50
@tindex glsig_emitter_t
 
51
@deftypefun {glsig_emitter_t *} gpsm_item_emitter (gpsm_item_t *@var{item})
 
52
Returns the signal emitter of the provided item.
 
53
@end deftypefun
 
54
 
 
55
@tindex gpsm_item_t
 
56
@deftypefun {const char *} gpsm_item_label (gpsm_item_t *@var{item})
 
57
Returns the label of the provided item. Note that the result is strictly
 
58
read-only.
 
59
@end deftypefun
 
60
 
 
61
@tindex gpsm_item_t
 
62
@deftypefun {long} gpsm_item_hposition (gpsm_item_t *@var{item})
 
63
@deftypefunx {long} gpsm_item_vposition (gpsm_item_t *@var{item})
 
64
@deftypefunx {long} gpsm_item_hsize (gpsm_item_t *@var{item})
 
65
@deftypefunx {long} gpsm_item_vsize (gpsm_item_t *@var{item})
 
66
These functions return the actual position (horizontal or vertical) or
 
67
the actual size (horizontal or vertical) of the provided item. Both
 
68
horizontal position and size are measured in samples. Both vertical
 
69
position and size are measured in tracks. Positions and sizes are
 
70
positive or zero.
 
71
@end deftypefun
 
72
 
 
73
 
 
74
Common operations you can carry out on an items are item destruction,
 
75
insertion and removal, setting of the label and flattening.
 
76
 
 
77
@tindex gpsm_item_t
 
78
@deftypefun void gpsm_item_destroy (gpsm_item_t *@var{item})
 
79
Destroys the provided gpsm item. The item is first removed from its
 
80
group, if necessary and then destructed in child-first order. Appropriate
 
81
signals are send out for this operation, namely @code{GPSM_SIG_ITEM_REMOVE}
 
82
(and the @code{GPSM_SIG_GRP_REMOVEITEM} signal to the items group) if
 
83
removal is required and @code{GPSM_SIG_ITEM_DESTROY}.
 
84
@end deftypefun
 
85
 
 
86
@tindex gpsm_item_t
 
87
@tindex gpsm_grp_t
 
88
@deftypefun int gpsm_grp_insert (gpsm_grp_t *@var{group}, gpsm_item_t *@var{item}, long @var{hposition}, long @var{vposition})
 
89
Inserts the specified gpsm-item into the group at the specified
 
90
position. Random (non-overlapping) h-/v-positioning is performed if you
 
91
pass -1 to h-/v-position.  May fail, as overlapping items are not
 
92
allowed. Returns 0 on success and -1 on error. Appropriate signals are
 
93
send out for this operation, namely @code{GPSM_SIG_GRP_NEWITEM} to the
 
94
group.
 
95
@end deftypefun
 
96
 
 
97
@tindex gpsm_item_t
 
98
@deftypefun void gpsm_item_remove (gpsm_item_t *@var{item})
 
99
Removes the specified gpsm-item from its current group. The items
 
100
position will be (0,0) after this operation. If the item was not member
 
101
of a group this is a NOP. Appropriate signals are send out for this
 
102
operation, namely @code{GPSM_SIG_ITEM_REMOVE} and the
 
103
@code{GPSM_SIG_GRP_REMOVEITEM} signal to the items group.
 
104
@end deftypefun
 
105
 
 
106
@tindex gpsm_item_t
 
107
@deftypefun void gpsm_item_set_label (gpsm_item_t *@var{item}, const char *@var{label})
 
108
Updates the label of the specified gpsm-item. Note that this will cause
 
109
a @code{GPSM_SIG_ITEM_CHANGED} signal to be send out.
 
110
@end deftypefun
 
111
 
 
112
@tindex gpsm_item_t
 
113
@deftypefun void gpsm_flatten (gpsm_item_t *@var{item})
 
114
Flattens a gpsm item, that is, out of a possible deep tree of
 
115
horizontally and vertically spreaded swfiles make a set of vertically
 
116
aligned (read: starting at position zero and ending at the maximum
 
117
position) swfiles.  Returns a new group with new swfiles, one for each
 
118
vertical track.  The data is COWed from the original tree. In the
 
119
special case of providing a swfile as item a new group with a COW copy
 
120
of this item is returned (without paying attention to hposition of the
 
121
item).  On failure NULL is returned.  Note that this feature greatly
 
122
simplifies operations such as play and export (i.e. where you only want
 
123
to _read_ from the files).
 
124
@end deftypefun
 
125
 
 
126
 
 
127
 
 
128
@node The group item, The swfile item, Generic operations on items, GLAME Project Structure Management
 
129
@section The group item
 
130
 
 
131
Group items form the back of the gpsm tree, they contain an arbitrary number
 
132
of items positioned relative to their parent. You can access a groups items
 
133
via the following generic iterators:
 
134
 
 
135
@tindex gpsm_grp_t
 
136
@tindex gpsm_item_t
 
137
@deftypefn Iterator {} gpsm_grp_foreach_item (gpsm_grp_t *@var{group}, gpsm_item_t *@var{item}) @{ @}
 
138
You can iterate through all items contained in the specified @var{group}
 
139
using the iterator (which acts like a for statement with the second
 
140
parameter as running variable). Note that you may not delete instances
 
141
in this loop!
 
142
@end deftypefn
 
143
 
 
144
@tindex gpsm_grp_t
 
145
@tindex gpsm_item_t
 
146
@deftypefn Iterator {} gpsm_grp_safe_foreach_item (gpsm_grp_t *@var{group}, void *@var{dummy}, gpsm_item_t *@var{item}) @{ @}
 
147
You can iterate through all items contained in the specified @var{group}
 
148
using the iterator (which acts like a for statement with the second
 
149
parameter as running variable). You may delete the actual @var{item} within
 
150
this iterator, but you have to specify another @var{dummy} pointer to use for
 
151
this to work.
 
152
@end deftypefn
 
153
 
 
154
 
 
155
There are a few operations specialized to work on group items only, namely
 
156
group creation and tree searching.
 
157
 
 
158
@tindex gpsm_grp_t
 
159
@deftypefun {gpsm_grp_t *} gpsm_newgrp (const char *@var{label})
 
160
Creates a new empty gpsm group with the specified @var{label}. You have
 
161
to insert it into a gpsm group yourself. Returns a gpsm group or NULL on
 
162
error.
 
163
@end deftypefun
 
164
 
 
165
@tindex gpsm_grp_t
 
166
@tindex gpsm_item_t
 
167
@deftypefun {gpsm_grp_t *} gpsm_find_grp_label (gpsm_grp_t *@var{root}, gpsm_item_t *@var{start}, const char *@var{label})
 
168
Find a gpsm-grp by label in the subtree specified by root. The search is
 
169
started at the item start (or at the root, if you specify NULL). You can
 
170
find all occurences by specifying the previous result as start. Returns
 
171
a gpsm-grp, if found or NULL, if not.
 
172
@end deftypefun
 
173
 
 
174
@tindex gpsm_grp_t
 
175
@tindex gpsm_item_t
 
176
@tindex gpsm_swfile_t
 
177
@deftypefun {gpsm_swfile_t *} gpsm_find_swfile_label (gpsm_grp_t *@var{root}, gpsm_item_t *@var{start}, const char *@var{label})
 
178
Find a gpsm-swfile by label in the subtree specified by root. The search
 
179
is started at the item start (or at the root, if you specify NULL). You
 
180
can find all occurences by specifying the previous result as
 
181
start. Returns a gpsm-swfile, if found or NULL, if not.
 
182
@end deftypefun
 
183
 
 
184
@tindex gpsm_grp_t
 
185
@tindex gpsm_item_t
 
186
@tindex gpsm_swfile_t
 
187
@deftypefun {gpsm_swfile_t *} gpsm_find_swfile_filename (gpsm_grp_t *@var{root}, gpsm_item_t *@var{start}, long @var{filename})
 
188
Find a gpsm-swfile by filename in the subtree specified by root. The
 
189
search is started at the item start (or at the root, if you specify
 
190
NULL). You can find all occurences by specifying the previous result as
 
191
start. Returns a gpsm-swfile, if found or NULL, if not. */
 
192
@end deftypefun
 
193
 
 
194
@tindex gpsm_grp_t
 
195
@tindex gpsm_item_t
 
196
@tindex gpsm_swfile_t
 
197
@deftypefun {gpsm_swfile_t *} gpsm_find_swfile_vposition (gpsm_grp_t *@var{root}, gpsm_item_t *@var{start}, long @var{vposition})
 
198
Find a gpsm-swfile by vposition in the subtree specified by root. The
 
199
search is started at the item start (or at the root, if you specify
 
200
NULL). You can find all occurences by specifying the previous result as
 
201
start. Returns a gpsm-swfile, if found or NULL, if not.
 
202
@end deftypefun
 
203
 
 
204
 
 
205
@node The swfile item, GPSM signals and their semantics, The group item, GLAME Project Structure Management
 
206
@section The swfile item
 
207
 
 
208
The swfile items are the leafs of the gpsm tree, they are the connection
 
209
between the backing store and the different views. Swfiles provide a
 
210
swapfile filename, a samplerate and a position which can be accessed
 
211
using the following functions:
 
212
 
 
213
@tindex gpsm_swfile_t
 
214
@deftypefun long gpsm_swfile_filename (gpsm_swfile_t *@var{swfile})
 
215
Returns the swapfile filename of the gpsm swfile item.
 
216
@end deftypefun
 
217
 
 
218
@tindex gpsm_swfile_t
 
219
@deftypefun int gpsm_swfile_samplerate (gpsm_swfile_t *@var{swfile})
 
220
Returns the samplerate of the gpsm swfile item.
 
221
@end deftypefun
 
222
 
 
223
@tindex gpsm_swfile_t
 
224
@deftypefun float gpsm_swfile_position (gpsm_swfile_t *@var{swfile})
 
225
Returns the stream position of the gpsm swfile item.
 
226
@end deftypefun
 
227
 
 
228
 
 
229
There exist a quite large number of specialized operations on swfile items,
 
230
including file creation, copying and linking, setting of the data and
 
231
notifying gpsm and its users about changes to the swapfile file data.
 
232
 
 
233
@tindex gpsm_swfile_t
 
234
@deftypefun {gpsm_swfile_t *} gpsm_newswfile (const char *@var{label})
 
235
Creates a new spare swapfile to operate with. You have to insert it into
 
236
a gpsm group yourself. Returns a gpsm-swfile or NULL on error.
 
237
@end deftypefun
 
238
 
 
239
@tindex gpsm_swfile_t
 
240
@deftypefun {gpsm_swfile_t *} gpsm_swfile_cow (gpsm_swfile_t *@var{swfile})
 
241
Creates a new swapfile with contents from the swapfile specified by the
 
242
gpsm-swfile. Returns a gpsm-swfile or NULL on error.
 
243
@end deftypefun
 
244
 
 
245
@tindex gpsm_swfile_t
 
246
@deftypefun {gpsm_swfile_t *} gpsm_swfile_link (gpsm_swfile_t *@var{swfile})
 
247
Creates a new gpsm-swfile with the swapfile of the specified gpsm-swfile
 
248
as backing store. Returns a gpsm-swfile or NULL on error.
 
249
@end deftypefun
 
250
 
 
251
@tindex gpsm_swfile_t
 
252
@deftypefun void gpsm_swfile_set (gpsm_swfile_t *@var{swfile}, int @var{samplerate}, float @var{position})
 
253
@deftypefunx void gpsm_swfile_set_samplerate (gpsm_swfile_t *@var{swfile}, int @var{samplerate})
 
254
@deftypefunx void gpsm_swfile_set_position (gpsm_swfile_t *@var{swfile}, float @var{position})
 
255
Updates the samplerate and/or position of the specified
 
256
gpsm-swfile. Note that this information is per gpsm-swfile, not per
 
257
swapfile! Note that this will cause a @code{GPSM_SIG_ITEM_CHANGED}
 
258
signal to be send out.
 
259
@end deftypefun
 
260
 
 
261
@deftypefun void gpsm_notify_swapfile_change (long @var{filename}, long @var{pos}, long @var{size})
 
262
@deftypefunx void gpsm_notify_swapfile_cut (long @var{filename}, long @var{pos}, long @var{size})
 
263
@deftypefunx void gpsm_notify_swapfile_insert (long @var{filename}, long @var{pos}, long @var{size})
 
264
@strong{After} you've done an operation on a swapfile such as modifying
 
265
or cutting/inserting via @code{sw_sendfile()} you have to notify the
 
266
GPSM about this change. The swfiles sizes will be updated and
 
267
appropriate signals will be send out.  Note that it is generally better
 
268
to make changes to a swapfile through gpsm functions (which dont exist
 
269
at the moment...).
 
270
@end deftypefun
 
271
 
 
272
@deftypefun void gpsm_invalidate_swapfile (long @var{filename})
 
273
If you have done changes to a swapfile which you cannot (or would not
 
274
like to) specify explicitly you can tell gpsm and its users to start
 
275
from scratch with this file. Note that this is a costly operation and it
 
276
is generally better to use the finer grained notify functions above.
 
277
@end deftypefun
 
278
 
 
279
 
 
280
 
 
281
@node GPSM signals and their semantics, Undo and redo support, The swfile item, GLAME Project Structure Management
 
282
@section GPSM signals and their semantics
 
283
 
 
284
There are a vast number of signals send out by the gpsm subsystem which
 
285
are described syntactically and semantically here. Signal names are
 
286
constructed with the prefix @code{GPSM_SIG} the infix denoting the type
 
287
of object and the type of the first argument it is sent to such as
 
288
@code{ITEM}, @code{SWFILE} and @code{GRP} and a suffix denoting the
 
289
semantics. A list of available signals follows.
 
290
 
 
291
The first group is the signals sent to all type of items (thus the
 
292
@code{ITEM} infix).
 
293
 
 
294
@table @strong
 
295
@item GPSM_SIG_ITEM_CHANGED
 
296
@code{GPSM_SIG_ITEM_CHANGED} has one parameter, the gpsm-item.  The
 
297
signal will be sent out @strong{after} a change to any of the items data
 
298
elements.  Note that @code{GPSM_SIG_ITEM_CHANGED} delivery is not
 
299
suppressed, if the change has a semantically more specific signal like
 
300
one of the @code{GPSM_SIG_GRP_*} or @code{GPSM_SIG_SWFILE_*}
 
301
signals. Also a @code{GPSM_SIG_ITEM_CHANGED} signal is sent out on item
 
302
re-position.
 
303
 
 
304
@item GPSM_SIG_ITEM_DESTROY
 
305
@code{GPSM_SIG_ITEM_DESTROY} has one parameter, the gpsm-item. The
 
306
signal will be sent out @strong{before} item destruction. Note that
 
307
items attached to a group will generally recieve a
 
308
@code{GPSM_SIG_GRP_REMOVEITEM} signal before destruction, i.e.
 
309
@code{gpsm_item_destroy()} will remove them first, then destruct.
 
310
 
 
311
@item GPSM_SIG_ITEM_REMOVE
 
312
@code{GPSM_SIG_ITEM_REMOVE} has one parameter, the gpsm-item. The signal
 
313
will be sent out @strong{before} item removal from its group.  The
 
314
@code{GPSM_SIG_GRP_REMOVEITEM} signal will be send out to the group
 
315
after this signal.
 
316
 
 
317
@end table
 
318
 
 
319
The second group is the signals sent to groups only (thus the @code{GRP}
 
320
infix).
 
321
Both @code{GPSM_SIG_GRP_NEWITEM} and @code{GPSM_SIG_GRP_REMOVEITEM} have
 
322
two parameters, the gpsm-grp as the first and the gpsm-item to be
 
323
inserted/removed as second one. The @code{GPSM_SIG_GRP_REMOVEITEM}
 
324
signal is sent out before item removal and after the item recieved the
 
325
@code{GPSM_SIG_ITEM_REMOVE} signal, the @code{NEWITEM} signal after item
 
326
addition.
 
327
 
 
328
@strong{NOTE}: If the actual item is a group it is certainly possible
 
329
for it to contain children!
 
330
 
 
331
@strong{NOTE2}: You may want to attach/remove signal handlers to the
 
332
item (and the possible childrens of a group)
 
333
 
 
334
 
 
335
@table @strong
 
336
@item GPSM_SIG_GRP_NEWITEM
 
337
@item GPSM_SIG_GRP_REMOVEITEM
 
338
@end table
 
339
 
 
340
The third and last group is the signals sent out to swfiles only (thus
 
341
the @code{SWFILE} infix).
 
342
The @code{GPSM_SIG_SWFILE_*} have three parameters, the first is the
 
343
gpsm-swfile itself, the second is a long position, the third a long size
 
344
specifying position and size of the inserted / cutted / changed data in
 
345
samples. This signal is sent _after_ the actual operation was carried
 
346
out on the swapfile.
 
347
 
 
348
@table @strong
 
349
@item GPSM_SIG_SWFILE_INSERT
 
350
@item GPSM_SIG_SWFILE_CUT
 
351
@item GPSM_SIG_SWFILE_CHANGED
 
352
@end table
 
353
 
 
354
 
 
355
@node Undo and redo support, , GPSM signals and their semantics, GLAME Project Structure Management
 
356
@section Undo and redo support
 
357
 
 
358
GPSM provides an easy way to support undo and redo at the scope of a
 
359
GPSM group (or a single swfile). To be able to do this you need to
 
360
manually save the state of a group before operating on it, undo and
 
361
redo then can automatically roll back to these saved states.
 
362
 
 
363
The maximum number of saved states can be configured by using the
 
364
following function (it is safe to call it before or after @code{gpsm_init()}):
 
365
 
 
366
@deftypefun int gpsm_set_max_saved_ops (int @var{max})
 
367
Changes (or just queries, if max < 0) the maximum number of states saved
 
368
for undo/redo. Returns the actual set value.
 
369
@end deftypefun
 
370
 
 
371
The following functions treating with undo and redo are available:
 
372
 
 
373
@tindex gpsm_item_t
 
374
@deftypefun int gpsm_op_prepare (gpsm_item_t *@var{item})
 
375
Save the current state of the provided subtree for later undo.  Returns
 
376
0 on success, -1 on failure.
 
377
@end deftypefun
 
378
 
 
379
@tindex gpsm_item_t
 
380
@deftypefun int gpsm_op_can_undo (gpsm_item_t *@var{item})
 
381
Returns 1 if undo is pending for the subtree item and can be undone at
 
382
this point, else returns 0.
 
383
@end deftypefun
 
384
 
 
385
@tindex gpsm_item_t
 
386
@deftypefun int gpsm_op_undo (gpsm_item_t *@var{item})
 
387
Rolls back to the latest saved state of the provided subtree.  Returns 0
 
388
on success, -1 on error (such as no undo pending or possible).  Saves
 
389
the actual state for later redo.
 
390
@end deftypefun
 
391
 
 
392
@tindex gpsm_item_t
 
393
@deftypefun int gpsm_op_undo_and_forget (gpsm_item_t *@var{item})
 
394
Rolls back to the latest saved state of the provided subtree.  Returns 0
 
395
on success, -1 on error (such as no undo pending or possible).  Does not
 
396
save the actual state for later redo.
 
397
@end deftypefun
 
398
 
 
399
@tindex gpsm_item_t
 
400
@deftypefun int gpsm_op_can_redo (gpsm_item_t *@var{item})
 
401
Returns 1 if redo is pending for the subtree item and can be redone at
 
402
this point, else returns 0.
 
403
@end deftypefun
 
404
 
 
405
@tindex gpsm_item_t
 
406
@deftypefun int gpsm_op_redo (gpsm_item_t *@var{item})
 
407
Rolls back to the state before the previous undo to the provided
 
408
subtree. Returns 0 on success, -1 on error (such as no redo pending or
 
409
possible). Saves the actual state for later undo.
 
410
@end deftypefun
 
411
 
 
412
@tindex gpsm_item_t
 
413
@deftypefun int gpsm_op_redo_and_forget (gpsm_item_t *@var{item})
 
414
Rolls back to the state before the previous undo to the provided
 
415
subtree. Returns 0 on success, -1 on error (such as no redo pending or
 
416
possible). Does not save the actual state for later undo.
 
417
@end deftypefun
 
418
 
 
419
@tindex gpsm_item_t
 
420
@deftypefun int gpsm_op_forget (gpsm_item_t *@var{item})
 
421
Kills off the latest saved state of the provided subtree. Returns 0 on
 
422
success, -1 on error (no pending undo or redo).
 
423
@end deftypefun