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


Java MidiEvent类代码示例

本文整理汇总了Java中org.herac.tuxguitar.io.midi.base.MidiEvent的典型用法代码示例。如果您正苦于以下问题:Java MidiEvent类的具体用法?Java MidiEvent怎么用?Java MidiEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MidiEvent类属于org.herac.tuxguitar.io.midi.base包,在下文中一共展示了MidiEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readTrack

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
private void readTrack(DataInputStream in, MidiTrack track)throws MidiFileException, IOException{
	while (true){
		if (in.readInt() == TRACK_MAGIC){
			break;
		}
		int chunkLength = in.readInt();
		if (chunkLength % 2 != 0){
			chunkLength++;
		}
		in.skip(chunkLength);
	}
	
	MidiTrackReaderHelper helper = new MidiTrackReaderHelper(0,in.readInt(),-1);
	while (helper.remainingBytes > 0){
		helper.ticks += readVariableLengthQuantity(in, helper);
		MidiEvent event = readEvent(in, helper);
		if(event != null){
			track.add(event);
		}
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:22,代码来源:MidiFileReader.java

示例2: writeTrack

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
private static int writeTrack(MidiTrack track,DataOutputStream out)throws IOException{
	int length = 0;
	if (out != null){
		out.writeInt(TRACK_MAGIC);
	}
	if (out != null){
		out.writeInt( writeTrack(track, null) );
	}
	MidiEvent previous = null;
	for (int i = 0; i < track.size(); i++){
		MidiEvent event = track.get(i);
		length += writeEvent(event,previous,out);
		previous = event;
	}
	return length;
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:17,代码来源:MidiFileWriter.java

示例3: addControlChange

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addControlChange(long tick,int track,int channelId, int controller, int value) {
	GMChannelRoute gmChannel = this.router.getRoute(channelId);
	if( gmChannel != null ){
		addEvent(track,new MidiEvent(MidiMessageUtils.controlChange(gmChannel.getChannel1(), controller, value), tick ));
		if( gmChannel.getChannel1() != gmChannel.getChannel2() ){
			addEvent(track,new MidiEvent(MidiMessageUtils.controlChange(gmChannel.getChannel2(), controller, value), tick ));
		}
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:10,代码来源:MidiSequenceHandlerImpl.java

示例4: addProgramChange

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addProgramChange(long tick,int track,int channelId, int instrument) {
	GMChannelRoute gmChannel = this.router.getRoute(channelId);
	if( gmChannel != null ){
		addEvent(track,new MidiEvent(MidiMessageUtils.programChange(gmChannel.getChannel1(), instrument), tick ));
		if( gmChannel.getChannel1() != gmChannel.getChannel2() ){
			addEvent(track,new MidiEvent(MidiMessageUtils.programChange(gmChannel.getChannel2(), instrument), tick ));
		}
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:10,代码来源:MidiSequenceHandlerImpl.java

示例5: writeEvent

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
private static int writeEvent(MidiEvent event,MidiEvent previous,OutputStream out)throws IOException{
	int length = writeVariableLengthQuantity(((previous != null)?(event.getTick() - previous.getTick()):0), out);
	MidiMessage	message = event.getMessage();
	if(message.getType() == MidiMessage.TYPE_SHORT){
		length += writeShortMessage(message,out);
	}
	else if(message.getType() == MidiMessage.TYPE_META){
		length += writeMetaMessage(message,out);
	}
	
	return length;
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:13,代码来源:MidiFileWriter.java

示例6: importSong

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public TGSong importSong() throws TGFileFormatException {
	try {
		if(this.settings == null || this.factory == null || this.stream == null ){
			return null;
		}
		MidiSequence sequence = new MidiFileReader().getSequence(this.stream);
		initFields(sequence);
		for(int i = 0; i < sequence.countTracks(); i++){
			MidiTrack track = sequence.getTrack(i);
			int trackNumber = getNextTrackNumber();
			int events = track.size();
			for(int j = 0;j < events;j ++){
				MidiEvent event = track.get(j);
				parseMessage(trackNumber,event.getTick(),event.getMessage());
			}
		}
		checkAll();
		
		TGSong song = this.factory.newSong();
		
		Iterator headers = this.headers.iterator();
		while(headers.hasNext()){
			song.addMeasureHeader((TGMeasureHeader)headers.next());
		}
		Iterator tracks = this.tracks.iterator();
		while(tracks.hasNext()){
			song.addTrack((TGTrack)tracks.next());
		}
		return new SongAdjuster(this.factory,song).adjustSong();
	} catch (Throwable throwable) {
		throw new TGFileFormatException(throwable);
	}
}
 
开发者ID:Totallicks,项目名称:totallicks-tuxguitar,代码行数:34,代码来源:MidiSongImporter.java

示例7: addEvent

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addEvent(int track, MidiEvent event) {
	if(track >= 0 && track < getSequence().countTracks()){
		getSequence().getTrack(track).add(event);
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:6,代码来源:MidiSequenceHandlerImpl.java

示例8: addNoteOff

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addNoteOff(long tick,int track,int channelId, int note, int velocity, int voice, boolean bendMode) {
	GMChannelRoute gmChannel = this.router.getRoute(channelId);
	if( gmChannel != null ){
		addEvent(track,new MidiEvent(MidiMessageUtils.noteOff(resolveChannel(gmChannel,bendMode), note, velocity), tick ));
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:7,代码来源:MidiSequenceHandlerImpl.java

示例9: addNoteOn

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addNoteOn(long tick,int track,int channelId, int note, int velocity, int voice, boolean bendMode) {
	GMChannelRoute gmChannel = this.router.getRoute(channelId);
	if( gmChannel != null ){
		addEvent(track,new MidiEvent(MidiMessageUtils.noteOn(resolveChannel(gmChannel,bendMode), note, velocity), tick ));
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:7,代码来源:MidiSequenceHandlerImpl.java

示例10: addPitchBend

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addPitchBend(long tick,int track,int channelId, int value, int voice, boolean bendMode) {
	GMChannelRoute gmChannel = this.router.getRoute(channelId);
	if( gmChannel != null ){
		addEvent(track,new MidiEvent(MidiMessageUtils.pitchBend(resolveChannel(gmChannel,bendMode), value), tick ));
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:7,代码来源:MidiSequenceHandlerImpl.java

示例11: addTempoInUSQ

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addTempoInUSQ(long tick,int track,int usq) {
	addEvent(track,new MidiEvent(MidiMessageUtils.tempoInUSQ(usq), tick ));
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:4,代码来源:MidiSequenceHandlerImpl.java

示例12: addTimeSignature

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addTimeSignature(long tick,int track,TGTimeSignature ts) {
	addEvent(track,new MidiEvent(MidiMessageUtils.timeSignature(ts), tick ));
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:4,代码来源:MidiSequenceHandlerImpl.java

示例13: process

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void process() throws TGFileFormatException {
	try {			
		InputStream stream = this.context.getAttribute(InputStream.class.getName());
		TGSongManager tgSongManager = this.context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG_MANAGER);
		
		this.factory = tgSongManager.getFactory();
		this.settings = this.context.getAttribute(MidiSettings.class.getName());
		if( this.settings == null ) {
			this.settings = MidiSettings.getDefaults();
		}
		
		MidiSequence sequence = new MidiFileReader().getSequence(stream);
		initFields(sequence);
		for(int i = 0; i < sequence.countTracks(); i++){
			MidiTrack track = sequence.getTrack(i);
			int trackNumber = getNextTrackNumber();
			int events = track.size();
			for(int j = 0;j < events;j ++){
				MidiEvent event = track.get(j);
				parseMessage(trackNumber,event.getTick(),event.getMessage());
			}
		}
		
		TGSong tgSong = this.factory.newSong();
		
		this.checkAll(tgSongManager);
		
		Iterator<TGChannel> channels = this.channels.iterator();
		while(channels.hasNext()){
			tgSong.addChannel((TGChannel)channels.next());
		}
		Iterator<TGMeasureHeader> headers = this.headers.iterator();
		while(headers.hasNext()){
			tgSong.addMeasureHeader((TGMeasureHeader)headers.next());
		}
		Iterator<TGTrack> tracks = this.tracks.iterator();
		while(tracks.hasNext()){
			tgSong.addTrack((TGTrack)tracks.next());
		}
		
		this.context.setAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG, new SongAdjuster(this.factory, tgSong).adjustSong());
	} catch (Throwable throwable) {
		throw new TGFileFormatException(throwable);
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:46,代码来源:MidiSongImporter.java

示例14: addControlChange

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addControlChange(long tick,int track,int channel, int controller, int value) {
	addEvent(track,new MidiEvent(MidiMessageUtils.controlChange(channel, controller, value), tick ));
}
 
开发者ID:Totallicks,项目名称:totallicks-tuxguitar,代码行数:4,代码来源:MidiSequenceHandlerImpl.java

示例15: addNoteOff

import org.herac.tuxguitar.io.midi.base.MidiEvent; //导入依赖的package包/类
public void addNoteOff(long tick,int track,int channel, int note, int velocity) {
	addEvent(track,new MidiEvent(MidiMessageUtils.noteOff(channel, note, velocity), tick ));
}
 
开发者ID:Totallicks,项目名称:totallicks-tuxguitar,代码行数:4,代码来源:MidiSequenceHandlerImpl.java


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