Skip to content

Commit

Permalink
bithammer
Browse files Browse the repository at this point in the history
  • Loading branch information
naus3a committed Dec 9, 2017
1 parent 0009c17 commit d0c8a65
Show file tree
Hide file tree
Showing 8 changed files with 506 additions and 14 deletions.
Binary file modified .README.md.swp
Binary file not shown.
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@

This is my personal collection of modules for [VCV Rack](https://vcvrack.com/): feel free to use them and modify them as you wish. If you find them useful, feel free to get me a beer.

### Tension
**Tension** is a fixed voltage generator: you turn the knob, you change the voltage. Useful when playing with logic chains or if you need to power up a virtual lamp ;) .

![tension](https://raw.githubusercontent.com/naus3a/NauModular/master/tension.png "tension")

---

### Function
**Function** is a function generator; it outputs the 3 conic section functions you learned in high school: ellipse, parabola and hyperbola. Input voltage acts as the x variable, while the knob is a constant parameter.

![function](https://raw.githubusercontent.com/naus3a/NauModular/master/function.png "function")

---

### Perlin
**Perlin** is a [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) generator.
Expand All @@ -37,12 +24,32 @@ The lowest, central output is the *mix output*, giving you a mix of the noise oc
---

### S&H(it)
**S&H(it)** is a sampler and hold module. The *time knob* controls how often it samples the input signal; the *divider knob* scales the other knob's value, so yu can range from very quick lo-fi sampling to >1s periods;
**S&H(it)** is a sample and hold module. The *time knob* controls how often it samples the input signal; the *divider knob* scales the other knob's value, so yu can range from very quick lo-fi sampling to >1s periods.


![S&Hit](https://raw.githubusercontent.com/naus3a/NauModular/master/shit.png "S&Hit")

---

### BitHammer
**BitHammer** is a logic module performing bitwise operations on 2 inputs. The incoming values are rendered as bits, hammered, reassembled as virtual voltages and finally sent out to the 6 outputs.

![BitHammer](https//raw.githubusercontent.com/naus3a/NauModular/master/bithammer.png "BitHammer")

---

### Tension
**Tension** is a fixed voltage generator: you turn the knob, you change the voltage. Useful when playing with logic chains or if you need to power up a virtual lamp ;) .

![tension](https://raw.githubusercontent.com/naus3a/NauModular/master/tension.png "tension")

---

### Function
**Function** is a function generator; it outputs the 3 conic section functions you learned in high school: ellipse, parabola and hyperbola. Input voltage acts as the x variable, while the knob is a constant parameter.

![function](https://raw.githubusercontent.com/naus3a/NauModular/master/function.png "function")

---


Binary file added bithammer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
380 changes: 380 additions & 0 deletions res/BitHammer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/.BitHammer.cpp.swp
Binary file not shown.
96 changes: 96 additions & 0 deletions src/BitHammer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "NauModular.hpp"

struct BitHammer : Module{
enum ParamIds{
NUM_PARAMS
};
enum InputIds{
A_INPUT,
B_INPUT,
NUM_INPUTS
};
enum OutputIds{
AND_OUTPUT,
OR_OUTPUT,
XOR_OUTPUT,
LEFT_OUTPUT,
RIGHT_OUTPUT,
NOT_OUTPUT,
NUM_OUTPUTS
};
enum LightIds{
NUM_LIGHTS
};

union Volts2Bits{
float volts;
int bits;
};

BitHammer();
void step() override;

Volts2Bits inA;
Volts2Bits inB;

Volts2Bits outAnd;
Volts2Bits outOr;
Volts2Bits outXor;
Volts2Bits outLeft;
Volts2Bits outRight;
Volts2Bits outNot;
};

BitHammer::BitHammer() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS){
}


void BitHammer::step(){
inA.volts = inputs[A_INPUT].value;
inB.volts = inputs[B_INPUT].value;

outAnd.bits = inA.bits & inB.bits;
outOr.bits = inA.bits | inB.bits;
outXor.bits = inA.bits ^ inB.bits;

outNot.bits = ~inA.bits;
outNot.bits &= ~inB.bits;

outLeft.bits = inA.bits &(1<< inB.bits);
outRight.bits = inA.bits >> inB.bits;

outputs[AND_OUTPUT].value = outAnd.volts;
outputs[OR_OUTPUT].value = outOr.volts;
outputs[XOR_OUTPUT].value = outXor.volts;
outputs[NOT_OUTPUT].value = outNot.volts;
outputs[LEFT_OUTPUT].value = outLeft.volts;
outputs[RIGHT_OUTPUT].value = outRight.volts;
}

BitHammerWidget::BitHammerWidget(){
BitHammer * module = new BitHammer();
setModule(module);
box.size = Vec(6*RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
{
SVGPanel * panel = new SVGPanel();
panel->box.size = box.size;
panel->setBackground(SVG::load(assetPlugin(plugin, "res/BitHammer.svg")));
addChild(panel);
}

addChild(createScrew<ScrewSilver>(Vec(15,0)));
addChild(createScrew<ScrewSilver>(Vec(box.size.x-30,0)));
addChild(createScrew<ScrewSilver>(Vec(15,365)));
addChild(createScrew<ScrewSilver>(Vec(box.size.x-30,365)));

addInput(createInput<PJ301MPort>(Vec(15, 85), module, BitHammer::A_INPUT));
addInput(createInput<PJ301MPort>(Vec(50, 85), module, BitHammer::B_INPUT));

addOutput(createOutput<PJ301MPort>(Vec(20, 140), module, BitHammer::AND_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(20, 175), module, BitHammer::OR_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(20, 210), module, BitHammer::XOR_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(20, 245), module, BitHammer::LEFT_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(20, 280), module, BitHammer::RIGHT_OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(20, 315), module, BitHammer::NOT_OUTPUT));
}

5 changes: 5 additions & 0 deletions src/NauModular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ void init(rack::Plugin * p){
"S&h(it)",
"S&h(it)",
SAMPLE_AND_HOLD_TAG));

p->addModel(createModel<BitHammerWidget>("NauModular",
"BitHammer",
"BitHammer",
LOGIC_TAG));
}
/*
void NauModular::init(){
Expand Down
4 changes: 4 additions & 0 deletions src/NauModular.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ struct PerlinWidget : ModuleWidget{
struct S_h_itWidget : ModuleWidget{
S_h_itWidget();
};

struct BitHammerWidget : ModuleWidget{
BitHammerWidget();
};

0 comments on commit d0c8a65

Please sign in to comment.