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
You need to set up variables to track when note 125 is down and note 127 is down. Down meaning a note on has been received but not a note off.
Pseudo code (which I recommend using before coding):
Create a notesDown array. Fill the first 128 slots with zero
When a midi note on comes in, set notesDown[notenumber] to 1
When a note off comes in set notesDown[notenumber] to 0
When a midi note on for note 125 or 127 comes in, check to see if both 125 and 127 are currently down. If so, do ….
Very Thanks spiegel ,
But why ( and ) in this case doesn’t work , In case, I have used and in many cases and it has worked.
And were the things you described about case number 1 or 2 ?
@pejman: case #2 you can use the same mechanism I described. The difference is just that you check when note 127 come in if notesDown[125] is 1
@pejman
First of all - Mozaic handles every event sequentially, one by one in the order they arrive. So OnMidiNoteOn will never be called with several notes (chords) at the same time. The notes on events will arrive one note at a time and therefor to manage chords or simultanes note presses, one has to store this informatikn. And also to remove the ‚note is pressed‘ status in the OnMidiNoteOff event function.
A variable will at any time only contain a single value - the same applies for Mozaics state functions like MIDINote, MIDICommand, LastKnob, LastPad etc.
Therefor in
the combined if condition can never be true. If „midinote 127 on“ event is processed, the second condition =125 is not tue. And when processing the „midi note 125 on“ event, the first part =127 condition is not met.
BTW: I suspect that you still don‘t use the correct backticks when posting code snippets. To add a code block, select the paragraph popup above your post and the select ‚codek - do this three times and you‘ll get six of the backticks. Now press enter two times after the third backtick and paste your script code right between the two groups of three backticks. This will also keep the indentation of the code which helps readability
@pejman : thanks to ki’s response I see your confusion. MIDI Note is just the most recently received note. You need to use variables to keep track of what notes are down besides the one that just came in.
The reason I suggested using an array to track notes is so that you can check whether any particular note is down (meaning a note on for that has come in but not a note off). You could just use two variables (let’s say note125state and note127state) but using an array is more easily adaptable and generalizable.
Thanks @ki and Thanks @espiegel for your valuable advice.
Based on @ki's tips and @espiegel's answer after that, do I need both @OnmidinoteOn and @OnMidinoteOff events Or not ?
Yes. You need both.
As I said earlier you can do something like the following:
Create a notesDown array. Fill the first 128 slots (0-127) with zero
When a midi note on comes in, set notesDown[notenumber] to 1
When a note off comes in set notesDown[notenumber] to 0
The notesDown array is something you can use to see if any particular note is down at the moment.
There are other ways of doing it, too.
thanks @espiegel for repetition and transparency of cases. 🙏
And thanks again to @ki for the attention.🙏
@pejman , If you mean something that you yourself have already written, then I tried to write like you and this was my best effort that I could do.
That's all I get ( narrative/description ) from onknobchange regarding knob 0.
When knob 0 value is detected
1, check if the padusedflag is 0 don’t do anything.
2, If Lastknob = 0
Noten = ( ROUNDED ) Value knob 0
Number of note of lastpad = noten
That is, the ROUNDED values of knob 0 should be put in noten and the same noten should be put in notenum in the last touched pad
3, If lastknob = 0
Sendmidinote on and off via ROUNDED value of knob 0.
Label knob and lastpad show number of note that is playing.
Turn noteknob , noteknob round the value.
The rounded value will be converted to note and play notes .
with turning knob creat different notes and play them with specific velocity .
and the last note created ( last the rounded value ) , save to lastpad and label noteknob and label lastpad .
Now, look at your description and recall that we said that when knobchange is called notenum[lastpad] has the value of the last note sent.
What do we have to do (in words not in Mozaic scripting) once we have the rounded noteknob value to avoid sending a duplicate note? And where would we do it?
I could not find the solution based on my knowledge of the subject that I wrote to you above,
I already knew about the issue and I've been looking for a solution for a few days now and still haven't found a solution.
Don’t think in programming terms. Describe to someone who doesn’t know programming what should happen.
You turn the knob and get the note number.
You know the last note that was sent.
What would you do to avoid sending the same note again?
I really do not know, while I am very eager to know.
Perhaps we should prevent the sound of repeated notes from playing.
Let’s say the new note is called newNote and the last note played is called last note.
How do you decide whether or not to ignore the new note?
When a newnote is played, the lastnote doesn’t play again .
@pejman : I am not sure if I am understanding what you mean. Here would be my description of what should happen
When the note knob is turned:
Ok , i have problem with this section :
compare the new note number (the knob’s rounded value) to the last note sent ( which is notenumber[lastPad].
If noten = nn or if nn = noten or noten = notenumber[lastPad]
I have written each of these ifs, but it didn't work.
You probably had things in the wrong place.
Here is my suggestion. Take the version of your script that we agreed works.
Put in a comment where you think the test goes.
This is the patch that works
I am going to put this code line ( if noten = notenum[LastPad] ) in a place where unfortunately I will have problems every time I put it.
For example :
elseif LastKnob = 0
if noten = notenum[LastPad]
padUsedFlag = 0
else
noten = Round GetKnobValue 0
notenum[LastPad] = noten
SendMIDINoteOn 0, noten, 127
SendMIDINoteOff 0, noten, 0, 100
LabelKnob 0, {note #}, noten
LabelPad LastPad, noten
Or
elseif LastKnob = 0
noten = Round GetKnobValue 0
notenum[LastPad] = noten
if noten <> notenum[LastPad]
SendMIDINoteOn 0, noten, 127
SendMIDINoteOff 0, noten, 0, 100
LabelKnob 0, {note #}, noten
LabelPad LastPad, noten
@pejman : I suggested that instead of adding code, you just add a comment where the test should go (without putting in the test). So we could separate where to put the test and how to do it.
I would like you to go through each of your examples line by line and tell yourself out loud what happens in each line to see if you can spot why they don’t work before reading on.
version 1 doesn’t work because you do your test before you have actually gotten the new knob value. Version 2 doesn’t work because you change the notenum array without first checking if you should. You always end up changing notenum. So notenum and noten are the same when you test.
Also, why in version 1 did you add
padUsedFlag = 0?
@espiegel said : Also, why in version 1 did you add
padUsedFlag = 0?
Yes i put it now for test .
To test what?
For avoiding play of repeat notes
I am not sure how assigning padUsedFlag would help with that. Can you explain what information you hoped to get by setting it to 0?
There might be another way to get the information without adding a confusing use of an existing variable. Maybe logging?
You're right, it's stupid, I remember once I used sendmidinoteoff instead of padusedflag = 0 , maybe it would have been better to send it as an example, anyway, I tried many methods and these two examples were two of them.
elseif LastKnob = 0
if noten = notenum[LastPad]
SendMIDINoteOff 0, noten, 0
else
noten = Round GetKnobValue 0
notenum[LastPad] = noten
SendMIDINoteOn 0, noten, 127
SendMIDINoteOff 0, noten, 0, 100
LabelKnob 0, {note #}, noten
LabelPad LastPad, noten
Ok , It is confusing for me where and with what command should I create the log
@pejman : there is a log command in Mozaic that sends information to the log area. We have discussed this before.
Can you explain precisely what information you were hoping to gain?
I am not judging. I am trying to understand what specific information you were trying to get from your test in order to help you figure out a good method for getting that information.
I didn't remember at all, I used log before in this script, but I couldn't get help from it
The numbers that the log shows me are correct but repeated numbers
Log noten = 56 56 56 57 57 57 ….
@pejman : please go back to the two examples you posted and say out loud to yourself what happens in each line of code.
And see if you can spot on your own logically why neither one works.
Then read the explanation I provided about why they don’t work.
I guess after that we need to discuss how to use logging and how to test productively.
My question is why when we round knob number 0, even though it is round, it still emits decimal numbers to generate repeated notes through decimal numbers, and then We put it in noten. ?