View Javadoc

1   package com.jamesbryangraves.bob.music;
2   
3   import com.jamesbryangraves.bob.util.BobUtils;
4   
5   public abstract class DiatonicMusicEventGenerator extends MusicEventGenerator {
6   	
7   	protected int getNextPitch(int pitch, int key, Scale scale) {
8   		return BobUtils.getRandomInt(4) % 1 == 0 ? 
9   				upOrDown(pitch) > 0 ? 
10  						scale.getNextNote(pitch, key) : 
11  							scale.getPreviousNote(pitch, key) 
12  								: getScalePitch(key, scale);
13  	}
14  	
15  	protected int getScalePitch(int key, Scale scale) {
16  		int pitch = key +
17  			scale.getScaleSteps().get(
18  					BobUtils.getRandomInt(scale.getScaleSteps().size()));
19  		return  pitch + (BobUtils.getRandomInt(1) * 12 * upOrDown(pitch));
20  	}
21  
22  }