double durationModifier = Chance.test(30) ? SpecialNoteType.STACCATO.getValue() : 0;
for (Phrase phrase : phrases) {
ExtendedPhrase extPhrase = ((ExtendedPhrase) phrase);
Scale currentScale = extPhrase.getScale();
if (currentScale.getDefinition().length != 7) { //no bass for irregular scales, for now
continue;
}
Phrase bassPhrase = new Phrase();
for (int i = 0; i < extPhrase.getMeasures(); i++) {
for (int k = 0; k < 2; k++) {
if (Chance.test(70)) {
int degreeIdx = 0;
if (dullBass) {
degreeIdx = Chance.choose(dullBassPercentages);
} else {
degreeIdx = Chance.choose(degreePercentages);
}
Note note = NoteFactory.createNote(JMC.C3 + ctx.getKeyNote() + currentScale.getDefinition()[degreeIdx], ctx.getNormalizedMeasureSize() / 2);
note.setDynamic(InstrumentGroups.getInstrumentSpecificDynamics(60 + random.nextInt(15), bassPart.getInstrument()));
if (durationModifier > 0) {
note.setDuration(note.getRhythmValue() * durationModifier);
}
bassPhrase.addNote(note);