当前位置: 首页>>代码示例>>Java>>正文


Java TGDuration.fromTime方法代码示例

本文整理汇总了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;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:18,代码来源:TGMeasureManager.java

示例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);
	}
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:67,代码来源:TGMeasureManager.java


注:本文中的org.herac.tuxguitar.song.models.TGDuration.fromTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。