com.softsynth.jmsl.score.transcribe
Class BeatDivision

java.lang.Object
  extended by com.softsynth.jmsl.score.transcribe.BeatDivision

public class BeatDivision
extends java.lang.Object

This class handles one beat of music events. Is characterized by a BeatDivisionScheme and a beat number on which to start examining note events. Refers to a time signature, a beat in the measure upon which to start, number of divisions (5 for quintuplet, etc), duration of a division (0.20 for 1/16th note quintuplet for example), total error, minimal number of events to be satisfied (for example, reject it if this is a septuplet but only 3 events fall into its grid. Examines events within a beat's time window and scores their error from the division's ideal grid. The events within this measure are prepared for it by MeasureExtractor, which are stored in a MusicShape. MusicShape's absolute durations are already normalized to start at time = 0 = start of measure. If there are no hits starting on this beat in this time span, then if it is not a tuplet, its score is 0, else if it is a tuplet, set its score to worst possible. This ensures that 16th and 32nds get chosen instead of something crazy like 3 triplet rests.

Author:
Nick Didkovsky, Jan 28, 2002 , (c) 2002 Nick Didkovsky, All Rights reserved.

Field Summary
static double TUPLET_REWARD_FACTOR
          reward tuplets if all are present, to compete with hogs like 16ths and 32nds
static double WORST_POSSIBLE_SCORE
           
 
Constructor Summary
BeatDivision()
           
 
Method Summary
 void calculateScore()
          run through *all* events in measure and drop them into a grid that fits this division scheme.
 int getBeatNumber()
           
 java.util.Vector getCollectedTimePoints()
          For this BeatDivision, collect the durations of rests following each non-empty timepoint and add these to the timepoint's duration.
 boolean getConformToBeat()
          tuplets to not conform to beats.
 java.util.Vector getIndexes()
           
 int getNumberOfBeats()
           
 int getNumberOfDivisions()
           
 int getNumTimePointsHit()
           
 double getScore()
           
 java.util.Vector getTimePoints()
           
 double getTimeSpan()
           
static void main(java.lang.String[] args)
           
 java.lang.String printTimePoints()
           
 void setBeatDivisionScheme(BeatDivisionScheme scheme)
           
 void setBeatNumber(int beatNumber)
           
 void setMeasure(MusicShape s)
           
 void setTimeSignature(TimeSignature ts)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WORST_POSSIBLE_SCORE

public static final double WORST_POSSIBLE_SCORE
See Also:
Constant Field Values

TUPLET_REWARD_FACTOR

public static final double TUPLET_REWARD_FACTOR
reward tuplets if all are present, to compete with hogs like 16ths and 32nds

See Also:
Constant Field Values
Constructor Detail

BeatDivision

public BeatDivision()
Method Detail

setBeatDivisionScheme

public void setBeatDivisionScheme(BeatDivisionScheme scheme)

setTimeSignature

public void setTimeSignature(TimeSignature ts)

setMeasure

public void setMeasure(MusicShape s)

setBeatNumber

public void setBeatNumber(int beatNumber)

getConformToBeat

public boolean getConformToBeat()
tuplets to not conform to beats. They have rigid time spans that may be longer than a beat (like a qtr note triplet in 4/8 time). Straight 16ths do conform to beats because they can fill a beat no matter what the time signature .

Returns:
conform to beat flag of this.BeatDivisionScheme

getBeatNumber

public int getBeatNumber()
Returns:
the starting beat of this BeatDivision

getNumberOfBeats

public int getNumberOfBeats()
Returns:
the number of beats covered by this timespan. For example, if timespan == 1 and timesig = 4/4, return 1. If timespan ==1 and timesig = 3/8, return 2
If this conforms to beats, return 1

calculateScore

public void calculateScore()
run through *all* events in measure and drop them into a grid that fits this division scheme. Only look at the ones that fall within this beat, and score their error.


getNumTimePointsHit

public int getNumTimePointsHit()

getNumberOfDivisions

public int getNumberOfDivisions()

getScore

public double getScore()
Returns:
the total error for this beat and this division scheme

getTimeSpan

public double getTimeSpan()
Returns:
the duration this division spans (ex 2 for qtr note triplets, 1 for 16th note quintuplets)

getIndexes

public java.util.Vector getIndexes()

printTimePoints

public java.lang.String printTimePoints()

getTimePoints

public java.util.Vector getTimePoints()

getCollectedTimePoints

public java.util.Vector getCollectedTimePoints()
For this BeatDivision, collect the durations of rests following each non-empty timepoint and add these to the timepoint's duration. This eliminates note/rest/note/rest patterns within a beat. First element is considered a collector even if it's a rest, to collect rest durations into one rest.

Returns:
Vector of collected time points

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)