Hi all,
I’m trying to make a micro tuner in gig performer to change each note’s pitch in cents individually. I have zero knowledge of coding but tried this app online and this is what it came up with:
– Define a global table to hold the pitch offset values for each note.
global pitch_offsets = {}
– Import the math library.
require(“math”)
– This function is called when the scriptlet is loaded.
function on_load()
– Set the initial pitch offset value for each note.
for i = 0, 127 do
pitch_offsets[i] = 100
end
end
– This function is called when MIDI data is received by the scriptlet.
function on_midi(data)
– Get the MIDI event type from the data.
local event_type = data[1] & 0xf0
– Check if the event is a note on or note off event.
if event_type == 0x90 or event_type == 0x80 then
– Get the note number from the data.
local note_number = data[2]
-- Get the pitch offset value for the note.
local pitch_offset = pitch_offsets[note_number]
-- Get the current pitch bend value from the data.
local pitch_bend = data[3] * 128 + data[2]
-- Calculate the new pitch bend value.
pitch_bend = pitch_bend + pitch_offset
-- Ensure that the pitch bend value does not exceed the maximum allowed value.
if pitch_bend > 16383 then
pitch_bend = pitch_bend - 16384
end
-- Set the new pitch bend value in the MIDI data.
data[3] = math.floor(pitch_bend / 128)
data[2] = pitch_bend % 128
-- Return the modified MIDI data.
return data
end
end
It gives me syntax errors all the time and it won’t compile. let me know what is wrong here guys all help is appreciated.