Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some methods #202

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hi_scripting/scripting/api/ScriptingApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ struct ScriptingApi::Engine::Wrapper
API_METHOD_WRAPPER_2(Engine, getDspNetworkReference);
API_METHOD_WRAPPER_1(Engine, getSystemTime);
API_METHOD_WRAPPER_1(Engine, loadAudioFileIntoBufferArray);
API_VOID_METHOD_WRAPPER_1(Engine, copyTextToClipboard);
};

ScriptingApi::Engine::Engine(ProcessorWithScriptingContent *p) :
Expand Down Expand Up @@ -1024,6 +1025,7 @@ parentMidiProcessor(dynamic_cast<ScriptBaseMidiProcessor*>(p))
ADD_API_METHOD_0(createExpansionHandler);
ADD_API_METHOD_3(showYesNoWindow);
ADD_API_METHOD_1(getSystemTime);
ADD_API_METHOD_1(copyTextToClipboard);
}


Expand All @@ -1037,6 +1039,11 @@ void ScriptingApi::Engine::allNotesOff()
getProcessor()->getMainController()->allNotesOff();
};

void ScriptingApi::Engine::copyTextToClipboard(String text)
{
SystemClipboard::copyTextToClipboard(text);
}

void ScriptingApi::Engine::addModuleStateToUserPreset(var moduleId)
{
if (auto jmp = dynamic_cast<JavascriptMidiProcessor*>(getProcessor()))
Expand Down
3 changes: 3 additions & 0 deletions hi_scripting/scripting/api/ScriptingApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ class ScriptingApi
/** Redo the last controller change. */
void redo();

/** Copies a string to the clipboard. */
void copyTextToClipboard(String text);

/** Returns a fully described string of this date and time in ISO-8601 format (using the local timezone) with or without divider characters. */
String getSystemTime(bool includeDividerCharacters);

Expand Down
12 changes: 12 additions & 0 deletions hi_scripting/scripting/api/ScriptingApiContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3948,6 +3948,8 @@ colour(Colour(0xff777777))
setMethod("setToolbarProperties", Wrapper::setToolbarProperties);
setMethod("setHeight", Wrapper::setHeight);
setMethod("setWidth", Wrapper::setWidth);
setMethod("getHeight", Wrapper::getHeight);
setMethod("getWidth", Wrapper::getWidth);
setMethod("createScreenshot", Wrapper::createScreenshot);
setMethod("addVisualGuide", Wrapper::addVisualGuide);
setMethod("makeFrontInterface", Wrapper::makeFrontInterface);
Expand Down Expand Up @@ -4191,6 +4193,16 @@ void ScriptingApi::Content::setWidth(int newWidth) noexcept

};

int ScriptingApi::Content::getHeight() const
{
return (int)height;
}

int ScriptingApi::Content::getWidth() const
{
return (int)width;
}

