HISE Logo Forum
    • Categories
    • Register
    • Login

    MIDI Player overlay panel LAF

    Scheduled Pinned Locked Moved General Questions
    lafmidi notemidi player
    6 Posts 2 Posters 81 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.
    • R
      rzrsharpeprod
      last edited by

      Good morning,

      Is it possible to change how the MIDI player notes look in an overlay panel/floating tile using LAF?
      I have had a look around the functions as well as looking on this forum and can't see an obvious candidate.

      I would just like to change the look a little, round the edges of the notes, maybe have a colour fade on them if possible but can't seem to find where to do this.

      Thanks in advance

      HISEnbergH 1 Reply Last reply Reply Quote 0
      • HISEnbergH
        HISEnberg @rzrsharpeprod
        last edited by

        @rzrsharpeprod Yes you have to display them in a panel and use a paint routine. I'll share a script for this shortly!

        HISEnbergH R 2 Replies Last reply Reply Quote 1
        • HISEnbergH
          HISEnberg @HISEnberg
          last edited by

          Here you go, this shows how to display the MIDI data in a panel. I think there is also an example in the HISE docs under MIDI somewhere. My version tries to scale the MIDI data to fill the whole panel, so it should resize the notes depending on how far they are from each other (in pitch, not time) in the MIDI sequence. But this will give you full customization over how the notes are displayed using the paint routine.

          HiseSnippet 2161.3ocyXr1Siqb0AVu8RZ2pck5O.28CW4rKXrSBPPnaK4II.IjMIvBrZ6dGrmDOA+B6IgXp1+a89s9mX+OTU0uVs8L1N1NA1GBcuR0BgxbdMmWy4bloqqsJ1yy1kKS1A9NXtL+A999VT8p5HhEWqZbYdFuIQiTi34Xf74p36f77vZbYxr5ALRxr1S3B99W+0JHCjkJNADG2Y1DU7wDSBMAZ28OhXXz.ogGPLSQcw8aoZaU01vdBnNqxKy4fTuFMB2AwHaEdtlHOctLuheq7ETKpsiV97as61pnsw6NDMbnRAshE2tztJE1EUrz1X4s3x7z5ZDpsaeJhh83x7jJ1Z980su0JbCNi3Qtx.yVnv0G14PvMrMzXlHCJWUchgV249IONPJcS7ZqF509S7sAmTL7Du2y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Lne5Se5WVDZdFXNtO+QFXJdFMg3OCegurx8lN947ss0XM3W7MIXubSDBHltvDxrofsfbP+Et792+CUH+0u792oJ9B9tDpp9Cqiq7.5H6s.9MPGiddmmwWe3P37ahB9D9Fm+XeKmuw1GNV+HXHFWBjdwCMa6CQZULql.jI5wRiVgkwGtVlsl4A5iszBVvRHhPpvVmIBoxbjblHUW6OnFdRl8PJ+P.DPmrBth4Z7sYqET3BNcm1OydMvOnptnntGi4erLV3wxXwGKia8XYb6GKi67XYrz2lQVwoxSn1lgGa33Z2sd3qljI945xrJ2+CqyWNGC
          
          Content.makeFrontInterface(300, 200);
          
          const var MIDIPlayer1 = Synth.getMidiPlayer("MIDI Player1");
          const var pnl_MidiDisplay = Content.getComponent("pnl_MidiDisplay");
          
          pnl_MidiDisplay.setPaintRoutine(function(g)
          {
              g.fillAll(this.get("bgColour"));
              
              // Scale the MIDI data to fill the panel
              var noteList = MIDIPlayer1.getNoteRectangleList([0, 0, this.getWidth(), this.getHeight()]);
              var minNote = 127;
              var maxNote = 0;
              
              // Only proceed fill if there is MIDI data
              if (!MIDIPlayer1.isEmpty() && noteList.length > 0)
              {
                  for (note in noteList)
                  {
                      var noteNumber = note[1];  
                      minNote = Math.min(minNote, noteNumber);
                      maxNote = Math.max(maxNote, noteNumber);
                  }
                  
                  // Calculate display parameters
                  var noteRange = Math.max(1, maxNote - minNote);
                  var panelHeight = this.getHeight();
                  var availableSpace = panelHeight / (noteRange + 1);
                  var noteHeight = Math.max(8, availableSpace);
                  
                  // Draw notes
                  for (note in noteList)
                  {
                      // Note data
                      var xPos = note[0];
                      var originalNoteNum = note[1];
                      var width = note[2];
                      
                      // Remap the Y position to fit the display range
                      var normalizedPos = (originalNoteNum - minNote) / noteRange;
                      var yPos = normalizedPos * (panelHeight - noteHeight);
                      
                      var noteRect = [xPos, yPos, width, noteHeight];
                      var shadowRect = [xPos + 1, yPos + 1, width, noteHeight];
                      
                      // Draw note
                      g.setColour(this.get("itemColour"));
                      g.fillRoundedRectangle(noteRect, 2.0);
                      
                      // Draw note outline
                      g.setColour(0xAAFFFFFF); 
                      g.drawRoundedRectangle(noteRect, 1.0, 1.0);
                  }
              }
              
              // Draw playback position indicator
              var playbackPos = MIDIPlayer1.getPlaybackPosition() * this.getWidth();
              g.setColour(this.get("itemColour2"));
              g.drawLine(playbackPos, playbackPos, 0.0, this.getHeight(), 2.0);
          });
          
          MIDIPlayer1.connectToPanel(pnl_MidiDisplay); // Connect to panel
          MIDIPlayer1.setRepaintOnPositionChange(true); // Repaint Panel
          
          
          

          giffy.gif

          1 Reply Last reply Reply Quote 3
          • R
            rzrsharpeprod @HISEnberg
            last edited by

            @HISEnberg

            @HISEnberg said in MIDI Player overlay panel LAF:

            Here you go, this shows how to display the MIDI data in a panel. I think there is also an example in the HISE docs under MIDI somewhere. My version tries to scale the MIDI data to fill the whole panel, so it should resize the notes depending on how far they are from each other (in pitch, not time) in the MIDI sequence. But this will give you full customization over how the notes are displayed using the paint routine.

            HiseSnippet 2161.3ocyXr1Siqb0AVu8RZ2pck5O.28CW4rKXrSBPPnaK4II.IjMIvBrZ6dGrmDOA+B6IgXp1+a89s9mX+OTU0uVs8L1N1NA1GBcuR0BgxbdMmWy4bloqqsJ1yy1kKS1A9NXtL+A999VT8p5HhEWqZbYdFuIQiTi34Xf74p36f77vZbYxr5ALRxr1S3B99W+0JHCjkJNADG2Y1DU7wDSBMAZ28OhXXz.ogGPLSQcw8aoZaU01vdBnNqxKy4fTuFMB2AwHaEdtlHOctLuheq7ETKpsiV97as61pnsw6NDMbnRAshE2tztJE1EUrz1X4s3x7z5ZDpsaeJhh83x7jJ1Z980su0JbCNi3Qtx.yVnv0G14PvMrMzXlHCJWUchgV249IONPJcS7ZqF509S7sAmTL7Du2yCPHjvQZGXlUVT8VcA0S4KodOfJsRJU52MOPFnRPPC6FnJ+Q91sp0RHDhxBJR0IttXKZe7MSvKFA2OB0.WHVjNXerssScKDndZoAyj9U.o8cvKhHyp+JYqbLypAw.GX2y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eKmuw1GNV+HXHFWBjdwCMa6CQZULql.jI5wRiVgkwGtVlsl4A5iszBVvRHhPpvVmIBoxbjblHUW6OnFdRl8PJ+P.DPmrBth4Z7sYqET3BNcm1OydMvOnptnntGi4erLV3wxXwGKia8XYb6GKi67XYrz2lQVwoxSn1lgGa33Z2sd3qljI945xrJ2+CqyWNGC
            
            Content.makeFrontInterface(300, 200);
            
            const var MIDIPlayer1 = Synth.getMidiPlayer("MIDI Player1");
            const var pnl_MidiDisplay = Content.getComponent("pnl_MidiDisplay");
            
            pnl_MidiDisplay.setPaintRoutine(function(g)
            {
                g.fillAll(this.get("bgColour"));
                
                // Scale the MIDI data to fill the panel
                var noteList = MIDIPlayer1.getNoteRectangleList([0, 0, this.getWidth(), this.getHeight()]);
                var minNote = 127;
                var maxNote = 0;
                
                // Only proceed fill if there is MIDI data
                if (!MIDIPlayer1.isEmpty() && noteList.length > 0)
                {
                    for (note in noteList)
                    {
                        var noteNumber = note[1];  
                        minNote = Math.min(minNote, noteNumber);
                        maxNote = Math.max(maxNote, noteNumber);
                    }
                    
                    // Calculate display parameters
                    var noteRange = Math.max(1, maxNote - minNote);
                    var panelHeight = this.getHeight();
                    var availableSpace = panelHeight / (noteRange + 1);
                    var noteHeight = Math.max(8, availableSpace);
                    
                    // Draw notes
                    for (note in noteList)
                    {
                        // Note data
                        var xPos = note[0];
                        var originalNoteNum = note[1];
                        var width = note[2];
                        
                        // Remap the Y position to fit the display range
                        var normalizedPos = (originalNoteNum - minNote) / noteRange;
                        var yPos = normalizedPos * (panelHeight - noteHeight);
                        
                        var noteRect = [xPos, yPos, width, noteHeight];
                        var shadowRect = [xPos + 1, yPos + 1, width, noteHeight];
                        
                        // Draw note
                        g.setColour(this.get("itemColour"));
                        g.fillRoundedRectangle(noteRect, 2.0);
                        
                        // Draw note outline
                        g.setColour(0xAAFFFFFF); 
                        g.drawRoundedRectangle(noteRect, 1.0, 1.0);
                    }
                }
                
                // Draw playback position indicator
                var playbackPos = MIDIPlayer1.getPlaybackPosition() * this.getWidth();
                g.setColour(this.get("itemColour2"));
                g.drawLine(playbackPos, playbackPos, 0.0, this.getHeight(), 2.0);
            });
            
            MIDIPlayer1.connectToPanel(pnl_MidiDisplay); // Connect to panel
            MIDIPlayer1.setRepaintOnPositionChange(true); // Repaint Panel
            
            
            

            giffy.gif

            That's fantastic thankyou, I will have a play with this but it is exactly what I was looking for and opens up a world of options.

            Thanks again, much appreciated

            R 1 Reply Last reply Reply Quote 0
            • R
              rzrsharpeprod @rzrsharpeprod
              last edited by

              @HISEnberg

              This is doing what I would like for the most part thankyou, I just have 1 issue now.

              Because of the way the notes are drawn and the height is calculated, when I use my transpose script all of the notes move as expected except for the lowest notes in the MIDI. They move sound wise but visually they don't. I think this is something to do with the fact that notes are drawn to start at the bottom of the panel but I can't for the life of me figure out how to uncouple it so all the MIDI notes move.

              Hopefully this illustrates what I mean:
              Original
              fd2a8feb-70c8-4821-aa6a-bcbbf7b251bf-image.png
              Transposed up but the lowest notes stay at the bottom of the panel
              984756b8-276d-41a2-b0bc-a82dfe8018ba-image.png

              In this other script example that doesn't look as good and I can't set the note height, all of the notes move together when transposed which is what I am looking for.
              Original
              c29fc6ad-7537-4f0a-a1f6-76c60d458cee-image.png
              Transposed
              ce5c0ab7-9f4f-4439-8dfa-96f64fb2c04f-image.png
              As I say I know it is something to do with how the note height is calculated being linked to the height of the panel but I can't figure out how to uncouple it so I can still have the nicer note height without it being tethered to the bottom of the panel.
              Would you be able to help me please?

              HISEnbergH 1 Reply Last reply Reply Quote 0
              • HISEnbergH
                HISEnberg @rzrsharpeprod
                last edited by HISEnberg

                @rzrsharpeprod said in MIDI Player overlay panel LAF:

                when I use my transpose script

                How are you transposing the notes? If you are using the transpose module it should be automatically get placed after the MIDI Player. Are you using a custom script processor?
                I'm not able to recreate the behaviour you described so if you shared a snippet it might help.

                If you minimize the range of the min and max Note, I think this should give you the behaviour you want, so change:

                var minNote = 127;
                var maxNote = 0;
                

                You can also edit this line to simply draw the note’s height in a fixed range (instead of dynamically resizing it

                var noteRect = [xPos, yPos, width, noteHeight];

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

                26

                Online

                1.8k

                Users

                12.1k

                Topics

                105.7k

                Posts