Browse Source

Auto-format code with astyle.

tags/v1.1.4
Andrew Belt 5 years ago
parent
commit
dca30e2b53
100 changed files with 1105 additions and 895 deletions
  1. +24
    -8
      include/Quantity.hpp
  2. +11
    -11
      include/app.hpp
  3. +8
    -8
      include/app/AudioWidget.hpp
  4. +11
    -11
      include/app/CableWidget.hpp
  5. +1
    -1
      include/app/CircularShadow.hpp
  6. +5
    -5
      include/app/Knob.hpp
  7. +5
    -5
      include/app/LedDisplay.hpp
  8. +3
    -3
      include/app/LightWidget.hpp
  9. +2
    -2
      include/app/MenuBar.hpp
  10. +6
    -6
      include/app/MidiWidget.hpp
  11. +1
    -1
      include/app/ModuleBrowser.hpp
  12. +1
    -1
      include/app/ModuleLightWidget.hpp
  13. +21
    -21
      include/app/ModuleWidget.hpp
  14. +1
    -1
      include/app/MultiLightWidget.hpp
  15. +8
    -8
      include/app/ParamWidget.hpp
  16. +12
    -12
      include/app/PortWidget.hpp
  17. +1
    -1
      include/app/RackRail.hpp
  18. +5
    -5
      include/app/RackScrollWidget.hpp
  19. +28
    -28
      include/app/RackWidget.hpp
  20. +7
    -7
      include/app/Scene.hpp
  21. +2
    -2
      include/app/SliderKnob.hpp
  22. +6
    -6
      include/app/SvgButton.hpp
  23. +8
    -6
      include/app/SvgKnob.hpp
  24. +1
    -1
      include/app/SvgPanel.hpp
  25. +6
    -4
      include/app/SvgPort.hpp
  26. +2
    -2
      include/app/SvgScrew.hpp
  27. +10
    -6
      include/app/SvgSlider.hpp
  28. +4
    -4
      include/app/SvgSwitch.hpp
  29. +3
    -3
      include/app/Switch.hpp
  30. +2
    -2
      include/asset.hpp
  31. +6
    -6
      include/audio.hpp
  32. +2
    -2
      include/bridge.hpp
  33. +7
    -5
      include/common.hpp
  34. +16
    -16
      include/componentlibrary.hpp
  35. +4
    -4
      include/dsp/common.hpp
  36. +14
    -14
      include/dsp/fft.hpp
  37. +2
    -2
      include/dsp/filter.hpp
  38. +24
    -24
      include/dsp/fir.hpp
  39. +1
    -1
      include/dsp/minblep.hpp
  40. +15
    -15
      include/dsp/resampler.hpp
  41. +8
    -8
      include/dsp/ringbuffer.hpp
  42. +15
    -15
      include/dsp/window.hpp
  43. +2
    -2
      include/engine/Cable.hpp
  44. +18
    -18
      include/engine/Engine.hpp
  45. +14
    -12
      include/engine/Module.hpp
  46. +1
    -1
      include/engine/ParamHandle.hpp
  47. +2
    -2
      include/engine/ParamQuantity.hpp
  48. +4
    -4
      include/engine/Port.hpp
  49. +51
    -35
      include/event.hpp
  50. +67
    -67
      include/force_link_glibc_2.23.h
  51. +36
    -36
      include/helpers.hpp
  52. +10
    -10
      include/history.hpp
  53. +1
    -1
      include/logger.hpp
  54. +20
    -14
      include/math.hpp
  55. +34
    -20
      include/midi.hpp
  56. +4
    -4
      include/network.hpp
  57. +2
    -2
      include/patch.hpp
  58. +7
    -7
      include/plugin.hpp
  59. +13
    -7
      include/plugin/Model.hpp
  60. +4
    -4
      include/plugin/Plugin.hpp
  61. +1
    -1
      include/plugin/callbacks.hpp
  62. +10
    -10
      include/rack.hpp
  63. +143
    -53
      include/rack0.hpp
  64. +4
    -4
      include/settings.hpp
  65. +1
    -1
      include/simd/sse_mathfun.h
  66. +37
    -29
      include/simd/vector.hpp
  67. +17
    -17
      include/string.hpp
  68. +1
    -1
      include/svg.hpp
  69. +10
    -10
      include/system.hpp
  70. +5
    -5
      include/ui/Button.hpp
  71. +1
    -1
      include/ui/ChoiceButton.hpp
  72. +5
    -3
      include/ui/IconButton.hpp
  73. +1
    -1
      include/ui/Label.hpp
  74. +6
    -6
      include/ui/Menu.hpp
  75. +6
    -4
      include/ui/MenuItem.hpp
  76. +1
    -1
      include/ui/MenuLabel.hpp
  77. +2
    -2
      include/ui/MenuOverlay.hpp
  78. +1
    -1
      include/ui/MenuSeparator.hpp
  79. +1
    -1
      include/ui/PasswordField.hpp
  80. +2
    -2
      include/ui/ProgressBar.hpp
  81. +3
    -3
      include/ui/RadioButton.hpp
  82. +4
    -4
      include/ui/ScrollBar.hpp
  83. +8
    -8
      include/ui/ScrollWidget.hpp
  84. +6
    -6
      include/ui/Slider.hpp
  85. +5
    -5
      include/ui/TextField.hpp
  86. +1
    -1
      include/ui/Tooltip.hpp
  87. +2
    -2
      include/widget/FramebufferWidget.hpp
  88. +7
    -7
      include/widget/OpaqueWidget.hpp
  89. +4
    -2
      include/widget/SvgWidget.hpp
  90. +1
    -1
      include/widget/TransformWidget.hpp
  91. +7
    -7
      include/widget/TransparentWidget.hpp
  92. +75
    -51
      include/widget/Widget.hpp
  93. +9
    -9
      include/widget/ZoomWidget.hpp
  94. +15
    -15
      include/window.hpp
  95. +14
    -8
      src/app.cpp
  96. +30
    -30
      src/app/AudioWidget.cpp
  97. +33
    -27
      src/app/CableWidget.cpp
  98. +2
    -2
      src/app/CircularShadow.cpp
  99. +6
    -6
      src/app/Knob.cpp
  100. +9
    -9
      src/app/LedDisplay.cpp

+ 24
- 8
include/Quantity.hpp View File