void ScriptingApi::Content::makeFrontInterface(int newWidth, int newHeight)
{
width = newWidth;
Expand Down
6 changes: 6 additions & 0 deletions hi_scripting/scripting/api/ScriptingApiContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,12 @@ class ScriptingApi::Content : public ScriptingObject,
/** Sets the height of the content. */
void setWidth(int newWidth) noexcept;

/** Gets the height of the interface. */
int getHeight() const;

/** Gets the width of the interface. */
int getWidth() const;

/** Creates a screenshot of the area relative to the content's origin. */
void createScreenshot(var area, var directory, String name);

Expand Down
22 changes: 22 additions & 0 deletions hi_scripting/scripting/api/ScriptingApiWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ struct ScriptingApi::Content::Wrapper
static var setPosition(const var::NativeFunctionArgs& args);
static var setHeight(const var::NativeFunctionArgs& args);
static var setWidth(const var::NativeFunctionArgs& args);
static var getHeight(const var::NativeFunctionArgs& args);
static var getWidth(const var::NativeFunctionArgs& args);
static var setName(const var::NativeFunctionArgs& args);
static var makeFrontInterface(const var::NativeFunctionArgs& args);
static var makeFullScreenInterface(const var::NativeFunctionArgs& args);
Expand Down Expand Up @@ -426,6 +428,16 @@ var ScriptingApi::Content::Wrapper::setHeight (const var::NativeFunctionArgs& ar
return var();
};

var ScriptingApi::Content::Wrapper::getHeight (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
{
return thisObject->getHeight();
}

return var();
};

var ScriptingApi::Content::Wrapper::setContentTooltip (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
Expand Down Expand Up @@ -478,6 +490,16 @@ var ScriptingApi::Content::Wrapper::setWidth (const var::NativeFunctionArgs& arg
return var();
};

var ScriptingApi::Content::Wrapper::getWidth (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
{
return thisObject->getWidth();
}

return var();
};

var ScriptingApi::Content::Wrapper::setName (const var::NativeFunctionArgs& args)
{
if (ScriptingApi::Content* thisObject = GET_OBJECT(Content))
Expand Down
5 changes: 5 additions & 0 deletions hi_scripting/scripting/engine/JavascriptEngineMathObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct HiseJavascriptEngine::RootObject::MathClass : public ApiClass
ADD_API_METHOD_1(tanh);
ADD_API_METHOD_1(atanh);
ADD_API_METHOD_1(log);
ADD_API_METHOD_1(log2);
ADD_API_METHOD_1(log10);
ADD_API_METHOD_1(exp);
ADD_API_METHOD_2(pow);
Expand Down Expand Up @@ -109,6 +110,7 @@ struct HiseJavascriptEngine::RootObject::MathClass : public ApiClass
API_METHOD_WRAPPER_1(MathClass, tanh);
API_METHOD_WRAPPER_1(MathClass, atanh);
API_METHOD_WRAPPER_1(MathClass, log);
API_METHOD_WRAPPER_1(MathClass, log2);
API_METHOD_WRAPPER_1(MathClass, log10);
API_METHOD_WRAPPER_1(MathClass, exp);
API_METHOD_WRAPPER_2(MathClass, pow);
Expand Down Expand Up @@ -219,6 +221,9 @@ struct HiseJavascriptEngine::RootObject::MathClass : public ApiClass
/** Calculates the log value (with base E). */
var log(var value) { return std::log((double)value); }

/** Calculates the log value (with base 2). */
var log2(var value) { return std::log2((double)value); }

/** Calculates the log value (with base 10). */
var log10(var value) { return std::log10((double)value); }

Expand Down
36 changes: 36 additions & 0 deletions hi_scripting/scripting/engine/JavascriptEngineObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct HiseJavascriptEngine::RootObject::ArrayClass : public DynamicObject
{
setMethod("contains", contains);
setMethod("remove", remove);
setMethod("removeIndex", remove);
setMethod("removeLast", remove);
setMethod("resize", remove);
setMethod("join", join);
setMethod("push", push);
setMethod("sort", sort);
Expand Down Expand Up @@ -54,6 +57,30 @@ struct HiseJavascriptEngine::RootObject::ArrayClass : public DynamicObject
return var();
}

static var removeIndex(Args a)
{
if (Array<var>* array = a.thisObject.getArray())
array->remove(get(a, 0));

return var();
}

static var removeLast(Args a)
{
if (Array<var>* array = a.thisObject.getArray())
array->removeLast(get(a, 0));

return var();
}

static var resize(Args a)
{
if (Array<var>* array = a.thisObject.getArray())
array->resize(get(a, 0));

return var();
}

static var join(Args a)
{
WARN_IF_AUDIO_THREAD(true, IllegalAudioThreadOps::StringCreation);
Expand Down Expand Up @@ -212,6 +239,15 @@ class DoxygenArrayFunctions
/** Removes all instances of the given element. */
var remove(var elementToRemove) { return var(); }

/** Removes the element at the given index. */
var removeIndex(var elementToRemove) { return var(); }

/** Removes n elements from the end. */
var removeLast(var elementToRemove) { return var(); }

/** Removes or adds empty elements to match the target size. */
var resize(var elementToRemove) { return var(); }

/** Reverses the order of the elements in the array. */
void reverse() {}

Expand Down
6 changes: 3 additions & 3 deletions projects/standalone/HISE Standalone.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<XCODE_MAC targetFolder="Builds/MacOSX" smallIcon="ho3qQy" bigIcon="ho3qQy"
extraLinkerFlags="/opt/intel/ipp/lib/libippi.a /opt/intel/ipp/lib/libipps.a /opt/intel/ipp/lib/libippvm.a /opt/intel/ipp/lib/libippcore.a"
customPList="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;&#10;&lt;plist version=&quot;1.0&quot;&gt;&#10;&lt;dict&gt;&#10;&lt;key&gt;NSAppTransportSecurity&lt;/key&gt; &#10;&lt;dict&gt; &#10;&lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;&lt;true/&gt;&#10;&lt;/dict&gt;&#10;&lt;/dict&gt;&#10;&lt;/plist&gt;"
extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1"
extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1&#10;HISE_SCRIPT_SERVER_TIMEOUT=20000"
extraCompilerFlags="-Wno-reorder -Wno-inconsistent-missing-override -mpopcnt">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" osxCompatibility="10.7 SDK" osxArchitecture="64BitIntel"
Expand Down Expand Up @@ -141,7 +141,7 @@
</XCODE_IPHONE>
<VS2017 targetFolder="Builds/VisualStudio2017" smallIcon="ho3qQy" bigIcon="ho3qQy"
useIPP="Sequential" IPPLibrary="Sequential" windowsTargetPlatformVersion="10.0.16299.0"
extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1"
extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1&#10;HISE_SCRIPT_SERVER_TIMEOUT=20000"
extraCompilerFlags="/bigobj">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
Expand Down Expand Up @@ -203,7 +203,7 @@
<MODULEPATH id="hi_snex" path="../../"/>
</MODULEPATHS>
</VS2017>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile" extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1&#10;"
<LINUX_MAKE targetFolder="Builds/LinuxMakefile" extraDefs="USE_IPP=1&#10;HI_ENABLE_EXPANSION_EDITING=1&#10;HISE_ENABLE_EXPANSIONS=1&#10;HISE_SCRIPT_SERVER_TIMEOUT=20000&#10;"
smallIcon="bfBEgJ" bigIcon="bfBEgJ" extraCompilerFlags="-Wno-reorder -Wno-inconsistent-missing-override"
linuxExtraPkgConfig="x11 xinerama xext" extraLinkerFlags="-no-pie&#10;/opt/intel/ipp/lib/intel64/libippi.a &#10;/opt/intel/ipp/lib/intel64/libipps.a&#10;/opt/intel/ipp/lib/intel64/libippvm.a&#10;/opt/intel/ipp/lib/intel64/libippcore.a&#10;">
<CONFIGURATIONS>
Expand Down
22 changes: 21 additions & 1 deletion projects/standalone/JuceLibraryCode/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@
#endif

#ifndef USE_VDSP_FFT
//#define USE_VDSP_FFT 0
//#define USE_VDSP_FFT 1
#endif

#ifndef FRONTEND_IS_PLUGIN
//#define FRONTEND_IS_PLUGIN 0
#endif

#ifndef PROCESS_SOUND_GENERATORS_IN_FX_PLUGIN
//#define PROCESS_SOUND_GENERATORS_IN_FX_PLUGIN 1
#endif

#ifndef FORCE_INPUT_CHANNELS
//#define FORCE_INPUT_CHANNELS 0
#endif
Expand Down Expand Up @@ -186,6 +190,10 @@
#define ENABLE_ALL_PEAK_METERS 1
#endif

#ifndef READ_ONLY_FACTORY_PRESETS
//#define READ_ONLY_FACTORY_PRESETS 0
#endif

#ifndef ENABLE_CONSOLE_OUTPUT
//#define ENABLE_CONSOLE_OUTPUT 1
#endif
Expand Down Expand Up @@ -285,6 +293,10 @@
//#define HISE_INCLUDE_SNEX 0
#endif

#ifndef SNEX_INCLUDE_MEMORY_ADDRESS_IN_DUMP
//#define SNEX_INCLUDE_MEMORY_ADDRESS_IN_DUMP 0
#endif

//==============================================================================
// hi_streaming flags:

Expand All @@ -299,6 +311,14 @@
//#define HISE_NO_GUI_TOOLS 0
#endif

#ifndef HISE_USE_NEW_CODE_EDITOR
//#define HISE_USE_NEW_CODE_EDITOR 1
#endif

#ifndef IS_MARKDOWN_EDITOR
//#define IS_MARKDOWN_EDITOR 0
#endif

//==============================================================================
// juce_audio_devices flags:

Expand Down