Waveform doesn't save in Preset
-
It looks like it's going through every button in the sequence when you recall the preset, which would explain why it lands on the Noise oscillator.
-
@trillbilly You can use a sliderpack to store and control the values of the buttons so they restore correctly.
-
@DanH this kinda thing (I'm using it for filter mode buttons)
/// DEFINE ARRAY const var pfButtons = [Content.getComponent("FILTButton1"), Content.getComponent("FILTButton5"), Content.getComponent("FILTButton3"), Content.getComponent("FILTButton4"), Content.getComponent("FILTButton2")]; /// CALLBACK FOR PFBUTTONS for (b in pfButtons) b.setControlCallback(onpfButtonsControl); inline function onpfButtonsControl(component, value) { local index = pfButtons.indexOf(component); for (i = 0; i < pfButtons.length; i++) { pfButtons[i].setValue(i == index); SliderPack3.setSliderAtIndex(i, i == index); } } /// SLIDERPACK3 CALLBACK SliderPack3.setControlCallback(onSliderPack3Control); inline function onSliderPack3Control(component, value) { for (i = 0; i < value.length; i++) { pfButtons[i].setValue(component.getSliderValueAt(i)); } }
-
@iamlamprey said in Waveform doesn't save in Preset:
It looks like it's going through every button in the sequence when you recall the preset, which would explain why it lands on the Noise oscillator.
do you start your radio buttons code with:
if(value) { ..your code here }
-
@iamlamprey Yes, buttons are in a radio group via the property editor.
@DanH Ok cool, let me try this. I havent even began using slider packs yet so its a good time to do it.
@Lindon No, I have them as radio buttons via the property editor.
-
@trillbilly said in Waveform doesn't save in Preset:
@iamlamprey Yes, buttons are in a radio group via the property editor.
@DanH Ok cool, let me try this. I havent even began using slider packs yet so its a good time to do it.
@Lindon No, I have them as radio buttons via the property editor.
There lies your problem, an easier fix than using slider packs - put the code in each radio button and make it execute ONLY when the radio button is on...
-
@Lindon I havent scripted radio buttons or used slider packs so I guess its time to learn both lol
-
@trillbilly said in Waveform doesn't save in Preset:
@Lindon I havent scripted radio buttons or used slider packs so I guess its time to learn both lol
-- what are you wanting the radio buttons to do?
I assume the buttons in your example code in the first post are radio buttons....
inline function onSinebtn1Control(component, value) { WaveformGenerator1.setAttribute(WaveformGenerator1.WaveForm1, 1); }; Content.getComponent("Sinebtn1").setControlCallback(onSinebtn1Control);
so the way you have this coded each radio button will exceute in turn - the last radio button is noise so noise will get loaded...
but if you change the code to this:
inline function onSinebtn1Control(component, value) { if(value) { WaveformGenerator1.setAttribute(WaveformGenerator1.WaveForm1, 1); }; }; Content.getComponent("Sinebtn1").setControlCallback(onSinebtn1Control);
..then only the ON button will be executed on preset load...
-
@Lindon Just allow only 1 waveform to be selected at a time. I just found an easy solution that seemed to work, it sounds like what you were suggesting but without scripting the Radio Buttons.
simply by changing this
//Sine inline function onSinebtn1Control(component, value) { WaveformGenerator1.setAttribute(WaveformGenerator1.WaveForm1, 1); }; Content.getComponent("Sinebtn1").setControlCallback(onSinebtn1Control);
to this
//Sine inline function onSinebtn1Control(component, value) { if (value) WaveformGenerator1.setAttribute(WaveformGenerator1.WaveForm1, 1); }; Content.getComponent("Sinebtn1").setControlCallback(onSinebtn1Control);
seems to have done the job. Is this what you meant? If not, do you see any problems doing it this way?
EDIT: Just seen your comment, its exactly what you were telling me lol
-
@trillbilly see above - yes thats what I mean - you need to add if(value) to each of the button callbacks.