Loopy Pro: Create music, your way.

What is Loopy Pro?Loopy Pro is a powerful, flexible, and intuitive live looper, sampler, clip launcher and DAW for iPhone and iPad. At its core, it allows you to record and layer sounds in real-time to create complex musical arrangements. But it doesn’t stop there—Loopy Pro offers advanced tools to customize your workflow, build dynamic performance setups, and create a seamless connection between instruments, effects, and external gear.

Use it for live looping, sequencing, arranging, mixing, and much more. Whether you're a live performer, a producer, or just experimenting with sound, Loopy Pro helps you take control of your creative process.

Download on the App Store

Loopy Pro is your all-in-one musical toolkit. Try it for free today.

Custom GPT for Streambyter programming

heshes
edited December 2023 in General App Discussion

Trying same custom GPT thing now with Streambyter as with Mozaic. "Training" so far has been just uploading the Streambyter manual page to the config resources.

I'm testing it out on an actual Streambyter question I found on the forum. Here's the question:

@cokomairena said:
Hey

How one would do to set some midi note boundaries so if a note is higher than that limit, then transpose an octave down.

If it’s lower than the lower limit, transpose one up…

Should be easy right.
originally posted at: https://forum.audiob.us/discussion/52951/streambyter-midi-range

I directed the Streambyter GPT to write a script doing this, given C2 and C5 as upper and lower limits. I also directed Streambyter to use aliases and write the Streambyter function to maximize readability by humans. Haven't tested it, but result is below and looks promising.

