the file will play anywhere i try to, so i'm not sure if it's a problem with encoding, but doesn't seem so. any feedback welcome.
import ddf.minim.*;
Minim minim;
void setup() {
size (200, 200);
minim = new Minim(this);
AudioPlayer aiffPlayer = minim.loadFile("1.aif");
}
returns
==== JavaSound Minim Error ====
==== IOException: Resetting to invalid mark
Exception in thread "Animation Thread" java.lang.NullPointerException
at ddf.minim.javasound.JSMinim.getAudioRecordingStream(JSMinim.java:201)
at ddf.minim.Minim.loadFile(Minim.java:357)
at ddf.minim.Minim.loadFile(Minim.java:341)
at aiffMinim.setup(aiffMinim.java:30)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
i'm working with a dataset in the form of several directories of *.csv (semi-comma separated, actually, for some reason) files, which i would like to process and add to a mysql db. yesterday,
mr. data converter came to my attention (praise twitter!) and a few tweaks to the code allowed me to use the semi-comma delimited text, via copy+paste.
this is nice, but i wondered if i could port the code (javascript) to processing so that i could recursively go through the files and add tables. while most of it is working (the syntax at least), a couple of issues are keeping me from actually testing this on the bunch of files i mentioned above.
below is the code i have thus far (apart from SQLibrary and boilerplate code for loading the files), and below that, the questions.
int columnCount = split(lines[0], delimiter).length;
String[] columnTypes = new String[columnCount];
int numRowsToTest = columnCount;
float threshold = 0.5;
for (int i=0; i < columnCount; i++) {
int floatCount = 0;
int intCount = 0;
for (int j=0; j < numRowsToTest; j++) {
/*if (CSVParser.isNumber(lines[j][i])) {
intCount++;
if (String(lines[j][i]).indexOf(".") > 0) {
floatCount++;
}
}*/
}
if ((intCount / numRowsToTest) > threshold) {
if (floatCount > 0) {
columnTypes[i] = "float";
}
else {
columnTypes[i] = "int";
}
}
else {
columnTypes[i] = "string";
}
}
return columnTypes;
}
boolean isNumber (String token) {
/*if( (token.equals(null)) || isNaN( new Number(string) ) ) {
return false;
} */
return true;
}
first up...
issue 1
for (int i=0; i < rowCount; i++) {
outputText += indent+"(";
for (int j=0; j < columnCount; j++) {
if ((columnTypes[j] == "int")||(columnTypes[j] == "float")) {
// HERE! // outputText += lines[i][j] || "null";
}
else {
// AND HERE!
// outputText += "'"+( lines[i][j] || "" )+"'";
}
if (j < columnCount - 1) outputText += ",";
}
outputText += ")";
if (i < rowCount - 1) outputText += ","+newLine;
}
the commented lines return a "
the type of the expression must be an array type but it resolved to String" error. if i'm referring to an item/index of a two-dimensional String array, is that not a String itself?
does this have anything to do with using the "+=" operator, instead of "concat()" method in String, or something of the sort? or with using a single string ("outputText") for the whole mysql output, instead of a String array?
issue 2
boolean isNumber (String token) {
/*if( (token.equals(null)) || isNaN( new Number(string) ) ) {
return false;
} */
return true;
}
this is just plain wrong, i know.
how would one go about writing a method in Processing for detecting if a String is a number?
can someone please point me in the right direction for converting a hex color string into 3 int values r, g, b ?
unhex() will convert a hex to int, i just don't know how to convert this int into 3 discreet values for each color channel... or from the hex string directly into the 3 values.