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 StoreLoopy Pro is your all-in-one musical toolkit. Try it for free today.
Comments
I think you need to describe more precisely what you want the script to do. Do you want it to track all notes currently held down (my interpretation) or notes played together as a block chord (what ki and McD are addressing.. though McD's script doesn't quite do that as I mentioned )
@pejman - people are stumbling around somewhat because it isn’t really clear what you’re trying to do. First you say you need to detect chords, but then you say you only need to count the number of notes held down to get their average velocity. You don’t say when or for what you would use that velocity.
Advice will be haphazard until you define the requirement better.
[edit] cross posted while @espiegel123 was saying about the same thing.
@espiegel123
I just need to get the count of the number of notes held down.
Because sometimes I add or reduce some of the notes of the chord I play , instead of lifting my hand completely from the keyboard and then putting it down again.
So the number of notes taken by my fingers can increase or decrease at the same moment.
As I said before, I need this code to average the velocity notes taken ( held down )
So I need the number of notes held down.
That’s what I thought, but the conversation got confused as soon as you mentioned chords.
So … you don’t need timers at all.
Counting the number of notes held down is simple. Create a variable to hold the number of notes. Initialize it to zero in the
@OnLoadevent. In the@OnMidiNoteOnevent add 1 to the variable. In the@OnMidiNoteOffevent subtract one from it.Averaging the velocity is trickier because you only get the velocity you’re looking for in the Note On event. So, you have to store that, then retrieve it when the note off occurs.
@OnLoadevent.OnLoadevent.ResetNoteStates 0.In the
@OnMidiNoteOnevent:SetNoteState MIDIChannel, MIDINote, MIDIVelocityIn the
@OnMidiNoteOffevent:x = GetNoteState MIDIChannel, MIDINote, MIDIVelocitySetNoteState MIDIChannel, MIDINote 0I’m not sure what you plan to do with this average velocity. You can’t use it to change the playing note velocity. That only happens once when the note On velocity is received.
@wim
You wrote; I’m not sure what you plan to do with this average velocity. You can’t use it to change the playing note velocity. That only happens once when the note On velocity is received.
I want use average velocity to changing notes length that goes from an arpeggiator to the mozaic and from the mozaic to the desired app.
@wim
Thanks wim for help and explanation.
Sorry, I thought the previous post was posted by @espiegel123
@wim
Your right , but believe me, I didn't know that the issue could be so sensitive and complicated, because I actually play chords, I thought I should talk about it in chord format.
But if you look at my second post to @McD and @espiegel that started this topic, you'll see that I explained perfectly what the problem was and exactly what I wanted.
https://forum.audiob.us/discussion/comment/1287596/#Comment_1287596
Anyway, I apologize if the question was not clear.
@pejman Are you interested in code that solves a problem you might be working on?
For the note carry over between chords you need a @OnNoteOff block that decrements “count” so that next chord would start from 1 and not zero. The added complexity is that the array would save the first note. So extra code to remove the correct note would need to be in that NoteOff event block and insure that correct note is saved for the following chord.
Let’s assume you have recognized a complete chord and have the notes saved with a count. What’s next?
Ideally someone else is learning something about how Mozaic “knows” something… the only thing it knows are events. All the memory and Logic are our responsibility.
@pejman : are you going to need to keep track of which notes are down or just the average velocity?
If you need to keep track of which notes are down, it is an interesting puzzle to solve. It is a straightforward problem to solve but maybe not obvious.
The tricky part is removing the notes when a note off comes in.
To add average velocity just add a variable to sum incoming velocities (MIDIByte3) and divide by count.
@espiegel123
@McD
Sorry for late . I don't know why recently I'm not getting notifications when someone sends a message.
@espiegel123 wrote: are you going to need to keep track of which notes are down or just the average velocity?
🔺Just average velocity .
@espiegel123 wrote : If you need to keep track of which notes are down, it is an interesting puzzle to solve. It is a straightforward problem to solve but maybe not obvious.
The tricky part is removing the notes when a note off comes in.
🔺 I am interested in solving this puzzle because I know it will help me somewhere.
@McD , Thank you for the explanations you gave in your previous two posts.
I have to think about The explanations you gave.
@McD wrote : To add average velocity just add a variable to sum incoming velocities (MIDIByte3) and divide by count.
Yes, I know the averaging formula, the only problem I have with the case you just mentioned is that :
1, With which mozaic mathematical function should be obtained the set of velocities of notes held down
2, How to get the number of generated velocities, Do we still need to get the number of down notes with this method?
@pejman: i would approach the note tracking in two steps.
Step 1:
Set up your script so that it adds played notes to an array and updates a counter for each added note.
Write a routine also that logs the number of notes in the array and the notes it holds.
After each note is added, call the note logging handler you created.
Step 2:
Once step 1 is working, and a note off handler that removes the note from the array created in step 1. There are a few ways to solve this problem. I'll let you try to puzzle that through.
@espiegel123
Ok i will try .
But before I try to do that, I would be very interested if you could answer the question I asked earlier.
1, With which mozaic mathematical function should be obtained the set of velocities of notes held down ?
I think I covered that in my earlier post.
https://forum.audiob.us/discussion/comment/1287849/#Comment_1287849
(You can't "obtain" the set of velocities held down. You have to capture and store them as the note-on event comes in, then reset that storage to zero when the note-off comes in.)
For your learning benefit, I'd prefer not to provide an actual code example. Also, @espiegel123 's approach and mine are slightly different, so I don't want to get further in the middle of the discussion and confuse things.
The Velocity of each NoteOn event comes in as MidiByte3. So. adding all the MidiByte3’s with a chord and dividing by the
chord “count” is a solution:
@McD : it was determined earlier in the thread that onTimer isn’t needed for this use-case. He is tracking the currently held-down notes not just the notes that are played within a particular time interval.
Wim provided excellent instructions a few messages up about how to track the average velocity of the currently held keys.
At some point, I would be curious about your and anyone else’s methods for tracking the held down keys. My method works but I feel like there are probably better methods.
https://patchstorage.com/sustainuto/ is a recent simple example of one way I’ve done note tracking. Sorry, there aren’t any comments, but the code is broken down into understandable discrete events.
Cool. That is one of the two methods I've used. It is more elegant than the one I've tended to use.
@McD
Thanks @McD for answer my question about ( How to get the sum of the values obtained from a variable in the mozaic )
velocity_total = velocity_total + MidiByte3
That’s great 👌🙏.
Don’t forget to compute the average when you need it:
Velocity_Average = round (velocity_total / count)
It's also important to decrement velocity_total when notes are released. However this is tricky because you don't get the velocity with the note-off.
velocity_total = velocity_total - MidiByte3will not work when the note is released. 😬
For this reason, you also have to store the MidiByte3 value when the note-on comes in. Then you have to look it up and subtract it when the note-off comes in. NoteStates is the perfect place to store this. So in the Note-on event you need something like:
Then when the note-off comes in you have to do something like:
Note 1: Note-Off may come with a "velocity" value in
MidiByte3. However, this is not the same thing as the Note-On velocity. Not many synths make use of this "release velocity", but it is a part of the midi spec. The important thing is it has no relation to the note's velocity.Note 2:
MidiVelocitycan be substituted forMidiByte3in the@OnMidiNoteOnevent. They're the same thing.MidiVelocitymight be clearer to understand in the code.@McD
Yes, Sure
Thank you very much for reminder.
@wim
😍 GREAT, GREAT,GREAT
The big problem for me was the midi note-off, which you explained and helped me very well.
Thanks for the explanations in Note 1 and Note 2 🙏.
Thank you for all your continuous help @espiegel123 @ki @wim @McD ❤️
I am glad to learn this very valuable content, Because I plan to make a patch so that the user can control the desired parameters through Velocity Average, and can translate ( calibration ) them to the desired amount.
Has such a patch ever been made in patch storage?
I haven't found anything like that yet.
I think your idea will be unique. Go for it.
Hi .

Why are there sending extra values in Square type lfo in mozaic ?
Can you post some code? In particular it would be helpful to see your
SetLFOType,SetupLFO, andGetLFOValuecommands in context. If this is a part of a large program, then it might be worth the time to write a simple program that does nothing else but log the values.All that said ... I think I remember running into this in a program earlier. I don't remember what was up, but I concluded that reading from a square LFO wasn't going to work for what I was doing.
@pejman - I did a quick test and the square LFO is working as expected. I did manage to get a wrong reading or two on the first cycle or two, but nothing that would explain your results.
LFO's are rarely perfectly square. If you have a slow LFO and high sampling rate you will be likely to get a few off values on the edges if you sample right in the middle of the down or up cycle.
Here's some test code I used to play with various values for
SetTimerIntervaland LFO speed.@wim
The image you see in the screenshot is related to the performance of LFOs patch by orchid.
I have this problem in the codes that I wrote myself, but unfortunately, because the codes that I wrote are not readable for you, I refuse to send them.
I don’t understand what you mean by that, but OK. 🤷🏻♂️
Hopefully someone else can help you.