Signaux OSC

From TidalCycles userbase
Revision as of 02:25, 15 December 2019 by Raphael (talk | contribs) (Created page with "Le second exemple privilégie plutôt <source inline>MessageStamp</source>, qui est similaire. Au lieu de placer le message dans un lot, la signature temporelle est définie p...")
Jump to: navigation, search
Other languages:
English • ‎français

Une version de Tidal supérieure à la 1.0.6 est nécessaire.

Il est possible de définir vos propres messages OSC (Open Sound Control), pour atteindre des logiciels autres que SuperDirt ou Dirt. Voici quelques exemples :

  customTarget = OSCTarget {oName = "MyStrangeSoftware", -- Give your target a name
                            oAddress = "", -- the target network address
                            oPort = 5050, -- the target network port
                            oPath = "/trigger/something", -- the OSC path
                            oShape = Nothing, -- The 'shape' - see below
                            oLatency = 0.02, -- the latency (to smooth network jitter)
                            oPreamble = [], -- Some fixed data to put at the start of messages
                            oTimestamp = BundleStamp -- The style of timestamp
  anotherTarget :: OSCTarget
  anotherTarget = OSCTarget {oName = "Another one",
                             oAddress = "",
                             oPort = 7771,
                             oPath = "/play",
                             oShape = Just [("note", Nothing),
                                            ("distortion", Just $ VF 0),
                                            ("loops", Just $ VI 1),
                                            ("vowel", Just $ VS "a"),
                                            ("sec", Just $ VI 0),
                                            ("usec", Just $ VI 0)
                             oLatency = 0.02,
                             oPreamble = [],
                             oTimestamp = MessageStamp

Dans le premier exemple ci-dessus, BundleStamp permet l'envoi 'ahead of time in batches' d'un message, à la vitesse définie par le cFrameTimespan défini dans la configuration de Tidal. Chaque message OSC sera placé dans un lot de messages avec une signature temporelle. Ce sera au client qui reçoit le message de scheduler le message correctement.

Le second exemple privilégie plutôt MessageStamp, qui est similaire. Au lieu de placer le message dans un lot, la signature temporelle est définie par deux entiers (sec et usec), à savoir le nombre de secondes et de micro-secondes depuis l'epoch UNIX.

Note also that the first example doesn't give an oShape. This means that tidal will send whatever parameters you use in the pattern. It will do this as named parameters, that is, each parameter will be preceded by the name of the parameter, as a string.

The second example does give an oShape, as a list of names and default values. Note that the "s" control parameter doesn't have a default value. This means that OSC messages won't get sent unless the "s" control is defined in the pattern.

Using a target

Once you've defined your target, you can use it like this:

tidal <- startTidal customTarget defaultConfig

let p = streamReplace tidal

p 1 $ s "bd sn" # vowel "a"

If you want to send messages to more than one target at once, you can do it like this:

tidal <- startMulti [customTarget, anotherTarget] defaultConfig

let p = streamReplace tidal

p 1 $ s "bd sn" # vowel "a"

See the standard BootTidal.hs for how the usual functions for interacting with tidal are defined.

Example with FAUST

Let's make the Simple Example noise generator from the FAUST manual work with TidalCycles. (Please be careful, loud noise can destroy your speakers or hearing.) Compile it as explained so it will listen for OSC messages on port 5510. The matching TidalCycles OSCTarget is this:

OSCTarget {oName = "Noise", oAddress = "", oPort = 5510,
  oPath = "/noise/level", oShape = Just [("level", Just $ VF 0)],
  oLatency = 0.02, oPreamble = [], oTimestamp = MessageStamp}

In the second line the OSC message is defined.

To make level usable like usual also define

let level = pF "level"

Now if you run

d1 $ level "0.5 1" --let the level jump between -6 and 0 dBFS.

the resulting OSC message is equivalent to running

$ oscsend localhost 5510 "/noise/level" f 0.5
$ sleep 1
$ oscsend localhost 5510 "/noise/level" f 1

on a command line.


One way to debug OSC is to use a packet sniffer like wireshark. You can put "osc" in the filter field (no double quotes) to filter out everything except OSC packets. If you click on an OSC network packet and expand fields you can find a nicely formatted representation of your OSC message.