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


Java ShortMessage.getCommand方法代码示例

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


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

示例1: send

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public void send(MidiMessage inMessage, long inTimeStamp)
{
if(inMessage instanceof ShortMessage)
	{
	ShortMessage	mm = (ShortMessage)inMessage;
	
	switch(mm.getCommand())
		{
		case ShortMessage.NOTE_ON:
		case ShortMessage.NOTE_OFF:
			MiProvider.instance().noteReceived(mm, inTimeStamp);
			break;

		case ShortMessage.CONTROL_CHANGE:
			//System.err.println("Control change");
			break;
		}
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:20,代码来源:MiPort.java

示例2: render

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override
public void render() throws RenderCommandException {
	sleepUntil(getFrame().playOutTime);

	for(MidiMessage msg : getFrame().messages) {
		if(msg instanceof ShortMessage) {
			final ShortMessage sm = (ShortMessage)msg;
			final MidiChannel  ch = synth.getChannels()[sm.getChannel()];
			switch(sm.getCommand()) {
			case ShortMessage.NOTE_ON:
				ch.noteOn(sm.getData1(), sm.getData2());
				continue;
			case ShortMessage.NOTE_OFF:
				ch.noteOff(sm.getData1(), sm.getData2());
				continue;
			case ShortMessage.PROGRAM_CHANGE:
				ch.programChange(sm.getData1());
				continue;
			case ShortMessage.CONTROL_CHANGE:
				ch.controlChange(sm.getData1(), sm.getData2());
				continue;
			}
		}
		throw new RenderCommandException("Unknown MIDI Command:" + MidiToString.toString(msg));
	}
}
 
开发者ID:arisona,项目名称:ether,代码行数:27,代码来源:JavaMidiSynthesizerTarget.java

示例3: handle

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override
public void handle(MidiMessage msg) {
	if(msg instanceof ShortMessage) {
		ShortMessage smsg = (ShortMessage)msg;
		switch(smsg.getCommand()) {
		case ShortMessage.CONTROL_CHANGE:
			int cc = smsg.getData1();
			if(cc2run[cc] != null) cc2run[cc].handle(msg);
			break;
		case ShortMessage.NOTE_ON:
			int key = smsg.getData1();
			if(key2run[key] != null) key2run[key].handle(msg);
			break;
		case ShortMessage.PITCH_BEND:
			pitchBend.set(smsg);
			synchronized (processMidi) {processMidi.notifyAll();}
			break;
		}
	}
	System.out.println(MidiToString.toString(msg));
}
 
开发者ID:arisona,项目名称:ether,代码行数:22,代码来源:AbletonPush.java

示例4: calcLastNoteTick

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public long calcLastNoteTick()
{
	long lastNoteTick = 0;
	for (Track t : sequence.getTracks())
	{
		for (int j = t.size() - 1; j >= 0; j--)
		{
			MidiEvent evt = t.get(j);
			MidiMessage msg = evt.getMessage();
			if (msg instanceof ShortMessage)
			{
				ShortMessage m = (ShortMessage) msg;
				if (m.getCommand() == ShortMessage.NOTE_OFF)
				{
					if (evt.getTick() > lastNoteTick)
					{
						lastNoteTick = evt.getTick();
					}
					break;
				}
			}
		}
	}

	return lastNoteTick;
}
 
开发者ID:digero,项目名称:maestro,代码行数:27,代码来源:SequenceInfo.java

示例5: send

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public void send(MidiMessage message, long timeStamp) {
	if (message instanceof ShortMessage) {
		ShortMessage sm = ((ShortMessage)message);
		switch(sm.getCommand()) {
		case ShortMessage.CONTROL_CHANGE:
			System.out.println(sm.getChannel());
			System.out.println(sm.getData1());
			System.out.println(sm.getData2());
			MidiControlChangedListener listener = listenersDic.get(sm.getData1());
			if(listener != null){
				listener.changed(sm.getData1(), sm.getData2());
			}
			break;
		}
	}
	System.out.println("midi received");
}
 
开发者ID:soma-arc,项目名称:K-Visions,代码行数:18,代码来源:MidiInputReceiver.java

示例6: send

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override public void send(MidiMessage message, long timeStamp)
{
	if (receiver == null)
		return;

	if (hasAbcPart && message instanceof ShortMessage)
	{
		ShortMessage m = (ShortMessage) message;
		int c = m.getChannel();
		int cmd = m.getCommand();
		int noteId = m.getData1();
		int speed = m.getData2();
		boolean noteOnMsg = (cmd == ShortMessage.NOTE_ON) && speed > 0;
		boolean noteOffMsg = (cmd == ShortMessage.NOTE_OFF) || (cmd == ShortMessage.NOTE_ON && speed == 0);

		if (!isNoteActive(noteId) && !(isNoteOn(c, noteId) && noteOffMsg))
			return;

		if (noteOnMsg)
			setNoteOn(c, noteId, true);
		else if (noteOffMsg)
			setNoteOn(c, noteId, false);
	}

	receiver.send(message, timeStamp);
}
 
开发者ID:digero,项目名称:maestro,代码行数:27,代码来源:NoteFilterTransceiver.java

示例7: interceptMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public final void interceptMessage(MidiMessage msg, Receiver receiver)
{
    try
    {
        ShortMessage shm = (ShortMessage)msg;
        if(shm.getCommand() == ShortMessage.NOTE_ON)
        {
            if(shm.getData2()==0)
            {
                pendingNoteOffs.get(receiver).remove(shm.getChannel() << 8 | shm.getData1());
            }
            else
            {
                if(!pendingNoteOffs.containsKey(receiver))
                    pendingNoteOffs.put(receiver,new HashSet<Integer>());
             
                pendingNoteOffs.get(receiver).add(shm.getChannel() << 8 | shm.getData1());
            }
        }
    } catch(Exception e) {}
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:22,代码来源:NoteOnCache.java

示例8: send

import javax.sound.midi.ShortMessage; //导入方法依赖的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

示例9: receive

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
private void receive(MidiMessage message, long sample)
{
    if (message instanceof ShortMessage)
    {
        ShortMessage msg = (ShortMessage)message;
        
        if (listening) switch (msg.getCommand())
        {
            case ShortMessage.CONTROL_CHANGE:
                typeSelect.setValue(0);
                controller = msg.getData1();
                controllerBox.setText(Integer.toString(controller));
                break;
            case ShortMessage.CHANNEL_PRESSURE:
                typeSelect.setValue(1);
                break;
            case ShortMessage.PITCH_BEND:
                typeSelect.setValue(2);
                break;
        }
        else switch (msg.getCommand())
        {
            case ShortMessage.CONTROL_CHANGE:
                if (type == 0 && msg.getData1() == controller) targetValue = msg.getData2()/63.5f - 1.0f;
                break;
            case ShortMessage.CHANNEL_PRESSURE:
                if (type == 1) targetValue = msg.getData1()/63.5f - 1.0f;
                break;
            case ShortMessage.PITCH_BEND:
                if (type == 2) targetValue = ((msg.getData2() << 7) | msg.getData1())/8191.5f - 1.0f;
                break;
        }
    }
}
 
开发者ID:SmashMaster,项目名称:KraftigAudio,代码行数:35,代码来源:MidiDecoder.java

示例10: toHexString

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
private static String toHexString(ShortMessage sm) {
	int status = sm.getStatus();
	String res = TextUtilities.byteToHex(sm.getStatus());
	switch (status) {
	case 0xF6: // Tune Request
	case 0xF7: // EOX
		// System real-time messages
	case 0xF8: // Timing Clock
	case 0xF9: // Undefined
	case 0xFA: // Start
	case 0xFB: // Continue
	case 0xFC: // Stop
	case 0xFD: // Undefined
	case 0xFE: // Active Sensing
	case 0xFF:
		return res;
	}
	res += ' ' + TextUtilities.byteToHex(sm.getData1());
	// if 2-byte message, return
	switch (status) {
	case 0xF1: // MTC Quarter Frame
	case 0xF3: // Song Select
		return res;
	}
	switch (sm.getCommand()) {
	case 0xC0:
	case 0xD0:
		return res;
	}
	// 3-byte messages left
	res += ' ' + TextUtilities.byteToHex(sm.getData2());
	return res;
}
 
开发者ID:arisona,项目名称:ether,代码行数:34,代码来源:MidiToString.java

示例11: calcFirstNoteTick

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public long calcFirstNoteTick()
{
	long firstNoteTick = Long.MAX_VALUE;
	for (Track t : sequence.getTracks())
	{
		for (int j = 0; j < t.size(); j++)
		{
			MidiEvent evt = t.get(j);
			MidiMessage msg = evt.getMessage();
			if (msg instanceof ShortMessage)
			{
				ShortMessage m = (ShortMessage) msg;
				if (m.getCommand() == ShortMessage.NOTE_ON)
				{
					if (evt.getTick() < firstNoteTick)
					{
						firstNoteTick = evt.getTick();
					}
					break;
				}
			}
		}
	}
	if (firstNoteTick == Long.MAX_VALUE)
		return 0;
	return firstNoteTick;
}
 
开发者ID:digero,项目名称:maestro,代码行数:28,代码来源:SequenceInfo.java

示例12: decodeShortMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
private Note decodeShortMessage(ShortMessage message, Track track, int nEvent, double unitTime) {
    if ((message.getCommand() != MIDIMessageCode.NoteOn) || (message.getData2() <= 0)) {
        return null;
    }
    int keyNumber = message.getData1();
    int velocity = message.getData2();
    double startTime = track.get(nEvent).getTick() * unitTime;
    double length = 0;
    long noteOffTime = findNearestNoteOff(track, nEvent, message);
    if (noteOffTime > -1) {
        length = (noteOffTime - track.get(nEvent).getTick()) * unitTime;
    }
    return new Note(keyNumber, velocity, startTime, length);
}
 
开发者ID:shuichi,项目名称:MediaMatrix,代码行数:15,代码来源:MidiAnalyzer.java

示例13: send

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override public void send(MidiMessage message, long timeStamp)
{
	boolean systemReset = false;
	if (message instanceof ShortMessage)
	{
		ShortMessage m = (ShortMessage) message;
		if (m.getCommand() == ShortMessage.SYSTEM_RESET)
		{
			Arrays.fill(channelVolume, UNSET_CHANNEL_VOLUME);
			systemReset = true;
		}
		else if (m.getCommand() == ShortMessage.CONTROL_CHANGE && m.getData1() == CHANNEL_VOLUME_CONTROLLER_COARSE)
		{
			try
			{
				int c = m.getChannel();
				channelVolume[c] = m.getData2();
				m.setMessage(m.getCommand(), c, CHANNEL_VOLUME_CONTROLLER_COARSE, getActualVolume(c));
			}
			catch (InvalidMidiDataException e)
			{
				e.printStackTrace();
			}
		}
	}

	if (receiver != null)
	{
		receiver.send(message, timeStamp);
		if (systemReset)
			sendVolumeAllChannels();
	}
}
 
开发者ID:digero,项目名称:maestro,代码行数:34,代码来源:VolumeTransceiver.java

示例14: send

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public void send(MidiMessage message, long timeStamp) {
    
    try
    {
        midiDevice.getReceiver().send(message,timeStamp);
        
        // Check if short message and update the gui
        if(message instanceof ShortMessage)
        {
            ShortMessage shm = (ShortMessage)message;
            int channel = shm.getChannel();
    
            // Pass the message onto midi device
            
            if(shm.getCommand() == ShortMessage.NOTE_ON)
            {
            }
            else if(shm.getCommand() == ShortMessage.CONTROL_CHANGE)
            {
                if(gui!=null && shm.getData1()==7)
                    gui.mixerSlots[channel].setVolume(shm.getData2());
                else if(gui!=null && shm.getData1()==10)
                    gui.mixerSlots[channel].setPan(shm.getData2());
            }
            else if(shm.getCommand() == ShortMessage.PITCH_BEND)
            {
                
            }
        }
    }
    catch(Exception e) {
        // For debugging
        //e.printStackTrace();
    }
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:36,代码来源:MidiOutDeviceWrapper.java

示例15: consume

import javax.sound.midi.ShortMessage; //导入方法依赖的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


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