-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recognize track type #358
Comments
You can fully rely on the midi information to identify whether a track is a percussion tab and which instrument it is. From a playback perspective the midi channel value 9 is considered the percussion channel. A small detail might be that the channels are 0 indexed, meaning that channel value 9 is the 10th channel and by this a percussion channel. The program defines the midi instrument. See lists like on Wikipedia for details to map them to instrument groups: https://en.wikipedia.org/wiki/General_MIDI#Program_change_events The You can build easily something like: function getTrackType(track) {
const pi = track.playbackInfo;
if(pi.primaryChannel === 9) {
return 'Percussion';
} else if(pi.program <= 7) {
return 'Piano';
} else if(pi.program <= 15) {
return 'Chromatic Percussion';
} else if(pi.program <= 23) {
return 'Organ';
} else if(pi.program <= 31) {
return 'Guitar';
} else if(pi.program <= 39) {
return 'Bass';
} else if(pi.program <= 47) {
return 'Strings';
} else if(pi.program <= 55) {
return 'Ensemble';
} else if(pi.program <= 63) {
return 'Brass';
} else if(pi.program <= 71) {
return 'Reed';
} else if(pi.program <= 79) {
return 'Pipe';
} else if(pi.program <= 87) {
return 'Synth Lead';
} else if(pi.program <= 95) {
return 'Synth Pad';
} else if(pi.program <= 103) {
return 'Synth Effects';
} else if(pi.program <= 111) {
return 'Ethnic';
} else if(pi.program <= 119) {
return 'Percussive';
} else if(pi.program <= 127) {
return 'Sound effects';
}
return 'Unknown';
} |
Thanks, this sample works perfect |
The question arose, how to map MIDI program value to a standart General MIDI instrument name. |
Question
Is there a way to recognize is a track a guitar/keyboard/bass/percussion/other?
Your environment
The text was updated successfully, but these errors were encountered: