File: MidiRecord.java

package info (click to toggle)
pilot-link 0.12.5-dfsg-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 6,868 kB
  • ctags: 5,811
  • sloc: ansic: 53,153; sh: 10,459; java: 2,584; perl: 2,247; python: 1,044; makefile: 991; yacc: 662; cpp: 551; xml: 39
file content (81 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Created on 16.03.2004
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.gnu.pilotlink;


/**
 * @author stephan
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class MidiRecord extends Record {
	private byte midi[];
	private String name;

	private static String id="PMrc";
	
	public MidiRecord() {
		midi=new byte[1]; //avoid nullpointer exception
		name="";
	}
	/* (non-Javadoc)
	 * @see org.gnu.pilotlink.Record#getBuffer()
	 */
	public byte[] getBuffer() {
		// TODO Auto-generated method stub
		int offset=name.length()+1+6;
		byte buf[]=new byte[offset+midi.length];
		setStringAt(buf,id,0);
		buf[4]=(byte)offset;
		buf[5]=0;
		setStringAt(buf,name,6);
		for (int i=0; i<midi.length;i++) {
			buf[offset+i]=midi[i];
		}
		return buf;
	}
	
	public void setName(String n) {
		name=n;
		setSize(midi.length+2+id.length()+name.length()+1);
	}
	public String getName() {
		
		return name;
	}
	public void setMidi(byte b[]) {
		midi=b;
		setSize(midi.length+2+id.length()+name.length()+1);
	}
	public byte[] getMidi() {
		return midi;
	}

	/* (non-Javadoc)
	 * @see org.gnu.pilotlink.Record#setBuffer(byte[])
	 */
	public void setBuffer(byte[] buf) {
		// TODO Auto-generated method stub
		name=getStringAt(buf,6);
		int offset=buf[4];
		midi=new byte[buf.length-offset];
		for (int i=0;i<midi.length;i++) {
			midi[i]=buf[i+offset];
		}
		setSize(buf.length);
	}

	/**
	 * @param r
	 */
	public MidiRecord(Record r) {
		super(r);
	}

	
}