Skip to content

Commit ab8ca4d

Browse files
authored
Merge pull request #1024 from shorepine/claude/docs-amy-sequenced-midi-out
2 parents c2329cd + 182acd5 commit ab8ca4d

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

docs/amyboard/python.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ def my_midi_callback(is_sysex):
211211
tulip.midi_callback(my_midi_callback)
212212
```
213213

214+
### Sending MIDI out
215+
216+
There are two ways to send MIDI out of AMYboard.
217+
218+
For one-off or arbitrary messages, use `tulip.midi_out()` with the raw MIDI bytes (a list, tuple or `bytes`). It sends immediately, out the MIDI out jack and the USB MIDI connection:
219+
220+
```python
221+
import tulip
222+
223+
tulip.midi_out([0x90, 60, 127]) # note on, channel 1, note 60, velocity 127
224+
tulip.midi_out([0x80, 60, 0]) # note off, channel 1, note 60
225+
tulip.midi_out([0xB0, 74, 64]) # control change, channel 1, CC 74 = 64
226+
```
227+
228+
For musically-timed output, let AMY send the MIDI for you. Set an oscillator's `wave` to `amy.AMY_MIDI`: instead of making a sound, that osc emits a MIDI note on/off whenever it receives a note. Because it's an ordinary osc, you can drive it from AMY's sequencer to get sample-accurate MIDI output that stays locked to AMY's tempo — for example, a pattern that plays an external synth:
229+
230+
```python
231+
import amy
232+
233+
amy.send(osc=0, wave=amy.AMY_MIDI) # osc 0 now sends MIDI instead of audio
234+
235+
# Play a MIDI note on channel 1 every quarter note (48 ticks), held for an eighth note.
236+
amy.send(osc=0, note=60, vel=1, sequence="0,48,1") # note on at tick 0 of each period
237+
amy.send(osc=0, note=60, vel=0, sequence="24,48,2") # note off at tick 24 of each period
238+
```
239+
240+
`amy.AMY_MIDI` always sends on MIDI channel 1, and notes that arrived over MIDI in are not echoed back out. See the [AMY MIDI docs](https://github.com/shorepine/amy/blob/main/docs/midi.md#sending-midi-out) for the full details.
241+
214242
## Example: simple arpeggiator
215243

216244
```python

0 commit comments

Comments
 (0)