HISE Logo Forum
    • Categories
    • Register
    • Login

    Using panel as keyboard advise....

    Scheduled Pinned Locked Moved General Questions
    1 Posts 1 Posters 246 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ulrikU
      ulrik
      last edited by

      I have this code on the init callback, it's a panel divided into zones where the different zones trigger NoteOn and NoteOff values, they also trigger some GUI stuff and what I want is to separate the GUI stuff from the mouseCallback events which are the most important and need to be as fast as they could be.
      As I understand it, I'm not able to use the audio thread for the mouseCallback so how would you do to separate them and set the NoteOns and Offs to highest priority?

      Here's an excerpt from the code:

      function NoteOn(n,v)
      {
          if(n>=0 && n<playBack.length)
          {
              id = Synth.addNoteOn(1, playBack[n], v, 0);
              Message.makeArtificial();
              cxList[n] = cx;
              idList[n] = id;
              KeyArr[n].set("itemColour2", col2);
              KeyNameArr[n].set("enabled", true);
          }
          
      }
      
      function NoteOff(n)
      {
          if(n>=0 && n<playBack.length)
          {
              Synth.noteOffByEventId(idList[n]);
              KeyArr[n].set("itemColour2", col1);
              KeyNameArr[n].set("enabled", false);
              cxList[n] = "";
              idList[n] = "";
          }
          
      }
      KeybPanel.setMouseCallback(function(event)
      {
          x = event.dragX;
          c = event.mouseDownX;
          cx = Math.floor(((c + x) * playBack.length) / KeybPanel.get("width"));
          //p = (c + x) - parseInt(borderList[cx]);
          
      	if(event.clicked == 1 && idList[cx] == "")
          {
              v = 127 - Math.floor((event.mouseDownY + event.dragY) / KeybPanel.get("height")* 126);
              NoteOn(cx,v);
              
              //Synth.setVoicePitchValue(playBack[cx], p);
              //Console.print("c "+c);
              //Console.print("cx "+cx);
          }
          
          if(event.drag == 1)
          {
              //Console.print("p "+p);
              if(cxList[cx] == "" || typeof cxList[cx] === "undefined")
              {
                  v = 127 - Math.floor((event.mouseDownY + event.dragY) / KeybPanel.get("height")* 126);
                  NoteOn(cx,v);
              
                  if((c+x) > borderList[cx])
                  {
                      NoteOff(cx+1);
                  }
                  else if((c+x) < borderList[cx])
                  {
                      NoteOff(cx-1);
                  }
              }
              //Synth.addPitchFade(idList[cx], 100, 0, p*0.2);
          }
          if(event.mouseUp)
          {
              var evX = Math.floor((event.x * playBack.length) / KeybPanel.get("width"));
              NoteOff(evX);
              //Console.print("evX "+evX);
          }
      

      Hise Develop branch
      MacOs 15.3.1, Xcode 16.2
      http://musikboden.se

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      58

      Online

      1.7k

      Users

      11.7k

      Topics

      102.1k

      Posts