@@ -30,15 +30,20 @@ public MidiMapper( Object theObject ) {
3030 welcome ( );
3131 }
3232
33- public final boolean test ( String theDevice ) {
33+ public final AssignedDevice test ( String theDevice ) {
3434 return connect ( theDevice , new TestReceiver ( theDevice ) );
3535 }
3636
37- public final boolean connect ( int theDeviceId , Receiver ... theReceivers ) {
37+ public final AssignedDevice connect ( int theDeviceId , Receiver ... theReceivers ) {
3838 out ( "connect to id not yet implemented" );
39- return false ;
39+ return null ;
4040 }
41-
41+
42+ public final AssignedDevice connect ( int theDeviceId ) {
43+ out ( "connect to id not yet implemented" );
44+ return null ;
45+ }
46+
4247 public final AssignedDevice connect ( String theDevice ) {
4348 try {
4449 MidiDevice device ;
@@ -54,6 +59,32 @@ public final AssignedDevice connect( String theDevice ) {
5459 }
5560 }
5661
62+ public final AssignedDevice connect ( String theDevice , Receiver ... theReceivers ) {
63+
64+ try {
65+ MidiDevice device ;
66+ device = MidiSystem .getMidiDevice ( getMidiDeviceInfo ( theDevice , false ) );
67+ device .open ( );
68+
69+ for ( Receiver receiver : theReceivers ) {
70+ Transmitter conTrans = device .getTransmitter ( );
71+ conTrans .setReceiver ( receiver );
72+ }
73+ return new AssignedDevice ( parent , device );
74+ } catch ( MidiUnavailableException e ) {
75+ // TODO Auto-generated catch block
76+ e .printStackTrace ( );
77+ return new AssignedDevice ( parent , null );
78+ } catch ( NullPointerException e ) {
79+ log .info ( String .format ( "No Midi device ( %1s ) is available." , theDevice ) );
80+ return new AssignedDevice ( parent , null );
81+ }
82+ }
83+
84+ private final void welcome ( ) {
85+ log .info ( String .format ( "midimap, %1s" , VERSION ) );
86+ }
87+
5788 /* theData1 corresponds to the id of the midi message, theData2 is a midi value between 0-127 */
5889
5990 public MidiMapper send ( int theChannel , int theData1 , int theData2 ) {
@@ -81,32 +112,6 @@ public MidiMapper send( Receiver theReceiver , int theCommand , int theChannel ,
81112 return this ;
82113 }
83114
84- public final boolean connect ( String theDevice , Receiver ... theReceivers ) {
85-
86- try {
87- MidiDevice device ;
88- device = MidiSystem .getMidiDevice ( getMidiDeviceInfo ( theDevice , false ) );
89- device .open ( );
90-
91- for ( Receiver receiver : theReceivers ) {
92- Transmitter conTrans = device .getTransmitter ( );
93- conTrans .setReceiver ( receiver );
94- }
95- } catch ( MidiUnavailableException e ) {
96- // TODO Auto-generated catch block
97- e .printStackTrace ( );
98- return false ;
99- } catch ( NullPointerException e ) {
100- log .info ( String .format ( "No Midi device ( %1s ) is available." , theDevice ) );
101- return false ;
102- }
103- return true ;
104- }
105-
106- private final void welcome ( ) {
107- log .info ( String .format ( "midimap, %1s" , VERSION ) );
108- }
109-
110115 static public void list ( ) {
111116 find ( "" );
112117 }
@@ -133,10 +138,6 @@ static public void find( final String thePattern ) {
133138 log .info ( msg .toString ( ) );
134139 }
135140
136- public MidiNote assign ( int theNote ) {
137- return new MidiNote ( parent , theNote );
138- }
139-
140141 static public Object invoke ( final Object theObject , final String theMember , final Object ... theParams ) {
141142
142143 Class [] cs = new Class [ theParams .length ];
0 commit comments