rgb clean-up, api clean-up

daktil_manuform
Jack Humbert 2016-12-19 11:18:18 -05:00
parent ae95834f5a
commit 06c64bbff3
6 changed files with 77 additions and 35 deletions

View File

@ -52,6 +52,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGB_MIDI #define RGB_MIDI
#define RGBW_BB_TWI #define RGBW_BB_TWI
#define RGBW 1
/* Set 0 if debouncing isn't needed */ /* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5 #define DEBOUNCE 5

View File

@ -116,28 +116,29 @@ void process_api(uint16_t length, uint8_t * data) {
MT_GET_DATA_ACK(DT_KEYMAP_SIZE, keymap_size, 2); MT_GET_DATA_ACK(DT_KEYMAP_SIZE, keymap_size, 2);
break; break;
} }
case DT_KEYMAP: { // This may be too much
uint8_t keymap_data[MATRIX_ROWS * MATRIX_COLS * 4 + 3]; // case DT_KEYMAP: {
keymap_data[0] = data[2]; // uint8_t keymap_data[MATRIX_ROWS * MATRIX_COLS * 4 + 3];
keymap_data[1] = MATRIX_ROWS;
keymap_data[2] = MATRIX_COLS;
for (int i = 0; i < MATRIX_ROWS; i++) {
for (int j = 0; j < MATRIX_COLS; j++) {
keymap_data[3 + (i*MATRIX_COLS*2) + (j*2)] = pgm_read_word(&keymaps[data[2]][i][j]) >> 8;
keymap_data[3 + (i*MATRIX_COLS*2) + (j*2) + 1] = pgm_read_word(&keymaps[data[2]][i][j]) & 0xFF;
}
}
MT_GET_DATA_ACK(DT_KEYMAP, keymap_data, MATRIX_ROWS * MATRIX_COLS * 4 + 3);
// uint8_t keymap_data[5];
// keymap_data[0] = data[2]; // keymap_data[0] = data[2];
// keymap_data[1] = data[3]; // keymap_data[1] = MATRIX_ROWS;
// keymap_data[2] = data[4]; // keymap_data[2] = MATRIX_COLS;
// keymap_data[3] = pgm_read_word(&keymaps[data[2]][data[3]][data[4]]) >> 8; // for (int i = 0; i < MATRIX_ROWS; i++) {
// keymap_data[4] = pgm_read_word(&keymaps[data[2]][data[3]][data[4]]) & 0xFF; // for (int j = 0; j < MATRIX_COLS; j++) {
// keymap_data[3 + (i*MATRIX_COLS*2) + (j*2)] = pgm_read_word(&keymaps[data[2]][i][j]) >> 8;
// keymap_data[3 + (i*MATRIX_COLS*2) + (j*2) + 1] = pgm_read_word(&keymaps[data[2]][i][j]) & 0xFF;
// }
// }
// MT_GET_DATA_ACK(DT_KEYMAP, keymap_data, MATRIX_ROWS * MATRIX_COLS * 4 + 3);
// // uint8_t keymap_data[5];
// // keymap_data[0] = data[2];
// // keymap_data[1] = data[3];
// // keymap_data[2] = data[4];
// // keymap_data[3] = pgm_read_word(&keymaps[data[2]][data[3]][data[4]]) >> 8;
// // keymap_data[4] = pgm_read_word(&keymaps[data[2]][data[3]][data[4]]) & 0xFF;
// MT_GET_DATA_ACK(DT_KEYMAP, keymap_data, 5); // // MT_GET_DATA_ACK(DT_KEYMAP, keymap_data, 5);
break; // break;
} // }
default: default:
break; break;
} }

View File

@ -77,6 +77,7 @@ static bool audio_initialized = false;
audio_config_t audio_config; audio_config_t audio_config;
uint16_t envelope_index = 0; uint16_t envelope_index = 0;
bool glissando = true;
void audio_init() void audio_init()
{ {
@ -205,6 +206,7 @@ ISR(TIMER3_COMPA_vect)
freq = frequencies[voice_place]; freq = frequencies[voice_place];
#endif #endif
} else { } else {
if (glissando) {
if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
frequency = frequency * pow(2, 440/frequency/12/2); frequency = frequency * pow(2, 440/frequency/12/2);
} else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
@ -212,6 +214,9 @@ ISR(TIMER3_COMPA_vect)
} else { } else {
frequency = frequencies[voices - 1]; frequency = frequencies[voices - 1];
} }
} else {
frequency = frequencies[voices - 1];
}
#ifdef VIBRATO_ENABLE #ifdef VIBRATO_ENABLE
if (vibrato_strength > 0) { if (vibrato_strength > 0) {

View File

@ -6,6 +6,7 @@
extern uint16_t envelope_index; extern uint16_t envelope_index;
extern float note_timbre; extern float note_timbre;
extern float polyphony_rate; extern float polyphony_rate;
extern bool glissando;
voice_type voice = default_voice; voice_type voice = default_voice;
@ -27,11 +28,13 @@ float voice_envelope(float frequency) {
switch (voice) { switch (voice) {
case default_voice: case default_voice:
glissando = true;
note_timbre = TIMBRE_50; note_timbre = TIMBRE_50;
polyphony_rate = 0; polyphony_rate = 0;
break; break;
case something: case something:
glissando = false;
polyphony_rate = 0; polyphony_rate = 0;
switch (compensated_index) { switch (compensated_index) {
case 0 ... 9: case 0 ... 9:
@ -43,16 +46,51 @@ float voice_envelope(float frequency) {
break; break;
case 20 ... 200: case 20 ... 200:
note_timbre = .25 + .125 + pow(((float)compensated_index - 20) / (200 - 20), 2)*.125; note_timbre = .125 + .125;
break; break;
default: default:
note_timbre = .25; note_timbre = .125;
break; break;
} }
break; break;
case drums:
glissando = false;
polyphony_rate = 0;
note_timbre = 0;
switch (envelope_index) {
case 0 ... 20:
note_timbre = 0.5;
default:
frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
break;
}
// if (frequency < 80.0) {
// switch (envelope_index % 4) {
// case 0:
// frequency = 348.0;
// case 1:
// frequency = 53.0;
// case 2:
// frequency = 128.0;
// case 3:
// frequency = 934.0;
// default:
// break;
// }
// } else if (frequency < 160.0) {
// } else if (frequency < 320.0) {
// } else if (frequency < 640.0) {
// } else if (frequency < 1280.0) {
// }
break;
case butts_fader: case butts_fader:
glissando = true;
polyphony_rate = 0; polyphony_rate = 0;
switch (compensated_index) { switch (compensated_index) {
case 0 ... 9: case 0 ... 9:
@ -100,6 +138,7 @@ float voice_envelope(float frequency) {
case duty_osc: case duty_osc:
// This slows the loop down a substantial amount, so higher notes may freeze // This slows the loop down a substantial amount, so higher notes may freeze
glissando = true;
polyphony_rate = 0; polyphony_rate = 0;
switch (compensated_index) { switch (compensated_index) {
default: default:
@ -114,6 +153,7 @@ float voice_envelope(float frequency) {
break; break;
case duty_octave_down: case duty_octave_down:
glissando = true;
polyphony_rate = 0; polyphony_rate = 0;
note_timbre = (envelope_index % 2) * .125 + .375 * 2; note_timbre = (envelope_index % 2) * .125 + .375 * 2;
if ((envelope_index % 4) == 0) if ((envelope_index % 4) == 0)
@ -122,6 +162,7 @@ float voice_envelope(float frequency) {
note_timbre = 0; note_timbre = 0;
break; break;
case delayed_vibrato: case delayed_vibrato:
glissando = true;
polyphony_rate = 0; polyphony_rate = 0;
note_timbre = TIMBRE_50; note_timbre = TIMBRE_50;
#define VOICE_VIBRATO_DELAY 150 #define VOICE_VIBRATO_DELAY 150

View File

@ -12,6 +12,7 @@ float voice_envelope(float frequency);
typedef enum { typedef enum {
default_voice, default_voice,
something, something,
drums,
butts_fader, butts_fader,
octave_crunch, octave_crunch,
duty_osc, duty_osc,

View File

@ -18,13 +18,6 @@
//#include "ws2812_config.h" //#include "ws2812_config.h"
//#include "i2cmaster.h" //#include "i2cmaster.h"
#define LIGHT_I2C 1
#define LIGHT_I2C_ADDR 0x84
#define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE )
#define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ )
#define RGBW 1
#ifdef RGBW #ifdef RGBW
#define LED_TYPE struct cRGBW #define LED_TYPE struct cRGBW
#else #else