Docs

Engine

The Engine object contains functions related to global properties (like sample rate or host tempo).

Engine.getSampleRate() // returns the current sample rate
Engine.sendAllNotesOff() // sends a all note off (MIDI Panic) message at the next audio buffer


Class methods

allNotesOff

Sends an allNotesOff message at the next buffer.

Engine.allNotesOff()



clearMidiFilePool

Removes all entries from the MIDi file pool.

Engine.clearMidiFilePool()



clearSampleMapPool

Removes all entries from the samplemap pool

Engine.clearSampleMapPool()



createAndRegisterAudioFile

Creates a audio file holder and registers it so you can access it from other modules.

Engine.createAndRegisterAudioFile(int index)



createAndRegisterSliderPackData

Creates a SliderPack Data object and registers it so you can access it from other modules.

Engine.createAndRegisterSliderPackData(int index)



createAndRegisterTableData

Creates a Table object and registers it so you can access it from other modules.

Engine.createAndRegisterTableData(int index)



createDspNetwork

Creates a Dsp node network.

Engine.createDspNetwork(String id)



createGlobalScriptLookAndFeel

Creates a (or returns an existing ) script look and feel object.

Engine.createGlobalScriptLookAndFeel()



createMessageHolder

Creates a storage object for Message events.

Engine.createMessageHolder()



createMidiList

Creates a MIDI List object.

Engine.createMidiList()



createSliderPackData

Creates a SliderPack Data object.

Engine.createSliderPackData()



createTimerObject

Creates a new timer object.

Engine.createTimerObject()



doubleToString

Returns a string of the value with the supplied number of digits.

Engine.doubleToString(double value, int digits)



dumpAsJSON

Exports an object as JSON.

Engine.dumpAsJSON(var object, String fileName)



extendTimeOut

Extends the compilation timeout. Use this if you have a long task that would get cancelled otherwise. This is doing nothing in compiled plugins.

Engine.extendTimeOut(int additionalMilliseconds)



getControlRateDownsamplingFactor

Returns the downsampling factor for the modulation signal (default is 8).

Engine.getControlRateDownsamplingFactor()



getCpuUsage

Returns the current CPU usage in percent (0 ... 100)

Engine.getCpuUsage()



getCurrentUserPresetName

Returns the currently loaded user preset (without extension).

Engine.getCurrentUserPresetName()



getDecibelsForGainFactor

Converts gain factor (0.0 .. 1.0) to decibel (-100.0 ... 0).

Engine.getDecibelsForGainFactor(double gainFactor)



getDeviceResolution

Returns the full screen resolution for the current device.

Engine.getDeviceResolution()



getDeviceType

Returns the mobile device that this software is running on.

Engine.getDeviceType()



getExpansionList

Creates a list of all available expansions.

Engine.getExpansionList()



getFilterModeList

Returns an object that contains all filter modes.

Engine.getFilterModeList()


You can use this object to create a list of filter modes you would like to add to your plugin.

Example Code:

// Create a filter effect
const var effect = Synth.addEffect("PolyphonicFilter", "filter", 0);

// Create a filter graph
const var display = Content.addFloatingTile("tile", 0, 0);
display.set("width", 200);
display.set("height", 50);
display.setContentData({"Type": "FilterDisplay", 
                        "ProcessorId": "filter"});

// Create a knob for the frequency
const var filterKnob = Content.addKnob("filterKnob", 250, 0);
filterKnob.set("mode", "Frequency");
inline function f(component, value){ effect.setAttribute(effect.Frequency, value); };
filterKnob.setControlCallback(f);

const var modeSelector = Content.addComboBox("modeSelector", 400, 10);

// Create the filter mode list object
const var filterList = Engine.getFilterModeList();

// Pick some values from the object and store it in an array
const var filterModes = [ filterList.StateVariableNotch, 
                          filterList.StateVariableLP ];
                          
// Create an array with a name for each mode
const var filterNames = [ "Notch",
                          "SVF Lowpass"];

// Use the filterNames list as combobox items
modeSelector.set("items", filterNames.join("\n"));


inline function modeCallback(component, value)
{
    // combobox values are starting with 1
    local index = value-1;
    
    if(index >= 0)
    {
        // use the index to get the actual number from the filterModes array.
        effect.setAttribute(effect.Mode, filterModes[index]);
    }
}

modeSelector.setControlCallback(modeCallback);


getFrequencyForMidiNoteNumber

Converts midi note number 0 ... 127 to Frequency 20 ... 20.000.

