diff --git a/hardware/MIDImike r3.brd b/hardware/MIDImike r4.brd similarity index 95% rename from hardware/MIDImike r3.brd rename to hardware/MIDImike r4.brd index bd38eb2..6427f0f 100644 --- a/hardware/MIDImike r3.brd +++ b/hardware/MIDImike r4.brd @@ -182,7 +182,7 @@ USB-MIDI USB-SERIAL -MIDImike r3 +MIDImike r4 Johan Vonk 2016 https://github.com/jvonk/MIDImike @@ -435,29 +435,6 @@ Includes mounting holes, and holes for ICSP header >NAME >VALUE - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - <b>JUMPER</b> @@ -1843,17 +1820,6 @@ design rules under a new name. - - - - - - - - - - - @@ -1923,8 +1889,6 @@ design rules under a new name. - - @@ -1938,15 +1902,10 @@ design rules under a new name. - - - - - @@ -1967,10 +1926,12 @@ design rules under a new name. - + + + @@ -2048,23 +2009,15 @@ design rules under a new name. - - - - - - - - - - - - - - + + + + + + @@ -2079,13 +2032,10 @@ design rules under a new name. - - - - - - - + + + + @@ -2119,6 +2069,10 @@ design rules under a new name. + + + + diff --git a/hardware/MIDImike r3.sch b/hardware/MIDImike r4.sch similarity index 98% rename from hardware/MIDImike r3.sch rename to hardware/MIDImike r4.sch index 0fafa05..34865a9 100644 --- a/hardware/MIDImike r3.sch +++ b/hardware/MIDImike r4.sch @@ -289,29 +289,6 @@ >NAME >VALUE - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - @@ -570,6 +547,7 @@ Includes mounting holes, and holes for ICSP header SD TFT DISPLAY + @@ -582,17 +560,6 @@ Includes mounting holes, and holes for ICSP header >VALUE - ->NAME ->VALUE - - - - - - - - @@ -726,6 +693,7 @@ Includes mounting holes, and holes for ICSP header + @@ -761,31 +729,6 @@ Includes mounting holes, and holes for ICSP header - -Switch Tactile OFF (ON) SPST Round Button PC Pins 0.05A 24VDC 100000Cycles 1.56N Thru-Hole Loose - - - - - - - - - - - - - - - - - - - - - - - <h3>Footprint of Adafruit AGC Electret Microphone Amplifier - MAX9814</h3> <p> @@ -7439,7 +7382,6 @@ Source: www.kingbright.com - @@ -7452,7 +7394,6 @@ Source: www.kingbright.com - @@ -7460,9 +7401,8 @@ Source: www.kingbright.com USB-MIDI -REPLAY USB-MIDI or USB-SERIAL -CLIP +CLIP SHIFT @@ -7491,15 +7431,11 @@ Source: www.kingbright.com - - - - - - + + @@ -7520,23 +7456,20 @@ Source: www.kingbright.com - - - - - - + + + + + + - - - + + + - - - @@ -7568,7 +7501,7 @@ Source: www.kingbright.com - + @@ -7582,11 +7515,6 @@ Source: www.kingbright.com - - - - - @@ -7677,19 +7605,7 @@ Source: www.kingbright.com - - - - - - - - - - - - @@ -7717,8 +7633,8 @@ Source: www.kingbright.com - - + + @@ -7744,6 +7660,15 @@ Source: www.kingbright.com + + + + + + + + + diff --git a/hardware/libraries/Coert-Vonk.lbr b/hardware/libraries/Coert-Vonk.lbr index 68077c2..3352836 100644 --- a/hardware/libraries/Coert-Vonk.lbr +++ b/hardware/libraries/Coert-Vonk.lbr @@ -7,7 +7,7 @@ - + @@ -6391,6 +6391,7 @@ Read the BAT voltage from IO35 and double it SD TFT DISPLAY + <h3>Arduino Uno R3</h3> @@ -11366,6 +11367,7 @@ Arduino Uno R3 Compatible Footprint. Matches PCB size of the original board. + diff --git a/main/main.ino b/main/main.ino index 9d101e0..bf4dcb7 100644 --- a/main/main.ino +++ b/main/main.ino @@ -66,11 +66,12 @@ namespace { typedef enum digialIoPins_t { SHIFT_BCD1 = 2, // ---wire-to--- SW2 BCD value 1 to GND SHIFT_BCD2 = 3, // ---wire-to--- SW2 BCD value 2 to GND + SPI_SD_CS = 4, // ---wire-to--- CARD_CS on TFT/SD breakout (SPI SD Card Chip Select) SHIFT_BCD4 = 5, // ---wire-to--- SW2 BCD value 4 to GND SHIFT_BCD8 = 6, // ---wire-to--- SW2 BCD value 8 to GND - REPLAY_BUTTON = 7, // ---wire-to--- Pushbutton to GND - SPI_SD_CS = 4, // ---wire-to--- CARD_CS on TFT/SD breakout (SPI SD Card Chip Select) - SPI_DC = 8, // ---wire-to--- D/C on TFT/SD breakout (SPI Data/Command) + //REPLAY_BUTTON = 7, // ---wire-to--- Pushbutton to GND + CLIP_LED = 7, // ---wire-to--- LED and 330 Ohm to GND + SPI_TFT_DC = 8, // ---wire-to--- TFT_DC on TFT/SD breakout (SPI TFT Data/!Command) SPI_RST = 9, // ---wire-to--- RESET on TFT/SD breakout (Reset) SPI_TFT_CS = 10, // ---wire-to--- TFT_CS on TFT/SD breakout (SPI TFT Chip Select) SPI_MOSI = 11, // ---wire-to--- MOSI on TFT/SD breakout (SPI Master out, slave in) @@ -144,16 +145,17 @@ setup() pinMode(SHIFT_BCD2, INPUT_PULLUP); pinMode(SHIFT_BCD4, INPUT_PULLUP); pinMode(SHIFT_BCD8, INPUT_PULLUP); + pinMode(CLIP_LED, OUTPUT); switch (DST) { case DST_STAFF: - staff_init(SPI_TFT_CS, SPI_DC, SPI_RST); + staff_init(SPI_TFT_CS, SPI_TFT_DC, SPI_RST); break; case DST_PIANOROLL: _.segment = new Segment(); _.segmentBuf = new SegmentBuf(); - pianoroll_init(SPI_TFT_CS, SPI_DC, SPI_RST); - pinMode(REPLAY_BUTTON, INPUT_PULLUP); + pianoroll_init(SPI_TFT_CS, SPI_TFT_DC, SPI_RST); + //pinMode(REPLAY_BUTTON, INPUT_PULLUP); break; case DST_TEXT: if (SRC == SRC_FILE) { @@ -192,7 +194,9 @@ loop() // get samples from microphone, samples will be dynamically allocated on first invocation amplitude_t amplitude; - samples_t samples = microphone_get_samples(&litude); + bool clipping; + samples_t samples = microphone_get_samples(&litude, &clipping); + digitalWrite(CLIP_LED, clipping); // find frequency from samples float freq = frequency_calculate(samples); @@ -216,11 +220,12 @@ loop() case DST_PIANOROLL: _.segment->put(millis(), pitch_measured.get_segment(), amplitude, _.segmentBuf); pianoroll_draw(_.segment->get_last_offset(), _.segmentBuf); - +#if 0 if ((USB == USB_MIDI) && digitalRead(REPLAY_BUTTON) == 0) { midiserial_send_notes(_.segmentBuf); pianoroll_clear(); } +#endif break; case DST_TEXT: Pitch pitch_in(NOTENR_C, 0); diff --git a/main/src/display/pianoroll.cpp b/main/src/display/pianoroll.cpp index a46e1e1..75004bc 100644 --- a/main/src/display/pianoroll.cpp +++ b/main/src/display/pianoroll.cpp @@ -202,12 +202,12 @@ pianoroll_clear(void) } void -pianoroll_init(uint_least8_t tftCS_pin, // GPIO# for SPI TFT Chip Select - uint_least8_t dc_pin, // GPIO# SPI Data/Command - uint_least8_t reset_pin) // GPIO# SPI Reset +pianoroll_init(uint_least8_t tft_cs_pin, // GPIO# for SPI TFT Chip Select + uint_least8_t tft_dc_pin, // GPIO# SPI Data/Command + uint_least8_t reset_pin) // GPIO# SPI Reset { - pinMode(tftCS_pin, OUTPUT); - _.tft = new Adafruit_ST7735(tftCS_pin, dc_pin, reset_pin); // instantiate TFT driver + pinMode(tft_cs_pin, OUTPUT); + _.tft = new Adafruit_ST7735(tft_cs_pin, tft_dc_pin, reset_pin); // instantiate TFT driver _.tft->initR(INITR_BLACKTAB); // initialize TFT (ST7735S chip, black tab) _.tft->setRotation(3); // make (0,0) corresponds to top-right _resize(_.tft->width(), _.tft->height()); diff --git a/main/src/display/pianoroll.h b/main/src/display/pianoroll.h index 735dcb0..ba316d8 100644 --- a/main/src/display/pianoroll.h +++ b/main/src/display/pianoroll.h @@ -4,6 +4,6 @@ #include #include "../../segment_t.h" -void pianoroll_init(uint_least8_t tftCS_pin, uint_least8_t dc_pin, uint_least8_t reset_pin); +void pianoroll_init(uint_least8_t tft_cs_pin, uint_least8_t tft_dc_pin, uint_least8_t reset_pin); void pianoroll_clear(void); void pianoroll_draw(absolute_time_t const lastOffset, SegmentBuf * const segmentBuf); diff --git a/main/src/display/staff.cpp b/main/src/display/staff.cpp index 1c95443..587f8f6 100644 --- a/main/src/display/staff.cpp +++ b/main/src/display/staff.cpp @@ -287,12 +287,12 @@ staff_draw_note(Pitch & pitch) // note measured ************/ void -staff_init(uint_least8_t tftCS_pin, // GPIO# for SPI TFT Chip Select - uint_least8_t dc_pin, // GPIO# for SPI Data/Command - uint_least8_t reset_pin) // GPIO# for SPI Reset +staff_init(uint_least8_t tft_cs_pin, // GPIO# for SPI TFT Chip Select + uint_least8_t tft_dc_pin, // GPIO# for SPI Data/Command + uint_least8_t reset_pin) // GPIO# for SPI Reset { - pinMode(tftCS_pin, OUTPUT); - _.tft = new Adafruit_ST7735(tftCS_pin, dc_pin, reset_pin); + pinMode(tft_cs_pin, OUTPUT); + _.tft = new Adafruit_ST7735(tft_cs_pin, tft_dc_pin, reset_pin); _.tft->initR(INITR_BLACKTAB); // initialize ST7735S chip, black tab _.tft->fillScreen(COLOR_BG); _.tft->setRotation(3); // (0,0) corresponds to top-right diff --git a/main/src/display/staff.h b/main/src/display/staff.h index 57e6e59..2d70848 100644 --- a/main/src/display/staff.h +++ b/main/src/display/staff.h @@ -4,5 +4,5 @@ #include #include "../../sample_t.h" -void staff_init(uint_least8_t tftCS_pin, uint_least8_t dc_pin, uint_least8_t reset_pin); +void staff_init(uint_least8_t tft_cs_pin, uint_least8_t tft_dc_pin, uint_least8_t reset_pin); void staff_draw_note(Pitch & pitch); diff --git a/main/src/microphone/microphone.cpp b/main/src/microphone/microphone.cpp index 3bea3ba..b2c052c 100644 --- a/main/src/microphone/microphone.cpp +++ b/main/src/microphone/microphone.cpp @@ -110,13 +110,14 @@ microphone_start(void) ************************/ samples_t // returns pointer to array of data samples, NULL on failure -microphone_get_samples(amplitude_t * const amplitudePtr) +microphone_get_samples(amplitude_t * const amplitudePtr, bool * const clipPtr) { while (ADCSRA & ADCSRA_IRQ_ENABLE) { // spin wait until all samples are available } bool clipping = (_.range.max == SCHAR_MIN) || (_.range.max == SCHAR_MAX); + *clipPtr = clipping; amplitude_t amplitude = (int16_t)_.range.max - _.range.min; // top-top [0..255] *amplitudePtr = amplitude/2; // range [0..127] diff --git a/main/src/microphone/microphone.h b/main/src/microphone/microphone.h index 95e3886..2f06bcf 100644 --- a/main/src/microphone/microphone.h +++ b/main/src/microphone/microphone.h @@ -6,4 +6,4 @@ void microphone_begin(uint8_t const port); // 0 for A0 void microphone_start(void); -samples_t microphone_get_samples(amplitude_t * const amplitudePtr); +samples_t microphone_get_samples(amplitude_t * const amplitudePtr, bool * const clipPtr);