Passthrough

I’ve got the 2host, which I enjoy and use. I figured that would most likely be the best choice for the time being. But I’ve actually paired down my setup for this a bit anyway to eliminate this problem. It became more of a hassle than it was worth and I had entered in to “diminishing returns” territory.

1 Like

@nattog How would I go about adding this to MLR? I have copied passthrough.lua to a ‘lib’ folder I created inside the mlr folder. I added `local Passthrough = include(“lib/Passthrough”) to line 24, but there is no function init(), it’s init = function() so not sure where to drop Passthrough.init()

I’m a codenoob - thanks! This is a great addition!

1 Like

Hi there! So i would drop that Passthrough.init() onto the line after init = function(). If in doubt look for where params are being added to the script, that would normally be in the init function.

In Lua a function is a value no different to a number being stored in a variable like x = 4. Defining init like @tehn has done isn’t that different to function init() ... end. Functions in Lua are anonymous, so it is helpful to store them in variables so we can reuse them. When we talk about a function name, say print, we are actually talking about a variable that holds that function.

1 Like

Hrmm – tried that but no go. Restarted norns and it says “error: load fail”

Here’s the error report from Maiden:

Summary

norns.script.load(“code/mlr/mlr.lua”)
script load: /home/we/dust/code/mlr/mlr.lua
not playing
not playing
not playing
not playing
cleanup
script clear
MISSING INCLUDE: lib/Passthrough
SCRIPT ERROR: load fail
/home/we/dust/code/mlr/mlr.lua:24: MISSING INCLUDE: lib/Passthrough
stack traceback:
/home/we/norns/lua/core/norns.lua:128: in function </home/we/norns/lua/core/norns.lua:128>
[C]: in function ‘error’
/home/we/norns/lua/core/startup.lua:47: in function ‘include’
/home/we/dust/code/mlr/mlr.lua:24: in main chunk
[C]: in function ‘dofile’
/home/we/norns/lua/core/script.lua:169: in function </home/we/norns/lua/core/script.lua:169>
[C]: in function ‘xpcall’
/home/we/norns/lua/core/norns.lua:129: in field ‘try’
/home/we/norns/lua/core/script.lua:169: in function ‘core/script.load’
(…tail calls…)
script clear

Appreciate the help!

Looks like you’ve got an uppercase P on the lib file. It should look like this:

Just tried adding Passthrough to MLR myself and it works here

1 Like

Yup, that was it! Copy>pasted the capital P from your top post. :wink:

Thanks again!

Ha! Woops… fixed :slight_smile:

1 Like

I am having an issue with sending midi on multiple channels. When set to all everything sends on channel 1. Can anyone else confirm?

Also – when setting up, I choose my device and then my interface. At that point I always have to change the device away and then back to what I want in order to start passing midi.

Also also – any way to add a command to refresh the midi devices? If I change anything they don’t show up in the list, even if I map them under the main norns midi devices page. In order to update I have to restart the script.

Sorry for the hassle, thanks for the great utility!

Also – when setting up, I choose my device and then my interface. At that point I always have to change the device away and then back to what I want in order to start passing midi.

Yep - i get this too, had looked briefly into it but haven’t yet been able to get it working as it should. Will have another look.

Will investigate the all issue too and see I can add refreshing to midi devices on connection.

There an update devices function which can get hit in the params callback. I’ll see if i can find a reference here shortly

Pretty sure I have seen something like that around… hard to remember in which script I last spotted it tho so if you do come across a reference, would be v handy!

Ok so I’m doing this in my Torii script when setting up the params for changing grid devices:

midi.update_devices() should help for either/both your midi_device and midi_interface params?

Also - looking at Passthrough.device_event(data) I’m not seeing anything obvious that would send to all channels. Wouldn’t that need a loop? I don’t think there’s any kind of “Omni” channel in the core midi library.

Yup - looks like it! To be honest i hadn’t tested that functionality as i’d lifted that chunk from elsewhere mostly… my bad! Maybe i should remove it… or add a loop in. An omni channel would be a good addition to the core midi lib

1 Like

looking at the core midi lib, I don’t think there’s an easy way to do this since the midi spec doesn’t really include a separate channel for all/omni. (investigating further). For now I think it’d need to be done at the app layer with a loop to send to all channels.

I’ve made an update this evening - this fixes the issue of the devices and interfaces events not targeting the right functions. So this should work as expected on script launch now. Thanks for the prompt to fix that.

As for the other issues. I haven’t yet a solution for refreshing the available midi devices. I’ll keep trying but I couldn’t get the params options to update when devices are added/removed. If you can find an example where this works well, let me know! And I removed all as a channel option for now. It would be great to support it properly, but for now I wanted to ensure that the core was behaving as it should and keep ‘work in progress’ features far from causing people issues!

1 Like

I updated and this still doesn’t seem to be working for me – still have to switch away and back to get data sending through. Just a minor thing, really.

Makes sense to me – this is a great utility (seems like it would be a great add to main norns under midi devices @tehn?) just hope that all becomes workable as it’s my primary use case right now :sweat_smile:

Weird - did you update it inside the scripts that you’re using it in? Or are you trying with the example script in the Passthrough repo? Just tried with my setup and it’s working here.

I’ll keep looking into all :slight_smile:

I wasn’t certain whether to suggest rolling it into Norns core midi although it could be nice. I haven’t really checked or tested Passthrough with scripts that use MIDI input/output in parallel since it wasn’t particularly relevant for me, and I wonder if having it in could create some hiccups for folks. I even was doubtful whether to add the repo to the community catalogue since the example script does nothing else :smiley:

Yes – I only have it in MLR right now, so overwrite the existing lib passthrough.lua with the new one. Confirmed it’s new because all is no longer there. Do I need to update anything inside the code?

I tried with both my Midi Fighter Twister and Qunexus sending to Digitone.

Good point about possible interactions with midi scripts. That could get very confusing, or requiring those scripts to assume control of the system somehow.

Alright i’ll try to reproduce …

I just tried it with MLR and it works instantly.

Can you show me your implementation in MLR?
Mine is this:
L24: local Passthrough = include("lib/passthrough")
L362: Passthrough.init()

and can you double check that you’re using the same contents in lib/passthrough.lua as what is on master on github? Feel free to send me the entire copy you’re using either here or on PM and I can take a peek.
Sorry for the trouble!