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


Java MidiMessage.getStatus方法代码示例

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


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

示例1: getTempoMPQ

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
/** parses this message for a META tempo message and returns
 * the tempo in MPQ, or -1 if this isn't a tempo message
 */
public static int getTempoMPQ(MidiMessage midiMsg) {
    // first check if it is a META message at all
    if (midiMsg.getLength() != 6
        || midiMsg.getStatus() != MetaMessage.META) {
        return -1;
    }
    byte[] msg = midiMsg.getMessage();
    if (((msg[1] & 0xFF) != META_TEMPO_TYPE) || (msg[2] != 3)) {
        return -1;
    }
    int tempo =    (msg[5] & 0xFF)
                | ((msg[4] & 0xFF) << 8)
                | ((msg[3] & 0xFF) << 16);
    return tempo;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:MidiUtils.java

示例2: send

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public void send(MidiMessage mess, long timeStamp) {
		if (mess.getStatus() >= ShortMessage.MIDI_TIME_CODE) {
//			 System.out.println(mess + " " + mess.getStatus() );
			return;
		}
		// make time stamp -1 (otherwise bad timing)
		
		if (mess instanceof ShortMessage) {

			ShortMessage shm = (ShortMessage) mess;

			int cmd = shm.getCommand();
			if (cmd != 240) {
				int chn = shm.getChannel();

				int dat1 = shm.getData1();
				int dat2 = shm.getData2();

				System.out.println(" cmd:" + cmd + " chn:" + chn + " data:"
						+ dat1 + " " + dat2);
			}		
		}
		chained.send(mess, -1);
	}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:25,代码来源:PlaySynth.java

示例3: isMetaEndOfTrack

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
/** return true if the passed message is Meta End Of Track */
public static boolean isMetaEndOfTrack(MidiMessage midiMsg) {
    // first check if it is a META message at all
    if (midiMsg.getLength() != 3
        || midiMsg.getStatus() != MetaMessage.META) {
        return false;
    }
    // now get message and check for end of track
    byte[] msg = midiMsg.getMessage();
    return ((msg[1] & 0xFF) == META_END_OF_TRACK_TYPE) && (msg[2] == 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:MidiUtils.java

示例4: isMetaTempo

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
/** return if the given message is a meta tempo message */
public static boolean isMetaTempo(MidiMessage midiMsg) {
    // first check if it is a META message at all
    if (midiMsg.getLength() != 6
        || midiMsg.getStatus() != MetaMessage.META) {
        return false;
    }
    // now get message and check for tempo
    byte[] msg = midiMsg.getMessage();
    // meta type must be 0x51, and data length must be 3
    return ((msg[1] & 0xFF) == META_TEMPO_TYPE) && (msg[2] == 3);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:MidiUtils.java

示例5: send

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public void send(MidiMessage message, long timeStamp)
    throws IllegalStateException
{
  if (message instanceof ShortMessage)
  {
    ShortMessage smessage = (ShortMessage) message;

    switch (message.getStatus())
    {
    case ShortMessage.NOTE_ON:
      int velocity = smessage.getData2();
      if (velocity > 0)
        channels[smessage.getChannel()].noteOn(smessage.getData1(),
                                               smessage.getData2());
      else
        channels[smessage.getChannel()].noteOff(smessage.getData1());
      break;
    case ShortMessage.CONTROL_CHANGE:
      channels[smessage.getChannel()].controlChange(smessage.getData1(),
                                                    smessage.getData2());
      break;
    default:
      System.out.println ("Unhandled message: " + message.getStatus());
      break;
    }
  }
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:DSSISynthesizer.java

示例6: send

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
@Override
public void send(MidiMessage message, long timeStamp) {
	int status = message.getStatus();
	System.out.println("Recieved [email protected]" + timeStamp + ", status=" + status);
	if (status == 144) {
		byte[] data = message.getMessage();
		int note = data[1];
		int velocity = data[2];
		System.out.printf("note=%d, velocity=%d\n", note, velocity);
	} else if (status == 128) {
		
	}
}
 
开发者ID:daveho,项目名称:Gervill4Beads,代码行数:14,代码来源:CaptureMidiMessagesTest.java

示例7: send

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public void send(MidiMessage message, long timeStamp)
    throws IllegalStateException
{
  if (message instanceof ShortMessage)
  {
    ShortMessage smessage = (ShortMessage) message;
  
    switch (message.getStatus())
    {
    case ShortMessage.NOTE_ON:
      int velocity = smessage.getData2();
      if (velocity > 0)
        channels[smessage.getChannel()].noteOn(smessage.getData1(), 
                                               smessage.getData2());
      else
        channels[smessage.getChannel()].noteOff(smessage.getData1());
      break;
    case ShortMessage.CONTROL_CHANGE:
      channels[smessage.getChannel()].controlChange(smessage.getData1(),
                                                    smessage.getData2());
      break;
    default:
      System.out.println ("Unhandled message: " + message.getStatus());
      break;
    }
  }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:28,代码来源:DSSISynthesizer.java

示例8: send

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public void send(MidiMessage message, long timeStamp) {

		// I hope no one is interested in these events
		if (message.getStatus() >= ShortMessage.MIDI_TIME_CODE)
			return;

		if (isLinux) {
			if (message.getStatus() == ShortMessage.PITCH_BEND) {
				ShortMessage mess = (ShortMessage) message;
				short low = (byte) mess.getData1();
				short high = (byte) mess.getData2();


				int channel = mess.getChannel();

                                // linux midi has a bug in the pitch bend this fixes the problem
				low = (byte) mess.getData1();
				high = (byte) mess.getData2();
				
				high= (short) ((high+64) & 0x007f);
				
				try {
					mess.setMessage(ShortMessage.PITCH_BEND, channel,
							low, high);
				} catch (InvalidMidiDataException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

		chained.send(message, timeStamp);
		notifyListeners(message);
	}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:35,代码来源:MonitorReceiver.java

示例9: midiMessage

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public void midiMessage(MidiMessage message) {
	if (!(message instanceof ShortMessage)) return;	
	
	if (message.getStatus() == ShortMessage.NOTE_ON) {
		float val=(float) ((((ShortMessage)message).getData1())/127.0);
		if (val > monitVal) monitVal=val;
	}
	
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:10,代码来源:MidiPeakMonitor.java

示例10: consume

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
/**
 * implements MidiFilter
 * 
 * @param mess   midimessage
 * @param stamp  time stamp
 * @return  true if the event was found in the map and used
 */
public boolean consume(MidiMessage mess, long stamp) {

    if (mess.getStatus() >= ShortMessage.MIDI_TIME_CODE) {
        return true;
    }
    if (!(mess instanceof ShortMessage)) {
        return true;
    }
    ShortMessage smsg = (ShortMessage) mess;

    if (learning) {
        System.out.println("LEARNING: ch cmd data1 data2: " + smsg.getChannel() + " " + smsg.getCommand() + " " + smsg.getData1() + " " + smsg.getData2());
        if (smsg.getCommand() == ShortMessage.NOTE_OFF) {
            return true; // let's ignore note offs for now
        }
        lastMessage = smsg;
        return true;
    } else {

        long key = MidiHashUtil.hashValue((ShortMessage) mess);
        ControlMapper mapper = map.get(key);
        if (mapper == null) {
            return false;
        }
        mapper.send(smsg, stamp);
        return true;

    }
   
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:38,代码来源:MidiEventRouter.java

示例11: messageReceived

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
@Override
	protected void messageReceived(Bead message) {
		if (Midi.hasMidiMessage(message)) {
			MidiMessage msg = Midi.getMidiMessage(message);
			if (msg instanceof ShortMessage) {
				// Note that NOTE_OFF messages are ignored.
				// NOTE_ON messages trigger the appropriate sample to be played.
				if (msg.getStatus() == ShortMessage.NOTE_ON) {
					//System.out.println("Sample note on?");
					// Find the appropriate SamplePlayer
					int note = ((ShortMessage)msg).getData1();
					final PlayerInfo sp = samplePlayers.get(note);
					if (sp != null) {
//						double time = ac.getTime();
//						System.out.printf("Play sample %d at %f from %f..%f ms\n", note, time, sp.range.startMs, sp.range.endMs);
						sp.player.reset();
						sp.player.setPosition(sp.range.startMs);
						float durationMs = (float)(sp.range.endMs - sp.range.startMs);
						
						sp.env.clear();
						float middleTimeMs = durationMs - 2*RAMP_TIME_MS;
						sp.env.addSegment(1.0f, RAMP_TIME_MS);
						if (middleTimeMs > 0) {
							sp.env.addSegment(1.0f, middleTimeMs);
						}
						sp.env.addSegment(0.0f, RAMP_TIME_MS);
						
						sp.player.start();
					}
				}
			}
		}
	}
 
开发者ID:daveho,项目名称:FunWithSound,代码行数:34,代码来源:SampleBankUGen.java

示例12: sendNoteOffIfOn

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
/**
 * chase all events from beginning of Track
 * and send note off for those events that are active
 * in noteOnCache array.
 * It is possible, of course, to catch notes from other tracks,
 * but better than more complicated logic to detect
 * which notes are really from this track
 */
private void sendNoteOffIfOn(Track track, long endTick) {
    int size = track.size();
    int done = 0;
    try {
        for (int i = 0; i < size; i++) {
            MidiEvent event = track.get(i);
            if (event.getTick() > endTick) break;
            MidiMessage msg = event.getMessage();
            int status = msg.getStatus();
            int len = msg.getLength();
            if (len == 3 && ((status & 0xF0) == ShortMessage.NOTE_ON)) {
                int note = -1;
                if (msg instanceof ShortMessage) {
                    ShortMessage smsg = (ShortMessage) msg;
                    if (smsg.getData2() > 0) {
                        // only consider Note On with velocity > 0
                        note = smsg.getData1();
                    }
                } else {
                    byte[] data = msg.getMessage();
                    if ((data[2] & 0x7F) > 0) {
                        // only consider Note On with velocity > 0
                        note = data[1] & 0x7F;
                    }
                }
                if (note >= 0) {
                    int bit = 1<<(status & 0x0F);
                    if ((noteOnCache[note] & bit) != 0) {
                        // the bit is set. Send Note Off
                        getTransmitterList().sendMessage(status | (note<<8), -1);
                        // clear the bit
                        noteOnCache[note] &= (0xFFFF ^ bit);
                        done++;
                    }
                }
            }
        }
    } catch (ArrayIndexOutOfBoundsException aioobe) {
        // this happens when messages are removed
        // from the track while this method executes
    }
    if (DEBUG_PUMP) Printer.println("  sendNoteOffIfOn: sent "+done+" messages.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:RealTimeSequencer.java

示例13: testMessage

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
private static boolean testMessage(MidiMessage message) {
    receivedMessage = null;
    baos = new ByteArrayOutputStream();
    expectedBytes = message.getLength();
    receivedBytes = 0;
    System.out.print("Sending message " + getMessageString(message.getMessage())+"...");
    receiver.send(message, -1);
    /* sending 3 bytes can roughly be done in 1 millisecond,
     * so this estimate waits at max 3 times longer than the message takes,
     * plus a little offset to allow the MIDI subsystem some processing time
     */
    int offset = 300; // standard offset 100 millis
    if (message instanceof SysexMessage) {
        // add a little processing time to sysex messages
        offset += 1000;
    }
    if (receivedBytes < expectedBytes) {
        sleep(expectedBytes + offset);
    }
    boolean equal;
    byte[] data = baos.toByteArray();
    if (data.length > 0) {
        equal = messagesEqual(message.getMessage(), data);
    } else {
        equal = messagesEqual(message, receivedMessage);
        if (receivedMessage != null) {
            data = receivedMessage.getMessage();
        } else {
            data = null;
        }
    }
    if (!equal) {
        if ((message.getStatus() & 0xF0) == ShortMessage.PITCH_BEND) {
            out("NOT failed (may expose a bug in ALSA)");
            equal = true;
            sleep(100);
        }
        if ((message.getStatus() == 0xF6) && (message.getLength() == 1)) {
            out("NOT failed (may expose an issue on Solaris)");
            equal = true;
            sleep(100);
        }
        else if ((message.getStatus()) == 0xF0 && message.getLength() < 4) {
            out("NOT failed (not a correct sys ex message)");
            equal = true;
            sleep(200);
        } else {
            out("FAILED:");
            out("  received as " + getMessageString(data));
        }
    } else {
        System.out.println("OK");
    }
    return equal;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:IOLoop.java

示例14: getStatus

import javax.sound.midi.MidiMessage; //导入方法依赖的package包/类
public static int getStatus(MidiMessage msg) {
    return msg.getStatus();
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:4,代码来源:MidiMsg.java


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