Engine.getFrequencyForMidiNoteNumber(int midiNumber)



getGainFactorForDecibels

Converts decibel (-100.0 ... 0.0) to gain factor (0.0 ... 1.0).

Engine.getGainFactorForDecibels(double decibels)



getHostBpm

Returns the Bpm of the host.

Engine.getHostBpm()



getLatencySamples

Returns the latency of the plugin as reported to the host. Default is 0.

Engine.getLatencySamples()



getMacroName

Returns the name for the given macro index.

Engine.getMacroName(int index)



getMasterPeakLevel

Returns the current peak volume (0...1) for the given channel.

Engine.getMasterPeakLevel(int channel)



getMemoryUsage

Returns the current memory usage in MB.

Engine.getMemoryUsage()


This only takes the size of the preload buffers and streaming buffers of the samples into account - the actual memory consumption might be much higher if you are using lots of images.

getMidiNoteFromName

Converts MIDI note name to MIDI number ("C3" for middle C).

Engine.getMidiNoteFromName(String midiNoteName)



getMidiNoteName

Converts MIDI note number to Midi note name ("C3" for middle C).

Engine.getMidiNoteName(int midiNumber)



getMilliSecondsForQuarterBeats

Converts quarter beats to milliseconds using the current tempo.

Engine.getMilliSecondsForQuarterBeats(double quarterBeats)



getMilliSecondsForQuarterBeatsWithTempo

Converts quarter beats to milliseconds using the given tempo.

Engine.getMilliSecondsForQuarterBeatsWithTempo(double quarterBeats, double bpm)



getMilliSecondsForSamples

Converts samples to milli seconds.

Engine.getMilliSecondsForSamples(double samples)



getMilliSecondsForTempo

Returns the millisecond value for the supplied tempo (HINT: Use "TempoSync" mode from Slider!)

Engine.getMilliSecondsForTempo(int tempoIndex)



getNumVoices

Returns the amount of currently active voices.

Engine.getNumVoices()



getOS

