Created
October 1, 2018 20:58
-
-
Save ypxk/93170e361fc5a508d38e9514a05bed4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
music = require 'mark_eats/musicutil' | |
chordsList = {} | |
timeSet = 0 | |
timeDone = 0 | |
--midi function | |
m = midi.connect() | |
m.event = function(data) | |
local d = midi.to_msg(data) | |
if d.type == "note_on" then | |
noteBuffer(d.note) | |
timeDone = util.time() | |
end | |
end | |
--note function | |
function noteBuffer(aNote) | |
timeSet = util.time() | |
for k, v in pairs (chordsList) do --ignore duplicate notes | |
if aNote == v then | |
return | |
end | |
end | |
if timeSet - timeDone < .5 then --set window for note input presses | |
table.insert(chordsList, aNote) | |
else -- clears table and starts new buffer | |
print('Initializing buffer') | |
for k, v in pairs(chordsList) do chordsList[k]=nil end | |
table.insert(chordsList, aNote) | |
end | |
capturedNotes = music.note_nums_to_names(chordsList) | |
print(#chordsList .. '-size buffer of notes ' ) | |
for k, v in pairs(capturedNotes) do | |
print(v) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment