@@ -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(); | |||
@@ -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() | |||
@@ -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); | |||
}; | |||
@@ -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); | |||
}; | |||
@@ -12,7 +12,7 @@ struct CircularShadow : widget::TransparentWidget { | |||
float opacity; | |||
CircularShadow(); | |||
void draw(const DrawArgs &args) override; | |||
void draw(const DrawArgs& args) override; | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -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); | |||
}; | |||
@@ -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 | |||
@@ -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); | |||
}; | |||
@@ -7,7 +7,7 @@ namespace rack { | |||
namespace app { | |||
widget::Widget *moduleBrowserCreate(); | |||
widget::Widget* moduleBrowserCreate(); | |||
} // namespace app | |||
@@ -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; | |||
@@ -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) {} | |||
}; | |||
@@ -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); | |||
}; | |||
@@ -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() {} | |||
@@ -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; | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -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(); | |||
}; | |||
@@ -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); | |||
}; | |||
@@ -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(); | |||
}; | |||
@@ -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); | |||
} | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -11,7 +11,7 @@ namespace app { | |||
struct PanelBorder : widget::TransparentWidget { | |||
void draw(const DrawArgs &args) override; | |||
void draw(const DrawArgs& args) override; | |||
}; | |||
@@ -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); | |||
} | |||
}; | |||
@@ -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); | |||
@@ -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); | |||
@@ -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; | |||
}; | |||
@@ -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; | |||
}; | |||
@@ -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 | |||
@@ -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); | |||
}; | |||
@@ -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 |
@@ -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) {} | |||
}; | |||
@@ -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"))); | |||
} | |||
}; | |||
@@ -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> | |||
@@ -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; | |||
} | |||
} | |||
}; | |||
@@ -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]; | |||
@@ -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; | |||
@@ -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,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 | |||
@@ -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) { | |||
@@ -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)); | |||
} | |||
@@ -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; | |||
}; | |||
@@ -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,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 = ¶ms[paramId]; | |||
Param* p = ¶ms[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) {} | |||
}; | |||
@@ -16,7 +16,7 @@ struct ParamHandle { | |||
*/ | |||
int moduleId = -1; | |||
int paramId = 0; | |||
Module *module = NULL; | |||
Module* module = NULL; | |||
std::string text; | |||
NVGcolor color; | |||
@@ -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(); | |||
@@ -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> | |||
@@ -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; | |||
}; | |||