Home › Forums › General › Programming › Simple Akai S2000 Frontend
- This topic has 34 replies, 4 voices, and was last updated 8 years, 2 months ago by pascalc.
-
AuthorPosts
-
January 12, 2015 at 1:11 pm #35468
Instead of all those elseif stuff, just index a lua table
something like:function akaiAlph(c)
akaiAlphabet = {0,1,2,3,4,5,6,7,8,9,”,’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’,’#’,’+’,’-‘,’.’}
return (akaiAlphabet[c])
endJanuary 12, 2015 at 2:52 pm #35470@Atom:
Yes, that will clean up a lot of the clutter. Thanks!I’ll try that. And try to put in the error message as well somehow, because I liked that when trying to get it to work before (it told me if my code was wrong or the data I was feeding it).
By the way: I read about “escaping” special characters with a “%”-sign in a few Lua tutorials… Didn’t I understand that or aren’t our characters special enough?
- This reply was modified 9 years, 3 months ago by BartBral.
January 12, 2015 at 2:59 pm #35473The exact info i get back is as such
RAW:[f0 47 00 03 48 01 00 1d 16 0b 1a 0a 0c 0b 1d 1d 0a 0a 0a f7]Cheers man nice one!
If you could get your decoded result to go into my decoder as a string s=”blahblahblah” Then i think it would work..
Sorry I don’t get that…
try this string: 😉
f0 47 00 03 48 01 00 0d 16 0b 12 0d 16 0b 12 0d 16 0b 12 f7
January 12, 2015 at 5:21 pm #35477I was just reading about tables & dictionaries.
trying when i get homeJanuary 12, 2015 at 5:56 pm #35480Is there a way i can get the actual sysex string into the script and not as a variable???
January 12, 2015 at 6:57 pm #35486Not shure if this is what you mean… but have you read this:
To convert a MemoryBlock to a hex string
mb = MemoryBlock ("f0 f1 f2 f3 f7") console (mb:toHexString(1))
And more interesting “Blahblahblah” 😉
- This reply was modified 9 years, 3 months ago by BartBral.
January 12, 2015 at 7:00 pm #35488For some reason the link doesn’t show up in above reply…
January 12, 2015 at 8:46 pm #35493for
f0 47 00 03 48 01 00 0d 16 0b 12 0d 16 0b 12 0d 16 0b 12 f7i got
1 0 C L A H C L A H C L A Hright???
January 12, 2015 at 9:25 pm #35495yes… I’m afraid so… I made a mistake…
It was coded by hand, and it should have read BLAHBLAHBLAH…But have you cracked it? The name decoding? I’m a bit further but am still having trouble with my input string.
January 12, 2015 at 9:41 pm #35496ive tried my decoder on every saved program, multi and sample i could throw at it even with my wifes name doing a reverse coding so my decoder works on the akai…..
here where it says “string” the actual sysex string and not a variable and im positive it will work….
s = “string”
s = s:gsub(” “, “”)
s = s:gsub(“0a”, ” “)s = s:gsub(“00”, “0”)
s = s:gsub(“01”, “1”)
s = s:gsub(“02”, “2”)
s = s:gsub(“03”, “3”)
s = s:gsub(“04”, “4”)
s = s:gsub(“05”, “5”)
s = s:gsub(“06”, “6”)
s = s:gsub(“07”, “7”)
s = s:gsub(“08”, “8”)
s = s:gsub(“09”, “9”)
s = s:gsub(“0B”, “A”)
s = s:gsub(“0C”, “B”)
s = s:gsub(“0D”, “C”)
s = s:gsub(“0E”, “D”)
s = s:gsub(“0F”, “E”)
s = s:gsub(“0b”, “A”)
s = s:gsub(“0c”, “B”)
s = s:gsub(“0d”, “C”)
s = s:gsub(“0e”, “D”)
s = s:gsub(“0f”, “E”)
s = s:gsub(“10”, “F”)
s = s:gsub(“11”, “G”)
s = s:gsub(“12”, “H”)
s = s:gsub(“13”, “I”)
s = s:gsub(“14”, “J”)
s = s:gsub(“15”, “K”)
s = s:gsub(“16”, “L”)
s = s:gsub(“17”, “M”)
s = s:gsub(“18”, “N”)
s = s:gsub(“19”, “O”)
s = s:gsub(“1A”, “P”)
s = s:gsub(“1B”, “Q”)
s = s:gsub(“1C”, “R”)
s = s:gsub(“1D”, “S”)
s = s:gsub(“1E”, “T”)
s = s:gsub(“1F”, “U”)
s = s:gsub(“1a”, “P”)
s = s:gsub(“1b”, “Q”)
s = s:gsub(“1c”, “R”)
s = s:gsub(“1d”, “S”)
s = s:gsub(“1e”, “T”)
s = s:gsub(“1f”, “U”)
s = s:gsub(“20”, “V”)
s = s:gsub(“21”, “W”)
s = s:gsub(“22”, “X”)
s = s:gsub(“23”, “Y”)
s = s:gsub(“24”, “Z”)
s = s:gsub(“0B”, “a”)
s = s:gsub(“0C”, “b”)
s = s:gsub(“0D”, “c”)
s = s:gsub(“0E”, “d”)
s = s:gsub(“0F”, “e”)
s = s:gsub(“10”, “f”)
s = s:gsub(“11”, “g”)
s = s:gsub(“12”, “h”)
s = s:gsub(“13”, “i”)
s = s:gsub(“14”, “j”)
s = s:gsub(“15”, “k”)
s = s:gsub(“16”, “l”)
s = s:gsub(“17”, “m”)
s = s:gsub(“18”, “n”)
s = s:gsub(“19”, “o”)
s = s:gsub(“1A”, “p”)
s = s:gsub(“1B”, “q”)
s = s:gsub(“1C”, “r”)
s = s:gsub(“1D”, “s”)
s = s:gsub(“1E”, “t”)
s = s:gsub(“1F”, “u”)
s = s:gsub(“20”, “v”)
s = s:gsub(“21”, “W”)
s = s:gsub(“22”, “x”)
s = s:gsub(“23”, “y”)
s = s:gsub(“24”, “z”)
s = s:gsub(“25”, “#”)
s = s:gsub(“26”, “+”)
s = s:gsub(“27”, “-“)
s = s:gsub(“28”, “.”)
s = s:gsub(“f7”, “”)
s = s:gsub(“0A”, ” “)
s = s:gsub(“0a”, ” “)
s = s:gsub(“F7”, “”)
print(s)
January 13, 2015 at 1:56 am #35510Well I’m not a professional but I know that staying positive will help you from going mad. But I don’t really think that going back to exactly the same “method” as last week and being positive about it will solve your problem. 😉
I’ve have changed my approach, took Atoms advice (if somebody will know… he will) and changed my code…
His code does what we want… (Mine did as well, but was way to long) The problem was I was trying to put in Hex values… But feeding it Decimals does/did the trick.
I have read about tonumber( ) and think I will have to use this to cast the bytes from the sysex message to numbers. The question is where/how.
Can somebody help / give me some advice? Please
Here is what I have now; and throws this error at me:
At line [-1]: [C]
What: C
Namewhat: method
Name: getData
Error message: std::runtime_error: ‘Trying to use unregistered class’This function tries to simulate the Midi-Dump, And prints to the console etc. :
function SYSEXDUMP_EMULATION() s = MemoryBlock( { 0xf0, 0x47, 0x00, 0x03, 0x48, 0x01, 0x00, 0x1d, 0x16, 0x0b, 0x1a, 0x0a, 0x0c, 0x0b, 0x1d, 0x1d, 0x0a, 0x0a, 0x0a, 0xf7 } ) name = covertNames( s ) -- name = akaiAlphabet( 10 ) -- <== works; just one character console( name ) end
I’m trying to convert the midi-message to Akai Character one by one here:
function covertNames( midiMessage ) programName = MemoryBlock() c = MemoryBlock() size = midiMessage:getSize() -- Size received midi bytes if size == 20 then -- if sysex string is 20 bytes long nameStringHex = MemoryBlock( midiMessage:getData():getRange( 08, 12 )) -- memoryblock with 12 char bytes for i = 1, 12, 1 do c = akaiAlphabet( nameStringHex:getByte( i ) ) programName:append( c:getData() ) end end return programName end
Here’s Atom’s function with some extra error messages.
So we’ll get an error when our number is out of bounds:function akaiAlphabet( c ) if c >= 0 and c <= 41 then akaiAlphabet = {'0','1','2','3','4','5','6','7','8','9',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','#','+','-','.'} return (akaiAlphabet[ c ]) elseif c == "nil" then error("NIL is NOT an Akai Character") else error("This byte is NOT an Akai Character") end end
So if anybody can point out my mistake or tell me what to read or what DEMO-panel to look at… I would be very happy!
January 13, 2015 at 9:52 am #35526True….
im digging in the manual a little more.
copy & paste code brings nothing without a basic understanding.January 13, 2015 at 10:25 am #35528Well you get an error because you are passing a MemoryBLock to your function and trying to call getData() on it, and you call getData() on a CtrlrMidiMessage() object not a MemoryBlock object.
ALSO you can’t have a function named akaiAlphabet and a table named the same way unless you explicitly say that the table is a local variable (by default all variables in lua are global, so you will get an error that you are trying to call a table as a function)
January 15, 2015 at 1:20 am #35644True… im digging in the manual a little more. copy & paste code brings nothing without a basic understanding.
Yes, I know… I’m having the same problem… It ain’t the best documented language: Lua… And CTRLR info is a bit scattered around this site as well…
But the more we’ll learn in the beginning the easier it’ll be after that 🙂
Well you get an error because you are passing a MemoryBLock to your function and trying to call getData() on it, and you call getData() on a CtrlrMidiMessage() object not a MemoryBlock object.
Cheers, I quickly tried but couldn’t get it to work when changing the MemoryBlock to CtrlrMidiMessage. I’ll try some more later…
Thanx
February 4, 2016 at 12:10 am #68272I think this thread should continue here: http://ctrlr.org/forums/topic/akai-s2000/
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.