Skip to content

Instantly share code, notes, and snippets.

@jarmitage
Last active February 5, 2024 05:16
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jarmitage/100ec087997100b448f173a0258d1885 to your computer and use it in GitHub Desktop.
Save jarmitage/100ec087997100b448f173a0258d1885 to your computer and use it in GitHub Desktop.
TidalCycles Bitwig OSC API (WIP)
:{
let bwAddress = "127.0.0.1"
bwPort = 8000
bwLatency = 0.02
bwPreamble = []
bwTimestamp = BundleStamp
:}
-- TEMPO
:{
bwTempoTarget = OSCTarget {oName = "BitwigTempo", oAddress = bwAddress, oPort = bwPort,
oPath = "/tempo/raw", oShape = Just [("raw", Just $ VF 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp
}
:}
-- SCENE
:{
bwSceneTarget = OSCTarget {oName = "BitwigScene", oAddress = bwAddress, oPort = bwPort,
oPath = "/scene/{scene}/launch", oShape = Just [],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- TRACK
:{
bwTrackTarget = OSCTarget {oName = "BitwigTrack", oAddress = bwAddress, oPort = bwPort,
oPath = "/track/{track}/{action}",
oShape = Just [("volume", Just $ VF 0), ("pan", Just $ VF 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- CLIP
:{
bwClipTarget = OSCTarget {oName = "BitwigClip", oAddress = bwAddress, oPort = bwPort,
oPath = "/track/{track}/clip/{clip}/{action}", oShape = Just [],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- MASTER
:{
bwMasterTarget = OSCTarget {oName = "BitwigMaster", oAddress = bwAddress, oPort = bwPort,
oPath = "/master/{action}/{value}",
oShape = Just [("volume", Just $ VF 0), ("pan", Just $ VF 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- MIDI
:{
bwMIDITarget = OSCTarget {oName = "BitwigMIDI", oAddress = bwAddress, oPort = bwPort,
oPath = "/vkb_midi/{channel}/{action}/{value}", oShape = Just [("value", Just $ VI 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- MIDICC
:{
bwMIDICCTarget = OSCTarget {oName = "BitwigMIDICC", oAddress = bwAddress, oPort = bwPort,
oPath = "/vkb_midi/{channel}/{action}/{channel}/{value}", oShape = Just [("value", Just $ VI 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- USER
:{
bwUserTarget = OSCTarget {oName = "BitwigUser", oAddress = bwAddress, oPort = bwPort,
oPath = "/user/{channel}/value", oShape = Just [("value", Just $ VF 0)],
oLatency = bwLatency, oPreamble = bwPreamble, oTimestamp = bwTimestamp}
:}
-- :{
bwTempo <- startTidal bwTempoTarget (defaultConfig {cFrameTimespan = 1/20})
bwScene <- startTidal bwSceneTarget (defaultConfig {cFrameTimespan = 1/20})
bwTrack <- startTidal bwTrackTarget (defaultConfig {cFrameTimespan = 1/20})
bwClip <- startTidal bwClipTarget (defaultConfig {cFrameTimespan = 1/20})
bwMaster <- startTidal bwMasterTarget (defaultConfig {cFrameTimespan = 1/20})
bwMIDI <- startTidal bwMIDITarget (defaultConfig {cFrameTimespan = 1/20})
bwMIDICC <- startTidal bwMIDICCTarget (defaultConfig {cFrameTimespan = 1/20})
bwUser <- startTidal bwUserTarget (defaultConfig {cFrameTimespan = 1/20})
-- :}
-- oPath parameters
:{
let channel = pI "channel"
value = pF "value"
-- vi = pI "value"
action = pS "action"
tempo = pF "raw"
scene = pI "scene"
track = pI "track"
clip = pI "clip"
-- p c v = value (range 0 16384 v) # channel c
:}
:{
let bwB = streamReplace bwTempo
bwS = streamReplace bwScene
bwT = streamReplace bwTrack
bwC = streamReplace bwClip
bwM = streamReplace bwMaster
bwV = streamReplace bwMIDI
bwVC = streamReplace bwMIDICC
bwU = streamReplace bwUser
hushB = mapM_ streamHush [bwTempo, bwScene, bwTrack, bwClip, bwMaster, bwMIDI, bwMIDICC, bwUser]
-- once = streamOnce superDirt
:}
@jarmitage
Copy link
Author

@ovitus
Copy link

ovitus commented Dec 30, 2019

I'm using your API trying to send MIDI messages via OSC from Tidalcycles:
bwV 1 $ channel 1 # action "note" # value 5

but then Bitwig OSC crashes:
OSC Crashed
For input string: "5.0"

Any ideas why?

@jarmitage
Copy link
Author

Yeah it’s because value is pattern float but for note it probably needs to be pattern int. the OSC extension has no type / error checking so can crash frequently. You need a separate ‘value’ param for note that is type pI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment