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

Single method to file #377

Open
wants to merge 20 commits into
base: master
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
36 changes: 24 additions & 12 deletions Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Builds/MacOSX/Info-AU.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<key>manufacturer</key>
<string>inSt</string>
<key>type</key>
<string>CtrlrAU</string>
<string>aumi</string>
<key>subtype</key>
<string>cTrl</string>
<key>version</key>
Expand Down
2 changes: 1 addition & 1 deletion Builds/MacOSX/Info-AUv3_AppExtension.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<key>manufacturer</key>
<string>inSt</string>
<key>type</key>
<string>CtrlrAU</string>
<string>aumi</string>
<key>subtype</key>
<string>cTrl</string>
<key>version</key>
Expand Down
6 changes: 3 additions & 3 deletions Ctrlr.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pluginIsSynth="1" pluginWantsMidiIn="1" pluginProducesMidiOut="1"
pluginIsMidiEffectPlugin="1" pluginEditorRequiresKeys="1" pluginAUExportPrefix="CtrlrAU"
pluginRTASCategory="" aaxIdentifier="com.instigator.Ctrlr" pluginAAXCategory="2"
companyName="Instigator" pluginAUMainType="CtrlrAU" pluginFormats="buildVST,buildVST3,buildAU,buildAUv3,buildStandalone"
companyName="Instigator" pluginFormats="buildVST,buildVST3,buildAU,buildAUv3,buildStandalone"
pluginCharacteristicsValue="pluginIsSynth,pluginWantsMidiIn,pluginProducesMidiOut,pluginIsMidiEffectPlugin,pluginEditorRequiresKeys"
jucerFormatVersion="1">
<MAINGROUP id="SRLsFb" name="Ctrlr">
Expand Down Expand Up @@ -1060,9 +1060,9 @@
enableGNUExtensions="0" extraCompilerFlags="-w">
<CONFIGURATIONS>
<CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="Ctrlr"
headerPath="../../Source&#10;../../Source/Misc&#10;../../Source/Misc/include&#10;../../Source/Misc/lua/include&#10;../../Source/Misc/luabind&#10;../../Source/Misc/libusb/include&#10;../../Source/Misc/boost&#10;../../Source/MIDI&#10;../../Source/Core&#10;../../Source/Native&#10;../../Source/Plugin&#10;../../Source/UIComponents&#10;../../Source/Lua"/>
headerPath="../../Source&#10;../../Source/Misc&#10;../../Source/Misc/include&#10;../../Source/Misc/lua/include&#10;../../Source/Misc/luabind&#10;../../Source/Misc/libusb/include&#10;../../Source/Misc/boost&#10;../../Source/Misc/vst2sdk&#10;../../Source/MIDI&#10;../../Source/Core&#10;../../Source/Native&#10;../../Source/Plugin&#10;../../Source/UIComponents&#10;../../Source/Lua"/>
<CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="Ctrlr"
headerPath="../../Source&#10;../../Source/Misc&#10;../../Source/Misc/include&#10;../../Source/Misc/lua/include&#10;../../Source/Misc/luabind&#10;../../Source/Misc/libusb/include&#10;../../Source/Misc/boost&#10;../../Source/MIDI&#10;../../Source/Core&#10;../../Source/Native&#10;../../Source/Plugin&#10;../../Source/UIComponents&#10;../../Source/Lua"
headerPath="../../Source&#10;../../Source/Misc&#10;../../Source/Misc/include&#10;../../Source/Misc/lua/include&#10;../../Source/Misc/luabind&#10;../../Source/Misc/libusb/include&#10;../../Source/Misc/boost&#10;../../Source/Misc/vst2sdk&#10;../../Source/MIDI&#10;../../Source/Core&#10;../../Source/Native&#10;../../Source/Plugin&#10;../../Source/UIComponents&#10;../../Source/Lua"
enablePluginBinaryCopyStep="0"/>
</CONFIGURATIONS>
<MODULEPATHS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev

