Print This Post Print This Post

MIDI Chord Button Keyboard Using PIC Microcontroller – 2

How chords are formed
Before discussing the processor board and software, it is worth mentioning how the chords are composed. I have provided the table below which shows the installed chords together with the intervals/notes they are constructed from, and examples of each in the key of C major.
Since the source-code is provided, and heavily commented, you can experiment, both with the actual chords installed, their placement on the matrix, and whether they will belong to the default or shifted group.
It is also likely that you may want to ‘open’ out some of the Phat Chords. I have left these in their minimum span configuration.
Slash Chords are not catered for on this unit, but a separate pedal-board is being developed which could be used to provide this facility.

Chord Numbers 0-7:default; 8-15:shifted; X:unassigned. ‘1′ represents note, ‘+12′ represents note an octave above.

Inversions available for all, but only shown on major chords

« Intervals/Notes »

Name Chord No. Root 1 2 3 4 5 6 7 8 9 10 11 Number of Notes Example C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B

Triads

maj 0

1

0 0 0 1 0 0 1 0 0 0 0

3

CMaj 1

0

0

0

1 0

0

1

0

0 0

0

maj (invroot) 0

+12

0 0 0 1 0 0 1 0 0 0 0

3

CMaj (invroot) +12

0

0

0

1 0

0

1

0

0 0

0

maj (inv2) 0

1

0 0 0 +12 0 0 1 0 0 0 0

3

CMaj (inv2) 1

0

0

0

+12 0

0

1

0

0 0

0

maj (inv3) 0

1

0 0 0 1 0 0 +12 0 0 0 0

3

CMaj (inv3) 1

0

0

0

1 0

0

+12

0

0 0

0

min 5

1

0 0 1 0 0 0 1 0 0 0 0

3

Cmin 1

0

0

1

0 0

0

1

0

0 0

0

dim (o) 15

1

0 0 1 0 0 1 0 0 0 0 0

3

Cdim (Co) 1

0

0

1

0 0

1

0

0

0 0

0

aug (+) 9

1

0 0 0 1 0 0 0 1 0 0 0

3

Caug (C+) 1

0

0

0

1 0

0

0

1

0 0

0

sus (sus4) 11

1

0 0 0 0 1 0 1 0 0 0 0

3

Csus (Csus4) 1

0

0

0

0 1

0

1

0

0 0

0

sus2 X

1

0 1 0 0 0 0 1 0 0 0 0

3

Csus2 1

0

1

0

0 0

0

1

0

0 0

0

Tetra Chords
7 2

1

0 0 0 1 0 0 1 0 0 1 0

4

C7 1

0

0

0

1 0

0

1

0

0 1

0

7b5 13

1

0 0 0 1 0 1 0 0 0 1 0

4

C7b5 1

0

0

0

1 0

1

0

0

0 1

0

Maj7 4

1

0 0 0 1 0 0 1 0 0 0 1

4

CMaj7 1

0

0

0

1 0

0

1

0

0 0

1

min7 7

1

0 0 1 0 0 0 1 0 0 1 0

4

Cmin7 1

0

0

1

0 0

0

1

0

0 1

0

dim7 (o7) X

1

0 0 1 0 0 1 0 0 1 0 0

4

Cdim7 (Co7) 1

0

0

1

0 0

1

0

0

1 0

0

aug7 (+7) 10

1

0 0 0 1 0 0 0 1 0 1 0

4

Caug7 (C+7) 1

0

0

0

1 0

0

0

1

0 1

0

sus7 (7sus4) 12

1

0 0 0 0 1 0 1 0 0 1 0

4

Csus7 (C7sus4) 1

0

0

0

0 1

0

1

0

0 1

0

6 1

1

0 0 0 1 0 0 1 0 1 0 0

4

C6 1

0

0

0

1 0

0

1

0

1 0

0

min6 6

1

0 0 1 0 0 0 1 0 1 0 0

4

Cmin6 1

0

0

1

0 0

0

1

0

1 0

0

Phat Chords

9 3

1

0 +12 0 1 0 0 1 0 0 1 0

5

C9 1

0

+12

0

1 0

0

1

0

0 1

0

Maj9 X

1

0 +12 0 1 0 0 1 0 0 0 1

5

CMaj9 1

0

+12

0

1 0

0

1

0

0 0

1

min9 8

1

0 +12 1 0 0 0 1 0 0 1 0

5

Cmin9 1

0

+12

1

0 0

0

1

0

0 1

0

7b9 14

1

+12 0 0 1 0 0 1 0 0 1 0

5

C7b9 1

+12

0

0

1 0

0

1

0

0 1

0

I append a code-snippet here as an example of how each chord is built up. ‘notes’ is an array of up to 8 notes, the 1st entry of which, notes[0], holds the root keynote.

