public void close() {
       // System.out.println("MIDI close called");

        if(state == CLOSED) return;
        if(state == STARTED) {
        	deallocate();
        }
        closeImpl();
        state = CLOSED;
        if(autoNotify){
        	startListenerNotification(PlayerListener.CLOSED, null);
        }
    }