@@ -1,5 +1,6 @@ | |||||
/Rack | /Rack | ||||
/Rack.exe | /Rack.exe | ||||
/libRack.a | |||||
/autosave.json | /autosave.json | ||||
/settings.json | /settings.json | ||||
/plugins | /plugins | ||||
@@ -180,17 +180,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||
THE SOFTWARE. | THE SOFTWARE. | ||||
# portaudio | |||||
# RtAudio | |||||
PortAudio Portable Real-Time Audio Library | |||||
Copyright (c) 1999-2011 Ross Bencina and Phil Burk | |||||
RtAudio: a set of realtime audio i/o C++ classes | |||||
Copyright (c) 2001-2017 Gary P. Scavone | |||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |||||
Permission is hereby granted, free of charge, to any person | |||||
obtaining a copy of this software and associated documentation files | |||||
(the "Software"), to deal in the Software without restriction, | |||||
including without limitation the rights to use, copy, modify, merge, | |||||
publish, distribute, sublicense, and/or sell copies of the Software, | |||||
and to permit persons to whom the Software is furnished to do so, | |||||
subject to the following conditions: | |||||
The above copyright notice and this permission notice shall be | |||||
included in all copies or substantial portions of the Software. | |||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |||||
Any person wishing to distribute modifications to the Software is | |||||
asked to send the modifications to the original developer so that | |||||
they can be incorporated into the canonical version. This is, | |||||
however, not a binding provision of this license. | |||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR | |||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||||
# RtMidi | # RtMidi | ||||
@@ -69,8 +69,14 @@ ifeq ($(ARCH), win) | |||||
env PATH=dep/bin:/mingw64/bin gdb -ex run ./Rack | env PATH=dep/bin:/mingw64/bin gdb -ex run ./Rack | ||||
endif | endif | ||||
perf: $(TARGET) | |||||
ifeq ($(ARCH), lin) | |||||
LD_LIBRARY_PATH=dep/lib perf record --call-graph dwarf ./Rack | |||||
endif | |||||
clean: | clean: | ||||
rm -fv libRack.a | |||||
rm -rfv $(TARGET) build dist | rm -rfv $(TARGET) build dist | ||||
# For Windows resources | # For Windows resources | ||||
@@ -106,7 +112,6 @@ ifeq ($(ARCH), mac) | |||||
cp dep/lib/libsamplerate.0.dylib $(BUNDLE)/Contents/MacOS/ | cp dep/lib/libsamplerate.0.dylib $(BUNDLE)/Contents/MacOS/ | ||||
cp dep/lib/libcurl.4.dylib $(BUNDLE)/Contents/MacOS/ | cp dep/lib/libcurl.4.dylib $(BUNDLE)/Contents/MacOS/ | ||||
cp dep/lib/libzip.5.dylib $(BUNDLE)/Contents/MacOS/ | cp dep/lib/libzip.5.dylib $(BUNDLE)/Contents/MacOS/ | ||||
cp dep/lib/libportaudio.2.dylib $(BUNDLE)/Contents/MacOS/ | |||||
cp dep/lib/librtmidi.4.dylib $(BUNDLE)/Contents/MacOS/ | cp dep/lib/librtmidi.4.dylib $(BUNDLE)/Contents/MacOS/ | ||||
cp dep/lib/librtaudio.dylib $(BUNDLE)/Contents/MacOS/ | cp dep/lib/librtaudio.dylib $(BUNDLE)/Contents/MacOS/ | ||||
@@ -116,7 +121,6 @@ ifeq ($(ARCH), mac) | |||||
install_name_tool -change $(PWD)/dep/lib/libsamplerate.0.dylib @executable_path/libsamplerate.0.dylib $(BUNDLE)/Contents/MacOS/Rack | install_name_tool -change $(PWD)/dep/lib/libsamplerate.0.dylib @executable_path/libsamplerate.0.dylib $(BUNDLE)/Contents/MacOS/Rack | ||||
install_name_tool -change $(PWD)/dep/lib/libcurl.4.dylib @executable_path/libcurl.4.dylib $(BUNDLE)/Contents/MacOS/Rack | install_name_tool -change $(PWD)/dep/lib/libcurl.4.dylib @executable_path/libcurl.4.dylib $(BUNDLE)/Contents/MacOS/Rack | ||||
install_name_tool -change $(PWD)/dep/lib/libzip.5.dylib @executable_path/libzip.5.dylib $(BUNDLE)/Contents/MacOS/Rack | install_name_tool -change $(PWD)/dep/lib/libzip.5.dylib @executable_path/libzip.5.dylib $(BUNDLE)/Contents/MacOS/Rack | ||||
install_name_tool -change $(PWD)/dep/lib/libportaudio.2.dylib @executable_path/libportaudio.2.dylib $(BUNDLE)/Contents/MacOS/Rack | |||||
install_name_tool -change $(PWD)/dep/lib/librtmidi.4.dylib @executable_path/librtmidi.4.dylib $(BUNDLE)/Contents/MacOS/Rack | install_name_tool -change $(PWD)/dep/lib/librtmidi.4.dylib @executable_path/librtmidi.4.dylib $(BUNDLE)/Contents/MacOS/Rack | ||||
install_name_tool -change librtaudio.dylib @executable_path/librtaudio.dylib $(BUNDLE)/Contents/MacOS/Rack | install_name_tool -change librtaudio.dylib @executable_path/librtaudio.dylib $(BUNDLE)/Contents/MacOS/Rack | ||||
@@ -51,6 +51,8 @@ You may use make's `-j$(nproc)` flag to parallelize builds across all your CPU c | |||||
make dep | make dep | ||||
You may use `make dep RTAUDIO_ALL_APIS=1` to attempt to build with all audio driver APIs enabled for your operating system. | |||||
You should see a message that all dependencies built successfully. | You should see a message that all dependencies built successfully. | ||||
Build Rack. | Build Rack. | ||||
@@ -86,13 +86,12 @@ $(glew): | |||||
$(MAKE) -C glew-2.1.0 GLEW_DEST="$(LOCAL)" LIBDIR="$(LOCAL)/lib" install | $(MAKE) -C glew-2.1.0 GLEW_DEST="$(LOCAL)" LIBDIR="$(LOCAL)/lib" install | ||||
$(glfw): | $(glfw): | ||||
$(WGET) https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip | |||||
$(UNZIP) glfw-3.2.1.zip | |||||
cd glfw-3.2.1 && $(CMAKE) . \ | |||||
git clone https://github.com/glfw/glfw.git | |||||
cd glfw && $(CMAKE) . \ | |||||
-DCMAKE_INSTALL_PREFIX="$(LOCAL)" -DBUILD_SHARED_LIBS=ON \ | -DCMAKE_INSTALL_PREFIX="$(LOCAL)" -DBUILD_SHARED_LIBS=ON \ | ||||
-DGLFW_USE_CHDIR=OFF -DGLFW_USE_MENUBAR=ON -DGLFW_USE_RETINA=ON | |||||
$(MAKE) -C glfw-3.2.1 | |||||
$(MAKE) -C glfw-3.2.1 install | |||||
-DGLFW_COCOA_CHDIR_RESOURCES=OFF -DGLFW_COCOA_MENUBAR=ON -DGLFW_COCOA_RETINA_FRAMEBUFFER=ON | |||||
$(MAKE) -C glfw | |||||
$(MAKE) -C glfw install | |||||
ifeq ($(ARCH),win) | ifeq ($(ARCH),win) | ||||
# Not sure why the GLFW build system puts a .dll in the lib directory | # Not sure why the GLFW build system puts a .dll in the lib directory | ||||
mv "$(LOCAL)/lib/glfw3.dll" "$(LOCAL)/bin/" | mv "$(LOCAL)/lib/glfw3.dll" "$(LOCAL)/bin/" | ||||
@@ -51,6 +51,11 @@ struct SlewLimiter { | |||||
float rise = 1.0; | float rise = 1.0; | ||||
float fall = 1.0; | float fall = 1.0; | ||||
float out = 0.0; | float out = 0.0; | ||||
void setRiseFall(float _rise, float _fall) { | |||||
rise = _rise; | |||||
fall = _fall; | |||||
} | |||||
float process(float in) { | float process(float in) { | ||||
float delta = clampf(in - out, -fall, rise); | float delta = clampf(in - out, -fall, rise); | ||||
out += delta; | out += delta; | ||||
@@ -295,7 +295,7 @@ struct Label : Widget { | |||||
/** Deletes itself from parent when clicked */ | /** Deletes itself from parent when clicked */ | ||||
struct MenuOverlay : OpaqueWidget { | struct MenuOverlay : OpaqueWidget { | ||||
void step() override; | void step() override; | ||||
void onDragDrop(EventDragDrop &e) override; | |||||
void onMouseDown(EventMouseDown &e) override; | |||||
void onHoverKey(EventHoverKey &e) override; | void onHoverKey(EventHoverKey &e) override; | ||||
}; | }; | ||||
@@ -60,8 +60,11 @@ void ModuleWidget::setPanel(std::shared_ptr<SVG> svg) { | |||||
json_t *ModuleWidget::toJson() { | json_t *ModuleWidget::toJson() { | ||||
json_t *rootJ = json_object(); | json_t *rootJ = json_object(); | ||||
// manufacturer | |||||
// plugin | |||||
json_object_set_new(rootJ, "plugin", json_string(model->plugin->slug.c_str())); | json_object_set_new(rootJ, "plugin", json_string(model->plugin->slug.c_str())); | ||||
// version (of plugin) | |||||
if (!model->plugin->version.empty()) | |||||
json_object_set_new(rootJ, "version", json_string(model->plugin->version.c_str())); | |||||
// model | // model | ||||
json_object_set_new(rootJ, "model", json_string(model->slug.c_str())); | json_object_set_new(rootJ, "model", json_string(model->slug.c_str())); | ||||
// pos | // pos | ||||
@@ -23,7 +23,7 @@ void SVGSlider::step() { | |||||
void SVGSlider::onChange(EventChange &e) { | void SVGSlider::onChange(EventChange &e) { | ||||
dirty = true; | dirty = true; | ||||
ParamWidget::onChange(e); | |||||
Knob::onChange(e); | |||||
} | } | ||||
@@ -151,12 +151,13 @@ Toolbar::Toolbar() { | |||||
struct ZoomSlider : Slider { | struct ZoomSlider : Slider { | ||||
void onAction(EventAction &e) override { | void onAction(EventAction &e) override { | ||||
Slider::onAction(e); | Slider::onAction(e); | ||||
gRackScene->zoomWidget->setZoom(value / 100.0); | |||||
gRackScene->zoomWidget->setZoom(roundf(value) / 100.0); | |||||
} | } | ||||
}; | }; | ||||
zoomSlider = new ZoomSlider(); | zoomSlider = new ZoomSlider(); | ||||
zoomSlider->box.pos = Vec(xPos, margin); | zoomSlider->box.pos = Vec(xPos, margin); | ||||
zoomSlider->box.size.x = 150; | zoomSlider->box.size.x = 150; | ||||
zoomSlider->precision = 0; | |||||
zoomSlider->label = "Zoom"; | zoomSlider->label = "Zoom"; | ||||
zoomSlider->unit = "%"; | zoomSlider->unit = "%"; | ||||
zoomSlider->setLimits(25.0, 200.0); | zoomSlider->setLimits(25.0, 200.0); | ||||
@@ -110,7 +110,7 @@ void MIDITriggerToCVInterface::processMidi(std::vector<unsigned char> msg) { | |||||
if (status == 0x8) { // note off | if (status == 0x8) { // note off | ||||
for (int i = 0; i < NUM_OUTPUTS; i++) { | for (int i = 0; i < NUM_OUTPUTS; i++) { | ||||
if (data1 == trigger[i].num) { | if (data1 == trigger[i].num) { | ||||
trigger[i].val = data2; | |||||
trigger[i].val = 0; | |||||
} | } | ||||
} | } | ||||
return; | return; | ||||
@@ -445,11 +445,9 @@ void guiRun() { | |||||
} | } | ||||
// Get framebuffer size | // Get framebuffer size | ||||
int width, height; | |||||
glfwGetFramebufferSize(gWindow, &width, &height); | |||||
int windowWidth, windowHeight; | |||||
glfwGetWindowSize(gWindow, &windowWidth, &windowHeight); | |||||
float pixelRatio = (float)width / windowWidth; | |||||
float pixelRatio; | |||||
glfwGetWindowContentScale(gWindow, &pixelRatio, NULL); | |||||
pixelRatio = roundf(pixelRatio); | |||||
if (pixelRatio != gPixelRatio) { | if (pixelRatio != gPixelRatio) { | ||||
EventZoom eZoom; | EventZoom eZoom; | ||||
gScene->onZoom(eZoom); | gScene->onZoom(eZoom); | ||||
@@ -144,6 +144,16 @@ static int loadPlugin(std::string path) { | |||||
plugin->handle = handle; | plugin->handle = handle; | ||||
initCallback(plugin); | initCallback(plugin); | ||||
// Reject plugin if slug already exists | |||||
for (Plugin *p : gPlugins) { | |||||
if (plugin->slug == p->slug) { | |||||
warn("Plugin \"%s\" is already loaded, not attempting to load it again"); | |||||
// TODO | |||||
// Fix memory leak with `plugin` here | |||||
return -1; | |||||
} | |||||
} | |||||
// Add plugin to list | // Add plugin to list | ||||
gPlugins.push_back(plugin); | gPlugins.push_back(plugin); | ||||
info("Loaded plugin %s", libraryFilename.c_str()); | info("Loaded plugin %s", libraryFilename.c_str()); | ||||
@@ -13,10 +13,12 @@ void MenuOverlay::step() { | |||||
} | } | ||||
} | } | ||||
void MenuOverlay::onDragDrop(EventDragDrop &e) { | |||||
if (e.origin == this) { | |||||
void MenuOverlay::onMouseDown(EventMouseDown &e) { | |||||
Widget::onMouseDown(e); | |||||
if (!e.consumed) { | |||||
// deletes `this` | // deletes `this` | ||||
gScene->setOverlay(NULL); | gScene->setOverlay(NULL); | ||||
e.consumed = true; | |||||
} | } | ||||
} | } | ||||
@@ -59,16 +59,19 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) { | |||||
for (NSVGshape *shape = svg->shapes; shape; shape = shape->next, shapeIndex++) { | for (NSVGshape *shape = svg->shapes; shape; shape = shape->next, shapeIndex++) { | ||||
DEBUG_ONLY(printf(" new shape: %d id \"%s\", fillrule %d, from (%f, %f) to (%f, %f)\n", shapeIndex, shape->id, shape->fillRule, shape->bounds[0], shape->bounds[1], shape->bounds[2], shape->bounds[3]);) | DEBUG_ONLY(printf(" new shape: %d id \"%s\", fillrule %d, from (%f, %f) to (%f, %f)\n", shapeIndex, shape->id, shape->fillRule, shape->bounds[0], shape->bounds[1], shape->bounds[2], shape->bounds[3]);) | ||||
// Visibility | |||||
if (!(shape->flags & NSVG_FLAGS_VISIBLE)) | if (!(shape->flags & NSVG_FLAGS_VISIBLE)) | ||||
continue; | continue; | ||||
nvgSave(vg); | nvgSave(vg); | ||||
// Opacity | |||||
if (shape->opacity < 1.0) | if (shape->opacity < 1.0) | ||||
nvgGlobalAlpha(vg, shape->opacity); | nvgGlobalAlpha(vg, shape->opacity); | ||||
// Build path | // Build path | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
// Iterate path linked list | // Iterate path linked list | ||||
for (NSVGpath *path = shape->paths; path; path = path->next) { | for (NSVGpath *path = shape->paths; path; path = path->next) { | ||||
DEBUG_ONLY(printf(" new path: %d points, %s, from (%f, %f) to (%f, %f)\n", path->npts, path->closed ? "closed" : "open", path->bounds[0], path->bounds[1], path->bounds[2], path->bounds[3]);) | DEBUG_ONLY(printf(" new path: %d points, %s, from (%f, %f) to (%f, %f)\n", path->npts, path->closed ? "closed" : "open", path->bounds[0], path->bounds[1], path->bounds[2], path->bounds[3]);) | ||||
@@ -81,6 +84,7 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) { | |||||
DEBUG_ONLY(printf(" bezier (%f, %f) to (%f, %f)\n", p[-2], p[-1], p[4], p[5]);) | DEBUG_ONLY(printf(" bezier (%f, %f) to (%f, %f)\n", p[-2], p[-1], p[4], p[5]);) | ||||
} | } | ||||
// Close path | |||||
if (path->closed) | if (path->closed) | ||||
nvgClosePath(vg); | nvgClosePath(vg); | ||||
@@ -161,11 +165,12 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) { | |||||
} | } | ||||
// Stroke shape | // Stroke shape | ||||
nvgStrokeWidth(vg, shape->strokeWidth); | |||||
// strokeDashOffset, strokeDashArray, strokeDashCount not yet supported | |||||
// strokeLineJoin, strokeLineCap not yet supported | |||||
if (shape->stroke.type) { | if (shape->stroke.type) { | ||||
nvgStrokeWidth(vg, shape->strokeWidth); | |||||
// strokeDashOffset, strokeDashArray, strokeDashCount not yet supported | |||||
nvgLineCap(vg, (NVGlineCap) shape->strokeLineCap); | |||||
nvgLineJoin(vg, (int) shape->strokeLineJoin); | |||||
switch (shape->stroke.type) { | switch (shape->stroke.type) { | ||||
case NSVG_PAINT_COLOR: { | case NSVG_PAINT_COLOR: { | ||||
NVGcolor color = getNVGColor(shape->stroke.color); | NVGcolor color = getNVGColor(shape->stroke.color); | ||||