Adding a compile button to the interface?



  • Is it possible to create a button on the interface to compile the script?...
    and will that even work once exported to vsti?
    (Looking for a solution for my “randomizing midi player” button)

    Once the tempo is changed via the host/daw my randomize button throws the midi sequence all off, but when I compile in the same scenario the midi sequence is randomized and still In sync with the host/daw. So that’s the reason for the question.



  • bump bump



  • Is it possible to create a button on the interface to compile the script?...

    No

    and will that even work once exported to vsti?

    No

    Once the tempo is changed via the host/daw my randomize button throws the midi sequence all off

    Sounds like a problem with your script.



  • @d-healey here is the part that's causing the problem, the midi sequence does not sync once I change the host tempo.

    //random button - example//
        inline function onButtonranControl(component, value)       
            
    {
          for(note in list) 
    
          {
              if(note.isNoteOn())
    
           note.setTransposeAmount(Math.random() > 0.5 ? 0 : -12)
    
         > note.setTimestamp(note.getTimestamp()   
         + Engine.getMilliSecondsForQuarterBeatsWithTempo(-1, -100.5));
         
    
    }
          MIDIPlay.flushMessageList(list);
         
               
    };
    Content.getComponent("Buttonran").setControlCallback(onButtonranControl);
    
    
    


  • @BWSounds You don't have brackets for your if statement, so only the line immediately after it will take the if into account, is that what you want?

    You're missing a semi-colon at the end of this line note.setTransposeAmount(Math.random() > 0.5 ? 0 : -12)

         > note.setTimestamp(note.getTimestamp()   
    

    What's with the >?



  • @d-healey
    thats not what I want.. the > and + is me trying to make this script work..I guess trying different things.

    even when I do this (below) change the tempo and hit my random button it does the same thing..

          inline function onButtonranControl(component, value)       
            
    {
          for(note in list) 
    
          {
              if(note.isNoteOn())
    
           note.setTransposeAmount(Math.random() > 0.5 ? 0 : -12);
    }
          MIDIPlay.flushMessageList(list);
                  
    };
    Content.getComponent("Buttonran").setControlCallback(onButtonranControl);
    
    

    picture view
    alt text
    alt text
    alt text



  • Let's get some brackets { } for your if statement so we can make sure everything you want to be affected by it is.

    What is triggering your button when the tempo is changed?



  • @d-healey
    I created a snippet.. when the tempo is changed I click my random button and the sequence is off.. but if I hit compile in a new instance it does the same thing but the sequence is not off tempo.. The snippet might make more since of things.

    HiseSnippet 2016.3oc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QRmYnqcme3QtRrSbrndQUR9tcURhOqHBqy8pjGN3HhxOmVehnesndg6LE1p3cZAvwCFluRH.Vgm5OtH0UI2UME2A8.rAmheRa7Fb80D+U79ED9m+NQTTbvFW4saV8XaHZZq3AQSkC6YGZo+TxSIkN1ZuYu09xwTRrm9miFptyJfC95QWEDvjXxz8uF4pWhE+uE5.POf0Qpe4Ke4WdL0Lgjw8AhHGkkRjKYzM9aNbbTS6l2Q93ZduMRhZHMvFLuz3qbDmojO94G1Z9lgMQN8MIgODaGCLB+Qk8CKsibgdAOZR9m9CUnexui5o5tuIYWnmpw482KNi+F9Hgem82cO660IKqqCT8N5ruHo3vm6a79evUt21ODmhKp6.2DOTgDFKoBvdBBiDcCQrWDhXiWSGtNLyHAPZQK9E72NloCWmXGyz6YRXon5X+ypwW8Ce40eHhB1mPQiAcE9g930jo2eeOYRZJZB7TOveVUMLU7CXe+75j4YnCyyPmrOCcXeF5j6YnS9mgNE9l5DVOpjumsU70DLgtkiqnj3vyySbIw+QNvruE
    


  • @BWSounds Does the tempo go off if you don't click the button?



  • @d-healey
    if I dont click the button everything is ok.. but the button is the only way i can randomize the sequence.



  • @BWSounds What happens if you remove this line note.setTransposeAmount(Math.random() > 0.5 ? 0 : -12);



  • @d-healey
    same thing, the sequence stays the same but the length of it is changed.



  • @BWSounds So the only thing that is causing the problem is this MIDIPlay.flushMessageList(list); I guess it must be a bug or an intended behaviour. I haven't used the MIDI player myself so I'm not familiar with this function. @Christoph-Hart Will know the answer.



  • @d-healey
    Ahh, well thank you for your help!



  • @Christoph-Hart
    any insight would be greatly appreciated.



  • @Christoph-Hart - any insight would be greatly appreciated.

    Bump Bump 🙂



  • I'll try one more time 🤷♂ ...Bump
    (I've tried everything, just cant be done yet I guess)



  • https://docs.hise.audio/hise-modules/midi-processors/list/midiplayer.html#using-the-midi-player

    The timestamp will use the current tempo and samplerate to be consistent with the rest of the MIDI processing in HISE. So if you have quarter notes at 44,1kHz and 120BPM, you will get these timestamps for the first bar:

    This is your problem right here. The timestamps in your list have the old tempo baked in. In order to solve it, recreate the list at each randomization (however then the randomization will "stack up"):

    inline function onButtonranControl(component, value)              
    {
        list = MIDIPlay.getEventList();
    
        for(note in list) 
        {
            if(note.isNoteOn())
                note.setTransposeAmount(Math.random() > 0.5 ? 0 : -12);
        }
    
        MIDIPlay.flushMessageList(list);          
    };
    Content.getComponent("Buttonran").setControlCallback(onButtonranControl);
    


  • @Christoph-Hart
    Ahh oK.. I took a quick look, but im getting this error
    Can't assign to this expression!

    I'll look deeper into this error and try to fix it.



  • You probably have declared the list as const var. Use reg instead.


Log in to reply
 

5
Online

702
Users

2.8k
Topics

23.7k
Posts