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.

MOZAIC Help Line

1121314151618»

Comments

  • wimwim
    edited December 2024

    @OscarSouth said:
    A quick one for now -- what'd be a quick/efficient way to get the first index in an array holding a -1 value?

    What I'm really trying to do here is basically to get the 'length' of an array where -1 is representing an empty value. Preferably as a one liner rather than a loop if possible.

    You can't do that without a loop. A while loop, being careful to also limit the iterations to the length of the array in case no empty spot is found, is the most efficient.

    What I'll usually do if I can is to find a way to track where the empty index should be in another variable as I go.

  • wimwim
    edited December 2024

    here's an example @OscarSouth :

    @OnLoad
      FillArray haystack,1
      needle = Random 0,1023
      log {1: haystack[}, needle, {] = -1}
      haystack[needle] = -1
    
      index = 0
      while haystack[index] <> -1 and index < 1024
        if haystack[index] <> -1
          Inc index
        endif
      endwhile
    
      if index = 1024
        log {2: Not found!}
      else
        log {2: Found needle at hastack[},index,{]}
      endif
    @End
    

    [edit] I get an error in the final if - else if I don't set anything to -1. I had assumed the else clause wouldn't be evaluated, but it seems it is so I get an invalid index error. So, the example needs to be enhanced a little to handle the not found situation better.

  • @OscarSouth said:
    A quick one for now -- what'd be a quick/efficient way to get the first index in an array holding a -1 value?

    What I'm really trying to do here is basically to get the 'length' of an array where -1 is representing an empty value. Preferably as a one liner rather than a loop if possible.

    What I do for that use case, is to use the first byte of the array as the array length—and increment or decrement it as cells are added or subtracted.

  • @pejman said:

    @pejman said:
    @wim

    @wim said:
    @pejman - If you have two things that are supposed to happen virtually simultaneously, but you can't be sure which will happen first, then you need to check if the first has happened yet.

    I haven't been following the conversation closely so this may not be the proper solution, but here's what I was thinking in generalized pseudo code.

    in onLoad
    // set both variables to something impossible
    speedCC = -1
    modeCC = -1
    
    in OnMidiCC
    // set speedCC or modeCC to the incoming value based on which arrived
    // check if both are not -1
    // if they are both <> -1 then 
      do something
      and then set them both back to -1
    

    The idea is, nothing happens unless both cc's are in the state you expect them to be. If one hasn't been set yet then wait for the other to be set. Then take the action that you want to do and un-set them both to repeat the next time around.

    Thanks @wim for help 🙏🙏🙏 , I'm glad there's a solution that doesn't require another mozaic.
    I will try your method. It is a valuable experience.

    @wim

    I added the codes to the script. Is this what you have in mind? If so, unfortunately it doesn't work.

    In the first step of steppolyarp, which sends both speedcc and modecc with values (midibyte3) higher than 0, nothing happens. These codes only prevent the number 0 corresponding to the modecc value from being sent, whereas I expect that after x, log will show the number corresponding to modecc which is higher than 0.


    @OnLoad speedcc = - 1 //13 modecc = -1 //14 x = 0 resetmode = 0 countnote = 0 countcc = 0 @End @OnXYChange resetmode = Round TranslateScale (GetXValue), 0, 127, 0, 1 @End @OnMidiCC //Log {cc received. #:}, midibyte2, { value: }, midibyte3 //log {x beginning of handler : }, x if MIDIByte2 = 14 modecc = MIDIByte2 elseif MIDIByte2 = 13 speedcc = MIDIByte2 endif if MIDIByte2 = modecc x = Round TranslateScale (MIDIByte3), 0, 127, 0, 7 //Log {cc assign to x. #:}, midibyte2, { value: }, midibyte3 //log {processing done. x: }, x endif if resetmode = 0 if MIDIByte2 = speedcc if MIDIByte3 > 0 Inc countcc elseif MIDIByte3 = 0 countcc = 0 endif endif if modecc <> -1 and speedcc <> -1 if MIDIByte2 = speedcc and MIDIByte3 > 0 and countnote = 1 and countcc = 1 log {🔺x after second handler : } ,x endif endif endif if countnote = 0 countcc = 0 speedcc = - 1 modecc = -1 endif //log {x end handler : } ,x @End @OnMidiNoteOn if resetmode = 0 countnote = 1 endif @End @OnMidiNoteOff countcc = 0 countnote = 0 @End

    I'm sorry, it's more work than I'm ready to go to in order to understand the whole picture. There is more going on than just the script, and although you've posted screen shots, with external things going on and an unclear idea of what you're trying to accomplish, it's just not fruitful to keep hazarding guesses about the code.

    The best thing you can to figure this out yourself is to list exactly what is incoming to the script in order on that first step. Then, keeping in mind, that each @OnMidiCC, @OnMidiNoteOn, and @OnMidiNoteOff can only work on one message at a time, list what each variable will be after each message. Lastly, only act when all variables have gotten to the state that you expect.

    Sorry, I'd like to be more help, but my trying to suggest scripting changes when not in possession of all the information won't be helpful. And asking all the questions needed would be too time consuming.

  • @wim said:

    @pejman said:

    @pejman said:
    @wim

    @wim said:
    @pejman - If you have two things that are supposed to happen virtually simultaneously, but you can't be sure which will happen first, then you need to check if the first has happened yet.

    I haven't been following the conversation closely so this may not be the proper solution, but here's what I was thinking in generalized pseudo code.

    in onLoad
    // set both variables to something impossible
    speedCC = -1
    modeCC = -1
    
    in OnMidiCC
    // set speedCC or modeCC to the incoming value based on which arrived
    // check if both are not -1
    // if they are both <> -1 then 
      do something
      and then set them both back to -1
    

    The idea is, nothing happens unless both cc's are in the state you expect them to be. If one hasn't been set yet then wait for the other to be set. Then take the action that you want to do and un-set them both to repeat the next time around.

    Thanks @wim for help 🙏🙏🙏 , I'm glad there's a solution that doesn't require another mozaic.
    I will try your method. It is a valuable experience.

    @wim

    I added the codes to the script. Is this what you have in mind? If so, unfortunately it doesn't work.

    In the first step of steppolyarp, which sends both speedcc and modecc with values (midibyte3) higher than 0, nothing happens. These codes only prevent the number 0 corresponding to the modecc value from being sent, whereas I expect that after x, log will show the number corresponding to modecc which is higher than 0.


    @OnLoad speedcc = - 1 //13 modecc = -1 //14 x = 0 resetmode = 0 countnote = 0 countcc = 0 @End @OnXYChange resetmode = Round TranslateScale (GetXValue), 0, 127, 0, 1 @End @OnMidiCC //Log {cc received. #:}, midibyte2, { value: }, midibyte3 //log {x beginning of handler : }, x if MIDIByte2 = 14 modecc = MIDIByte2 elseif MIDIByte2 = 13 speedcc = MIDIByte2 endif if MIDIByte2 = modecc x = Round TranslateScale (MIDIByte3), 0, 127, 0, 7 //Log {cc assign to x. #:}, midibyte2, { value: }, midibyte3 //log {processing done. x: }, x endif if resetmode = 0 if MIDIByte2 = speedcc if MIDIByte3 > 0 Inc countcc elseif MIDIByte3 = 0 countcc = 0 endif endif if modecc <> -1 and speedcc <> -1 if MIDIByte2 = speedcc and MIDIByte3 > 0 and countnote = 1 and countcc = 1 log {🔺x after second handler : } ,x endif endif endif if countnote = 0 countcc = 0 speedcc = - 1 modecc = -1 endif //log {x end handler : } ,x @End @OnMidiNoteOn if resetmode = 0 countnote = 1 endif @End @OnMidiNoteOff countcc = 0 countnote = 0 @End

    I'm sorry, it's more work than I'm ready to go to in order to understand the whole picture. There is more going on than just the script, and although you've posted screen shots, with external things going on and an unclear idea of what you're trying to accomplish, it's just not fruitful to keep hazarding guesses about the code.

    The best thing you can to figure this out yourself is to list exactly what is incoming to the script in order on that first step. Then, keeping in mind, that each @OnMidiCC, @OnMidiNoteOn, and @OnMidiNoteOff can only work on one message at a time, list what each variable will be after each message. Lastly, only act when all variables have gotten to the state that you expect.

    Sorry, I'd like to be more help, but my trying to suggest scripting changes when not in possession of all the information won't be helpful. And asking all the questions needed would be too time consuming.

    What more information do you need from me?

  • @pejman said:

    @wim said:

    @pejman said:

    @pejman said:
    @wim

    @wim said:
    @pejman - If you have two things that are supposed to happen virtually simultaneously, but you can't be sure which will happen first, then you need to check if the first has happened yet.

    I haven't been following the conversation closely so this may not be the proper solution, but here's what I was thinking in generalized pseudo code.

    in onLoad
    // set both variables to something impossible
    speedCC = -1
    modeCC = -1
    
    in OnMidiCC
    // set speedCC or modeCC to the incoming value based on which arrived
    // check if both are not -1
    // if they are both <> -1 then 
      do something
      and then set them both back to -1
    

    The idea is, nothing happens unless both cc's are in the state you expect them to be. If one hasn't been set yet then wait for the other to be set. Then take the action that you want to do and un-set them both to repeat the next time around.

    Thanks @wim for help 🙏🙏🙏 , I'm glad there's a solution that doesn't require another mozaic.
    I will try your method. It is a valuable experience.

    @wim

    I added the codes to the script. Is this what you have in mind? If so, unfortunately it doesn't work.

    In the first step of steppolyarp, which sends both speedcc and modecc with values (midibyte3) higher than 0, nothing happens. These codes only prevent the number 0 corresponding to the modecc value from being sent, whereas I expect that after x, log will show the number corresponding to modecc which is higher than 0.


    @OnLoad speedcc = - 1 //13 modecc = -1 //14 x = 0 resetmode = 0 countnote = 0 countcc = 0 @End @OnXYChange resetmode = Round TranslateScale (GetXValue), 0, 127, 0, 1 @End @OnMidiCC //Log {cc received. #:}, midibyte2, { value: }, midibyte3 //log {x beginning of handler : }, x if MIDIByte2 = 14 modecc = MIDIByte2 elseif MIDIByte2 = 13 speedcc = MIDIByte2 endif if MIDIByte2 = modecc x = Round TranslateScale (MIDIByte3), 0, 127, 0, 7 //Log {cc assign to x. #:}, midibyte2, { value: }, midibyte3 //log {processing done. x: }, x endif if resetmode = 0 if MIDIByte2 = speedcc if MIDIByte3 > 0 Inc countcc elseif MIDIByte3 = 0 countcc = 0 endif endif if modecc <> -1 and speedcc <> -1 if MIDIByte2 = speedcc and MIDIByte3 > 0 and countnote = 1 and countcc = 1 log {🔺x after second handler : } ,x endif endif endif if countnote = 0 countcc = 0 speedcc = - 1 modecc = -1 endif //log {x end handler : } ,x @End @OnMidiNoteOn if resetmode = 0 countnote = 1 endif @End @OnMidiNoteOff countcc = 0 countnote = 0 @End

    I'm sorry, it's more work than I'm ready to go to in order to understand the whole picture. There is more going on than just the script, and although you've posted screen shots, with external things going on and an unclear idea of what you're trying to accomplish, it's just not fruitful to keep hazarding guesses about the code.

    The best thing you can to figure this out yourself is to list exactly what is incoming to the script in order on that first step. Then, keeping in mind, that each @OnMidiCC, @OnMidiNoteOn, and @OnMidiNoteOff can only work on one message at a time, list what each variable will be after each message. Lastly, only act when all variables have gotten to the state that you expect.

    Sorry, I'd like to be more help, but my trying to suggest scripting changes when not in possession of all the information won't be helpful. And asking all the questions needed would be too time consuming.

    What more information do you need from me?

    Short of being in the same room with you to work through it, watching what you’re doing with StepPolyArp, and asking questions as we go, I can’t think of a way to approach this that would be an effective use of time. 🤷🏻‍♂️

    I believe you can work it put if you do the things that have been suggested already. If not then maybe focus on other things for a bit. Sometimes when I return after a break from a project I’ve gotten stuck on, things finally start to become clear.

  • edited December 2024

    @wim

    This is my script, very simple and clear, and I did all the things that espiegel asked me to do, and finally we came to the conclusion that mozaic processes the received ccs one by one and not all at once, this is the problem I am facing. Even with putting a lot of logs and collecting information, we finally came to the same conclusion and I really don't know what else to do.

    Is there anything else I should have done that I haven't done?

    @OnLoad
      PBspeedcc = 13
      PBmodecc = 14
      x = 0 
      resetmode = 0
      countnote = 0
      countcc = 0
    @End
    
    @OnXYChange
    resetmode = Round TranslateScale (GetXValue), 0, 127, 0, 1  
    @End 
    
    
    @OnMidiCC
    if MIDIByte2 = PBmodecc 
       x = Round TranslateScale (MIDIByte3), 0, 127, 0, 7  
    endif
    
      if resetmode = 0 
        if MIDIByte2 = PBspeedcc 
          if MIDIByte3 > 0 
            Inc countcc
          elseif MIDIByte3 = 0 
             countcc = 0 
          endif
         endif
                      
    if MIDIByte2 = PBspeedcc and MIDIByte3 > 0 and countnote = 1 and countcc = 1  
                    //do something  if x = 3 for example
           log x        
    endif      
    endif
         
         
    if countnote = 0
      countcc = 0
      endif
    
    @End 
     
    
    @OnMidiNoteOn
    if resetmode = 0
     countnote = 1
     endif
    @End 
    
    @OnMidiNoteOff
      countcc = 0
      countnote = 0  
    @End 
    
    
  • edited December 2024

    @wim

    @wim said:

    You wrote: _I believe you can work it put if you do the things that have been suggested already. If not then maybe focus on other things for a bit. Sometimes when I return after a break from a project I’ve gotten stuck on, things finally start to become clear.
    _

    This is the method I use most often to solve the puzzle. I followed your advice and left the house and went to the nearest mountain to my house. On the way back home, remembering what @espiegel was trying to tell me, especially Order of processing ccs in mozaic , this solution came to my mind.

    It’s working.

    I simplified the script even further.


    @OnLoad PBspeedcc = 13 PBmodecc = 14 x = 0 state = 0 stateb = 0 @End @OnMidiCC if MIDIByte2 = PBmodecc and MIDIByte3 > 0 state = 1 endif if MIDIByte2 = PBspeedcc and MIDIByte3 > 0 stateb = 1 endif if state = 1 and stateb = 1 if MIDIByte2 = PBmodecc x = Round TranslateScale (MIDIByte3), 0, 127, 0, 7 log x endif endif @End
  • That's awesome @pejman! 😎👍🏼

Sign In or Register to comment.