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.

Controlling tempo in AUM via MIDI from Mozaic or StreamByter

Programatically controlling tempo became a possibility in AUM 1.4.0 and there was much rejoicing.
However I'm struggling with this in practice with Mozaic, never quite getting the BPM right...

Firstly I setup AUM transport to receive MIDI CC 102 for tempo, restricting range to 20-240bpm, and with Mozaic as a MIDI source.

I then created a script (below) to set BPM via a knob.

The issue is that the value scaling in AUM is never quite right, either plus or minus a few tenths of BPM.
Understanding that there are 128 CC values I thought maybe I could set a 256 BPM range in AUM to ensure no rounding errors, but the range selection in AUM won't allow this, only producing whole numbers every 10bpm.

What am I missing? Is there any way to cleanly map CC to whole number BPM values in AUM?

Here's the test script for anyone brave enough to try...

@OnLoad
ShowLayout 0

SetKnobValue 0, Round (TranslateScale (Round HostTempo), 20, 240, 0, 127)
Call @KnobChange_BPM
@End

@OnKnobChange
if LastKnob = 0
Call @KnobChange_BPM
endif
@End

@KnobChange_BPM
_knobBPMValue = Round (GetKnobValue 0)
_knobBPMValueScaled = Round (TranslateScale _knobBPMValue, 0, 127, 20, 240)
LabelKnob 0, {BPM: }, _knobBPMValueScaled
SendMIDICC 0, 102, _knobBPMValue
@End

«1