Returns the current operating system ("OSX" or ("WIN").

Engine.getOS()


You can use this method to query the OS in order to implement some platform specific code. HISE tries to abstract as much OS specifics as possible,but especially when it comes to font loading, there are some subtle differences between the different operating systems.

Console.print(Engine.getOS());


getPitchRatioFromSemitones

Converts a semitone value to a pitch ratio (-12 ... 12) -> (0.5 ... 2.0)

Engine.getPitchRatioFromSemitones(double semiTones)



getPlayHead

Allows access to the data of the host (playing status, timeline, etc...).

Engine.getPlayHead()



getPreloadProgress

Returns the preload progress from 0.0 to 1.0. Use this to display some kind of loading icon.

Engine.getPreloadProgress()



getQuarterBeatsForMilliSeconds

Converts milliseconds to quarter beats using the current tempo.

Engine.getQuarterBeatsForMilliSeconds(double milliSeconds)



getQuarterBeatsForMilliSecondsWithTempo

Converts milliseconds to quarter beats using the given tempo.

Engine.getQuarterBeatsForMilliSecondsWithTempo(double milliSeconds, double bpm)



getQuarterBeatsForSamples

Converts samples to quarter beats using the current tempo.

Engine.getQuarterBeatsForSamples(double samples)



getQuarterBeatsForSamplesWithTempo

Converts samples to quarter beats using the given tempo.

Engine.getQuarterBeatsForSamplesWithTempo(double samples, double bpm)



getRegexMatches

Returns an array with all matches.

Engine.getRegexMatches(String stringToMatch, String regex)



getSampleFilesFromDirectory

Iterates the given sub-directory of the Samples folder and returns a list with all references to audio files.

Engine.getSampleFilesFromDirectory( String relativePathFromSampleFolder, bool recursive)



getSampleRate

Returns the current sample rate.

Engine.getSampleRate()



getSamplesForMilliSeconds

Converts milli seconds to samples

Engine.getSamplesForMilliSeconds(double milliSeconds)



getSamplesForQuarterBeats

Converts quarter beats to samples using the current tempo.

Engine.getSamplesForQuarterBeats(double quarterBeats)



getSamplesForQuarterBeatsWithTempo

Converts quarter beats to samples using the given tempo.

Engine.getSamplesForQuarterBeatsWithTempo(double quarterBeats, double bpm)



getSemitonesFromPitchRatio

Converts a pitch ratio to semitones (0.5 ... 2.0) -> (-12 ... 12)

Engine.getSemitonesFromPitchRatio(double pitchRatio)



getSettingsWindowObject

Returns a object that contains the properties for the settings dialog.

Engine.getSettingsWindowObject()



getUptime

Returns the uptime of the engine in seconds.

Engine.getUptime()



getUserPresetList

Returns a list of all available user presets as relative path.

Engine.getUserPresetList()



getVersion

Returns the product version (not the HISE version!).

Engine.getVersion()



getZoomLevel

Returns the current Zoom Level.

Engine.getZoomLevel()



isControllerUsedByAutomation

Checks if the given CC number is used for parameter automation and returns the index of the control.

Engine.isControllerUsedByAutomation(int controllerNumber)



isMpeEnabled

Checks if the global MPE mode is enabled.

Engine.isMpeEnabled()



isPlugin

Returns true if running as VST / AU / AAX plugin.

Engine.isPlugin()



loadAudioFilesIntoPool

Calling this makes sure that all audio files are loaded into the pool and will be available in the compiled plugin.

Engine.loadAudioFilesIntoPool()



loadFont

Loads a font file. This is deprecated, because it might result in different names on various OS. Use loadFontAs() instead.

Engine.loadFont( String fileName)



loadFontAs

Loads the font from the given file in the image folder and registers it under the fontId. This is platform agnostic.

Engine.loadFontAs(String fileName, String fontId)



loadFromJSON

Imports a JSON file as object.

Engine.loadFromJSON(String fileName)



loadImageIntoPool

Loads an image into the pool. You can use a wildcard to load multiple images at once.

Engine.loadImageIntoPool( String id)



loadNextUserPreset

Loads the next user preset.

Engine.loadNextUserPreset(bool stayInDirectory)



loadPreviousUserPreset

Loads the previous user preset.

Engine.loadPreviousUserPreset(bool stayInDirectory)



loadUserPreset

Loads a user preset with the given relative path (use / for directory separation).

Engine.loadUserPreset( String relativePathWithoutFileEnding)



matchesRegex

Matches the string against the regex token.

Engine.matchesRegex(String stringToMatch, String regex)



openWebsite

launches the given URL in the system's web browser.

Engine.openWebsite(String url)



rebuildCachedPools

Rebuilds the entries for all cached pools (MIDI files and samplemaps).

Engine.rebuildCachedPools()



redo

Redo the last controller change.

Engine.redo()



saveUserPreset

Asks for a preset name (if presetName is empty) and saves the current user preset.

Engine.saveUserPreset(String presetName)



setAllowDuplicateSamples

Sets whether the samples are allowed to be duplicated. Set this to false if you operate on the same samples differently.

Engine.setAllowDuplicateSamples(bool shouldAllow)



setCompileProgress

Displays the progress (0.0 to 1.0) in the progress bar of the editor.

Engine.setCompileProgress(var progress)



setCurrentExpansion

Sets the active expansion and updates the preset browser.

Engine.setCurrentExpansion( String expansionName)



setGlobalFont

Sets the font that will be used as default font for various things.

Engine.setGlobalFont(String fontName)


In order to do so, put them all in a Fonts subdirectory of the Images folder, and access it with

javascriptEngine.loadFontAs("{PROJECT_FOLDER}Fonts/Heebo.ttf", "heebo");Engine.setGlobalFont("heebo");


setHostBpm

Overwrites the host BPM. Use -1 for sync to host.

Engine.setHostBpm(double newTempo)



setKeyColour

Sets a key of the global keyboard to the specified colour (using the form 0x00FF00 for eg. of the key to the specified colour.

Engine.setKeyColour(int keyNumber, int colourAsHex)



setLatencySamples

sets the latency of the plugin as reported to the host. Default is 0.

Engine.setLatencySamples(int latency)



setLowestKeyToDisplay

Changes the lowest visible key on the on screen keyboard.

Engine.setLowestKeyToDisplay(int keyNumber)



setUserPresetTagList

Sets the tags that appear in the user preset browser.

Engine.setUserPresetTagList(var listOfTags)



showErrorMessage

Shows a error message on the compiled plugin (or prints it on the console). Use isCritical if you want to disable the "Ignore" Button.

Engine.showErrorMessage(String message, bool isCritical)



showMessage

Shows a message with an overlay on the compiled plugin with an "OK" button in order to notify the user about important events.

Engine.showMessage(String message)



undo

Reverts the last controller change.

Engine.undo()