@@ -87,25 +87,34 @@ class MidiManager {
8787 }
8888
8989 registerInput ( note , callback ) {
90- console . log ( `${ note } registering` )
91- const midiNote = new MidiNote ( note ) ;
92- let chanCb = this . _channelCallbacks [ midiNote . channel ] ;
93- if ( ! chanCb ) {
94- chanCb = { } ;
95- this . _channelCallbacks [ midiNote . channel ] = chanCb ;
96- }
97- let typeCb = chanCb [ midiNote . type ] ;
98- if ( ! typeCb ) {
99- typeCb = [ ] ;
100- chanCb [ midiNote . type ] = typeCb ;
101- }
102- let cb = typeCb [ midiNote . byte1 ] ;
103- if ( ! cb ) {
104- cb = [ ] ;
105- typeCb [ midiNote . byte1 ] = cb ;
106- this . _setupListenerOnChannelForType ( midiNote . channel , midiNote . type ) ;
90+ try {
91+ if ( ! note || ! callback ) return ;
92+ const notes = note . split ( ',' ) . map ( item => item . trim ( ) ) ;
93+ for ( note of notes ) {
94+ console . log ( `${ note } registering` ) ;
95+ const midiNote = new MidiNote ( note ) ;
96+ let chanCb = this . _channelCallbacks [ midiNote . channel ] ;
97+ if ( ! chanCb ) {
98+ chanCb = { } ;
99+ this . _channelCallbacks [ midiNote . channel ] = chanCb ;
100+ }
101+ let typeCb = chanCb [ midiNote . type ] ;
102+ if ( ! typeCb ) {
103+ typeCb = [ ] ;
104+ chanCb [ midiNote . type ] = typeCb ;
105+ }
106+ let cb = typeCb [ midiNote . byte1 ] ;
107+ if ( ! cb ) {
108+ cb = [ ] ;
109+ typeCb [ midiNote . byte1 ] = cb ;
110+ this . _setupListenerOnChannelForType ( midiNote . channel , midiNote . type ) ;
111+ }
112+ cb . push ( [ midiNote , callback ] ) ;
113+ }
114+ } catch ( err ) {
115+ console . error ( err ) ;
116+ return ;
107117 }
108- cb . push ( [ midiNote , callback ] ) ;
109118 }
110119
111120 // Method for components to unregister their inputs
0 commit comments