90s Guitar Synth Keypad Matrix Sending midi notes - Suggestions/Help

Status
Not open for further replies.

Cfredisdead

New member
Hey All,
I Recently acquired a broken Casio Dg-10 (digital guitar from the 90s), and am working on turning it into a midi controller(to send midi note on/off messages) using the The teensy ++ 2.0 I just ordered. I have a little past experience using an Arduino and a 3 octave keyboard. One of the Main tone generating ICs on the DG-10 was broken, so its been gutted excluding the keypad/buttons and interesting 'string sensor mechanism'.

Whilst the Teensy is on its way I've started compiling some "basic" code to start testing the button matrix on the fret board only.
This is the DG-10's Service manual and on page 6 is the 'fret board' key matrix that I want to incorporate. Eventually I want to incorporate the string sensor mechanism shown on page 14 and the top right of page 7, and was hoping one of you could point me in the right direction of incorporating that mechanism fluidly.

So First off I have downloaded the keypad library and the midi library. I've modified Mark Stanleys Multikey.ino example and laid out the fret board into the keypad matrix so that each button is named the midi note that it should play when pressed. I used the auto check to get rid of a few dumb errors, but here's the botched code:

Code:
/* @file MultiKey.ino
|| @version 1.0
|| @author Mark Stanley
|| @contact mstanley@technologist.com
||
|| @description
|| | The latest version, 3.0, of the keypad library supports up to 10
|| | active keys all being pressed at the same time. This sketch is an
|| | example of how you can get multiple key presses from a keypad or
|| | keyboard.
|| #
*/

#include <Keypad.h>
#include <MIDI.h>

const int channel = 1; //Set midi Channel 1
const byte ROWS = 20; //four rows
const byte COLS = 6; //three columns

