# Osc json format to send to open stage control (a must-have software !) \[Solved\]

**URL:** <https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286>\
**Category:** \[P\] Patreon Support\
**Created:** [June 27, 2018, 11:17am UTC](https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286 "2018-06-27T11:17:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [June 27, 2018, 11:17am UTC](https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286/1 "2018-06-27T11:17:23Z")

</div>

Hi there,

I keep exploring open stage control ([https://osc.ammd.net/)](https://osc.ammd.net/) to create a visual interface for Sonic Pi.

the doc concerning edit the interface in open stage control [https://osc.ammd.net/extras/remote-control/](https://osc.ammd.net/extras/remote-control/)

I need to send the osc message  
In python using the python-osc it works with this code

```ruby

"""
Test d'envoi vers open stage control d'un message osc
pour changer un label dynamiquement
"""
import argparse
import random
import time

import json

from pythonosc import osc_message_builder
from pythonosc import udp_client

"""
jsonData = '{"label":"New Label"}'
jsonToPython = json.loads(jsonData)
"""

pythonDictionary = {'label':'nouveau nom', 'color':'pink'}
dictionaryToJson = json.dumps(pythonDictionary)

if __name__ == " __main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip", default="127.0.0.1",
      help="adresse du serveur openstagecontrol")
  parser.add_argument("--port", type=int, default=8080,
      help="8080 the port is listening on")
  args = parser.parse_args()

  client = udp_client.SimpleUDPClient(args.ip, args.port)

client.send_message("/EDIT", ("push_4", dictionaryToJson))
time.sleep(4)
client.send_message("/EDIT", ("push_4", '{"label":"New Label"}'))

```

Now i need to make it work in Sonic Pi but i miss something about the syntax.

```ruby
live_loop :changeLabelPush_4 do
  options = {"label" => "depuis sonic pi"}
  require 'json'
  # => true
  options.to_json
  puts options
  osc_send "127.0.0.1",8080,"/EDIT", "push_4", options
  sleep 4
  stop
end

```

it give this in the sonic pi journal

```ruby
{run: 17, time: 4.0, thread: :live_loop_changeLabelPush_4}
 ├─ {"label"=>"depuis sonic pi"}
 └─ OSC -> 127.0.0.1, 8080, /EDIT, ["push_4", {"label"=>"depuis sonic pi"}]

```

and causes an error in the open stage control log

```ruby
OSC received: { address: '/EDIT', args: 'push_4' } From : 127.0.0.1:4560
[Renderer process error]
Uncaught SyntaxError: JSON5: invalid character 'u' at 1:1
at default (node_modules/json5/dist/index.js:1:0)
at default (node_modules/json5/dist/index.js:1:0)
at default (node_modules/json5/dist/index.js:1:0)
at default (node_modules/json5/dist/index.js:1:0)
at default (node_modules/json5/dist/index.js:1:0)
at EDIT (src/browser/js/app/remote-control.js:11:53)
at exec (src/browser/js/app/remote-control.js:163:28)
at receive (src/browser/js/app/osc.js:38:72)
at receiveOsc (src/browser/js/app/ipc/callbacks.js:17:12)
at require (src/browser/js/app/ipc/index.js:40:16)

```

Open stage control needs this

```ruby
OSC received: { address: '/EDIT',
args: ['push_4', '{"label":"New Label"}'] }

```

Some clever ideas to help ?  
Cheers

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [June 27, 2018, 12:08pm UTC](https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286/2 "2018-06-27T12:08:08Z")

</div>

well i find the good syntax. May it helps.

```ruby
live_loop :changeLabelPush_4 do
 
 require 'json'
 options = { :label => "from sonic pi"}.to_json
 puts options
 osc_send "127.0.0.1",8080,"/EDIT", "push_4", options
 stop
 sleep 4  
end

```

---

<div class="post-metadata">

**Author:** ![Davids-Music-Lab](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/davids-music-lab/32/512_2.png) [@Davids-Music-Lab](https://in-thread.sonic-pi.net/u/Davids-Music-Lab)\
**Post date:** [June 27, 2018, 2:12pm UTC](https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286/3 "2018-06-27T14:12:49Z")

</div>

I only used OSC with processing and haven’t sent OSC yet, but it seems to me that what SP is sending is what you want.  
From the error message I guess that the second argument is not recieved, possibly a type conversion error?

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [June 27, 2018, 2:24pm UTC](https://in-thread.sonic-pi.net/t/osc-json-format-to-send-to-open-stage-control-a-must-have-software-solved/1286/4 "2018-06-27T14:24:50Z")

</div>

yes with my last post it works 🙂 that’s why i put [solved]  
cheers
