A little help with this scriptlet (micro tuner idea)

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.

– 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

– 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

-- 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


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.

The syntax is just vaguely gpscript. Maybe you used chatgpt? That is not fully educated yet. Here some links with more information on scripting. These should get you on track with scripting.




I think I got your idea. Could you please post a small gig file here, sow we can have a look at your real code?

The above looks a little bit like both pseudo code and GP script :thinking: Therefore I would also expect some Syntax Errors :wink:

Some thoughts about your idea

  • this will work most probably only on monophonic sounds, as pitchbend typically adresses the global tuning of an instrument
  • you don’t need to determine Note On or Off in your script. GP provides dedicated callbacks for NoteOn/Note off event


@farabee Welcome, btw :grinning:

This is bizarre….it looks like a mishmash of JavaScript, Pascal and PHP

Was this really produced by ChatGPT?

I tried (shallow) to have chatgpt write an example script, but it seemed confused. Maybe I asked the wrong question

Thanks guys for the feedback, and yes you guessed it right. It is a chatgpt answer to questions for the AI and it kinda teaches me where to start to tackle this idea in my head.

It appears that its not accurate but it’s a starting point.

yeah it is chatgpt

thanks for your reply

1 Like