View Javadoc

1   package com.jamesbryangraves.bob.music;
2   
3   import java.util.Collection;
4   
5   import com.jamesbryangraves.bob.util.BobUtils;
6   
7   public abstract class MusicEventGenerator {
8   	
9   	protected int getNoteValue(long resolution) {
10  		return (int)Math.pow(2, BobUtils.getRandomInt(
11  				(int)(Math.log(resolution)/Math.log(2)) + 1));
12  	}
13  	
14  	protected int upOrDown(int pitch) {
15  		//the threshold of pitch is 10 < pitch < 100
16  		if(BobUtils.getRandomInt(2) > 0)
17  			return pitch <= 24 ? 1 : -1;
18  		return pitch >= 108 ? -1 : 1;
19  	}
20  	
21  	public abstract Collection<MusicEvent> generateEvents(
22  			MusicContext musicContext, long tick)  throws Exception;
23  
24  }