Streambyter GPT has advantage over Mozaic in that Streambyter itself is free on iOS (and is presumably somewhat lighter-weight than Mozaic, but that's not huge deal).

The chat where I got the code below is here:
https://chat.openai.com/share/f8246fd0-414d-4727-a9cd-75f2cbba7f88

# StreamByter Script for Transposing MIDI Notes

# Initialize and define aliases
IF LOAD
  # Define the note value limits
  # C5 in MIDI is 72 (hex 48), C2 in MIDI is 36 (hex 24)
  ALIAS ^C5 UPPER_LIMIT
  ALIAS ^C2 LOWER_LIMIT

  # Define octave transposition value
  ALIAS $12 OCTAVE
END

# Transpose notes above C5 down and below C2 up an octave
# for both Note On and Note Off messages
IF M0 >= 80 AND M0 <= 9F # Note On and Note Off messages for all channels
  IF M1 >= UPPER_LIMIT  # Check if the note is above C5
    MAT M1 = M1 - OCTAVE # Subtract 12 from the note value
  ELSIF M1 <= LOWER_LIMIT  # Check if the note is below C2
    MAT M1 = M1 + OCTAVE # Add 12 to the note value
  END
END

# Note: This script handles both Note On and Note Off messages.

Comments

  • Still a little learning to do... StreamByter does not allow a logical expression on the IF (or anywhere else). Its syntax is extremely minimal, macro assembler level.

    I expect you'll also have trouble with its weird array indexing:

    Ass I0 = 2
    Ass MI0 = 0
    

    for example.

  • @uncledave said:
    Still a little learning to do... StreamByter does not allow a logical expression on the IF (or anywhere else). Its syntax is extremely minimal, macro assembler level.

    Ah, thanks. Easy enough to remedy this, just make sure it knows about the limitation. Not sure about the array indexing, but I assume it will also be simple fix. GPT doesn't know anything about 'weird'; I'll just make sure it knows the rules if it hasn't absorbed them yet. . . .

    # StreamByter Script for Transposing MIDI Notes
    
    # Initialize and define aliases
    IF LOAD
      # Define the note value limits
      # C5 in MIDI is 72 (hex 48), C2 in MIDI is 36 (hex 24)
      ALIAS ^C5 UPPER_LIMIT
      ALIAS ^C2 LOWER_LIMIT
    
      # Define octave transposition value
      ALIAS $12 OCTAVE
    END
    
    # Handle both Note On and Note Off messages
    # Check if the message is a Note On or Note Off message
    IF M0 >= 80 # Check for Note Off and Note On message status bytes
      IF M0 <= 9F # Further check for Note Off and Note On message status bytes
        # Transpose notes above C5 down an octave
        IF M1 >= UPPER_LIMIT  # Check if the note is above C5
          MAT M1 = M1 - OCTAVE # Subtract 12 from the note value
        END
    
        # Transpose notes below C2 up an octave
        IF M1 <= LOWER_LIMIT  # Check if the note is below C2
          MAT M1 = M1 + OCTAVE # Add 12 to the note value
        END
      END
    END
    
    # Note: This script handles both Note On and Note Off messages.
    
    
  • You don't actually need to check for M0 >= 80, because it always is. Every MIDI message starts with a command byte with the high bit set, followed by data values <80. It doesn't hurt, but the test is completely redundant.

    Also, your comments suggest that you expect C4 to be middle C, note 60, but StreamByter follows the alternate convention, making C3 middle C, note 0x3C. So your aliases do not do what the comments describe.

  • heshes
    edited December 2023

    @uncledave said:
    You don't actually need to check for M0 >= 80, because it always is. Every MIDI message starts with a command byte with the high bit set, followed by data values <80. It doesn't hurt, but the test is completely redundant.

    Yes, for the moment I'll let GPT do as it wants, with this. Understanding how to consolidate checks into a single test (e.g., your < A0 in your solution) seems to require deeper understanding than just coding with some unnecessary checks. Also, unnecessarily explicit checking may be more understandable for non-programmers who are trying to use this. Baby steps; I expect it's possible to get GPT to do it either way, as directed, eventually.

    Also, your comments suggest that you expect C4 to be middle C, note 60, but StreamByter follows the alternate convention, making C3 middle C, note 0x3C. So your aliases do not do what the comments describe.

    Thanks! Not my comments, though; they're GPT's. Interesting that it didn't pick this up from the manual. To train I'm not sure what I do, maybe write out list of "PLEASE NOTE:" items to upload that remind it of things it's either not noticing or is misunderstanding from the Streambyter manual.

  • Wow, really cool!

  • Another useful project! Streambyter is free so many more will benefit from a way to create MIDI scripts.
    I just hope the documentation is sufficient to train your model to do the hard things. Hopefully, there are a lot
    of machine level concepts already in the DNA of ChatGPT to assist with the Hexidecimal encoding of most MIDI details.
    I think Nick added decimal equivalents near the end of his efforts to popularize the app. He also added some extra
    User Interface features that I hope come through as well.

  • wimwim
    edited December 2023

    @uncledave said:
    Still a little learning to do... StreamByter does not allow a logical expression on the IF (or anywhere else). Its syntax is extremely minimal, macro assembler level.

    I expect you'll also have trouble with its weird array indexing:

    Ass I0 = 2
    Ass MI0 = 0
    

    for example.

    Or how about

    Ass I14 = 7F 02 414 4A
    
  • @wim said:

    @uncledave said:
    Still a little learning to do... StreamByter does not allow a logical expression on the IF (or anywhere else). Its syntax is extremely minimal, macro assembler level.

    I expect you'll also have trouble with its weird array indexing:

    Ass I0 = 2
    Ass MI0 = 0
    

    for example.

    Or how about

    Ass I14 = 7F 02 14 4A
    

    "Ass" probably triggered GPT's Political Correctness filter and its virtual synapses went up in puffs of smoke 😉

  • @wim said:

    @uncledave said:
    Still a little learning to do... StreamByter does not allow a logical expression on the IF (or anywhere else). Its syntax is extremely minimal, macro assembler level.

    I expect you'll also have trouble with its weird array indexing:

    Ass I0 = 2
    Ass MI0 = 0
    

    for example.

    Or how about

    Ass I14 = 7F 02 414 4A
    

    Yeah. But, to be fair, they're clearly explained in the manual, if you carefully parse every line. There's a lot of detail in a very few sentences.

  • @hes . I hope you stripped out the early part of the StreamByter manual, describing the original StreamByter replacement rules, like BX = B0. They're not needed with the scripting language, and the syntax is really strange, "replace this with that".

  • @hes said:

    Also, your comments suggest that you expect C4 to be middle C, note 60, but StreamByter follows the alternate convention, making C3 middle C, note 0x3C. So your aliases do not do what the comments describe.

    Thanks! Not my comments, though; they're GPT's. Interesting that it didn't pick this up from the manual. To train I'm not sure what I do, maybe write out list of "PLEASE NOTE:" items to upload that remind it of things it's either not noticing or is misunderstanding from the Streambyter manual.

    But, what prompt did you give GPT? If you said "Transpose notes outside C2 to C5", then the program did what you said, though it might have not been what you intended, given the C3 vs C4 confusion.

    I was a bit surprised that it transposed C2 and C5 as well (>= and <=), though the comments say "above" and "below". Also, I would have used a while loop to bring all notes into the range, not just raising/lowering them by one octave. Maybe that's all you asked it to do.

  • heshes
    edited December 2023

    @uncledave said:
    But, what prompt did you give GPT? If you said "Transpose notes outside C2 to C5", then the program did what you said, though it might have not been what you intended, given the C3 vs C4 confusion.

    You can see my entire interaction in the link. What I initially asked was "For this script, let's set C5 as upper range and C2 as lower range. Any notes above or below those limits should be lowered or raised by an octave." I thought this was clear, but upon second look it's slightly ambiguous. I intended to set C5 as upper end of a C2 to C5 range, with both C2 and C5 in the range. What GPT seems to have done is set two ranges, an upper range of '>=C5' and transposed notes in that range down, and set a lower range of '<=C2' and transposed notes in that range up. At least that seems like a possible ambiguity in my instructions. (In strict terms, in that case the middle range of C2 to C5 would not include C2 to C5, but would have C2 and C5 as its "limits". Maybe I'm thinking GPT is smarter than it is, maybe not. :smile: )

    I was a bit surprised that it transposed C2 and C5 as well (>= and <=), though the comments say "above" and "below". Also, I would have used a while loop to bring all notes into the range, not just raising/lowering them by one octave. Maybe that's all you asked it to do.

    It should have been clear to me that GPT was not doing what I wanted from its first suggested code. Notice the contradiction in its comments:

    # Transpose notes above C5 down an octave
    # MIDI note C5 and above are decremented by 12 (an octave)
    IF LOAD
      ALIAS $12 OCTAVE_DOWN
    END
    

    In short, GPT is pretty good, but of course it makes mistakes. In some cases (like this one) the errors can be quite similar to the typical mistakes a human might make.

    Separate point, but for training or using GPT to work with an unusual language like Streambyter, I think you have to understand that GPT comes with a large background knowledge of how programming languages work. You need to clarify how Streambyter differs from the normal, and (probably) add specific emphasis to certain points. You can't just give it a rule and expect it to be followed 100% of the time. Maybe you can get close if you emphasize to GPT that you want the rule followed 100% of the time. But what if that conflicts with another rule that it's been told to follow 100% of the time? Like humans, GPT has large storehouse of knowledge, and none of it is actually assigned a 100% certainty. There are items in our knowledge that conflict, we believe contradictory things, continually adjust our degrees of confidence, and we have to decide based on the situation exactly what we acknowledge as true in a given situation. GPT does something similar.

Sign In or Register to comment.