//////////////////////////////////////////////////////////////////
// Dim9
void SubDim9(void)
{
	notes[1] = notes[0] + 3;
	notes[2] = notes[0] + 6;
	notes[3] = notes[0] + 9;
	numofnotes = 4;
}


The sequence of 4 notes is subsequently output via MIDI OUT.

Chord Controller Board

The chords are produced by scanning a matrix of switches to produce a unique value for each chord comprising the key value of the chord (eg. C#) and the chord value (e.g. min7). The switch matrix is scanned by the matrix decoder board, (see part 1: MIDI Chord Button Keyboard Using PIC Microcontroller) and when a switch close is detected, a TTL ‘low’ is placed on connector SV7 which is connected to RB1 of the PIC Microcontroller on the Controller board, the schematic of which is shown below.
Note that this controller is dual-purpose. For the chord-controller, IC2 – the CD4073 is not required, and it should not be installed.
On the right, SV1 and SV2 carry the address lines to the matrix decoder, Power is also supplied to the matrix encoder board via SV4. The MIDI OUT signals are provided on SV9, whilst the command hexpad, RESET, and LED connections are via X3,SV3, SV6 and SV8.
Both pitch wheel and velocity/volume control are provided for, and these interface to SV10 and SV11. A connector pin on SV8 allows for the connection of a chord-shift switch.
Note that the Analog channels AN0-AN5, and the digital pins associated with these are not used in the design, but code is installed to read each of the analog signals and may be used to provide extra controller interfaces if desired.

PIC Chord Controller Schematic V.04

PIC Chord Controller Schematic V.04

Command Hexpad Board

Below is shown the command keypad comprising the external processor RESET switch, hexpad and 3 indicator LEDs, together with a suggested layout.

Command Keypad Schematic

Command Keypad Schematic

Suggested Command Panel Layout

Suggested Command Panel Layout

Mapping Commands
As an example of how I mapped my hexpad to control the unit (and the connected synth) I append a code-snippet here of the main interpreter.
First of all the hexpad keyvalue is translated from it’s raw scan value then processed. The digit keys 0-9 are passed on without further action except for designating the keytype as DECIMAL_VAL.
The left-hand-side and bottom-row peripheral keys (except for zero) are assigned specific functions/roles, and control passed to a relevant routine as required.
I will discuss various code routines later.

///////////////////////////////////////////////////////////
// Interpret and act (if required) on the last key pressed
// The key type is put in keytype
// The equivalent value is put in keyvalue
// Carry out any required action
///////////////////////////////////////////////////////////
void InterpretKeyPress(void)
{
	keyvalue = TranslateKey(hexpadkey);
	switch (keyvalue)
	{
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
				keytype = DECIMAL_VAL; // digit
			break;
		case 10: keytype = FUNC_VAL; // bottom left
				if (interpret_level == 0)
				{
					interpret_level++; // block recursion
					DoEditRoutines();
					interpret_level--;
				}
			break;
		case 15: keytype = CHANNEL_VAL; // top left
				if (interpret_level == 0)
				{
					interpret_level++; // block recursion
					AssignMIDIChannel();
					interpret_level--;
				}
			break;
		case 14: keytype = PROGRAM_VAL;  //next top left
				if (interpret_level == 0)
				{
					interpret_level++; // block recursion
					ProgramChange();
					interpret_level--;
				}
			break;
		case 13: keytype = PARAM_VAL;   // (BANk) next to bottom left
				if (interpret_level == 0)
				{
					interpret_level++; // block recursion
					MIDICommand();
					interpret_level--;
				}
			break;
		case 11: keytype = CLEAR_VAL;  // bottom 2nd from left
			break;
		case 12: keytype = DEFAULT_VAL; // bottom far right
			break;
	}

}

Top and bottom foil views of both the command hexpad and Chord Controller Processor board are given below.

Chord Controller Processor Board Top View

Chord Controller Processor Board Top View


Chord Controller Processor Board Bottom Foil

Chord Controller Processor Board Bottom Foil


Command Hexpad Board Top Foil

Command Hexpad Board Top Foil


Command Hexpad Board Bottom Foil

Command Hexpad Board Bottom Foil

Finally, I append a few more photos of the prototype. The concluding article will discuss construction of the chord matrix, remaining interfaces and provide all resources, including Eagle Schematic and Printed Circuit layouts, Front Panel layouts for the chord and hexpad matrixes, and the full source code and MPLAB project, together with ready-to-go binaries.
The source-code supplied is tailored to my two DB60XG synths, and as such provides an easy-to-select control of all of the XG voices.

Prototype front/top view

Prototype front/top view


Pitch Wheel inside detail

Pitch Wheel inside detail


Chord Shift switch detail bottom

Chord Shift switch detail bottom


Chord Shift switch detail top

Chord Shift switch detail top

Copy the code below to your web site.
x 
  • Share/Bookmark
PDF Download    Send article as PDF   

You must be logged in to post a comment.