char keys[ROWS][COLS] = {
  {'41','46','51','56','60','65'},
  {'42','47','52','57','61','66'},
  {'43','48','53','58','62','67'},
  {'44','49','54','59','63','68'},
  {'45','50','55','60','64','69'},
  {'46','51','56','61','65','70'},
  {'47','52','57','62','66','71'},
  {'48','53','58','63','67','72'},
  {'49','54','59','64','68','73'},
  {'50','55','60','65','69','74'},
  {'51','56','61','66','70','75'},
  {'52','57','62','67','71','76'},
  {'53','58','63','68','72','77'},
  {'54','59','64','69','73','78'},
  {'55','60','65','70','74','79'},
  {'56','61','66','71','75','80'},
  {'57','62','67','72','76','81'},
  {'58','63','68','73','77','82'},
  {'59','64','69','74','78','83'},
  {'60','65','70','75','79','84'} 
  
};
byte rowPins[ROWS] = {30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {9, 8, 7, 6, 5, 4}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



void setup() {
  MIDI.begin();
  Serial.begin(9600);
  kpd.setDebounceTime(1);
}

unsigned long loopCount = 0;
unsigned long startTime = millis();




void loop() {

  loopCount++;
  if ( (millis()-startTime)>1000 ) {
      Serial.println(loopCount);
      startTime = millis();
      loopCount = 0;
  }

  // Fills kpd.key[ ] array with up-to 10 active keys.
  // Returns true if there are ANY active keys.
  if (kpd.getKeys())
  {
    for (int note=40; note<LIST_MAX; note++)   // Scan the whole key list.
    {
      if ( kpd.key[note].stateChanged )   // Only find keys that have changed state.
      {
        switch (kpd.key[note].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
            case PRESSED:
                MIDI.sendNoteOn(note, 100, channel);
                break;
            case HOLD: 
                break;
            case RELEASED:
                MIDI.sendNoteOff(note, 100, channel);
                break;
            case IDLE: ;
        }
        
      }
    }
  }
}  // End loop

So i guess my questions (until i can actually test with the teensy) are:
-Can anyone spot any obvious errors/ point me in the right direction to fix them?
-Is including the string sensor mechanism possible with this code... maybe using the idle and hold states and analog inputs?
-The string sensor mechanism connects very momentarily as the springs wiggle, is reading the time between wiggles and incorporating a sustain velocity with the analog inputs too outlandish?
-Is it possible to have only certain columns of the key pad matrix output notes dependent on which string sensor mechanism is being 'wiggled'?
-How could i go about including the open notes (when no strings are fretted)
-Is the integer 'note' going to be defined properly
-Advice tips for a novice?

Well... hope that makes sense to any of you and appreciate the advice/assistance

Edit:maybe this should be in 'Project guidance" instead?

Cfreddy
 
Last edited:
Your code hangs the C compiler with Arduino 1.6.4 and Teensyduino 1.23 beta 2.
I narrowed it down to the keys array which isn't declared correctly.
Code:
char keys[ROWS][COLS] = {
  {'41','46','51','56','60','65'},
// ...etc
};
Each entry in the array is a char but you are trying to put two chars into each one. For example, '41' is two chars.
I think you just need to remove the quotes altogether.
Code:
char keys[ROWS][COLS] = {
  {41,46,51,56,60,65},
// ...etc
};

Can't help with the other questions.

Pete
 
Thanks for the input Pete. I've adjusted the code:

Code:
/* @file MultiKey.ino
|| @version 1.0
|| @author Mark Stanley
|| @contact mstanley@technologist.com
||
|| @description
|| | The latest version, 3.0, of the keypad library supports up to 10
|| | active keys all being pressed at the same time. This sketch is an
|| | example of how you can get multiple key presses from a keypad or
|| | keyboard.
|| #
*/

#include <Keypad.h>
#include <MIDI.h>

const int channel = 1; //Set midi Channel 1
const byte ROWS = 20; //four rows
const byte COLS = 6; //three columns

char keys[ROWS][COLS] = {
  {41,46,51,56,60,65},
  {42,47,52,57,61,66},
  {43,48,53,58,62,67},
  {44,49,54,59,63,68},
  {45,50,55,60,64,69},
  {46,51,56,61,65,70},
  {47,52,57,62,66,71},
  {48,53,58,63,67,72},
  {49,54,59,64,68,73},
  {50,55,60,65,69,74},
  {51,56,61,66,70,75},
  {52,57,62,67,71,76},
  {53,58,63,68,72,77},
  {54,59,64,69,73,78},
  {55,60,65,70,74,79},
  {56,61,66,71,75,80},
  {57,62,67,72,76,81},
  {58,63,68,73,77,82},
  {59,64,69,74,78,83},
  {60,65,70,75,79,84} 
  
};
byte rowPins[ROWS] = {30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {9, 8, 7, 6, 5, 4}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



void setup() {
  MIDI.begin();
  Serial.begin(9600);
  kpd.setDebounceTime(1);
}

unsigned long loopCount = 0;
unsigned long startTime = millis();




void loop() {

  loopCount++;
  if ( (millis()-startTime)>1000 ) {
      Serial.println(loopCount);
      startTime = millis();
      loopCount = 0;
  }

  // Fills kpd.key[ ] array with up-to 10 active keys.
  // Returns true if there are ANY active keys.
  if (kpd.getKeys())
  {
    for (int note=40; note<LIST_MAX; note++)   // Scan the whole key list.
    {
      if ( kpd.key[note].stateChanged )   // Only find keys that have changed state.
      {
        switch (kpd.key[note].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
            case PRESSED:
                MIDI.sendNoteOn(note, 100, channel);
                break;
            case HOLD: 
                break;
            case RELEASED:
                MIDI.sendNoteOff(note, 100, channel);
                break;
            case IDLE: ;
        }
        
      }
    }
  }
}  // End loop

I've also been thinking on how to implement sustain. My best guess at the moment is to use the Bounce library to measure the time between contacts on the 'string sensor mechanism' and calculate/add a decay variable to the midi note velocity, maybe for the Idle and hold cases.

Here's how the string sensor functions
KJ8RVC6.png
 
Last edited:
Status
Not open for further replies.
Back
Top