HISE Logo Forum
    • Categories
    • Register
    • Login

    C++ API: How to connect Intensity to a Slider?

    Scheduled Pinned Locked Moved C++ Development
    20 Posts 4 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.
    • hisefiloH
      hisefilo
      last edited by

      Hi guys, any idea on how to connect Intensity value to a slider on the C++ API?
      Connecting a parameter is already explained on VCSL example, but Intensity is not a parameter. Any help??

          StrippedSlider<SimpleReverbEffect::WetLevel> reverbSlider;
          StrippedSlider<GainEffect::Gain> mainGainSlider;
          StrippedSlider<GainEffect::Gain> releasesGainSlider;
          StrippedSlider<LfoModulator::IntensityChain> vibratoSlider; // <<-- Not working
      
      hisefiloH 1 Reply Last reply Reply Quote 0
      • hisefiloH
        hisefilo @hisefilo
        last edited by

        @Christoph-Hart ?? pleeeeeeeease :)

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

          @hisefilo In the Modulation base class, it seems to be just intensity, but I honestly don't know if looked at the right place, have a try ;)

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

          hisefiloH 1 Reply Last reply Reply Quote 1
          • hisefiloH
            hisefilo @ustk
            last edited by

            @ustk thanks mate! Already tried. I think is something on ModulatorSyth::Gain but cannot figure out how to hook it

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

              It's a little bit more complicated unfortunately. You need to create a template class that calls Modulator::setIntensity() and Modulator::getIntensity() and pass that to the UIConnection - actually it should be part of the raw namespace so I try to find some time tomorrow to add this.

              hisefiloH 2 Replies Last reply Reply Quote 1
              • hisefiloH
                hisefilo @Christoph Hart
                last edited by

                @Christoph-Hart thanks Christoph. Will be super useful :)

                1 Reply Last reply Reply Quote 0
                • hisefiloH
                  hisefilo @Christoph Hart
                  last edited by

                  @Christoph-Hart any luck?

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

                    I was busy with the expansion stuff, but it's the next thing on my list.

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

                      Alright, it's there.

                      Class Definition:

                      juce::Slider mySlider; // must not be a HiSlider as this expects to be connected to a parameter
                      raw::UIConnections::SliderBase intensityConnection;
                      

                      Constructor:

                      MyClass():
                        mySlider("SomeName"),
                        intensityConnection(&mySlider, mc, "SomeModulator")
                      {
                          // ...
                          intensityConnection.setData<raw::Data<float>::Intensity>();
                          // ...
                      }
                      

                      Data<float>::Intensity> can also be used in the storage process to save the intensity to a preset / value tree, but that's a nice little homework to figure out yourself :)

                      hisefiloH 1 Reply Last reply Reply Quote 1
                      • hisefiloH
                        hisefilo @Christoph Hart
                        last edited by hisefilo

                        @Christoph-Hart said in C++ API: How to connect Intensity to a Slider?:

                        intensityConnection

                        💪 💪 💪 💪 thanks :) !!!

                        Just one error I guess:

                        No type named 'SliderBase' in 'hise::raw::UIConnection'
                        
                        1 Reply Last reply Reply Quote 0
                        • Christoph HartC
                          Christoph Hart
                          last edited by

                          Have you pulled the latest scriptnode?

                          hisefiloH 2 Replies Last reply Reply Quote 1
                          • hisefiloH
                            hisefilo @Christoph Hart
                            last edited by hisefilo

                            @Christoph-Hart mmmm nope!!! I was using Master to work with the C++ API. Should I jump to Scriptnode?

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

                              @hisefilo said in C++ API: How to connect Intensity to a Slider?:

                              @Christoph-Hart mmmm nope!!! I was using Master

                              You've been in the stone age!

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

                              hisefiloH 1 Reply Last reply Reply Quote 1
                              • hisefiloH
                                hisefilo @d.healey
                                last edited by

                                @d-healey I'm on lastest scriptnode for non-C++ API projects! :)

                                1 Reply Last reply Reply Quote 1
                                • hisefiloH
                                  hisefilo @Christoph Hart
                                  last edited by

                                  @Christoph-Hart got it working!!! Thanks a lot @Christoph-Hart
                                  Now I'm working on replicating HiSlider stuff for the juce::Slider we are using. (MidiLearn, and LookAndFeel)

                                  Screen Shot 2021-03-13 at 10.07.31 AM.png

                                  hisefiloH 1 Reply Last reply Reply Quote 0
                                  • hisefiloH
                                    hisefilo @hisefilo
                                    last edited by hisefilo

                                    @Christoph-Hart it's possible to tweak HiSlider to receive Intensity? Will be much easier than adding Midilearn and flaf to Juce slider?

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

                                      Yes that‘s a valid point.

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

                                        Ah damn, I just noticed that it's super hard to MIDI learn the intensity - the entire system uses a parameter index and the intensity is not a parameter so the HiSlider is the smallest problem.

                                        One option would be to write a MIDI processor class that uses one slider and forwards this to the intensity that you need - it's super verbose for a simple task though...

                                        class IntensityForwarder: public HardcodedMidiProcessor
                                        {
                                            IntensitySlider(MainController* mc, const String& modId):
                                              HardcodedMidiProcessor(mc, "IntensityForwarder")
                                            {
                                                modToUse = dynamic_cast<Modulator*>(ProcessorHelpers::getFirstProcessorWithId(mc->getMainSynthChain(), modId));
                                                jassert(modToUse != nullptr);
                                        
                                                // Add one slider that will forward the value to the intensity.
                                                Content.addSlider("modIntensity", 0, 0);
                                            }
                                        
                                            // add all callbacks
                                        
                                            void onControl(var c, var value)
                                            {
                                                modToUse->setIntensity((float)value);
                                            }
                                         
                                            WeakReference<Modulator> modToUse;
                                        };
                                        
                                        
                                        // creation:
                                        
                                        raw::Builder b;
                                        b.createTheModulatorYouWantToControlBeforeTheOtherOne();
                                        b.create<IntensityForwarder>(mc->getMainSynthChain(), whateverParameters);
                                        
                                        raw::UIConnection::Slider<0> c; // connect it to the IntensityForwarder
                                        

                                        This is pseudo code and will definitely not work, but it should get you started.

                                        hisefiloH 2 Replies Last reply Reply Quote 0
                                        • hisefiloH
                                          hisefilo @Christoph Hart
                                          last edited by

                                          @Christoph-Hart Thanks !!!!!!! Working on it. Will post results!

                                          1 Reply Last reply Reply Quote 0
                                          • hisefiloH
                                            hisefilo @Christoph Hart
                                            last edited by

                                            @Christoph-Hart
                                            cannot get it working. Compiles, runs but onController never gets executed.

                                            This is what I did:
                                            Changed HardcodedMidiProcessor to HardcodedScriptProcessor because does not exist.
                                            Changed Modulator for LfoModulator since Modulator does not have setIntensity

                                            class IntensityForwarder: public hise::HardcodedScriptProcessor
                                            {
                                                
                                            public:
                                                
                                                /** Set the name and default ID of the processor. */
                                                SET_PROCESSOR_NAME("IntensityForwarder", "IntensityForwarder", "IntensityForwarder");
                                                
                                                IntensityForwarder(MainController* mc, const String& id, const String& modId):
                                                HardcodedScriptProcessor(mc, id, mc->getMainSynthChain())
                                            
                                                {
                                                    
                                                    modToUse = dynamic_cast<LfoModulator*>(ProcessorHelpers::getFirstProcessorWithName(mc->getMainSynthChain(), modId));
                                                    jassert(modToUse != nullptr);
                                                    
                                                    // Add one slider that will forward the value to the intensity.
                                                    Content.addKnob("modIntensity", 100, 100);
                                                }
                                                
                                                // add all callbacks
                                                
                                                void onControl(var c, var value) 
                                                {
                                                    std::cout << "on Control" << std::endl;
                                                    modToUse->setIntensity((float)value);
                                                }
                                                
                                            private:
                                                
                                                WeakReference<LfoModulator> modToUse;
                                                
                                                JUCE_DECLARE_WEAK_REFERENCEABLE(IntensityForwarder);
                                            
                                            };
                                            
                                            
                                            

                                            then I had to build it using add, instead of create

                                            builder.add<IntensityForwarder>(new IntensityForwarder(mc, "IntensityForwarder1", "LfoGain"), mc->getMainSynthChain(), raw::IDs::Chains::Midi);
                                            

                                            and lately conected it using this:

                                            sliderForwarder.connect("IntensityForwarder1");
                                            
                                            template <int ParameterIndex>
                                            class StrippedSlider : public hise::HiSlider,
                                            	public ControlledObject
                                            {
                                            public:
                                            
                                            	StrippedSlider(MainController* mc, const String& name) :
                                            		HiSlider(name),
                                            		ControlledObject(mc)
                                            	{
                                            		raw::Pool pool(mc, true);
                                            //        flaf.setFilmstripImage(pool.loadImage("Strip.png"), 100);
                                                    flaf.setFilmstripImage(pool.loadImage("StripBigNew.png"), 64);
                                                    flaf.setScaleFactor(0.3);
                                            
                                                    
                                            
                                            		setName(name);
                                            		setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
                                            		setLookAndFeel(&flaf);
                                            		setTextBoxStyle(Slider::NoTextBox, false, 0, 0);
                                            	}
                                            
                                            	~StrippedSlider()
                                            	{
                                            		connection = nullptr;
                                            	}
                                            
                                              
                                                
                                            	void connect(const String& id)
                                            	{
                                            		auto p = ProcessorHelpers::getFirstProcessorWithName(getMainController()->getMainSynthChain(), id);
                                            
                                            		setup(p, ParameterIndex, Slider::getName());
                                            		connection = new raw::UIConnection::Slider<ParameterIndex>(this, getMainController(), id);
                                            		setLookAndFeel(&flaf);
                                            	}
                                            
                                            	bool tempoSyncMode = false;
                                            
                                            	FilmstripLookAndFeel flaf;
                                            	ScopedPointer<raw::UIConnection::Slider<ParameterIndex>> connection;
                                            
                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            20

                                            Online

                                            1.8k

                                            Users

                                            11.9k

                                            Topics

                                            104.0k

                                            Posts