load font example please



  • can someone put a Engine load font script example. i cant seem to write it correctly without an error

    Engine.loadFont("what goes after that lol")



  • i got it to not give a error with

    const var myfont = Engine.loadFont("{PROJECT_FOLDER}myfont.ttf")

    and changing it in the use preset widget but it just goes to a default and not what i wanted :( im sure its something simple if someone could help ;(



  • i really wish there was example code in all the reference material. all it ever has is coding speak. which is the reason i get stuck constantly. all i need is example usage of things and i can figure it out. but this like alot of things have no trace in the documentation or forums. the best i found was "use Engine Load Font" i know that part but the term "string" to me is soooo vague

    so this

    Engine.loadFont( String fileName) really doesnt help that much actually

    and the simple usage of this among the other things would really make it so much easier to understand. i also still havent gotten one reply about the filmstrip usage in vu meters and how to attach meters to various outputs

    these things were all quite cut and dry in every other way ive created plugins. im just wanting to do simple things but for some reason there is no documentation to do these standard things. so i have to reach out to a forum that has 2 people a day on it lol



  • i just wish i didnt have to post a topic every time i sit down and work on this. and if in the API reference material there was an example default type usage code, it would literally probably be the last thing i ever said here haha. that seems like a difficult thing to do so i guess ill just keep plugging away



  • ok so for anyone that ever has issues with Engine Load Font

    i did this

    const var MyFont = Engine.loadFont("{PROJECT_FOLDER}myfont.ttf")

    then i adjust the font name wherever i desired to change it. however!!!

    calling upon it by its filename does not work. i had to go into my windows fonts folder and look. it showed up as something different for example..

    myfont.ttf showed as

    My Font Regular

    however including the Regular in the font name field in hise did not work

    i took away the Regular and got it to work...viola now if someone searches for it there is an actual solution an usage example


  • administrators

    Loading and embedding fonts is definitely not a simple task. The font IDs vary between Windows / OSX, selecting the font style is non standard etc.

    The Scripting API is a pure reference to look up the syntax and argument order, but there is a pretty extensive tutorial about using the ScriptPanel and everything that relates to this. I've updated this documentation to give more hints how to use external fonts:

    http://hise.audio/manual/ScriptPanel.php#114fonts

    And I am waiting for your filmstrip image before I write an example.



  • i attached it in the email i sent you earlier but here it is0_1507670365261_VU_meter_128_frames.png



  • try to include in the example explanation of how to change where the data can be pulled from different sources other than the master out of the plugin. for example if you were using a compressor wink how to reflect the gain reduction on the meter. or any other source for that matter. i want to make mine switchable to reflect input/gain reduction from compressor/output


  • administrators

    There you go:

    Content.makeFrontInterface(600, 500);
    
    /** Creates a VU-Meter from a filmstrip for the master volume. */
    /** Creates a VU-Meter from a filmstrip for the master volume. */
    inline function createFilmStripVuMeter(name, x, y, isLeft)
    {
    	local widget = Content.addPanel(name, x, y);
        
        Content.setPropertiesFromJSON(name, {
          "width": 130, // this uses the exact dimensions of one filmstrip
          "height": 65,
          "opaque": true // opaque is important in order to increase the drawing performance
        });
        
        // Put the image in your image folder
        widget.loadImage("{PROJECT_FOLDER}vu_meter_128_frames.png", "filmstrip");
        
        widget.data.value = 0.0;
        widget.data.isLeft = isLeft;
        
        // Set the initial image 
        widget.setImage("filmstrip", 0, 0);
        
        widget.setTimerCallback(function()
        {
        	// Get the peak value from the master output
        	var newValue = Engine.getMasterPeakLevel(this.data.isLeft ? 0 : 1);
        	
        	if(newValue > this.data.value)
        		this.data.value = newValue;
        	else
        		// Just decay the current value (0.92 controls the decay time)
        		this.data.value = this.data.value * 0.92;
        	
        	// Calculate the filmstrip index
        	// this must be an integer value
        	// 84 is used instead of 128 because 84 is ~0dB which is
        	// more accurate for this example filmstrip
        	var index = parseInt(this.data.value * 84.0);
        	
        	// If you just want to paint one image, 
        	// you don't need the paint routine, but
        	// just use this method
        	// the yOffset is index * heightOfFilmstrip
        	this.setImage("filmstrip", 0, index * 65);	
        });
        
        widget.startTimer(30);
        return widget;
    };
    
    const var VuMeterLeft = createFilmStripVuMeter("VuMeterLeft", 11, 10, false);
    const var VuMeterRight = createFilmStripVuMeter("VuMeterRight", 160, 10, true);
    

    This is just an approximation of actual gain level to the needle scale (it would be pretty hard to make this accurate).

    This example only shows how to use the master volume output. If you need to use a different source, you need to do these things:

    1. Create a reference to the module you want to view.
    2. Use the method Module.getCurrentLevel(leftChannel) instead of Engine.getMasterPeakLevel in the timer callback. This method is available for synths, effects and even modulators.

    So if you want to view the output level of a sine generator in your patch, you would need to do this:

    const var SineWaveGenerator = Synth.getChildSynth("Sine Wave Generator");
    
    // in the timer callback:
    SineWaveGenerator.getCurrentLevel(this.data.isLeft);
    

    The problem with using the peak level of anything other than the master output is that it will not work in a compiled plugin unless you explicitly enable it using a preprocessor directive. The reason is that crawling through every buffer of every module and calculate the peak volume is not required for 99% of all compiled plugins so it's deactivated by default for compiled plugins in order to save CPU (some patches consists of 100s of modulators / effects and calculating the peak for every module there is not really necessary).

    How to fix this? Just go into your project settings (File -> Project Settings) and add ENABLE_ALL_PEAK_METERS=1 to every Extra preprocessor definitions field (Windows, OSX and iOS). If you compile the plugin now, it will enable the function in the source code just like in HISE.

    If you want to get an overview over all available preprocessor flags, take a look at the hi_core.h file on GitHub:

    https://github.com/christophhart/HISE/blob/master/hi_core/hi_core.h



  • awesome. could i just replace the code in the vumeter.js with this code?


Log in to reply

Looks like your connection to load font example please was lost, please wait while we try to reconnect.