Demo panel for MIDI receive/transmit routines

Home Forums General Using Ctrlr Demo panel for MIDI receive/transmit routines

Viewing 11 posts - 61 through 71 (of 71 total)
  • Author
    Posts
  • #73334
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    yeah, connected loopbe1 as output device.
    i don’t see the ‘click me once’ button moving, and
    nothing lands in midiox. the method associated with
    that is ‘namethemall’. what is supposed to happen? 🙂

    your code kicks up a lot of questions:
    1/(recurrent) i’m perplexed by the way code that is needed early on
    is defined later in the script ie: where mySplitStringIntoFourSegments()
    appears, when it is referred to at the start. how does that work?

    2/meaning of all the symbols in return (s:gsub("^%s*(.-)%s*$", "%1"))
    (how thff does that work?!!)

    3/format of this? console(String(i.."[".. v.."]"))

    it’s quite heavy for me to follow ! this is quite sophisticated
    stuff for a novice.

    #73335
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 480
    • Total: 484
    • ★★

    I should have explained that panel more clearly. The green button just a trigger for a script that fills all modulators named modulator-1 … modulator56 with names from a table of D110 parameters or controls. I didn’t have to type each name into Ctrlr, so I thought that might be of interest to you. Once initialized it is no longer needed. What you do is send a sysex message (see attached syx file) from MidiOx to the panel through LoopBe1 (input device in Ctrlr) and it will load each sysex value into each modulator. You don’t do anything with the panel, it is just receiving data.

    s:gsub("^%s*(.-)%s*$", "%1") is a regex expression that looks for space at the beginning or end of a string and removes it (in this case). I don’t think I could come up with that expression.

    console(String(i.."[".. v.."]")) this is just printing the index number “i” of the table and its value “v” to the console. There are four strings printed that were split from the 80 character (240 byte string). The 240 byte string ends with a space, hence the function that strips that space at the end.

    Each process or function that works on the string is broken down into separate functions or methods as they may be called, which makes for easier readability (perhaps?) and easier management of code (perhaps?).

    Attachments:
    You must be logged in to view attached files.
    #73339
    proton
    Participant
    • Topics: 19
    • Replies: 94
    • Total: 113
    • ★★

    Hi dnaldoog,

    I did tested your code and what I’ve found out is that the Sysex that comes from OX indeed changes the numbers on all the modulators BUT the actual value of the modulator is not affected at all. Can you please explain why this might be happening? I was under the impression that Sysex will cause the value to change and not only the values display. I hope this make sense to you. For testing purposes send Sysex to a modulator that had a value of 0 for example and after you see the new value displayed go to edit mode and see that the value is still 0 and there was no change in value caused by the incoming Sysex data. Weird right?
    Cheers!

    #73340
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    okay, i’m going to have to digest this more slowly.
    thanks for panel/jpg/syx. off to try that again now.

    worth noting:
    first time i’ve ever heard of regex ! 🙂
    (but somewhat reassured that you cribbed it)
    i’ve bookmarked that page to have a look later.
    ok, so i get what that does – i think i saw another
    way of doing that elsewhere (lost in the fog back there..),
    maybe with more conventional Lua – or it could have been a
    gsub thing; possibly Possemo..

    question: 80 characters is 240 bytes? can you clarify
    the obviousness i’m oblivious to? 🙂 i’m obviously
    considering bytes in the wrong way.

    and [".. v.."] this is the bit that looks weird to me.
    -bearing in mind i’m only just barely getting to grips
    with basic iteration stuff (only done my own one ONCE !)

    #73341
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    alright, yes, your ‘kit’ was good; got it to work.
    see below.
    went looking for the value as described by Proton,
    but?? can’t find a current value entry in my properties
    column. can’t remember if it’s supposed to have one..
    but i think i’ve seen one…scrolling up and down, not
    finding it.

    ..nope. not there. must’ve imagined it.

    hey: ‘*reverseNameThemAll*’? what’s that for?

    i can see how this can be useful – in some form –
    for making one’s lists quickly, with a bit of practice.
    did kinda wonder about it while arduously bashing out
    lists of names, and matching sysex messages – how do the
    pros do this – certainly, if there’s another 7 parts to do
    on the D-110. lot of legwork there.

    Attachments:
    You must be logged in to view attached files.
    #73343
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    and… yes i see now: you’ve broken down the midi receive
    into 2 operations: myMidiReceived() and received()
    – you didn’t say ‘check the console’ ! 😉

    and offset=10 … is that a 10 byte dummy header you’ve got?
    params start at 01? (possibly 00 on real D-110 .. yes, 00h for
    name1) and t# is table ‘t’ item number, got that.. why is offset-1?

    (appreciate that you’re imparting quite a bit of technique here)
    with j=1, you’re using that to?define a start point? oh yeah,
    and to be able to increment with that: j=j+1
    phew. and does it matter what order you put all of these
    expressions in there?(my earlier observation that some things
    that seemed to need to be ‘known’ earlier in a method, often
    come later)

    can i just point out that line 13 in table of modulators is
    misnamed “P-ENV TIME I” (not “1”). doubt it is of any importance.
    (oh same again at 43+44)

    #73344
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    hey i’m not imagining things: i have opened your panel,
    and there is no ‘current value’ entry. i have to leave
    panel edit, twiddle the control, and the edit again,
    and the current value is there. very weird.

    have 2 other panels open at the same time, and they do
    not have ‘current value’ either…time to close them
    all and see what this is about… !

    #73345
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 480
    • Total: 484
    • ★★

    Hi Proton,

    The reason why the values are all zero is that in the received() function I had written:
    panel:getModulatorByName(t[j]):getComponent():setValue(m,false)
    Changing it to
    panel:getModulatorByName(t[j]):getComponent():setValue(m,true)
    fixes that!

    Regards,

    Attachments:
    You must be logged in to view attached files.
    #73347
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 480
    • Total: 484
    • ★★

    Hi Human Fly,

    I just put that panel together quickly and maybe there’s a much better way of doing it, but *reverse_nameThemAll* if renamed to *nameThemAll* and *nameThemAll* given a temporary name (say *nameThemAll2*) will return the names back to the original modulator-1,.. modulator-56. If you change a name in the table/array like those typos you spotted, you then run the original *nameThemAll* function again. Bit clumsy I realise, but just cobbled together quickly.

    my earlier observation that some things
    that seemed to need to be ‘known’ earlier in a method, often
    come later

    When you define a function it can reside anywhere in your program (often in another file) and the great thing is you can use that function again anywhere in your program rather than have some code in-line when you need it in one function and repeat that same code in another function, which could lead to more confusion and errors. In other words, if you are going to use that gsub code more than once, then bundle it into a function that you can call anywhere.

    is that a 10 byte dummy header you’ve got?

    That sysex is completely made up from what I thought the D110 should look like, but not fully checked. Have you looked at my JD-990 panel which might function similarly to the D110?

    for i=offset,#t+(offset-1)
    ‘offset=10’ is minus the headers and address locations, but F0 is ignored. You would have to check the real offset in the D110, so from that point (‘offset=10’, which is really 11!!! (remembering we ignore the first byte F0)) we load data into the modulators on Ctrlr.

    #t means the size of table #t=56 – keep looping until you reach #t (56)+(offset-1) (or + 9) so loop through 56 times from position 10 to 65.

    The (offset-1) is unnecessary – it’s just to show you what’s happening. The last two numbers are ‘checksum’ and ‘F7 end sysex’ and so are ignored. Confusing! 🙁

    
    offset=10
    j=1
    for i=10,65 do
    m=midi:getLuaData():getByte(i)
    panel:getModulatorByName(t[j]):getComponent():setValue(m,true)
    j=j+1
    end

    because ‘i’ starts at 10, we can’t use it to reference t[1] through to t[56] so I use another counter ‘j’ instead. You can do this too:

    
    for i=10,65 do
    m=midi:getLuaData():getByte(i)
    panel:getModulatorByName(t[i-9]):getComponent():setValue(m,true)
    end
    
    #73348
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 480
    • Total: 484
    • ★★

    80 characters is 240 bytes? can you clarify
    the obviousness i’m oblivious to? ? i’m obviously
    considering bytes in the wrong way.

    I haven’t gone right into it, but I think lua treats strings as a series of bytes, so the length of a string of 80 sysex values is F+0+” ” (space) that’s 3 bytes: ,multiply 3 by 80 and you get 240, except I was slightly wrong there – there is no trailing space, so the correct length is 239. My panel still divides 239 into 4 strings of 20 sysex values, but there could be a potential bug in there somewhere. I’ve changed the code slightly, from
    local st = mySplitStringIntoFourSegments(a,60)
    to
    local st = mySplitStringIntoFourSegments(a,#a/4)
    but it would need to be tested.

    and [“.. v..”] this is the bit that looks weird to me

    with console() or console(String()) you can mix strings with data:
    console(String(">>"..i.." = my test value= "..(v*3).."\n_____\\n prints a new line!_____"))
    Regards,

    Attachments:
    You must be logged in to view attached files.
    #73350
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    ok, thanks. i’ll have a messaround with those.
    (and i don’t think i’ve seen your JD990 panel yet)

    i think the other weirdness i’m getting here,
    ie: the current value entry not appearing initially
    must be related to situations where initial values
    are no longer preset on startup – which could be
    due to high VST Index numbers – i’m up in the 5000’s
    here at the moment, and none of the panels i had open
    had the current value entry until the modulator had
    its value changed – at which point the current value
    entry appears.

    this is a general flaw with this version of Ctrlr (5.4.2x):
    any loaded panels seem to share a common VST Index# list,
    so that if panel A goes up to, say, 20, and you start another
    panel, your first modulator there will start at 21, so it
    just keeps going up.

    and if 2 panels have modulators with sysex messages at the
    same VST Index#, and you trigger one, the sysex from both
    will be sent out to midiox/etc.

    it would be good if Ctrlr, as the ‘host’, could treat panels
    completely separately – would certainly make the workflow
    easier. maybe something for Atom to consider, if it is possible.
    (anyway, so i wasn’t able to observe that issue of values not
    corresponding)

Viewing 11 posts - 61 through 71 (of 71 total)
  • The forum ‘Using Ctrlr’ is closed to new topics and replies.
There is currently 0 users and 39 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr