Browse Source

A few random changes from the last week

tags/v0.6.0
Andrew Belt 7 years ago
parent
commit
734d367a8a
7 changed files with 48 additions and 11 deletions
  1. +2
    -1
      include/app.hpp
  2. +10
    -0
      include/dsp/samplerate.hpp
  3. +1
    -1
      include/engine.hpp
  4. +1
    -1
      src/app/Knob.cpp
  5. +9
    -0
      src/app/RackRail.cpp
  6. +25
    -4
      src/app/RackWidget.cpp
  7. +0
    -4
      src/app/SVGSwitch.cpp

+ 2
- 1
include/app.hpp View File

@@ -199,6 +199,8 @@ struct ParamWidget : OpaqueWidget, QuantityWidget {
struct Knob : ParamWidget {
/** Snap to nearest integer while dragging */
bool snap = false;
/** Multiplier for mouse movement to adjust knob value */
float speed = 1.0;
float dragValue;
void onDragStart(EventDragStart &e) override;
void onDragMove(EventDragMove &e) override;
@@ -249,7 +251,6 @@ struct SVGSwitch : virtual Switch, FramebufferWidget {
SVGSwitch();
/** Adds an SVG file to represent the next switch position */
void addFrame(std::shared_ptr<SVG> svg);
void step() override;
void onChange(EventChange &e) override;
};



+ 10
- 0
include/dsp/samplerate.hpp View File

@@ -2,6 +2,7 @@

#include <assert.h>
#include <samplerate.h>
#include <string.h>
#include "frame.hpp"


@@ -33,6 +34,15 @@ struct SampleRateConverter {
}
/** `in` and `out` are interlaced with the number of channels */
void process(const Frame<CHANNELS> *in, int *inFrames, Frame<CHANNELS> *out, int *outFrames) {
/*
if (nearf(data.src_ratio, 1.0)) {
int len = mini(*inFrames, *outFrames);
memcpy(out, in, len * sizeof(Frame<CHANNELS>));
*inFrames = len;
*outFrames = len;
return;
}
*/
// Old versions of libsamplerate use float* here instead of const float*
data.data_in = (float*) in;
data.input_frames = *inFrames;


+ 1
- 1
include/engine.hpp View File

@@ -16,7 +16,7 @@ struct Light {
float value = 0.0;
float getBrightness();
void setBrightness(float brightness) {
value = brightness * brightness;
value = (brightness > 0.f) ? brightness * brightness : 0.f;
}
void setBrightnessSmooth(float brightness);
};


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

@@ -18,7 +18,7 @@ void Knob::onDragStart(EventDragStart &e) {

void Knob::onDragMove(EventDragMove &e) {
// Drag slower if Mod
float delta = KNOB_SENSITIVITY * (maxValue - minValue) * -e.mouseRel.y;
float delta = KNOB_SENSITIVITY * (maxValue - minValue) * -e.mouseRel.y * speed;
if (guiIsModPressed())
delta /= 16.0;
dragValue += delta;


+ 9
- 0
src/app/RackRail.cpp View File

@@ -46,6 +46,15 @@ void RackRail::draw(NVGcontext *vg) {
nvgLineTo(vg, box.size.x, railY + RACK_GRID_HEIGHT - 0.5);
nvgStroke(vg);
}


// Useful for screenshots
if (0) {
nvgBeginPath(vg);
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y);
nvgFillColor(vg, nvgRGBf(1.0, 1.0, 1.0));
nvgFill(vg);
}
}




+ 25
- 4
src/app/RackWidget.cpp View File

@@ -38,6 +38,25 @@ void RackWidget::clear() {
wireContainer->clearChildren();
moduleContainer->clearChildren();
lastPath = "";

/*
// Add all modules to rack
Vec pos;
for (Plugin *plugin : gPlugins) {
for (Model *model : plugin->models) {
ModuleWidget *moduleWidget = model->createModuleWidget();
moduleContainer->addChild(moduleWidget);
// Move module nearest to the mouse position
Rect box;
box.size = moduleWidget->box.size;
box.pos = pos;
requestModuleBoxNearest(moduleWidget, box);
pos.x += box.size.x;
}
pos.y += RACK_GRID_HEIGHT;
pos.x = 0;
}
*/
}

void RackWidget::reset() {
@@ -127,8 +146,10 @@ json_t *RackWidget::toJson() {
json_t *rootJ = json_object();

// version
json_t *versionJ = json_string(gApplicationVersion.c_str());
json_object_set_new(rootJ, "version", versionJ);
if (!gApplicationVersion.empty()) {
json_t *versionJ = json_string(gApplicationVersion.c_str());
json_object_set_new(rootJ, "version", versionJ);
}

// modules
json_t *modulesJ = json_array();
@@ -323,8 +344,8 @@ bool RackWidget::requestModuleBoxNearest(ModuleWidget *m, Rect box) {
int x0 = roundf(box.pos.x / RACK_GRID_WIDTH);
int y0 = roundf(box.pos.y / RACK_GRID_HEIGHT);
std::vector<Vec> positions;
for (int y = maxi(0, y0 - 4); y < y0 + 4; y++) {
for (int x = maxi(0, x0 - 200); x < x0 + 200; x++) {
for (int y = maxi(0, y0 - 8); y < y0 + 8; y++) {
for (int x = maxi(0, x0 - 400); x < x0 + 400; x++) {
positions.push_back(Vec(x * RACK_GRID_WIDTH, y * RACK_GRID_HEIGHT));
}
}


+ 0
- 4
src/app/SVGSwitch.cpp View File

@@ -18,10 +18,6 @@ void SVGSwitch::addFrame(std::shared_ptr<SVG> svg) {
}
}

void SVGSwitch::step() {
FramebufferWidget::step();
}

void SVGSwitch::onChange(EventChange &e) {
assert(frames.size() > 0);
float valueScaled = rescalef(value, minValue, maxValue, 0, frames.size() - 1);


Loading…
Cancel
Save