Comments

  • Cool. I missed this detail in the AUM update list... along with dozens of other cool new features.

    Someone should share the Streambyter code equivalent since streambyter is free... does it have knobs or does that require MIDIFire?

  • @belldu said:
    Programatically controlling tempo became a possibility in AUM 1.4.0 and there was much rejoicing.
    However I'm struggling with this in practice with Mozaic, never quite getting the BPM right...

    Firstly I setup AUM transport to receive MIDI CC 102 for tempo, restricting range to 20-240bpm, and with Mozaic as a MIDI source.

    I then created a script (below) to set BPM via a knob.

    The issue is that the value scaling in AUM is never quite right, either plus or minus a few tenths of BPM.
    Understanding that there are 128 CC values I thought maybe I could set a 256 BPM range in AUM to ensure no rounding errors, but the range selection in AUM won't allow this, only producing whole numbers every 10bpm.

    What am I missing? Is there any way to cleanly map CC to whole number BPM values in AUM?

    Here's the test script for anyone brave enough to try...

    @OnLoad
    ShowLayout 0

    SetKnobValue 0, Round (TranslateScale (Round HostTempo), 20, 240, 0, 127)
    Call @KnobChange_BPM
    @End

    @OnKnobChange
    if LastKnob = 0
    Call @KnobChange_BPM
    endif
    @End

    @KnobChange_BPM
    _knobBPMValue = Round (GetKnobValue 0)
    _knobBPMValueScaled = Round (TranslateScale _knobBPMValue, 0, 127, 20, 240)
    LabelKnob 0, {BPM: }, _knobBPMValueScaled
    SendMIDICC 0, 102, _knobBPMValue
    @End

    AU parameters are floating point numbers and midi is restricted to integer values. The range of 20 to 240 a range of 220) does not map neatly to 128 integer values (0 to 127). While Mozaic internally uses floating point values, MIDI events just use integers.

  • @McD said:
    Cool. I missed this detail in the AUM update list... along with dozens of other cool new features.

    Someone should share the Streambyter code equivalent since streambyter is free... does it have knobs or does that require MIDIFire?

    Yes, StreamByter has knobs, "sliders" actually. No difficult to use.

  • @espiegel123 said:

    @belldu said:
    Programatically controlling tempo became a possibility in AUM 1.4.0 and there was much rejoicing.
    However I'm struggling with this in practice with Mozaic, never quite getting the BPM right...

    Firstly I setup AUM transport to receive MIDI CC 102 for tempo, restricting range to 20-240bpm, and with Mozaic as a MIDI source.

    I then created a script (below) to set BPM via a knob.

    The issue is that the value scaling in AUM is never quite right, either plus or minus a few tenths of BPM.
    Understanding that there are 128 CC values I thought maybe I could set a 256 BPM range in AUM to ensure no rounding errors, but the range selection in AUM won't allow this, only producing whole numbers every 10bpm.

    What am I missing? Is there any way to cleanly map CC to whole number BPM values in AUM?

    Here's the test script for anyone brave enough to try...

    @OnLoad
    ShowLayout 0

    SetKnobValue 0, Round (TranslateScale (Round HostTempo), 20, 240, 0, 127)
    Call @KnobChange_BPM
    @End

    @OnKnobChange
    if LastKnob = 0
    Call @KnobChange_BPM
    endif
    @End

    @KnobChange_BPM
    _knobBPMValue = Round (GetKnobValue 0)
    _knobBPMValueScaled = Round (TranslateScale _knobBPMValue, 0, 127, 20, 240)
    LabelKnob 0, {BPM: }, _knobBPMValueScaled
    SendMIDICC 0, 102, _knobBPMValue
    @End

    AU parameters are floating point numbers and midi is restricted to integer values. The range of 20 to 240 a range of 220) does not map neatly to 128 integer values (0 to 127). While Mozaic internally uses floating point values, MIDI events just use integers.

    @espiegel123 said:

    @belldu said:
    Programatically controlling tempo became a possibility in AUM 1.4.0 and there was much rejoicing.
    However I'm struggling with this in practice with Mozaic, never quite getting the BPM right...

    Firstly I setup AUM transport to receive MIDI CC 102 for tempo, restricting range to 20-240bpm, and with Mozaic as a MIDI source.

    I then created a script (below) to set BPM via a knob.

    The issue is that the value scaling in AUM is never quite right, either plus or minus a few tenths of BPM.
    Understanding that there are 128 CC values I thought maybe I could set a 256 BPM range in AUM to ensure no rounding errors, but the range selection in AUM won't allow this, only producing whole numbers every 10bpm.

    What am I missing? Is there any way to cleanly map CC to whole number BPM values in AUM?

    Here's the test script for anyone brave enough to try...

    @OnLoad
    ShowLayout 0

    SetKnobValue 0, Round (TranslateScale (Round HostTempo), 20, 240, 0, 127)
    Call @KnobChange_BPM
    @End

    @OnKnobChange
    if LastKnob = 0
    Call @KnobChange_BPM
    endif
    @End

    @KnobChange_BPM
    _knobBPMValue = Round (GetKnobValue 0)
    _knobBPMValueScaled = Round (TranslateScale _knobBPMValue, 0, 127, 20, 240)
    LabelKnob 0, {BPM: }, _knobBPMValueScaled
    SendMIDICC 0, 102, _knobBPMValue
    @End

    AU parameters are floating point numbers and midi is restricted to integer values. The range of 20 to 240 a range of 220) does not map neatly to 128 integer values (0 to 127). While Mozaic internally uses floating point values, MIDI events just use integers.

    Yes, I think thats my problem.
    I tried to solve by setting AUM range to be 128 or a multiple of it to avoid rounding errors.
    However while you can set lower to 20, you can't set the upper range in AUM to be 248, the closest I could get was 248.2... which still produced fractional BPM.

    Unless I'm missing a trick then setting tempo via CC isn't ever going to produce whole number BPM which makes it difficult to work with. But am I missing a trick?

  • Apologies for my appalling maths... the point was correct, the numbers not so. As MIDI CC has 128 values, the point is I can't set a range of 128 or 256 in AUM, so mapping CC to tempo is always going to result in fractional BPM, unless I'm missing something...

  • @belldu said:
    Apologies for my appalling maths... the point was correct, the numbers not so. As MIDI CC has 128 values, the point is I can't set a range of 128 or 256 in AUM, so mapping CC to tempo is always going to result in fractional BPM, unless I'm missing something...

    Is there a reason why a fractional bpm is a problem?

    Have you tried setting the range from 40 to 167?

  • My use case is a Mozaic script that adjusts tempo over a set number of bars from one value to another (i.e. slowing accelerating tempo). The issue is that while I can round values nicely in Mozaic, and use the new Midi CC map in AUM for tempo, it never quite ends up where it should.
    And I can't get 167 in AUM. It gives me 167.1 and only gives me whole BPM numbers on multiples of 10.
    I'm wondering if I should request 'tap to enter range' in AUM...

  • edited June 1

    @McD said:
    Cool. I missed this detail in the AUM update list... along with dozens of other cool new features.

    Someone should share the Streambyter code equivalent since streambyter is free... does it have knobs or does that require MIDIFire?

    Here's my StreamByter implementation. It does calculations to the nearest (rounded) integer value, necessary for sending an integer CC value. But AUM scales that to the range 20-240 BPM in floating point, so the end results are usually fractions.

    #SetAUMTempo
    
    If load
    Set name SetBPM
    Alias $102 theCCNumber
    Alias $20 minBPM
    Alias $240 maxBPM
    
    Alias Q0 theTempoCC
    Alias 0 indTempoCC
    Alias Q1 theBPM
    Alias 1 indBPM
    Set Q0 Tempo_CC 0 $127
    Set Q1 BPM minBPM maxBPM
    Set Q2 +hide
    Set Q3 +hide
    Set Q4 +hide
    Set Q5 +hide
    Set Q6 +hide
    Set Q7 +hide
    
    Ass Q0 = 0 minBPM
    
    Set SLIDER_DISPLAY 1
    
    # low/high values
    # mode 0 maps CC range to BPM. Mode 2 maps BPM to CC
    Ass K00 = minBPM maxBPM 0 $127 minBPM maxBPM
    
    # compute y = y0 + (y1-y0) * (x-x0)/(x1-x0) rounded
    # y = y0 + ( 2*(y1-y0)*(x-x0) + (x1-x0) ) / ( 2*(x1-x0) )
    # doubling ensures symmetry for odd and even ranges
    # this calculation works with unsigned integers, the data type in SB
    Sub ScaleValue pResult pValue pMode
       Mat I20 = 2 * pMode
       Mat I21 = I20 + 2
       Mat I22 = I21 + 1
       Mat P00 = pValue - KI21   # input reduced to 0
       Mat I29 = KI22 - KI21    # input range
       Mat I2A = 2 * I29
       Mat I21 = I20 + 1
       Mat I2B = KI21 - KI20   # output range
       Mat I2B = 2 * I2B   # doubled
       Mat P00 = P00 * I2B
       Mat P00 = P00 + I29
       Mat P00 = P00 / I2A   # division always last step
       Mat pResult = P00 + KI20
    End
    
    Sub UpdateValues pIndex
       If pIndex == indTempoCC
          ScaleValue theBPM theTempoCC pIndex
       Else
          ScaleValue theTempoCC theBPM pIndex
       End
    End
    
    End # Initialization ———————————————————————————
    
    If M0 == F0 7D 01       # handle control change
       UpdateValues M3
       Send B0 theCCNumber theTempoCC
    End
    

    Here it is in use. You can adjust either slider and the correct CC value will be sent. Notice that the tempo indicates 84.1 BPM. It's probably not exactly that either, the display is just rounded to one decimal place.

    Edit: Corrected script for larger ranges – need to use P00 to accumulate the numerator.

  • There are 128 different CC values, but the range is 127. Doubled is 254. I was able to set the tempo scaling in AUM to 20-274.1. Could not hit 274 exactly. This means each CC value selects an even tempo. But CC values above 64 result in xx.1 BPM values as displayed in AUM.

  • So now I've learned there is an interesting thing called StreamByter... I'm sure I originally came here for music stuff to get away from IT... lol. But you've got the same issue I have I think in that the midi cc range can't map to an equivalent range in AUM and rounding errors then occur, although you've done a better job in lessening them.
    My conclusion thus far is that a 'click to enter range value manually' button is needed in AUM to allow for entry of 274.
    Any other ideas or should I request it?

  • @belldu said:
    So now I've learned there is an interesting thing called StreamByter... I'm sure I originally came here for music stuff to get away from IT... lol. But you've got the same issue I have I think in that the midi cc range can't map to an equivalent range in AUM and rounding errors then occur, although you've done a better job in lessening them.
    My conclusion thus far is that a 'click to enter range value manually' button is needed in AUM to allow for entry of 274.
    Any other ideas or should I request it?

    Yes. Direct entry of range would be useful when specific values are needed, as in this case.

    But trying to set an exact integer BPM from a 7-bit MIDI CC is a bit of a stretch anyway. Look at the tricks you need to know: the range must be an integer multiple of 127, and you need to fudge the input to select one of the available 128 values. All not very general. It might be better if AUM received a 14-bit value, maybe a double CC, to set the BPM exactly. This wouldn't fit the generic CC mapping paradigm, but it could be more useful.

  • Since you can change BPM using AUM a good script would offer an LFO that swings between two BPM values at some configurable rate.

    NOTE: Rozetta LFO works for this use case if anyone owns it. The CC range of 0-127 swings between 20 and something way up around 500. I turned the upper limit down to 50 to reach around 200+. WARNING: Rapidly changing BPM's may induce vomiting in your audience. (What?! You have an audience?). I suppose if I took off the headphones I could claim to have an audience.

  • heshes
    edited June 2

    I haven't checked out the new AUM, but it looks like something called "Tempo Presets" are one of the additions:

    TEMPO PRESET 
    This allows setting a specific tempo triggered by a MIDI message. 
    Tap "ADD" to add a tempo preset. 
    Then tap it to configure which MIDI message should trigger it. 
    Swipe it to DELETE or EDIT it. 
    

    Sounds to me like you could set up a number of precise tempo presets (integer values) and then use midi messages to switch between them. If so, maybe not quite as flexible as just sending an integer value directly, but maybe can get you to what you want.

  • @McD said:
    Since you can change BPM using AUM a good script would offer an LFO that swings between two BPM values at some configurable rate.

    NOTE: Rozetta LFO works for this use case if anyone owns it. The CC range of 0-127 swings between 20 and something way up around 500. I turned the upper limit down to 50 to reach around 200+. WARNING: Rapidly changing BPM's may induce vomiting in your audience. (What?! You have an audience?). I suppose if I took off the headphones I could claim to have an audience.

    You can adjust the scale of the tempo CC in AUM to set the low and high limits as desired. Cutting down the range will give smoother transitions.

  • @uncledave said:

    @McD said:
    Since you can change BPM using AUM a good script would offer an LFO that swings between two BPM values at some configurable rate.

    NOTE: Rozetta LFO works for this use case if anyone owns it. The CC range of 0-127 swings between 20 and something way up around 500. I turned the upper limit down to 50 to reach around 200+. WARNING: Rapidly changing BPM's may induce vomiting in your audience. (What?! You have an audience?). I suppose if I took off the headphones I could claim to have an audience.

    You can adjust the scale of the tempo CC in AUM to set the low and high limits as desired. Cutting down the range will give smoother transitions.

    Nice tip... I looked for a way to adjust the range and completely missed those settings.

    I got an idea yesterday to convert the MIDI note vale to a CC parameter and MIDI learn that CC to the AUM Stereo Balance (i.e. pan) so that low notes would be on my left and high notes
    on the right just like sitting at a real piano . Turns out AUM reverses my intended sides so
    I set the CC value to 127-Note_Number but I suspect flipping the range is also a feature in
    AUM's MIDI control settings.

    Turns out this makes a piano part very wide in the stereo image and that PAN control in AUM jumps around like it's gone berserk.

  • wimwim
    edited June 2

    It seems like I'm always throwing out derailing ideas, but I can't help thinking how I would accomplish these things sometimes.

    I wouldn't go through all of this. I would add an instance of Loopy Pro AUv3, with Link turned on. Then I'd set up a single nice big fat knob or slider with an action to adjust the Loopy tempo in a suitable range.

    I just tried it. Took less than two minutes. It doesn't filter out decimal tempos, but for my purposes that doesn't matter.

  • Weird result: After setting up Rozetta LFO to change the Tempo/BPM of AUM, I started a new session and with nothing loaded yet the Tempo kept oscillating from 20 to 220 at the speed of the Rosetta rate.

    I tried a dozen ways to re-program Tempo which did not show any config and even re-started a new Rozeta LFO but nothing would change the old behavior in AUM. I powered off
    the iPad and re-started AUM... same LFO oscillating of tempo.

    I finally deleted and re-install AUM and it cleaned it up but I did loose all my AUM Sessions but not the recording which I assume are in the iCloud and we're not deleted on AUM deletion.

  • Plenty of food for thought here... and I'm now wondering if instead of CC messages, that it can be mapped to pitchbend which is a 14 bit value with a range of 0 to 16383.
    Experiments continue...

    And although the limit on the range is 500 bpm you can manually drag the AUM tempo to 999.
    With the metronome on this sounds like an 80s video game sound effect (i'm thinking Chuckie Egg for those old enough to remember!). Pointless, but fun.

  • I posted this in the AUM 1.4.0 thread earlier this week. It backs up the comments made here + I agree Tempo Presets look the way to go if you want integer values but I haven’t tried them…

  • @belldu said:
    Plenty of food for thought here... and I'm now wondering if instead of CC messages, that it can be mapped to pitchbend which is a 14 bit value with a range of 0 to 16383.
    Experiments continue...

    And although the limit on the range is 500 bpm you can manually drag the AUM tempo to 999.
    With the metronome on this sounds like an 80s video game sound effect (i'm thinking Chuckie Egg for those old enough to remember!). Pointless, but fun.

    PBEND is available in the settings for Tempo. Should be able to get a lot closer with that.

  • @McD said:
    Weird result: After setting up Rozetta LFO to change the Tempo/BPM of AUM, I started a new session and with nothing loaded yet the Tempo kept oscillating from 20 to 220 at the speed of the Rosetta rate.

    I tried a dozen ways to re-program Tempo which did not show any config and even re-started a new Rozeta LFO but nothing would change the old behavior in AUM. I powered off
    the iPad and re-started AUM... same LFO oscillating of tempo.

    I finally deleted and re-install AUM and it cleaned it up but I did loose all my AUM Sessions but not the recording which I assume are in the iCloud and we're not deleted on AUM deletion.

    Are you saying the tempo kept fluctuating even with a blank session, nothing loaded? I don't see how that could be possible. Did you have some other app sending Ableton Link perhaps?

  • @j_liljedahl said:
    Are you saying the tempo kept fluctuating even with a blank session, nothing loaded? I don't see how that could be possible.

    It was some phantom weirdness for sure. I killed everything running except AUM.

    I'll try and duplicate the steps to see if it re-occurs.

    I even powered off and on the iPad and the AUM instance kept moving the Tempo between 20 and 220 and those are the end points I had requested in a Rozeta instance earlier in the day using 0 to 50 on the CC scale.

    Did you have some other app sending Ableton Link perhaps?

    No.

  • @McD said:

    @j_liljedahl said:
    Are you saying the tempo kept fluctuating even with a blank session, nothing loaded? I don't see how that could be possible.

    It was some phantom weirdness for sure. I killed everything running except AUM.

    I'll try and duplicate the steps to see if it re-occurs.

    I even powered off and on the iPad and the AUM instance kept moving the Tempo between 20 and 220 and those are the end points I had requested in a Rozeta instance earlier in the day using 0 to 50 on the CC scale.

    The Tempo midi mapping is saved with the session, so there's no way it could be controlled that way after restarting AUM and not loading any session (or last state). The only thing that technically could modulate the tempo in that case is Ableton Link (if enabled). Perhaps you had something running on another device on the same network.

  • @j_liljedahl said:

    @McD said:

    @j_liljedahl said:
    Are you saying the tempo kept fluctuating even with a blank session, nothing loaded? I don't see how that could be possible.

    It was some phantom weirdness for sure. I killed everything running except AUM.

    I'll try and duplicate the steps to see if it re-occurs.

    I even powered off and on the iPad and the AUM instance kept moving the Tempo between 20 and 220 and those are the end points I had requested in a Rozeta instance earlier in the day using 0 to 50 on the CC scale.

    The Tempo midi mapping is saved with the session, so there's no way it could be controlled that way after restarting AUM and not loading any session (or last state). The only thing that technically could modulate the tempo in that case is Ableton Link (if enabled). Perhaps you had something running on another device on the same network.

    I have tried to duplicate the sequence and I can't reproduce the phantom LFO behavior.
    Since I deleted AUM and re-installed I don't have the Aum Project that might re-create the odd Tempo oscillations.

    Thank you for these new features... greatly appreciated. I will now test the new "Tip Jar" located at the base of the MENU page with a dollar sign on it.

  • @McD said:

    @j_liljedahl said:

    @McD said:

    @j_liljedahl said:
    Are you saying the tempo kept fluctuating even with a blank session, nothing loaded? I don't see how that could be possible.

    It was some phantom weirdness for sure. I killed everything running except AUM.

    I'll try and duplicate the steps to see if it re-occurs.

    I even powered off and on the iPad and the AUM instance kept moving the Tempo between 20 and 220 and those are the end points I had requested in a Rozeta instance earlier in the day using 0 to 50 on the CC scale.

    The Tempo midi mapping is saved with the session, so there's no way it could be controlled that way after restarting AUM and not loading any session (or last state). The only thing that technically could modulate the tempo in that case is Ableton Link (if enabled). Perhaps you had something running on another device on the same network.

    I have tried to duplicate the sequence and I can't reproduce the phantom LFO behavior.
    Since I deleted AUM and re-installed I don't have the Aum Project that might re-create the odd Tempo oscillations.

    A project couldn't affect anything unless you did load the project? Anyway, let me know if it happens again! And the things to check if it happens are: 1) Is there a tempo BPM or tempo preset MIDI binding? 2) Is Ableton Link enabled? Try disable it if so.

    Thank you for these new features... greatly appreciated. I will now test the new "Tip Jar" located at the base of the MENU page with a dollar sign on it.

    :) <3

  • @belldu AUM BPM setting is exact when input is a PitchBend message. Here's my updated StreamByter script:

    #SetAUMTempoPB
    
    If load
    Set name SetBP
    Alias $20 minBPM
    Alias $240 maxBPM
    Alias 0 minOutput
    Alias 3FFF maxOutput
    
    Alias Q0 theTempoPB
    Alias 0 indTempoPB
    Alias Q1 theBPM
    Alias 1 indBPM
    Set Q0 Tempo_CC minOutput maxOutput
    Set Q1 BPM minBPM maxBPM
    Set Q2 +hide
    Set Q3 +hide
    Set Q4 +hide
    Set Q5 +hide
    Set Q6 +hide
    Set Q7 +hide
    
    Ass Q0 = 0 minBPM
    
    Set SLIDER_DISPLAY 1
    
    # low/high values
    # mode 0 maps PB range to BPM. Mode 2 maps BPM to PB
    Ass K00 = minBPM maxBPM minOutput maxOutput minBPM maxBPM
    
    # compute y = y0 + (y1-y0) * (x-x0)/(x1-x0) rounded
    # y = y0 + ( 2*(y1-y0)*(x-x0) + (x1-x0) ) / ( 2*(x1-x0) )
    # doubling ensures symmetry for odd and even ranges
    # this calculation works with unsigned integers, the data type in SB
    # Using P00 (32-bit) for numerator, because it can be large.
    Sub ScaleValue pResult pValue pMode
       Mat I20 = 2 * pMode
       Mat I21 = I20 + 2
       Mat I22 = I21 + 1
       Mat P00 = pValue - KI21   # input reduced to 0
       Mat I29 = KI22 - KI21    # input range
       Mat I2A = 2 * I29
       Mat I21 = I20 + 1
       Mat I2B = KI21 - KI20   # output range
       Mat I2B = 2 * I2B   # doubled
       Mat P00 = P00 * I2B
       Mat P00 = P00 + I29
       Mat P00 = P00 / I2A   # division always last step
       Mat pResult = P00 + KI20
    End
    
    Sub UpdateValues pIndex
       If pIndex == indTempoPB
          ScaleValue theBPM theTempoPB pIndex
       Else
          ScaleValue theTempoPB theBPM pIndex
       End
    End
    
    Sub SendPitchBend pChan pValue
       Mat I20 = E0 + pChan
       Mat I21 = pValue & 7F    # LSB is first in PB
       Mat I22 = pValue / 80   # shift MSB down
       Mat I22 = I22 & 7F     # mask MSB to be safe
       Send I20 I21 I22
    End
    
    End # Initialization ———————————————————————————
    
    If M0 == F0 7D 01       # handle control change
       UpdateValues M3
       SendPitchBend 0 theTempoPB
    End
    

    Changes were minimal aside from the new SendPitchBend sub. And here it is running:

    The SB BPM slider can only be set to integer values, and AUM tempo shows the same integers. This uses the original range of 20 to 240 BPM, no tricky fudging required.

    You should be able to adapt your Mozaic script in the same way. It seems a bit strange to be using PB like this, but it's only between the script and the AUM Tempo mapping. It's just a way of sending a 14-bit value.

  • @uncledave said:
    @belldu AUM BPM setting is exact when input is a PitchBend message. Here's my updated StreamByter script:

    #SetAUMTempoPB
    
    If load
    Set name SetBP
    Alias $20 minBPM
    Alias $240 maxBPM
    Alias 0 minOutput
    Alias 3FFF maxOutput
    
    Alias Q0 theTempoPB
    Alias 0 indTempoPB
    Alias Q1 theBPM
    Alias 1 indBPM
    Set Q0 Tempo_CC minOutput maxOutput
    Set Q1 BPM minBPM maxBPM
    Set Q2 +hide
    Set Q3 +hide
    Set Q4 +hide
    Set Q5 +hide
    Set Q6 +hide
    Set Q7 +hide
    
    Ass Q0 = 0 minBPM
    
    Set SLIDER_DISPLAY 1
    
    # low/high values
    # mode 0 maps PB range to BPM. Mode 2 maps BPM to PB
    Ass K00 = minBPM maxBPM minOutput maxOutput minBPM maxBPM
    
    # compute y = y0 + (y1-y0) * (x-x0)/(x1-x0) rounded
    # y = y0 + ( 2*(y1-y0)*(x-x0) + (x1-x0) ) / ( 2*(x1-x0) )
    # doubling ensures symmetry for odd and even ranges
    # this calculation works with unsigned integers, the data type in SB
    # Using P00 (32-bit) for numerator, because it can be large.
    Sub ScaleValue pResult pValue pMode
       Mat I20 = 2 * pMode
       Mat I21 = I20 + 2
       Mat I22 = I21 + 1
       Mat P00 = pValue - KI21   # input reduced to 0
       Mat I29 = KI22 - KI21    # input range
       Mat I2A = 2 * I29
       Mat I21 = I20 + 1
       Mat I2B = KI21 - KI20   # output range
       Mat I2B = 2 * I2B   # doubled
       Mat P00 = P00 * I2B
       Mat P00 = P00 + I29
       Mat P00 = P00 / I2A   # division always last step
       Mat pResult = P00 + KI20
    End
    
    Sub UpdateValues pIndex
       If pIndex == indTempoPB
          ScaleValue theBPM theTempoPB pIndex
       Else
          ScaleValue theTempoPB theBPM pIndex
       End
    End
    
    Sub SendPitchBend pChan pValue
       Mat I20 = E0 + pChan
       Mat I21 = pValue & 7F    # LSB is first in PB
       Mat I22 = pValue / 80   # shift MSB down
       Mat I22 = I22 & 7F     # mask MSB to be safe
       Send I20 I21 I22
    End
    
    End # Initialization ———————————————————————————
    
    If M0 == F0 7D 01     # handle control change
       UpdateValues M3
       SendPitchBend 0 theTempoPB
    End
    

    Changes were minimal aside from the new SendPitchBend sub. And here it is running:

    The SB BPM slider can only be set to integer values, and AUM tempo shows the same integers. This uses the original range of 20 to 240 BPM, no tricky fudging required.

    You should be able to adapt your Mozaic script in the same way. It seems a bit strange to be using PB like this, but it's only between the script and the AUM Tempo mapping. It's just a way of sending a 14-bit value.

    @uncledave said:
    @belldu AUM BPM setting is exact when input is a PitchBend message. Here's my updated StreamByter script:

    #SetAUMTempoPB
    
    If load
    Set name SetBP
    Alias $20 minBPM
    Alias $240 maxBPM
    Alias 0 minOutput
    Alias 3FFF maxOutput
    
    Alias Q0 theTempoPB
    Alias 0 indTempoPB
    Alias Q1 theBPM
    Alias 1 indBPM
    Set Q0 Tempo_CC minOutput maxOutput
    Set Q1 BPM minBPM maxBPM
    Set Q2 +hide
    Set Q3 +hide
    Set Q4 +hide
    Set Q5 +hide
    Set Q6 +hide
    Set Q7 +hide
    
    Ass Q0 = 0 minBPM
    
    Set SLIDER_DISPLAY 1
    
    # low/high values
    # mode 0 maps PB range to BPM. Mode 2 maps BPM to PB
    Ass K00 = minBPM maxBPM minOutput maxOutput minBPM maxBPM
    
    # compute y = y0 + (y1-y0) * (x-x0)/(x1-x0) rounded
    # y = y0 + ( 2*(y1-y0)*(x-x0) + (x1-x0) ) / ( 2*(x1-x0) )
    # doubling ensures symmetry for odd and even ranges
    # this calculation works with unsigned integers, the data type in SB
    # Using P00 (32-bit) for numerator, because it can be large.
    Sub ScaleValue pResult pValue pMode
       Mat I20 = 2 * pMode
       Mat I21 = I20 + 2
       Mat I22 = I21 + 1
       Mat P00 = pValue - KI21   # input reduced to 0
       Mat I29 = KI22 - KI21    # input range
       Mat I2A = 2 * I29
       Mat I21 = I20 + 1
       Mat I2B = KI21 - KI20   # output range
       Mat I2B = 2 * I2B   # doubled
       Mat P00 = P00 * I2B
       Mat P00 = P00 + I29
       Mat P00 = P00 / I2A   # division always last step
       Mat pResult = P00 + KI20
    End
    
    Sub UpdateValues pIndex
       If pIndex == indTempoPB
          ScaleValue theBPM theTempoPB pIndex
       Else
          ScaleValue theTempoPB theBPM pIndex
       End
    End
    
    Sub SendPitchBend pChan pValue
       Mat I20 = E0 + pChan
       Mat I21 = pValue & 7F    # LSB is first in PB
       Mat I22 = pValue / 80   # shift MSB down
       Mat I22 = I22 & 7F     # mask MSB to be safe
       Send I20 I21 I22
    End
    
    End # Initialization ———————————————————————————
    
    If M0 == F0 7D 01     # handle control change
       UpdateValues M3
       SendPitchBend 0 theTempoPB
    End
    

    Changes were minimal aside from the new SendPitchBend sub. And here it is running:

    The SB BPM slider can only be set to integer values, and AUM tempo shows the same integers. This uses the original range of 20 to 240 BPM, no tricky fudging required.

    You should be able to adapt your Mozaic script in the same way. It seems a bit strange to be using PB like this, but it's only between the script and the AUM Tempo mapping. It's just a way of sending a 14-bit value.

    Excellent work @UncleDave. I'm not familiar with StreamByter but downloaded it and marvelled at the tempo changing in nice whole BPM steps as I slid left and right. I'm gonna go find a StreamByter manual and will post an equivalent Mozaic script here when I'm bi-lingual.
    "Seems strange to be doing it like this" is this forum in a nutshell, and that's where the fun is found!

  • @belldu The StreamByter manual is built-in (? icon), and there's a pdf linked from this page. But you don't really need it. The complicated part of my code is just the linear scaling operation. You should just need to update the range in Mozaic to be 0 to 0x3FFF, and figure out how to send a Pitch Bend message. Also, you'll want to change your knob to enter BPM, not CC value, and scale it to the corresponding PB value.

  • edited June 2

    @UncleDave. Trust me I need a manual when a script starts:
    If M0 == F0 7D 01 # handle control change
    UpdateValues M3
    ...

    But I figured it out, along with the curious 'KI21' indirection thing, and the equivalent Mozaic script which syncs a Mozaic knob to AUM tempo is below. Thanks for the help!

    @Description
    AUM volume control
    ------------------
    Usage:
    1. Map this Mozaic script as a Source for MIDI Control in AUM
    2. Map Tempo Transport parameter to PBEND with (default) range 20-240 BPM on desired midiOutputChannel
    3. BPM on knob 0 will be applied to AUM
    
    Thanks to 'Uncle Dave' on AudioBus forum for the clever bits.
    @End
    
    @OnLoad
      // you can set other minBPM and maxBPM values, but if you do, remember to change the range in AUM too.
      minBPM = 20
      maxBPM = 240
      midiOutputChannel = 1
    
      minOutput = 0
      maxOutput = 16383
      params = [minBPM, maxBPM, minOutput, maxOutput, minBPM, maxBPM]
      knobBPM = 0
    
      SetKnobValue knobBPM, Round (TranslateScale (Round HostTempo), minBPM, maxBPM, 0, 127)
      Call @KnobChange_BPM
    
      ShowLayout 0
    @End
    
    @OnKnobChange
      if LastKnob = knobBPM
        Call @KnobChange_BPM
      endif
    @End
    
    @KnobChange_BPM
      BPMValue = Round (TranslateScale (Round (GetKnobValue knobBPM)), 0, 127, minBPM, maxBPM)
      LabelKnob knobBPM, BPMValue
      Call @CalculatePBValue 
      SendMIDIPitchBend midiOutputChannel -1, PitchBendValue  
    @End
    
    @CalculatePBValue
      // needs BPMValue to be set, along with params defining min/max ranges
      // sets PitchBendValue as an output.
    
      offset1 = 2 * 1   // if converting BPM to PB then * 1, vice versa * 0
      offset2 = offset1 + 2
    
      PitchBendValue = ((((BPMValue - params[offset2]) * ((params[offset1+1] - params[offset1]) * 2)) + (params[offset2+1] - params[offset2])) / (2 * (params[offset2+1] - params[offset2]))) + params[offset1]
    @End
    
  • @belldu I thought you could just continue using TranslateScale instead of my tedious formula. That's why I suggested revising your existing code, along with switching the input knob to BPM, since those are the exact values you want. Anyway, glad it works for you. Cheers!

Sign In or Register to comment.