|
|
|
11-27-2020, 06:25 AM
|
#1
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
ASCII string to MIDI Morse Script?
I'm not LUA/Pyton programmer.
I ask to the great expertises here.
I would like to have a script that gets an ASCII string, and it turns it into a sequence of dashes-dots into the MIDI window.
Considering that:
- Dash is 3 times longer than a dot
- Dashes and dots, in a character, are spaced by a dot-length
- Characters are spaced by a dash-length (3 dots)
- words are spaced by: a dash length space + 7 dots + dash-length space
Example: running the script, a windows opens with an input field
I writ "Hello World"
and once I give OK, it should place the following sequences of dashes & dots o A note I selected
.... . .-.. .-.. --- ....... .-- --- .-. .-.. -..
Thank you so much in advance for who can help me on that
|
|
|
11-27-2020, 09:46 AM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
So you want the script to translate the Ascii into morse code and transform the morse-code into midi notes of that form, drawn into the midi editor currently selected?
Like, dot=short note, long=long note?
Edit:
You said words are spaced by a certain sequence. I take it that the character for the spacebar shall follow the sequence "dash length space + 7 dots + dash-length space" rather than !?.;, who can separate words as well.
I made a basic ascii to morse-code converter that hopefully converts it to your description above(and displays the result into the ReaScript-console-window):
Code:
retval, InputString=reaper.GetUserInputs("Original string", 1, "", "")
if retval==false then return end
InputString=InputString:upper()
MorseTable={}
MorseTable["A"]=". -"
MorseTable["B"]="- . . ."
MorseTable["C"]="- . - ."
MorseTable["D"]="- . ."
MorseTable["E"]="."
MorseTable["F"]=". . - ."
MorseTable["G"]="- - ."
MorseTable["H"]=". . . ."
MorseTable["I"]=". ."
MorseTable["J"]=". - - -"
MorseTable["K"]="- . -"
MorseTable["L"]=". - . ."
MorseTable["M"]="- -"
MorseTable["N"]="- ."
MorseTable["O"]="- - -"
MorseTable["P"]=". - - ."
MorseTable["Q"]="- - . -"
MorseTable["R"]=". - ."
MorseTable["S"]=". . ."
MorseTable["T"]="-"
MorseTable["U"]=". . -"
MorseTable["V"]=". . . -"
MorseTable["W"]=". - -"
MorseTable["X"]="- . . -"
MorseTable["Y"]="- . - -"
MorseTable["Z"]="- - . ."
MorseTable["1"]=". - - - -"
MorseTable["2"]=". . - - -"
MorseTable["3"]=". . . - -"
MorseTable["4"]=". . . . -"
MorseTable["5"]=". . . . ."
MorseTable["6"]="- . . . ."
MorseTable["7"]="- - . . ."
MorseTable["8"]="- - - . ."
MorseTable["9"]="- - - - ."
MorseTable["0"]="- - - - -"
MorseTable["À"]=". - - . -"
MorseTable["Å"]=". - - . -"
MorseTable["Ä"]=". - . -"
MorseTable["È"]=". - . . -"
MorseTable["É"]=". . - . ."
MorseTable["Ö"]="- - - ."
MorseTable["Ü"]=". . - -"
MorseTable["ß"]=". . . - - . ."
MorseTable["CH"]="- - - -"
MorseTable["Ñ"]="- - . - -"
MorseTable["."]=". - . - . -"
MorseTable[","]="- - . . - -"
MorseTable[":"]="- - - . . ."
MorseTable[";"]="- . - . - ."
MorseTable["?"]=". . - - . ."
MorseTable["!"]="- . - . - -"
MorseTable["-"]="- . . . . -"
MorseTable["_"]=". . - - . -"
MorseTable["("]="- . - - ."
MorseTable[")"]="- . - - . -"
MorseTable["'"]=". - - - - ."
MorseTable["\""]=". - . . - ."
MorseTable["="]="- . . . -"
MorseTable["+"]=". - . - ."
MorseTable["/"]="- . . - ."
MorseTable["@"]=". - - . - ."
MorseTable[" "]=" "
OutputString=""
i=1
while i<=InputString:len() do
k=InputString:sub(i,i)
if k==c and InputString:sub(i+1,i+1)=="H" then
k="CH"
i=i+1
end
if MorseTable[k]~=nil then
OutputString=OutputString..MorseTable[k].." "
end
i=i+1
end
OutputString=OutputString:sub(1,-4)
reaper.ShowConsoleMsg("\n"..OutputString.."\n")
reaper.ShowConsoleMsg(string.gsub(OutputString, " ", "|").."\n")
It omits all characters not known to morse-code and sees the original string as upper-case.
I output it two ways: one the regular way and one, where I replaced the spaces with | so you can count out, whether the output matches your descriptions for character/wordspacing properly.
If that's working the way you expect it, it can be further developed along to insert the result as midi-notes.
(Not by me though, as I have no experience with drawing midi-notes.)
I followed this morse-code-table: https://de.wikipedia.org/wiki/Morsec...rd-Codetabelle
Last edited by Meo-Ada Mespotine; 11-27-2020 at 10:32 AM.
|
|
|
11-27-2020, 09:53 AM
|
#3
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,109
|
kawa has some morse related scripts in ReaPack:
https://kawa.works/reascript-midi-section
(look for morse, edit: the closest to what you're looking for is probably '46. Morse Split'/'48. Morse Duplicate').
Last edited by nofish; 11-27-2020 at 10:41 AM.
|
|
|
11-27-2020, 10:59 AM
|
#4
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by Meo-Ada Mespotine
So you want the script to translate the Ascii into morse code and transform the morse-code into midi notes of that form, drawn into the midi editor currently selected?
Like, dot=short note, long=long note?
Edit:
You said words are spaced by a certain sequence. I take it that the character for the spacebar shall follow the sequence "dash length space + 7 dots + dash-length space" rather than !?.;, who can separate words as well.
I made a basic ascii to morse-code converter that hopefully converts it to your description above(and displays the result into the ReaScript-console-window):
Code:
retval, InputString=reaper.GetUserInputs("Original string", 1, "", "")
if retval==false then return end
InputString=InputString:upper()
MorseTable={}
MorseTable["A"]=". -"
MorseTable["B"]="- . . ."
MorseTable["C"]="- . - ."
MorseTable["D"]="- . ."
MorseTable["E"]="."
MorseTable["F"]=". . - ."
MorseTable["G"]="- - ."
MorseTable["H"]=". . . ."
MorseTable["I"]=". ."
MorseTable["J"]=". - - -"
MorseTable["K"]="- . -"
MorseTable["L"]=". - . ."
MorseTable["M"]="- -"
MorseTable["N"]="- ."
MorseTable["O"]="- - -"
MorseTable["P"]=". - - ."
MorseTable["Q"]="- - . -"
MorseTable["R"]=". - ."
MorseTable["S"]=". . ."
MorseTable["T"]="-"
MorseTable["U"]=". . -"
MorseTable["V"]=". . . -"
MorseTable["W"]=". - -"
MorseTable["X"]="- . . -"
MorseTable["Y"]="- . - -"
MorseTable["Z"]="- - . ."
MorseTable["1"]=". - - - -"
MorseTable["2"]=". . - - -"
MorseTable["3"]=". . . - -"
MorseTable["4"]=". . . . -"
MorseTable["5"]=". . . . ."
MorseTable["6"]="- . . . ."
MorseTable["7"]="- - . . ."
MorseTable["8"]="- - - . ."
MorseTable["9"]="- - - - ."
MorseTable["0"]="- - - - -"
MorseTable["À"]=". - - . -"
MorseTable["Å"]=". - - . -"
MorseTable["Ä"]=". - . -"
MorseTable["È"]=". - . . -"
MorseTable["É"]=". . - . ."
MorseTable["Ö"]="- - - ."
MorseTable["Ü"]=". . - -"
MorseTable["ß"]=". . . - - . ."
MorseTable["CH"]="- - - -"
MorseTable["Ñ"]="- - . - -"
MorseTable["."]=". - . - . -"
MorseTable[","]="- - . . - -"
MorseTable[":"]="- - - . . ."
MorseTable[";"]="- . - . - ."
MorseTable["?"]=". . - - . ."
MorseTable["!"]="- . - . - -"
MorseTable["-"]="- . . . . -"
MorseTable["_"]=". . - - . -"
MorseTable["("]="- . - - ."
MorseTable[")"]="- . - - . -"
MorseTable["'"]=". - - - - ."
MorseTable["\""]=". - . . - ."
MorseTable["="]="- . . . -"
MorseTable["+"]=". - . - ."
MorseTable["/"]="- . . - ."
MorseTable["@"]=". - - . - ."
MorseTable[" "]=" "
OutputString=""
i=1
while i<=InputString:len() do
k=InputString:sub(i,i)
if k==c and InputString:sub(i+1,i+1)=="H" then
k="CH"
i=i+1
end
if MorseTable[k]~=nil then
OutputString=OutputString..MorseTable[k].." "
end
i=i+1
end
OutputString=OutputString:sub(1,-4)
reaper.ShowConsoleMsg("\n"..OutputString.."\n")
reaper.ShowConsoleMsg(string.gsub(OutputString, " ", "|").."\n")
It omits all characters not known to morse-code and sees the original string as upper-case.
I output it two ways: one the regular way and one, where I replaced the spaces with | so you can count out, whether the output matches your descriptions for character/wordspacing properly.
If that's working the way you expect it, it can be further developed along to insert the result as midi-notes.
(Not by me though, as I have no experience with drawing midi-notes.)
I followed this morse-code-table: https://de.wikipedia.org/wiki/Morsec...rd-Codetabelle
|
Wow I will try it and I will be back to you to give the feedback
|
|
|
11-27-2020, 11:09 AM
|
#5
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by Meo-Ada Mespotine
So you want the script to translate the Ascii into morse code and transform the morse-code into midi notes of that form, drawn into the midi editor currently selected?
Like, dot=short note, long=long note?
Edit:
You said words are spaced by a certain sequence. I take it that the character for the spacebar shall follow the sequence "dash length space + 7 dots + dash-length space" rather than !?.;, who can separate words as well.
I made a basic ascii to morse-code converter that hopefully converts it to your description above(and displays the result into the ReaScript-console-window):
Code:
retval, InputString=reaper.GetUserInputs("Original string", 1, "", "")
if retval==false then return end
InputString=InputString:upper()
MorseTable={}
MorseTable["A"]=". -"
MorseTable["B"]="- . . ."
MorseTable["C"]="- . - ."
MorseTable["D"]="- . ."
MorseTable["E"]="."
MorseTable["F"]=". . - ."
MorseTable["G"]="- - ."
MorseTable["H"]=". . . ."
MorseTable["I"]=". ."
MorseTable["J"]=". - - -"
MorseTable["K"]="- . -"
MorseTable["L"]=". - . ."
MorseTable["M"]="- -"
MorseTable["N"]="- ."
MorseTable["O"]="- - -"
MorseTable["P"]=". - - ."
MorseTable["Q"]="- - . -"
MorseTable["R"]=". - ."
MorseTable["S"]=". . ."
MorseTable["T"]="-"
MorseTable["U"]=". . -"
MorseTable["V"]=". . . -"
MorseTable["W"]=". - -"
MorseTable["X"]="- . . -"
MorseTable["Y"]="- . - -"
MorseTable["Z"]="- - . ."
MorseTable["1"]=". - - - -"
MorseTable["2"]=". . - - -"
MorseTable["3"]=". . . - -"
MorseTable["4"]=". . . . -"
MorseTable["5"]=". . . . ."
MorseTable["6"]="- . . . ."
MorseTable["7"]="- - . . ."
MorseTable["8"]="- - - . ."
MorseTable["9"]="- - - - ."
MorseTable["0"]="- - - - -"
MorseTable["À"]=". - - . -"
MorseTable["Å"]=". - - . -"
MorseTable["Ä"]=". - . -"
MorseTable["È"]=". - . . -"
MorseTable["É"]=". . - . ."
MorseTable["Ö"]="- - - ."
MorseTable["Ü"]=". . - -"
MorseTable["ß"]=". . . - - . ."
MorseTable["CH"]="- - - -"
MorseTable["Ñ"]="- - . - -"
MorseTable["."]=". - . - . -"
MorseTable[","]="- - . . - -"
MorseTable[":"]="- - - . . ."
MorseTable[";"]="- . - . - ."
MorseTable["?"]=". . - - . ."
MorseTable["!"]="- . - . - -"
MorseTable["-"]="- . . . . -"
MorseTable["_"]=". . - - . -"
MorseTable["("]="- . - - ."
MorseTable[")"]="- . - - . -"
MorseTable["'"]=". - - - - ."
MorseTable["\""]=". - . . - ."
MorseTable["="]="- . . . -"
MorseTable["+"]=". - . - ."
MorseTable["/"]="- . . - ."
MorseTable["@"]=". - - . - ."
MorseTable[" "]=" "
OutputString=""
i=1
while i<=InputString:len() do
k=InputString:sub(i,i)
if k==c and InputString:sub(i+1,i+1)=="H" then
k="CH"
i=i+1
end
if MorseTable[k]~=nil then
OutputString=OutputString..MorseTable[k].." "
end
i=i+1
end
OutputString=OutputString:sub(1,-4)
reaper.ShowConsoleMsg("\n"..OutputString.."\n")
reaper.ShowConsoleMsg(string.gsub(OutputString, " ", "|").."\n")
It omits all characters not known to morse-code and sees the original string as upper-case.
I output it two ways: one the regular way and one, where I replaced the spaces with | so you can count out, whether the output matches your descriptions for character/wordspacing properly.
If that's working the way you expect it, it can be further developed along to insert the result as midi-notes.
(Not by me though, as I have no experience with drawing midi-notes.)
I followed this morse-code-table: https://de.wikipedia.org/wiki/Morsec...rd-Codetabelle
|
I did tried it. It works perfectly. Now the only thing is missing, is to translate the returned morse code into notes. Exactly like you have understood from my request
|
|
|
11-27-2020, 12:09 PM
|
#6
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
For those who want to approach it:
Read the OutputString-variable character by character and set the notes according to that.
- becomes the three times note
. becomes the one time note,
everything else becomes a one-time-pause.
@BartR
It would be helpful, if you could specify what the length of a dotted note is, so it would be possible to work from that.
|
|
|
11-27-2020, 12:20 PM
|
#7
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by Meo-Ada Mespotine
For those who want to approach it:
Read the OutputString-variable character by character and set the notes according to that.
- becomes the three times note
. becomes the one time note,
everything else becomes a one-time-pause.
@BartR
It would be helpful, if you could specify what the length of a dotted note is, so it would be possible to work from that.
|
Right.
suppose the grid is in quarters
the dash is 3/4
the dot is 1/4
Space between characters: 3/4
please check the example I have made here in the screenshot in attachment
|
|
|
11-27-2020, 12:29 PM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by BartR
Right.
suppose the grid is in quarters
the dash is 3/4
the dot is 1/4
Space between characters: 3/4
please check the example I have made here in the screenshot in attachment
|
So it's relative to the gridsize?
|
|
|
11-27-2020, 01:01 PM
|
#9
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by Meo-Ada Mespotine
So it's relative to the gridsize?
|
If you want: yes. I mean this was the esiest way, for me, to put Morse-code inside the MIDI (by hand).
But you are not obliged to follow the grid size.
Just te relationships among dash-dot-space
Last edited by BartR; 11-27-2020 at 01:07 PM.
|
|
|
11-27-2020, 02:37 PM
|
#10
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Here is Mespotine's code with added code for the MIDI Notes.
It will insert a new MIDI item at the first selected or last touched track at the edit cursor position.
Code:
retval, InputString=reaper.GetUserInputs("Original string", 1, "", "")
if retval==false then return end
InputString=InputString:upper()
MorseTable={}
MorseTable["A"]=". -"
MorseTable["B"]="- . . ."
MorseTable["C"]="- . - ."
MorseTable["D"]="- . ."
MorseTable["E"]="."
MorseTable["F"]=". . - ."
MorseTable["G"]="- - ."
MorseTable["H"]=". . . ."
MorseTable["I"]=". ."
MorseTable["J"]=". - - -"
MorseTable["K"]="- . -"
MorseTable["L"]=". - . ."
MorseTable["M"]="- -"
MorseTable["N"]="- ."
MorseTable["O"]="- - -"
MorseTable["P"]=". - - ."
MorseTable["Q"]="- - . -"
MorseTable["R"]=". - ."
MorseTable["S"]=". . ."
MorseTable["T"]="-"
MorseTable["U"]=". . -"
MorseTable["V"]=". . . -"
MorseTable["W"]=". - -"
MorseTable["X"]="- . . -"
MorseTable["Y"]="- . - -"
MorseTable["Z"]="- - . ."
MorseTable["1"]=". - - - -"
MorseTable["2"]=". . - - -"
MorseTable["3"]=". . . - -"
MorseTable["4"]=". . . . -"
MorseTable["5"]=". . . . ."
MorseTable["6"]="- . . . ."
MorseTable["7"]="- - . . ."
MorseTable["8"]="- - - . ."
MorseTable["9"]="- - - - ."
MorseTable["0"]="- - - - -"
MorseTable["À"]=". - - . -"
MorseTable["Å"]=". - - . -"
MorseTable["Ä"]=". - . -"
MorseTable["È"]=". - . . -"
MorseTable["É"]=". . - . ."
MorseTable["Ö"]="- - - ."
MorseTable["Ü"]=". . - -"
MorseTable["ß"]=". . . - - . ."
MorseTable["CH"]="- - - -"
MorseTable["Ñ"]="- - . - -"
MorseTable["."]=". - . - . -"
MorseTable[","]="- - . . - -"
MorseTable[":"]="- - - . . ."
MorseTable[";"]="- . - . - ."
MorseTable["?"]=". . - - . ."
MorseTable["!"]="- . - . - -"
MorseTable["-"]="- . . . . -"
MorseTable["_"]=". . - - . -"
MorseTable["("]="- . - - ."
MorseTable[")"]="- . - - . -"
MorseTable["'"]=". - - - - ."
MorseTable["\""]=". - . . - ."
MorseTable["="]="- . . . -"
MorseTable["+"]=". - . - ."
MorseTable["/"]="- . . - ."
MorseTable["@"]=". - - . - ."
MorseTable[" "]=" "
OutputString=""
i=1
while i<=InputString:len() do
k=InputString:sub(i,i)
if k=="C" and InputString:sub(i+1,i+1)=="H" then
k="CH"
i=i+1
end
if MorseTable[k]~=nil then
OutputString=OutputString..MorseTable[k].." "
end
i=i+1
end
OutputString=OutputString:sub(1,-4)
reaper.ShowConsoleMsg("\n"..OutputString.."\n")
-- Insert MIDI item at edit cursor position with Morse message
local cur_pos = reaper.GetCursorPosition()
local track = reaper.GetSelectedTrack(0, 0) or reaper.GetLastTouchedTrack()
if not track then return end
local item = reaper.CreateNewMIDIItemInProj( track, cur_pos, cur_pos + 5, false )
local take = reaper.GetActiveTake( item )
local pos = reaper.MIDI_GetPPQPosFromProjTime( take, cur_pos )
local dur = 480
local len = #OutputString
local i = 1
while true do
local l = OutputString:sub( i, i )
local duration
if l == "-" then
duration = pos + dur*3
reaper.MIDI_InsertNote( take, false, false, pos, duration, 1, 71, 100, true )
elseif l == "." then
duration = pos + dur
reaper.MIDI_InsertNote( take, false, false, pos, duration, 1, 71, 100, true )
else -- l == " " then
duration = pos + dur
end
pos = duration
if i == len then break else i = i + 1 end
end
reaper.MIDI_Sort( take )
local last_note_end = ({reaper.MIDI_GetNote( take, ({reaper.MIDI_CountEvts( take )})[2]-1 )})[5]
reaper.SetMediaItemInfo_Value( item, "D_LENGTH", reaper.MIDI_GetProjTimeFromPPQPos( take, last_note_end ) - cur_pos )
reaper.Undo_OnStateChange( "Create Morse Code Item" )
Last edited by amagalma; 11-27-2020 at 03:03 PM.
|
|
|
11-27-2020, 03:22 PM
|
#11
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by amagalma
Here is Mespotine's code with added code for the MIDI Notes.
It will insert a new MIDI item at the first selected or last touched track at the edit cursor position.
Code:
retval, InputString=reaper.GetUserInputs("Original string", 1, "", "")
if retval==false then return end
InputString=InputString:upper()
MorseTable={}
MorseTable["A"]=". -"
MorseTable["B"]="- . . ."
MorseTable["C"]="- . - ."
MorseTable["D"]="- . ."
MorseTable["E"]="."
MorseTable["F"]=". . - ."
MorseTable["G"]="- - ."
MorseTable["H"]=". . . ."
MorseTable["I"]=". ."
MorseTable["J"]=". - - -"
MorseTable["K"]="- . -"
MorseTable["L"]=". - . ."
MorseTable["M"]="- -"
MorseTable["N"]="- ."
MorseTable["O"]="- - -"
MorseTable["P"]=". - - ."
MorseTable["Q"]="- - . -"
MorseTable["R"]=". - ."
MorseTable["S"]=". . ."
MorseTable["T"]="-"
MorseTable["U"]=". . -"
MorseTable["V"]=". . . -"
MorseTable["W"]=". - -"
MorseTable["X"]="- . . -"
MorseTable["Y"]="- . - -"
MorseTable["Z"]="- - . ."
MorseTable["1"]=". - - - -"
MorseTable["2"]=". . - - -"
MorseTable["3"]=". . . - -"
MorseTable["4"]=". . . . -"
MorseTable["5"]=". . . . ."
MorseTable["6"]="- . . . ."
MorseTable["7"]="- - . . ."
MorseTable["8"]="- - - . ."
MorseTable["9"]="- - - - ."
MorseTable["0"]="- - - - -"
MorseTable["À"]=". - - . -"
MorseTable["Å"]=". - - . -"
MorseTable["Ä"]=". - . -"
MorseTable["È"]=". - . . -"
MorseTable["É"]=". . - . ."
MorseTable["Ö"]="- - - ."
MorseTable["Ü"]=". . - -"
MorseTable["ß"]=". . . - - . ."
MorseTable["CH"]="- - - -"
MorseTable["Ñ"]="- - . - -"
MorseTable["."]=". - . - . -"
MorseTable[","]="- - . . - -"
MorseTable[":"]="- - - . . ."
MorseTable[";"]="- . - . - ."
MorseTable["?"]=". . - - . ."
MorseTable["!"]="- . - . - -"
MorseTable["-"]="- . . . . -"
MorseTable["_"]=". . - - . -"
MorseTable["("]="- . - - ."
MorseTable[")"]="- . - - . -"
MorseTable["'"]=". - - - - ."
MorseTable["\""]=". - . . - ."
MorseTable["="]="- . . . -"
MorseTable["+"]=". - . - ."
MorseTable["/"]="- . . - ."
MorseTable["@"]=". - - . - ."
MorseTable[" "]=" "
OutputString=""
i=1
while i<=InputString:len() do
k=InputString:sub(i,i)
if k=="C" and InputString:sub(i+1,i+1)=="H" then
k="CH"
i=i+1
end
if MorseTable[k]~=nil then
OutputString=OutputString..MorseTable[k].." "
end
i=i+1
end
OutputString=OutputString:sub(1,-4)
reaper.ShowConsoleMsg("\n"..OutputString.."\n")
-- Insert MIDI item at edit cursor position with Morse message
local cur_pos = reaper.GetCursorPosition()
local track = reaper.GetSelectedTrack(0, 0) or reaper.GetLastTouchedTrack()
if not track then return end
local item = reaper.CreateNewMIDIItemInProj( track, cur_pos, cur_pos + 5, false )
local take = reaper.GetActiveTake( item )
local pos = reaper.MIDI_GetPPQPosFromProjTime( take, cur_pos )
local dur = 480
local len = #OutputString
local i = 1
while true do
local l = OutputString:sub( i, i )
local duration
if l == "-" then
duration = pos + dur*3
reaper.MIDI_InsertNote( take, false, false, pos, duration, 1, 71, 100, true )
elseif l == "." then
duration = pos + dur
reaper.MIDI_InsertNote( take, false, false, pos, duration, 1, 71, 100, true )
else -- l == " " then
duration = pos + dur
end
pos = duration
if i == len then break else i = i + 1 end
end
reaper.MIDI_Sort( take )
local last_note_end = ({reaper.MIDI_GetNote( take, ({reaper.MIDI_CountEvts( take )})[2]-1 )})[5]
reaper.SetMediaItemInfo_Value( item, "D_LENGTH", reaper.MIDI_GetProjTimeFromPPQPos( take, last_note_end ) - cur_pos )
reaper.Undo_OnStateChange( "Create Morse Code Item" )
|
WOWWWWWWWWW That's great!!! it works super!!!
Liten, can you put it somewhere where other ones can download it? A stash or so?
I will use it for something unique and I would like it is accessible by everyone (with your consent)
Guys you are great!
|
|
|
11-27-2020, 03:51 PM
|
#12
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
@amagalma
If you want to add it to ReaPack, just add my name and a link to mespotine.de to it and I'm fine.
|
|
|
11-27-2020, 04:06 PM
|
#13
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
|
Thanks to all, tried it quickly, cool working nicely.
Using the "item stretching feature" one can anyway stretch the result to any length. My test string was "James Brown is dead", it gave its original length. Then stretched to 1 bar, too quick notes, 2 bars, hmm better, maybe still too fast, 4 bars, ok, nice. So for "James Brown is dead" a 4 bar stretch gives nice result, of course, always depending on what you goal with those midi notes are. I had only a simple piano sound on the fx, which is my default for new tracks.
One nice addition could be, adding, on top also the original text as text markers, and even displaying maybe as a separate "empty item" on a new track above. So we could see later text, plus below the midi notes.
Or you could take lyrics of any midi songs or .kar (karaoke songs, which are also .mid only using a different ending), and convert the entire lyrics into midi notes. One would only need to find the "fitting" stretch amount for the target use case. Thanks again, cool addition. kawa's morse tool is for splitting notes, I also did not check if the specifications are exactly same. But cool having both.
One could start thinking, which other data we want to convert to midi notes?
What about binary number sequences? No matter if decimal number as input or hexadecimal number as input, both could be converted to binary number, then those sequence to midi notes, again using step length of a quarter note, we can stretch it anyways later.
Any other interesting ideas, what could be converted? ascii to decimal to binary to notes, as a second track, playing together with morse in first track, checking how it sounds. Maybe these ideas can create new form of "euclidean rhythms".
Then maybe colors, to numbers to binary to notes.
|
|
|
11-27-2020, 04:08 PM
|
#14
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
|
Quote:
Originally Posted by BartR
I will use it for something unique and I would like it is accessible by everyone (with your consent)
|
Can you tell more about your use case, if it is not a secret?
|
|
|
11-27-2020, 04:21 PM
|
#15
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by TonE
Thanks to all, tried it quickly, cool working nicely.
Using the "item stretching feature" one can anyway stretch the result to any length. My test string was "James Brown is dead", it gave its original length. Then stretched to 1 bar, too quick notes, 2 bars, hmm better, maybe still too fast, 4 bars, ok, nice. So for "James Brown is dead" a 4 bar stretch gives nice result, of course, always depending on what you goal with those midi notes are. I had only a simple piano sound on the fx, which is my default for new tracks.
One nice addition could be, adding, on top also the original text as text markers, and even displaying maybe as a separate "empty item" on a new track above. So we could see later text, plus below the midi notes.
Or you could take lyrics of any midi songs or .kar (karaoke songs, which are also .mid only using a different ending), and convert the entire lyrics into midi notes. One would only need to find the "fitting" stretch amount for the target use case. Thanks again, cool addition. kawa's morse tool is for splitting notes, I also did not check if the specifications are exactly same. But cool having both.
One could start thinking, which other data we want to convert to midi notes?
What about binary number sequences? No matter if decimal number as input or hexadecimal number as input, both could be converted to binary number, then those sequence to midi notes, again using step length of a quarter note, we can stretch it anyways later.
Any other interesting ideas, what could be converted? ascii to decimal to binary to notes, as a second track, playing together with morse in first track, checking how it sounds. Maybe these ideas can create new form of "euclidean rhythms".
Then maybe colors, to numbers to binary to notes.
|
This script as it is, it's very USEFUL for a purpose I will present here once I have made the related video about.
CERTAINLY it can be more improved. But what I aks is to wait a bit, because on that video, you will se an application, in this moment, you can't imagine neither :-)
And perhaps it can help you also to have other ideas about :-)
It will be nie it's into ReaPack so that people can take it, without "script install" procedures (especially for who comes to Reaper the first time :-) ). At the same time it can be easily updated and improved :-)
I've also some idea in conjunction with yours etc. just I would like that you will evaluate it after having seen that purpose, for which I asked for the script :-)
Im' sure you will appreciate
Last edited by BartR; 11-27-2020 at 05:00 PM.
Reason: corrected
|
|
|
11-27-2020, 05:00 PM
|
#16
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
@tone
SORRY I CORRECTED
i did write "the script as it is is useless"
I wanted to write "IS USEFUL"
I'm very sorry for that. I corrected the message.Shame on me :-(
Last edited by BartR; 11-27-2020 at 05:22 PM.
|
|
|
11-27-2020, 05:51 PM
|
#17
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
|
Let us wait for the magic video then.
|
|
|
11-28-2020, 02:24 AM
|
#18
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
amagalma_mespotine_Create MIDI Morse Message Item at edit cursor position, grid length duration, first selected/last touched/ or first track
is up on ReaPack
Code:
local track = reaper.GetSelectedTrack(0, 0) or (reaper.GetLastTouchedTrack() or reaper.GetTrack(0, 0))
if not track then return end
local ok, InputString = reaper.GetUserInputs("Create (International) Morse Code Message", 1,
"Enter Message :,extrawidth=100", "")
if not ok then return end
InputString = InputString:upper()
local MorseTable = {
["A"] = {". -", 5},
["B"] = {"- . . .", 9},
["C"] = {"- . - .", 11},
["D"] = {"- . .", 7},
["E"] = {".", 1},
["F"] = {". . - .", 9},
["G"] = {"- - .", 9},
["H"] = {". . . .", 7},
["I"] = {". .", 3},
["J"] = {". - - -", 13},
["K"] = {"- . -", 9},
["L"] = {". - . .", 9},
["M"] = {"- -", 7},
["N"] = {"- .", 5},
["O"] = {"- - -", 11},
["P"] = {". - - .", 11},
["Q"] = {"- - . -", 13},
["R"] = {". - .", 7},
["S"] = {". . .", 5},
["T"] = {"-", 3},
["U"] = {". . -", 7},
["V"] = {". . . -", 9},
["W"] = {". - -", 9},
["X"] = {"- . . -", 11},
["Y"] = {"- . - -", 13},
["Z"] = {"- - . .", 11},
["0"] = {"- - - - -", 19},
["1"] = {". - - - -", 17},
["2"] = {". . - - -", 15},
["3"] = {". . . - -", 13},
["4"] = {". . . . -", 11},
["5"] = {". . . . .", 9},
["6"] = {"- . . . .", 11},
["7"] = {"- - . . .", 13},
["8"] = {"- - - . .", 15},
["9"] = {"- - - - .", 17},
["Ä"] = {". - . -", 11},
["Á"] = {". - - . -", 15},
["À"] = {". - - . -", 15},
["CH"] = {"- - - -", 15},
["Å"] = {". - - . -", 15},
["È"] = {". - . . -", 13},
["É"] = {". . - . .", 11},
["Ñ"] = {"- - . - -", 17},
["Ö"] = {"- - - .", 13},
["Ü"] = {". . - -", 11},
["ß"] = {". . . - - . .", 17},
[" "] = {" ", 13},
["="] = {"- . . . -", 13},
["!"] = {"- . - . - -", 19},
['"'] = {". - . . - .", 15},
["'"] = {". - - - - .", 19},
["("] = {"- . - - .", 15},
[")"] = {"- . - - . -", 19},
["+"] = {". - . - .", 13},
[","] = {"- - . . - -", 19},
["-"] = {"- . . . . -", 15},
["."] = {". - . - . -", 17},
["/"] = {"- . . - .", 13},
[":"] = {"- - - . . .", 17},
[";"] = {"- . - . - .", 17},
["?"] = {". . - - . .", 15},
["@"] = {". - - . - .", 17},
["_"] = {". . - - . -", 17},
}
local InputString_len = InputString:len()
local OutputString = ""
local i = 1
local total_str_length = 0
while true do
local k = InputString:sub(i,i)
if k == "C" and InputString:sub(i+1,i+1) == "H" then
k = "CH"
i = i + 1
end
if MorseTable[k][1] then
OutputString = OutputString .. MorseTable[k][1] .. " "
total_str_length = total_str_length + MorseTable[k][2] + 3
else
reaper.MB( k .. " is not a valid International Morse Code character", "Invalid character!", 0 )
return
end
i = i + 1
if i > InputString_len then break end
end
OutputString = OutputString:sub(1,-4)
total_str_length = total_str_length - 3
-- Insert MIDI item at edit cursor position with Morse message
local cur_pos = reaper.GetCursorPosition()
local miditicksperbeat = tonumber(({reaper.get_config_var_string( "miditicksperbeat" )})[2])
local grid_in_QN = (({reaper.GetSetProjectGrid( 0, 0, 0, 0, 0 )})[2]) * 4
local dur = miditicksperbeat*grid_in_QN
local cur_pos_QN = reaper.TimeMap_timeToQN( cur_pos )
local item = reaper.CreateNewMIDIItemInProj( track, cur_pos_QN, cur_pos_QN + total_str_length*grid_in_QN, true )
local take = reaper.GetActiveTake( item )
local pos_ppq = reaper.MIDI_GetPPQPosFromProjTime( take, cur_pos )
local len = #OutputString
local i = 1
while true do
local l = OutputString:sub( i, i )
local duration
if l == "-" then
duration = pos_ppq + dur*3
reaper.MIDI_InsertNote( take, false, false, pos_ppq, duration, 1, 71, 100, true )
elseif l == "." then
duration = pos_ppq + dur
reaper.MIDI_InsertNote( take, false, false, pos_ppq, duration, 1, 71, 100, true )
else -- l == " " then
duration = pos_ppq + dur
end
pos_ppq = duration
if i == len then break else i = i + 1 end
end
reaper.MIDI_Sort( take )
reaper.GetSetMediaItemTakeInfo_String( take, "P_NAME", "Message: " .. InputString, true )
reaper.Undo_OnStateChange( "Create Morse Code Item" )
@mespotine: I have added your website as a link. The donation link in your signature does not work, so I could not add it along with mine in the script. Update it if you wish and I' ll add it in the script too
|
|
|
11-28-2020, 02:48 AM
|
#19
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by amagalma
amagalma_mespotine_Create MIDI Morse Message Item at edit cursor position, grid length duration, first selected/last touched/ or first track
is up on ReaPack
Code:
local track = reaper.GetSelectedTrack(0, 0) or (reaper.GetLastTouchedTrack() or reaper.GetTrack(0, 0))
if not track then return end
local ok, InputString = reaper.GetUserInputs("Create (International) Morse Code Message", 1,
"Enter Message :,extrawidth=100", "")
if not ok then return end
InputString = InputString:upper()
local MorseTable = {
["A"] = {". -", 5},
["B"] = {"- . . .", 9},
["C"] = {"- . - .", 11},
["D"] = {"- . .", 7},
["E"] = {".", 1},
["F"] = {". . - .", 9},
["G"] = {"- - .", 9},
["H"] = {". . . .", 7},
["I"] = {". .", 3},
["J"] = {". - - -", 13},
["K"] = {"- . -", 9},
["L"] = {". - . .", 9},
["M"] = {"- -", 7},
["N"] = {"- .", 5},
["O"] = {"- - -", 11},
["P"] = {". - - .", 11},
["Q"] = {"- - . -", 13},
["R"] = {". - .", 7},
["S"] = {". . .", 5},
["T"] = {"-", 3},
["U"] = {". . -", 7},
["V"] = {". . . -", 9},
["W"] = {". - -", 9},
["X"] = {"- . . -", 11},
["Y"] = {"- . - -", 13},
["Z"] = {"- - . .", 11},
["0"] = {"- - - - -", 19},
["1"] = {". - - - -", 17},
["2"] = {". . - - -", 15},
["3"] = {". . . - -", 13},
["4"] = {". . . . -", 11},
["5"] = {". . . . .", 9},
["6"] = {"- . . . .", 11},
["7"] = {"- - . . .", 13},
["8"] = {"- - - . .", 15},
["9"] = {"- - - - .", 17},
["Ä"] = {". - . -", 11},
["Á"] = {". - - . -", 15},
["À"] = {". - - . -", 15},
["CH"] = {"- - - -", 15},
["Å"] = {". - - . -", 15},
["È"] = {". - . . -", 13},
["É"] = {". . - . .", 11},
["Ñ"] = {"- - . - -", 17},
["Ö"] = {"- - - .", 13},
["Ü"] = {". . - -", 11},
["ß"] = {". . . - - . .", 17},
[" "] = {" ", 13},
["="] = {"- . . . -", 13},
["!"] = {"- . - . - -", 19},
['"'] = {". - . . - .", 15},
["'"] = {". - - - - .", 19},
["("] = {"- . - - .", 15},
[")"] = {"- . - - . -", 19},
["+"] = {". - . - .", 13},
[","] = {"- - . . - -", 19},
["-"] = {"- . . . . -", 15},
["."] = {". - . - . -", 17},
["/"] = {"- . . - .", 13},
[":"] = {"- - - . . .", 17},
[";"] = {"- . - . - .", 17},
["?"] = {". . - - . .", 15},
["@"] = {". - - . - .", 17},
["_"] = {". . - - . -", 17},
}
local InputString_len = InputString:len()
local OutputString = ""
local i = 1
local total_str_length = 0
while true do
local k = InputString:sub(i,i)
if k == "C" and InputString:sub(i+1,i+1) == "H" then
k = "CH"
i = i + 1
end
if MorseTable[k][1] then
OutputString = OutputString .. MorseTable[k][1] .. " "
total_str_length = total_str_length + MorseTable[k][2] + 3
else
reaper.MB( k .. " is not a valid International Morse Code character", "Invalid character!", 0 )
return
end
i = i + 1
if i > InputString_len then break end
end
OutputString = OutputString:sub(1,-4)
total_str_length = total_str_length - 3
-- Insert MIDI item at edit cursor position with Morse message
local cur_pos = reaper.GetCursorPosition()
local miditicksperbeat = tonumber(({reaper.get_config_var_string( "miditicksperbeat" )})[2])
local grid_in_QN = (({reaper.GetSetProjectGrid( 0, 0, 0, 0, 0 )})[2]) * 4
local dur = miditicksperbeat*grid_in_QN
local cur_pos_QN = reaper.TimeMap_timeToQN( cur_pos )
local item = reaper.CreateNewMIDIItemInProj( track, cur_pos_QN, cur_pos_QN + total_str_length*grid_in_QN, true )
local take = reaper.GetActiveTake( item )
local pos_ppq = reaper.MIDI_GetPPQPosFromProjTime( take, cur_pos )
local len = #OutputString
local i = 1
while true do
local l = OutputString:sub( i, i )
local duration
if l == "-" then
duration = pos_ppq + dur*3
reaper.MIDI_InsertNote( take, false, false, pos_ppq, duration, 1, 71, 100, true )
elseif l == "." then
duration = pos_ppq + dur
reaper.MIDI_InsertNote( take, false, false, pos_ppq, duration, 1, 71, 100, true )
else -- l == " " then
duration = pos_ppq + dur
end
pos_ppq = duration
if i == len then break else i = i + 1 end
end
reaper.MIDI_Sort( take )
reaper.GetSetMediaItemTakeInfo_String( take, "P_NAME", "Message: " .. InputString, true )
reaper.Undo_OnStateChange( "Create Morse Code Item" )
@mespotine: I have added your website as a link. The donation link in your signature does not work, so I could not add it along with mine in the script. Update it if you wish and I' ll add it in the script too
|
EXCELLENT!
|
|
|
11-28-2020, 08:39 AM
|
#20
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
@amagalma
Oops, I updated the donation link
|
|
|
11-29-2020, 04:03 AM
|
#22
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
version 1.5 changelog :
- Full automatic Latin/Greek/Cyrillic character support!
- Take markers for every character
|
|
|
11-29-2020, 05:57 AM
|
#23
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
|
woooooow this is very cool! A thing I wanted to have some time ago!
Thanks for the script amagalma + mespotine you both are beautiful !
Now I can send more hidden messages in my music
|
|
|
11-29-2020, 06:45 AM
|
#24
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
|
Quote:
Originally Posted by amagalma
- Take markers for every character
|
Thanks a lot for the take markers, works perfectly!
|
|
|
12-01-2020, 06:44 AM
|
#25
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,624
|
Quote:
Originally Posted by TonE
Let us wait for the magic video then.
|
I think you can go ahead with your requests :-) The reason is that I will employ a bit to create that video, because to adapt the script better to my needs, I tried to make some modification (apart from the official now integrated in ReaPack) and being not LUA programmer, I'm busy with
I'm also t successful and I want to have this occasion to learn a bit more :-)
Apart this, I will YES use the one on ReaPAck; I find it great!
|
|
|
03-22-2022, 12:11 PM
|
#26
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
|
why "CH" is processed as a single character with 4 long beeps?
in "BACH" for exemple
|
|
|
11-05-2022, 08:30 AM
|
#27
|
Human being with feelings
Join Date: Feb 2011
Posts: 43
|
I've just been messing about with this script for rhythm generating, and changed the duration number from 480 to 240, to double the tempo, which works, and is better suited to my use. I couldn't initially see why it was defaulting to a B4 note, but then checked it as a note number and found the '71', so changed the 2 instances to 37 and now it directly triggers the snare in MT drums. It's simple to add the JS MIDI Transpose Notes plugin, as an alternative, to move the '71' note to a different one.
Once you have a midi rhythm, if you quantize to 'swing' @ 25%, it's all pretty close to a jazz snare line sound.
I found this as a good standalone utility for quickly auditioning/assessing morse rhythms and tempos, although it's only within the utility. It only saves with a default 'unit' of 1 second, so needs some more work to use in Reaper.
https://www.softpedia.com/get/Office...rse-Midi.shtml
|
|
|
11-05-2022, 08:42 AM
|
#28
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by daniellumertz
why "CH" is processed as a single character with 4 long beeps?
in "BACH" for exemple
|
Here's why:
https://en.m.wikipedia.org/wiki/Ch_(digraph)
tl;dr
It used to be its own character in many languages and its representation became ch later.
That's probably why it's represented as its own character.
|
|
|
11-05-2022, 11:05 AM
|
#29
|
Human being with feelings
Join Date: Feb 2011
Posts: 43
|
The space between words is supposed to be 7 units, but the script seems to be producing 13 units. I tried editing MorseTable[" "]=" " to 7 spaces from 13 but so far it hasn't worked.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:56 PM.
|