Audiobus: Use your music apps together.

What is Audiobus?Audiobus is an award-winning music app for iPhone and iPad which lets you use your other music apps together. Chain effects on your favourite synth, run the output of apps or Audio Units into an app like GarageBand or Loopy, or select a different audio interface output for each app. Route MIDI between apps — drive a synth from a MIDI sequencer, or add an arpeggiator to your MIDI keyboard — or sync with your external MIDI gear. And control your entire setup from a MIDI controller.

Download on the App Store

Audiobus is the app that makes the rest of your setup better.

Mozaic: How to detect a "long tap" (0.5secs) on my BlueBoard?

1235»

Comments

  • I completely agree, @Janosax! It's mainly for making practicing easier, to feel more in control. In a live situation you definitely should do this without any audio feedback... but until then, it will make my life easier and more "responsive". :wink:

  • @josh83 said:
    I completely agree, @Janosax! It's mainly for making practicing easier, to feel more in control. In a live situation you definitely should do this without any audio feedback... but until then, it will make my life easier and more "responsive". :wink:

    I’m sure you will master it faster than you think :)

  • _ki_ki
    edited August 2020

    @josh83 You need to setup a ‚background‘ task with the timer event. This maybe runs every 100 or 50 msec and in the OnTImer event you need to check the states of your four possible input notes.
    .

    I suggest restructuring your code a bit, to simplify further development.

    In OnLoad define an array containing 4 blueboard notes

      bbNotes = [60,62,64,65]
    

    And an array containg either EMPTY = -1 or SystemTime of each possible of the 127 notes - managing it for all notes is simpler than having 4 vars with individual if‘s.

      EMPTY = -1
      FillArray noteTime, EMPTY, 128
    
      SetTimerInterval 50
      StartTimer
    

    In OnMidiNoteOn add

      noteTime[MIDINote] = SystemTime
    

    In OnMidiNoteOff add

      noteTime[MIDINote] = EMPTY  
    

    The Timer

    @OnTimer
      for i = 0 to 3
        bb = bbNote[i]
        nt = noteTime[bb]
        if nt <> EMPTY 
          delta = SystemTime - nt
          if delta > 1000
            // Do what you wanted when hold longer than 1000msec
    
            // clear the note, as it was already handled
            noteTime[bb] = EMPTY
          endif
        endif
      endfor
    @End
    

    .

    BTW: You can use trick with the indirection via bbNote[] everywhere you already had a 4 stage if-cascade your code to simplify it to a single test inside a loop.

    Like for instance in ShortTap:

    @ShortTap
      // Log {Short Tap: }, MidiNote
      for i = 0 to 3
        if MIDINote = bbNote[i]
          noteToSend = baseNote + i + 1
        endif
      endfor
    
      Call @SendNoteFromCurrentSpace
    @End
    
  • _ki_ki
    edited August 2020

    Hmm, the OnTimer is now running its four-step loop every 50msec - this does no harm on iPads, but maybe it‘s wiser to further reduce the CPU load:

    In OnLoad add

      noteCount = 0
    

    .

    In MidiNoteOn add

      Inc noteCount
    

    .

    In MidiNoteOff add

      Dec noteCount
    

    .

    Modify OnTimer

    @OnTimer
      If noteCount = 0
        Exit
      Endif
    
      for i = 0 to 3
         ...
    

    This immediately ‚leaves‘ the OnTimer event if no note is active - thus no loop, no further if‘s etc.

  • @josh83 said:
    Now I got another question: I'd love to give some audio feedback after a button is pressed for exactly 1 second (so I know that I can release it). As described in AUM: Play short audio files upon receiving specific MIDI signals?, I have set up a nice way of providing audio feedback using a sampler with a custom preset, loaded as AUv3.

    So I only need to know how to wait for a second after receiving the "MIDI on" event, and then, if the "off" event has not arrived yet, send the MIDI signal which would trigger the sampler's audio file.

    Any idea?

    Here's a highly simplified example to do only what you want it to do. It gets a little more complicated if you need to time more than one thing simultaneously and so need to keep the timer running all the time.

    @Bryan 's https://patchstorage.com/double-tap-and-hold/ and @_ki 's https://patchstorage.com/pad-manager-include/have some excellent code examples.

    @OnLoad
      cueTime = 1000
      interval = 5
      cueCounter = 0
      SetTimerInterval interval  
    @End
    
    @OnMidiNoteOn
      cueCounter = cueTime
      StartTimer
    @End
    
    @OnMidiNoteOff
      StopTimer
    @End
    
    @DoSomething
      Log {Time to do the thing.}
    @End
    
    @OnTimer
      if cueCounter > 0
        cueCounter = cueCounter - interval
      else
        StopTimer
        Call @DoSomething
      endif
    @End
    
  • BTW: My code snipptes have extra documentation including their source available in the AudioBus wiki, here the link to the Pad and Shift Manager Snippet Documentation.

  • Thanks for your suggestions and inspirations, guys! :heart:

    @_ki:

    I took your idea of removing the if/else stuff and replacing it with this beautiful loop: https://github.com/jmuheim/mozaic-blueboard/commit/43eab7e4dff99b450849f5ef520e12ea74b0e08d#diff-3205c0ded576131ea255ad2bd38b0fb2

    I liked @wim's implementation of the timer better though, as it only runs when a button is pressed: https://github.com/jmuheim/mozaic-blueboard/commit/e2473445e57ca9ff44a5929be6400a643949f695#diff-3205c0ded576131ea255ad2bd38b0fb2

    I'm starting to get the concept of working with those events. Powerful stuff! I have many more cool ideas on how to improve my workflow! :smiley:

  • xorxor
    edited August 2020

    Oops, didn’t notice the next page, @_ki already has you covered. Sorry

    @josh83 if you’re not already using timers the you can do something like this (assumes you don’t want to reset the countdown on a second midi on event)...

    @OnLoad
      NotificationQueued = NO
    @End
    
    @OnMidiNoteOn
      if condition-that-triggers-sound and NotificationQueued = NO
        NotificationQueued = YES
        SetTimer 1000  // 1 second timer
      endif
    @End
    
    @OnMidiNoteOff
      if condition-that-prevents-sound and NotificationQueued = YES
        StopTimer
        NotificationQueued = NO
      end
    @End
    
    @OnTimer
      StopTimer
      SendMIDINote ...  // Play your sound
      NotificationQueued = NO
    @End
    

    If you’re already using a timer then you’d need to use the SystemTime and check it in your timer event

    @OnLoad
      NotificationStart = -1
    @End
    
    @OnMidiNoteOn
      if condition-that-prevents-sound and NotificationStart = -1
        NotificationStart = SystemTime
      endif
    @End
    
    @OnMidiNoteOff
      if condition-that-prevents-sound
        NotificationStart = -1
      end
    @End
    
    @OnTimer
      if NotificationStart > 0 and SystemTime - NotificationStart >= 1000
        SendMidiNote ... // Play your sound
        NotificationStart = -1
      end 
    @End
    
  • Thanks for your explanation, @xor! The detail with SystemTime is pretty relevant, good to know!

Sign In or Register to comment.