commit 84cc8f3ed6da0352fdb7bc953496246e8a8d86b4
parent 0fafef7125c36d3de5241e2a65c457c6e5abf67b
Author: Adam M <[email protected]>
Date: Wed, 13 Jan 2021 20:32:38 -0600
Revert "Tick frame output every frame even in full random mode when 2 frames may be displayed together, random shuffle mode respect EOC zeroOffset"
This reverts commit 8a23277fb61822729b4eb9881cb2339a2f24122c.
Diffstat:
2 files changed, 24 insertions(+), 57 deletions(-)
diff --git a/src/ComputerscareBlank.cpp b/src/ComputerscareBlank.cpp
@@ -9,8 +9,6 @@
#include <sstream>
#include <thread>
#include <dirent.h>
-#include <algorithm>
-#include <random>
#define FONT_SIZE 13
@@ -40,7 +38,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
float frameDelay = .5;
std::vector<float> frameDelays;
std::vector<int> frameMapForScan;
- std::vector<int> shuffledFrames;
float totalGifDuration = 0.f;
@@ -52,12 +49,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
int pingPongDirection = 1;
- float speedFactor = 1.f;
-
- float zeroOffset = 0.f;
-
- bool tick = false;
-
/*
uninitialized: 0
gif: 1
@@ -72,26 +63,31 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
bool resetConnected = false;
bool speedConnected = false;
+ float leftMessages[2][8] = {};
+
+
+
+ float speedFactor = 1.f;
+
+ float zeroOffset = 0.f;
+
std::vector<std::string> animationModeDescriptions;
std::vector<std::string> endBehaviorDescriptions;
dsp::SchmittTrigger clockTrigger;
dsp::SchmittTrigger resetTrigger;
- dsp::SchmittTrigger resetButtonTrigger;
dsp::Timer syncTimer;
ComputerscareSVGPanel* panelRef;
-
- float leftMessages[2][8] = {};
-
enum ParamIds {
ANIMATION_SPEED,
ANIMATION_ENABLED,
CONSTANT_FRAME_DELAY,
ANIMATION_MODE,
END_BEHAVIOR,
+ ZERO_OFFSET,
NUM_PARAMS
};
enum InputIds {
@@ -111,6 +107,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
configParam(ANIMATION_ENABLED, 0.f, 1.f, 1.f, "Animation Enabled");
configParam(CONSTANT_FRAME_DELAY, 0.f, 1.f, 0.f, "Constant Frame Delay");
configMenuParam(END_BEHAVIOR, 0.f, 5.f, 0.f, "Animation End Behavior", 2);
+ configParam(ZERO_OFFSET, -1.f, 1.f, 0.f, "Frame Zero Offset");
animationModeDescriptions.push_back("Forward");
animationModeDescriptions.push_back("Reverse");
@@ -156,8 +153,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
scrubbing = messageFromExpander[8];
-
-
updateScrubFrame();
if (clockConnected) {
@@ -191,16 +186,9 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
goToFrame(0);
}
}
- if(resetButtonTrigger.process(messageFromExpander[9])) {
- goToFrame(0);
- }
messageToSendToExpander[0] = float (currentFrame);
messageToSendToExpander[1] = float (numFrames);
- messageToSendToExpander[2] = float (mappedFrame);
- messageToSendToExpander[3] = float (scrubFrame);
- messageToSendToExpander[4] = float (tick);
-
// Flip messages at the end of the timestep
leftExpander.module->rightExpander.messageFlipRequested = true;
}
@@ -333,7 +321,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
void setFrameDelays(std::vector<float> frameDelaysSeconds) {
frameDelays = frameDelaysSeconds;
setFrameMap();
- setFrameShuffle();
ready = true;
}
void setFrameMap() {
@@ -347,14 +334,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
frameMapForScan.push_back(i);
}
}
- }
- void setFrameShuffle() {
- shuffledFrames.resize(0);
- for(int i=0; i < numFrames; i++) {
- shuffledFrames.push_back(i);
- }
- auto rng = std::default_random_engine {};
- std::shuffle(std::begin(shuffledFrames), std::end(shuffledFrames), rng);
}
void setTotalGifDuration(float totalDuration) {
@@ -368,7 +347,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
if (numFrames > 1) {
int animationMode = params[ANIMATION_MODE].getValue();
if (params[ANIMATION_SPEED].getValue() >= 0 ) {
- if (animationMode == 0 || animationMode == 3) {
+ if (animationMode == 0) {
nextFrame();
} else if (animationMode == 1) {
prevFrame();
@@ -384,7 +363,6 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
else if (animationMode == 4 ) {
goToRandomFrame();
}
- tick = !tick;
}
else {
@@ -431,14 +409,9 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
sampleCounter = 0;
currentFrame = frameNum;
mappedFrame = (currentFrame + mapBlankFrameOffset(zeroOffset, numFrames)) % numFrames;
- if(params[ANIMATION_MODE].getValue() == 3) {
- mappedFrame = shuffledFrames[mappedFrame];
- }
-
currentFrame += numFrames;
currentFrame %= numFrames;
setCurrentFrameDelayFromTable();
- DEBUG("currentFrame:%i, mappedFrame:%i, scrubFrame:%i",currentFrame,mappedFrame,scrubFrame);
}
else {
DEBUG("no frames lol");
@@ -582,7 +555,7 @@ struct ssmi : MenuItem
MenuItem::step();
}
};
-struct ParamSelectMenu : MenuItem {
+struct Strongbipper : MenuItem {
ParamQuantity* param;
std::vector<std::string> options;
@@ -758,16 +731,13 @@ struct GiantFrameDisplay : TransparentWidget {
addChild(frameDisplay);
addChild(description);
- //TransparentWidget();
+ TransparentWidget();
}
void step() {
if (module) {
visible = module->scrubbing;
frameDisplay->value = string::f("%i / %i", module->scrubFrame + 1, module->numFrames);
}
- else {
- visible = false;
- }
TransparentWidget::step();
}
};
@@ -825,20 +795,27 @@ struct ComputerscareBlankWidget : MenuParamModuleWidget {
ComputerscareBlank* blank = dynamic_cast<ComputerscareBlank*>(this->blankModule);
- modeMenu = new ParamSelectMenu();
+ Strongbipper *modeMenu = new Strongbipper();
modeMenu->text = "Animation Mode";
modeMenu->rightText = RIGHT_ARROW;
modeMenu->param = blankModule->paramQuantities[ComputerscareBlank::ANIMATION_MODE];
modeMenu->options = blankModule->animationModeDescriptions;
- endMenu = new ParamSelectMenu();
+
+
+
+
+ Strongbipper *endMenu = new Strongbipper();
endMenu->text = "Animation End Behavior";
endMenu->rightText = RIGHT_ARROW;
endMenu->param = blankModule->paramQuantities[ComputerscareBlank::END_BEHAVIOR];
endMenu->options = blankModule->endBehaviorDescriptions;
+
+
menu->addChild(new MenuEntry);
+ //menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Keyboard Controls:"));
menu->addChild(modeMenu);
menu->addChild(endMenu);
@@ -1018,8 +995,6 @@ struct ComputerscareBlankWidget : MenuParamModuleWidget {
ComputerscareResizeHandle *leftHandle;
ComputerscareResizeHandle *rightHandle;
GiantFrameDisplay* frameDisplay;
- ParamSelectMenu *modeMenu;
- ParamSelectMenu *endMenu;
};
diff --git a/src/ComputerscareBlankExpander.cpp b/src/ComputerscareBlankExpander.cpp
@@ -23,7 +23,6 @@ struct ComputerscareBlankExpander : Module {
float lastFrame = -1;
int numFrames = 1;
bool scrubbing = false;
- int lastTick = -1;
enum ParamIds {
@@ -88,10 +87,6 @@ struct ComputerscareBlankExpander : Module {
float currentFrame = messageFromMother[0];
int newNumFrames = messageFromMother[1];
- int mappedFrame = messageFromMother[2];
- int scrubFrame = messageFromMother[3];
- int tick = messageFromMother[4];
-
if (newNumFrames != numFrames) {
numFrames = newNumFrames;
@@ -100,10 +95,10 @@ struct ComputerscareBlankExpander : Module {
float currentSyncTime = syncTimer.process(args.sampleTime);
- if (eocMessageReadTrigger.process(mappedFrame == scrubFrame ? 10.f : 0.f)) {
+ if (eocMessageReadTrigger.process(currentFrame == 0 ? 10.f : 0.f)) {
eocPulse.trigger(1e-3);
}
- if (eachFrameReadTrigger.process(lastTick != tick ? 10.f : 0.f)) {
+ if (eachFrameReadTrigger.process(abs(currentFrame - lastFrame) * 10)) {
eachFramePulse.trigger(1e-3);
}
@@ -123,15 +118,12 @@ struct ComputerscareBlankExpander : Module {
messageToSendToMother[8] = scrubbing;
- messageToSendToMother[9] = params[MANUAL_RESET_BUTTON].getValue()*10;
-
outputs[EOC_OUTPUT].setVoltage(eocPulse.process(args.sampleTime) ? 10.f : 0.f);
outputs[EACH_FRAME_OUTPUT].setVoltage(eachFramePulse.process(args.sampleTime) ? 10.f : 0.f);
rightExpander.module->leftExpander.messageFlipRequested = true;
lastFrame = currentFrame;
- lastTick = tick;
}
else {
isConnected = false;