@@ -19,24 +19,36 @@ struct Quantity {
/** Returns the value
Override this to return the state of your subclass.
*/
virtual float getValue() {return 0.f;}
virtual float getValue() {
return 0.f;
}

/** Returns the minimum allowed value */
virtual float getMinValue() {return 0.f;}
virtual float getMinValue() {
return 0.f;
}

/** Returns the maximum allowed value */
virtual float getMaxValue() {return 1.f;}
virtual float getMaxValue() {
return 1.f;
}

/** Returns the default value, for resetting */
virtual float getDefaultValue() {return 0.f;}
virtual float getDefaultValue() {
return 0.f;
}

/** Returns the value, possibly transformed for displaying
Useful for logarithmic scaling, multiplying by 100 for percentages, etc.
*/
virtual float getDisplayValue() {return getValue();}
virtual float getDisplayValue() {
return getValue();
}

/** Inversely transforms the display value and sets the value */
virtual void setDisplayValue(float displayValue) {setValue(displayValue);}
virtual void setDisplayValue(float displayValue) {
setValue(displayValue);
}

/** The number of total decimal places for generating the display value string
*/
@@ -48,12 +60,16 @@ struct Quantity {
virtual void setDisplayValueString(std::string s);

/** The name of the quantity */
virtual std::string getLabel() {return "";}
virtual std::string getLabel() {
return "";
}

/** The unit abbreviation of the quantity
Include an initial space character if you want a space after the number, e.g. "440 Hz". This allows space-less units, like "100%".
*/
virtual std::string getUnit() {return "";}
virtual std::string getUnit() {
return "";
}

/** Returns a string representation of the quantity */
virtual std::string getString();


+ 11
- 11
include/app.hpp View File

@@ -6,12 +6,12 @@ namespace rack {


namespace history {
struct State;
struct State;
} // namespace history


namespace engine {
struct Engine;
struct Engine;
} // namespace engine


@@ -20,23 +20,23 @@ struct PatchManager;


namespace event {
struct State;
struct State;
} // namespace event


namespace app {
struct Scene;
struct Scene;
} // namespace app


/** Contains the application state */
struct App {
event::State *event = NULL;
app::Scene *scene = NULL;
engine::Engine *engine = NULL;
Window *window = NULL;
history::State *history = NULL;
PatchManager *patch = NULL;
event::State* event = NULL;
app::Scene* scene = NULL;
engine::Engine* engine = NULL;
Window* window = NULL;
history::State* history = NULL;
PatchManager* patch = NULL;

void init();
~App();
@@ -46,7 +46,7 @@ struct App {
void appInit();
void appDestroy();
/** Returns the global App pointer */
App *appGet();
App* appGet();

/** Accesses the global App pointer */
#define APP appGet()


+ 8
- 8
include/app/AudioWidget.hpp View File

@@ -9,14 +9,14 @@ namespace app {


struct AudioWidget : LedDisplay {
LedDisplayChoice *driverChoice;
LedDisplaySeparator *driverSeparator;
LedDisplayChoice *deviceChoice;
LedDisplaySeparator *deviceSeparator;
LedDisplayChoice *sampleRateChoice;
LedDisplaySeparator *sampleRateSeparator;
LedDisplayChoice *bufferSizeChoice;
void setAudioPort(audio::Port *port);
LedDisplayChoice* driverChoice;
LedDisplaySeparator* driverSeparator;
LedDisplayChoice* deviceChoice;
LedDisplaySeparator* deviceSeparator;
LedDisplayChoice* sampleRateChoice;
LedDisplaySeparator* sampleRateSeparator;
LedDisplayChoice* bufferSizeChoice;
void setAudioPort(audio::Port* port);
};




+ 11
- 11
include/app/CableWidget.hpp View File

@@ -12,25 +12,25 @@ namespace app {


struct CableWidget : widget::OpaqueWidget {
PortWidget *outputPort = NULL;
PortWidget *inputPort = NULL;
PortWidget *hoveredOutputPort = NULL;
PortWidget *hoveredInputPort = NULL;
PortWidget* outputPort = NULL;
PortWidget* inputPort = NULL;
PortWidget* hoveredOutputPort = NULL;
PortWidget* hoveredInputPort = NULL;
/** Owned. */
engine::Cable *cable;
engine::Cable* cable;
NVGcolor color;

CableWidget();
~CableWidget();
bool isComplete();
void setOutput(PortWidget *outputPort);
void setInput(PortWidget *inputPort);
void setOutput(PortWidget* outputPort);
void setInput(PortWidget* inputPort);
math::Vec getOutputPos();
math::Vec getInputPos();
json_t *toJson();
void fromJson(json_t *rootJ);
void draw(const DrawArgs &args) override;
void drawPlugs(const DrawArgs &args);
json_t* toJson();
void fromJson(json_t* rootJ);
void draw(const DrawArgs& args) override;
void drawPlugs(const DrawArgs& args);
};




+ 1
- 1
include/app/CircularShadow.hpp View File

@@ -12,7 +12,7 @@ struct CircularShadow : widget::TransparentWidget {
float opacity;

CircularShadow();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 5
- 5
include/app/Knob.hpp View File

@@ -20,11 +20,11 @@ struct Knob : ParamWidget {
/** Drag horizontally instead of vertically */
bool horizontal = false;

void onHover(const event::Hover &e) override;
void onButton(const event::Button &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragMove(const event::DragMove &e) override;
void onHover(const event::Hover& e) override;
void onButton(const event::Button& e) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDragMove(const event::DragMove& e) override;
void reset() override;
void randomize() override;
};


+ 5
- 5
include/app/LedDisplay.hpp View File

@@ -10,12 +10,12 @@ namespace app {


struct LedDisplay : widget::OpaqueWidget {
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};

struct LedDisplaySeparator : widget::Widget {
LedDisplaySeparator();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};

struct LedDisplayChoice : widget::OpaqueWidget {
@@ -25,8 +25,8 @@ struct LedDisplayChoice : widget::OpaqueWidget {
NVGcolor color;
NVGcolor bgColor;
LedDisplayChoice();
void draw(const DrawArgs &args) override;
void onButton(const event::Button &e) override;
void draw(const DrawArgs& args) override;
void onButton(const event::Button& e) override;
};

struct LedDisplayTextField : ui::TextField {
@@ -34,7 +34,7 @@ struct LedDisplayTextField : ui::TextField {
math::Vec textOffset;
NVGcolor color;
LedDisplayTextField();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
int getTextPosition(math::Vec mousePos) override;
};



+ 3
- 3
include/app/LightWidget.hpp View File

@@ -12,9 +12,9 @@ struct LightWidget : widget::TransparentWidget {
NVGcolor color = nvgRGBA(0, 0, 0, 0);
NVGcolor borderColor = nvgRGBA(0, 0, 0, 0);

void draw(const DrawArgs &args) override;
virtual void drawLight(const DrawArgs &args);
virtual void drawHalo(const DrawArgs &args);
void draw(const DrawArgs& args) override;
virtual void drawLight(const DrawArgs& args);
virtual void drawHalo(const DrawArgs& args);
};




+ 2
- 2
include/app/MenuBar.hpp View File

@@ -8,11 +8,11 @@ namespace app {


struct MenuBar : widget::OpaqueWidget {
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};


MenuBar *createMenuBar();
MenuBar* createMenuBar();


} // namespace app


+ 6
- 6
include/app/MidiWidget.hpp View File

@@ -9,12 +9,12 @@ namespace app {


struct MidiWidget : LedDisplay {
LedDisplayChoice *driverChoice;
LedDisplaySeparator *driverSeparator;
LedDisplayChoice *deviceChoice;
LedDisplaySeparator *deviceSeparator;
LedDisplayChoice *channelChoice;
void setMidiPort(midi::Port *port);
LedDisplayChoice* driverChoice;
LedDisplaySeparator* driverSeparator;
LedDisplayChoice* deviceChoice;
LedDisplaySeparator* deviceSeparator;
LedDisplayChoice* channelChoice;
void setMidiPort(midi::Port* port);
};




+ 1
- 1
include/app/ModuleBrowser.hpp View File

@@ -7,7 +7,7 @@ namespace rack {
namespace app {


widget::Widget *moduleBrowserCreate();
widget::Widget* moduleBrowserCreate();


} // namespace app


+ 1
- 1
include/app/ModuleLightWidget.hpp View File

@@ -12,7 +12,7 @@ namespace app {
Will access firstLightId, firstLightId + 1, etc. for each added color
*/
struct ModuleLightWidget : MultiLightWidget {
engine::Module *module = NULL;
engine::Module* module = NULL;
int firstLightId;

void step() override;


+ 21
- 21
include/app/ModuleWidget.hpp View File

@@ -14,11 +14,11 @@ namespace app {

/** Manages an engine::Module in the rack. */
struct ModuleWidget : widget::OpaqueWidget {
plugin::Model *model = NULL;
plugin::Model* model = NULL;
/** Owned. */
engine::Module *module = NULL;
engine::Module* module = NULL;

widget::Widget *panel = NULL;
widget::Widget* panel = NULL;
/** Note that the indexes of these vectors do not necessarily correspond with the indexes of `Module::params` etc.
*/
std::vector<ParamWidget*> params;
@@ -29,39 +29,39 @@ struct ModuleWidget : widget::OpaqueWidget {
math::Vec oldPos;

ModuleWidget();
DEPRECATED ModuleWidget(engine::Module *module) : ModuleWidget() {
DEPRECATED ModuleWidget(engine::Module* module) : ModuleWidget() {
setModule(module);
}
~ModuleWidget();

void draw(const DrawArgs &args) override;
void drawShadow(const DrawArgs &args);
void draw(const DrawArgs& args) override;
void drawShadow(const DrawArgs& args);

void onButton(const event::Button &e) override;
void onHoverKey(const event::HoverKey &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragMove(const event::DragMove &e) override;
void onButton(const event::Button& e) override;
void onHoverKey(const event::HoverKey& e) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDragMove(const event::DragMove& e) override;

/** Associates this ModuleWidget with the Module
Transfers ownership
*/
void setModule(engine::Module *module);
void setModule(engine::Module* module);
void setPanel(std::shared_ptr<Svg> svg);

/** Convenience functions for adding special widgets (calls addChild()) */
void addParam(ParamWidget *param);
void addOutput(PortWidget *output);
void addInput(PortWidget *input);
ParamWidget *getParam(int paramId);
PortWidget *getOutput(int outputId);
PortWidget *getInput(int inputId);
void addParam(ParamWidget* param);
void addOutput(PortWidget* output);
void addInput(PortWidget* input);
ParamWidget* getParam(int paramId);
PortWidget* getOutput(int outputId);
PortWidget* getInput(int inputId);

/** Overriding these is deprecated.
Use Module::dataToJson() and dataFromJson() instead
*/
virtual json_t *toJson();
virtual void fromJson(json_t *rootJ);
virtual json_t* toJson();
virtual void fromJson(json_t* rootJ);

/** Serializes/unserializes the module state */
void copyClipboard();
@@ -93,7 +93,7 @@ struct ModuleWidget : widget::OpaqueWidget {
/** Override to add context menu entries to your subclass.
It is recommended to add a blank ui::MenuEntry first for spacing.
*/
virtual void appendContextMenu(ui::Menu *menu) {}
virtual void appendContextMenu(ui::Menu* menu) {}
};




+ 1
- 1
include/app/MultiLightWidget.hpp View File

@@ -14,7 +14,7 @@ struct MultiLightWidget : LightWidget {

void addBaseColor(NVGcolor baseColor);
/** Sets the color to a linear combination of the baseColors with the given weights */
void setBrightnesses(const std::vector<float> &brightnesses);
void setBrightnesses(const std::vector<float>& brightnesses);
};




+ 8
- 8
include/app/ParamWidget.hpp View File

@@ -12,20 +12,20 @@ namespace app {

/** Manages an engine::Param on a ModuleWidget. */
struct ParamWidget : widget::OpaqueWidget {
engine::ParamQuantity *paramQuantity = NULL;
engine::ParamQuantity* paramQuantity = NULL;
float dirtyValue = NAN;
ui::Tooltip *tooltip = NULL;
ui::Tooltip* tooltip = NULL;

void step() override;
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;

void onButton(const event::Button &e) override;
void onDoubleClick(const event::DoubleClick &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &e) override;
void onButton(const event::Button& e) override;
void onDoubleClick(const event::DoubleClick& e) override;
void onEnter(const event::Enter& e) override;
void onLeave(const event::Leave& e) override;

/** For legacy patch loading */
void fromJson(json_t *rootJ);
void fromJson(json_t* rootJ);
void createContextMenu();
void resetAction();
virtual void reset() {}


+ 12
- 12
include/app/PortWidget.hpp View File

@@ -11,7 +11,7 @@ namespace app {

/** Manages an engine::Port on a ModuleWidget. */
struct PortWidget : widget::OpaqueWidget {
engine::Module *module = NULL;
engine::Module* module = NULL;
int portId;
bool hovered = false;

@@ -20,22 +20,22 @@ struct PortWidget : widget::OpaqueWidget {
INPUT
};
Type type;
MultiLightWidget *plugLight;
MultiLightWidget* plugLight;

PortWidget();
~PortWidget();

void step() override;
void draw(const DrawArgs &args) override;
void onButton(const event::Button &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
void onDragEnter(const event::DragEnter &e) override;
void onDragLeave(const event::DragLeave &e) override;
void draw(const DrawArgs& args) override;
void onButton(const event::Button& e) override;
void onEnter(const event::Enter& e) override;
void onLeave(const event::Leave& e) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDragDrop(const event::DragDrop& e) override;
void onDragEnter(const event::DragEnter& e) override;
void onDragLeave(const event::DragLeave& e) override;
};




+ 1
- 1
include/app/RackRail.hpp View File

@@ -11,7 +11,7 @@ struct RackRail : widget::TransparentWidget {
std::shared_ptr<Svg> busBoardSvg;

RackRail();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 5
- 5
include/app/RackScrollWidget.hpp View File

@@ -10,17 +10,17 @@ namespace app {


struct RackScrollWidget : ui::ScrollWidget {
widget::ZoomWidget *zoomWidget;
RackWidget *rackWidget;
widget::ZoomWidget* zoomWidget;
RackWidget* rackWidget;
/** The pivot point for zooming */
math::Vec zoomPos;
math::Vec oldOffset;

RackScrollWidget();
void step() override;
void draw(const DrawArgs &args) override;
void onHoverKey(const event::HoverKey &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
void draw(const DrawArgs& args) override;
void onHoverKey(const event::HoverKey& e) override;
void onHoverScroll(const event::HoverScroll& e) override;
void reset();
};



+ 28
- 28
include/app/RackWidget.hpp View File

@@ -16,13 +16,13 @@ namespace app {

/** Container for ModuleWidget and CableWidget. */
struct RackWidget : widget::OpaqueWidget {
widget::Widget *moduleContainer;
widget::Widget *cableContainer;
CableWidget *incompleteCable = NULL;
widget::FramebufferWidget *railFb;
widget::Widget* moduleContainer;
widget::Widget* cableContainer;
CableWidget* incompleteCable = NULL;
widget::FramebufferWidget* railFb;
/** The last mouse position in the RackWidget */
math::Vec mousePos;
ParamWidget *touchedParam = NULL;
ParamWidget* touchedParam = NULL;
std::map<int, math::Vec> moduleDragPositions;
int nextCableColorId = 0;

@@ -30,17 +30,17 @@ struct RackWidget : widget::OpaqueWidget {
~RackWidget();

void step() override;
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;

void onHover(const event::Hover &e) override;
void onHoverKey(const event::HoverKey &e) override;
void onDragHover(const event::DragHover &e) override;
void onButton(const event::Button &e) override;
void onHover(const event::Hover& e) override;
void onHoverKey(const event::HoverKey& e) override;
void onDragHover(const event::DragHover& e) override;
void onButton(const event::Button& e) override;

/** Completely clear the rack's modules and cables */
void clear();
json_t *toJson();
void fromJson(json_t *rootJ);
json_t* toJson();
void fromJson(json_t* rootJ);
void pastePresetClipboardAction();

// Module methods
@@ -48,39 +48,39 @@ struct RackWidget : widget::OpaqueWidget {
/** Adds a module and adds it to the Engine
Ownership rules work like add/removeChild()
*/
void addModule(ModuleWidget *mw);
void addModuleAtMouse(ModuleWidget *mw);
void addModule(ModuleWidget* mw);
void addModuleAtMouse(ModuleWidget* mw);
/** Removes the module and transfers ownership to the caller */
void removeModule(ModuleWidget *mw);
void removeModule(ModuleWidget* mw);
/** Sets a module's box if non-colliding. Returns true if set */
bool requestModulePos(ModuleWidget *mw, math::Vec pos);
bool requestModulePos(ModuleWidget* mw, math::Vec pos);
/** Moves a module to the closest non-colliding position */
void setModulePosNearest(ModuleWidget *mw, math::Vec pos);
void setModulePosForce(ModuleWidget *mw, math::Vec pos);
ModuleWidget *getModule(int moduleId);
void setModulePosNearest(ModuleWidget* mw, math::Vec pos);
void setModulePosForce(ModuleWidget* mw, math::Vec pos);
ModuleWidget* getModule(int moduleId);
bool isEmpty();
void updateModuleDragPositions();
history::ComplexAction *getModuleDragAction();
history::ComplexAction* getModuleDragAction();

// Cable methods

void clearCables();
void clearCablesAction();
/** Removes all complete cables connected to the port */
void clearCablesOnPort(PortWidget *port);
void clearCablesOnPort(PortWidget* port);
/** Adds a complete cable and adds it to the Engine.
Ownership rules work like add/removeChild()
*/
void addCable(CableWidget *w);
void removeCable(CableWidget *w);
void addCable(CableWidget* w);
void removeCable(CableWidget* w);
/** Takes ownership of `w` and adds it as a child if it isn't already */
void setIncompleteCable(CableWidget *w);
CableWidget *releaseIncompleteCable();
void setIncompleteCable(CableWidget* w);
CableWidget* releaseIncompleteCable();
/** Returns the most recently added complete cable connected to the given Port, i.e. the top of the stack */
CableWidget *getTopCable(PortWidget *port);
CableWidget *getCable(int cableId);
CableWidget* getTopCable(PortWidget* port);
CableWidget* getCable(int cableId);
/** Returns all cables attached to port, complete or not */
std::list<CableWidget*> getCablesOnPort(PortWidget *port);
std::list<CableWidget*> getCablesOnPort(PortWidget* port);
};




+ 7
- 7
include/app/Scene.hpp View File

@@ -12,10 +12,10 @@ namespace app {

struct Scene : widget::OpaqueWidget {
// Convenience variables for accessing important widgets
RackScrollWidget *rackScroll;
RackWidget *rack;
MenuBar *menuBar;
widget::Widget *moduleBrowser;
RackScrollWidget* rackScroll;
RackWidget* rack;
MenuBar* menuBar;
widget::Widget* moduleBrowser;

double lastAutosaveTime = 0.0;

@@ -27,9 +27,9 @@ struct Scene : widget::OpaqueWidget {
Scene();
~Scene();
void step() override;
void draw(const DrawArgs &args) override;
void onHoverKey(const event::HoverKey &e) override;
void onPathDrop(const event::PathDrop &e) override;
void draw(const DrawArgs& args) override;
void onHoverKey(const event::HoverKey& e) override;
void onPathDrop(const event::PathDrop& e) override;

void runCheckVersion();
};


+ 2
- 2
include/app/SliderKnob.hpp View File

@@ -9,10 +9,10 @@ namespace app {

struct SliderKnob : Knob {
// Bypass Knob's circular hitbox detection
void onHover(const event::Hover &e) override {
void onHover(const event::Hover& e) override {
ParamWidget::onHover(e);
}
void onButton(const event::Button &e) override {
void onButton(const event::Button& e) override {
ParamWidget::onButton(e);
}
};


+ 6
- 6
include/app/SvgButton.hpp View File

@@ -11,16 +11,16 @@ namespace app {


struct SvgButton : widget::OpaqueWidget {
widget::FramebufferWidget *fb;
CircularShadow *shadow;
widget::SvgWidget *sw;
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::SvgWidget* sw;
std::vector<std::shared_ptr<Svg>> frames;

SvgButton();
void addFrame(std::shared_ptr<Svg> svg);
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDragDrop(const event::DragDrop& e) override;
};




+ 8
- 6
include/app/SvgKnob.hpp View File

@@ -13,18 +13,20 @@ namespace app {

/** A knob which rotates an SVG and caches it in a framebuffer */
struct SvgKnob : Knob {
widget::FramebufferWidget *fb;
CircularShadow *shadow;
widget::TransformWidget *tw;
widget::SvgWidget *sw;
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::TransformWidget* tw;
widget::SvgWidget* sw;
/** Angles in radians */
float minAngle = 0.f;
float maxAngle = M_PI;

SvgKnob();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);}
void onChange(const event::Change &e) override;
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
setSvg(svg);
}
void onChange(const event::Change& e) override;
};




+ 1
- 1
include/app/SvgPanel.hpp View File

@@ -11,7 +11,7 @@ namespace app {


struct PanelBorder : widget::TransparentWidget {
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 6
- 4
include/app/SvgPort.hpp View File

@@ -11,13 +11,15 @@ namespace app {


struct SvgPort : PortWidget {
widget::FramebufferWidget *fb;
CircularShadow *shadow;
widget::SvgWidget *sw;
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::SvgWidget* sw;

SvgPort();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);}
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
setSvg(svg);
}
};




+ 2
- 2
include/app/SvgScrew.hpp View File

@@ -11,8 +11,8 @@ namespace app {

/** If you don't add these to your ModuleWidget, they will fall out of the rack... */
struct SvgScrew : widget::Widget {
widget::FramebufferWidget *fb;
widget::SvgWidget *sw;
widget::FramebufferWidget* fb;
widget::SvgWidget* sw;

SvgScrew();
void setSvg(std::shared_ptr<Svg> svg);


+ 10
- 6
include/app/SvgSlider.hpp View File

@@ -13,19 +13,23 @@ namespace app {
Can be used for horizontal or vertical linear faders.
*/
struct SvgSlider : app::SliderKnob {
widget::FramebufferWidget *fb;
widget::SvgWidget *background;
widget::SvgWidget *handle;
widget::FramebufferWidget* fb;
widget::SvgWidget* background;
widget::SvgWidget* handle;
/** Intermediate positions will be interpolated between these positions */
math::Vec minHandlePos, maxHandlePos;

SvgSlider();
void setBackgroundSvg(std::shared_ptr<Svg> svg);
void setHandleSvg(std::shared_ptr<Svg> svg);
void onChange(const event::Change &e) override;
void onChange(const event::Change& e) override;

DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);}
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);}
DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {
setBackgroundSvg(svg);
}
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {
setBackgroundSvg(svg);
}
DEPRECATED void setSVGs(std::shared_ptr<Svg> backgroundSvg, std::shared_ptr<Svg> handleSvg) {
setBackgroundSvg(backgroundSvg);
setHandleSvg(handleSvg);


+ 4
- 4
include/app/SvgSwitch.hpp View File

@@ -12,15 +12,15 @@ namespace app {

/** A ParamWidget with multiple frames corresponding to its value */
struct SvgSwitch : Switch {
widget::FramebufferWidget *fb;
CircularShadow *shadow;
widget::SvgWidget *sw;
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::SvgWidget* sw;
std::vector<std::shared_ptr<Svg>> frames;

SvgSwitch();
/** Adds an SVG file to represent the next switch position */
void addFrame(std::shared_ptr<Svg> svg);
void onChange(const event::Change &e) override;
void onChange(const event::Change& e) override;
};




+ 3
- 3
include/app/Switch.hpp View File

@@ -20,9 +20,9 @@ struct Switch : ParamWidget {
bool momentaryReleased = false;

void step() override;
void onDoubleClick(const event::DoubleClick &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDoubleClick(const event::DoubleClick& e) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void reset() override;
void randomize() override;
};


+ 2
- 2
include/asset.hpp View File

@@ -6,7 +6,7 @@ namespace rack {


namespace plugin {
struct Plugin;
struct Plugin;
} // namespace plugin


@@ -19,7 +19,7 @@ std::string system(std::string filename);
/** Returns the path of a user resource. Can read and write files to this location. */
std::string user(std::string filename);
/** Returns the path of a resource in the plugin's folder. Should only read files from this location. */
std::string plugin(plugin::Plugin *plugin, std::string filename);
std::string plugin(plugin::Plugin* plugin, std::string filename);


// Set these before calling init() to override the default paths


+ 6
- 6
include/audio.hpp View File

@@ -4,7 +4,7 @@

#pragma GCC diagnostic push
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include <RtAudio.h>
#pragma GCC diagnostic pop
@@ -28,7 +28,7 @@ struct Port {
int blockSize = 256;
int numOutputs = 0;
int numInputs = 0;
RtAudio *rtAudio = NULL;
RtAudio* rtAudio = NULL;
/** Cached */
RtAudio::DeviceInfo deviceInfo;

@@ -40,7 +40,7 @@ struct Port {
void setDriverId(int driverId);

int getDeviceCount();
bool getDeviceInfo(int deviceId, RtAudio::DeviceInfo *deviceInfo);
bool getDeviceInfo(int deviceId, RtAudio::DeviceInfo* deviceInfo);
/** Returns the number of inputs or outputs, whichever is greater */
int getDeviceChannels(int deviceId);
std::string getDeviceName(int deviceId);
@@ -58,12 +58,12 @@ struct Port {
void openStream();
void closeStream();

virtual void processStream(const float *input, float *output, int frames) {}
virtual void processStream(const float* input, float* output, int frames) {}
virtual void onCloseStream() {}
virtual void onOpenStream() {}
virtual void onChannelsChange() {}
json_t *toJson();
void fromJson(json_t *rootJ);
json_t* toJson();
void fromJson(json_t* rootJ);
};




+ 2
- 2
include/bridge.hpp View File

@@ -8,8 +8,8 @@ namespace rack {

void bridgeInit();
void bridgeDestroy();
void bridgeAudioSubscribe(int channel, audio::Port *port);
void bridgeAudioUnsubscribe(int channel, audio::Port *port);
void bridgeAudioSubscribe(int channel, audio::Port* port);
void bridgeAudioUnsubscribe(int channel, audio::Port* port);


} // namespace rack

+ 7
- 5
include/common.hpp View File

@@ -120,13 +120,13 @@ Example:
Foo *foo = construct<Foo>(&Foo::greeting, "Hello world", &Foo::legs, 2);
*/
template <typename T>
T *construct() {
T* construct() {
return new T;
}

template <typename T, typename F, typename V, typename... Args>
T *construct(F f, V v, Args... args) {
T *o = construct<T>(args...);
T* construct(F f, V v, Args... args) {
T* o = construct<T>(args...);
o->*f = v;
return o;
}
@@ -144,7 +144,9 @@ template <typename F>
struct DeferWrapper {
F f;
DeferWrapper(F f) : f(f) {}
~DeferWrapper() { f(); }
~DeferWrapper() {
f();
}
};

template <typename F>
@@ -157,7 +159,7 @@ DeferWrapper<F> deferWrapper(F f) {

/** An exception meant to be shown to the user */
struct UserException : std::runtime_error {
UserException(const std::string &msg) : std::runtime_error(msg) {}
UserException(const std::string& msg) : std::runtime_error(msg) {}
};




+ 16
- 16
include/componentlibrary.hpp View File

@@ -45,8 +45,8 @@ static const NVGcolor SCHEME_DARK_GRAY = nvgRGB(0x17, 0x17, 0x17);

struct RoundKnob : app::SvgKnob {
RoundKnob() {
minAngle = -0.83*M_PI;
maxAngle = 0.83*M_PI;
minAngle = -0.83 * M_PI;
maxAngle = 0.83 * M_PI;
}
};

@@ -83,8 +83,8 @@ struct RoundBlackSnapKnob : RoundBlackKnob {

struct Davies1900hKnob : app::SvgKnob {
Davies1900hKnob() {
minAngle = -0.83*M_PI;
maxAngle = 0.83*M_PI;
minAngle = -0.83 * M_PI;
maxAngle = 0.83 * M_PI;
}
};

@@ -127,8 +127,8 @@ struct Davies1900hLargeRedKnob : Davies1900hKnob {

struct Rogan : app::SvgKnob {
Rogan() {
minAngle = -0.83*M_PI;
maxAngle = 0.83*M_PI;
minAngle = -0.83 * M_PI;
maxAngle = 0.83 * M_PI;
}
};

@@ -297,12 +297,12 @@ struct Rogan1PWhite : Rogan {

struct SynthTechAlco : app::SvgKnob {
SynthTechAlco() {
minAngle = -0.82*M_PI;
maxAngle = 0.82*M_PI;
minAngle = -0.82 * M_PI;
maxAngle = 0.82 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg")));
// Add cap
widget::FramebufferWidget *capFb = new widget::FramebufferWidget;
widget::SvgWidget *cap = new widget::SvgWidget;
widget::FramebufferWidget* capFb = new widget::FramebufferWidget;
widget::SvgWidget* cap = new widget::SvgWidget;
cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg")));
capFb->addChild(cap);
addChild(capFb);
@@ -311,16 +311,16 @@ struct SynthTechAlco : app::SvgKnob {

struct Trimpot : app::SvgKnob {
Trimpot() {
minAngle = -0.75*M_PI;
maxAngle = 0.75*M_PI;
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg")));
}
};

struct BefacoBigKnob : app::SvgKnob {
BefacoBigKnob() {
minAngle = -0.75*M_PI;
maxAngle = 0.75*M_PI;
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg")));
}
};
@@ -333,8 +333,8 @@ struct BefacoBigSnapKnob : BefacoBigKnob {

struct BefacoTinyKnob : app::SvgKnob {
BefacoTinyKnob() {
minAngle = -0.75*M_PI;
maxAngle = 0.75*M_PI;
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg")));
}
};


+ 4
- 4
include/dsp/common.hpp View File

@@ -53,23 +53,23 @@ T dbToAmplitude(T db) {

template <typename T>
T quadraticBipolar(T x) {
return simd::sgn(x) * (x*x);
return simd::sgn(x) * (x * x);
}

template <typename T>
T cubic(T x) {
return x*x*x;
return x * x * x;
}

template <typename T>
T quarticBipolar(T x) {
return simd::sgn(x) * (x*x*x*x);
return simd::sgn(x) * (x * x * x * x);
}

template <typename T>
T quintic(T x) {
// optimal with -fassociative-math
return x*x*x*x*x;
return x * x * x * x * x;
}

template <typename T>


+ 14
- 14
include/dsp/fft.hpp View File

@@ -13,7 +13,7 @@ Wrapper for [PFFFT](https://bitbucket.org/jpommier/pffft/)
Buffers must be aligned to 16-byte boundaries. new[] and malloc() do this for you.
*/
struct RealFFT {
PFFFT_Setup *setup;
PFFFT_Setup* setup;
int length;

RealFFT(size_t length) {
@@ -31,7 +31,7 @@ struct RealFFT {
Output is arbitrarily ordered for performance reasons.
However, this ordering is consistent, so element-wise multiplication with line up with other results, and the inverse FFT will return a correctly ordered result.
*/
void rfftUnordered(const float *input, float *output) {
void rfftUnordered(const float* input, float* output) {
pffft_transform(setup, input, output, NULL, PFFFT_FORWARD);
}

@@ -39,7 +39,7 @@ struct RealFFT {
Input is `2*length` elements. Output is `length` elements.
Scaling is such that IRFFT(RFFT(x)) = N*x.
*/
void irfftUnordered(const float *input, float *output) {
void irfftUnordered(const float* input, float* output) {
pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD);
}

@@ -54,17 +54,17 @@ struct RealFFT {
output[length - 2] = real(F(n/2 - 1))
output[length - 1] = imag(F(n/2 - 1))
*/
void rfft(const float *input, float *output) {
void rfft(const float* input, float* output) {
pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD);
}

void irfft(const float *input, float *output) {
void irfft(const float* input, float* output) {
pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD);
}

/** Scales the RFFT so that `scale(IFFT(FFT(x))) = x`.
*/
void scale(float *x) {
void scale(float* x) {
float a = 1.f / length;
for (int i = 0; i < length; i++) {
x[i] *= a;
@@ -77,7 +77,7 @@ struct RealFFT {
`length` must be a multiple of 16.
*/
struct ComplexFFT {
PFFFT_Setup *setup;
PFFFT_Setup* setup;
int length;

ComplexFFT(size_t length) {
@@ -93,7 +93,7 @@ struct ComplexFFT {
Input and output must be aligned using the above align*() functions.
Input is `2*length` elements. Output is `2*length` elements.
*/
void fftUnordered(const float *input, float *output) {
void fftUnordered(const float* input, float* output) {
pffft_transform(setup, input, output, NULL, PFFFT_FORWARD);
}

@@ -101,23 +101,23 @@ struct ComplexFFT {
Input is `2*length` elements. Output is `2*length` elements.
Scaling is such that FFT(IFFT(x)) = N*x.
*/
void ifftUnordered(const float *input, float *output) {
void ifftUnordered(const float* input, float* output) {
pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD);
}

void fft(const float *input, float *output) {
void fft(const float* input, float* output) {
pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD);
}

void ifft(const float *input, float *output) {
void ifft(const float* input, float* output) {
pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD);
}

void scale(float *x) {
void scale(float* x) {
float a = 1.f / length;
for (int i = 0; i < length; i++) {
x[2*i+0] *= a;
x[2*i+1] *= a;
x[2 * i + 0] *= a;
x[2 * i + 1] *= a;
}
}
};


+ 2
- 2
include/dsp/filter.hpp View File

@@ -214,7 +214,7 @@ struct TBiquadFilter {
T process(T in) {
// Advance IIR
T out = b[0] * in + b[1] * x[0] + b[2] * x[1]
- a[0] * y[0] - a[1] * y[1];
- a[0] * y[0] - a[1] * y[1];
// Push input
x[1] = x[0];
x[0] = in;
@@ -348,7 +348,7 @@ struct TBiquadFilter {
}
}

void copyParameters(const TBiquadFilter<T> &from) {
void copyParameters(const TBiquadFilter<T>& from) {
b[0] = from.b[0];
b[1] = from.b[1];
b[2] = from.b[2];


+ 24
- 24
include/dsp/fir.hpp View File

@@ -8,7 +8,7 @@ namespace dsp {


/** Performs a direct sum convolution */
inline float convolveNaive(const float *in, const float *kernel, int len) {
inline float convolveNaive(const float* in, const float* kernel, int len) {
float y = 0.f;
for (int i = 0; i < len; i++) {
y += in[len - 1 - i] * kernel[i];
@@ -17,7 +17,7 @@ inline float convolveNaive(const float *in, const float *kernel, int len) {
}

/** Computes the impulse response of a boxcar lowpass filter */
inline void boxcarLowpassIR(float *out, int len, float cutoff = 0.5f) {
inline void boxcarLowpassIR(float* out, int len, float cutoff = 0.5f) {
for (int i = 0; i < len; i++) {
float t = i - (len - 1) / 2.f;
out[i] = 2 * cutoff * sinc(2 * cutoff * t);
@@ -28,23 +28,23 @@ inline void boxcarLowpassIR(float *out, int len, float cutoff = 0.5f) {
struct RealTimeConvolver {
// `kernelBlocks` number of contiguous FFT blocks of size `blockSize`
// indexed by [i * blockSize*2 + j]
float *kernelFfts = NULL;
float *inputFfts = NULL;
float *outputTail = NULL;
float *tmpBlock = NULL;
float* kernelFfts = NULL;
float* inputFfts = NULL;
float* outputTail = NULL;
float* tmpBlock = NULL;
size_t blockSize;
size_t kernelBlocks = 0;
size_t inputPos = 0;
PFFFT_Setup *pffft;
PFFFT_Setup* pffft;

/** `blockSize` is the size of each FFT block. It should be >=32 and a power of 2. */
RealTimeConvolver(size_t blockSize) {
this->blockSize = blockSize;
pffft = pffft_new_setup(blockSize*2, PFFFT_REAL);
pffft = pffft_new_setup(blockSize * 2, PFFFT_REAL);
outputTail = new float[blockSize];
std::memset(outputTail, 0, blockSize * sizeof(float));
tmpBlock = new float[blockSize*2];
std::memset(tmpBlock, 0, blockSize*2 * sizeof(float));
tmpBlock = new float[blockSize * 2];
std::memset(tmpBlock, 0, blockSize * 2 * sizeof(float));
}

~RealTimeConvolver() {
@@ -54,7 +54,7 @@ struct RealTimeConvolver {
pffft_destroy_setup(pffft);
}

void setKernel(const float *kernel, size_t length) {
void setKernel(const float* kernel, size_t length) {
// Clear existing kernel
if (kernelFfts) {
pffft_aligned_free(kernelFfts);
@@ -72,17 +72,17 @@ struct RealTimeConvolver {
kernelBlocks = (length - 1) / blockSize + 1;

// Allocate blocks
kernelFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize*2 * kernelBlocks);
inputFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize*2 * kernelBlocks);
std::memset(inputFfts, 0, sizeof(float) * blockSize*2 * kernelBlocks);
kernelFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize * 2 * kernelBlocks);
inputFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize * 2 * kernelBlocks);
std::memset(inputFfts, 0, sizeof(float) * blockSize * 2 * kernelBlocks);

for (size_t i = 0; i < kernelBlocks; i++) {
// Pad each block with zeros
std::memset(tmpBlock, 0, sizeof(float) * blockSize*2);
size_t len = std::min((int) blockSize, (int) (length - i*blockSize));
std::memcpy(tmpBlock, &kernel[i*blockSize], sizeof(float)*len);
std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2);
size_t len = std::min((int) blockSize, (int)(length - i * blockSize));
std::memcpy(tmpBlock, &kernel[i * blockSize], sizeof(float)*len);
// Compute fft
pffft_transform(pffft, tmpBlock, &kernelFfts[blockSize*2 * i], NULL, PFFFT_FORWARD);
pffft_transform(pffft, tmpBlock, &kernelFfts[blockSize * 2 * i], NULL, PFFFT_FORWARD);
}
}
}
@@ -90,7 +90,7 @@ struct RealTimeConvolver {
/** Applies reverb to input
input and output must be of size `blockSize`
*/
void processBlock(const float *input, float *output) {
void processBlock(const float* input, float* output) {
if (kernelBlocks == 0) {
std::memset(output, 0, sizeof(float) * blockSize);
return;
@@ -99,17 +99,17 @@ struct RealTimeConvolver {
// Step input position
inputPos = (inputPos + 1) % kernelBlocks;
// Pad block with zeros
std::memset(tmpBlock, 0, sizeof(float) * blockSize*2);
std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2);
std::memcpy(tmpBlock, input, sizeof(float) * blockSize);
// Compute input fft
pffft_transform(pffft, tmpBlock, &inputFfts[blockSize*2 * inputPos], NULL, PFFFT_FORWARD);
pffft_transform(pffft, tmpBlock, &inputFfts[blockSize * 2 * inputPos], NULL, PFFFT_FORWARD);
// Create output fft
std::memset(tmpBlock, 0, sizeof(float) * blockSize*2);
std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2);
// convolve input fft by kernel fft
// Note: This is the CPU bottleneck loop
for (size_t i = 0; i < kernelBlocks; i++) {
size_t pos = (inputPos - i + kernelBlocks) % kernelBlocks;
pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize*2 * i], &inputFfts[blockSize*2 * pos], tmpBlock, 1.f);
pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize * 2 * i], &inputFfts[blockSize * 2 * pos], tmpBlock, 1.f);
}
// Compute output
pffft_transform(pffft, tmpBlock, tmpBlock, NULL, PFFFT_BACKWARD);
@@ -118,7 +118,7 @@ struct RealTimeConvolver {
tmpBlock[i] += outputTail[i];
}
// Copy output block to output
float scale = 1.f / (blockSize*2);
float scale = 1.f / (blockSize * 2);
for (size_t i = 0; i < blockSize; i++) {
// Scale based on FFT
output[i] = tmpBlock[i] * scale;


+ 1
- 1
include/dsp/minblep.hpp View File

@@ -12,7 +12,7 @@ o: oversample factor
output: must be length `2 * z * o`.
https://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf
*/
void minBlepImpulse(int z, int o, float *output);
void minBlepImpulse(int z, int o, float* output);


template <int Z, int O, typename T = float>


+ 15
- 15
include/dsp/resampler.hpp View File

@@ -15,7 +15,7 @@ namespace dsp {
/** Resamples by a fixed rational factor. */
template <int MAX_CHANNELS>
struct SampleRateConverter {
SpeexResamplerState *st = NULL;
SpeexResamplerState* st = NULL;
int channels = MAX_CHANNELS;
int quality = SPEEX_RESAMPLER_QUALITY_DEFAULT;
int inRate = 44100;
@@ -73,7 +73,7 @@ struct SampleRateConverter {
}

/** `in` and `out` are interlaced with the number of channels */
void process(const Frame<MAX_CHANNELS> *in, int *inFrames, Frame<MAX_CHANNELS> *out, int *outFrames) {
void process(const Frame<MAX_CHANNELS>* in, int* inFrames, Frame<MAX_CHANNELS>* out, int* outFrames) {
assert(in);
assert(inFrames);
assert(out);
@@ -105,13 +105,13 @@ struct SampleRateConverter {
/** Downsamples by an integer factor. */
template <int OVERSAMPLE, int QUALITY, typename T = float>
struct Decimator {
T inBuffer[OVERSAMPLE*QUALITY];
float kernel[OVERSAMPLE*QUALITY];
T inBuffer[OVERSAMPLE * QUALITY];
float kernel[OVERSAMPLE * QUALITY];
int inIndex;

Decimator(float cutoff = 0.9f) {
boxcarLowpassIR(kernel, OVERSAMPLE*QUALITY, cutoff * 0.5f / OVERSAMPLE);
blackmanHarrisWindow(kernel, OVERSAMPLE*QUALITY);
boxcarLowpassIR(kernel, OVERSAMPLE * QUALITY, cutoff * 0.5f / OVERSAMPLE);
blackmanHarrisWindow(kernel, OVERSAMPLE * QUALITY);
reset();
}
void reset() {
@@ -119,17 +119,17 @@ struct Decimator {
std::memset(inBuffer, 0, sizeof(inBuffer));
}
/** `in` must be length OVERSAMPLE */
T process(T *in) {
T process(T* in) {
// Copy input to buffer
std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE*sizeof(T));
std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE * sizeof(T));
// Advance index
inIndex += OVERSAMPLE;
inIndex %= OVERSAMPLE*QUALITY;
inIndex %= OVERSAMPLE * QUALITY;
// Perform naive convolution
T out = 0.f;
for (int i = 0; i < OVERSAMPLE*QUALITY; i++) {
for (int i = 0; i < OVERSAMPLE * QUALITY; i++) {
int index = inIndex - 1 - i;
index = (index + OVERSAMPLE*QUALITY) % (OVERSAMPLE*QUALITY);
index = (index + OVERSAMPLE * QUALITY) % (OVERSAMPLE * QUALITY);
out += kernel[i] * inBuffer[index];
}
return out;
@@ -141,12 +141,12 @@ struct Decimator {
template <int OVERSAMPLE, int QUALITY>
struct Upsampler {
float inBuffer[QUALITY];
float kernel[OVERSAMPLE*QUALITY];
float kernel[OVERSAMPLE * QUALITY];
int inIndex;

Upsampler(float cutoff = 0.9f) {
boxcarLowpassIR(kernel, OVERSAMPLE*QUALITY, cutoff * 0.5f / OVERSAMPLE);
blackmanHarrisWindow(kernel, OVERSAMPLE*QUALITY);
boxcarLowpassIR(kernel, OVERSAMPLE * QUALITY, cutoff * 0.5f / OVERSAMPLE);
blackmanHarrisWindow(kernel, OVERSAMPLE * QUALITY);
reset();
}
void reset() {
@@ -154,7 +154,7 @@ struct Upsampler {
std::memset(inBuffer, 0, sizeof(inBuffer));
}
/** `out` must be length OVERSAMPLE */
void process(float in, float *out) {
void process(float in, float* out) {
// Zero-stuff input buffer
inBuffer[inIndex] = OVERSAMPLE * in;
// Advance index


+ 8
- 8
include/dsp/ringbuffer.hpp View File

@@ -18,13 +18,13 @@ struct RingBuffer {
size_t end = 0;

size_t mask(size_t i) const {
return i & (S - 1);
return i & (S - 1);
}
void push(T t) {
size_t i = mask(end++);
data[i] = t;
}
void pushBuffer(const T *t, int n) {
void pushBuffer(const T* t, int n) {
size_t i = mask(end);
size_t e1 = i + n;
size_t e2 = (e1 < S) ? e1 : S;
@@ -37,7 +37,7 @@ struct RingBuffer {
T shift() {
return data[mask(start++)];
}
void shiftBuffer(T *t, size_t n) {
void shiftBuffer(T* t, size_t n) {
size_t i = mask(start);
size_t s1 = i + n;
size_t s2 = (s1 < S) ? s1 : S;
@@ -70,7 +70,7 @@ Thread-safe for single producers and consumers?
*/
template <typename T, size_t S>
struct DoubleRingBuffer {
T data[S*2];
T data[S * 2];
size_t start = 0;
size_t end = 0;

@@ -104,7 +104,7 @@ struct DoubleRingBuffer {
If any data is appended, you must call endIncr afterwards.
Pointer is invalidated when any other method is called.
*/
T *endData() {
T* endData() {
return &data[mask(end)];
}
void endIncr(size_t n) {
@@ -123,7 +123,7 @@ struct DoubleRingBuffer {
/** Returns a pointer to S consecutive elements for consumption
If any data is consumed, call startIncr afterwards.
*/
const T *startData() const {
const T* startData() const {
return &data[mask(start)];
}
void startIncr(size_t n) {
@@ -174,7 +174,7 @@ struct AppleRingBuffer {
}
/** Returns a pointer to S consecutive elements for appending, requesting to append n elements.
*/
T *endData(size_t n) {
T* endData(size_t n) {
if (end + n > N) {
returnBuffer();
}
@@ -189,7 +189,7 @@ struct AppleRingBuffer {
/** Returns a pointer to S consecutive elements for consumption
If any data is consumed, call startIncr afterwards.
*/
const T *startData() const {
const T* startData() const {
return &data[start];
}
void startIncr(size_t n) {


+ 15
- 15
include/dsp/window.hpp View File

@@ -16,7 +16,7 @@ inline T hann(T p) {
}

/** Multiplies the Hann window by a signal `x` of length `len` in-place. */
inline void hannWindow(float *x, int len) {
inline void hannWindow(float* x, int len) {
for (int i = 0; i < len; i++) {
x[i] *= hann(float(i) / (len - 1));
}
@@ -29,12 +29,12 @@ A typical alpha value is 0.16.
template <typename T>
inline T blackman(T alpha, T p) {
return
+ (1 - alpha) / 2
- T(1) / 2 * simd::cos(2 * T(M_PI) * p)
+ alpha / 2 * simd::cos(4 * T(M_PI) * p);
+ (1 - alpha) / 2
- T(1) / 2 * simd::cos(2 * T(M_PI) * p)
+ alpha / 2 * simd::cos(4 * T(M_PI) * p);
}

inline void blackmanWindow(float alpha, float *x, int len) {
inline void blackmanWindow(float alpha, float* x, int len) {
for (int i = 0; i < len; i++) {
x[i] *= blackman(alpha, float(i) / (len - 1));
}
@@ -47,13 +47,13 @@ https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Nuttall_window
template <typename T>
inline T blackmanNuttall(T p) {
return
+ T(0.3635819)
- T(0.4891775) * simd::cos(2 * T(M_PI) * p)
+ T(0.1365995) * simd::cos(4 * T(M_PI) * p)
- T(0.0106411) * simd::cos(6 * T(M_PI) * p);
+ T(0.3635819)
- T(0.4891775) * simd::cos(2 * T(M_PI) * p)
+ T(0.1365995) * simd::cos(4 * T(M_PI) * p)
- T(0.0106411) * simd::cos(6 * T(M_PI) * p);
}

inline void blackmanNuttallWindow(float *x, int len) {
inline void blackmanNuttallWindow(float* x, int len) {
for (int i = 0; i < len; i++) {
x[i] *= blackmanNuttall(float(i) / (len - 1));
}
@@ -65,13 +65,13 @@ https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window
template <typename T>
inline T blackmanHarris(T p) {
return
+ T(0.35875)
- T(0.48829) * simd::cos(2 * T(M_PI) * p)
+ T(0.14128) * simd::cos(4 * T(M_PI) * p)
- T(0.01168) * simd::cos(6 * T(M_PI) * p);
+ T(0.35875)
- T(0.48829) * simd::cos(2 * T(M_PI) * p)
+ T(0.14128) * simd::cos(4 * T(M_PI) * p)
- T(0.01168) * simd::cos(6 * T(M_PI) * p);
}

inline void blackmanHarrisWindow(float *x, int len) {
inline void blackmanHarrisWindow(float* x, int len) {
for (int i = 0; i < len; i++) {
x[i] *= blackmanHarris(float(i) / (len - 1));
}


+ 2
- 2
include/engine/Cable.hpp View File

@@ -9,9 +9,9 @@ namespace engine {

struct Cable {
int id = -1;
Module *outputModule = NULL;
Module* outputModule = NULL;
int outputId;
Module *inputModule = NULL;
Module* inputModule = NULL;
int inputId;
};



+ 18
- 18
include/engine/Engine.hpp View File

@@ -12,7 +12,7 @@ namespace engine {

struct Engine {
struct Internal;
Internal *internal;
Internal* internal;

Engine();
~Engine();
@@ -37,12 +37,12 @@ struct Engine {
If the module ID is -1, an ID is automatically assigned.
Does not transfer pointer ownership.
*/
void addModule(Module *module);
void removeModule(Module *module);
Module *getModule(int moduleId);
void resetModule(Module *module);
void randomizeModule(Module *module);
void bypassModule(Module *module, bool bypass);
void addModule(Module* module);
void removeModule(Module* module);
Module* getModule(int moduleId);
void resetModule(Module* module);
void randomizeModule(Module* module);
void bypassModule(Module* module, bool bypass);

// Cables
/** Adds a cable to the rack engine.
@@ -50,26 +50,26 @@ struct Engine {
If the cable ID is -1, an ID is automatically assigned.
Does not transfer pointer ownership.
*/
void addCable(Cable *cable);
void removeCable(Cable *cable);
void addCable(Cable* cable);
void removeCable(Cable* cable);

// Params
void setParam(Module *module, int paramId, float value);
float getParam(Module *module, int paramId);
void setSmoothParam(Module *module, int paramId, float value);
float getSmoothParam(Module *module, int paramId);
void setParam(Module* module, int paramId, float value);
float getParam(Module* module, int paramId);
void setSmoothParam(Module* module, int paramId, float value);
float getSmoothParam(Module* module, int paramId);

// ParamHandles
void addParamHandle(ParamHandle *paramHandle);
void removeParamHandle(ParamHandle *paramHandle);
void addParamHandle(ParamHandle* paramHandle);
void removeParamHandle(ParamHandle* paramHandle);
/** Returns the unique ParamHandle for the given paramId */
ParamHandle *getParamHandle(int moduleId, int paramId);
ParamHandle* getParamHandle(int moduleId, int paramId);
/** Use getParamHandle(int, int) instead. */
DEPRECATED ParamHandle *getParamHandle(Module *module, int paramId);
DEPRECATED ParamHandle* getParamHandle(Module* module, int paramId);
/** Sets the ParamHandle IDs and module pointer.
If `overwrite` is true and another ParamHandle points to the same param, unsets that one and replaces it with the given handle.
*/
void updateParamHandle(ParamHandle *paramHandle, int moduleId, int paramId, bool overwrite = true);
void updateParamHandle(ParamHandle* paramHandle, int moduleId, int paramId, bool overwrite = true);
};




+ 14
- 12
include/engine/Module.hpp View File

@@ -14,7 +14,7 @@ namespace rack {


namespace plugin {
struct Model;
struct Model;
}


@@ -23,7 +23,7 @@ namespace engine {

/** DSP processor instance for your module. */
struct Module {
plugin::Model *model = NULL; /** Unique ID for referring to the module in the engine.
plugin::Model* model = NULL; /** Unique ID for referring to the module in the engine.
Assigned when added to the engine.
*/
int id = -1;
@@ -42,7 +42,7 @@ struct Module {
/** ID of the expander module, or -1 if nonexistent. */
int moduleId = -1;
/** Pointer to the expander Module, or NULL if nonexistent. */
Module *module = NULL;
Module* module = NULL;
/** Double buffer for receiving messages from the expander module.
If you intend to receive messages from an expander, allocate both message buffers with identical blocks of memory (arrays, structs, etc).
Remember to free the buffer in the Module destructor.
@@ -63,8 +63,8 @@ struct Module {
You may choose for your Module to instead write to its own message buffer for consumption by other modules, i.e. the expander "pulls" rather than this module "pushing".
As long as this convention is followed by the other module, this is fine.
*/
void *producerMessage = NULL;
void *consumerMessage = NULL;
void* producerMessage = NULL;
void* consumerMessage = NULL;
bool messageFlipRequested = false;
};

@@ -97,10 +97,10 @@ struct Module {
if (paramQuantities[paramId])
delete paramQuantities[paramId];

Param *p = &params[paramId];
Param* p = &params[paramId];
p->value = defaultValue;

ParamQuantity *q = new TParamQuantity;
ParamQuantity* q = new TParamQuantity;
q->module = this;
q->paramId = paramId;
q->minValue = minValue;
@@ -125,7 +125,7 @@ struct Module {
/** Advances the module by one audio sample.
Override this method to read Inputs and Params and to write Outputs and Lights.
*/
virtual void process(const ProcessArgs &args) {
virtual void process(const ProcessArgs& args) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
step();
@@ -145,12 +145,14 @@ struct Module {
/** Called when the Module is removed from the Engine */
virtual void onRemove() {}

json_t *toJson();
void fromJson(json_t *rootJ);
json_t* toJson();
void fromJson(json_t* rootJ);

/** Override to store extra internal data in the "data" property of the module's JSON object. */
virtual json_t *dataToJson() { return NULL; }
virtual void dataFromJson(json_t *root) {}
virtual json_t* dataToJson() {
return NULL;
}
virtual void dataFromJson(json_t* root) {}
};




+ 1
- 1
include/engine/ParamHandle.hpp View File

@@ -16,7 +16,7 @@ struct ParamHandle {
*/
int moduleId = -1;
int paramId = 0;
Module *module = NULL;
Module* module = NULL;

std::string text;
NVGcolor color;


+ 2
- 2
include/engine/ParamQuantity.hpp View File

@@ -12,7 +12,7 @@ struct Module;

/** A Quantity that wraps an engine::Param. */
struct ParamQuantity : Quantity {
Module *module = NULL;
Module* module = NULL;
int paramId = 0;

/** The minimum allowed value. */
@@ -38,7 +38,7 @@ struct ParamQuantity : Quantity {
/** An optional one-sentence description of the parameter. */
std::string description;

Param *getParam();
Param* getParam();
/** Request to the engine to smoothly set the value */
void setSmoothValue(float smoothValue);
float getSmoothValue();


+ 4
- 4
include/engine/Port.hpp View File

@@ -62,12 +62,12 @@ struct alignas(32) Port {
/** Returns a pointer to the array of voltages beginning with firstChannel.
The pointer can be used for reading and writing.
*/
float *getVoltages(int firstChannel = 0) {
float* getVoltages(int firstChannel = 0) {
return &voltages[firstChannel];
}

/** Copies the port's voltages to an array of size at least `channels`. */
void readVoltages(float *v) {
void readVoltages(float* v) {
for (int c = 0; c < channels; c++) {
v[c] = voltages[c];
}
@@ -76,7 +76,7 @@ struct alignas(32) Port {
/** Copies an array of size at least `channels` to the port's voltages.
Remember to set the number of channels *before* calling this method.
*/
void writeVoltages(const float *v) {
void writeVoltages(const float* v) {
for (int c = 0; c < channels; c++) {
voltages[c] = v[c];
}
@@ -105,7 +105,7 @@ struct alignas(32) Port {

template <typename T>
T getPolyVoltageSimd(int firstChannel) {
return isMonophonic() ? getVoltage(0) : getVoltageSimd<T>(firstChannel);
return isMonophonic() ? getVoltage(0) : getVoltageSimd<T>(firstChannel);
}

template <typename T>


+ 51
- 35
include/event.hpp View File

@@ -31,7 +31,7 @@ namespace rack {


namespace widget {
struct Widget;
struct Widget;
}


@@ -47,46 +47,52 @@ struct Context {
/** Whether the event has been consumed by an event handler and no more handlers should consume the event. */
bool consumed = false;
/** The widget that responded to the event. */
widget::Widget *target = NULL;
widget::Widget* target = NULL;
};


/** Base class for all events. */
struct Base {
Context *context = NULL;
Context* context = NULL;

/** Prevents the event from being handled by more Widgets.
*/
void stopPropagating() const {
if (!context) return;
if (!context)
return;
context->propagating = false;
}
bool isPropagating() const {
if (!context) return true;
if (!context)
return true;
return context->propagating;
}
/** Tells the event handler that a particular Widget consumed the event.
You usually want to stop propagation as well, so call consume() instead.
*/
void setTarget(widget::Widget *w) const {
if (!context) return;
void setTarget(widget::Widget* w) const {
if (!context)
return;
context->target = w;
}
widget::Widget *getTarget() const {
if (!context) return NULL;
widget::Widget* getTarget() const {
if (!context)
return NULL;
return context->target;
}
/** Sets the target Widget and stops propagating.
A NULL Widget may be passed to consume but not set a target.
*/
void consume(widget::Widget *w) const {
if (!context) return;
void consume(widget::Widget* w) const {
if (!context)
return;
context->propagating = false;
context->consumed = true;
context->target = w;
}
bool isConsumed() const {
if (!context) return false;
if (!context)
return false;
return context->consumed;
}
};
@@ -256,7 +262,7 @@ Consume this event to allow DragEnter and DragLeave to occur.
*/
struct DragHover : DragBase, PositionBase {
/** The dragged widget */
widget::Widget *origin = NULL;
widget::Widget* origin = NULL;
/** Change in mouse position since the last frame. Can be zero. */
math::Vec mouseDelta;
};
@@ -268,7 +274,7 @@ The target sets `draggedWidget`, which allows DragLeave to occur.
*/
struct DragEnter : DragBase {
/** The dragged widget */
widget::Widget *origin = NULL;
widget::Widget* origin = NULL;
};


@@ -277,7 +283,7 @@ Must consume the DragHover event (when the Widget is entered) to receive this ev
*/
struct DragLeave : DragBase {
/** The dragged widget */
widget::Widget *origin = NULL;
widget::Widget* origin = NULL;
};


@@ -286,7 +292,7 @@ Must consume the Button event (on release) to receive this event.
*/
struct DragDrop : DragBase {
/** The dragged widget */
widget::Widget *origin = NULL;
widget::Widget* origin = NULL;
};


@@ -294,10 +300,10 @@ struct DragDrop : DragBase {
Recurses.
*/
struct PathDrop : Base, PositionBase {
PathDrop(const std::vector<std::string> &paths) : paths(paths) {}
PathDrop(const std::vector<std::string>& paths) : paths(paths) {}

/** List of file paths in the dropped selection */
const std::vector<std::string> &paths;
const std::vector<std::string>& paths;
};


@@ -361,32 +367,42 @@ struct Hide : Base {


struct State {
widget::Widget *rootWidget = NULL;
widget::Widget* rootWidget = NULL;
/** State widgets
Don't set these directly unless you know what you're doing. Use the set*() methods instead.
*/
widget::Widget *hoveredWidget = NULL;
widget::Widget *draggedWidget = NULL;
widget::Widget* hoveredWidget = NULL;
widget::Widget* draggedWidget = NULL;
int dragButton = 0;
widget::Widget *dragHoveredWidget = NULL;
widget::Widget *selectedWidget = NULL;
widget::Widget* dragHoveredWidget = NULL;
widget::Widget* selectedWidget = NULL;
/** For double-clicking */
double lastClickTime = -INFINITY;
widget::Widget *lastClickedWidget = NULL;
widget::Widget* lastClickedWidget = NULL;
std::set<int> heldKeys;

widget::Widget *getRootWidget() {return rootWidget;}
widget::Widget *getHoveredWidget() {return hoveredWidget;}
widget::Widget *getDraggedWidget() {return draggedWidget;}
widget::Widget *getDragHoveredWidget() {return dragHoveredWidget;}
widget::Widget *getSelectedWidget() {return selectedWidget;}
widget::Widget* getRootWidget() {
return rootWidget;
}
widget::Widget* getHoveredWidget() {
return hoveredWidget;
}
widget::Widget* getDraggedWidget() {
return draggedWidget;
}
widget::Widget* getDragHoveredWidget() {
return dragHoveredWidget;
}
widget::Widget* getSelectedWidget() {
return selectedWidget;
}

void setHovered(widget::Widget *w);
void setDragged(widget::Widget *w, int button);
void setDragHovered(widget::Widget *w);
void setSelected(widget::Widget *w);
void setHovered(widget::Widget* w);
void setDragged(widget::Widget* w, int button);
void setDragHovered(widget::Widget* w);
void setSelected(widget::Widget* w);
/** Prepares a widget for deletion */
void finalizeWidget(widget::Widget *w);
void finalizeWidget(widget::Widget* w);

bool handleButton(math::Vec pos, int button, int action, int mods);
bool handleHover(math::Vec pos, math::Vec mouseDelta);
@@ -394,7 +410,7 @@ struct State {
bool handleScroll(math::Vec pos, math::Vec scrollDelta);
bool handleText(math::Vec pos, int codepoint);
bool handleKey(math::Vec pos, int key, int scancode, int action, int mods);
bool handleDrop(math::Vec pos, const std::vector<std::string> &paths);
bool handleDrop(math::Vec pos, const std::vector<std::string>& paths);
bool handleZoom();
};



+ 67
- 67
include/force_link_glibc_2.23.h View File

@@ -501,11 +501,11 @@ __asm__(".symver __progname_full,__progname_full@GLIBC_2.2.5");
__asm__(".symver __pthread_cleanup_routine,__pthread_cleanup_routine@GLIBC_2.3.3");
__asm__(".symver __pthread_getspecific,__pthread_getspecific@GLIBC_2.2.5");
#ifndef _GLIBCXX_SHARED
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver __pthread_key_create,__pthread_key_create@GLIBC_2.2.5");
#endif
#endif
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver __pthread_key_create,__pthread_key_create@GLIBC_2.2.5");
#endif
#endif
#endif
__asm__(".symver __pthread_mutex_destroy,__pthread_mutex_destroy@GLIBC_2.2.5");
__asm__(".symver __pthread_mutex_init,__pthread_mutex_init@GLIBC_2.2.5");
@@ -544,7 +544,7 @@ __asm__(".symver __realpath_chk,__realpath_chk@GLIBC_2.4");
__asm__(".symver __recv_chk,__recv_chk@GLIBC_2.4");
__asm__(".symver __recvfrom_chk,__recvfrom_chk@GLIBC_2.4");
#ifdef _REENTRANT
__asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2");
__asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2");
#endif
__asm__(".symver __remainder_finite,__remainder_finite@GLIBC_2.15");
__asm__(".symver __remainderf_finite,__remainderf_finite@GLIBC_2.15");
@@ -2009,47 +2009,47 @@ __asm__(".symver pselect,pselect@GLIBC_2.2.5");
__asm__(".symver psiginfo,psiginfo@GLIBC_2.10");
__asm__(".symver psignal,psignal@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_destroy,pthread_attr_destroy@GLIBC_2.2.5");
__asm__(".symver pthread_attr_destroy,pthread_attr_destroy@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_getaffinity_np,pthread_attr_getaffinity_np@GLIBC_2.3.4");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_getdetachstate,pthread_attr_getdetachstate@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getdetachstate,pthread_attr_getdetachstate@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_getguardsize,pthread_attr_getguardsize@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_getinheritsched,pthread_attr_getinheritsched@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getinheritsched,pthread_attr_getinheritsched@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_getschedparam,pthread_attr_getschedparam@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getschedparam,pthread_attr_getschedparam@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_getschedpolicy,pthread_attr_getschedpolicy@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getschedpolicy,pthread_attr_getschedpolicy@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_getscope,pthread_attr_getscope@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getscope,pthread_attr_getscope@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_getstack,pthread_attr_getstack@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getstackaddr,pthread_attr_getstackaddr@GLIBC_2.2.5");
__asm__(".symver pthread_attr_getstacksize,pthread_attr_getstacksize@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_init,pthread_attr_init@GLIBC_2.2.5");
__asm__(".symver pthread_attr_init,pthread_attr_init@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_setaffinity_np,pthread_attr_setaffinity_np@GLIBC_2.3.4");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_setdetachstate,pthread_attr_setdetachstate@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setdetachstate,pthread_attr_setdetachstate@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_setguardsize,pthread_attr_setguardsize@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_attr_setinheritsched,pthread_attr_setinheritsched@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setinheritsched,pthread_attr_setinheritsched@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_setschedparam,pthread_attr_setschedparam@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setschedparam,pthread_attr_setschedparam@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_setschedpolicy,pthread_attr_setschedpolicy@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setschedpolicy,pthread_attr_setschedpolicy@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_attr_setscope,pthread_attr_setscope@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setscope,pthread_attr_setscope@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_attr_setstack,pthread_attr_setstack@GLIBC_2.2.5");
__asm__(".symver pthread_attr_setstackaddr,pthread_attr_setstackaddr@GLIBC_2.2.5");
@@ -2063,44 +2063,44 @@ __asm__(".symver pthread_barrierattr_init,pthread_barrierattr_init@GLIBC_2.2.5")
__asm__(".symver pthread_barrierattr_setpshared,pthread_barrierattr_setpshared@GLIBC_2.2.5");
__asm__(".symver pthread_cancel,pthread_cancel@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_cond_broadcast,pthread_cond_broadcast@GLIBC_2.3.2");
__asm__(".symver pthread_cond_broadcast,pthread_cond_broadcast@GLIBC_2.3.2");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_cond_destroy,pthread_cond_destroy@GLIBC_2.3.2");
__asm__(".symver pthread_cond_destroy,pthread_cond_destroy@GLIBC_2.3.2");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_cond_init,pthread_cond_init@GLIBC_2.3.2");
__asm__(".symver pthread_cond_init,pthread_cond_init@GLIBC_2.3.2");
#endif
__asm__(".symver pthread_cond_signal,pthread_cond_signal@GLIBC_2.3.2");
#ifdef _REENTRANT
__asm__(".symver pthread_cond_timedwait,pthread_cond_timedwait@GLIBC_2.3.2");
__asm__(".symver pthread_cond_timedwait,pthread_cond_timedwait@GLIBC_2.3.2");
#endif
__asm__(".symver pthread_cond_wait,pthread_cond_wait@GLIBC_2.3.2");
#ifdef _REENTRANT
__asm__(".symver pthread_condattr_destroy,pthread_condattr_destroy@GLIBC_2.2.5");
__asm__(".symver pthread_condattr_destroy,pthread_condattr_destroy@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_condattr_getclock,pthread_condattr_getclock@GLIBC_2.3.3");
__asm__(".symver pthread_condattr_getpshared,pthread_condattr_getpshared@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_condattr_init,pthread_condattr_init@GLIBC_2.2.5");
__asm__(".symver pthread_condattr_init,pthread_condattr_init@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_condattr_setclock,pthread_condattr_setclock@GLIBC_2.3.3");
__asm__(".symver pthread_condattr_setpshared,pthread_condattr_setpshared@GLIBC_2.2.5");
#ifndef _GLIBCXX_SHARED
#ifdef _REENTRANT
__asm__(".symver pthread_create,pthread_create@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_create,pthread_create@GLIBC_2.2.5");
#endif
#endif
#ifndef _GLIBCXX_SHARED
#ifdef _REENTRANT
__asm__(".symver pthread_detach,pthread_detach@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_detach,pthread_detach@GLIBC_2.2.5");
#endif
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5");
__asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5");
__asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_getaffinity_np,pthread_getaffinity_np@GLIBC_2.3.4");
__asm__(".symver pthread_getattr_default_np,pthread_getattr_default_np@GLIBC_2.18");
@@ -2109,50 +2109,50 @@ __asm__(".symver pthread_getconcurrency,pthread_getconcurrency@GLIBC_2.2.5");
__asm__(".symver pthread_getcpuclockid,pthread_getcpuclockid@GLIBC_2.2.5");
__asm__(".symver pthread_getname_np,pthread_getname_np@GLIBC_2.12");
#ifdef _REENTRANT
__asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5");
__asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5");
#endif
#ifndef _GLIBCXX_SHARED
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_getspecific,pthread_getspecific@GLIBC_2.2.5");
#endif
#endif
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_getspecific,pthread_getspecific@GLIBC_2.2.5");
#endif
#endif
#endif
#ifndef _GLIBCXX_SHARED
#ifdef _REENTRANT
__asm__(".symver pthread_join,pthread_join@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_join,pthread_join@GLIBC_2.2.5");
#endif
#endif
#ifndef _GLIBCXX_SHARED
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_key_create,pthread_key_create@GLIBC_2.2.5");
#endif
#endif
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_key_create,pthread_key_create@GLIBC_2.2.5");
#endif
#endif
#endif
#ifndef _GLIBCXX_SHARED
#ifdef _REENTRANT
__asm__(".symver pthread_key_delete,pthread_key_delete@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_key_delete,pthread_key_delete@GLIBC_2.2.5");
#endif
#endif
__asm__(".symver pthread_kill,pthread_kill@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_consistent,pthread_mutex_consistent@GLIBC_2.12");
__asm__(".symver pthread_mutex_consistent_np,pthread_mutex_consistent_np@GLIBC_2.4");
#ifdef _REENTRANT
__asm__(".symver pthread_mutex_destroy,pthread_mutex_destroy@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_destroy,pthread_mutex_destroy@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_mutex_getprioceiling,pthread_mutex_getprioceiling@GLIBC_2.4");
#ifdef _REENTRANT
__asm__(".symver pthread_mutex_init,pthread_mutex_init@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_init,pthread_mutex_init@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_mutex_lock,pthread_mutex_lock@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_lock,pthread_mutex_lock@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_mutex_setprioceiling,pthread_mutex_setprioceiling@GLIBC_2.4");
__asm__(".symver pthread_mutex_timedlock,pthread_mutex_timedlock@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_trylock,pthread_mutex_trylock@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_mutex_unlock,pthread_mutex_unlock@GLIBC_2.2.5");
__asm__(".symver pthread_mutex_unlock,pthread_mutex_unlock@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_mutexattr_destroy,pthread_mutexattr_destroy@GLIBC_2.2.5");
__asm__(".symver pthread_mutexattr_getkind_np,pthread_mutexattr_getkind_np@GLIBC_2.2.5");
@@ -2171,11 +2171,11 @@ __asm__(".symver pthread_mutexattr_setrobust,pthread_mutexattr_setrobust@GLIBC_2
__asm__(".symver pthread_mutexattr_setrobust_np,pthread_mutexattr_setrobust_np@GLIBC_2.4");
__asm__(".symver pthread_mutexattr_settype,pthread_mutexattr_settype@GLIBC_2.2.5");
#ifndef _GLIBCXX_SHARED
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_once,pthread_once@GLIBC_2.2.5");
#endif
#endif
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_once,pthread_once@GLIBC_2.2.5");
#endif
#endif
#endif
__asm__(".symver pthread_rwlock_destroy,pthread_rwlock_destroy@GLIBC_2.2.5");
__asm__(".symver pthread_rwlock_init,pthread_rwlock_init@GLIBC_2.2.5");
@@ -2193,28 +2193,28 @@ __asm__(".symver pthread_rwlockattr_init,pthread_rwlockattr_init@GLIBC_2.2.5");
__asm__(".symver pthread_rwlockattr_setkind_np,pthread_rwlockattr_setkind_np@GLIBC_2.2.5");
__asm__(".symver pthread_rwlockattr_setpshared,pthread_rwlockattr_setpshared@GLIBC_2.2.5");
#ifdef _REENTRANT
__asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5");
__asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_setaffinity_np,pthread_setaffinity_np@GLIBC_2.3.4");
__asm__(".symver pthread_setattr_default_np,pthread_setattr_default_np@GLIBC_2.18");
#ifdef _REENTRANT
__asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5");
__asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5");
#endif
#ifdef _REENTRANT
__asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5");
__asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_setconcurrency,pthread_setconcurrency@GLIBC_2.2.5");
__asm__(".symver pthread_setname_np,pthread_setname_np@GLIBC_2.12");
#ifdef _REENTRANT
__asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5");
__asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5");
#endif
__asm__(".symver pthread_setschedprio,pthread_setschedprio@GLIBC_2.3.4");
#ifndef _GLIBCXX_SHARED
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_setspecific,pthread_setspecific@GLIBC_2.2.5");
#endif
#endif
#ifndef IN_LIBGCC2
#ifdef _REENTRANT
__asm__(".symver pthread_setspecific,pthread_setspecific@GLIBC_2.2.5");
#endif
#endif
#endif
__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2.5");
__asm__(".symver pthread_sigqueue,pthread_sigqueue@GLIBC_2.11");


+ 36
- 36
include/helpers.hpp View File

@@ -17,49 +17,49 @@ namespace rack {


template <class TModule, class TModuleWidget, typename... Tags>
plugin::Model *createModel(const std::string &slug) {
plugin::Model* createModel(const std::string& slug) {
struct TModel : plugin::Model {
engine::Module *createModule() override {
engine::Module *m = new TModule;
engine::Module* createModule() override {
engine::Module* m = new TModule;
m->model = this;
return m;
}
app::ModuleWidget *createModuleWidget() override {
TModule *m = new TModule;
app::ModuleWidget* createModuleWidget() override {
TModule* m = new TModule;
m->engine::Module::model = this;
app::ModuleWidget *mw = new TModuleWidget(m);
app::ModuleWidget* mw = new TModuleWidget(m);
mw->model = this;
return mw;
}
app::ModuleWidget *createModuleWidgetNull() override {
app::ModuleWidget *mw = new TModuleWidget(NULL);
app::ModuleWidget* createModuleWidgetNull() override {
app::ModuleWidget* mw = new TModuleWidget(NULL);
mw->model = this;
return mw;
}
};

plugin::Model *o = new TModel;
plugin::Model* o = new TModel;
o->slug = slug;
return o;
}

template <class TWidget>
TWidget *createWidget(math::Vec pos) {
TWidget *o = new TWidget;
TWidget* createWidget(math::Vec pos) {
TWidget* o = new TWidget;
o->box.pos = pos;
return o;
}

template <class TWidget>
TWidget *createWidgetCentered(math::Vec pos) {
TWidget *o = createWidget<TWidget>(pos);
TWidget* createWidgetCentered(math::Vec pos) {
TWidget* o = createWidget<TWidget>(pos);
o->box.pos = o->box.pos.minus(o->box.size.div(2));
return o;
}

template <class TParamWidget>
TParamWidget *createParam(math::Vec pos, engine::Module *module, int paramId) {
TParamWidget *o = new TParamWidget;
TParamWidget* createParam(math::Vec pos, engine::Module* module, int paramId) {
TParamWidget* o = new TParamWidget;
o->box.pos = pos;
if (module) {
o->paramQuantity = module->paramQuantities[paramId];
@@ -68,15 +68,15 @@ TParamWidget *createParam(math::Vec pos, engine::Module *module, int paramId) {
}

template <class TParamWidget>
TParamWidget *createParamCentered(math::Vec pos, engine::Module *module, int paramId) {
TParamWidget *o = createParam<TParamWidget>(pos, module, paramId);
TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) {
TParamWidget* o = createParam<TParamWidget>(pos, module, paramId);
o->box.pos = o->box.pos.minus(o->box.size.div(2));
return o;
}

template <class TPortWidget>
TPortWidget *createInput(math::Vec pos, engine::Module *module, int inputId) {
TPortWidget *o = new TPortWidget;
TPortWidget* createInput(math::Vec pos, engine::Module* module, int inputId) {
TPortWidget* o = new TPortWidget;
o->box.pos = pos;
o->module = module;
o->type = app::PortWidget::INPUT;
@@ -85,15 +85,15 @@ TPortWidget *createInput(math::Vec pos, engine::Module *module, int inputId) {
}

template <class TPortWidget>
TPortWidget *createInputCentered(math::Vec pos, engine::Module *module, int inputId) {
TPortWidget *o = createInput<TPortWidget>(pos, module, inputId);
TPortWidget* createInputCentered(math::Vec pos, engine::Module* module, int inputId) {
TPortWidget* o = createInput<TPortWidget>(pos, module, inputId);
o->box.pos = o->box.pos.minus(o->box.size.div(2));
return o;
}

template <class TPortWidget>
TPortWidget *createOutput(math::Vec pos, engine::Module *module, int outputId) {
TPortWidget *o = new TPortWidget;
TPortWidget* createOutput(math::Vec pos, engine::Module* module, int outputId) {
TPortWidget* o = new TPortWidget;
o->box.pos = pos;
o->module = module;
o->type = app::PortWidget::OUTPUT;
@@ -102,15 +102,15 @@ TPortWidget *createOutput(math::Vec pos, engine::Module *module, int outputId) {
}

template <class TPortWidget>
TPortWidget *createOutputCentered(math::Vec pos, engine::Module *module, int outputId) {
TPortWidget *o = createOutput<TPortWidget>(pos, module, outputId);
TPortWidget* createOutputCentered(math::Vec pos, engine::Module* module, int outputId) {
TPortWidget* o = createOutput<TPortWidget>(pos, module, outputId);
o->box.pos = o->box.pos.minus(o->box.size.div(2));
return o;
}

template <class TModuleLightWidget>
TModuleLightWidget *createLight(math::Vec pos, engine::Module *module, int firstLightId) {
TModuleLightWidget *o = new TModuleLightWidget;
TModuleLightWidget* createLight(math::Vec pos, engine::Module* module, int firstLightId) {
TModuleLightWidget* o = new TModuleLightWidget;
o->box.pos = pos;
o->module = module;
o->firstLightId = firstLightId;
@@ -118,33 +118,33 @@ TModuleLightWidget *createLight(math::Vec pos, engine::Module *module, int first
}

template <class TModuleLightWidget>
TModuleLightWidget *createLightCentered(math::Vec pos, engine::Module *module, int firstLightId) {
TModuleLightWidget *o = createLight<TModuleLightWidget>(pos, module, firstLightId);
TModuleLightWidget* createLightCentered(math::Vec pos, engine::Module* module, int firstLightId) {
TModuleLightWidget* o = createLight<TModuleLightWidget>(pos, module, firstLightId);
o->box.pos = o->box.pos.minus(o->box.size.div(2));
return o;
}

template <class TMenuLabel = ui::MenuLabel>
TMenuLabel *createMenuLabel(std::string text) {
TMenuLabel *o = new TMenuLabel;
TMenuLabel * createMenuLabel(std::string text) {
TMenuLabel* o = new TMenuLabel;
o->text = text;
return o;
}

template <class TMenuItem = ui::MenuItem>
TMenuItem *createMenuItem(std::string text, std::string rightText = "") {
TMenuItem *o = new TMenuItem;
TMenuItem * createMenuItem(std::string text, std::string rightText = "") {
TMenuItem* o = new TMenuItem;
o->text = text;
o->rightText = rightText;
return o;
}

template <class TMenu = ui::Menu>
TMenu *createMenu() {
TMenu *o = new TMenu;
TMenu * createMenu() {
TMenu* o = new TMenu;
o->box.pos = APP->window->mousePos;

ui::MenuOverlay *menuOverlay = new ui::MenuOverlay;
ui::MenuOverlay* menuOverlay = new ui::MenuOverlay;
menuOverlay->addChild(o);

APP->scene->addChild(menuOverlay);


+ 10
- 10
include/history.hpp View File

@@ -11,8 +11,8 @@ namespace rack {


namespace app {
struct ModuleWidget;
struct CableWidget;
struct ModuleWidget;
struct CableWidget;
} // namespace app


@@ -52,7 +52,7 @@ struct ComplexAction : Action {
~ComplexAction();
void undo() override;
void redo() override;
void push(Action *action);
void push(Action* action);
bool isEmpty();
};

@@ -66,14 +66,14 @@ struct ModuleAction : Action {


struct ModuleAdd : ModuleAction {
plugin::Model *model;
plugin::Model* model;
math::Vec pos;
json_t *moduleJ;
json_t* moduleJ;
ModuleAdd() {
name = "add module";
}
~ModuleAdd();
void setModule(app::ModuleWidget *mw);
void setModule(app::ModuleWidget* mw);
void undo() override;
void redo() override;
};
@@ -108,8 +108,8 @@ struct ModuleBypass : ModuleAction {


struct ModuleChange : ModuleAction {
json_t *oldModuleJ;
json_t *newModuleJ;
json_t* oldModuleJ;
json_t* newModuleJ;
ModuleChange() {
name = "change module";
}
@@ -138,7 +138,7 @@ struct CableAdd : Action {
int inputModuleId;
int inputId;
NVGcolor color;
void setCable(app::CableWidget *cw);
void setCable(app::CableWidget* cw);
void undo() override;
void redo() override;
CableAdd() {
@@ -163,7 +163,7 @@ struct State {
State();
~State();
void clear();
void push(Action *action);
void push(Action* action);
void undo();
void redo();
bool canUndo();


+ 1
- 1
include/logger.hpp View File

@@ -35,7 +35,7 @@ void destroy();
/** Do not use this function directly. Use the macros above.
Thread-safe, meaning messages cannot overlap each other in the log.
*/
void log(Level level, const char *filename, int line, const char *format, ...);
void log(Level level, const char* filename, int line, const char* format, ...);


} // namespace logger


+ 20
- 14
include/math.hpp View File

@@ -64,7 +64,7 @@ inline int eucDiv(int a, int b) {
return div;
}

inline void eucDivMod(int a, int b, int *div, int *mod) {
inline void eucDivMod(int a, int b, int* div, int* mod) {
*div = a / b;
*mod = a % b;
if (*mod < 0) {
@@ -149,10 +149,10 @@ inline float crossfade(float a, float b, float p) {
/** Linearly interpolates an array `p` with index `x`.
Assumes that the array at `p` is of length at least `floor(x) + 1`.
*/
inline float interpolateLinear(const float *p, float x) {
inline float interpolateLinear(const float* p, float x) {
int xi = x;
float xf = x - xi;
return crossfade(p[xi], p[xi+1], xf);
return crossfade(p[xi], p[xi + 1], xf);
}

/** Complex multiplication `c = a * b`.
@@ -161,7 +161,7 @@ Example:

cmultf(ar, ai, br, bi, &ar, &ai);
*/
inline void complexMult(float ar, float ai, float br, float bi, float *cr, float *ci) {
inline void complexMult(float ar, float ai, float br, float bi, float* cr, float* ci) {
*cr = ar * br - ai * bi;
*ci = ar * bi + ai * br;
}
@@ -280,17 +280,17 @@ struct Rect {
/** Returns whether this Rect contains an entire point, inclusive on the top/left, non-inclusive on the bottom/right. */
bool isContaining(Vec v) const {
return pos.x <= v.x && v.x < pos.x + size.x
&& pos.y <= v.y && v.y < pos.y + size.y;
&& pos.y <= v.y && v.y < pos.y + size.y;
}
/** Returns whether this Rect contains an entire Rect. */
bool isContaining(Rect r) const {
return pos.x <= r.pos.x && r.pos.x + r.size.x <= pos.x + size.x
&& pos.y <= r.pos.y && r.pos.y + r.size.y <= pos.y + size.y;
&& pos.y <= r.pos.y && r.pos.y + r.size.y <= pos.y + size.y;
}
/** Returns whether this Rect overlaps with another Rect. */
bool isIntersecting(Rect r) const {
return (pos.x + size.x > r.pos.x && r.pos.x + r.size.x > pos.x)
&& (pos.y + size.y > r.pos.y && r.pos.y + r.size.y > pos.y);
&& (pos.y + size.y > r.pos.y && r.pos.y + r.size.y > pos.y);
}
bool isEqual(Rect r) const {
return pos.isEqual(r.pos) && size.isEqual(r.size);
@@ -365,22 +365,28 @@ struct Rect {
return r;
}

DEPRECATED bool contains(Vec v) const {return isContaining(v);}
DEPRECATED bool contains(Rect r) const {return isContaining(r);}
DEPRECATED bool intersects(Rect r) const {return isIntersecting(r);}
DEPRECATED bool contains(Vec v) const {
return isContaining(v);
}
DEPRECATED bool contains(Rect r) const {
return isContaining(r);
}
DEPRECATED bool intersects(Rect r) const {
return isIntersecting(r);
}
};


inline Vec Vec::clamp(Rect bound) const {
return Vec(
math::clamp(x, bound.pos.x, bound.pos.x + bound.size.x),
math::clamp(y, bound.pos.y, bound.pos.y + bound.size.y));
math::clamp(x, bound.pos.x, bound.pos.x + bound.size.x),
math::clamp(y, bound.pos.y, bound.pos.y + bound.size.y));
}

inline Vec Vec::clampSafe(Rect bound) const {
return Vec(
math::clampSafe(x, bound.pos.x, bound.pos.x + bound.size.x),
math::clampSafe(y, bound.pos.y, bound.pos.y + bound.size.y));
math::clampSafe(x, bound.pos.x, bound.pos.x + bound.size.x),
math::clampSafe(y, bound.pos.y, bound.pos.y + bound.size.y));
}




+ 34
- 20
include/midi.hpp View File

@@ -59,17 +59,31 @@ struct Output;

struct Driver {
virtual ~Driver() {}
virtual std::string getName() {return "";}
virtual std::string getName() {
return "";
}

virtual std::vector<int> getInputDeviceIds() {return {};}
virtual std::string getInputDeviceName(int deviceId) {return "";}
virtual InputDevice *subscribeInput(int deviceId, Input *input) {return NULL;}
virtual void unsubscribeInput(int deviceId, Input *input) {}
virtual std::vector<int> getInputDeviceIds() {
return {};
}
virtual std::string getInputDeviceName(int deviceId) {
return "";
}
virtual InputDevice* subscribeInput(int deviceId, Input* input) {
return NULL;
}
virtual void unsubscribeInput(int deviceId, Input* input) {}

virtual std::vector<int> getOutputDeviceIds() {return {};}
virtual std::string getOutputDeviceName(int deviceId) {return "";}
virtual OutputDevice *subscribeOutput(int deviceId, Output *output) {return NULL;}
virtual void unsubscribeOutput(int deviceId, Output *output) {}
virtual std::vector<int> getOutputDeviceIds() {
return {};
}
virtual std::string getOutputDeviceName(int deviceId) {
return "";
}
virtual OutputDevice* subscribeOutput(int deviceId, Output* output) {
return NULL;
}
virtual void unsubscribeOutput(int deviceId, Output* output) {}
};

////////////////////
@@ -82,15 +96,15 @@ struct Device {

struct InputDevice : Device {
std::set<Input*> subscribed;
void subscribe(Input *input);
void unsubscribe(Input *input);
void subscribe(Input* input);
void unsubscribe(Input* input);
void onMessage(Message message);
};

struct OutputDevice : Device {
std::set<Output*> subscribed;
void subscribe(Output *input);
void unsubscribe(Output *input);
void subscribe(Output* input);
void unsubscribe(Output* input);
virtual void sendMessage(Message message) {}
};

@@ -108,7 +122,7 @@ struct Port {
*/
int channel = -1;
/** Not owned */
Driver *driver = NULL;
Driver* driver = NULL;

/** Remember to call setDriverId(-1) in subclass destructors. */
virtual ~Port() {}
@@ -125,14 +139,14 @@ struct Port {
std::string getChannelName(int channel);
void setChannel(int channel);

json_t *toJson();
void fromJson(json_t *rootJ);
json_t* toJson();
void fromJson(json_t* rootJ);
};


struct Input : Port {
/** Not owned */
InputDevice *inputDevice = NULL;
InputDevice* inputDevice = NULL;

Input();
~Input();
@@ -152,13 +166,13 @@ struct InputQueue : Input {
std::queue<Message> queue;
void onMessage(Message message) override;
/** If a Message is available, writes `message` and return true */
bool shift(Message *message);
bool shift(Message* message);
};


struct Output : Port {
/** Not owned */
OutputDevice *outputDevice = NULL;
OutputDevice* outputDevice = NULL;

Output();
~Output();
@@ -176,7 +190,7 @@ struct Output : Port {
void init();
void destroy();
/** Registers a new MIDI driver. Takes pointer ownership. */
void addDriver(int driverId, Driver *driver);
void addDriver(int driverId, Driver* driver);


} // namespace midi


+ 4
- 4
include/network.hpp View File

@@ -21,13 +21,13 @@ enum Method {
/** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc)
Caller must json_decref().
*/
json_t *requestJson(Method method, std::string url, json_t *dataJ);
json_t* requestJson(Method method, std::string url, json_t* dataJ);
/** Returns true if downloaded successfully */
bool requestDownload(std::string url, const std::string &filename, float *progress);
bool requestDownload(std::string url, const std::string& filename, float* progress);
/** URL-encodes `s` */
std::string encodeUrl(const std::string &s);
std::string encodeUrl(const std::string& s);
/** Gets the path portion of the URL. */
std::string urlPath(const std::string &url);
std::string urlPath(const std::string& url);


} // namespace network


+ 2
- 2
include/patch.hpp View File

@@ -30,8 +30,8 @@ struct PatchManager {
/** Disconnects all cables */
void disconnectDialog();

json_t *toJson();
void fromJson(json_t *rootJ);
json_t* toJson();
void fromJson(json_t* rootJ);
bool isLegacy(int level);
};



+ 7
- 7
include/plugin.hpp View File

@@ -25,21 +25,21 @@ struct Update {

void init();
void destroy();
void logIn(const std::string &email, const std::string &password);
void logIn(const std::string& email, const std::string& password);
void logOut();
bool isLoggedIn();
void queryUpdates();
bool hasUpdates();
void syncUpdate(Update *update);
void syncUpdate(Update* update);
void syncUpdates();
bool isSyncing();
Plugin *getPlugin(const std::string &pluginSlug);
Model *getModel(const std::string &pluginSlug, const std::string &modelSlug);
std::string normalizeTag(const std::string &tag);
Plugin* getPlugin(const std::string& pluginSlug);
Model* getModel(const std::string& pluginSlug, const std::string& modelSlug);
std::string normalizeTag(const std::string& tag);
/** Checks that the slug contains only alphanumeric characters, "-", and "_" */
bool isSlugValid(const std::string &slug);
bool isSlugValid(const std::string& slug);
/** Returns a string containing only the valid slug characters. */
std::string normalizeSlug(const std::string &slug);
std::string normalizeSlug(const std::string& slug);


extern const std::set<std::string> allowedTags;


+ 13
- 7
include/plugin/Model.hpp View File

@@ -9,12 +9,12 @@ namespace rack {


namespace app {
struct ModuleWidget;
struct ModuleWidget;
} // namespace app


namespace engine {
struct Module;
struct Module;
} // namespace engine


@@ -22,7 +22,7 @@ namespace plugin {


struct Model {
Plugin *plugin = NULL;
Plugin* plugin = NULL;
std::vector<std::string> presetPaths;

/** Must be unique. Used for saving patches. Never change this after releasing your module.
@@ -38,13 +38,19 @@ struct Model {

virtual ~Model() {}
/** Creates a headless Module */
virtual engine::Module *createModule() { return NULL; }
virtual engine::Module* createModule() {
return NULL;
}
/** Creates a ModuleWidget with a Module attached */
virtual app::ModuleWidget *createModuleWidget() { return NULL; }
virtual app::ModuleWidget* createModuleWidget() {
return NULL;
}
/** Creates a ModuleWidget with no Module, useful for previews */
virtual app::ModuleWidget *createModuleWidgetNull() { return NULL; }
virtual app::ModuleWidget* createModuleWidgetNull() {
return NULL;
}

void fromJson(json_t *rootJ);
void fromJson(json_t* rootJ);
};




+ 4
- 4
include/plugin/Plugin.hpp View File

@@ -18,7 +18,7 @@ struct Plugin {
/** The file path to the plugin's directory */
std::string path;
/** OS-dependent library handle */
void *handle = NULL;
void* handle = NULL;

/** Must be unique. Used for saving patches. Never change this after releasing your plugin.
To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin"
@@ -63,9 +63,9 @@ struct Plugin {
double modifiedTimestamp = -INFINITY;

~Plugin();
void addModel(Model *model);
Model *getModel(std::string slug);
void fromJson(json_t *rootJ);
void addModel(Model* model);
Model* getModel(std::string slug);
void fromJson(json_t* rootJ);
};




+ 1
- 1
include/plugin/callbacks.hpp View File

@@ -6,4 +6,4 @@
You must implement this in your plugin
*/
extern "C"
void init(rack::plugin::Plugin *plugin);
void init(rack::plugin::Plugin* plugin);

+ 10
- 10
include/rack.hpp View File

@@ -101,16 +101,16 @@ namespace rack {

/** Define this macro before including this header to prevent common namespaces from being included in the main `rack::` namespace. */
#ifndef RACK_FLATTEN_NAMESPACES
// Import some namespaces for convenience
using namespace logger;
using namespace math;
using namespace widget;
using namespace ui;
using namespace app;
using plugin::Plugin;
using plugin::Model;
using namespace engine;
using namespace componentlibrary;
// Import some namespaces for convenience
using namespace logger;
using namespace math;
using namespace widget;
using namespace ui;
using namespace app;
using plugin::Plugin;
using plugin::Model;
using namespace engine;
using namespace componentlibrary;
#endif




+ 143
- 53
include/rack0.hpp View File

@@ -17,35 +17,91 @@ namespace rack {

using namespace math;

DEPRECATED inline int min(int a, int b) {return std::min(a, b);}
DEPRECATED inline int max(int a, int b) {return std::max(a, b);}
DEPRECATED inline int eucmod(int a, int base) {return eucMod(a, base);}
DEPRECATED inline bool ispow2(int n) {return isPow2(n);}
DEPRECATED inline int clamp2(int x, int a, int b) {return clampSafe(x, a, b);}
DEPRECATED inline float min(float a, float b) {return std::min(a, b);}
DEPRECATED inline float max(float a, float b) {return std::max(a, b);}
DEPRECATED inline float eucmod(float a, float base) {return eucMod(a, base);}
DEPRECATED inline float clamp2(float x, float a, float b) {return clampSafe(x, a, b);}

DEPRECATED inline int mini(int a, int b) {return std::min(a, b);}
DEPRECATED inline int maxi(int a, int b) {return std::max(a, b);}
DEPRECATED inline int clampi(int x, int min, int max) {return math::clamp(x, min, max);}
DEPRECATED inline int absi(int a) {return std::fabs(a);}
DEPRECATED inline int eucmodi(int a, int base) {return eucMod(a, base);}
DEPRECATED inline int log2i(int n) {return math::log2(n);}
DEPRECATED inline bool ispow2i(int n) {return isPow2(n);}
DEPRECATED inline float absf(float x) {return std::fabs(x);}
DEPRECATED inline float sgnf(float x) {return sgn(x);}
DEPRECATED inline float eucmodf(float a, float base) {return eucMod(a, base);}
DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) {return math::isNear(a, b, epsilon);}
DEPRECATED inline float clampf(float x, float min, float max) {return math::clamp(x, min, max);}
DEPRECATED inline float clamp2f(float x, float min, float max) {return clampSafe(x, min, max);}
DEPRECATED inline float chopf(float x, float eps) {return chop(x, eps);}
DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {return math::rescale(x, a, b, yMin, yMax);}
DEPRECATED inline float crossf(float a, float b, float frac) {return crossfade(a, b, frac);}
DEPRECATED inline float interpf(const float *p, float x) {return interpolateLinear(p, x);}
DEPRECATED inline void complexMult(float *cr, float *ci, float ar, float ai, float br, float bi) {complexMult(ar, ai, br, bi, cr, ci);}
DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(ar, ai, br, bi, cr, ci);}
DEPRECATED inline int min(int a, int b) {
return std::min(a, b);
}
DEPRECATED inline int max(int a, int b) {
return std::max(a, b);
}
DEPRECATED inline int eucmod(int a, int base) {
return eucMod(a, base);
}
DEPRECATED inline bool ispow2(int n) {
return isPow2(n);
}
DEPRECATED inline int clamp2(int x, int a, int b) {
return clampSafe(x, a, b);
}
DEPRECATED inline float min(float a, float b) {
return std::min(a, b);
}
DEPRECATED inline float max(float a, float b) {
return std::max(a, b);
}
DEPRECATED inline float eucmod(float a, float base) {
return eucMod(a, base);
}
DEPRECATED inline float clamp2(float x, float a, float b) {
return clampSafe(x, a, b);
}

DEPRECATED inline int mini(int a, int b) {
return std::min(a, b);
}
DEPRECATED inline int maxi(int a, int b) {
return std::max(a, b);
}
DEPRECATED inline int clampi(int x, int min, int max) {
return math::clamp(x, min, max);
}
DEPRECATED inline int absi(int a) {
return std::fabs(a);
}
DEPRECATED inline int eucmodi(int a, int base) {
return eucMod(a, base);
}
DEPRECATED inline int log2i(int n) {
return math::log2(n);
}
DEPRECATED inline bool ispow2i(int n) {
return isPow2(n);
}
DEPRECATED inline float absf(float x) {
return std::fabs(x);
}
DEPRECATED inline float sgnf(float x) {
return sgn(x);
}
DEPRECATED inline float eucmodf(float a, float base) {
return eucMod(a, base);
}
DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) {
return math::isNear(a, b, epsilon);
}
DEPRECATED inline float clampf(float x, float min, float max) {
return math::clamp(x, min, max);
}
DEPRECATED inline float clamp2f(float x, float min, float max) {
return clampSafe(x, min, max);
}
DEPRECATED inline float chopf(float x, float eps) {
return chop(x, eps);
}
DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {
return math::rescale(x, a, b, yMin, yMax);
}
DEPRECATED inline float crossf(float a, float b, float frac) {
return crossfade(a, b, frac);
}
DEPRECATED inline float interpf(const float* p, float x) {
return interpolateLinear(p, x);
}
DEPRECATED inline void complexMult(float* cr, float* ci, float ar, float ai, float br, float bi) {
complexMult(ar, ai, br, bi, cr, ci);
}
DEPRECATED inline void cmultf(float* cr, float* ci, float ar, float ai, float br, float bi) {
return complexMult(ar, ai, br, bi, cr, ci);
}

////////////////////
// string
@@ -57,11 +113,21 @@ DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br
// random
////////////////////

DEPRECATED inline uint32_t randomu32() {return random::u32();}
DEPRECATED inline uint64_t randomu64() {return random::u64();}
DEPRECATED inline float randomUniform() {return random::uniform();}
DEPRECATED inline float randomNormal() {return random::normal();}
DEPRECATED inline float randomf() {return random::uniform();}
DEPRECATED inline uint32_t randomu32() {
return random::u32();
}
DEPRECATED inline uint64_t randomu64() {
return random::u64();
}
DEPRECATED inline float randomUniform() {
return random::uniform();
}
DEPRECATED inline float randomNormal() {
return random::normal();
}
DEPRECATED inline float randomf() {
return random::uniform();
}

////////////////////
// logger
@@ -77,23 +143,47 @@ DEPRECATED inline float randomf() {return random::uniform();}
// asset
////////////////////

DEPRECATED inline std::string assetGlobal(std::string filename) {return asset::system(filename);}
DEPRECATED inline std::string assetLocal(std::string filename) {return asset::user(filename);}
DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return asset::plugin(plugin, filename);}
DEPRECATED inline std::string assetGlobal(std::string filename) {
return asset::system(filename);
}
DEPRECATED inline std::string assetLocal(std::string filename) {
return asset::user(filename);
}
DEPRECATED inline std::string assetPlugin(Plugin* plugin, std::string filename) {
return asset::plugin(plugin, filename);
}

////////////////////
// color
////////////////////

DEPRECATED inline NVGcolor colorClip(NVGcolor a) {return color::clamp(a);}
DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {return color::minus(a, b);}
DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {return color::plus(a, b);}
DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) {return color::mult(a, b);}
DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) {return color::mult(a, x);}
DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {return color::screen(a, b);}
DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) {return color::alpha(a, alpha);}
DEPRECATED inline NVGcolor colorFromHexString(std::string s) {return color::fromHexString(s);}
DEPRECATED inline std::string colorToHexString(NVGcolor c) {return color::toHexString(c);}
DEPRECATED inline NVGcolor colorClip(NVGcolor a) {
return color::clamp(a);
}
DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {
return color::minus(a, b);
}
DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {
return color::plus(a, b);
}
DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) {
return color::mult(a, b);
}
DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) {
return color::mult(a, x);
}
DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {
return color::screen(a, b);
}
DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) {
return color::alpha(a, alpha);
}
DEPRECATED inline NVGcolor colorFromHexString(std::string s) {
return color::fromHexString(s);
}
DEPRECATED inline std::string colorToHexString(NVGcolor c) {
return color::toHexString(c);
}

////////////////////
// componentlibrary
@@ -118,14 +208,14 @@ DEPRECATED static const NVGcolor COLOR_DARK_PANEL = componentlibrary::SCHEME_DAR

/** Use createWidget() instead */
template <class TScrew>
DEPRECATED TScrew *createScrew(math::Vec pos) {
DEPRECATED TScrew* createScrew(math::Vec pos) {
return createWidget<TScrew>(pos);
}

/** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */
template <class TParamWidget>
DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
TParamWidget *o = createParam<TParamWidget>(pos, module, paramId);
DEPRECATED TParamWidget* createParam(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) {
TParamWidget* o = createParam<TParamWidget>(pos, module, paramId);
if (module) {
module->configParam(paramId, minValue, maxValue, defaultValue);
}
@@ -133,8 +223,8 @@ DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId,
}

template <class TParamWidget>
DEPRECATED TParamWidget *createParamCentered(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
TParamWidget *o = createParamCentered<TParamWidget>(pos, module, paramId);
DEPRECATED TParamWidget* createParamCentered(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) {
TParamWidget* o = createParamCentered<TParamWidget>(pos, module, paramId);
if (module) {
module->configParam(paramId, minValue, maxValue, defaultValue);
}
@@ -143,8 +233,8 @@ DEPRECATED TParamWidget *createParamCentered(math::Vec pos, Module *module, int

/** Use createInput() and createOutput() without the `type` variable */
template <class TPortWidget>
DEPRECATED TPortWidget *createPort(math::Vec pos, PortWidget::Type type, Module *module, int inputId) {
TPortWidget *o = new TPortWidget;
DEPRECATED TPortWidget* createPort(math::Vec pos, PortWidget::Type type, Module* module, int inputId) {
TPortWidget* o = new TPortWidget;
o->box.pos = pos;
o->type = type;
o->module = module;


+ 4
- 4
include/settings.hpp View File

@@ -41,10 +41,10 @@ extern bool skipLoadOnLaunch;
extern std::string patchPath;
extern std::vector<NVGcolor> cableColors;

json_t *toJson();
void fromJson(json_t *rootJ);
void save(const std::string &path);
void load(const std::string &path);
json_t* toJson();
void fromJson(json_t* rootJ);
void save(const std::string& path);
void load(const std::string& path);


} // namespace settings


+ 1
- 1
include/simd/sse_mathfun.h View File

@@ -374,7 +374,7 @@ inline __m128 sse_mathfun_cos_ps(__m128 x) { // any x

/* since sin_ps and cos_ps are almost identical, sincos_ps could replace both of them..
it is almost as fast, and gives you a free cosine with your sine */
inline void sse_mathfun_sincos_ps(__m128 x, __m128 *s, __m128 *c) {
inline void sse_mathfun_sincos_ps(__m128 x, __m128* s, __m128* c) {
__m128 xmm1, xmm2, xmm3 = _mm_setzero_ps(), sign_bit_sin, y;
__m128i emm0, emm2, emm4;
sign_bit_sin = x;


+ 37
- 29
include/simd/vector.hpp View File

@@ -63,13 +63,13 @@ struct Vector<float, 4> {

/** Returns a vector with all 1 bits. */
static Vector mask() {
return _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
return _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
}

/** Reads an array of 4 values.
On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`.
*/
static Vector load(const float *x) {
static Vector load(const float* x) {
/*
My benchmarks show that _mm_loadu_ps() performs equally as fast as _mm_load_ps() when data is actually aligned.
This post seems to agree. https://stackoverflow.com/a/20265193/272642
@@ -81,12 +81,16 @@ struct Vector<float, 4> {
/** Writes an array of 4 values.
On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`.
*/
void store(float *x) {
void store(float* x) {
_mm_storeu_ps(x, v);
}

float &operator[](int i) {return s[i];}
const float &operator[](int i) const {return s[i];}
float& operator[](int i) {
return s[i];
}
const float& operator[](int i) const {
return s[i];
}

// Conversions
Vector(Vector<int32_t, 4> a);
@@ -119,18 +123,22 @@ struct Vector<int32_t, 4> {
static Vector mask() {
return Vector(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
}
static Vector load(const int32_t *x) {
static Vector load(const int32_t* x) {
// HACK
// Use _mm_loadu_si128() because GCC doesn't support _mm_loadu_si32()
return Vector(_mm_loadu_si128((__m128i*) x));
}
void store(int32_t *x) {
void store(int32_t* x) {
// HACK
// Use _mm_storeu_si128() because GCC doesn't support _mm_storeu_si32()
_mm_storeu_si128((__m128i*) x, v);
}
int32_t &operator[](int i) {return s[i];}
const int32_t &operator[](int i) const {return s[i];}
int32_t& operator[](int i) {
return s[i];
}
const int32_t& operator[](int i) const {
return s[i];
}
Vector(Vector<float, 4> a);
static Vector cast(Vector<float, 4> a);
};
@@ -160,21 +168,21 @@ inline Vector<int32_t, 4> Vector<int32_t, 4>::cast(Vector<float, 4> a) {


/** `~a & b` */
inline Vector<float, 4> andnot(const Vector<float, 4> &a, const Vector<float, 4> &b) {
inline Vector<float, 4> andnot(const Vector<float, 4>& a, const Vector<float, 4>& b) {
return Vector<float, 4>(_mm_andnot_ps(a.v, b.v));
}

/** Returns an integer with each bit corresponding to the most significant bit of each element.
For example, `movemask(float_4::mask())` returns 0xf.
*/
inline int movemask(const Vector<float, 4> &a) {
inline int movemask(const Vector<float, 4>& a) {
return _mm_movemask_ps(a.v);
}

/** Returns an integer with each bit corresponding to the most significant bit of each byte.
For example, `movemask(int32_4::mask())` returns 0xffff.
*/
inline int movemask(const Vector<int32_t, 4> &a) {
inline int movemask(const Vector<int32_t, 4>& a) {
return _mm_movemask_epi8(a.v);
}

@@ -250,7 +258,7 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator==, _mm_cmpeq_ps)
DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator==, _mm_cmpeq_epi32)

DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator>=, _mm_cmpge_ps)
inline Vector<int32_t, 4> operator>=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) {
inline Vector<int32_t, 4> operator>=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) {
return Vector<int32_t, 4>(_mm_cmpgt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask();
}

@@ -258,7 +266,7 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator>, _mm_cmpgt_ps)
DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator>, _mm_cmpgt_epi32)

DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator<=, _mm_cmple_ps)
inline Vector<int32_t, 4> operator<=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) {
inline Vector<int32_t, 4> operator<=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) {
return Vector<int32_t, 4>(_mm_cmplt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask();
}

@@ -266,75 +274,75 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator<, _mm_cmplt_ps)
DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator<, _mm_cmplt_epi32)

DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator!=, _mm_cmpneq_ps)
inline Vector<int32_t, 4> operator!=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) {
inline Vector<int32_t, 4> operator!=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) {
return Vector<int32_t, 4>(_mm_cmpeq_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask();
}

/** `+a` */
inline Vector<float, 4> operator+(const Vector<float, 4> &a) {
inline Vector<float, 4> operator+(const Vector<float, 4>& a) {
return a;
}
inline Vector<int32_t, 4> operator+(const Vector<int32_t, 4> &a) {
inline Vector<int32_t, 4> operator+(const Vector<int32_t, 4>& a) {
return a;
}

/** `-a` */
inline Vector<float, 4> operator-(const Vector<float, 4> &a) {
inline Vector<float, 4> operator-(const Vector<float, 4>& a) {
return 0.f - a;
}
inline Vector<int32_t, 4> operator-(const Vector<int32_t, 4> &a) {
inline Vector<int32_t, 4> operator-(const Vector<int32_t, 4>& a) {
return 0 - a;
}

/** `++a` */
inline Vector<float, 4> &operator++(Vector<float, 4> &a) {
inline Vector<float, 4>& operator++(Vector<float, 4>& a) {
a += 1.f;
return a;
}
inline Vector<int32_t, 4> &operator++(Vector<int32_t, 4> &a) {
inline Vector<int32_t, 4>& operator++(Vector<int32_t, 4>& a) {
a += 1;
return a;
}

/** `--a` */
inline Vector<float, 4> &operator--(Vector<float, 4> &a) {
inline Vector<float, 4>& operator--(Vector<float, 4>& a) {
a -= 1.f;
return a;
}
inline Vector<int32_t, 4> &operator--(Vector<int32_t, 4> &a) {
inline Vector<int32_t, 4>& operator--(Vector<int32_t, 4>& a) {
a -= 1;
return a;
}

/** `a++` */
inline Vector<float, 4> operator++(Vector<float, 4> &a, int) {
inline Vector<float, 4> operator++(Vector<float, 4>& a, int) {
Vector<float, 4> b = a;
++a;
return b;
}
inline Vector<int32_t, 4> operator++(Vector<int32_t, 4> &a, int) {
inline Vector<int32_t, 4> operator++(Vector<int32_t, 4>& a, int) {
Vector<int32_t, 4> b = a;
++a;
return b;
}

/** `a--` */
inline Vector<float, 4> operator--(Vector<float, 4> &a, int) {
inline Vector<float, 4> operator--(Vector<float, 4>& a, int) {
Vector<float, 4> b = a;
--a;
return b;
}
inline Vector<int32_t, 4> operator--(Vector<int32_t, 4> &a, int) {
inline Vector<int32_t, 4> operator--(Vector<int32_t, 4>& a, int) {
Vector<int32_t, 4> b = a;
--a;
return b;
}

/** `~a` */
inline Vector<float, 4> operator~(const Vector<float, 4> &a) {
inline Vector<float, 4> operator~(const Vector<float, 4>& a) {
return a ^ Vector<float, 4>::mask();
}
inline Vector<int32_t, 4> operator~(const Vector<int32_t, 4> &a) {
inline Vector<int32_t, 4> operator~(const Vector<int32_t, 4>& a) {
return a ^ Vector<int32_t, 4>::mask();
}



+ 17
- 17
include/string.hpp View File

@@ -11,55 +11,55 @@ namespace string {


/** Converts a UTF-16/32 string (depending on the size of wchar_t) to a UTF-8 string. */
std::string fromWstring(const std::wstring &s);
std::wstring toWstring(const std::string &s);
std::string fromWstring(const std::wstring& s);
std::wstring toWstring(const std::string& s);
/** Converts a `printf()` format string and optional arguments into a std::string.
Remember that "%s" must reference a `char *`, so use `.c_str()` for `std::string`s, otherwise you might get binary garbage.
*/
std::string f(const char *format, ...);
std::string f(const char* format, ...);
/** Replaces all characters to lowercase letters */
std::string lowercase(const std::string &s);
std::string lowercase(const std::string& s);
/** Replaces all characters to uppercase letters */
std::string uppercase(const std::string &s);
std::string uppercase(const std::string& s);
/** Removes whitespace from beginning and end of string. */
std::string trim(const std::string &s);
std::string trim(const std::string& s);
/** Truncates and adds "..." to a string, not exceeding `len` characters */
std::string ellipsize(const std::string &s, size_t len);
std::string ellipsizePrefix(const std::string &s, size_t len);
bool startsWith(const std::string &str, const std::string &prefix);
bool endsWith(const std::string &str, const std::string &suffix);
std::string ellipsize(const std::string& s, size_t len);
std::string ellipsizePrefix(const std::string& s, size_t len);
bool startsWith(const std::string& str, const std::string& prefix);
bool endsWith(const std::string& str, const std::string& suffix);
/** Extracts the directory of the path.
Example: directory("dir/file.txt") // "dir"
Calls POSIX dirname().
*/
std::string directory(const std::string &path);
std::string directory(const std::string& path);
/** Extracts the filename of the path.
Example: directory("dir/file.txt") // "file.txt"
Calls POSIX basename().
*/
std::string filename(const std::string &path);
std::string filename(const std::string& path);
/** Extracts the portion of a filename without the extension.
Example: filenameBase("file.txt") // "file"
Note: Only works on filenames. Call filename(path) to get the filename of the path.
*/
std::string filenameBase(const std::string &filename);
std::string filenameBase(const std::string& filename);
/** Extracts the extension of a filename.
Example: filenameExtension("file.txt") // "txt"
Note: Only works on filenames. Call filename(path) to get the filename of the path.
*/
std::string filenameExtension(const std::string &filename);
std::string filenameExtension(const std::string& filename);
/** Returns the canonicalized absolute path pointed to by `path`, following symlinks.
Returns "" if the symbol is not found.
*/
std::string absolutePath(const std::string &path);
std::string absolutePath(const std::string& path);
/** Scores how well a query matches a string.
A score of 0 means no match.
The score is arbitrary and is only meaningful for sorting.
*/
float fuzzyScore(const std::string &s, const std::string &query);
float fuzzyScore(const std::string& s, const std::string& query);

struct CaseInsensitiveCompare {
bool operator()(const std::string &a, const std::string &b) const {
bool operator()(const std::string& a, const std::string& b) const {
return lowercase(a) < lowercase(b);
}
};


+ 1
- 1
include/svg.hpp View File

@@ -7,7 +7,7 @@
namespace rack {


void svgDraw(NVGcontext *vg, NSVGimage *svg);
void svgDraw(NVGcontext* vg, NSVGimage* svg);


} // namespace rack

+ 10
- 10
include/system.hpp View File

@@ -12,23 +12,23 @@ namespace system {


/** Returns a list of all entries (directories, files, symbols) in a directory. */
std::list<std::string> getEntries(const std::string &path);
std::list<std::string> getEntries(const std::string& path);
/** Returns whether the given path is a file. */
bool isFile(const std::string &path);
bool isFile(const std::string& path);
/** Returns whether the given path is a directory. */
bool isDirectory(const std::string &path);
bool isDirectory(const std::string& path);
/** Moves a file. */
void moveFile(const std::string &srcPath, const std::string &destPath);
void moveFile(const std::string& srcPath, const std::string& destPath);
/** Copies a file. */
void copyFile(const std::string &srcPath, const std::string &destPath);
void copyFile(const std::string& srcPath, const std::string& destPath);
/** Creates a directory.
The parent directory must exist.
*/
void createDirectory(const std::string &path);
void createDirectory(const std::string& path);
/** Returns the number of logical simultaneous multithreading (SMT) (e.g. Intel Hyperthreaded) threads on the CPU. */
int getLogicalCoreCount();
/** Sets a name of the current thread for debuggers and OS-specific process viewers. */
void setThreadName(const std::string &name);
void setThreadName(const std::string& name);
/** Sets the current thread to be high-priority. */
void setThreadRealTime(bool realTime);
/** Returns the caller's human-readable stack trace with "\n"-separated lines. */
@@ -37,13 +37,13 @@ std::string getStackTrace();
Shell injection is possible, so make sure the URL is trusted or hard coded.
May block, so open in a new thread.
*/
void openBrowser(const std::string &url);
void openBrowser(const std::string& url);
/** Opens Windows Explorer, Finder, etc at the folder location. */
void openFolder(const std::string &path);
void openFolder(const std::string& path);
/** Runs an executable without blocking.
The launched process will continue running if the current process is closed.
*/
void runProcessDetached(const std::string &path);
void runProcessDetached(const std::string& path);
std::string getOperatingSystemInfo();




+ 5
- 5
include/ui/Button.hpp View File

@@ -11,13 +11,13 @@ namespace ui {
struct Button : widget::OpaqueWidget {
std::string text;
/** Not owned. Tracks the pressed state of the button.*/
Quantity *quantity = NULL;
Quantity* quantity = NULL;

Button();
void draw(const DrawArgs &args) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
void draw(const DrawArgs& args) override;
void onDragStart(const event::DragStart& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDragDrop(const event::DragDrop& e) override;
};




+ 1
- 1
include/ui/ChoiceButton.hpp View File

@@ -8,7 +8,7 @@ namespace ui {


struct ChoiceButton : Button {
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 5
- 3
include/ui/IconButton.hpp View File

@@ -10,12 +10,14 @@ namespace ui {


struct IconButton : Button {
widget::FramebufferWidget *fw;
widget::SvgWidget *sw;
widget::FramebufferWidget* fw;
widget::SvgWidget* sw;

IconButton();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);}
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
setSvg(svg);
}
};




+ 1
- 1
include/ui/Label.hpp View File

@@ -20,7 +20,7 @@ struct Label : widget::Widget {
Alignment alignment = LEFT_ALIGNMENT;

Label();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 6
- 6
include/ui/Menu.hpp View File

@@ -9,17 +9,17 @@ namespace ui {


struct Menu : widget::OpaqueWidget {
Menu *parentMenu = NULL;
Menu *childMenu = NULL;
Menu* parentMenu = NULL;
Menu* childMenu = NULL;
/** The entry which created the child menu */
MenuEntry *activeEntry = NULL;
MenuEntry* activeEntry = NULL;

Menu();
~Menu();
void setChildMenu(Menu *menu);
void setChildMenu(Menu* menu);
void step() override;
void draw(const DrawArgs &args) override;
void onHoverScroll(const event::HoverScroll &e) override;
void draw(const DrawArgs& args) override;
void onHoverScroll(const event::HoverScroll& e) override;
};




+ 6
- 4
include/ui/MenuItem.hpp View File

@@ -15,12 +15,14 @@ struct MenuItem : MenuEntry {
bool disabled = false;
bool active = false;

void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
void step() override;
void onEnter(const event::Enter &e) override;
void onDragDrop(const event::DragDrop &e) override;
void onEnter(const event::Enter& e) override;
void onDragDrop(const event::DragDrop& e) override;
void doAction();
virtual Menu *createChildMenu() {return NULL;}
virtual Menu* createChildMenu() {
return NULL;
}
};




+ 1
- 1
include/ui/MenuLabel.hpp View File

@@ -10,7 +10,7 @@ namespace ui {
struct MenuLabel : MenuEntry {
std::string text;

void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
void step() override;
};



+ 2
- 2
include/ui/MenuOverlay.hpp View File

@@ -10,8 +10,8 @@ namespace ui {
/** Deletes itself from parent when clicked */
struct MenuOverlay : widget::OpaqueWidget {
void step() override;
void onButton(const event::Button &e) override;
void onHoverKey(const event::HoverKey &e) override;
void onButton(const event::Button& e) override;
void onHoverKey(const event::HoverKey& e) override;
};




+ 1
- 1
include/ui/MenuSeparator.hpp View File

@@ -9,7 +9,7 @@ namespace ui {

struct MenuSeparator : MenuEntry {
MenuSeparator();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 1
- 1
include/ui/PasswordField.hpp View File

@@ -8,7 +8,7 @@ namespace ui {


struct PasswordField : TextField {
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 2
- 2
include/ui/ProgressBar.hpp View File

@@ -10,10 +10,10 @@ namespace ui {

struct ProgressBar : widget::Widget {
/** Not owned. Stores the progress value and label. */
Quantity *quantity = NULL;
Quantity* quantity = NULL;

ProgressBar();
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 3
- 3
include/ui/RadioButton.hpp View File

@@ -12,11 +12,11 @@ namespace ui {

struct RadioButton : widget::OpaqueWidget {
/** Not owned. */
Quantity *quantity = NULL;
Quantity* quantity = NULL;

RadioButton();
void draw(const DrawArgs &args) override;
void onDragDrop(const event::DragDrop &e) override;
void draw(const DrawArgs& args) override;
void onDragDrop(const event::DragDrop& e) override;
};




+ 4
- 4
include/ui/ScrollBar.hpp View File

@@ -18,10 +18,10 @@ struct ScrollBar : widget::OpaqueWidget {
float size = 0.0;

ScrollBar();
void draw(const DrawArgs &args) override;
void onDragStart(const event::DragStart &e) override;
void onDragMove(const event::DragMove &e) override;
void onDragEnd(const event::DragEnd &e) override;
void draw(const DrawArgs& args) override;
void onDragStart(const event::DragStart& e) override;
void onDragMove(const event::DragMove& e) override;
void onDragEnd(const event::DragEnd& e) override;
};




+ 8
- 8
include/ui/ScrollWidget.hpp View File

@@ -10,19 +10,19 @@ namespace ui {

/** Handles a container with ScrollBar */
struct ScrollWidget : widget::OpaqueWidget {
widget::Widget *container;
ScrollBar *horizontalScrollBar;
ScrollBar *verticalScrollBar;
widget::Widget* container;
ScrollBar* horizontalScrollBar;
ScrollBar* verticalScrollBar;
math::Vec offset;

ScrollWidget();
void scrollTo(math::Rect r);
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
void step() override;
void onButton(const event::Button &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragMove(const event::DragMove &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
void onButton(const event::Button& e) override;
void onDragStart(const event::DragStart& e) override;
void onDragMove(const event::DragMove& e) override;
void onHoverScroll(const event::HoverScroll& e) override;
};




+ 6
- 6
include/ui/Slider.hpp View File

@@ -11,14 +11,14 @@ namespace ui {

struct Slider : widget::OpaqueWidget {
/** Not owned. */
Quantity *quantity = NULL;
Quantity* quantity = NULL;

Slider();
void draw(const DrawArgs &args) override;
void onDragStart(const event::DragStart &e) override;
void onDragMove(const event::DragMove &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDoubleClick(const event::DoubleClick &e) override;
void draw(const DrawArgs& args) override;
void onDragStart(const event::DragStart& e) override;
void onDragMove(const event::DragMove& e) override;
void onDragEnd(const event::DragEnd& e) override;
void onDoubleClick(const event::DoubleClick& e) override;
};




+ 5
- 5
include/ui/TextField.hpp View File

@@ -20,11 +20,11 @@ struct TextField : widget::OpaqueWidget {
int selection = 0;

TextField();
void draw(const DrawArgs &args) override;
void onDragHover(const event::DragHover &e) override;
void onButton(const event::Button &e) override;
void onSelectText(const event::SelectText &e) override;
void onSelectKey(const event::SelectKey &e) override;
void draw(const DrawArgs& args) override;
void onDragHover(const event::DragHover& e) override;
void onButton(const event::Button& e) override;
void onSelectText(const event::SelectText& e) override;
void onSelectKey(const event::SelectKey& e) override;

/** Inserts text at the cursor, replacing the selection if necessary */
void insertText(std::string text);


+ 1
- 1
include/ui/Tooltip.hpp View File

@@ -11,7 +11,7 @@ struct Tooltip : widget::Widget {
std::string text;

void step() override;
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 2
- 2
include/widget/FramebufferWidget.hpp View File

@@ -15,7 +15,7 @@ struct FramebufferWidget : Widget {
bool dirty = true;
bool bypass = false;
float oversample = 1.0;
NVGLUframebuffer *fb = NULL;
NVGLUframebuffer* fb = NULL;
/** Scale relative to the world */
math::Vec scale;
/** Offset in world coordinates */
@@ -34,7 +34,7 @@ struct FramebufferWidget : Widget {
FramebufferWidget();
~FramebufferWidget();
void step() override;
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
virtual void drawFramebuffer();
int getImageHandle();
};


+ 7
- 7
include/widget/OpaqueWidget.hpp View File

@@ -10,14 +10,14 @@ namespace widget {
Also consumes Hover and Button for left-clicks.
*/
struct OpaqueWidget : Widget {
void onHover(const event::Hover &e) override {
void onHover(const event::Hover& e) override {
Widget::onHover(e);
e.stopPropagating();
// Consume if not consumed by child
if (!e.isConsumed())
e.consume(this);
}
void onButton(const event::Button &e) override {
void onButton(const event::Button& e) override {
Widget::onButton(e);
e.stopPropagating();
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
@@ -26,26 +26,26 @@ struct OpaqueWidget : Widget {
e.consume(this);
}
}
void onHoverKey(const event::HoverKey &e) override {
void onHoverKey(const event::HoverKey& e) override {
Widget::onHoverKey(e);
e.stopPropagating();
}
void onHoverText(const event::HoverText &e) override {
void onHoverText(const event::HoverText& e) override {
Widget::onHoverText(e);
e.stopPropagating();
}
void onHoverScroll(const event::HoverScroll &e) override {
void onHoverScroll(const event::HoverScroll& e) override {
Widget::onHoverScroll(e);
e.stopPropagating();
}
void onDragHover(const event::DragHover &e) override {
void onDragHover(const event::DragHover& e) override {
Widget::onDragHover(e);
e.stopPropagating();
// Consume if not consumed by child
if (!e.isConsumed())
e.consume(this);
}
void onPathDrop(const event::PathDrop &e) override {
void onPathDrop(const event::PathDrop& e) override {
Widget::onPathDrop(e);
e.stopPropagating();
}


+ 4
- 2
include/widget/SvgWidget.hpp View File

@@ -16,9 +16,11 @@ struct SvgWidget : Widget {

/** Sets and wraps the SVG */
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);}
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
setSvg(svg);
}

void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;
};




+ 1
- 1
include/widget/TransformWidget.hpp View File

@@ -37,7 +37,7 @@ struct TransformWidget : Widget {
nvgTransformPremultiply(transform, t);
}

void draw(const DrawArgs &args) override {
void draw(const DrawArgs& args) override {
// No need to save the state because that is done in the parent
nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]);
Widget::draw(args);


+ 7
- 7
include/widget/TransparentWidget.hpp View File

@@ -9,13 +9,13 @@ namespace widget {
/** A Widget that does not respond to events and does not pass events to children */
struct TransparentWidget : Widget {
/** Override behavior to do nothing instead. */
void onHover(const event::Hover &e) override {}
void onButton(const event::Button &e) override {}
void onHoverKey(const event::HoverKey &e) override {}
void onHoverText(const event::HoverText &e) override {}
void onHoverScroll(const event::HoverScroll &e) override {}
void onDragHover(const event::DragHover &e) override {}
void onPathDrop(const event::PathDrop &e) override {}
void onHover(const event::Hover& e) override {}
void onButton(const event::Button& e) override {}
void onHoverKey(const event::HoverKey& e) override {}
void onHoverText(const event::HoverText& e) override {}
void onHoverScroll(const event::HoverScroll& e) override {}
void onDragHover(const event::DragHover& e) override {}
void onPathDrop(const event::PathDrop& e) override {}
};




+ 75
- 51
include/widget/Widget.hpp View File

@@ -23,7 +23,7 @@ struct Widget {
/** Stores position and size */
math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY));
/** Automatically set when Widget is added as a child to another Widget */
Widget *parent = NULL;
Widget* parent = NULL;
std::list<Widget*> children;
/** Disables rendering but allow stepping */
bool visible = true;
@@ -40,7 +40,7 @@ struct Widget {

virtual math::Rect getChildrenBoundingBox();
/** Returns `v` transformed into the coordinate system of `relative` */
virtual math::Vec getRelativeOffset(math::Vec v, Widget *relative);
virtual math::Vec getRelativeOffset(math::Vec v, Widget* relative);
/** Returns `v` transformed into world coordinates */
math::Vec getAbsoluteOffset(math::Vec v) {
return getRelativeOffset(v, NULL);
@@ -49,20 +49,24 @@ struct Widget {
virtual math::Rect getViewport(math::Rect r);

template <class T>
T *getAncestorOfType() {
if (!parent) return NULL;
T *p = dynamic_cast<T*>(parent);
if (p) return p;
T* getAncestorOfType() {
if (!parent)
return NULL;
T* p = dynamic_cast<T*>(parent);
if (p)
return p;
return parent->getAncestorOfType<T>();
}

template <class T>
T *getFirstDescendantOfType() {
for (Widget *child : children) {
T *c = dynamic_cast<T*>(child);
if (c) return c;
T* getFirstDescendantOfType() {
for (Widget* child : children) {
T* c = dynamic_cast<T*>(child);
if (c)
return c;
c = child->getFirstDescendantOfType<T>();
if (c) return c;
if (c)
return c;
}
return NULL;
}
@@ -70,12 +74,12 @@ struct Widget {
/** Adds widget to list of children.
Gives ownership of widget to this widget instance.
*/
void addChild(Widget *child);
void addChildBottom(Widget *child);
void addChild(Widget* child);
void addChildBottom(Widget* child);
/** Removes widget from list of children if it exists.
Does not delete widget but transfers ownership to caller
*/
void removeChild(Widget *child);
void removeChild(Widget* child);
/** Removes and deletes all children */
void clearChildren();

@@ -83,26 +87,26 @@ struct Widget {
virtual void step();

struct DrawArgs {
NVGcontext *vg;
NVGcontext* vg;
math::Rect clipBox;
NVGLUframebuffer *fb = NULL;
NVGLUframebuffer* fb = NULL;
};

/** Draws the widget to the NanoVG context */
virtual void draw(const DrawArgs &args);
virtual void draw(const DrawArgs& args);
/** Override draw(const DrawArgs &args) instead */
DEPRECATED virtual void draw(NVGcontext *vg) {}
DEPRECATED virtual void draw(NVGcontext* vg) {}

// Events

/** Recurses an event to all visible Widgets */
template <typename TMethod, class TEvent>
void recurseEvent(TMethod f, const TEvent &e) {
void recurseEvent(TMethod f, const TEvent& e) {
for (auto it = children.rbegin(); it != children.rend(); it++) {
// Stop propagation if requested
if (!e.isPropagating())
break;
Widget *child = *it;
Widget* child = *it;
// Filter child by visibility
if (!child->visible)
continue;
@@ -116,12 +120,12 @@ struct Widget {

/** Recurses an event to all visible Widgets until it is consumed. */
template <typename TMethod, class TEvent>
void recursePositionEvent(TMethod f, const TEvent &e) {
void recursePositionEvent(TMethod f, const TEvent& e) {
for (auto it = children.rbegin(); it != children.rend(); it++) {
// Stop propagation if requested
if (!e.isPropagating())
break;
Widget *child = *it;
Widget* child = *it;
// Filter child by visibility and position
if (!child->visible)
continue;
@@ -139,35 +143,55 @@ struct Widget {
/** Override these event callbacks to respond to events.
See event.hpp for a description of each event.
*/
virtual void onHover(const event::Hover &e) {recursePositionEvent(&Widget::onHover, e);}
virtual void onButton(const event::Button &e) {recursePositionEvent(&Widget::onButton, e);}
virtual void onDoubleClick(const event::DoubleClick &e) {}
virtual void onHoverKey(const event::HoverKey &e) {recursePositionEvent(&Widget::onHoverKey, e);}
virtual void onHoverText(const event::HoverText &e) {recursePositionEvent(&Widget::onHoverText, e);}
virtual void onHoverScroll(const event::HoverScroll &e) {recursePositionEvent(&Widget::onHoverScroll, e);}
virtual void onEnter(const event::Enter &e) {}
virtual void onLeave(const event::Leave &e) {}
virtual void onSelect(const event::Select &e) {}
virtual void onDeselect(const event::Deselect &e) {}
virtual void onSelectKey(const event::SelectKey &e) {}
virtual void onSelectText(const event::SelectText &e) {}
virtual void onDragStart(const event::DragStart &e) {}
virtual void onDragEnd(const event::DragEnd &e) {}
virtual void onDragMove(const event::DragMove &e) {}
virtual void onDragHover(const event::DragHover &e) {recursePositionEvent(&Widget::onDragHover, e);}
virtual void onDragEnter(const event::DragEnter &e) {}
virtual void onDragLeave(const event::DragLeave &e) {}
virtual void onDragDrop(const event::DragDrop &e) {}
virtual void onPathDrop(const event::PathDrop &e) {recursePositionEvent(&Widget::onPathDrop, e);}
virtual void onAction(const event::Action &e) {}
virtual void onChange(const event::Change &e) {}
virtual void onZoom(const event::Zoom &e) {recurseEvent(&Widget::onZoom, e);}
virtual void onReposition(const event::Reposition &e) {}
virtual void onResize(const event::Resize &e) {}
virtual void onAdd(const event::Add &e) {}
virtual void onRemove(const event::Remove &e) {}
virtual void onShow(const event::Show &e) {recurseEvent(&Widget::onShow, e);}
virtual void onHide(const event::Hide &e) {recurseEvent(&Widget::onHide, e);}
virtual void onHover(const event::Hover& e) {
recursePositionEvent(&Widget::onHover, e);
}
virtual void onButton(const event::Button& e) {
recursePositionEvent(&Widget::onButton, e);
}
virtual void onDoubleClick(const event::DoubleClick& e) {}
virtual void onHoverKey(const event::HoverKey& e) {
recursePositionEvent(&Widget::onHoverKey, e);
}
virtual void onHoverText(const event::HoverText& e) {
recursePositionEvent(&Widget::onHoverText, e);
}
virtual void onHoverScroll(const event::HoverScroll& e) {
recursePositionEvent(&Widget::onHoverScroll, e);
}
virtual void onEnter(const event::Enter& e) {}
virtual void onLeave(const event::Leave& e) {}
virtual void onSelect(const event::Select& e) {}
virtual void onDeselect(const event::Deselect& e) {}
virtual void onSelectKey(const event::SelectKey& e) {}
virtual void onSelectText(const event::SelectText& e) {}
virtual void onDragStart(const event::DragStart& e) {}
virtual void onDragEnd(const event::DragEnd& e) {}
virtual void onDragMove(const event::DragMove& e) {}
virtual void onDragHover(const event::DragHover& e) {
recursePositionEvent(&Widget::onDragHover, e);
}
virtual void onDragEnter(const event::DragEnter& e) {}
virtual void onDragLeave(const event::DragLeave& e) {}
virtual void onDragDrop(const event::DragDrop& e) {}
virtual void onPathDrop(const event::PathDrop& e) {
recursePositionEvent(&Widget::onPathDrop, e);
}
virtual void onAction(const event::Action& e) {}
virtual void onChange(const event::Change& e) {}
virtual void onZoom(const event::Zoom& e) {
recurseEvent(&Widget::onZoom, e);
}
virtual void onReposition(const event::Reposition& e) {}
virtual void onResize(const event::Resize& e) {}
virtual void onAdd(const event::Add& e) {}
virtual void onRemove(const event::Remove& e) {}
virtual void onShow(const event::Show& e) {
recurseEvent(&Widget::onShow, e);
}
virtual void onHide(const event::Hide& e) {
recurseEvent(&Widget::onHide, e);
}
};




+ 9
- 9
include/widget/ZoomWidget.hpp View File

@@ -10,42 +10,42 @@ namespace widget {
struct ZoomWidget : Widget {
float zoom = 1.f;

math::Vec getRelativeOffset(math::Vec v, Widget *relative) override;
math::Vec getRelativeOffset(math::Vec v, Widget* relative) override;
math::Rect getViewport(math::Rect r) override;
void setZoom(float zoom);
void draw(const DrawArgs &args) override;
void draw(const DrawArgs& args) override;

void onHover(const event::Hover &e) override {
void onHover(const event::Hover& e) override {
event::Hover e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHover(e2);
}
void onButton(const event::Button &e) override {
void onButton(const event::Button& e) override {
event::Button e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onButton(e2);
}
void onHoverKey(const event::HoverKey &e) override {
void onHoverKey(const event::HoverKey& e) override {
event::HoverKey e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverKey(e2);
}
void onHoverText(const event::HoverText &e) override {
void onHoverText(const event::HoverText& e) override {
event::HoverText e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverText(e2);
}
void onHoverScroll(const event::HoverScroll &e) override {
void onHoverScroll(const event::HoverScroll& e) override {
event::HoverScroll e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverScroll(e2);
}
void onDragHover(const event::DragHover &e) override {
void onDragHover(const event::DragHover& e) override {
event::DragHover e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onDragHover(e2);
}
void onPathDrop(const event::PathDrop &e) override {
void onPathDrop(const event::PathDrop& e) override {
event::PathDrop e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onPathDrop(e2);


+ 15
- 15
include/window.hpp View File

@@ -20,40 +20,40 @@ namespace rack {
// Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held.

struct Font {
NVGcontext *vg;
NVGcontext* vg;
int handle = -1;
/** Don't call this directly but instead use `APP->window->loadFont()` */
void loadFile(const std::string &filename, NVGcontext *vg);
void loadFile(const std::string& filename, NVGcontext* vg);
~Font();
/** Use `APP->window->loadFont()` instead. */
DEPRECATED static std::shared_ptr<Font> load(const std::string &filename);
DEPRECATED static std::shared_ptr<Font> load(const std::string& filename);
};

struct Image {
NVGcontext *vg;
NVGcontext* vg;
int handle = -1;
/** Don't call this directly but instead use `APP->window->loadImage()` */
void loadFile(const std::string &filename, NVGcontext *vg);
void loadFile(const std::string& filename, NVGcontext* vg);
~Image();
/** Use `APP->window->loadImage()` instead. */
DEPRECATED static std::shared_ptr<Image> load(const std::string &filename);
DEPRECATED static std::shared_ptr<Image> load(const std::string& filename);
};

struct Svg {
NSVGimage *handle = NULL;
NSVGimage* handle = NULL;
/** Don't call this directly but instead use `APP->window->loadSvg()` */
void loadFile(const std::string &filename);
void loadFile(const std::string& filename);
~Svg();
/** Use `APP->window->loadSvg()` instead. */
DEPRECATED static std::shared_ptr<Svg> load(const std::string &filename);
DEPRECATED static std::shared_ptr<Svg> load(const std::string& filename);
};

DEPRECATED typedef Svg SVG;


struct Window {
GLFWwindow *win = NULL;
NVGcontext *vg = NULL;
GLFWwindow* win = NULL;
NVGcontext* vg = NULL;
/** The scaling ratio */
float pixelRatio = 1.f;
/* The ratio between the framebuffer size and the window size reported by the OS.
@@ -72,7 +72,7 @@ struct Window {
std::map<std::string, std::weak_ptr<Svg>> svgCache;

struct Internal;
Internal *internal;
Internal* internal;

Window();
~Window();
@@ -90,9 +90,9 @@ struct Window {
bool isFullScreen();
bool isFrameOverdue();

std::shared_ptr<Font> loadFont(const std::string &filename);
std::shared_ptr<Image> loadImage(const std::string &filename);
std::shared_ptr<Svg> loadSvg(const std::string &filename);
std::shared_ptr<Font> loadFont(const std::string& filename);
std::shared_ptr<Image> loadImage(const std::string& filename);
std::shared_ptr<Svg> loadSvg(const std::string& filename);
};




+ 14
- 8
src/app.cpp View File

@@ -24,22 +24,28 @@ void App::init() {

App::~App() {
// Set pointers to NULL so other objects will segfault when attempting to access them
if (scene) delete scene;
if (scene)
delete scene;
scene = NULL;
if (patch) delete patch;
if (patch)
delete patch;
patch = NULL;
if (event) delete event;
if (event)
delete event;
event = NULL;
if (history) delete history;
if (history)
delete history;
history = NULL;
if (window) delete window;
if (window)
delete window;
window = NULL;
if (engine) delete engine;
if (engine)
delete engine;
engine = NULL;
}


static App *appInstance = NULL;
static App* appInstance = NULL;

void appInit() {
assert(!appInstance);
@@ -53,7 +59,7 @@ void appDestroy() {
appInstance = NULL;
}

App *appGet() {
App* appGet() {
return appInstance;
}



+ 30
- 30
src/app/AudioWidget.cpp View File

@@ -7,23 +7,23 @@ namespace app {


struct AudioDriverItem : ui::MenuItem {
audio::Port *port;
audio::Port* port;
int driverId;
void onAction(const event::Action &e) override {
void onAction(const event::Action& e) override {
port->setDriverId(driverId);
}
};

struct AudioDriverChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const event::Action &e) override {
audio::Port* port;
void onAction(const event::Action& e) override {
if (!port)
return;

ui::Menu *menu = createMenu();
ui::Menu* menu = createMenu();
menu->addChild(createMenuLabel("Audio driver"));
for (int driverId : port->getDriverIds()) {
AudioDriverItem *item = new AudioDriverItem;
AudioDriverItem* item = new AudioDriverItem;
item->port = port;
item->driverId = driverId;
item->text = port->getDriverName(driverId);
@@ -47,28 +47,28 @@ struct AudioDriverChoice : LedDisplayChoice {


struct AudioDeviceItem : ui::MenuItem {
audio::Port *port;
audio::Port* port;
int deviceId;
int offset;
void onAction(const event::Action &e) override {
void onAction(const event::Action& e) override {
port->setDeviceId(deviceId, offset);
}
};

struct AudioDeviceChoice : LedDisplayChoice {
audio::Port *port;
audio::Port* port;
/** Prevents devices with a ridiculous number of channels from being displayed */
int maxTotalChannels = 128;

void onAction(const event::Action &e) override {
void onAction(const event::Action& e) override {
if (!port)
return;

ui::Menu *menu = createMenu();
ui::Menu* menu = createMenu();
menu->addChild(createMenuLabel("Audio device"));
int deviceCount = port->getDeviceCount();
{
AudioDeviceItem *item = new AudioDeviceItem;
AudioDeviceItem* item = new AudioDeviceItem;
item->port = port;
item->deviceId = -1;
item->text = "(No device)";
@@ -78,7 +78,7 @@ struct AudioDeviceChoice : LedDisplayChoice {
for (int deviceId = 0; deviceId < deviceCount; deviceId++) {
int channels = std::min(maxTotalChannels, port->getDeviceChannels(deviceId));
for (int offset = 0; offset < channels; offset += port->maxChannels) {
AudioDeviceItem *item = new AudioDeviceItem;
AudioDeviceItem* item = new AudioDeviceItem;
item->port = port;
item->deviceId = deviceId;
item->offset = offset;
@@ -104,27 +104,27 @@ struct AudioDeviceChoice : LedDisplayChoice {


struct AudioSampleRateItem : ui::MenuItem {
audio::Port *port;
audio::Port* port;
int sampleRate;
void onAction(const event::Action &e) override {
void onAction(const event::Action& e) override {
port->setSampleRate(sampleRate);
}
};

struct AudioSampleRateChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const event::Action &e) override {
audio::Port* port;
void onAction(const event::Action& e) override {
if (!port)
return;

ui::Menu *menu = createMenu();
ui::Menu* menu = createMenu();
menu->addChild(createMenuLabel("Sample rate"));
std::vector<int> sampleRates = port->getSampleRates();
if (sampleRates.empty()) {
menu->addChild(createMenuLabel("(Locked by device)"));
}
for (int sampleRate : sampleRates) {
AudioSampleRateItem *item = new AudioSampleRateItem;
AudioSampleRateItem* item = new AudioSampleRateItem;
item->port = port;
item->sampleRate = sampleRate;
item->text = string::f("%g kHz", sampleRate / 1000.0);
@@ -145,27 +145,27 @@ struct AudioSampleRateChoice : LedDisplayChoice {


struct AudioBlockSizeItem : ui::MenuItem {
audio::Port *port;
audio::Port* port;
int blockSize;
void onAction(const event::Action &e) override {
void onAction(const event::Action& e) override {
port->setBlockSize(blockSize);
}
};

struct AudioBlockSizeChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const event::Action &e) override {
audio::Port* port;
void onAction(const event::Action& e) override {
if (!port)
return;

ui::Menu *menu = createMenu();
ui::Menu* menu = createMenu();
menu->addChild(createMenuLabel("Block size"));
std::vector<int> blockSizes = port->getBlockSizes();
if (blockSizes.empty()) {
menu->addChild(createMenuLabel("(Locked by device)"));
}
for (int blockSize : blockSizes) {
AudioBlockSizeItem *item = new AudioBlockSizeItem;
AudioBlockSizeItem* item = new AudioBlockSizeItem;
item->port = port;
item->blockSize = blockSize;
float latency = (float) blockSize / port->sampleRate * 1000.0;
@@ -186,12 +186,12 @@ struct AudioBlockSizeChoice : LedDisplayChoice {
};


void AudioWidget::setAudioPort(audio::Port *port) {
void AudioWidget::setAudioPort(audio::Port* port) {
clearChildren();

math::Vec pos;

AudioDriverChoice *driverChoice = createWidget<AudioDriverChoice>(pos);
AudioDriverChoice* driverChoice = createWidget<AudioDriverChoice>(pos);
driverChoice->box.size.x = box.size.x;
driverChoice->port = port;
addChild(driverChoice);
@@ -202,7 +202,7 @@ void AudioWidget::setAudioPort(audio::Port *port) {
this->driverSeparator->box.size.x = box.size.x;
addChild(this->driverSeparator);

AudioDeviceChoice *deviceChoice = createWidget<AudioDeviceChoice>(pos);
AudioDeviceChoice* deviceChoice = createWidget<AudioDeviceChoice>(pos);
deviceChoice->box.size.x = box.size.x;
deviceChoice->port = port;
addChild(deviceChoice);
@@ -213,7 +213,7 @@ void AudioWidget::setAudioPort(audio::Port *port) {
this->deviceSeparator->box.size.x = box.size.x;
addChild(this->deviceSeparator);

AudioSampleRateChoice *sampleRateChoice = createWidget<AudioSampleRateChoice>(pos);
AudioSampleRateChoice* sampleRateChoice = createWidget<AudioSampleRateChoice>(pos);
sampleRateChoice->box.size.x = box.size.x / 2;
sampleRateChoice->port = port;
addChild(sampleRateChoice);
@@ -224,7 +224,7 @@ void AudioWidget::setAudioPort(audio::Port *port) {
this->sampleRateSeparator->box.size.y = this->sampleRateChoice->box.size.y;
addChild(this->sampleRateSeparator);

AudioBlockSizeChoice *bufferSizeChoice = createWidget<AudioBlockSizeChoice>(pos);
AudioBlockSizeChoice* bufferSizeChoice = createWidget<AudioBlockSizeChoice>(pos);
bufferSizeChoice->box.pos.x = box.size.x / 2;
bufferSizeChoice->box.size.x = box.size.x / 2;
bufferSizeChoice->port = port;


+ 33
- 27
src/app/CableWidget.cpp View File

@@ -11,7 +11,7 @@
namespace rack {
namespace app {

static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) {
static void drawPlug(NVGcontext* vg, math::Vec pos, NVGcolor color) {
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5);

// Plug solid
@@ -32,7 +32,7 @@ static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) {
nvgFill(vg);
}

static void drawCable(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) {
static void drawCable(NVGcontext* vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) {
NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10);
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5);

@@ -44,7 +44,7 @@ static void drawCable(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor c

float dist = pos1.minus(pos2).norm();
math::Vec slump;
slump.y = (1.0 - tension) * (150.0 + 1.0*dist);
slump.y = (1.0 - tension) * (150.0 + 1.0 * dist);
math::Vec pos3 = pos1.plus(pos2).div(2).plus(slump);

// Adjust pos1 and pos2 to not draw over the plug
@@ -99,7 +99,7 @@ bool CableWidget::isComplete() {
return outputPort && inputPort;
}

void CableWidget::setOutput(PortWidget *outputPort) {
void CableWidget::setOutput(PortWidget* outputPort) {
this->outputPort = outputPort;
if (outputPort) {
assert(outputPort->type == PortWidget::OUTPUT);
@@ -108,7 +108,7 @@ void CableWidget::setOutput(PortWidget *outputPort) {
}
}

void CableWidget::setInput(PortWidget *inputPort) {
void CableWidget::setInput(PortWidget* inputPort) {
this->inputPort = inputPort;
if (inputPort) {
assert(inputPort->type == PortWidget::INPUT);
@@ -141,9 +141,9 @@ math::Vec CableWidget::getInputPos() {
}
}

json_t *CableWidget::toJson() {
json_t* CableWidget::toJson() {
assert(isComplete());
json_t *rootJ = json_object();
json_t* rootJ = json_object();

json_object_set_new(rootJ, "id", json_integer(cable->id));
json_object_set_new(rootJ, "outputModuleId", json_integer(cable->outputModule->id));
@@ -157,35 +157,41 @@ json_t *CableWidget::toJson() {
return rootJ;
}

void CableWidget::fromJson(json_t *rootJ) {
void CableWidget::fromJson(json_t* rootJ) {
// outputModuleId
json_t *outputModuleIdJ = json_object_get(rootJ, "outputModuleId");
if (!outputModuleIdJ) return;
json_t* outputModuleIdJ = json_object_get(rootJ, "outputModuleId");
if (!outputModuleIdJ)
return;
int outputModuleId = json_integer_value(outputModuleIdJ);
ModuleWidget *outputModule = APP->scene->rack->getModule(outputModuleId);
if (!outputModule) return;
ModuleWidget* outputModule = APP->scene->rack->getModule(outputModuleId);
if (!outputModule)
return;

// inputModuleId
json_t *inputModuleIdJ = json_object_get(rootJ, "inputModuleId");
if (!inputModuleIdJ) return;
json_t* inputModuleIdJ = json_object_get(rootJ, "inputModuleId");
if (!inputModuleIdJ)
return;
int inputModuleId = json_integer_value(inputModuleIdJ);
ModuleWidget *inputModule = APP->scene->rack->getModule(inputModuleId);
if (!inputModule) return;
ModuleWidget* inputModule = APP->scene->rack->getModule(inputModuleId);
if (!inputModule)
return;

// outputId
json_t *outputIdJ = json_object_get(rootJ, "outputId");
if (!outputIdJ) return;
json_t* outputIdJ = json_object_get(rootJ, "outputId");
if (!outputIdJ)
return;
int outputId = json_integer_value(outputIdJ);

// inputId
json_t *inputIdJ = json_object_get(rootJ, "inputId");
if (!inputIdJ) return;
json_t* inputIdJ = json_object_get(rootJ, "inputId");
if (!inputIdJ)
return;
int inputId = json_integer_value(inputIdJ);

// Only set ID if unset
if (cable->id < 0) {
// id
json_t *idJ = json_object_get(rootJ, "id");
json_t* idJ = json_object_get(rootJ, "id");
// Before 1.0, cables IDs were not used, so just leave it as default and Engine will assign one automatically.
if (idJ) {
cable->id = json_integer_value(idJ);
@@ -199,13 +205,13 @@ void CableWidget::fromJson(json_t *rootJ) {
setInput(inputModule->inputs[inputId]);
}
else {
for (PortWidget *port : outputModule->outputs) {
for (PortWidget* port : outputModule->outputs) {
if (port->portId == outputId) {
setOutput(port);
break;
}
}
for (PortWidget *port : inputModule->inputs) {
for (PortWidget* port : inputModule->inputs) {
if (port->portId == inputId) {
setInput(port);
break;
@@ -215,7 +221,7 @@ void CableWidget::fromJson(json_t *rootJ) {
if (!isComplete())
return;

json_t *colorJ = json_object_get(rootJ, "color");
json_t* colorJ = json_object_get(rootJ, "color");
if (colorJ) {
// v0.6.0 and earlier patches use JSON objects. Just ignore them if so and use the existing cable color.
if (json_is_string(colorJ))
@@ -223,13 +229,13 @@ void CableWidget::fromJson(json_t *rootJ) {
}
}

void CableWidget::draw(const DrawArgs &args) {
void CableWidget::draw(const DrawArgs& args) {
float opacity = settings::cableOpacity;
float tension = settings::cableTension;
float thickness = 5;

if (isComplete()) {
engine::Output *output = &cable->outputModule->outputs[cable->outputId];
engine::Output* output = &cable->outputModule->outputs[cable->outputId];
// Draw opaque if mouse is hovering over a connected port
if (output->channels > 1) {
// Increase thickness if output port is polyphonic
@@ -254,7 +260,7 @@ void CableWidget::draw(const DrawArgs &args) {
drawCable(args.vg, outputPos, inputPos, color, thickness, tension, opacity);
}

void CableWidget::drawPlugs(const DrawArgs &args) {
void CableWidget::drawPlugs(const DrawArgs& args) {
math::Vec outputPos = getOutputPos();
math::Vec inputPos = getInputPos();



+ 2
- 2
src/app/CircularShadow.cpp View File

@@ -10,12 +10,12 @@ CircularShadow::CircularShadow() {
opacity = 0.15;
}

void CircularShadow::draw(const DrawArgs &args) {
void CircularShadow::draw(const DrawArgs& args) {
if (opacity <= 0.0)
return;

nvgBeginPath(args.vg);
nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2*blurRadius, box.size.y + 2*blurRadius);
nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2 * blurRadius, box.size.y + 2 * blurRadius);
math::Vec center = box.size.div(2.0);
float radius = center.x;
NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity);


+ 6
- 6
src/app/Knob.cpp View File

@@ -12,7 +12,7 @@ namespace app {
static const float KNOB_SENSITIVITY = 0.0015f;


void Knob::onHover(const event::Hover &e) {
void Knob::onHover(const event::Hover& e) {
math::Vec c = box.size.div(2);
float dist = e.pos.minus(c).norm();
if (dist <= c.x) {
@@ -20,7 +20,7 @@ void Knob::onHover(const event::Hover &e) {
}
}

void Knob::onButton(const event::Button &e) {
void Knob::onButton(const event::Button& e) {
math::Vec c = box.size.div(2);
float dist = e.pos.minus(c).norm();
if (dist <= c.x) {
@@ -28,7 +28,7 @@ void Knob::onButton(const event::Button &e) {
}
}

void Knob::onDragStart(const event::DragStart &e) {
void Knob::onDragStart(const event::DragStart& e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

@@ -42,7 +42,7 @@ void Knob::onDragStart(const event::DragStart &e) {
APP->window->cursorLock();
}

void Knob::onDragEnd(const event::DragEnd &e) {
void Knob::onDragEnd(const event::DragEnd& e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

@@ -52,7 +52,7 @@ void Knob::onDragEnd(const event::DragEnd &e) {
float newValue = paramQuantity->getSmoothValue();
if (oldValue != newValue) {
// Push ParamChange history action
history::ParamChange *h = new history::ParamChange;
history::ParamChange* h = new history::ParamChange;
h->name = "move knob";
h->moduleId = paramQuantity->module->id;
h->paramId = paramQuantity->paramId;
@@ -63,7 +63,7 @@ void Knob::onDragEnd(const event::DragEnd &e) {
}
}

void Knob::onDragMove(const event::DragMove &e) {
void Knob::onDragMove(const event::DragMove& e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;



+ 9
- 9
src/app/LedDisplay.cpp View File

@@ -8,7 +8,7 @@ namespace rack {
namespace app {


void LedDisplay::draw(const DrawArgs &args) {
void LedDisplay::draw(const DrawArgs& args) {
nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5.0);
nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00));
@@ -24,7 +24,7 @@ LedDisplaySeparator::LedDisplaySeparator() {
box.size = math::Vec();
}

void LedDisplaySeparator::draw(const DrawArgs &args) {
void LedDisplaySeparator::draw(const DrawArgs& args) {
nvgBeginPath(args.vg);
nvgMoveTo(args.vg, 0, 0);
nvgLineTo(args.vg, box.size.x, box.size.y);
@@ -42,7 +42,7 @@ LedDisplayChoice::LedDisplayChoice() {
textOffset = math::Vec(10, 18);
}

void LedDisplayChoice::draw(const DrawArgs &args) {
void LedDisplayChoice::draw(const DrawArgs& args) {
nvgScissor(args.vg, RECT_ARGS(args.clipBox));
if (bgColor.a > 0.0) {
nvgBeginPath(args.vg);
@@ -62,7 +62,7 @@ void LedDisplayChoice::draw(const DrawArgs &args) {
nvgResetScissor(args.vg);
}

void LedDisplayChoice::onButton(const event::Button &e) {
void LedDisplayChoice::onButton(const event::Button& e) {
OpaqueWidget::onButton(e);

if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) {
@@ -80,7 +80,7 @@ LedDisplayTextField::LedDisplayTextField() {
}


void LedDisplayTextField::draw(const DrawArgs &args) {
void LedDisplayTextField::draw(const DrawArgs& args) {
nvgScissor(args.vg, RECT_ARGS(args.clipBox));

// Background
@@ -98,8 +98,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) {
int begin = std::min(cursor, selection);
int end = (this == APP->event->selectedWidget) ? std::max(cursor, selection) : -1;
bndIconLabelCaret(args.vg, textOffset.x, textOffset.y,
box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y,
-1, color, 12, text.c_str(), highlightColor, begin, end);
box.size.x - 2 * textOffset.x, box.size.y - 2 * textOffset.y,
-1, color, 12, text.c_str(), highlightColor, begin, end);

bndSetFont(APP->window->uiFont->handle);
}
@@ -110,8 +110,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) {
int LedDisplayTextField::getTextPosition(math::Vec mousePos) {
bndSetFont(font->handle);
int textPos = bndIconLabelTextPosition(APP->window->vg, textOffset.x, textOffset.y,
box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y,
-1, 12, text.c_str(), mousePos.x, mousePos.y);
box.size.x - 2 * textOffset.x, box.size.y - 2 * textOffset.y,
-1, 12, text.c_str(), mousePos.x, mousePos.y);
bndSetFont(APP->window->uiFont->handle);
return textPos;
}


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save