The Program Change Event is used to change which program (instrument/patch) should be played on the MIDI channel. The controller number specifies which control is changing and the controller value defines it's new setting.Ĭlick here for a list of the defined MIDI controller types. There are 128 controllers which define different attributes of the channel including volume, pan, modulation, effects, and more. The Controller Event signals the change in a MIDI channels state. Note Aftertouch is used for extra expression of particular notes, often introducing or increasing some type of modulation during the instrument's sustain phase Controller Event
#Audio to midi note number full#
The note number of which key's pressure is changing and the aftertouch value which specifies amount of pressure being applied (0 = no pressure, 127 = full pressure). The Note Aftertouch Event is used to indicate a pressure change on one of the currently pressed MIDI keys. The note number is normally used to specify the instruments musical pitch and the velocity is usually used to specify the instruments playback volume and intensity. The note number that specifies which of the 128 MIDI keys is being played and the velocity determines how fast/hard the key is pressed. The Note On Event is used to signal when a MIDI key is pressed. The note number is normally used to specify which previously pressed key is being released and the velocity is usually ignored, but is sometimes used to adjust the slope of an instrument's release phase. The note number specifies which of the 128 MIDI keys is being played and the velocity determines how fast/hard the key was released. These events have two parameters identical to a Note On event. The Note Off Event is used to signal when a MIDI key is released. Below is a detailed description of each type of MIDI event and how it is used. Each MIDI Channel Event consists of a variable-length delta time (like all track events) and a two or three byte description which determines the MIDI channel it corresponds to, the type of event it is and one or two event type specific values. You should also use Exceptions instead of returning -1 this way you can differentiate between a malformatted string ("abbc123") and a value out of range ("B#9").įinally, If I remember correctly, there is an offset in MIDI pitch (like C0 isn't 0 but 12).Musical control information such as playing a note or adjusting a MIDI channel's modulation value are defined by MIDI Channel Events. You could create a Map (like "C" is mapped to 0, "D" to 2, etc.) or use an enumeration. Depending on your input format this doesn't work since Cb is a valid note but there is no array index -1. However, using the array index as a mapping isn't the best approach in my opinion.
Return Character.getNumericValue(oct) * 12 + i + accidental // !! read the documentation of Character#getNumericValue !! Return -1 // you should really use Exceptions instead Int accidental = 0 // initialize with default value 0 (i.e. So with the least modification of your code: You can handle the accidentals separately.
Is there a way to do this without tearing my method apart? However, I would also like to be able to use convertToPitch() with the alternate note value (Db becomes C#, etc.) for each note with an alternate name. Return Character.getNumericValue(oct) * 12 + i Īnd it works just great. Find the corresponding note in the array. Otherwise, it must be a two-char note. If the length is two, then grab the symbol and number. Public static int convertToPitch(String note) I have written the following method to convert notes (with the octave appended to the end) to the corresponding MIDI pitch: // Converts a note string (MUST HAVE OCTAVE) to an integer pitch.