Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- miditable = {}
- for i=0,256 do
- miditable[i] = 0
- end
- -- menu entries
- renoise.tool():add_menu_entry {
- name = "Main Menu:Tools:mytool:start",
- invoke = function() start() end
- }
- renoise.tool():add_menu_entry {
- name = "Main Menu:Tools:mytool:stop",
- invoke = function() stop() end
- }
- -- create some handy shortcuts
- local OscMessage = renoise.Osc.Message
- local OscBundle = renoise.Osc.Bundle
- -- open a socket connection to the server
- local client, socket_error = renoise.Socket.create_client(
- "localhost", 8000, renoise.Socket.PROTOCOL_UDP)
- if (socket_error) then
- renoise.app():show_warning(("Failed to start the " ..
- "OSC client. Error: '%s'"):format(socket_error))
- return
- end
- running = 0
- randval = 0
- function start ()
- running = 1
- myfunc()
- end
- function stop ()
- running = 0
- end
- function map (val,startin,endin,startout,endout)
- return (val - startin) * (endout - startout) / (endin - startin) + startout;
- end
- -- renoise.song().instruments[].samples[].transpose, _observable -- [number, -120 - 120]
- function myfunc ()
- randval = math.random(-1,7)
- client:send(
- OscMessage(
- "/renoise/trigger/note_on",{
- {tag="i",value=randval},
- {tag="i",value=randval+1},
- {tag="i",value=math.random(119)},
- {tag="i",value=100}
- }
- )
- )
- mytimer()
- end
- function mytimer ()
- if (renoise.tool():has_timer(myfunc)) then
- renoise.tool():remove_timer(myfunc)
- end
- if(running == 1) then
- renoise.tool():add_timer(myfunc, math.random(100))
- end
- -- print(map(miditable[0],0,127,100,1000))
- -- print(miditable[0])
- end
- rprint(renoise.Midi.available_input_devices())
- local inputs = renoise.Midi.available_input_devices()
- local midi_device = nil
- if not table.is_empty(inputs) then
- local device_name = inputs[5]
- local function midi_callback(message)
- assert(#message == 3)
- assert(message[1] >= 0 and message[1] <= 0xff)
- assert(message[2] >= 0 and message[2] <= 0xff)
- assert(message[3] >= 0 and message[3] <= 0xff)
- miditable[message[2]] = message[3]
- -- rprint(miditable)
- print(("%s: got MIDI %X %X %X"):format(device_name, message[1], message[2], message[3]))
- end
- -- note: sysex callback would be a optional 2nd arg...
- midi_device = renoise.Midi.create_input_device(
- device_name, midi_callback)
- -- stop dumping with 'midi_device:close()' ...
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement