aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboard/planck/beeps.c62
-rw-r--r--keyboard/planck/keymap_midi.c38
-rw-r--r--protocol/lufa/lufa.c2
3 files changed, 45 insertions, 57 deletions
diff --git a/keyboard/planck/beeps.c b/keyboard/planck/beeps.c
index a1e697be4..8d1f81f21 100644
--- a/keyboard/planck/beeps.c
+++ b/keyboard/planck/beeps.c
@@ -183,22 +183,6 @@ ISR(TIMER3_COMPA_vect) {
183// // PORTC |= (1<<6); 183// // PORTC |= (1<<6);
184} 184}
185 185
186void loop() {
187}
188// ISR(TIMER1_COMPA_vect)
189// {
190// // if (i<(sizeof(wave)/sizeof(int))) //don't exceed ends of vector... sizeof(wave)
191// if (i<pow(2, 10)) //don't exceed ends of vector... sizeof(wave)
192// {
193// OCR3A = (int)((float)wave[i]*ICR3/RANGE); //go to next array element
194// // int x = 1;
195// // int y = 5;
196// // OCR3A = (int) (round(sin(i*440*pow(2, x/12.0))*.5+.5 + sin(i*440*pow(2, y/12.0))*.5+.5) / 2 * ICR3);
197// i++; //increment
198// }
199// else i=0; //reset
200// }
201
202void play_note(double freq, int vol) { 186void play_note(double freq, int vol) {
203 187
204 if (freq > 0) { 188 if (freq > 0) {
@@ -236,27 +220,27 @@ void play_note(double freq, int vol) {
236 // TCCR3B = 0; 220 // TCCR3B = 0;
237} 221}
238 222
239void note(int x, float length) { 223// void note(int x, float length) {
240 DDRC |= (1<<6); 224// DDRC |= (1<<6);
241 int t = (int)(440*pow(2,-x/12.0)); // starting note 225// int t = (int)(440*pow(2,-x/12.0)); // starting note
242 for (int y = 0; y < length*1000/t; y++) { // note length 226// for (int y = 0; y < length*1000/t; y++) { // note length
243 PORTC |= (1<<6); 227// PORTC |= (1<<6);
244 delay_us(t); 228// delay_us(t);
245 PORTC &= ~(1<<6); 229// PORTC &= ~(1<<6);
246 delay_us(t); 230// delay_us(t);
247 } 231// }
248 PORTC &= ~(1<<6); 232// PORTC &= ~(1<<6);
249} 233// }
250 234
251void true_note(float x, float y, float length) { 235// void true_note(float x, float y, float length) {
252 for (uint32_t i = 0; i < length * 50; i++) { 236// for (uint32_t i = 0; i < length * 50; i++) {
253 uint32_t v = (uint32_t) (round(sin(PI*2*i*640000*pow(2, x/12.0))*.5+1 + sin(PI*2*i*640000*pow(2, y/12.0))*.5+1) / 2 * pow(2, 8)); 237// uint32_t v = (uint32_t) (round(sin(PI*2*i*640000*pow(2, x/12.0))*.5+1 + sin(PI*2*i*640000*pow(2, y/12.0))*.5+1) / 2 * pow(2, 8));
254 for (int u = 0; u < 8; u++) { 238// for (int u = 0; u < 8; u++) {
255 if (v & (1 << u) && !(PORTC&(1<<6))) 239// if (v & (1 << u) && !(PORTC&(1<<6)))
256 PORTC |= (1<<6); 240// PORTC |= (1<<6);
257 else if (PORTC&(1<<6)) 241// else if (PORTC&(1<<6))
258 PORTC &= ~(1<<6); 242// PORTC &= ~(1<<6);
259 } 243// }
260 } 244// }
261 PORTC &= ~(1<<6); 245// PORTC &= ~(1<<6);
262} \ No newline at end of file 246// } \ No newline at end of file
diff --git a/keyboard/planck/keymap_midi.c b/keyboard/planck/keymap_midi.c
index 60ad6d53a..748ca4d56 100644
--- a/keyboard/planck/keymap_midi.c
+++ b/keyboard/planck/keymap_midi.c
@@ -35,7 +35,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
35 if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { 35 if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) {
36 if (record->event.pressed) { 36 if (record->event.pressed) {
37 starting_note++; 37 starting_note++;
38 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 38 // play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
39 midi_send_cc(&midi_device, 0, 0x7B, 0); 39 midi_send_cc(&midi_device, 0, 0x7B, 0);
40 midi_send_cc(&midi_device, 1, 0x7B, 0); 40 midi_send_cc(&midi_device, 1, 0x7B, 0);
41 midi_send_cc(&midi_device, 2, 0x7B, 0); 41 midi_send_cc(&midi_device, 2, 0x7B, 0);
@@ -43,7 +43,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
43 midi_send_cc(&midi_device, 4, 0x7B, 0); 43 midi_send_cc(&midi_device, 4, 0x7B, 0);
44 return; 44 return;
45 } else { 45 } else {
46 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); 46 // stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
47 // stop_all_notes(); 47 // stop_all_notes();
48 return; 48 return;
49 } 49 }
@@ -51,7 +51,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
51 if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { 51 if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) {
52 if (record->event.pressed) { 52 if (record->event.pressed) {
53 starting_note--; 53 starting_note--;
54 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 54 // play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
55 midi_send_cc(&midi_device, 0, 0x7B, 0); 55 midi_send_cc(&midi_device, 0, 0x7B, 0);
56 midi_send_cc(&midi_device, 1, 0x7B, 0); 56 midi_send_cc(&midi_device, 1, 0x7B, 0);
57 midi_send_cc(&midi_device, 2, 0x7B, 0); 57 midi_send_cc(&midi_device, 2, 0x7B, 0);
@@ -59,7 +59,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
59 midi_send_cc(&midi_device, 4, 0x7B, 0); 59 midi_send_cc(&midi_device, 4, 0x7B, 0);
60 return; 60 return;
61 } else { 61 } else {
62 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1))); 62 // stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[0 + offset])/12.0+(MATRIX_ROWS - 1)));
63 // stop_all_notes(); 63 // stop_all_notes();
64 return; 64 return;
65 } 65 }
@@ -73,12 +73,12 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
73 midi_send_cc(&midi_device, 3, 0x7B, 0); 73 midi_send_cc(&midi_device, 3, 0x7B, 0);
74 midi_send_cc(&midi_device, 4, 0x7B, 0); 74 midi_send_cc(&midi_device, 4, 0x7B, 0);
75 // stop_all_notes(); 75 // stop_all_notes();
76 for (int i = 0; i <= 7; i++) { 76 // for (int i = 0; i <= 7; i++) {
77 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 77 // play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
78 _delay_us(80000); 78 // _delay_us(80000);
79 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); 79 // stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
80 _delay_us(8000); 80 // _delay_us(8000);
81 } 81 // }
82 return; 82 return;
83 } 83 }
84 if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { 84 if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
@@ -89,20 +89,22 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
89 midi_send_cc(&midi_device, 3, 0x7B, 0); 89 midi_send_cc(&midi_device, 3, 0x7B, 0);
90 midi_send_cc(&midi_device, 4, 0x7B, 0); 90 midi_send_cc(&midi_device, 4, 0x7B, 0);
91 // stop_all_notes(); 91 // stop_all_notes();
92 for (int i = 0; i <= 7; i++) { 92 // for (int i = 0; i <= 7; i++) {
93 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC); 93 // play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)), 0xC);
94 _delay_us(80000); 94 // _delay_us(80000);
95 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1))); 95 // stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[i + offset])/12.0+(MATRIX_ROWS - 1)));
96 _delay_us(8000); 96 // _delay_us(8000);
97 } 97 // }
98 return; 98 return;
99 } 99 }
100 100
101 if (record->event.pressed) { 101 if (record->event.pressed) {
102 // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); 102 // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
103 play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); 103 midi_send_noteon(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
104 // play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
104 } else { 105 } else {
105 // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); 106 // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
106 stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); 107 midi_send_noteoff(&midi_device, 0, (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row), 127);
108 // stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
107 } 109 }
108} \ No newline at end of file 110} \ No newline at end of file
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index c6e6e9505..b31f3031e 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -51,7 +51,9 @@
51 51
52#include "descriptor.h" 52#include "descriptor.h"
53#include "lufa.h" 53#include "lufa.h"
54#ifdef MIDI_ENABLE
54#include <beeps.h> 55#include <beeps.h>
56#endif
55 57
56// #include <LUFA/Version.h> 58// #include <LUFA/Version.h>
57// #include <LUFA/Drivers/USB/USB.h> 59// #include <LUFA/Drivers/USB/USB.h>