Skip to content

Commit

Permalink
add midicmd documentation 2
Browse files Browse the repository at this point in the history
- MiniRepl for input-output.mdx
- addresses #789 #710
  • Loading branch information
nkymut committed Jan 19, 2025
1 parent 268c66c commit 1349ecb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/midi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ It supports the following commands:
// You can control the clock with a pattern and ensure it starts in sync when the repl begins.
// Note: It might act unexpectedly if MIDI isn't set up initially.
stack(
midicmd("clock*24,<start stop>/2").midi('RHYTHM DESIGNER RD-6') //Trigger start and stop on Behringer RD-6
midicmd("clock*48,<start stop>/2").midi('IAC Driver')
)
```

Expand Down
39 changes: 25 additions & 14 deletions website/src/pages/learn/input-output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@ Selects the MIDI channel to use. If not used, `.midi` will use channel 1 by defa

### midicmd

`midicmd` sends MIDI system real-time messages to control timing and transport on MIDI devices.
`midicmd` sends MIDI system real-time messages to control timing and transport on MIDI devices.

It supports the following commands:

- `clock`/`midiClock` - Sends MIDI timing clock messages
- `start` - Sends MIDI start message
- `stop` - Sends MIDI stop message
- `continue` - Sends MIDI continue message

```javascript
// You can control the clock with a pattern and ensure it starts in sync when the repl begins.
// Note: It might act unexpectedly if MIDI isn't set up initially.
stack(
midicmd("clock*24,<start stop>/2").midi('RHYTHM DESIGNER RD-6') //Trigger start and stop on Behringer RD-6
)
```

<MiniRepl
client:idle
tune={`$:stack(
midicmd("clock*48,<start stop>/2").midi('IAC Driver')
)`}
/>

## ccn && ccv

Expand Down Expand Up @@ -157,8 +160,8 @@ The following example shows how to send a pattern to an MQTT broker:
client:only="react"
tune={`"hello world"
.mqtt(undefined, // username (undefined for open/public servers)
undefined, // password
'/strudel-pattern', // mqtt 'topic'
undefined, // password
'/strudel-pattern', // mqtt 'topic'
'wss://mqtt.eclipseprojects.io:443/mqtt', // MQTT server address
'mystrudel', // MQTT client id - randomly generated if not supplied
0 // latency / delay before sending messages (0 = no delay)
Expand All @@ -169,12 +172,14 @@ The following example shows how to send a pattern to an MQTT broker:
Other software can then receive the messages. For example using the [mosquitto](https://mosquitto.org/) commandline client tools:

```
> mosquitto_sub -h mqtt.eclipseprojects.io -p 1883 -t "/strudel-pattern"
hello
world
hello
world
...
> mosquitto_sub -h mqtt.eclipseprojects.io -p 1883 -t "/strudel-pattern"
> hello
> world
> hello
> world
> ...
```

Control patterns will be encoded as JSON, for example:
Expand All @@ -194,11 +199,17 @@ Control patterns will be encoded as JSON, for example:
Will send messages like the following:

```
{"s":"sax","speed":2}
{"s":"sax","speed":2}
{"s":"sax","speed":3}
{"s":"sax","speed":2}
...
```

Libraries for receiving MQTT are available for many programming languages.

```
```

0 comments on commit 1349ecb

Please sign in to comment.