comparison README_OSC.md @ 2520:2fa6ee1df046

Reformat README.OSC as markdown and expand and update it a bit
author Chris Cannam
date Wed, 29 Apr 2020 13:29:00 +0100
parents README.OSC@e9c77a4c865e
children c3779574273b
comparison
equal deleted inserted replaced
2519:e9506f77388d 2520:2fa6ee1df046
1
2 OSC control of Sonic Visualiser
3 ===============================
4
5 Sonic Visualiser can be controlled remotely using the Open Sound
6 Control protocol. This facility requires Steve Harris's liblo (Lite
7 OSC) library to have been available when Sonic Visualiser was built.
8
9 Sonic Visualiser opens a single OSC port on startup, provided that OSC
10 support is compiled in, the `--no-osc` command-line option has not
11 been supplied, and permission to use the network was not refused by
12 the user the first time Sonic Visualiser was run.
13
14 The URL of the OSC port is printed to standard output on startup, or
15 can be read from the About box on the Help menu.
16
17
18 General outline
19 ---------------
20
21 OSC commands accepted by Sonic Visualiser take the form:
22
23 ```
24 <scheme>://<host>:<port>/<method> [<arg> ...]
25 ```
26
27 For example, `osc.udp://localhost:12654/play 2.0` will play the
28 current session from time 2.0 seconds.
29
30 Methods that manipulate panes or layers act on the currently selected
31 pane or layer. Use the `setcurrent` method to choose the right target
32 for subsequent such methods.
33
34
35 OSC clients and invocation
36 --------------------------
37
38 If you need an OSC client, there is a small program in the svcore
39 library at `svcore/data/osc/sv-osc-send.c` that sends an OSC method
40 and arguments to a given URL -- this is not specific to SV but will
41 work with it. To compile that program you should only have to run
42
43 ```
44 $ gcc sv-osc-send.c -o sv-osc-send -llo
45 ```
46
47 provided you have liblo installed.
48
49 Then there is a small shell script in the same directory, called
50 `sv-command`, that provides a basic command shell for Sonic
51 Visualiser. Start SV first, then `sv-command` should find its OSC
52 port from the system process table when you start it. For example:
53
54 ```
55 $ PATH=.:$PATH ./sv-command # Set PATH so it can find sv-osc-send
56 /open snare_hex.wav
57 /add spectrogram
58 /set layer Colour Sunset
59 /play
60 /quit
61 $
62 ```
63
64 You can also start Sonic Visualiser directly in "OSC script" mode by
65 supplying the `--osc-script <filename>` command-line option. The
66 argument to this should be the path of a text file containing a series
67 of OSC commands (like those in the example above). These will be
68 executed in succession as quickly as possible. A line that contains
69 only a number, instead of a command, will cause SV to pause for that
70 number of seconds before going on with the script. Lines beginning
71 with `#` are ignored.
72
73 If you supply "-" as the filename argument to the `--osc-script`
74 option, SV will instead read OSC commands from standard input. So you
75 can do something like
76
77 ```
78 $ rlwrap sonic-visualiser --osc-script - /path/to/filename.wav
79 ```
80
81 to obtain a rather limited Sonic Visualiser OSC read-eval loop.
82
83
84 Method reference
85 ----------------
86
87 ### File management
88
89 ```
90 /open <filename>
91 ```
92
93 Open a new file (of type determined by Sonic Visualiser). If it is an
94 audio file, use it to replace the existing main audio file (if any).
95
96 ```
97 /openadditional <filename>
98 ```
99
100 Open a new file. If it is an audio file, open it in a new pane in
101 addition to the existing audio file (if any).
102
103 ```
104 /recent <n>
105 /last
106 ```
107
108 Open the `<n>`th most recent file from the Recent Files menu, counting
109 from 1 for the most recent file opened. "last" is a synonym for
110 "recent 1".
111
112 ```
113 /save <filename>
114 ```
115
116 Save the current session in `<filename>` as an SV session file.
117
118 This action will try to fail rather than overwrite an existing file,
119 but you probably shouldn't rely on that.
120
121 ```
122 /export <filename>
123 ```
124
125 Export the main audio file to `<filename>` in floating-point extended
126 WAV format. If a region is selected, export only that region.
127
128 This action will try to fail rather than overwrite an existing
129 file, but you probably shouldn't rely on that.
130
131 ```
132 /exportlayer <filename>
133 ```
134
135 Export the current layer to `<filename>`. See `/setcurrent` for how to
136 change which layer is current. The format to use is determined from
137 the file extension of `<filename>`:
138
139 * `xml`, `svl` - Sonic Visualiser layer file formats
140 * `mid`, `midi` - MIDI (note layers only)
141 * `ttl`, `n3` - Audio Features Ontology RDF/Turtle (only some layer types)
142 * `csv` - Comma-separated text
143 * anything else - Tab-separated text
144
145 If a region is currently selected, and the file type is CSV,
146 tab-separated, or MIDI, export only that region. Otherwise export
147 the whole layer.
148
149 This action will try to fail rather than overwrite an existing
150 file, but you probably shouldn't rely on that.
151
152 ```
153 /exportimage <filename>
154 ```
155
156 Export a PNG image of the contents of the current pane to
157 `<filename>`. See `/setcurrent` for how to change which pane is
158 current. If a region is currently selected, export only that
159 region. Otherwise export the whole pane. Currently the export will
160 fail if the area to be exported is more than 32767 pixels wide.
161
162 To export to an image of a fixed width regardless of model duration,
163 consider using `/zoom fit` to zoom the model contents to fit the
164 window width, then optionally zooming in or out a known number of
165 steps, before exporting.
166
167 This action will try to fail rather than overwrite an existing file,
168 but you probably shouldn't rely on that.
169
170 ```
171 /exportsvg <filename>
172 ```
173
174 Export a SVG vector graphic of the contents of the current pane to
175 `<filename>`. See `/setcurrent` for how to change which pane is
176 current. If a region is currently selected, export only that
177 region. Otherwise export the whole pane.
178
179 This action will try to fail rather than overwrite an existing file,
180 but you probably shouldn't rely on that.
181
182
183 ### Playback control
184
185 ```
186 /jump <t>
187 /jump end
188 /jump selection
189 ```
190
191 Jump the playback position to time `<t>` (in seconds); or to the end
192 of the file; or to the start of the current selection.
193
194 ```
195 /play
196 /play <t>
197 /play selection
198 ```
199
200 Start playback. If a time `<t>` is given, start from that time in
201 seconds. If the word `selection` is given instead, play the current
202 selection.
203
204 ```
205 /stop
206 ```
207
208 Stop playback.
209
210 ```
211 /loop on
212 /loop off
213 ```
214
215 Switch playback loop mode on or off.
216
217
218 ### Region selection
219
220 ```
221 /select <t0> <t1>
222 /select all
223 /select none
224 ```
225
226 Select the region from times `<t0>` to `<t1>` in seconds; or select
227 the whole file; or clear the selection. If there is a layer selected
228 that can be used as a snap guide for the selection, then the selection
229 will be snapped to it (in the same manner as when making selections
230 interactively).
231
232 ```
233 /addselect <t0> <t1>
234 ```
235
236 Make an additional selection (leaving any existing selection in place)
237 from times `<t0>` to `<t1>` in seconds.
238
239
240 ### Panes, layers, and the window
241
242 ```
243 /add <layertype>
244 /add <layertype> <channel>
245 ```
246
247 Add a new pane containing a layer of the given type, based on the
248 given channel of the main audio file (numbered from 0). If no
249 `<channel>` is specified, mix all channels.
250
251 Useful values of `<layertype>` are:
252
253 ```
254 waveform
255 spectrogram
256 melodicrange
257 peakfrequency
258 spectrum
259 timeruler
260 ```
261
262 The following `<layertype>`s are also accepted:
263
264 ```
265 timeinstants
266 timevalues
267 notes
268 text
269 colour3dplot
270 ```
271
272 But they are less useful, as they create empty layers which there is
273 currently no OSC support for editing.
274
275 ```
276 /setcurrent <pane>
277 /setcurrent <pane> <layer>
278 ```
279
280 Make the given `<pane>` (a number counting from 1 for the topmost
281 pane) and optionally the given `<layer>` on that pane (a number
282 counting from 1 for the "frontmost" layer) the current pane and layer
283 for subsequent pane and layer operations.
284
285 ```
286 /delete pane
287 /delete layer
288 ```
289
290 Delete the current pane or layer.
291
292 ```
293 /set <control> <value>
294 /set pane <control> <value>
295 /set layer <control> <value>
296 ```
297
298 Set a main window control; a property of the current pane; or a
299 property of the current layer.
300
301 Accepted main window controls are:
302
303 * `gain` - whose values are linear multipliers (i.e. 1.0 == unity gain).
304 * `speed` - takes a value of a percentage change in playback speed,
305 so 100 is the default playback speed, 200 sets double the default
306 speed, and 50 sets half the default.
307 * `overlays` - controls the verbosity level of the text overlays on
308 each pane, from 0 (everything off) to 2 (everything on).
309 * `zoomwheels` - controls whether the zoom wheels are displayed (1)
310 or not (0).
311 * `propertyboxes` - controls whether the property boxes are displayed
312 (1) or not (0).
313
314 For pane and layer properties, the control name is the displayed name
315 of the given property (though you may use "-" or "_" in place of any
316 spaces in the name if it's easier for you). The value may be the
317 displayed value or underlying integer for the property.
318
319 Some examples:
320
321 ```
322 /set pane Global-Scroll off
323 /set pane Follow_Playback Scroll
324 /set layer Colour Blue
325 /set layer Scale-Units dB
326 /set layer Frequency-Scale Log
327 ```
328
329 Note that while you can use "-" or "_" in place of spaces in the
330 property name, you cannot currently do so in the value text. If
331 this is a problem for you, you might be able to set the value
332 as an integer instead (all layer properties can be set this way).
333
334 ```
335 /zoom <level>
336 /zoom in
337 /zoom out
338 /zoom fit
339 /zoom default
340 ```
341
342 Zoom to a given zoom `<level>`, given in audio sample frames per
343 pixel; or zoom in or out one step from the current level; or zoom so
344 that the whole model duration fits in the current view width; or
345 return to the default zoom level. This method acts on the current
346 pane (it only affects all panes if set to Global Zoom, which is the
347 default).
348
349 ```
350 /zoomvertical <min> <max>
351 /zoomvertical in
352 /zoomvertical out
353 /zoomvertical default
354 ```
355
356 Change the vertical zoom and origin so as to show the value range from
357 `<min>` to `<max>` in the vertical scale; or zoom in or out
358 vertically; or return to the default vertical zoom level. The effect
359 of this method is heavily dependent on the current layer.
360
361 ```
362 /transform <name>
363 ```
364
365 Transform the current main audio file using the named transform.
366 Transforms are named according to the scheme
367
368 ```
369 type:source:plugin:output
370 ```
371
372 For example, the percussion onset detector from the Vamp example
373 plugin set can be invoked via
374
375 ```
376 /transform vamp:vamp-example-plugins:percussiononsets:onsets
377 ```
378
379 If the output is omitted, the first is used. Note that you need to
380 use the plugin and output name, not description: in this case
381 `percussiononsets` rather than "Simple Percussion Onset Detector".
382
383 There is not yet any way to run a transform via OSC on any but the
384 main audio file, nor with any but its default parameters, processing
385 block/step size, or channel selection.
386
387 ```
388 /resize <w> <h>
389 ```
390
391 Resize the main window to width `<w>` and height `<h>` (if the window
392 system permits).
393
394
395 ### Housekeeping
396
397 ```
398 /undo
399 /redo
400 ```
401
402 Undo the last editing operation; redo the last undone operation. Note
403 that most of the classic editing operations (copy and paste etc) are
404 not controllable via OSC, but undo may still be useful because Sonic
405 Visualiser considers actions such as adding a pane to be undoable
406 editing operations as well.
407
408 ```
409 /quit
410 ```
411
412 Exit the program abruptly without saving.
413
414
415 ### Missing things
416
417 Handy features still missing from the OSC interface include:
418
419 * the ability to run transforms with non-default parameters or
420 starting from different source models
421 * the ability to add layers to a pane (without transform)
422 * the ability to add panes (and layers) showing any but the
423 main model
424 * the ability to set play parameters on a layer/model and show/hide it
425 * the ability to import layers
426 * a working pane resize
427 * the ability to rename a layer
428
429