Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
872 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#include "block.h" | ||
|
||
float freq[12][9] = { | ||
{ | ||
16.3516, | ||
32.7032, | ||
65.40639, | ||
130.8128, | ||
261.6256, | ||
523.2511, | ||
1046.502, | ||
2093.005, | ||
4186.009, | ||
}, | ||
{ | ||
17.32391, | ||
34.64783, | ||
69.29566, | ||
138.5913, | ||
277.1826, | ||
554.3653, | ||
1108.731, | ||
2217.461, | ||
4434.922, | ||
}, | ||
{ | ||
18.35405, | ||
36.7081, | ||
73.41619, | ||
146.8324, | ||
293.6648, | ||
587.3295, | ||
1174.659, | ||
2349.318, | ||
4698.636, | ||
}, | ||
{ | ||
19.44544, | ||
38.89087, | ||
77.78175, | ||
155.5635, | ||
311.127, | ||
622.254, | ||
1244.508, | ||
2489.016, | ||
4978.032, | ||
}, | ||
{ | ||
20.60172, | ||
41.20344, | ||
82.40689, | ||
164.8138, | ||
329.6276, | ||
659.2551, | ||
1318.51, | ||
2637.02, | ||
5274.041, | ||
}, | ||
{ | ||
21.82676, | ||
43.65353, | ||
87.30706, | ||
174.6141, | ||
349.2282, | ||
698.4565, | ||
1396.913, | ||
2793.826, | ||
5587.652, | ||
}, | ||
{ | ||
23.12465, | ||
46.2493, | ||
92.49861, | ||
184.9972, | ||
369.9944, | ||
739.9888, | ||
1479.978, | ||
2959.955, | ||
5919.911, | ||
}, | ||
{ | ||
24.49971, | ||
48.99943, | ||
97.99886, | ||
195.9977, | ||
391.9954, | ||
783.9909, | ||
1567.982, | ||
3135.963, | ||
6271.927, | ||
}, | ||
{ | ||
25.95654, | ||
51.91309, | ||
103.8262, | ||
207.6523, | ||
415.3047, | ||
830.6094, | ||
1661.219, | ||
3322.438, | ||
6644.875, | ||
}, | ||
{ | ||
27.5, | ||
55.0, | ||
110.0, | ||
220.0, | ||
440.0, | ||
880.0, | ||
1760.0, | ||
3520.0, | ||
7040.0, | ||
}, | ||
{ | ||
29.13524, | ||
58.27047, | ||
116.5409, | ||
233.0819, | ||
466.1638, | ||
932.3275, | ||
1864.655, | ||
3729.31, | ||
7458.62, | ||
}, | ||
{ | ||
30.86771, | ||
61.73541, | ||
123.4708, | ||
246.9417, | ||
493.8833, | ||
987.7666, | ||
1975.533, | ||
3951.066, | ||
7902.133, | ||
}, | ||
}; | ||
|
||
float SoundBlock::frequency() { | ||
return freq[note][octave]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#pragma once | ||
#include "weirdmath.h" | ||
|
||
class Block { | ||
public: | ||
bool active = false; | ||
void activate() { active = true; } | ||
void deactivate() { active = false; } | ||
}; | ||
|
||
class KitBlock : public Block { | ||
public: | ||
int sample; | ||
void sampleUp() { sample = wrapping_add(sample, 4); } | ||
void sampleDown() { sample = wrapping_sub(sample, 4); } | ||
}; | ||
|
||
#define MAX_ATTACK 800.0 | ||
#define MAX_DECAY 800.0 | ||
|
||
class SoundBlock : public Block { | ||
public: | ||
enum Filter { low }; | ||
int note = 0; | ||
int octave = 3; | ||
float attack = 10.0; | ||
float decay = 40.0; | ||
float delay = 0.0; | ||
float pan = 0.0; | ||
float amp = 1.0; | ||
float sustain = 0.0; | ||
float filterType = Filter::low; | ||
float filterQ = 0.618; | ||
float filterFreq = 8000.0; | ||
int filterStage = 0; | ||
float pulseWidth = 0.5; | ||
float frequency(); | ||
void activate(int n, int o) { | ||
note = n; | ||
octave = o; | ||
active = true; | ||
} | ||
void filterDown() { | ||
filterFreq = saturating_sub(filterFreq, 10000.0, 100.0, 40.0); | ||
} | ||
void filterUp() { | ||
filterFreq = saturating_add(filterFreq, 10000.0, 100.0, 40.0); | ||
} | ||
void filterQDown() { | ||
filterFreq = saturating_sub(filterFreq, 1.0, 0.0234, 0); | ||
} | ||
void filterQUp() { filterFreq = saturating_add(filterFreq, 1.0, 0.0234, 0); } | ||
void noteUp() { note = wrapping_add(note, 11); } | ||
void noteDown() { note = wrapping_sub(note, 11); } | ||
void octaveUp() { octave = wrapping_add(octave, 8); } | ||
void octaveDown() { octave = wrapping_sub(octave, 8); } | ||
void decayUp() { decay = saturating_add_curve(decay, MAX_DECAY, 10, 0); } | ||
void decayDown() { decay = saturating_sub_curve(decay, MAX_DECAY, 10, 0); } | ||
void delayUp() { delay = saturating_add(delay, 100.0, 10.0, 0); } | ||
void delayDown() { delay = saturating_sub(delay, 100.0, 10.0, 0); } | ||
void ampUp() { amp = saturating_add(amp, 1.0, 0.1, 0); } | ||
void ampDown() { amp = saturating_sub(amp, 1.0, 0.1, 0); } | ||
void pulseWidthUp() { pulseWidth = saturating_add(pulseWidth, 1.0, 0.1, 0); } | ||
void pulseWidthDown() { | ||
pulseWidth = saturating_sub(pulseWidth, 1.0, 0.1, 0); | ||
} | ||
void panLeft() { pan = saturating_sub(pan, 1.0); } | ||
void panRight() { pan = saturating_add(pan, 1.0); } | ||
void attackUp() { attack = saturating_add_curve(attack, MAX_ATTACK, 10, 0); } | ||
void attackDown() { attack = saturating_sub_curve(attack, MAX_ATTACK, 10, 0); } | ||
void sustainUp() { sustain = saturating_add(sustain, 1.0, 0.137, 0); } | ||
void sustainDown() { sustain = saturating_sub(sustain, 1.0, 0.137, 0); } | ||
SoundBlock cut() { | ||
active = false; | ||
SoundBlock s; | ||
s.note = note; | ||
s.octave = octave; | ||
s.active = true; | ||
s.attack = attack; | ||
s.decay = decay; | ||
s.delay = delay; | ||
s.amp = amp; | ||
s.pan = pan; | ||
s.sustain = sustain; | ||
s.filterFreq = filterFreq; | ||
s.filterQ = filterQ; | ||
s.filterType = filterType; | ||
s.pulseWidth = pulseWidth; | ||
return s; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "display.h" | ||
|
||
Point getCoord(int idx) { | ||
int x = idx % 4; | ||
int y = idx / 4; | ||
return Point { | ||
x : GRID_OFFSET_X + (x * (BLOCK_SIZE + GRID_GAP)), | ||
y : GRID_OFFSET_Y + (y * (BLOCK_SIZE + GRID_GAP)) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <Adafruit_GFX.h> | ||
#include <Adafruit_ST7735.h> | ||
|
||
#define NEOPIXEL_PIN 8 | ||
#define NEOPIXEL_LENGTH 5 | ||
|
||
#define DISPLAY_CS 44 | ||
#define DISPLAY_RST 46 | ||
#define DISPLAY_DC 45 | ||
#define DISPLAY_BACKLIGHT 47 | ||
#define DISPLAY_HEIGHT 128 | ||
#define DISPLAY_WIDTH 160 | ||
|
||
#define BLOCK_SIZE 20 | ||
#define GRID_OFFSET_X 36 | ||
#define GRID_OFFSET_Y 20 | ||
#define GRID_GAP 2 | ||
#define STANDARD_BLOCK_COLOR 0xfebb | ||
#define TICK_BLOCK_COLOR 0xfc53 | ||
|
||
struct Point { | ||
int x; | ||
int y; | ||
}; | ||
|
||
Point getCoord(int idx); |
Empty file.
Oops, something went wrong.