HISE Logo Forum
    • Categories
    • Register
    • Login

    Midi Activity Led

    Scheduled Pinned Locked Moved Solved Scripting
    22 Posts 5 Posters 2.0k 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.
    • ustkU
      ustk
      last edited by

      Hi,
      Could someone try this little snippet, please?
      It just gives me a black tile with the MIDI label inside, the images never appear (the .png are under the Images folder)

      HiseSnippet 836.3ocsUszaSCDDd2l3nl.AnHNvQqbpUpTkzVdH3.oMOPARaBMgB2p1XuNYUs20xdcaip5eL3B24OC+CJyZ6T6PCgZjvm77Myry2Nu19dBCpuuvCgKNbpKEguu1fob4jFSHLNpSSD9AZGP7kTO8Hn8m5R78olHLN26T.3h4Qge+7s6SrIbCZBDBcrfYP6xbXxDz90+.y1tMwjNj4jx5cq2wPvaHrEA.exoUE4RLNkLldHQY1JZHbgVlLovafjHo9Hb98ElSGLQbNOx9iY9rQ1TkPMz.3fhfaKrMULVghZLgYa1e181GAmR+jrPtnrvSzNfYxtAOIa7nPE5IdjNefWYYzq1emdUWD8vonW9H5sl1.COlqLQiha2SqCGJTVDnDjlVQ1hveSqg.LfK2xgbJssGHbiCquS0papuc0pa7Fq.tgjI35B9gBIsGe8MJcYohktpzuqwxZQpTAwSXaS8VjVUI2aItsNOvYD0aS8yH1AzY1A274SsEtaoVinKbJCE7NblrmKMVd48Fn3LF72m5zjHIp5QLFXmK0SxTzA2jdFznGUcJp0j5epT3FZqiqfqNAbAYn1xypcDN0FwfPupV3+0PWjLKrU8oIBOs94LS4DDVC+XLBMgxFOQpj9JBMeLJKiaeihQaaAQx3iGxfTiJTOTKMT5HV+yoi3Gq6R7fSL0QeCKi4Rxz7L9jfDmgFFeg2CpwmwjS6BI5QimMfWrvO990WqbfIoNKCc6zvR5ExaabXsAet1kkKoqWA5L63.KNp7Z8JW1+nduuUigmztW2lsN5JgkEvisb4iqrYjw7+rs74MU0Gol+6RFQsAGjdAzxktBtx2ZDEVTHLCrIx42dnVYFq.Z6maLUMKx8gzT5UpYXkR067Fu6JcWSqOSZLYw7ckEvWna7+MeyMqopkkE0PlP17Zs+x+513LPkiDApwmCHROFL8ncXfy.nWzfBLgCyG9p4xUTaNhjqpjUYlATtYnv0vWrxZJYbrxZyThbHFdhSLhVHpdBX0PDfS7vWBKBOICx50PgKIi3sCzWdhggJQ7Lf4K1isyrG6jYO1Myd77L6wKxrGuLyd7pk3gZIvdARgSzXA.zuUzJHbKNA5pB6.Q+Bn5DBRN
      

      midiActivityLed.jpeg
      offLed.png
      onLed.png
      Cheers

      Can't help pressing F5 in the forum...

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        Seems to be broken

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 0
        • Christoph HartC
          Christoph Hart
          last edited by

          I've created a GitHub issue for this:

          Link Preview Image
          Check MIDI activity floating tile · Issue #118 · christophhart/HISE

          as described here: https://forum.hise.audio/topic/1283/midi-activity-led/2

          favicon

          GitHub (github.com)

          I'll close it when it's fixed, so you can keep track of it.

          1 Reply Last reply Reply Quote 2
          • ustkU
            ustk
            last edited by

            @Christoph-Hart Thanks! 👍

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 0
            • NatanN
              Natan
              last edited by Natan

              Is This Fixed?
              Or is There any Alternative way to Show Activity, For example, Painting a Panel, and Connecting it to Midi On/Off?

              Update!
              It was a very simple Task To Achieve, Just Need An Extra Line on Note on/off to show hide an Image, and Yeah it 😉

              1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey
                last edited by

                This still appears to be broken. I've made a test project using Greg's snippet and images.

                midiActivityTest.zip

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                clevername27C ustkU 2 Replies Last reply Reply Quote 1
                • clevername27C
                  clevername27 @d.healey
                  last edited by

                  @d-healey Bump.

                  1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @d.healey
                    last edited by ustk

                    @d-healey I've made some progress on this in FrontendPanelTypes, and it seems the images are somehow not loaded properly.
                    If I just paint the background with a colour it works:

                    void ActivityLedPanel::paint(Graphics &g)
                    {
                    	g.fillAll(isOn ? Colours::red : Colours::black); // THIS WORKS
                    	g.setFont(getFont());
                    
                    	if (showMidiLabel)
                    		g.drawText("MIDI", 0, 0, 100, getHeight(), Justification::centredLeft, false);
                    
                    	if (auto img = isOn ? on.getData() : off.getData()) // maybe getData() doesn't works or the problem is in the header...
                    	{
                    		g.drawImageWithin(*img, showMidiLabel ? 38 : 2, 2, 24, getHeight(), RectanglePlacement::centred);
                    	}
                    }
                    

                    Can't help pressing F5 in the forum...

                    1 Reply Last reply Reply Quote 1
                    • ustkU ustk marked this topic as a question on
                    • ustkU
                      ustk
                      last edited by ustk

                      @Christoph-Hart Need a wee bit of help trying to upgrade the ActivityLedPanel for using a custom path instead of an image...

                      I got it to work when loading a path directly in the constructor but I get an 'Array<juce::var>' to 'const void *' conversion issue when I want to load the path from the Data object:

                      Screenshot 2022-12-09 at 01.24.57.png

                      void ActivityLedPanel::fromDynamicObject(const var& object)
                      {
                      	FloatingTileContent::fromDynamicObject(object);
                      
                      	showMidiLabel = getPropertyWithDefault(object, (int)SpecialPanelIds::ShowMidiLabel);
                      	useMidiPath   = getPropertyWithDefault(object, (int)SpecialPanelIds::UseMidiPath);
                      
                      	auto data = getPropertyWithDefault(object, SpecialPanelIds::MidiIconPathData);
                      
                      	if (data.isArray())
                      	{
                      		midiIconData.clear();
                      		midiIconData.addArray(*data.getArray());
                      	}
                      
                      	 midiIconPath.loadPathFromData (midiIconData, sizeof(midiIconData)); // -> No viable conversion from 'Array<juce::var>' to 'const void *'
                      }
                      

                      Declared in class as:

                      ===== class ActivityLedPanel ======
                      
                      private:
                      	Array<var> midiIconData;
                      

                      Trying this gives the same error

                      midiIconData  = getPropertyWithDefault(object, (int)SpecialPanelIds::MidiIconPathData);
                      
                      midiIconPath.loadPathFromData (midiIconData, sizeof(midiIconData));
                      

                      Can't help pressing F5 in the forum...

                      clevername27C 1 Reply Last reply Reply Quote 0
                      • clevername27C
                        clevername27 @ustk
                        last edited by

                        @ustk Have you tried an explicit cast (if relevant)?

                        ustkU 2 Replies Last reply Reply Quote 0
                        • ustkU
                          ustk @clevername27
                          last edited by

                          @clevername27 Thanks, but could you enlight me with this please, I'm noob in C++ 🙄

                          Can't help pressing F5 in the forum...

                          1 Reply Last reply Reply Quote 0
                          • ustkU
                            ustk @clevername27
                            last edited by ustk

                            @clevername27 well I think I see what you mean but I don't know exactly how to write it...

                            something like const_cast<blabla>(midiIconData) maybe?

                            EDIT:

                            tried this with no luck

                            const void *mid = midiIconData;
                            
                            midiIconPath.loadPathFromData (&mid, sizeof(&mid));
                            

                            and same with this

                            midiIconPath.loadPathFromData (const_cast<const void *>(midiIconData), sizeof(const_cast<const void *>(midiIconData)));
                            

                            Can't help pressing F5 in the forum...

                            1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey
                              last edited by

                              @ustk @Christoph-Hart Could this be the cause of the issue?

                              Link Preview Image
                              File not found · christophhart/HISE

                              The open source framework for sample based instruments - File not found · christophhart/HISE

                              favicon

                              GitHub (github.com)

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              ustkU 2 Replies Last reply Reply Quote 0
                              • ustkU
                                ustk @d.healey
                                last edited by

                                @d-healey I don't think so. In fact I had it working and I can draw anything like an ellipse for instance. But I stopped because I don't know how to draw a path which I thought would have been more trivial...

                                In fact I'd like to put a path in the data property so we don't need an image. I have made pretty much all the necessary modifications but got stuck at one point and I don't have much time atm.

                                This gives an idea if you want to give it a go:

                                Screenshot 2023-01-14 at 01.20.55.png
                                Screenshot 2023-01-14 at 01.21.06.png
                                Screenshot 2023-01-14 at 01.21.30.png

                                Can't help pressing F5 in the forum...

                                1 Reply Last reply Reply Quote 1
                                • ustkU
                                  ustk @d.healey
                                  last edited by ustk

                                  @d-healey In the end it would be even better if we can set a path from API like FloatingTile.setPath(path) but that would be even harder to implement. So placing it in the data property might still be a good workaround, but not a conventional one I confess.

                                  Can't help pressing F5 in the forum...

                                  Christoph HartC 1 Reply Last reply Reply Quote 1
                                  • Christoph HartC
                                    Christoph Hart @ustk
                                    last edited by

                                    @ustk It won't work like that. The load path from data expects a consecutive memory block of 8bit integers (char or uint8) and the var type is much bigger so casting a pointer will make it interpret garbage.

                                    If you're converting the path with the SVG converter in HISE you also get the ability of using a Base64 encoded string instead of the number array (which is recommended anyway because it will be shorter so the Javascript parser has much less to do in the onInit BTW). With this string it could work, then all you need to do is to create a MemoryBlock and parse the Base64 string

                                    var propertyFromJSON("2124.dlaklasdf8laksdjh32fkaldshfasjdfsfd");
                                        
                                    String funkyPath = propertyFromJSON.toString();
                                         
                                    MemoryBlock mb;
                                    mb.fromBase64Encoding(funkyPath);
                                        
                                    Path p;
                                    p.loadPathFromData(mb.getData(), mb.getSize());
                                    

                                    otherwise you would have to convert it to a new Array<uint8> manually by iterating over the Array<var> and push each value after casting it to a uint8. Then you can use Array<uint8>::getRawDataPointer() to get a pointer to the byte-aligned data for the path.

                                    ustkU 2 Replies Last reply Reply Quote 2
                                    • ustkU
                                      ustk @Christoph Hart
                                      last edited by

                                      @Christoph-Hart awesome! I'll give this a second chance then :)

                                      Can't help pressing F5 in the forum...

                                      1 Reply Last reply Reply Quote 0
                                      • ustkU
                                        ustk @Christoph Hart
                                        last edited by ustk

                                        @Christoph-Hart Alright so I'm trying this direct approach in the paint routine to "get more chance" but I feel idiot it does not work...

                                        Maybe I need to scale the path... Please bring me to school Chris :)

                                        
                                        	if (useMidiPath)
                                        	{
                                        		//var propertyFromJSON(base64MidiPath);
                                        		var propertyFromJSON("678.t0V8.ZBQPJkgCIFl3+AQPJkgC0ipZPDQuC4P8npFD4++cNjX8npFDoKDqNDl3+AQt0ZsCUOflPjasV6PhIUBsPjasV6PsdkLDoKDqNDqWICQ9+emCIVqWICQD8NjCIUBsPDjRY3P0CnIDAoTFNzXsUOflPDzWg3PhIQerPDzWg3PhLULDY7ARNjHSECQ9+emCIlHSECQ3fepCIQerPjKnN6P0CnID4BpyNjXYSHHD4BpyNj2rtAQ3fepC4MqaPj++24Ph4MqaPjwGH4PYSHHDA8UHNT8.ZBQPeEhCMVa0CnIDMqWuMjXBJxGDMqWuMzV8cAQBsRfC05oQPD3Np3Ph4ezKPTexO4PMi7ADk1UcNTyHe.QocUmCwF..d.Q..fmCwVyHe.QXhpmCIVyHe.QXhpmC4ezKPzfMf5PsdZDDARbwNjXa02ED4K05Njfh7AQmBEwCUOflPjoPQ7Phg12sPjoPQ7PjJXMD4K05NzTXsCQfDWrCIl.tDDQD1.pCMyMEQDln54PybSQDgIpdNDa..XQDA..dNDaybSQDk1UcNjXybSQDk1UcNj.tDDQ8I+jCMEV6PD3Np3PhQpf0PjPqD3Po8cKDMqWuMj8.ZBQy50aCMVa0CnIDQSZyMjXP5VKDQSZyMzFzSCQRHtfCwWs5Pz.kv3Ph4oP.Qz3ST4P5R8PDgKXcNDvYPDQ9+emCIltTODQD8omC4oP.QjFra5P7UqNDou1uNjXaPOMDsdG4NDjt0BQNdjvCUOflPjiGI7Phs0jePjiGI7Pju.FDsdG4NDgJIAQ5q8qCIVX8x.QavtoCUzJIPjQe54P+XNBD4++cNjXEsRBDkKXcNTX8x.QiOQkCQnRRPDAkv3PhQ9BXPjDhK3PaM4GDUSZyMT8.ZBQ0j1bCMVY");
                                        
                                        		String midiIconPath = propertyFromJSON.toString();
                                        
                                        		MemoryBlock mb;
                                        		mb.fromBase64Encoding(midiIconPath);
                                        
                                        		Path p;
                                        		p.loadPathFromData(mb.getData(), mb.getSize());
                                        
                                        		g.fillPath(p);
                                        	}
                                        	else
                                        		g.fillEllipse(getWidth()-getHeight(), 0, getHeight(), getHeight());
                                        

                                        Can't help pressing F5 in the forum...

                                        ustkU 1 Reply Last reply Reply Quote 0
                                        • ustkU
                                          ustk @ustk
                                          last edited by

                                          Oh wait I almost got it to work! I forgot to scale the path in the resized function...
                                          But it looks a bit weird for now so stay tuned 🤣

                                          Can't help pressing F5 in the forum...

                                          1 Reply Last reply Reply Quote 0
                                          • ustkU
                                            ustk
                                            last edited by

                                            Gotcha!

                                            Screenshot 2023-01-14 at 15.09.24.png

                                            Can't help pressing F5 in the forum...

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

                                            41

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.1k

                                            Posts