本文整理汇总了Java中org.herac.tuxguitar.song.models.TGDuration.fromTime方法的典型用法代码示例。如果您正苦于以下问题:Java TGDuration.fromTime方法的具体用法?Java TGDuration.fromTime怎么用?Java TGDuration.fromTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.herac.tuxguitar.song.models.TGDuration
的用法示例。
在下文中一共展示了TGDuration.fromTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDurations
import org.herac.tuxguitar.song.models.TGDuration; //导入方法依赖的package包/类
public static List<TGDuration> createDurations(TGFactory factory,long time){
List<TGDuration> durations = new ArrayList<TGDuration>();
TGDuration minimum = factory.newDuration();
minimum.setValue(TGDuration.SIXTY_FOURTH);
minimum.setDotted(false);
minimum.setDoubleDotted(false);
minimum.getDivision().setEnters(3);
minimum.getDivision().setTimes(2);
long missingTime = time;
while( missingTime > minimum.getTime() ){
TGDuration duration = TGDuration.fromTime(factory, missingTime, minimum , 10);
durations.add( duration.clone(factory) );
missingTime -= duration.getTime();
}
return durations;
}
示例2: locateBeat
import org.herac.tuxguitar.song.models.TGDuration; //导入方法依赖的package包/类
public void locateBeat( TGBeat beat, TGTrack track , boolean newMeasureAlsoForRestBeats) {
if( beat.getMeasure() != null ){
beat.getMeasure().removeBeat(beat);
beat.setMeasure(null);
}
TGMeasure newMeasure = getSongManager().getTrackManager().getMeasureAt(track, beat.getStart() );
if( newMeasure == null ){
boolean createNewMeasure = newMeasureAlsoForRestBeats;
if( !createNewMeasure ){
createNewMeasure = ( !beat.isRestBeat() || beat.isTextBeat() );
}
if( createNewMeasure ){
while( newMeasure == null && beat.getStart() >= TGDuration.QUARTER_TIME){
getSongManager().addNewMeasureBeforeEnd(track.getSong());
newMeasure = getSongManager().getTrackManager().getMeasureAt(track, beat.getStart() );
}
}
}
if( newMeasure != null ){
long mStart = newMeasure.getStart();
long mLength = newMeasure.getLength();
long bStart = beat.getStart();
for( int v = 0 ; v < beat.countVoices() ; v ++ ){
TGVoice voice = beat.getVoice( v );
long vDuration = voice.getDuration().getTime();
if(!voice.isEmpty() && (bStart + vDuration) > (mStart + mLength) ){
long vTiedDuration = ( (bStart + vDuration) - (mStart + mLength) );
vDuration -= vTiedDuration;
if( vDuration > 0 ){
TGDuration duration = TGDuration.fromTime(getSongManager().getFactory(), vDuration);
if( duration != null ){
voice.getDuration().copyFrom( duration );
}
}
if( vTiedDuration > 0 ) {
TGDuration newVoiceDuration = TGDuration.fromTime(getSongManager().getFactory(), vTiedDuration);
if( newVoiceDuration != null ){
long newBeatStart = (bStart + vDuration);
TGBeat newBeat = getBeat(track, newBeatStart);
if( newBeat == null ){
newBeat = getSongManager().getFactory().newBeat();
newBeat.setStart( (bStart + vDuration) );
}
TGVoice newVoice = newBeat.getVoice( v );
for( int n = 0 ; n < voice.countNotes() ; n ++ ){
TGNote note = voice.getNote( n );
TGNote newNote = getSongManager().getFactory().newNote();
newNote.setTiedNote( true );
newNote.setValue( note.getValue() );
newNote.setString( note.getString() );
newNote.setVelocity( note.getVelocity() );
newVoice.addNote( newNote );
}
newVoice.setEmpty( false );
newVoice.getDuration().copyFrom( newVoiceDuration );
locateBeat(newBeat, track, newMeasureAlsoForRestBeats);
}
}
}
}
newMeasure.addBeat(beat);
}
}