int ave;
int counter = 0;
Enumeration enum1 = part.getPhraseList().elements();
while(enum1.hasMoreElements()){
Phrase tempPhrase = (Phrase) enum1.nextElement();
if (tempPhrase == null) {
break;
}
Enumeration enum2 = tempPhrase.getNoteList().elements();
while(enum2.hasMoreElements()){
Note note = (Note) enum2.nextElement();
if(note.getPitch() != REST ) { // reject rests
curr = note.getDynamic();
accum += curr;
counter++;
}
}
}
ave = (int)(accum / counter);
// compress the sucker
enum1 = part.getPhraseList().elements();
while(enum1.hasMoreElements()){
Phrase tempPhrase = (Phrase) enum1.nextElement();
if (tempPhrase == null) {
break;
}
Enumeration enum2 = tempPhrase.getNoteList().elements();
while(enum2.hasMoreElements()){
Note note = (Note) enum2.nextElement();
System.out.println("note was =" + note.getDynamic());
curr = (int)(ave + ((note.getDynamic() - ave) * ratio));
note.setDynamic(curr);