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


Java MetaMessage.getType方法代码示例

本文整理汇总了Java中javax.sound.midi.MetaMessage.getType方法的典型用法代码示例。如果您正苦于以下问题:Java MetaMessage.getType方法的具体用法?Java MetaMessage.getType怎么用?Java MetaMessage.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.MetaMessage的用法示例。


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

示例1: checkClone

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
private static void checkClone(MetaMessage msg) throws Exception {
    System.out.print("Original: ");
    byte[] msgData=msg.getData();
    printMsg(msg, msgData);
    MetaMessage msg2=(MetaMessage) msg.clone();
    byte[] msg2Data=msg2.getData();
    System.out.print("Clone:    ");
    printMsg(msg2, msg2Data);

    if (msg2.getLength()!=msg.getLength()
        || msg.getType()!=msg2.getType()
        || msgData.length!=msg2Data.length) {
            throw new Exception("cloned MetaMessage is not equal.");
    }
    int max=Math.min(msgData.length, 10);
    for (int i=0; i<max; i++) {
        if (msgData[i]!=msg2Data[i]) {
            throw new Exception("Cloned MetaMessage data is not equal.");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:MetaMessageClone.java

示例2: getMicrosecondsPerQuarterNote

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
/**
 * Gets the number of microseconds per quarter note for a sequence, used to
 * determine its BPM.
 * 
 * @param sequence
 * @return
 */
private static int getMicrosecondsPerQuarterNote(Sequence sequence) {

	// Check all MIDI tracks for MIDI_SET_TEMPO message
	for (Track track : sequence.getTracks()) {
		for (int i = 0; i < track.size(); i++) {
			MidiEvent event = track.get(i);
			MidiMessage message = event.getMessage();
			if (message instanceof MetaMessage) {
				MetaMessage m = (MetaMessage) message;
				byte[] data = m.getData();
				int type = m.getType();
				if (type == MIDI_SET_TEMPO) {
					return ((data[0] & 0xff) << 16) | ((data[1] & 0xff) << 8) | (data[2] & 0xff);
				}
			}
		}
	}
	return 0;
}
 
开发者ID:TaylorPeer,项目名称:AI-909,代码行数:27,代码来源:MidiUtilities.java

示例3: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
@Override
public void meta(MetaMessage event) {
   	// we are only worried about the end of track meta message
       if (event.getType() == MidiAudioPlayer.END_OF_TRACK_MESSAGE) {
       	// make sure the audio should loop
           if (this.configuration.isLoopEnabled()) {
           	this.loop();
           	// log that the audio is being looped
   	        LOGGER.debug("Looping");
           } else {
           	this.stop();
           }
       	// set the volume again
       	this.setVolume(this.configuration.getVolume());
   		// set the mute control
   		this.setMuted(this.configuration.isAudioMuted());
       }
}
 
开发者ID:wnbittle,项目名称:praisenter,代码行数:19,代码来源:MidiAudioPlayer.java

示例4: TimeSignature

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public TimeSignature(MetaMessage midiMessage)
{
	byte[] data = midiMessage.getData();
	if (midiMessage.getType() != META_TIME_SIGNATURE || data.length < 4)
	{
		throw new IllegalArgumentException("Midi message is not a time signature event");
	}

	if ((1 << data[1]) > MAX_DENOMINATOR)
	{
		this.numerator = 4;
		this.denominator = 4;
		this.metronome = 24;
		this.thirtySecondNotes = 8;
	}
	else
	{
		this.numerator = data[0];
		this.denominator = 1 << data[1];
		this.metronome = data[2];
		this.thirtySecondNotes = data[3];
	}
}
 
开发者ID:digero,项目名称:maestro,代码行数:24,代码来源:TimeSignature.java

示例5: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public synchronized void meta( MetaMessage message ) {

        if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");

        if( message.getType() == 47 ) {
            if (sequencerloop){
                //notifyAll();
                sequencer.setMicrosecondPosition(0);
                loop();
            } else {
                stop();
            }
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:JavaSoundAudioClip.java

示例6: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
@Override
public synchronized void meta(MetaMessage message) {

    if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");

    if( message.getType() == 47 ) {
        if (sequencerloop){
            //notifyAll();
            sequencer.setMicrosecondPosition(0);
            loop();
        } else {
            stop();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:JavaSoundAudioClip.java

示例7: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public void meta(MetaMessage m) {
    System.out.print("  Got MetaMessage: ");
    if (m.getType() == 47) {
        stopTime = System.currentTimeMillis();
        System.out.println(" End Of Track -- OK");
    } else {
        System.out.println(" unknown. Ignored.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Looping.java

示例8: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public void meta(MetaMessage p1) {
 if(p1.getType() ==47) {
   return;
 }
 System.out.println("getTickPosition:\t"+theSequencer.getTickPosition()
     +"\t Sequencer.getTickLength:\t"+theSequencer.getTickLength()
     +"\tReal Length:\t"+lastTick
     +"\t Sequence.getTickLength:\t"+theSequence.getTickLength()
     //(theSequencer.getTickLength()/64));
     );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TickLength.java

示例9: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public void meta(MetaMessage msg) {
    System.out.println(""+metaCount+": got "+msg);
    if (msg.getType() == 0x2F) {
        finished = true;
    } else if (msg.getData().length > 0 && msg.getType() == 1) {
        metaCount++;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:MetaCallback.java

示例10: writeTrack

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
/**
 * Write a track to an output stream.
 *
 * @param track the track to write
 * @param dos a MidiDataOutputStream to write to
 * @return the number of bytes written
 */
private int writeTrack(Track track, MidiDataOutputStream dos)
  throws IOException
{
  int i = 0, elength = track.size(), trackLength;
  MidiEvent pme = null;
  dos.writeInt(0x4d54726b); // "MTrk"
  trackLength = computeTrackLength(track, dos);
  dos.writeInt(trackLength);
  while (i < elength)
    {
      MidiEvent me = track.get(i);
      int dtime = 0;
      if (pme != null)
        dtime = (int) (me.getTick() - pme.getTick());
      dos.writeVariableLengthInt(dtime);
      // FIXME: use running status byte
      byte msg[] = me.getMessage().getMessage();
      dos.write(msg);
      pme = me;
      i++;
    }

  // We're done if the last event was an End of Track meta message.
  if (pme != null && (pme.getMessage() instanceof MetaMessage))
    {
      MetaMessage mm = (MetaMessage) pme.getMessage();
      if (mm.getType() == 0x2f) // End of Track message
        return trackLength + 8;
    }

  // Write End of Track meta message
  dos.writeVariableLengthInt(0); // Delta time of 0
  dos.writeByte(0xff); // Meta Message
  dos.writeByte(0x2f); // End of Track message
  dos.writeVariableLengthInt(0); // Length of 0

  return trackLength + 8 + 4;
}
 
开发者ID:vilie,项目名称:javify,代码行数:46,代码来源:MidiFileWriter.java

示例11: writeTrack

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
/**
  * Write a track to an output stream.
  *
  * @param track the track to write
  * @param dos a MidiDataOutputStream to write to
  * @return the number of bytes written
  */
 private int writeTrack(Track track, MidiDataOutputStream dos)
   throws IOException
 {
   int i = 0, elength = track.size(), trackLength;
   MidiEvent pme = null;
   dos.writeInt(0x4d54726b); // "MTrk"
   trackLength = computeTrackLength(track, dos);
   dos.writeInt(trackLength);
   while (i < elength)
     {
MidiEvent me = track.get(i);
int dtime = 0;
if (pme != null)
  dtime = (int) (me.getTick() - pme.getTick());
dos.writeVariableLengthInt(dtime); 
// FIXME: use running status byte
byte msg[] = me.getMessage().getMessage();
dos.write(msg);
pme = me;
i++;
     } 

   // We're done if the last event was an End of Track meta message.
   if (pme != null && (pme.getMessage() instanceof MetaMessage))
     {
MetaMessage mm = (MetaMessage) pme.getMessage();
if (mm.getType() == 0x2f) // End of Track message
  return trackLength + 8;
     }

   // Write End of Track meta message
   dos.writeVariableLengthInt(0); // Delta time of 0
   dos.writeByte(0xff); // Meta Message
   dos.writeByte(0x2f); // End of Track message
   dos.writeVariableLengthInt(0); // Length of 0

   return trackLength + 8 + 4;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:46,代码来源:MidiFileWriter.java

示例12: decodeMetaMessage

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
private void decodeMetaMessage(MetaMessage message, MusicScore score, double startTime) {
    byte[] abMessage = message.getMessage();
    byte[] abData = message.getData();
    int nDataLength = message.getLength();

    switch (message.getType()) {
        case MIDIMessageCode.MicrosecondsPerQuarterNote:
            int sec = ((abData[0] & 0xFF) << 16) | ((abData[1] & 0xFF) << 8) | (abData[2] & 0xFF);
            score.addTempo(new Tempo(startTime, sec));
            score.setMicrosecondsPerQuarterNote(sec);
            break;

        case MIDIMessageCode.SMPTEOffset:
            String offset = (abData[0] & 0xFF) + ":" + (abData[1] & 0xFF) + ":" + (abData[2] & 0xFF) + "." + (abData[3] & 0xFF) + "." + (abData[4] & 0xFF);
            break;

        case MIDIMessageCode.TimeSignature:
            int timeSigElement = abData[0] & 0xFF;
            int timeSigDenominator = 1 << (abData[1] & 0xFF);
            int clocksperMetronome = abData[2] & 0xFF;
            int midiClock = abData[3] & 0xFF;
            score.setClocksperMetronome(clocksperMetronome);
            score.setTimeSigDenominator(timeSigDenominator);
            score.setTimeSigElement(timeSigElement);
            score.setMidiClock(midiClock);
            break;

        case MIDIMessageCode.KeySignature:
            if (abData[1] == 1) {
                score.setGender(false);
            } else {
                score.setGender(true);
            }
            score.setKeySignature(abData[0] + 7);
            break;

        default:
            break;
    }
}
 
开发者ID:shuichi,项目名称:MediaMatrix,代码行数:41,代码来源:MidiAnalyzer.java

示例13: meta

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
/**
    * Invoked when a Sequencer has encountered and processed a MetaMessage
    * in the Sequence it is processing.
    * @param MetaMessage meta - the meta-message that the sequencer
    *                           encountered
    */
   public void meta(MetaMessage metaEvent) {
	//System.out.println("JavaSound sequencer sent meta event");
	if (metaEvent.getType() == StopType) {
		if (msCycle) {
			rePlay();
		} else {
			stop();
		}
	}
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:17,代码来源:MidiSynth.java

示例14: KeySignature

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
public KeySignature(MetaMessage midiMessage)
{
	byte[] data = midiMessage.getData();
	if (midiMessage.getType() != META_KEY_SIGNATURE || data.length < 2)
	{
		throw new IllegalArgumentException("Midi message is not a key signature");
	}

	this.sharpsFlats = data[0];
	this.mode = (data[1] == 1) ? KeyMode.MINOR : KeyMode.MAJOR;
}
 
开发者ID:digero,项目名称:maestro,代码行数:12,代码来源:KeySignature.java

示例15: parseMetaMessage

import javax.sound.midi.MetaMessage; //导入方法依赖的package包/类
/**
 * Parses instances of MetaMessage. 
 * @param message The message to parse
 * @param timestamp the time at which the message was encountered in this track
 */
private void parseMetaMessage(MetaMessage message, long timestamp)
{
    switch (message.getType())
    {
      case 0x51 : parseTempo(message, timestamp); break;
      case 0x59 : break; // Even though we care about Key Signatures, we don't want to read one in from a MIDI file,
                         // because the notes that we'll receive will already be adjusted for the key signature.
                         // MIDI's Key Signature is more about notating sheet music that influencing the played notes.
    default : break;
    }
    // Nothing to do - JFugue doesn't use sysex messages
    trace("MetaMessage received but not parsed by JFugue (doesn't use them)");
}
 
开发者ID:d2fn,项目名称:passage,代码行数:19,代码来源:MidiParser.java


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