Play a note in real-time from renoise tool

I am developing a renoise tool to help with live performance. Switching instruments, that kind of thing. I would love to be able to play samples from LUA script as well. How can I do this, given renoise.song().instruments[]?

send osc, see osc in the documentation

In Renoise, you can trigger notes through OSC. This is built-in functionality, which is described here:

https://github.com/renoise/xrnx/blob/master/GlobalOscActions.lua#L21

Triggering notes via OSC will work from “anywhere” - external control of Renoise from another computer, etc., as long as those messages can arrive through the network.

So, in order to produce notes from your tool, the answer is to let the tool produce such OSC messages.

Here is a snippet which demonstrates how to create an OSC server in the Renoise API:

https://github.com/renoise/xrnx/blob/master/Snippets/Osc.lua

Note: if you are planning to run the tool as an “autonomous process”,you can’t really trigger notes with absolute precision. The reason is that tools exist in the UI thread, with a maximum frequency of a dozen updates per second or so (depending on how much work the CPU has to perform). To make such a thing work, you would need to write those notes into the pattern and let the Renoise playback engine pick them up.

However, if you are planning to respond to user/MIDI input, this will work fine - because such events exist in the audio/realtime thread. So it would be more than good enough for e.g. auditioning notes.

Excellent, thank you both. This will work perfectly. I will be sending the OSC from a MIDI event handler, so it should be fine.