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 // Only send the last midi value of a midi cc stream?

I am trying to only send the last midi cc value of a midi data stream after a given idle time.

I managed the timing functions but don't see a way to store the last value and send it later. I'd like to be flexible with the cc param numbers, too.

Is there a clever way to do this in Mozaic?

Comments

  • no expert with a little advice out there?

  • Every time a new CC value comes in save it to a variable.
    When the timer goes off then send out a CC message using this saved last value.

    Each CC coming in can overwrite the one before it since you only care about the last one.

  • wimwim
    edited October 2020

    Here's one way I think will do what you want. For more flexibility, you could set the channel, cc#, and timeout with knobs.

    @OnLoad
      channel = 0     // channel to listen on
      ccNumber = 20   // cc to listen for
      timeout = 2000  // timeout in milliseconds
      interval = 10
      SetTimerInterval interval
      running = NO
    @End
    
    @OnMidiCC
      if (MIDIChannel = channel) and (MIDIByte2 = ccNumber)
        ccValue = MIDIByte3
        counter = timeout
        if running = NO 
          StartTimer
        endif
      endif
    @End
    
    @OnTimer
      counter = counter - interval
      if counter <= 0
        StopTimer
        running = NO
        SendMIDICC channel,ccNumber,ccValue
      endif
    @End
    

    NOTE: This script will block all other MIDI. Some additional code is needed if other midi needs to be passed through.

  • Here's a version that passes through all other midi:

    @OnLoad
      channel = 0     // channel to listen on
      ccNumber = 20   // cc to listen for
      timeout = 2000  // timeout in milliseconds
      interval = 10
      SetTimerInterval interval
      running = NO
    @End
    
    @OnMidiInput
      if MIDICommand <> 0xB0
        SendMIDIThru 
      endif
    @End
    
    @OnMidiCC
      if (MIDIChannel = channel) and (MIDIByte2 = ccNumber)
        ccValue = MIDIByte3
        counter = timeout
        if running = NO 
          StartTimer
        endif
      else
        SendMIDIThru 
      endif
    @End
    
    @OnSysex
      SendSysexThru 
    @End
    
    @OnTimer
      counter = counter - interval
      if counter <= 0
        StopTimer
        running = NO
        SendMIDICC channel,ccNumber,ccValue
      endif
    @End
    
  • hey thanks guys @wim @McD! i will try that.

    it's always good to see a code example since i'm sometimes get stuck trying to achieve things like these with the little mozaic toolbox.

    what i still don't understand is the role of the counter variable in your example @wim. since it's state is always NO, what does it do?

  • @nuno_agogo said:
    hey thanks guys @wim @McD! i will try that.

    it's always good to see a code example since i'm sometimes get stuck trying to achieve things like these with the little mozaic toolbox.

    what i still don't understand is the role of the counter variable in your example @wim. since it's state is always NO, what does it do?

    Look at the code again. The counter is reset to the timeout value on each new midicc and then counts down each time through the timer loop

  • edited October 2020

    alright, i was able to assemble the script.

    it now captures the incoming cc messages, stores them in a state variable and outputs them all after the timeout.

    thanks for helping me with my brain jam :)

        @OnLoad
          channel = 0     // channel to listen on
          ccNumber = 1   // cc to listen for
          timeout = 444  // timeout in milliseconds
          interval = 10
          SetTimerInterval interval      
          state[0] = -2
          for p = 0 to 127
            state[p]  = -1
          endfor    
        @End
    
        @OnMidiCC
          if (MIDIChannel = channel)
            state[MIDIByte2] = MIDIByte3
            counter = timeout
            StartTimer
          endif
        @End
    
        @OnTimer
          counter = counter - interval
          if counter <= 0
            StopTimer
    
            Log {----------}
    
            for p = 127 to 0
              if state[p] <> -1
                SendMIDICC channel, p, state[p]
                Log {Ch }, channel, { CC-}, p, {: }, state[p]
                state[p] = -1
              endif
            endfor
    
          endif
        @End
    
        @OnMidiInput
          if MIDICommand <> 0xB0
            SendMIDIThru 
          endif
        @End
    
        @OnSysex
          SendSysexThru 
        @End
    
Sign In or Register to comment.