lib/minim/src/ddf/minim/NoteManager.java
// but we store them as taking place at a specific time, rather than a relative time.
but we store them as taking place at a specific time, rather than a relative time.
but we store them as taking place at a specific time rather than a relative time .
public synchronized void addEvent(float startTime, float duration, Instrument instrument)
	{
		int on = now + (int)(sampleRate * ( startTime + noteOffset ) * 60f/tempo);
		Integer onAt = new Integer( on );
		float actualDuration = duration * durationFactor * 60f/tempo;
		if ( events.containsKey(onAt) )
		{
			ArrayList<NoteEvent> eventsAtOn = events.get(onAt);
			eventsAtOn.add( new NoteOnEvent(instrument, actualDuration) );
		}
		else
		{
			ArrayList<NoteEvent> eventsAtOn = new ArrayList<NoteEvent>();
			eventsAtOn.add( new NoteOnEvent(instrument, actualDuration) );
			events.put(onAt, eventsAtOn);
		}
		Integer offAt = new Integer( on + (int)(sampleRate * actualDuration) );
		if ( events.containsKey(offAt) )
		{
			ArrayList<NoteEvent> eventsAtOff = events.get(offAt);
			eventsAtOff.add( new NoteOffEvent(instrument) );
		}
		else
		{
			ArrayList<NoteEvent> eventsAtOff = new ArrayList<NoteEvent>();
			eventsAtOff.add( new NoteOffEvent(instrument) );
			events.put(offAt, eventsAtOff);
		}
	}
public synchronized void addEvent ( float startTime , float duration , Instrument instrument ) { int on = now + ( int ) ( sampleRate * ( startTime + noteOffset ) * 60f / tempo ) ; Integer onAt = new Integer ( on ) ; float actualDuration = duration * durationFactor * 60f / tempo ; if ( events . containsKey ( onAt ) ) { ArrayList < NoteEvent > eventsAtOn = events . get ( onAt ) ; eventsAtOn . add ( new NoteOnEvent ( instrument , actualDuration ) ) ; } else { ArrayList < NoteEvent > eventsAtOn = new ArrayList < NoteEvent > ( ) ; eventsAtOn . add ( new NoteOnEvent ( instrument , actualDuration ) ) ; events . put ( onAt , eventsAtOn ) ; } Integer offAt = new Integer ( on + ( int ) ( sampleRate * actualDuration ) ) ; if ( events . containsKey ( offAt ) ) { ArrayList < NoteEvent > eventsAtOff = events . get ( offAt ) ; eventsAtOff . add ( new NoteOffEvent ( instrument ) ) ; } else { ArrayList < NoteEvent > eventsAtOff = new ArrayList < NoteEvent > ( ) ; eventsAtOff . add ( new NoteOffEvent ( instrument ) ) ; events . put ( offAt , eventsAtOff ) ; } }
but we store them as taking place at a specific time, rather than a relative time.
but we store them as taking place at a specific time rather than a relative time .