Adding a second action to a button
-
I have a button which enables/disables the compressor in my project.
It was reuested that I add a makeup gain to the compressor, so I just added a simplegain to it. The problem is that the simplegain does not get enabled/disabled with the button.
Can I use code to assign that second action to the button?
-
@pcs800 said in Adding a second action to a button:
Can I use code to assign that second action to the button?
Yes, for this you need to use a control callback.
-
@d-healey Such as this?
// Assign this script to the control callback of the compToggle button
const compressor = Synth.getEffect("Dynamics1");
const gain = Synth.getEffect("simplegain1");inline function oncompToggleControl(component, value)
{
// This sets the compressor enabled state (already mapped in HISE)
compressor.setAttribute(0, value); // Attribute 0 is usually "Enabled" or "Bypass", double check// Now also toggle the gain module gain.setAttribute(0, value); // Again, Attribute 0 is usually Bypass/Enabled
}
// Attach the control callback to the button
const compToggle = Content.getComponent("compToggle");
compToggle.setControlCallback(oncompToggleControl); -
@pcs800 This smells like AI? It's pretty close actually.
Don't use magic numbers, like attribute
0
. Use the built in constants instead - you can find these by right-clicking on the module's header and selecting Dump parameter IDs and values.However for changing the bypass state you don't use
setAttribute
. Instead usesetBypassed
.@pcs800 said in Adding a second action to a button:
(already mapped in HISE)
You can have either processor/parameter ID or a control callback, not both. So in your case you need to remove the assignment in the interface designer and do it all through the control callback.
-
@d-healey Yes Ai is what I am using to try teaching myself and getting code. The problem with it, is it usually gives wrong answers for an hour until i provide enough error feedback for it to get something right.
-
@pcs800
Doing the parameter dump, I see this.
So I would use:
{
// This sets the compressor enabled state (already mapped in HISE)
compressor.ssetBypassed(0, value);// Now also toggle the gain module
gain.setBypassed(0.00, value);
}
? -
@pcs800 Or
gain.setBypassed("Gain", 0.00); ? -
@pcs800 please don‘t post AI code here - it poisons the code quality in the forum.
You can obviously use AI for yourself but typing something into ChatGPT and then paste in here here for DaveGPT to correct it is super lazy.
-
@Christoph-Hart
I'm just trying to learn without bothering everyone here too much -
@pcs800 said in Adding a second action to a button:
I'm just trying to learn without bothering everyone here too much
AI is not a good teacher. A good teacher will tell you when you made a mistake, but with AI you have to tell it when it made a mistake - but that makes you the teacher...
AI is great for improving your workflow once you're able to spot and correct its mistakes. It can also guide you down a path of investigation so that you have some idea of which part of the documentation you need to be reading.
-
@pcs800 said in Adding a second action to a button:
Doing the parameter dump, I see this.
This is only useful for
setAttribute
. As I say you don't need to use this function for this task and should usesetBypassed
instead. The documentation in the API browser should help you here, it just takes one parameter. -
HISE will remain outside of AI scope for some time because there's just not enough training data out there, and it's not entirely code-based.
However if you're adamant on using it, you NEED to feed the docs into the context.
RAG is not very good here.
Instead, I recommend you use the Context7 MCP, so you'll need to use an AI tool that lets you use MCP tools.
The IDE-based ones all do, but so does Claude Desktop (as Anthropic were the ones to come up with the protocol), which is much nicer to work with in this particular case because you can set up projects with custom instructions and knowledge. Get Claude Desktop, create a project, describe what you're doing, and in the project instructions explicitly mention you're working in HISE and that it should use Context7 to always get the docs because there's not enough training data. Update the project knowledge as you go along and as you learn which stuff makes the LLM trip up.
It would be better to use it to chat about HISE, sampling, VI paradigms and DSP using Context7 as a doc tool for HISE instead of letting it write your code, as a big part of the HISE dev workflow is not really code-based. So I'm not encouraging it, but if you're gonna do it anyway, no one can stop you, so I'm letting you know about the best way to do it that I've found, and actually getting something useful and concurrent out of it.
-
@d-healey
I've got it working now, thanks -
@pcs800 Nice!