Trigger Audio Loop Player With Specific Midi Note



  • Happy Friday All,

    I'm trying to set up multiple audio loop players but have each one triggered by a specific midi note.

    For eg:

    Audio Loop Player 1 = C1
    Audio Loop Player 2 = C#1
    Audio Loop Player 3 = D ...etc

    I know it could be done the usual way in a single sampler having all of the samples mapped to the notes, but I'm using different audio loop players for each sample as I'd like to have a separate waveform on the GUI for each sample and also let the user be able to load in their own samples.

    Where would be the best place to start for this scripting wise?

    I've tried a few ways around 'if / else' commands using Synth.playNote(noteNumber, 60)); but got them all totally wrong. I'm not sure which noteNumbers apply to C1, C#1, D anyway so I'm just guessing.

    I'm thinking it could maybe also be code needed in a script processor inside the midi processor of the player and using onNoteOn commands... but again I'm just clutching at straws 不

    Could anyone please point me in the right direction on how to start the code for this, and which note number C1 would be? (or if it can be done with a midi processor an easier way as well?)

    Thanks all.

    PS: Sidenote, (if it's important at this stage)... I'd also like to keep the audio loop players 'pitch-tracking' set on if it's possible, but still have the sample play at its original pitch when triggered by its midi note. (I'm pretty sure that could be done if the root note was just changed by a couple of steps on the slider in the audio loop player?) The reason for this is because I'm thinking of adding an arpeggiator to each audio loop player and making use of the 'velocity' section linked to a slider pack to use as a kind of step sequencer, and also the 'note numbers' section to pitch up and down samples also in a step sequencer'ish way)

    I have a basic snippet with 2 audio loop players set up here

    HiseSnippet 1185.3oc6X0sahaDEdLfqJoak51tUpWZU0KRj1FrA1.R8hRR.1h1PVTHaZW0KVMwd.OB6YrFOFBppuQ8gn8MnOB8QnuAsmwleL6Rn.pIMpKbEy4LGy24uuywzQvsIggbARK+kiCHHsGo2cLS5dpKlxPspiz9DcqiL5fcL5h8C7HBzIiCvggDGjlV1mqtkV9bn3O+42dB1CyrIyEgPWwo1jyn9T4bocp8BpmWSrC4RpepaWtVKaN6TtGOBPTVcST.1d.tO4br5ZYzQZePCGpjK5JwRRHRK2Ibmwcc4iXI2+JZH8ZOh5fEpK7fRD2j64nPrRJ5TWpmSmoddHBdnclGGxlDGdhdapCcl7zwCkBi4VjN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6ieCersf+F6j+MQUs7GFKA7aV77875sUmMl8OipqadnILN1g9FaaU39qsPnkaSwsvlRagMk2Bad1VXyQagMU1BaptRaT6Sbbjj6mzJBB5zH9uJUSa1tdZYQ+sj689K
    


  • I'm still going round in circles on this one 不



  • I've managed to get the step sequencer and pitch sequencer going now and a bunch of other controls. So far, so good there. I still can't work out how to trigger each player with a specific midi note yet though...



  • Still no joy yet. Can anyone help, please?



  • This is the closest I've got so far that kinda makes sense but it's still playing all of the midi notes, not just C1.

    My audio loop player is named 'PlayerPad1'

    In the players midi script processor, in the onInit I have:

    const var PlayerPad1 = Synth.getAudioSampleProcessor("PlayerPad1");
    

    ...and in the onNoteOn I have this...

    function onNoteOn()
    {
    	if(Message.getNoteNumber() == 12)
        {
            var timeStamp = Message.getTimestamp();
            PlayerPad1.play(timeStamp);
            Message.ignoreEvent(true);
        }
    }
    

    ...but it still plays when any note on the keyboard is played. For this player I'm hoping to only have C1 trigger the sample, and then the next player will be C#1 with midi note 13, and so on.

    Can anybody tell me what I'm doing wrong?



  • @SteveRiggs said in Trigger Audio Loop Player With Specific Midi Note:

    var timeStamp = Message.getTimestamp();

    I'm not familiar with the loop player but change that var to a local.

    And if you want it to ignore notes then you need to use Message.ignoreEvent(true); for all the notes you want to ignore, not just C1.



  • @d-healey Thanks man.

    I've changed the 'var' to 'local' in the onInit of the midi processor for the audio loop player.

    It's C1 that I'd like to trigger the audio loop player for this one and have every other note ignored if possible.

    How do I go about referencing all of the other notes that I'd like ignored? Do I need to have a string with 0, 1, 2, up to 127 inside brackets somewhere, but just miss out the note number I want to use?



  • @SteveRiggs
    You're over thinking it

    if(Message.getNoteNumber() == 12)
        {
            var timeStamp = Message.getTimestamp();
            PlayerPad1.play(timeStamp);
            Message.ignoreEvent(true);
        }
        else
            Message.ignoreEvent(true);
    

    Actually since you want to ignore all notes you could just put it outside of the if statement.



  • @d-healey said in Trigger Audio Loop Player With Specific Midi Note:

    You're over thinking it

    I had a feeling I would be 不

    Thanks man. I've added that into the midi script processor but all the keys are still triggering it and I'm getting this error in the console...

    Script Processor1:! Line 1, column 25: Call of getNoteNumber() outside of onNoteOn / onNoteOff callback {U2NyaXB0IFByb2Nlc3NvcjF8fDI0fDF8MjU=}
    


  • @SteveRiggs Post your on note callback



  • @d-healey I have it like this:

    function onNoteOn()
    {
        
    if(Message.getNoteNumber() == 12)
        {
            var timeStamp = Message.getTimestamp();
            PlayerPad1.play(timeStamp);
            Message.ignoreEvent(true);
        }
        else
            Message.ignoreEvent(true);
    

    It's in the midi processor though. Not sure if thats correct now...

    Screen Shot 2019-11-01 at 23.58.10.png

    Screen Shot 2019-11-01 at 23.58.17.png



  • You're missing the closing }



  • @d-healey Silly mistake!

    I've added the last } in now. The console error is gone and it compiles but all the keys are still triggering the audio loop player



  • I don't see a play function for audio processor in the API help. You sure that's right?



  • I just built a little test project. I'm pretty sure this is all you need in the on note callback, and you don't need anything in on init.

        if (!Message.getNoteNumber() == 12)
            Message.ignoreEvent(true);
    


  • @d-healey Weird man. Tried that as well but still all notes triggering.

    I have a snippet here if it helps? The sample might not be loaded but any thing will work.

    HiseSnippet 2800.3oc6aszcaabEdnkFaQYKYIa2WmSWftoGoSikHojrraZhAEeXxJRJXQ4Gsm1ZCALjDVfXP.AnDSZZT6oKx11Mca9KzUcYS+G3bxug1Mdi+GzNC.Hv.PPJHX4TIerVnilG267cuyL2WCjfAVB0qG1.jJ8dCzQfTWC1bflYmBcDUz.UKBRs.L6c3DDk4ZJ1UWEY.1ZftXudHYPpTS8.5rRkdZf8Ou99aIpJpIg76B.dLVQBUSoqhoeuB7aqnpVVTFsmRWlYuNeUIrVArJ1hfnofY.5hRGH1F0PjNsKAAotbIYESrQSSQSTOPpo2BKOnYG7gZNy+wJ8T1WEQajEzjvHmtKiUkoHl1KnPGEUYggRdO.HETvWOLkid3Vv5JxJd8ypOnCv4SAq9H0klD7xxBuLwGdoXf2zNvaQXSICEcS+QnX6pvpZlHiVhjs.VX4LWPp+Er.lLAMyU5Jd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j.ZtSBnYyDPycmHMzG2OukItqycLRGBkbRUOk2WXQpo.+O.c5jWBA
    


  • Sorry my fault.

    	if (Message.getNoteNumber() != 12)
    	    Message.ignoreEvent(true);
    


  • @d-healey said in Trigger Audio Loop Player With Specific Midi Note:

    if (Message.getNoteNumber() != 12)
    Message.ignoreEvent(true);

    No worries. All the notes are still triggering it though. Should that make just C1 trigger and all other notes be ignored?



  • This snippet is working for me

    HiseSnippet 1004.3oc4W0saiSDEdllXVRDKhksWvkFIPJUBZhK6tfDBQaSSgHZ5FUWV3tnYsOIYnimwZ73ThPvqEuF7Fvq.7D.mwNt1YWqR1HQWIvW44aNmwemeluY7XsJ.RRTZBs0kKiAB8sb7WJMy6OmwkjgmPnusyHVhAzt4PGuLlkj.gDJswWYAnsZRxd9iu7XlfICfRHB4YJd.bFOhaJQGe32vEhSYgvk7nJV+nCGFnj8UBUJxmFN8HwrfqXyfyYVy1wgPeiAgbiR6aXFHgPadrJbo+b00xb6eFOg+bAXG3Q7wEJG9TkHzxX66j9y4hvwEwcBgPcFWlEZjmE10YDOjeCdY13cxlvszip4C5N2F87pRud0ROuZnGoB6ZlyNjDpvTAyrNyrkiUSvUqWoFJMfLgaVVsb8ZktOvYL2DLud9tSM7EKT+ay2UE+66LX5THvTR1lNm982sU5GVPkiRC4pyTpXPmQkcyQbsPtiErkf16V1T9aa5lx3MdSIpODfkMnZqTVs7RMtckKmU8SYo4.ICyEgUs+Bkxbtx.UEE7YQwB.ynZCt7UWjKfEfNAVC6TtXktvu3zMBB4rtgrEP2uSoux0qKlJ+ArDlfiUgWykgIc8US4rIki+5g9C5l+QS5FHXZtDLdcSRSLXJrDYxJjIABUBL4wGLIbojEwCNX+qYKHQ1zsC0xoH1OZe8W+vlDAF2YghE3d+IMCXfLrXdZiMtAppR15awqXeMxZMeMHq8Jn5ReYghG33Gn4wlxYrb6gqPKY25M74yRn+ti6zTYfMw3pj1tqmJ6rW6epcK9T2NiPOwiR1eFj03cdZzyAcm8be+uv06f8te6Vt3SgQ7YRkFFr.jlNFcJr2m29ma+Rq9zo4K+KLWekznUBgc4qYZ61K8s4XGYF29H2ELA9oKLDyRqWFZuYkAb2KpkZpXnRNTxMOMFVcpYQxp.wibS.V0nx3pJZV3TiYkP0Hz0OmS3ae6vSXFlscXEFZGJ0Y31HjdBr.UpxaNZ4bBjbkQEeGdhXiMSV+en6tUAG84VwlAxEf.CxLN9tXTMkkJLEnq2aORIUwyURdv55gFMe1LPWk60FPGYLnlbIxtGdAH.VREg2O3vyPYNl9EkzeExEdadt31pWumSNccs8Tt+23lLM9+4MYtPkZvaBLhgMp1yDQ4Ve7BDA.xDoDDI1yA2wpDjOtWwQn9fLLavegOqlzyNltZRuhIuS9FQr.sZRPtjlsW9MyPv3Vlc2iV3OGgic8HYh0neN81uGdmfP9jf.a59i8Hj584fsvmOYK74QagOOdK74IagOe5V3ymcq9XuGyQoFUT9VQDX7friXnzatGJsA4uAzKcC3M
    


  • @d-healey

    That's weird. That one works for me as well.

    I just tried that with mine and it seems to stop working when the arpeggiator is turned on. Is there any way of getting around that?


Log in to reply
 

4
Online

551
Users

2.1k
Topics

16.1k
Posts