Skip to content

Commit

Permalink
Updating to rack 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adbrant committed Nov 25, 2017
1 parent 254f4a7 commit 8dcbe01
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 68 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VERSION ?= v0.5.0

FLAGS += \
-fshort-enums -DTEST \
-DTEST \
-I./eurorack \
-Wno-unused-local-typedefs

Expand Down
6 changes: 4 additions & 2 deletions Makefile.parasite
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

VERSION ?= v0.5.0

FLAGS += \
-fshort-enums -DTEST -DPARASITES \
-DTEST -DPARASITES \
-I./parasites \
-Wno-unused-local-typedefs
-Wno-unused-local-typedefs


SOURCES = $(wildcard src/*.cpp) \
Expand Down
21 changes: 14 additions & 7 deletions src/AudibleInstruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ void init(rack::Plugin *p) {
plugin = p;
#ifdef PARASITES
plugin->slug = "ParableInstruments";
plugin->name = "Parable Instruments";
plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";
//plugin->name = "Parable Instruments";
//plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";

createModel<CloudsWidget>(plugin, "Neil", "Neil - Texture Synthesizer");
//createModel<CloudsWidget>(plugin, "Neil", "Neil - Texture Synthesizer");
#ifdef VERSION
p->version = TOSTRING(VERSION);
#endif
p->addModel(createModel<CloudsWidget>("Arable Instruments", "Neil", "Neil - Texture Synthesizer",GRANULAR_TAG, REVERB_TAG));
#else
plugin->slug = "ArableInstruments";
plugin->name = "Arable Instruments";
plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";
p->slug = "ArableInstruments";
//plugin->name = "Arable Instruments";
//plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";

createModel<CloudsWidget>(plugin, "Joni", "Joni - Texture Synthesizer");
#ifdef VERSION
p->version = TOSTRING(VERSION);
#endif
p->addModel(createModel<CloudsWidget>("Arable Instruments", "Joni", "Joni - Texture Synthesizer",GRANULAR_TAG, REVERB_TAG));
#endif
}
24 changes: 24 additions & 0 deletions src/AudibleInstruments.cpp.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "AudibleInstruments.hpp"


Plugin *plugin;

void init(rack::Plugin *p) {
plugin = p;
#ifdef PARASITES
plugin->slug = "ParableInstruments";
//plugin->name = "Parable Instruments";
//plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";

//createModel<CloudsWidget>(plugin, "Neil", "Neil - Texture Synthesizer");
#else
p->slug = "ArableInstruments";
//plugin->name = "Arable Instruments";
//plugin->homepageUrl = "https://github.com/adbrant/ArableInstruments";

#ifdef VERSION
p->version = TOSTRING(VERSION);
#endif
p->addModel(createModel<CloudsWidget>("Arable Instruments", "Joni", "Joni - Texture Synthesizer",GRANULAR_TAG, REVERB_TAG);
#endif
}
131 changes: 73 additions & 58 deletions src/Clouds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include "dsp/samplerate.hpp"
#include "dsp/ringbuffer.hpp"
#include "dsp/digital.hpp"
#include "dsp/vumeter.hpp"
#include "clouds/dsp/granular_processor.h"



struct Clouds : Module {
enum ParamIds {
Expand Down Expand Up @@ -45,16 +46,23 @@ struct Clouds : Module {
OUT_R_OUTPUT,
NUM_OUTPUTS
};
enum LightIds {
FREEZE_LIGHT,
#ifdef PARASITES
REVERSE_LIGHT,
#endif
NUM_LIGHTS
};

SampleRateConverter<2> inputSrc;
SampleRateConverter<2> outputSrc;
DoubleRingBuffer<Frame<2>, 256> inputBuffer;
DoubleRingBuffer<Frame<2>, 256> outputBuffer;

clouds::PlaybackMode playbackmode = clouds::PLAYBACK_MODE_GRANULAR;


int buffersize = 1;


int buffersize = 1;
int currentbuffersize = 1;
bool lofi = false;
bool mono = false;
Expand Down Expand Up @@ -83,7 +91,7 @@ struct Clouds : Module {
json_object_set_new(rootJ, "playbackmode", json_integer(playbackmode));
json_object_set_new(rootJ, "lofi", json_integer(lofi));
json_object_set_new(rootJ, "mono", json_integer(mono));
json_object_set_new(rootJ, "freeze", json_integer(freeze));
json_object_set_new(rootJ, "freeze", json_integer(freeze));
json_object_set_new(rootJ, "buffersize", json_integer(buffersize));
#ifdef PARASITES
json_object_set_new(rootJ, "reverse", json_integer(reverse));
Expand All @@ -107,10 +115,10 @@ struct Clouds : Module {
json_t *freezeJ = json_object_get(rootJ, "freeze");
if (freezeJ) {
freeze = json_integer_value(freezeJ);
}
json_t *buffersizeJ = json_object_get(rootJ, "buffersize");
if (buffersizeJ) {
buffersize = json_integer_value(buffersizeJ);
}
json_t *buffersizeJ = json_object_get(rootJ, "buffersize");
if (buffersizeJ) {
buffersize = json_integer_value(buffersizeJ);
}
#ifdef PARASITES
json_t *reverseJ = json_object_get(rootJ, "reverse");
Expand All @@ -123,7 +131,7 @@ struct Clouds : Module {
};


Clouds::Clouds() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {
Clouds::Clouds() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
const int memLen = 118784;
const int ccmLen = 65536 - 128;
block_mem = new uint8_t[memLen]();
Expand Down Expand Up @@ -163,7 +171,7 @@ void Clouds::step() {
clouds::ShortFrame input[32] = {};
// Convert input buffer
{
inputSrc.setRatio(32000.0 / gSampleRate);
inputSrc.setRatio(32000.0 / engineGetSampleRate());
Frame<2> inputFrames[32];
int inLen = inputBuffer.size();
int outLen = 32;
Expand All @@ -175,18 +183,18 @@ void Clouds::step() {
input[i].l = clampf(inputFrames[i].samples[0] * 32767.0, -32768, 32767);
input[i].r = clampf(inputFrames[i].samples[1] * 32767.0, -32768, 32767);
}
}
if(currentbuffersize != buffersize){
//re-init processor with new size
delete processor;
delete[] block_mem;
int memLen = 118784*buffersize;
const int ccmLen = 65536 - 128;
block_mem = new uint8_t[memLen]();
processor = new clouds::GranularProcessor();
memset(processor, 0, sizeof(*processor));
processor->Init(block_mem, memLen, block_ccm, ccmLen);
currentbuffersize = buffersize;
}
if(currentbuffersize != buffersize){
//re-init processor with new size
delete processor;
delete[] block_mem;
int memLen = 118784*buffersize;
const int ccmLen = 65536 - 128;
block_mem = new uint8_t[memLen]();
processor = new clouds::GranularProcessor();
memset(processor, 0, sizeof(*processor));
processor->Init(block_mem, memLen, block_ccm, ccmLen);
currentbuffersize = buffersize;
}

// Set up processor
Expand Down Expand Up @@ -223,13 +231,13 @@ void Clouds::step() {
reverse = !reverse;
}
p->granular.reverse = reverse;
reverseLight = p->granular.reverse ? 1.0 : 0.0;
lights[REVERSE_LIGHT].setBrightness(p->granular.reverse ? 1.0 : 0.0);
#endif

clouds::ShortFrame output[32];
processor->Process(input, output, 32);

freezeLight = p->freeze ? 1.0 : 0.0;
lights[FREEZE_LIGHT].setBrightness(p->freeze ? 1.0 : 0.0);

// Convert output buffer
{
Expand All @@ -239,7 +247,7 @@ void Clouds::step() {
outputFrames[i].samples[1] = output[i].r / 32768.0;
}

outputSrc.setRatio(gSampleRate / 32000.0);
outputSrc.setRatio( engineGetSampleRate() / 32000.0);
int inLen = 32;
int outLen = outputBuffer.capacity();
outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen);
Expand All @@ -266,12 +274,12 @@ CloudsWidget::CloudsWidget() {
box.size = Vec(15*18+67*3-6, 380);

{
Panel *panel = new LightPanel();
Panel *panel = new LightPanel();
#ifdef PARASITES
panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Neil.png"));
#else
panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Joni.png"));
#endif
panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Neil.png"));
#else
panel->backgroundImage = Image::load(assetPlugin(plugin, "res/Joni.png"));
#endif

panel->box.size = box.size;
addChild(panel);
Expand Down Expand Up @@ -316,11 +324,18 @@ CloudsWidget::CloudsWidget() {
addInput(createInput<PJ3410Port>(Vec(214+67*2, 291), module, Clouds::FEEDBACK_INPUT));
addInput(createInput<PJ3410Port>(Vec(214+67*3, 291), module, Clouds::REVERB_INPUT));

struct FreezeLight : GreenLight {
FreezeLight() {
box.size = Vec(28-16, 28-16);
bgColor = COLOR_BLACK_TRANSPARENT;
}
};

addParam(createParam<LEDButton>(Vec(68, 52-1), module, Clouds::FREEZE_PARAM, 0.0, 1.0, 0.0));
addChild(createValueLight<SmallLight<GreenValueLight>>(Vec(68+5, 52+4), &module->freezeLight));
addChild(createLight<FreezeLight>(Vec(68+3, 52-1+3), module,Clouds::FREEZE_LIGHT));
#ifdef PARASITES
addParam(createParam<LEDButton>(Vec(68-15, 52-1-25), module, Clouds::REVERSE_PARAM, 0.0, 1.0, 0.0));
addChild(createValueLight<SmallLight<GreenValueLight>>(Vec(68+5-15, 52+4-25), &module->reverseLight));
addChild(createLight<FreezeLight>(Vec(68+3-15, 52-1+3-25), module, Clouds::REVERSE_LIGHT));
#endif


Expand All @@ -330,7 +345,7 @@ struct CloudsModeItem : MenuItem {
Clouds *clouds;
clouds::PlaybackMode mode;

void onAction() override {
void onAction(EventAction &e) override {
clouds->playbackmode = mode;
}
void step() override {
Expand All @@ -343,7 +358,7 @@ struct CloudsMonoItem : MenuItem {
Clouds *clouds;
bool setting;

void onAction() override {
void onAction(EventAction &e) override {
clouds->mono = setting;
}
void step() override {
Expand All @@ -356,25 +371,25 @@ struct CloudsLofiItem : MenuItem {
Clouds *clouds;
bool setting;

void onAction() override {
void onAction(EventAction &e) override {
clouds->lofi = setting;
}
void step() override {
rightText = (clouds->lofi == setting) ? "" : "";
}
};


struct CloudsBufferItem : MenuItem {
Clouds *clouds;
int setting;

void onAction() override {
clouds->buffersize = setting;
}
void step() override {
rightText = (clouds->buffersize == setting) ? "" : "";
}
};


struct CloudsBufferItem : MenuItem {
Clouds *clouds;
int setting;

void onAction(EventAction &e) override {
clouds->buffersize = setting;
}
void step() override {
rightText = (clouds->buffersize == setting) ? "" : "";
}
};

Menu *CloudsWidget::createContextMenu() {
Expand All @@ -400,16 +415,16 @@ Menu *CloudsWidget::createContextMenu() {

menu->pushChild(construct<MenuLabel>(&MenuEntry::text, "HIFI/LOFI"));
menu->pushChild(construct<CloudsLofiItem>(&MenuEntry::text, "HIFI", &CloudsLofiItem::clouds, clouds, &CloudsLofiItem::setting, false));
menu->pushChild(construct<CloudsLofiItem>(&MenuEntry::text, "LOFI", &CloudsLofiItem::clouds, clouds, &CloudsLofiItem::setting, true));

#ifdef BUFFERRESIZING
// disable by default as it seems to make alternative modes unstable
menu->pushChild(construct<MenuLabel>(&MenuEntry::text, "BUFFER SIZE (EXPERIMENTAL)"));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "ORIGINAL", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 1));
menu->pushChild(construct<CloudsLofiItem>(&MenuEntry::text, "LOFI", &CloudsLofiItem::clouds, clouds, &CloudsLofiItem::setting, true));

#ifdef BUFFERRESIZING
// disable by default as it seems to make alternative modes unstable
menu->pushChild(construct<MenuLabel>(&MenuEntry::text, "BUFFER SIZE (EXPERIMENTAL)"));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "ORIGINAL", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 1));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "2X", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 2));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "4X", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 4));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "8X", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 8));
#endif
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "4X", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 4));
menu->pushChild(construct<CloudsBufferItem>(&MenuEntry::text, "8X", &CloudsBufferItem::clouds, clouds, &CloudsBufferItem::setting, 8));
#endif

return menu;
}
Expand Down
Loading

0 comments on commit 8dcbe01

Please sign in to comment.