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