|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.score.transcribe.MeasureExtractor
public class MeasureExtractor
Given a source MusicShape where dimension 0 stores absolute times for events (as opposed to relative durations),
pull out a subset of the MusicShape that fall within a measure's time window.
Assumes ontimes have already been adjusted for tempo, so that 1.0=quarter note.
Resulting extracted MusicShape contains on-times normalized relative to start time of measure.
Note: don't expect the on-time of the first element to be 0, since it may not have landed on a measure boundary.
Constructor Summary | |
---|---|
MeasureExtractor()
|
Method Summary | |
---|---|
double |
extract()
Pull out a subrange of the source shape. |
MusicShape |
getExtractedMusicShape()
|
double |
getStartTime()
|
static void |
main(java.lang.String[] args)
Test a few simple cases. |
void |
setSourceShape(MusicShape s)
This is the MusicShape from which one measure's worth of elements are extracted |
void |
setStartTime(double startTime)
Set the start time within the source shape to begin pulling events |
void |
setTempo(Tempo tempo)
Used to scale the calculate time span within which elements are extracted |
void |
setTimeSignature(TimeSignature ts)
Used to calculate time span within which elements are extracted |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MeasureExtractor()
Method Detail |
---|
public void setSourceShape(MusicShape s)
public void setTimeSignature(TimeSignature ts)
public void setTempo(Tempo tempo)
public void setStartTime(double startTime)
public double getStartTime()
public double extract() throws TimeWindowNotFoundException
TimeWindowNotFoundException
- if all elements in the source music shape are earlier than the requested start time.public MusicShape getExtractedMusicShape()
public static void main(java.lang.String[] args)
boolean keepExtracting = true; while(keepExtracting) { try { extractor.setTimeSignature(new TimeSignature(3, 4)); extractor.setStartTime(extractor.extract()); MusicShape extractedMeasure = extractor.getExtractedMusicShape(); extractedMeasure.print(); } catch (TimeWindowNotFoundException e) { System.out.println("Done"); keepExtracting = false; } }
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |