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


Java ShortMessage.getData2方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: send

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

示例7: openFileByMasterMidiMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
/**
 * Opens a file by midi message
 * 
 * @param message
 *            The midi message
 */
public void openFileByMasterMidiMessage(MidiMessage message) {

	if (message instanceof ShortMessage) {
		ShortMessage shortMessage = (ShortMessage) message;

		if (shortMessage.getCommand() == OPEN_FILE_MIDI_COMMAND
				&& (shortMessage.getChannel() + 1) == OPEN_FILE_MIDI_CHANNEL
				&& shortMessage.getData1() == OPEN_FILE_MIDI_CONTROL_NO) {

			int index = shortMessage.getData2();
			fileListService.selectEntryByIndex(index, false);
		}
	}
}
 
开发者ID:aguelle,项目名称:MIDI-Automator,代码行数:21,代码来源:MidiExecuteService.java

示例8: handleShortMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
/**
 * Parses and routes MIDI short messages to adequate sub-handlers.
 *
 * @param message The inconming message.
 * @param timestamp When the message arrived.
 */
protected void handleShortMessage(ShortMessage message, long timestamp) {
    int status = message.getStatus();
    int note = message.getData1();
    int velocity = message.getData2();

    if (status == ShortMessage.NOTE_ON) {
        handleNoteOnMessage(note, velocity, timestamp);
    } else if (status == ShortMessage.CONTROL_CHANGE) {
        handleControlChangeMessage(note, velocity, timestamp);
    } else {
        throw new LaunchpadException("Unknown event : " + message);
    }
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:20,代码来源:DefaultMidiProtocolReceiver.java

示例9: 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

示例10: NoteEvent

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
/**
 * The process generating the NoteEvent should first supply it start event, 
 * and when ready the end event - to form a complete Note event
 * @param startEvent
 * 
 */
NoteEvent(MidiPart part, MidiEvent startEvent)
{
    super(part,startEvent.getTick());
    this.startEvent = startEvent;
    ShortMessage shm = (ShortMessage)startEvent.getMessage();
    note = shm.getData1();
    velocity = shm.getData2();
    channel = shm.getChannel();
    startTick = startEvent.getTick();
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:17,代码来源:NoteEvent.java

示例11: send

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

示例12: midiMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public void midiMessage(MidiMessage message) {
	if(listenlane.isRecording())
	{
		if(table.getSelectedRow() == -1 || table.getSelectedColumn() == -1) return;
		if(((table.getSelectedColumn() - 1)  % TrackerTableModel.COLUMNS) != TrackerTableModel.COLUMN_NOTEORCC) return; 
	
		
		if(message instanceof ShortMessage)
		{
			ShortMessage sms = (ShortMessage)message; 
			if(sms.getCommand() == ShortMessage.NOTE_ON || sms.getCommand() == ShortMessage.NOTE_OFF )
			{						
				int note = sms.getData1();
				int vel = sms.getData2();
				if(sms.getCommand() == ShortMessage.NOTE_OFF) vel = 0;						
				if(vel > 0)
				{
					int row = table.getSelectedRow();
					int col = tableModel.tableColumnToTrackerColumn(table.getSelectedColumn());
					
					part.getEditHistoryContainer().mark("new note");
					
					final MultiEvent me = tableModel.getCellEvent(row, col);
					if(me != null)
						part.remove(me);
					
					NoteEvent event = new NoteEvent(part,tableModel.getTickForRow(row),note,vel,1,(long)(tableModel.ticksPerRow*tableModel.getEditDuration()));
			        event.setTrackerColumn(col);
			        part.add(event);
					part.getEditHistoryContainer().notifyEditHistoryListeners();	 
					
					if(getAutomaticRowJump()>0 )
						table.changeSelection(table.getSelectedRow()+getAutomaticRowJump(),table.getSelectedColumn(),false,false);
				}						
			}
			
		}
	}
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:40,代码来源:TrackerPanel.java

示例13: noteOn

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override
	public void noteOn(ShortMessage smsg, int note) {
//		System.out.printf("Env note on note=%d\n", note);
		envelope.clear();
		int velocity = smsg.getData2();
		float minGain = Util.getFloat(params, ParamNames.MIN_GAIN);
		float gain = minGain + ((1.0f - minGain) * (velocity/127.0f));
		float attackTimeMs = Util.getFloat(params, ParamNames.ATTACK_TIME_MS);
//		System.out.printf("Ramp to gain %f in %f ms\n", gain, attackTimeMs);
		envelope.addSegment(gain, attackTimeMs);
	}
 
开发者ID:daveho,项目名称:FunWithSound,代码行数:12,代码来源:ASRNoteEnvelope.java

示例14: 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

示例15: FastShortMessage

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
/** Creates a FastShortMessage from this ShortMessage */
FastShortMessage(ShortMessage msg) {
    this.packedMsg = msg.getStatus()
        | (msg.getData1() << 8)
        | (msg.getData2() << 16);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:FastShortMessage.java


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