Skip to content

mattorp/syn-http

Repository files navigation

syn-http

This is an HTTP endpoint for Synesthesia. For now, it supports setting controls and scenes and getting values from Synesthesia including audio variables. The purpose is to provide an HTTP interface, that map to OSC messages.

NOTE: Synesthesia Pro is required for this to work.

It will include a CLI tool later to avoid having to clone this repo. Note that this should not be used to build upon for now. It's in a very early stage of development. I just needed the functionality for now, but a cleaner solution will be implemented later.

Note that this is not affiliated with the team behind Synesthesia. For problems or suggestions please open an issue here.

For the official Synesthesia OSC interface, you can find documentation here

Installation

Node.js must be installed to use this.

git clone https://github.com/mattorp/syn-http
cd syn-http

Run the following command in the root directory of the repository:

If using npm:

npm install

If using yarn:

yarn install

Usage

Turn on OSC input and output in Synesthesia settings.

Then start the server:

npm run start

Then send an HTTP request to the server (see Examples below) e.g. using bash from another terminal. The default port for the server is 5999, which can be changed in ./.env.

Note that the link deviates from the OSC format /address value , so that value is separated with / instead of a space /address/value. This is to avoid having to handle encoding spaces in the URL.

The control name is insensitive to case and spacing characters like "_" and "-", so you don't have to be exact; "/controls/my_slider", "/controls/MySlider", and "/controls/m-Y-s-L-i-D-e-R" would all update the same slider. 1

All controls are normalized to the range 0-1. E.g., brightness is shown as -1 to 0 in the app, but use 0 to set it to 0%, and 1 to set it to 100%.

Examples

A list of examples are included in the examples folder.

Set Controls

CONTROL=brightness
VALUE=0.5
curl http://localhost:5999/controls/$CONTROL/$VALUE

The values d and r can be used to send the default value or a random value for meta and scene controls. The default scene values are defined in scene.json.

CONTROL=brightness
VALUE=d
curl http://localhost:5999/controls/$CONTROL/$VALUE
CONTROL=brightness
VALUE=r
curl http://localhost:5999/controls/$CONTROL/$VALUE

Set Scene

SCENE=AlienCavern
curl http://localhost:5999/scenes/$SCENE

The scene names can be found in the Synesthesia app.

Get Values

VARIABLE=syn_Presence
curl http://localhost:5999/values/$VARIABLE

Available Values

Examples

These values are available from Synesthesia:

syn_ToggleOnBeat
syn_Threshold
syn_MidPresence
syn_RandomOnBeat
syn_MidHits
syn_MidHighTime
syn_MidHighLevel
syn_MidHighHits
syn_Level
syn_Hits
syn_PrimeBang
syn_MidLevel
syn_Intensity
syn_OnBeat
syn_HighTime
syn_HighPresence
syn_BPMTwitcher
syn_HighLevel
syn_HighHits
syn_CurvedTime
syn_MidHighPresence
syn_BPMSin4
syn_BassHits
syn_BassExpoCurve
syn_BassPresence
syn_RawLevel
syn_BPMTri2
syn_Time
syn_BPMConfidence
syn_BPMTri
syn_FadeInOut
syn_BassLevel
syn_BassTime
syn_BPMSin2
syn_Presence
syn_MidTime
TIME
syn_BPM
syn_BPMSin
syn_BeatTime

Available Controls

Examples

Meta controls:

invert
brightness
gamma
contrast
hue
saturation
vert_mirror
hor_mirror
invert_media
fit_or_fill
media_contrast
paused
playback_speed
reactivity
audio_speed
limit_colors
low_color
high_color
transition

Scene controls:

scene-toggle-<i>
scene-slider-<i>
scene-bang-<i>
scene-knob-<i>
scene-xy-<i>
scene-color-<i>
scene-dropdown-<i>

<i> is the 0-based index of the type of control, in order of appearance in the scene.json file.

You can also use the name of the control:

SCENE=AlienCavern
CONTROL=droppers
curl http://localhost:5999/scenes/$SCENE
curl http://localhost:5999/controls/$CONTROL/1

Convenience

You can source the .env file to export the variables to your shell. Navigate to the root directory of the repository and run:

source .env

This includes the shorthand variables:

CONTROLS=http://localhost:5999/controls
SCENES=http://localhost:5999/scenes
VALUES=http://localhost:5999/values

Which can be used like this:

curl $CONTROLS/brightness/0.5
curl $SCENES/AlienCavern
curl $VALUES/syn_Presence

scripts

Generate

Random controls

You can generate random controls by running the following script:

npm run generate:random:controls

The script will generate 10 random files saved to ./generate/random/controls/tmp. You can run each of the .sh files in the directory to set the controls. To save the presets move the files to another directory. To generate new presets run the script again (this will overwrite the old ones).

Examples

If you change the host or port in the .env file, you can use the following script to set the controls:

npm run generate:generate:examples

Footnotes

  1. https://synesthesia.live/docs/manual/osc.html

About

An HTTP endpoint for Synesthesia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published