Browse Source

Store/modify internal state of SEQ3

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
f87b7afaaf
4 changed files with 49 additions and 17 deletions
  1. +0
    -10
      src/Fundamental.cpp
  2. +2
    -4
      src/Fundamental.hpp
  3. +33
    -0
      src/SEQ3.cpp
  4. +14
    -3
      src/VCO.cpp

+ 0
- 10
src/Fundamental.cpp
File diff suppressed because it is too large
View File


+ 2
- 4
src/Fundamental.hpp View File

@@ -4,10 +4,6 @@
using namespace rack; using namespace rack;




extern float sawTable[2048];
extern float triTable[2048];


//////////////////// ////////////////////
// module widgets // module widgets
//////////////////// ////////////////////
@@ -46,4 +42,6 @@ struct ScopeWidget : ModuleWidget {


struct SEQ3Widget : ModuleWidget { struct SEQ3Widget : ModuleWidget {
SEQ3Widget(); SEQ3Widget();
json_t *toJsonData();
void fromJsonData(json_t *root);
}; };

+ 33
- 0
src/SEQ3.cpp View File

@@ -48,6 +48,39 @@ struct SEQ3 : Module {


SEQ3(); SEQ3();
void step(); void step();

json_t *toJson() {
json_t *rootJ = json_object();

json_t *gatesJ = json_array();
for (int i = 0; i < 8; i++) {
json_t *gateJ = json_integer((int) gateState[i]);
json_array_append_new(gatesJ, gateJ);
}
json_object_set_new(rootJ, "gates", gatesJ);

return rootJ;
}

void fromJson(json_t *rootJ) {
json_t *gatesJ = json_object_get(rootJ, "gates");
for (int i = 0; i < 8; i++) {
json_t *gateJ = json_array_get(gatesJ, i);
gateState[i] = !!json_integer_value(gateJ);
}
}

void initialize() {
for (int i = 0; i < 8; i++) {
gateState[i] = false;
}
}

void randomize() {
for (int i = 0; i < 8; i++) {
gateState[i] = (randomf() > 0.5);
}
}
}; };






+ 14
- 3
src/VCO.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save