use of blue.soundObject.Note in project blue by kunstmusik.
the class MultiplyProcessor method processNotes.
@Override
public final void processNotes(NoteList in) throws NoteProcessorException {
Note temp;
double fieldVal = 0;
for (int i = 0; i < in.size(); i++) {
temp = in.get(i);
try {
fieldVal = Double.parseDouble(temp.getPField(pfield));
} catch (NumberFormatException ex) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.pfieldNotDouble"), pfield);
} catch (Exception ex) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.missingPfield"), pfield);
}
temp.setPField(Double.toString(fieldVal * value), pfield);
}
}
use of blue.soundObject.Note in project blue by kunstmusik.
the class RotateProcessor method processNotes.
@Override
public final void processNotes(NoteList in) throws NoteProcessorException {
if (in.size() < 2 || noteIndex == 1) {
return;
}
in.sort();
Note lastNote = in.get(in.size() - 1);
double startTime = lastNote.getStartTime() + lastNote.getSubjectiveDuration();
int index = noteIndex;
if (index > 0) {
index = index - 1;
} else {
index = in.size() + index;
}
if (index > in.size()) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.rotateIndex"));
}
Collections.rotate(in, -index);
index = in.size() - index;
while (index < in.size()) {
Note n = in.get(index);
n.setStartTime(n.getStartTime() + startTime);
index++;
}
ScoreUtilities.normalizeNoteList(in);
}
use of blue.soundObject.Note in project blue by kunstmusik.
the class SwitchProcessor method processNotes.
@Override
public final void processNotes(NoteList in) throws NoteProcessorException {
Note temp;
String tempPField;
int pcount = 0;
for (int i = 0; i < in.size(); i++) {
temp = in.get(i);
// validate necessary pfields are there
pcount = temp.getPCount();
if (pfield1 < 1 || pfield1 >= pcount) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.missingPfield"), pfield1);
}
if (pfield2 < 1 || pfield2 >= pcount) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.missingPfield"), pfield2);
}
tempPField = temp.getPField(pfield1);
temp.setPField(temp.getPField(pfield2), pfield1);
temp.setPField(tempPField, pfield2);
}
}
use of blue.soundObject.Note in project blue by kunstmusik.
the class TuningProcessor method processNotes.
@Override
public void processNotes(NoteList in) throws NoteProcessorException {
Note temp;
int pcount = 0;
double freq = 0f;
for (int i = 0; i < in.size(); i++) {
temp = in.get(i);
// verify pfield
pcount = temp.getPCount();
if (pfield < 1 || pfield > pcount) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.missingPfield"), pfield);
}
String val = temp.getPField(pfield).trim();
try {
freq = convert(val, scale);
} catch (Exception ex) {
throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.scaleFileConvert"), pfield);
}
temp.setPField(Double.toString(freq), pfield);
}
}
use of blue.soundObject.Note in project blue by kunstmusik.
the class Field method generateNotes.
public NoteList generateNotes(final double duration, java.util.Random rnd) {
NoteList nl = new NoteList();
double xt = 0.0;
int numFields = parameters.size();
for (int i = 0; i < parameters.size(); i++) {
getParameter(i).initialize(duration);
}
while (xt < duration) {
Note n = Note.createNote(numFields);
double p1 = getParameter(0).getValue(xt, rnd);
p1 = p1 < 1.0 ? 1.0 : Utilities.round(p1, 0);
n.setPField(NumberUtilities.formatDouble(p1), 1);
n.setPField(NumberUtilities.formatDouble(xt), 2);
for (int i = 3; i < numFields + 1; i++) {
double val = getParameter(i - 1).getValue(xt, rnd);
if (i == 3 && val < 0) {
n.setPField(NumberUtilities.formatDouble(-val), i);
n.setTied(true);
} else {
n.setPField(NumberUtilities.formatDouble(val), i);
}
}
double p2 = getParameter(1).getValue(xt, rnd);
if (p2 == 0.0) {
System.err.println("[JMask] - WARNING: p2 = 0 !");
}
xt += p2;
nl.add(n);
}
return nl;
}
Aggregations