HISE Logo Forum
    • Categories
    • Register
    • Login

    Dynamically adding Curve EQ with Effect Slot Save Preset Problem.

    Scheduled Pinned Locked Moved General Questions
    2 Posts 1 Posters 279 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.
    • marcLabM
      marcLab
      last edited by marcLab

      Hello!

      I'm having an issue with, adding and removing dynamically the Curve EQ using the Effect Slot processor.

      I think my problem is in this function. ->

      inline function oncmbFxControl(component, value)
      {
      	local index = cmbFxSlot.indexOf(component);
      	local fxType = cmbFxSlot[index].getItemText();
      	
      	if (fxType == "Empty")
      	    fxSlot[index].setEffect("EmptyFX");
      	else
      	    fxSlot[index].setEffect(fxType);
      	    
          btnShowPanel[index].setValue(1);
      	btnShowPanel[index].changed();
      		
      	if (fxType == "CurveEq")
      	{
      		local tileData = {
      			"Type": "DraggableFilterPanel",
      			"ProcessorId": "fx"+index+"_CurveEq",
      			"Index": -1
      		};
      		
      		//Console.print(index);
      		showFltFxEq(index);
      		
      		fltFxEq[index].setContentData(tileData);
      	    Engine.addModuleStateToUserPreset("fx"+index+"_CurveEq");
      	}	
      };
      

      I think the problem is here ->

      Engine.addModuleStateToUserPreset("fx"+index+"_CurveEq");
      

      When I save a preset with a CurveEQ it works. If I change the combobox to Empty and Save Preset then I get a crash.

      Exception thrown: read access violation.
      p was nullptr.
      
      
      juce::ValueTree UserPresetHelpers::createModuleStateTree(ModulatorSynthChain* chain)
      {
      	ValueTree modules("Modules");
      
      	if (auto sp = JavascriptMidiProcessor::getFirstInterfaceScriptProcessor(chain->getMainController()))
      	{
      		for (auto id : sp->getListOfModuleIds())
      		{
      			auto p = ProcessorHelpers::getFirstProcessorWithName(chain, id);
      			auto mTree = p->exportAsValueTree();
      
      			mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
      			mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
      
      			modules.addChild(mTree, -1, nullptr);
      	
      		}
      	}
      
      	return modules;
      }
      

      So I tried this in the source code ->

      juce::ValueTree UserPresetHelpers::createModuleStateTree(ModulatorSynthChain* chain)
      {
      	ValueTree modules("Modules");
      
      	if (auto sp = JavascriptMidiProcessor::getFirstInterfaceScriptProcessor(chain->getMainController()))
      	{
      		for (auto id : sp->getListOfModuleIds())
      		{
      			
      			auto p = ProcessorHelpers::getFirstProcessorWithName(chain, id);
      			
      
      			if (p != nullptr)
      			{
      				auto mTree = p->exportAsValueTree();
      
      				mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
      				mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
      
      				modules.addChild(mTree, -1, nullptr);
      			}
      	
      		}
      	}
      

      Hise is not crashing anymore but I think my fix breaks it in some other way.

      IN CONCLUSION (lol)

      I think this nullptr problem is caused by .addModuleStateToUserPreset once I Save my combobox with Empty after setting it to CurveEq. I don't have this problem with other FX.

      Is there a way to remove addModuleStateToUserPreset - removeModuleStateToUserPreset or something similar? Maybe this will solve my problem.

      Cheers!

      1 Reply Last reply Reply Quote 0
      • marcLabM
        marcLab
        last edited by marcLab

        UPDATE with

        juce::ValueTree UserPresetHelpers::createModuleStateTree(ModulatorSynthChain* chain)
        {
           ValueTree modules("Modules");
        
           if (auto sp = JavascriptMidiProcessor::getFirstInterfaceScriptProcessor(chain->getMainController()))
           {
           	for (auto id : sp->getListOfModuleIds())
           	{
           		
           		auto p = ProcessorHelpers::getFirstProcessorWithName(chain, id);
           		
        
           		if (p != nullptr)
           		{
           			auto mTree = p->exportAsValueTree();
        
           			mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
           			mTree.removeChild(mTree.getChildWithName("EditorStates"), nullptr);
        
           			modules.addChild(mTree, -1, nullptr);
           		}
           
           	}
           }
        

        It does work! But I need to click twice to recall the CurveEq values if coming from Empty Slot or other FX. If I'm already on a CureveEq then it loads on first attempt ->

        glitch.gif

        @Christoph-Hart

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

        15

        Online

        1.7k

        Users

        11.8k

        Topics

        102.7k

        Posts