private void buildOSCByteBuffer(int c) {
    	switch(oscRxNextOp)
    	{
    	case OSC_RXOP_WAITFORSTART:
    		if(c==0xBE) {
				oscRxNextOp = OSC_RXOP_READSIZE;
			}
    		break;
    	case OSC_RXOP_READSIZE:
    		oscRxMsgSize = c;
			oscRxReadBytes = 0;
			oscRxData = new byte[oscRxMsgSize+1];
			oscRxNextOp = OSC_RXOP_READDATA;
    		break;
    	case OSC_RXOP_READDATA:
    		try {
    		oscRxData[oscRxReadBytes++] = (byte)c;
    		if(oscRxReadBytes == oscRxMsgSize) {
    		oscRxData[oscRxReadBytes] = 0; //terminate string
    			oscRxNextOp = OSC_RXOP_READCHKSUM;
    		}
    		} catch (java.lang.ArrayIndexOutOfBoundsException e) {
    			//something went wrong (i.e., got an erroneous 0xBE- throw the message away
    			oscRxNextOp = OSC_RXOP_WAITFORSTART;
    		}
    		break;
    	case OSC_RXOP_READCHKSUM:
    		short oscRxChecksum = 0;
			for (int i=0; i<oscRxMsgSize; i++) {
				oscRxChecksum=(short)((oscRxChecksum + (short)(0x000000FF &(int)oscRxData[i]))% 256);
			}
			if(oscRxChecksum == c) {
				// checksum matched and we're done with this msg
				// -> fire off registered listeners
				
				OSCPacket oscPacket = converter.convert(oscRxData,oscRxMsgSize);
				//System.out.println("received valid OSC message.");
				dispatcher.dispatchPacket(oscPacket);
				oscRxNextOp = OSC_RXOP_WAITFORSTART;
			} else {
				// mismatch - throw this message away
				System.err.println("Received corrupted OSC message: calculated "+(int)oscRxChecksum+", should have been: "+(int)c);
				oscRxNextOp = OSC_RXOP_WAITFORSTART;
			}
    		break;
    	}
    }