Jump to content

Chat GPT (open AI) code for Logic's MIDI FX Scripter doesn't work


anp27

Recommended Posts

ChatGPT is kind of amazing, but it has a fundamental problem, which is that it's "confidently wrong" a lot of the time. There's lots of articles on this if you google, but here's an example:

https://mashable.com/article/chatgpt-amazing-wrong

If you ask it a question, it will tell you the answer, but there is no guarantee it's the *correct* answer. It turns out it's an *excellent* BS-er...

Same with code - you can't expect ChatGPT generated code to be correct/working/good, even if it *looks* good.

However, it can be a useful head start, and if you know what you are doing, you can probably see, and fix it's mistakes, and still find it worthwhile to use.

Just don't expect it to be right

Edited by des99
  • Like 1
Link to comment
Share on other sites

54 minutes ago, des99 said:

However, it can be a useful head start, and if you know what you are doing, you can probably see, and fix it's mistakes, and still find it worthwhile to use.

Yes, that's the problem, I don't 100% know what I'm doing 😀  I'm not from the coding world... I do however have enough understanding where I can edit the script, I just need to know how to fix the mistakes.

Link to comment
Share on other sites

6 hours ago, des99 said:

If you ask it a question, it will tell you the answer, but there is no guarantee it's the *correct* answer. It turns out it's an *excellent* BS-er...

In other words, AI has already gone all the way in emulating the human mind. That is uncomfortably close...

Edited by fuzzfilth
  • Like 2
  • Haha 2
Link to comment
Share on other sites

21 hours ago, des99 said:

If you ask it a question, it will tell you the answer, but there is no guarantee it's the *correct* answer. It turns out it's an *excellent* BS-er...

In that other thread about the "Hit Formula" I had linked to a video where ChatGPT basically failed when quizzed about harmonic progressions in jazz. What struck me as hilarious was the (perceived) confidence contained in the answer. Having worked in education for a long time I'm quite familiar with this strategy.

  • Like 2
  • Haha 1
Link to comment
Share on other sites

On 1/31/2023 at 7:37 AM, gacki said:

Could you share some of those attempts?

On 1/31/2023 at 1:45 PM, Jordi Torres said:

If we don't see your code we cannot help. Would also help if you said what is it you're trying to achieve.

J.

Ok, here's one example. I asked "generate code that adds MIDI CC 7 = 0 when MIDI note = note off"

This is the code it generated:

function addCC7onNoteOff(midiEvents) {

    for (let i = 0; i < midiEvents.length; i++) {

        if (midiEvents.type === "noteOff") {

            midiEvents.splice(i+1, 0, {

                type: "controlChange",

                controllerNumber: 7,

                value: 0,

                timestamp: midiEvents.timestamp

            });

        }

    }

    return midiEvents;

}

I did this as a test because I already have a Scripter that does it for me (add volume = 0 at notes off) and I wanted to compare the two. Since I'm a noob with this stuff I wasn't able to come up with anything. 

Link to comment
Share on other sites

This is the problem with these tools - "confidently wrong".

It gives you code that *looks* plausible, especially to non-coders, and goes "there you are", but the code is likely entirely useless, leaving the end user going to forums saying "Can you debug this ChatGPT code?" - when it would probably just be easier to bypass the AI step, and ask the experts on the forum directly, and get something that *does* work.... 😄

It's been a minute since I've done any Scripter-ing in Logic, but (from memory) that code is not even how you do event processing in Logic's Scripter (which is not looping through an array of data to be processed, but on an event by event process).

Like I say, the tools are interesting, but are a long-way from being dependable at this point. Let's see how they evolve.

Edited by des99
  • Like 1
Link to comment
Share on other sites

Also I feel like asking it to “generate code” is like asking it to “generate language”.

like, which one of the 7,139 currently spoken in the world?

Maybe help it out by specifying Javascript lol.

Edit: Wait, actually don’t help it out! We gotta prolong the AI Apocalypse as long as possible!

Edited by RobertAnthony
Link to comment
Share on other sites

1 hour ago, gacki said:

Did you specify the "operational surroundings" for this? In other words: It has to operate on "live" data, not on a MIDI file?

Nope, this is the question I asked it verbatim: "generate code that adds MIDI CC 7 = 0 when MIDI note = note off"

Link to comment
Share on other sites

15 minutes ago, anp27 said:

Nope, this is the question I asked it verbatim: "generate code that adds MIDI CC 7 = 0 when MIDI note = note off"

That's probably not specific enough to get the results you expected; ChatGPT can't "know" that this has to be realtime. As @des99 pointed out the function works on an array of MIDI commands and inserts data into this array. This would/could make sense when dealing with a MIDI file or "MIDI data" in general but not with "live" data.

So the code actually is probably fine but it is generated under a certain (wrong) assumption. I wouldn't blame ChatGPT for this.

Edited by gacki
Link to comment
Share on other sites

26 minutes ago, gacki said:

That's probably not specific enough to get the results you expected; ChatGPT can't "know" that this has to be realtime. As @des99 pointed out the function works on an array of MIDI commands and inserts data into this array. This would/could make sense when dealing with a MIDI file or "MIDI data" in general but not with "live" data.

So the code actually is probably fine but it is generated under a certain (wrong) assumption. I wouldn't blame ChatGPT for this.

Right, so how do I tell ChatGPT that it's supposed to deal with live data?

Link to comment
Share on other sites

19 minutes ago, anp27 said:

Right, so how do I tell ChatGPT that it's supposed to deal with live data?

And here we come onto the finessing of the commands you feed these things - you might want to add some "using Scripter for Logic Pro" type qualifiers. Remember, the tool is drawing on it's knowledge base, and the corpus of Javascript is much larger than the specific implementation of JS for Scripter in Logic. Unless you tell it what you want, it has to guess.

Once you start adding qualifiers, it helps it with refining it's answer from similar code it already knows about. You may require a bunch of juggling with the command to get something that works well enough unguided, or it may generate something good enough as a starting point to modify and fix.

Let us know how you get on!

Edited by des99
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hey 🙂

Been trying for a few hours making a Scripter script that does real time humanising, like shiftting incoming midi notes a notch early or late.

I get code that Scripter accepts, but it doesn't do anything.

I think I am going to make my own thread about it, but I am "happy" to see that I am not the only one having issues getting it working. Well, not really, I would prefer it was working, but I see there might be other reasons than, errrrhhhmm... Me... That the script is not working.

Anyway, I'll post the script here for context, but also create a new thread, since it's a different script.

Here it is:
 

 

var PluginParameters = [
  {
    name: "Humanize Amount",
    type: "lin",
    minValue: 0,
    maxValue: 100,
    numberOfSteps: 100,
    defaultValue: 50
  },
];


function HandleMIDI(event) {
  if (event instanceof NoteOn || event instanceof NoteOff) {
    var humanizeAmount = GetParameter("Humanize Amount") / 100.0;
    var randomTiming = Math.random() * humanizeAmount * 2 - humanizeAmount;
    event.delta += randomTiming;
    Trace(randomTiming); // See the timing offset
  }
  event.send();
}

function ParameterChanged(param, value) {
  if (param == 0) {
    humanizeAmount = GetParameter(param) / 100.0;
    // humanizeAmount = value / 100;
    Trace(value); // See value in console
  }
}


 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...