[go: up one dir, main page]

Menu

[r10]: / trunk / APIs / ren / util / PO.java  Maximize  Restore  History

Download this file

211 lines (176 with data), 5.4 kB

  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
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
* Created on 30/05/2005
*
* @author Rene Wooller
*/
package ren.util;
import com.lemu.music.LPart;
import jm.music.data.Part;
/**
* @author wooller
*
*30/05/2005
*
* Copyright JEDI/Rene Wooller
*
*/
public class PO {
public static void p(double [] d) {
System.out.print(" = { ");
for(int i=0; i< d.length; i++) {
System.out.print(d[i] + ", ");
}
System.out.println("}");
}
public static void p(double [] d, int dec) {
p(d, dec, "\n");
}
public static void p(double [] d, int dec, String ps) {
System.out.print(" = { ");
for(int i=0; i< d.length; i++) {
StringBuffer dp = new StringBuffer(Double.toString(d[i]));
String out = new String();
if(dp.charAt(dp.length()-3) == 'E') {
//PO.p("eee ");
StringBuffer ndp = new StringBuffer(dp.substring(0, dec-3));
ndp.append(dp.substring(17, 21));
out = ndp.toString();
} else if(dp.length() > dec){
//PO.p("eee ");
out = dp.substring(0, dec+1);
} else {
//PO.p("eee ");
while (dp.length() <= dec) {
dp.append('0');
}
out = dp.toString();
}
System.out.print(out + ", ");
}
System.out.print("} " + ps);
}
/**
*
* @param s
* @param p
* @param type 0 - just pitch, 1 pitch and start times
*/
public static void p(String s, Part p, int type) {
System.out.println("\n" + s);
if(type == 0) {
for(int i=0; i<p.size(); i++) {
System.out.print(
p.getPhrase(i).getNote(0).getPitch() + ", ");
}
} else if (type == 1) {
for(int i=0; i<p.size(); i++) {
System.out.print(" " + ((int)(p.getPhrase(i).getStartTime()/0.0001))*0.0001 + ":" +
p.getPhrase(i).getNote(0).getPitch() + ", ");
}
} else if (type == 2) {
for(int i=0; i<p.size(); i++) {
System.out.print("s " + p.getPhrase(i).getStartTime() + " p:" +
p.getPhrase(i).getNote(0).getPitch() + " D: " + p.getPhrase(i).getNote(0).getDuration()+ ", ");
}
}
System.out.print("\n");
}
public static void p(String s, Object [] o) {
System.out.println(s);
for(int i=0; i< o.length; i++) {
p(o[i].toString());
}
}
public static void p(String s, LPart [] lp) {
System.out.println(s);
for(int i=0; i< lp.length; i++) {
if(lp[i] == null)
break;
p(" i = " + i, lp[i].getPart(), 1);
}
}
public static void p(Object o) {
System.out.println(o.toString());
}
public static void p(int [] d) {
System.out.print(" = { ");
for(int i=0; i< d.length; i++) {
System.out.print(d[i] + ", ");
}
System.out.println("}");
}
public static void p(int [][]d) {
//System.out.println("l = " + d.length);
for(int i=0; i<d.length; i++) {
//System.out.println(" sub l = " + d[i].length);
if(d[i] == null)
System.out.print(" " + i + " null \n");
else {
System.out.print(" " + i +"[");
for(int j = 0; j< d[i].length; j++) {
System.out.print("," + d[i][j] + " ");
}
System.out.print("],\n");
}
}
System.out.print("}");
}
public static void p(String out, double [] d) {
System.out.print(out);
p(d);
}
public static void p(String out, double [] d, int dec) {
System.out.print(out);
p(d, dec);
}
public static void p(String out, double [] d, int dec, String ps) {
System.out.print(out);
p(d, dec, ps);
}
public static void p(String out, int [] d) {
System.out.print(out);
p(d);
}
public static void p(String out, int [][] d) {
System.out.print(out);
p(d);
}
public static void p(String out, double [][]d) {
System.out.print(out + "\n {");
for(int i=0; i<d.length; i++) {
System.out.print(" " + i +"[");
for(int j = 0; j< d[i].length; j++) {
System.out.print("," + d[i][j] + " ");
}
System.out.print("],\n");
}
System.out.print("}");
}
public static void p(String out) {
System.out.println(out);
}
public static void isn(Object o) {
if(o == null)
p("null");
else
p("not null");
}
public static void p(String [] s) {
for(int i=0; i<s.length; i++) {
p(" = {" + s[i] + ", ");
}
}
/**
* repeats the given string the given number of times
* @param string to be repeated
* @param i number of times
* @return
*/
public static String r(String string, int i) {
StringBuffer sb = new StringBuffer();
for(int j=0; j<i; j++) {
sb.append(string);
}
return sb.toString();
}
}