Skip to content

Commit

Permalink
moving to github
Browse files Browse the repository at this point in the history
  • Loading branch information
felixh committed Jun 13, 2024
1 parent 4e69736 commit 63fda90
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/build
/dist
/plugin.so
/plugin.dylib
/plugin.dll
.DS_Store
*swp
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# If RACK_DIR is not defined when calling the Makefile, default to two directories above
RACK_DIR ?= ../..

# FLAGS will be passed to both the C and C++ compiler
FLAGS +=
CFLAGS +=
CXXFLAGS +=

# Careful about linking to shared libraries, since you can't assume much about the user's environment and library search path.
# Static libraries are fine, but they should be added to this plugin's build system.
LDFLAGS +=

# Add .cpp files to the build
SOURCES += $(wildcard src/*.cpp)

# Add files to the ZIP package when running `make dist`
# The compiled plugin and "plugin.json" are automatically added.
DISTRIBUTABLES += res
DISTRIBUTABLES += $(wildcard LICENSE*)
DISTRIBUTABLES += $(wildcard presets)

# Include the Rack plugin Makefile framework
include $(RACK_DIR)/plugin.mk
23 changes: 23 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"slug": "Quarks-additive",
"name": "additive",
"version": "2.0.0",
"license": "Apache-2.0",
"brand": "Quarks",
"author": "Felixh",
"authorEmail": "",
"authorUrl": "",
"pluginUrl": "",
"manualUrl": "",
"sourceUrl": "",
"donateUrl": "",
"changelogUrl": "",
"modules": [
{
"slug": "additive",
"name": "additive",
"description": "Change output voltage in set amounts",
"tags": ["seq"]
}
]
}
228 changes: 228 additions & 0 deletions res/additive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions src/additive.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#include "plugin.hpp"


struct Additive : Module {
enum ParamId {
PARAMS_LEN
};
enum InputId {
PATH118_INPUT,
PATH120_INPUT,
CLKIN_INPUT,
NEG1_INPUT,
NEG5_INPUT,
INPUTS_LEN
};
enum OutputId {
PATH116_OUTPUT,
OUTPUTS_LEN
};
enum LightId {
LIGHTS_LEN
};

Additive() {
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
configInput(PATH118_INPUT, "");
configInput(PATH120_INPUT, "");
configInput(CLKIN_INPUT, "");
configOutput(PATH116_OUTPUT, "");
}
float pitch =1.f;
float clock = 0.f;
float top = 1.f;
float bottom = -1.f;
float value = 0.f;
float debug = 0.f;
//
bool onest = 1;
bool fivest = 1;
bool negonest = 1;
bool negfivest = 1;
int notecount = 0;
int major[7] = {0,2,4,5,7,9,11};


void process(const ProcessArgs& args) override {

float clock_value = inputs[CLKIN_INPUT].getVoltage();
value = inputs[PATH118_INPUT].getVoltage();
/* if (value != debug){ */
/* debug = value; */
/* DEBUG("outside +1 %f", value); */
/* } */
if ( clock_value > 0.5){
// rising voltage
// set high so we dont process again this clock cycle
clock = clock_value;
// do work

value = inputs[PATH118_INPUT].getVoltage();
if (onest and value > 0.f) {
/* DEBUG("+1 %f", value); */
pitch = pitch + 1.f/12;
notecount += 1;
onest = false;
}
value = inputs[PATH120_INPUT].getVoltage();
if (fivest and value > 0.f) {
/* DEBUG("+5 %f", value); */
pitch = pitch + 5.f/12;
notecount += 5;
fivest = false;
}
value = inputs[NEG1_INPUT].getVoltage();
if (negonest and value > 0.f) {
pitch = pitch - 1.f/12;
notecount -= 1;
negonest = false;
}
value = inputs[NEG5_INPUT].getVoltage();
if (negfivest and value > 0.f) {
pitch = pitch - 1.f/12;
notecount -= 5;
negfivest = false;
}

float foo = (int)notecount/7 + (major[(80 + notecount)%7] * 1.f/12);
if (debug) {
DEBUG("count %i oct %i mod %i st %i", notecount, (int)notecount/7, notecount %7, major[(80+ notecount)%7]);
DEBUG("%f" ,foo);
debug = 0;
}

if (pitch > top) {
pitch = pitch - (top - bottom);
}
if (pitch < bottom) {
pitch = pitch + (top - bottom);
}
outputs[PATH116_OUTPUT].setVoltage(pitch);

}
if ( clock_value < 0.5 ){
// falling voltage
/* DEBUG("reseting"); */
clock = 0;
onest = true;
fivest = true;
negonest = true;
negfivest = true;
debug = true;
}

}
};


struct AdditiveWidget : ModuleWidget {
AdditiveWidget(Additive* module) {
setModule(module);
setPanel(createPanel(asset::plugin(pluginInstance, "res/additive.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

addInput(createInputCentered<PJ301MPort>(mm2px(Vec(10.598, 29.168)), module, Additive::PATH118_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(10.598, 39.267)), module, Additive::PATH120_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(10.598, 69.25)), module, Additive::CLKIN_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(10.598, 48.819)), module, Additive::NEG1_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(10.598, 58.932)), module, Additive::NEG5_INPUT));

addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(10.598, 18.065)), module, Additive::PATH116_OUTPUT));
}
};


Model* modelAdditive = createModel<Additive, AdditiveWidget>("additive");
15 changes: 15 additions & 0 deletions src/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "plugin.hpp"


Plugin* pluginInstance;


void init(Plugin* p) {
pluginInstance = p;

// Add modules here
p->addModel(modelAdditive);

// Any other plugin initialization may go here.
// As an alternative, consider lazy-loading assets and lookup tables when your module is created to reduce startup times of Rack.
}
11 changes: 11 additions & 0 deletions src/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <rack.hpp>


using namespace rack;

// Declare the Plugin, defined in plugin.cpp
extern Plugin* pluginInstance;

// Declare each Model, defined in each module source file
extern Model* modelAdditive;

0 comments on commit 63fda90

Please sign in to comment.