JMSL Tutorial: JScore's Transcriber, part 4
Specifying time signatures and tempos

The output of the transcriber is sent to a Score. Unless you specify otherwise, 4/4 time will be used throughout, with a tempo of 60 bpm. This means that a duration of 1.0 second in the input would be interpreted as a quarter note in the score.

You may provide a time signature and tempo framework for the transcriber. For example, if you specify a tempo of 120bpm, then a duration of 0.5 second in the input would be interpreted as a quarter notes in the resulting score.
When the transcriber examines the timestamps of the input MusicShape, it "bins" them into groups that fit each specified measure. If the tempo is something other than 60bpm, it will scale these timestamps appropriately to interpret them as the tempo requires.

Tempo can change with every measure. Time signature can change every measure as well. The key idea is to add time signature / tempo specifications to a Vector and hand that Vector to the Transcriber.

The following code excerpt shows how.
Transcriber transcriber = new Transcriber();
Vector tsVector = new Vector();
tsVector.addElement(new TempoTimeSignatureHolder(new Tempo(120), new TimeSignature(3, 8)));
tsVector.addElement(new TempoTimeSignatureHolder(new Tempo(60), new TimeSignature(4, 4)));
tsVector.addElement(new TempoTimeSignatureHolder(new Tempo(90), new TimeSignature(5, 8)));
transcriber.setTempoTimeSignatures(tsVector);

The score resulting from the above Vector would start out with the first measure in 3/8 time, 120bpm. The next measure would switch to 4/4 time, at 60bpm. The third measure would change to 5/8 time, at 90 bpm. If the input MusicShape contains more elements than fit into these three measures, additional measures of 5/8 would be added as needed.
IMPORTANT: You can set the Transcriber to cycle through this three measure pattern instead of using the data from the last measure by calling transcriber.setLoopTimeSignatures(true)

Previous Tutorial Index Tutorial Contents Next

 
  (C) 2000 Nick Didkovsky and Phil Burk, All Rights Reserved
  JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.