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.
    • 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
                                • ustkU
                                  ustk
                                  last edited by

                                  @d-healey @clevername27 @Christoph-Hart Pull Request made
                                  https://github.com/christophhart/HISE/pull/374

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

                                  clevername27C 1 Reply Last reply Reply Quote 2
                                  • ustkU ustk has marked this topic as solved on
                                  • clevername27C
                                    clevername27 @ustk
                                    last edited by

                                    @ustk @Christoph-Hart If interested, I posted an efficient, working and configurable MIDI indicator widget a couple months back.

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

                                    38

                                    Online

                                    1.7k

                                    Users

                                    11.7k

                                    Topics

                                    102.1k

                                    Posts