// [4/4]
/* <-- kEventParamOrigin (out, typeHIPoint)
* On exit, contains the scrollable views current origin (the
* On exit, contains the scrollable view's current origin (the
* view-relative coordinate that is drawn at the top left
* corner of its frame). These coordinates should always be
* greater than or equal to zero. They should be less than or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String&
g.setColour (findColour (PropertyComponent::labelTextColourId));

g.setFont ({ (float) height * 0.7f, Font::bold });
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
g.drawText (name, textX, 0, std::max(width - textX - 4,1), height, Justification::centredLeft, true);
}

void LookAndFeel_V4::drawPropertyComponentBackground (Graphics& g, int width, int height, PropertyComponent& component)
Expand Down
4 changes: 2 additions & 2 deletions JuceLibraryCode/BinaryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18778,8 +18778,8 @@ static const unsigned char temp_binary_data_81[] =
"end\r\n"
" </utility>\r\n"
"\r\n"
" <utility name=\"json4lua\" description=\"JSON implementation\" alwaysUpdate=\"1\" uuid=\"00000000000000000000000000000004\" resource=\"json_lua\" />\r\n"
" <utility name=\"debugger.lua\" description=\"clidebugger\" alwaysUpdate=\"1\" uuid=\"00000000000000000000000000000005\" resource=\"debugger_lua\" />\r\n"
" <utility name=\"json\" description=\"JSON implementation\" alwaysUpdate=\"1\" uuid=\"00000000000000000000000000000004\" resource=\"json_lua\" />\r\n"
" <utility name=\"debugger\" description=\"clidebugger\" alwaysUpdate=\"1\" uuid=\"00000000000000000000000000000005\" resource=\"debugger_lua\" />\r\n"
" <utility name=\"inspect\" description=\"Lua table inspector\" alwaysUpdate=\"1\" uuid=\"00000000000000000000000000000006\" resource=\"inspect_lua\" />\r\n"
" </utilityMethods>\r\n"
"</methods>\r\n";
Expand Down
2 changes: 1 addition & 1 deletion JuceLibraryCode/JucePluginDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#define JucePlugin_Vst3Category "Instrument|Synth"
#endif
#ifndef JucePlugin_AUMainType
#define JucePlugin_AUMainType CtrlrAU
#define JucePlugin_AUMainType 'aumi'
#endif
#ifndef JucePlugin_AUSubType
#define JucePlugin_AUSubType JucePlugin_PluginCode
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Control any MIDI enabled hardware: synthesizers, drum machines, samplers, effect

Cross Platform
==============
Works on Windows (XP and up, both 64 and 32bit binaries are available), MAC OSX (10.5 and up), Linux (any modern distro should run it).
Works on Windows (XP and up, both 64 and 32bit binaries are available), macOS (10.5 and up), Linux (any modern distro should run it).
Host in your DAW

Each platform has a VST build of Ctrlr so you can host your panels as normal VST plugins, for the OSX a special AU build is available.
Each platform has a VST build of Ctrlr so you can host your panels as normal VST plugins, for macOS a special AU build is available.

Customize
=========
Expand Down Expand Up @@ -71,15 +71,17 @@ The post-commit script takes an argument "clean" if you wish to clean all the in
files before building. If you want to ignore any package errors that it reports (i assume you
know your system better then my script) then just add -f as an option when building.

OSX
===
You need the CoreAudio developer files for the build to work.
macOS
=====
Unzip boost or link your own boost library e.g. from [Homebrew](https://brew.sh):

First you need to build the AU_wrapper library that simplifies the build a lot, it's located in
Builds/Generated/Mac/AU_Wrapper, it will create a .a library and try to put it in /usr/local/lib
if it fails, do that manualy (permission problems)
```
# use packaged boost library
cd Source/Misc/boost && unzip boost.zip
# alternatively, link your own
ln -s /opt/homebrew/Cellar/boost/BOOST_VERSION/include/boost Source/Misc/boost/boost
```

Open the corresponding Xcode project in Builds/Generated/Mac, after that just build it, in case of
errors you are on your own, the amount of changes between Xcode versions and OSX versions is impossible
for me to track, you can post an issue and i'll try to solve it.
Open the Xcode project `Builds/MacOSX/Ctrlr.xcodeproj` and build it.

In case of errors it might help to refresh the project files using Projuicer.
6 changes: 3 additions & 3 deletions Source/Core/CtrlrModulator/CtrlrModulatorProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void CtrlrModulatorProcessor::handleAsyncUpdate()
if (valueChangedCbk.get() && !owner.getRestoreState())
{
CtrlrPanel &ownerPanel = owner.getOwnerPanel();
if (!ownerPanel.getRestoreState() && !ownerPanel.getBootstrapState() && valueChangedCbk->isValid())
if (!ownerPanel.getRestoreState() && !ownerPanel.getBootstrapState() && valueChangedCbk->isCallable())
{
owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (valueChangedCbk,
&owner,
Expand Down Expand Up @@ -324,7 +324,7 @@ int CtrlrModulatorProcessor::getValueFromMidiMessage(const CtrlrMIDIDeviceType s

if (getValueFromMidiCbk)
{
if (!getValueFromMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isValid())
if (!getValueFromMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isCallable())
{
evaluationResult = owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (getValueFromMidiCbk, &owner, getMidiMessage(source), evaluationResult);
}
Expand Down Expand Up @@ -477,7 +477,7 @@ int CtrlrModulatorProcessor::getValueForMidiMessage(const int value)

if (getValueForMidiCbk)
{
if (!getValueForMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isValid())
if (!getValueForMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isCallable())
{
evaluationResult = owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (getValueForMidiCbk, &owner, evaluationResult);
}
Expand Down
25 changes: 13 additions & 12 deletions Source/Core/CtrlrPanel/CtrlrPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ Result CtrlrPanel::restoreState (const ValueTree &savedState)
File panelFile = userDocsDir.getNonexistentChildFile("CtrlrPanel", ".panel");
filePath = panelFile.getFullPathName();
}
_DBG(filePath);
panelTree.setProperty(Ids::panelFilePath, filePath, nullptr);

ctrlrLuaManager->restoreState(savedState.getChildWithName(Ids::luaManager));
Expand Down Expand Up @@ -278,7 +279,7 @@ Result CtrlrPanel::restoreState (const ValueTree &savedState)

if (luaPanelBeforeLoadCbk && !luaPanelBeforeLoadCbk.wasObjectDeleted())
{
if (luaPanelBeforeLoadCbk->isValid())
if (luaPanelBeforeLoadCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelBeforeLoadCbk);
}
Expand Down Expand Up @@ -342,7 +343,7 @@ void CtrlrPanel::bootstrapPanel(const bool setInitialProgram)

if (luaPanelLoadedCbk.get())
{
if (luaPanelLoadedCbk->isValid())
if (luaPanelLoadedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelLoadedCbk, (uint8)owner.getInstanceMode());
}
Expand Down Expand Up @@ -829,7 +830,7 @@ ValueTree CtrlrPanel::getCustomData()

if (luaPanelSaveStateCbk && !luaPanelSaveStateCbk.wasObjectDeleted())
{
if (luaPanelSaveStateCbk->isValid())
if (luaPanelSaveStateCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelSaveStateCbk, customData);
}
Expand All @@ -852,7 +853,7 @@ void CtrlrPanel::setCustomData (const ValueTree &customData)
{
if (luaPanelRestoreStateCbk && !luaPanelRestoreStateCbk.wasObjectDeleted())
{
if (luaPanelRestoreStateCbk->isValid())
if (luaPanelRestoreStateCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelRestoreStateCbk, customData);
}
Expand Down Expand Up @@ -912,7 +913,7 @@ void CtrlrPanel::setProgram(ValueTree programTree, const bool sendSnapshotNow)

if (luaPanelProgramChangedCbk && !luaPanelProgramChangedCbk.wasObjectDeleted())
{
if (luaPanelProgramChangedCbk->isValid())
if (luaPanelProgramChangedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelProgramChangedCbk);
}
Expand Down Expand Up @@ -1088,7 +1089,7 @@ void CtrlrPanel::handleAsyncUpdate()
bool luaValid = false;

if (luaPanelMidiReceivedCbk)
luaValid = luaPanelMidiReceivedCbk->isValid();
luaValid = luaPanelMidiReceivedCbk->isCallable();

while (i.getNextEvent(m,time))
{
Expand Down Expand Up @@ -1181,7 +1182,7 @@ void CtrlrPanel::setMidiChannel(const CtrlrPanelMidiChannel optionToSet, const u

if (luaPanelMidiChannelChangedCbk && !luaPanelMidiChannelChangedCbk.wasObjectDeleted())
{
if (luaPanelMidiChannelChangedCbk->isValid())
if (luaPanelMidiChannelChangedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelMidiChannelChangedCbk, (int)optionToSet, (int)value);
}
Expand Down Expand Up @@ -1275,7 +1276,7 @@ void CtrlrPanel::modulatorValueChanged(CtrlrModulator *m)

if (luaPanelModulatorValueChangedCbk && !luaPanelModulatorValueChangedCbk.wasObjectDeleted())
{
if (luaPanelModulatorValueChangedCbk->isValid())
if (luaPanelModulatorValueChangedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelModulatorValueChangedCbk, m, m->getValueNonMapped());
}
Expand Down Expand Up @@ -1461,7 +1462,7 @@ void CtrlrPanel::luaSavePanel(const CtrlrPanelFileType fileType, const File &fil
{
if (luaPanelSavedCbk && !luaPanelSavedCbk.wasObjectDeleted())
{
if (luaPanelSavedCbk->isValid())
if (luaPanelSavedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelSavedCbk, (int)fileType, file);
}
Expand Down Expand Up @@ -1497,7 +1498,7 @@ void CtrlrPanel::sendMidiProgramChange()

if (luaPanelProgramChangedCbk && !luaPanelProgramChangedCbk.wasObjectDeleted())
{
if (luaPanelProgramChangedCbk->isValid())
if (luaPanelProgramChangedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelProgramChangedCbk, program, bankLsb, bankMsb);
}
Expand Down Expand Up @@ -1665,7 +1666,7 @@ void CtrlrPanel::notify (const String &notification, CtrlrNotificationCallback *
{
if (luaPanelMessageHandlerCbk && !luaPanelMessageHandlerCbk.wasObjectDeleted())
{
if (luaPanelMessageHandlerCbk->isValid())
if (luaPanelMessageHandlerCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelMessageHandlerCbk, notification, ctrlrNotificationType);
}
Expand Down Expand Up @@ -1765,7 +1766,7 @@ void CtrlrPanel::resourceImportFinished()

if (luaPanelResourcesLoadedCbk && !luaPanelResourcesLoadedCbk.wasObjectDeleted())
{
if (luaPanelResourcesLoadedCbk->isValid())
if (luaPanelResourcesLoadedCbk->isCallable())
{
getCtrlrLuaManager().getMethodManager().call (luaPanelResourcesLoadedCbk);
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/CtrlrPanel/CtrlrPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class CtrlrPanel: public ValueTree::Listener,
File getPanelContentDir();
File getPanelLuaDir();
File getPanelResourcesDir();
Result convertLuaMethodToFile(ValueTree & item);
Result convertLuaMethodsToFiles(const String dirPath);
File getLuaMethodGroupDir(const ValueTree &methodGroup);

Expand Down Expand Up @@ -183,7 +184,8 @@ class CtrlrPanel: public ValueTree::Listener,
static void writePanelXml(OutputStream &outputStream, CtrlrPanel *panel, const bool compressPanel);
Result writeLuaMethod(const File &parentDir, ValueTree *method);
Result writeLuaMethodGroup(const File &parentDir, ValueTree *methodGroup);
Result writeLuaChildren(const File &parentDir, ValueTree *parentElement);
Result writeLuaChild(const File &parentDir, ValueTree *child);
Result writeLuaChildren(const File &parentDir, ValueTree *parentElement);
File getLuaMethodSourceFile(const ValueTree *method);
static void convertLuaMethodsToPropeties(const File &panelLuaDir, ValueTree &panelTree);
static void convertLuaMethodToProperty(const File &panelLuaDir, ValueTree *method);
Expand Down
82 changes: 62 additions & 20 deletions Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,36 @@ File CtrlrPanel::getLuaMethodGroupDir(const ValueTree &methodGroup)
return result;
}

Result CtrlrPanel::convertLuaMethodToFile(ValueTree & item)
{
Result res = Result::ok();
if (!item.isValid() || !item.hasType(Ids::luaMethod))
{
res = Result::fail("Internal error: Ony Lua methods can be converted to files.");
}
File methodLuaDirectory(getLuaMethodGroupDir(item.getParent()));
if (methodLuaDirectory.existsAsFile())
{ // A directory with that name already exists
res = Result::fail("Convert to file can't create directory (a file with that name already exists): " + methodLuaDirectory.getFullPathName());
}
else if (!methodLuaDirectory.exists())
{
res = methodLuaDirectory.createDirectory();
}
if (res.ok())
{
if (methodLuaDirectory.hasWriteAccess())
{ // Save lua code
res = writeLuaChild(methodLuaDirectory, &item);
}
else
{
res = Result::fail("Convert to XML can't write in panel directory: " + methodLuaDirectory.getFullPathName());
}
}
return res;
}

Result CtrlrPanel::convertLuaMethodsToFiles(const String dirPath)
{
Result res = Result::ok();
Expand Down Expand Up @@ -680,35 +710,46 @@ Result CtrlrPanel::writeLuaMethodGroup(const File &parentDir, ValueTree *methodG
return res;
}

Result CtrlrPanel::writeLuaChildren(const File &parentDir, ValueTree *parentElement)
Result CtrlrPanel::writeLuaChild(const File &parentDir, ValueTree *child)
{
if (parentElement == nullptr)
return Result::fail("Parent element is missing");
if (child == nullptr)
return Result::fail("Child element is missing");

Result res = Result::ok();
for (int i = 0; i<parentElement->getNumChildren(); i++)
if (child->hasType(Ids::luaMethod))
{
ValueTree child = parentElement->getChild(i);
if (child.hasType(Ids::luaMethod))
{
if ((int)child.getProperty(Ids::luaMethodSource) != CtrlrLuaMethod::codeInFile)
{ // Only process methods that are not already saved in files
res = CtrlrPanel::writeLuaMethod(parentDir, &child);
if (res.failed())
{ // Break on first error
return res;
}
}
}
else if (child.hasType(Ids::luaMethodGroup))
if ((int)child->getProperty(Ids::luaMethodSource) != CtrlrLuaMethod::codeInFile)
{
res = CtrlrPanel::writeLuaMethodGroup(parentDir, &child);
// Only process methods that are not already saved in files
res = CtrlrPanel::writeLuaMethod(parentDir, child);
if (res.failed())
{ // Break on first error
return res;
}
}
}
else if (child->hasType(Ids::luaMethodGroup))
{
res = CtrlrPanel::writeLuaMethodGroup(parentDir, child);
if (res.failed())
{ // Break on first error
return res;
}
}
return res;
}

Result CtrlrPanel::writeLuaChildren(const File &parentDir, ValueTree *parentElement)
{
if (parentElement == nullptr)
return Result::fail("Parent element is missing");

Result res = Result::ok();
for (int i = 0; i<parentElement->getNumChildren(); i++)
{
ValueTree child = parentElement->getChild(i);
writeLuaChild(parentDir, &child);
}
return res;
}

Expand Down Expand Up @@ -978,7 +1019,8 @@ void CtrlrPanel::updatePanelWindowTitle()
{
editor->setName(newName);
// Trigger editor window title update
owner.getEditor()->activeCtrlrChanged();
auto editor = owner.getEditor();
if (editor) editor->activeCtrlrChanged();
}
}
}
Expand Down Expand Up @@ -1038,4 +1080,4 @@ bool CtrlrPanel::canClose(const bool closePanel)
}
}
return result;
}
}
Loading