#define FEATUREREQUESTMODE_H_
bool syncedOscilators = true;
#endif
Posts
-
RE: Preparing for HISE 2.0
-
RE: AAX dosen't recognized in Pro tools 2018
Is it AAX 64? ProTools 2018 does only 64 Bit AAX.
-
RE: My Project : GoldPiano
Nice work, but maybe use a more complex piano piece for your demo that has some nice dynamics, ex. some Bach classic like prelude or Chopin - Nocturne.
-
RE: Add/Remove "Sound Generators" at runtime using scripting
@christoph-hart: Your assumption is right and thank you for the offer. I think we can work something out here (which works constructive in both directions), i'll contact you as soon as i get back to the office.
-
RE: 1 Filmstrip to display various parameters
Could you please explain a bit more on what you trying to achieve?
-
Add/Remove "Sound Generators" at runtime using scripting
Hi.
Is it possible to create/remove instances of sound generators (for example a Waveform Generator) at runtime from the Javascript Engine?
Thanks!
-
RE: oscillator sync script ?
+1 ! A sync option on the oscillator would be more then welcome. Also built in Legato and Portamento would be nice.
-
RE: Bug in scope of FOR loop
@d-healey said in Bug in scope of FOR loop:
I know I keep saying this, but HISE Script is not Javascript
I understand your point, but i didn't expected such elementary behaviour to differ from Javascript. But thank you for pointing out the local keyword. That indeed solves my problem. As Javascript developer this is kind of mind f*ckery to my mind 8)
-
Bug in scope of FOR loop
I found this really annoying bug in FOR loops, consider:
function test1(){ for(var index = 0; index < 5; index++){ test2(index); } } function test2(){ Console.print(index); } test1();
Which outputs:
Interface: 0 Interface: 1 Interface: 2 Interface: 3 Interface: 4
Which is not correct in normal Javascript and i can't imagine this is desired behaviour. The variable index should not be in the scope of test2(). This caused for some real strange behaviour in my code, because i'm using a variable with the same name. Besides the issue of the variable being accessible, it's apparently by reference... if you set this variable to a new value you mess up the iteration of your loop in test1(). It took me quite some time to figure out what is causing this weird behaviour...
-
RE: Get name of attribute
Cool! Learned something new, i wasn't aware of the module browser. In my build it seem to work 8)
So this will at least solve my question about which attribute index is what. Still i would love to have a method which can be used to get these names programmatically ;) I hate magic numbers in my code.
-
RE: Get name of attribute
I'm trying to get a list of all available attributes from a processor (in this case a waveform generator). Trying to build a custom user control that dynamically builds up a display of all available configuration parameters. So it would be nice if i could query a processor and tell it to give me all its attributes with name and current value. :)
So in an ideal world i would like to be able to do something like this:
var attributeCount = WaveformGenerator1.getNumAttributes(); for(var attributeIndex=0; attributeIndex < attributeCount; attributeIndex++){ Console.print("Name: " + WaveformGenerator1.getAttributeName(attributeIndex)); Console.print("Value: " + WaveformGenerator1.getAttribute(attributeIndex)); }
But, as i don't have a way to get the attribute name, i run the following code:
var attributeCount = WaveformGenerator1.getNumAttributes(); for(var attributeIndex=0; attributeIndex < attributeCount; attributeIndex++){ Console.print(WaveformGenerator1.getAttribute(attributeIndex)); }
And it outputs:
Interface: 0.25 Interface: 0 Interface: 256 Interface: 20 Interface: 5 Interface: 2 Interface: 0 Interface: 0 Interface: 0 Interface: 3 Interface: 0 Interface: 0 Interface: 0.5 Interface: 1 Interface: 0.5 Interface: 0.5
So getNumAttributes() return 16, and as you can see i can get the values of all 16 attributes. But which parameter index is which knob in the UI? I have been able to get this list of parameters from the Waveform Generator C++ source:
parameterNames.add("OctaveTranspose1"); parameterNames.add("WaveForm1"); parameterNames.add("Detune1"); parameterNames.add("Pan1"); parameterNames.add("OctaveTranspose2"); parameterNames.add("WaveForm2"); parameterNames.add("Detune2"); parameterNames.add("Pan2"); parameterNames.add("Mix"); parameterNames.add("EnableSecondOscillator"); parameterNames.add("PulseWidth1"); parameterNames.add("PulseWidth2");
But those are only 12 parameters, and i found out that the first parameter in this list is Index 4 in the list of Attributes which i see in Javascript. So what are those 4 preceding attributes? That's why i think a method like getAttributeName(int attributeIndex) that returns something like "OctaveTranspose1" would be very handy :)
Ps. sorry for my noobish questions, second day of HISE programming ;)
-
Get name of attribute
Method:
Synth.getAttribute(int attributeIndex)
Returns the current value of the given attribute index, but i'm looking for a way to get the name of the attribute. How do i accomplish this, i can't find any method (like getAttributeName(int attributeIndex)) that does this.
Ps. Logically, given the name i would expect that getAttribute() returns an object containing both the attributes name and it's value. :)
-
RE: New operator support in Javascript engine?
@Christoph-Hart: I see, your concerns about the GC are valid. Memory leaks in these type of application are horrible. Thanks for pointing out this behaviour of the Javascript Engine garbage collector. I will definitely take these into account.
I have been refining and simplifying the method above:
/* The helper manager that helps us instantiate new objects */ function ObjectManager(){ return { construct: function(prototype, parameters){ var instance = PrototypeFactory(prototype); if(typeof(instance.construct) === "function"){ instance.construct(parameters); } return instance; } } } /* Note: you need to add all your class definitions to this factory */ function PrototypeFactory(name){ switch(name){ case "Cat": return Cat(); } } /* Now we can just define classes in a modern Javascript fashion, like this Cat class with some properties and methods */ function Cat(){ return { name: "Garfield", construct: function(parameters){ this.age = parameters.age; }, printInformation: function(){ Console.print("Age: " + this.age); Console.print("Name: " + this.name); } } } /* Now we can instantiate objects of that class */ var cat = ObjectManager().construct("Cat", {age: 2}); cat.printInformation(); /* Outputs: Age: 2 Name: Garfield */ var olderCat = ObjectManager().construct("Cat", {age: 4}); olderCat.printInformation(); /* Outputs: Age: 4 Name: Garfield */
Again, i'm still experimenting and planning my code design strategy. Is there a way that I can monitor the Javascript engine's object count thru the API? Something like (pseudocode):
const var objectCountTimer = Engine.createTimerObject(); objectCountTimer.callback = function() { Console.print("Object count: " + Engine.getObjectCount()); }; objectCountTimer.startTimer(10000);
Besides that fact that this would allow me to test my design strategy for memory leaks, I think it would be a really nice addition to the framework because it allows monitoring of object instance regression (at least during debugging) and analyzing the behaviour of the Javascript Engine GC.
It's not that i'm planning to do very advanced OO Javascript stuff, so no inheritance etc. Just some basic prototyping and instantiation.. should that work (without memory leaks) than that would be my prefered strategy in contrast to using the C++ API. Just because i'm more comfortable with Javascript then C++ now-a-days.
So the GUI design I have in mind for this particular plugin i'm building is a very dynamic in nature, i'm trying to dynamically modify the module backend (Effects & Modulators) based on the users input. So for this to work, the Javascript Engine must be able to free memory of (my custom Javascript UI) objects that are unreferenced and go out of scope, otherwise it will leak like hell (like you mentioned) and render my method (mentioned above) totally unusable. Today I'll try to attach some custom C++ code using the C++ API, try and see how that works out.
Ps. It's good to know that a script panel can hold a custom data object, that would allow me to go for a more C stylish approach inside Javascript instead of the my custom OOP approach above. Like putting all the logic in a namespace and let the script panels cary their own data. Will give this approach a shot too, but I slowly getting the feeling that I need to go down the C++ road for my idea to work properly (and keep my code clean/maintainable).
Update: I found out that the object oriented Javascript method failed when trying to access class properties from within a callback function:
function DisplayComponent(){ return { backgroundColor: Colours.green, construct: function(parameters){ this.setPaintRoutine(); }, setPaintRoutine: function(){ var classthis = this; Display.setPaintRoutine(function(g) { g.fillAll(classthis.backgroundColor); }); } } }
It just can't access that backgroundColor property from within that scope. I could not find any documentation or examples on how to implement custom C++ code so i'm going to see if i can do something with the data object holder inside Script panel and build my design around that.
-
RE: New operator support in Javascript engine?
So i have been reading the "best practices" guide. I like the namespacing concept, but those are just static objects for as far as i understand and mainly have the purpose of reducing code clutter. At some point, in the code i'm planning to write, I need some sort of object instantiation to prevent duplicate code and that things getting really messy (me = chairman at the federation of pizza lovers against duplicate code).
I need to simulate an LCD display on a scripting panel, and therefore I would like to write a few "classes" that mimic certain "on-screen" display controls like ADSR graphs and other visual elements that you'll normally find in settings pages of traditional 90's rack synthesizer units. I would like to be able to re-use these virtual controls code wise. No fast refresh rates are needed and i'm planning to buffer certain areas so that the painting routines are doing minimal as possible.
So in my first attempt to work Object Oriented in HISE "Javascript" without using the new operator I came up with the following structure to mimic the behaviour of Classes:
function MyClass(options){ /* Store constructor argument in private property */ this.options = options; return { otherFunction: function(){ Console.print("Console print from other function"); }, foo: function(){ /* Calling other function in class, just for illustration */ this.otherFunction(); /* Example on how to access properties of the options object */ Console.print(options.rect.top); Console.print(options.enabled ? "true" : "false"); }, printRectTop: function(){ Console.print(options.rect.top); } } } /* Construct first object */ var object1 = MyClass({ enabled: false, rect: { top: 500 }, }); /* Call method on first object, which works as expected */ object1.printRectTop(); /* outputs 500 */ /* Construct second object, and set alternative top value */ var object2 = MyClass({ enabled: false, rect: { top: 1000 }, }); /* Call method on second object, which also works as expected */ object2.printRectTop(); /* outputs 1000 */ /* Call method on first object again, which will now outputs 1000 which is not as expected */ object1.printRectTop(); /* outputs 1000 */
As you can see this clearly does not work, the first object was mutated. So I came up with another solution, which does work:
function ObjectManager(){ this.objects = []; return { construct: function(options){ var instance = {}; instance.options = options; instance.otherMethod = function(){ Console.print("Other method on class, just for illustration.."); }; objects.push(instance); return instance; } } } /* Construct first object and call method, works like expected */ var object1 = ObjectManager().construct({rect: {top: 500}}); Console.print(object1.options.rect.top); /* 500 */ /* Construct second object and call method, works like expected */ var object2 = ObjectManager().construct({rect: {top: 1000}}); Console.print(object2.options.rect.top); /* 1000 */ /* Call method again on first object, works like expected because the value of its property is unchanged */ Console.print(object1.options.rect.top); /* 500 */
It compiles and works for as far as i can see. I don't know how this will impact performance, still needs to measure it and compare it to some other writing styles. I'm just posting it here, so it maybe can help other users, or even to illustrate how to not write your code. Just experimenting how far I can go with the HISE "Javascript" engine, if performance gets in the way I'll probably need to switch to the C++ API and hope that allows me to implement custom painting routines for the UI.
-
RE: New operator support in Javascript engine?
Thanks for clearing that up, those links are very helpful indead and answered a lot of my questions.
-
New operator support in Javascript engine?
I wanted to code my scripting logic in a object oriented fashion, but according this compiler error:
Interface:! Line 61, column 15: new is not supported anymore
It seems the new keyword is not supported anymore? Is object oriented Javascript not supported?
Testcase:
function FooBar(){ this.shout = function(){ Console.print("Bazinga"); }; } var foo = new FooBar(); foo.shout();
-
Loading presets in development mode
How do you (re)load a preset from the preset browser in development mode? I found the preset browser, so i made a couple of different module setups and saved them to different presets. But when i click a just created preset i expected that my module configuration is being restored but nothing happens.
Am i missing something?
Cheers!