1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.nativemidi.cts; 18 19 public class NativeMidiMessage { 20 public static final int AMIDI_PACKET_SIZE = 1024; 21 public static final int AMIDI_PACKET_OVERHEAD = 9; 22 public static final int AMIDI_BUFFER_SIZE = AMIDI_PACKET_SIZE - AMIDI_PACKET_OVERHEAD; 23 24 public int opcode; 25 public byte[] buffer = new byte[AMIDI_BUFFER_SIZE]; 26 public int len; 27 public long timestamp; 28 public long timeReceived; 29 30 public NativeMidiMessage() {} 31 32 public String toString() { 33 StringBuilder sb = new StringBuilder(); 34 sb.append("{opcode:" + opcode + " [len:" + len + "|"); 35 for(int index = 0; index < len; index++) { 36 sb.append("0x" + Integer.toHexString(buffer[index] & 0x00FF)); 37 if (index < len - 1) { 38 sb.append(" "); 39 } 40 } 41 sb.append("] timestamp:" + Long.toHexString(timestamp)); 42 43 return sb.toString(); 44 } 45 46 }