Last active
May 10, 2016 21:06
-
-
Save bjorn-nesby/9ebb07af6896d8373c47 to your computer and use it in GitHub Desktop.
Using xRules to enable MMC commands by listening to incoming sysex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------- | |
-- Ruleset definition for xRules | |
-- More info @ http://www.renoise.com/tools/xrules | |
----------------------------------------------------------- | |
return { | |
osc_enabled = false, | |
manage_voices = false, | |
description = "Enable MMC commands in Renoise by listening to incoming sysex.\nSee also http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/mmc.htm", | |
{ | |
osc_pattern = { | |
pattern_in = "", | |
pattern_out = "", | |
}, | |
name = "MMC Transport", | |
actions = { | |
{ | |
call_function = [[local rns = renoise.song() | |
if (values[2] == 0x7F) | |
-- ignore third byte (manufacturer ID) | |
and (values[4] == 0x06) | |
then | |
-- MMC STOP --------------------------------------------- | |
if (values[5] == 1) then | |
rns.transport:stop() | |
-- MMC START -------------------------------------------- | |
elseif (values[5] == 2) then | |
local mode = renoise.Transport.PLAYMODE_RESTART_PATTERN | |
rns.transport:start(mode) | |
-- MMC DEFERRED PLAY ------------------------------------ | |
elseif (values[5] == 3) then | |
local mode = renoise.Transport.PLAYMODE_CONTINUE_PATTERN | |
rns.transport:start(mode) | |
-- MMC FAST FORWARD ------------------------------------- | |
elseif (values[5] == 4) then | |
local play_pos = rns.transport.playback_pos | |
play_pos.sequence = play_pos.sequence + 1 | |
local seq_len = #rns.sequencer.pattern_sequence | |
if (play_pos.sequence <= seq_len) then | |
local new_patt_idx = | |
rns.sequencer.pattern_sequence[play_pos.sequence] | |
local new_patt = rns:pattern(new_patt_idx) | |
if (play_pos.line > new_patt.number_of_lines) then | |
play_pos.line = 1 | |
end | |
rns.transport.playback_pos = play_pos | |
end | |
-- MMC REWIND -------------------------------------------- | |
elseif (values[5] == 5) then | |
local play_pos = rns.transport.playback_pos | |
play_pos.sequence = play_pos.sequence - 1 | |
if (play_pos.sequence < 1) then | |
play_pos.sequence = 1 | |
end | |
local new_patt_idx = | |
rns.sequencer.pattern_sequence[play_pos.sequence] | |
local new_patt = rns:pattern(new_patt_idx) | |
if (play_pos.line > new_patt.number_of_lines) then | |
play_pos.line = 1 | |
end | |
rns.transport.playback_pos = play_pos | |
-- MMC RECORD STROBE ------------------------------------- | |
elseif (values[5] == 6) then | |
rns.transport.edit_mode = true | |
-- MMC RECORD EXIT --------------------------------------- | |
elseif (values[5] == 7) then | |
rns.transport.edit_mode = false | |
-- MMC PAUSE --------------------------------------------- | |
elseif (values[5] == 9) then | |
rns.transport:stop() | |
end | |
end]], | |
}, | |
}, | |
conditions = { | |
{ | |
message_type = { | |
equal_to = "sysex", | |
}, | |
}, | |
{ | |
sysex = { | |
equal_to = "F0 7F * 06 * F7", | |
}, | |
}, | |
}, | |
match_any = true, | |
midi_enabled = true, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment