05 May 2001

MKCC154.HEX : new program for MKC (MIDI Keyboard Controller), 
replacing MKCC2.HEX, MKCC151.HEX and MKCC152.HEX.
---------------------------------------------

Where is this file from?
-----------------------
This file is part of MKC (MIDI Keyboard Controller) project.
You can find whole project at MKC homepage: 
www.geocities.com/jdpetkov/hardware


What is this for?
-----------------------
This HEX file replaces the three previous versions of MKC firmware distributed
as MKCC2.HEX, MKCC151.HEX and MKCC152 files maintaining all their functionality. 
New functions are added for this (Key11 - Key16). 
For more information about these functions see NOTES section at the 
bottom of this document.

Thus, user is now able to control at runtime:
MIDI channel, 
Starting octave, 
Starting note (Transposition),
Velocity default value,
AllNotesOff event,
NoteOff event,
MIDI Program (Preset,Patch),
MIDI Bank.

The MIDI channel, Transposition, AllNotesOff and NoteOff settings are stored and 
used until next change. This is possible due to PIC ability to store and hold a 
number of data bytes in its non-violative EEPROM memory.
The MIDI Preset and MIDI Bank settings are not saved and reset at 0 on every 
device reset.


How to use it?
------------------------
- First, you should change JP1 jumper (as shown on schematic) with any kind of
  momentary action button. It will be called 'PROGRAM button'.
- Second, you should download MKCC154.HEX file wich contains the new PIC program.
- Third, you should burn this program into PIC. At this moment you keyboard is
  almost ready to work. Default settings are:

MIDI channel      : 1        (MIDI channel number range is 1..16)
Starting octave   : 4        (Octave number range is 1..11)
Starting note     : 36       (C-Do, note number range is 0..127)
Velocity value    : 127      (Velocity value range is 0..127)
AllNotesOff event : Disabled (possible values are Enabled/Disabled)
NoteOff event     : Enabled  (possible values are Enabled/Disabled)
MIDI Preset       : 0
MIDI Bank         : 0

To adjust these values you should press PROGRAM button, and while holding it down,
press once or more times some of first (leftmost) 16 keys on your keyboard. 
Here is the table of control keys functions:

Key#	Command				Memorized	Note
----------------------------------------------------------------------------------
1	MIDI channel -1			Yes		Default MIDI channel	
2	MIDI channel +1			Yes		Default MIDI channel
3	Starting octave -1		Yes		Default octave
4	Starting octave +1		Yes		Default octave
5	Starting note -1		Yes		Default note 
6	Starting note +1		Yes		Default note 
7	Velocity -1			Yes		Default velocity 
8	Velocity +1			Yes		Default velocity 
9	AllNotesOff message Disabled	Yes	        Default ANOff status
10	AllNotesOff message Enabled	Yes		Default ANOff status
11      NoteOn(Velocity=0) is generated Yes             Default NoteOff message
12      NoteOff is generated            Yes             Default NoteOff message
13	MIDI Program -1			No		Change Program&Bank 
14	MIDI Program +1			No 		messages are trans-
15	MIDI Bank -1			No		mitted on keyboard  
16	MIDI Bank +1			No		default MIDI channel 

Some of parameters you change this way (see table above) become default until 
you change it next way. Other are reset to 0 during every device reset.
You may experiment new values at runtime. 

EXAMPLES:
All examples consider that keyboard is connected to PC Joystick port and PC is on.
In order to hear changes you make, proper software (MIDIkey, MIDImon, MIDIox, 
Cakewalk etc.) must run on the PC. You can download my 'midikey.exe' or 
M$ 'midimon.exe' from MKC controller homepage. During adjustments, every time when 
changing some setting, you will hear sound, generated thru current MIDI channel 
and having new settings.

1. You want to use your keyboard to generate percussive sounds:
   Percussive sounds are placed on MIDI channel #10 (GM - General MIDI). 
   This means you have to change you keyboard's MIDI channel to #10.
   What to do:
   - press and hold down PROGRAM button  
   - press Key2 as many times as needed to go to MIDI channel#10. 
   - release PROGRAM button

2. You want to transpose your keyboard a octave down. 
   What to do:
   - press and hold down PROGRAM button  
   - press Key3 once
   - release PROGRAM button

3. Your keyboard first key is F (Fa) starting while controller's 
   default starting note is #36 (C-Do), so you want to adjust 
   controller's starting note to F (Fa).
   What to do:
   - press and hold down PROGRAM button  
   - press Key5 7 (seven) times to go to lower F(Fa) - MIDI note #29 
     OR press Key6 5 (five) times to go to upper F(Fa) - MIDI note #41
   - release PROGRAM button
   
4. You want to change default keyboard Velocity.
   What to do:
   - press and hold down PROGRAM button  
   - press Key7 as many times as needed to decrease Velocity
     OR press Key8 as many times as needed to increase Velocity
   - release PROGRAM button  

5. You want to enable/disable 'AllNotesOff' message to be generated 
   when all keys are released.
   What to do:
   - press and hold down PROGRAM button  
   - press Key9 if you want to disable 'AllNotesOff' message
     OR press Key10 if you want to enable 'AllNotesOff' message
   - release PROGRAM button    

6. You want to change 'NoteOff' message type. Two types are possible:
   standard 'NoteOff' mesage with default Velocity, or 'NoteOn' message
   with Velocity=0.
   What to do:
   - press and hold down PROGRAM button  
   - press Key11 if you want to use standard 'NoteOff' message
     OR press Key12 if you want to use 'NoteOn' with Velocity=0 message
   - release PROGRAM button    

7. You want to change MIDI Program (preset)
   What to do:
   - press and hold down PROGRAM button  
   - press Key13 if you want to decrement MIDI Program number
     OR press Key14 if you want to increment MIDI Program number
   - release PROGRAM button    

8. You want to change MIDI Bank
   What to do:
   - press and hold down PROGRAM button  
   - press Key15 if you want to decrement MIDI Bank number
     OR press Key16 if you want to increment MIDI Bank number
   - release PROGRAM button    

NOTES:
   MIDI channel, Velocity, Program and Bank are open (linear) range settings. 
   When increasing such setting you reach it's maximum value, next increase 
   will not take effect. 
   When decreasing such settingthe you reach it's minimal value, next decrease
   will not take effect.

   Starting octave and Starting note are closed (circular) range settings. 
   When increasing such setting you reach it's maximum value, next increase 
   will set it to range staring value (minimal value). 
   When decreasing such setting you reach it's minimal value, next decrease
   will set it to range ending value (maximal value).

   Enabling/disabling AllNotesOff event is supported for compatibility with some 
   cheap soundcards (mine Yamaha for example). Such cards ocasionally miss 
   messages generated by controller (especially 'NoteOff' message). This causes 
   some notes to 'hang' (to continue even after the proper key was released). 
   To avoid this effect designed all versions MKCC154.HEX is able to generate 
   'AllNotesOff' event after the last key is released, breaking 'hanging notes'. 
   From the other side, if user wants to use keyboard controller 
   along with another keyboard controllers sharing the same MIDI channel, generating 
   'AllNotesOff' message by the first keyboard controller should break notes 
   generated by the second one.
   For this reason, these versions allow user to decide wether to use 
   'AllNotesOff' or not. The main rule for usng it is: enable it only if you have 
   problems with 'hanging notes' and disable it if there are no such problems.

   Selecting 'NoteOff' message genetarion mode is supported for compatibility with
   some soundcards (for example Creative AWE) which don't accept standard MIDI
   message 'NoteOff'. Instead, they accept 'NoteOn' message with Velocity byte 
   set to 0. Many keyboards (especially Velocity non-sensitive) work this way.
   User can select which kind of NoteOff message should be generated at key 
   releasing.
 
   Changing Bank automatically generates two consequent MIDI messages: 
   'BankSelect' and 'ProgramChange' due to next fact:
   When a 'BankSelect' is received, the MIDI module doesn't actually change 
   to a patch in the new bank. Rather, the Bank Select value is simply stored by 
   the MIDI module without changing the current patch. Whenever a subsequent 
   'ProgramChange' is received, the stored Bank Select is then utilized to switch 
   to the specified patch in the new bank.

 
Jordan D.Petkov,
j.d.petkov@mailcity.com
www.geocities.com/jdpetkov