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


Java ShortMessage.getData1方法代码示例

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


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

示例1: sendControllerEvents

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
/**
 * Send midi player events.
 */
void sendControllerEvents(MidiMessage message) {
    int size = controllerEventListeners.size();
    if (size == 0) return;

    //if (Printer.debug) Printer.debug("sending a controller event");

    if (! (message instanceof ShortMessage)) {
        if (Printer.debug) Printer.debug("sendControllerEvents: message is NOT instanceof ShortMessage!");
        return;
    }
    ShortMessage msg = (ShortMessage) message;
    int controller = msg.getData1();
    List<Object> sendToListeners = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        ControllerListElement cve = controllerEventListeners.get(i);
        for(int j = 0; j < cve.controllers.length; j++) {
            if (cve.controllers[j] == controller) {
                sendToListeners.add(cve.listener);
                break;
            }
        }
    }
    getEventDispatcher().sendAudioEvents(message, sendToListeners);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:RealTimeSequencer.java

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

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

示例5: messageReceived

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
@Override
protected void messageReceived(Bead message) {
	if (Midi.hasMidiMessage(message)) {
		MidiMessage msg = Midi.getMidiMessage(message);
		
		if (msg instanceof ShortMessage) {
			ShortMessage smsg = (ShortMessage) msg;
			int note = smsg.getData1();
			
			if (smsg.getCommand() == ShortMessage.NOTE_ON) {
				onNoteOn(smsg, note);
			} else if (smsg.getCommand() == ShortMessage.NOTE_OFF) {
				// Only requests to stop playing the current note will be honored
				if (note == this.note) {
					onNoteOff(smsg, note);
				}
			}
		}
	}
}
 
开发者ID:daveho,项目名称:FunWithSound,代码行数:21,代码来源:MonoSynthUGen2.java

示例6: main

import javax.sound.midi.ShortMessage; //导入方法依赖的package包/类
public static void main(String argv[]) throws Exception {
    Sequence seq = new Sequence(Sequence.PPQ, 240);
    Track t = seq.createTrack();

    log("add 10 events in random order");
    t.add(createEvent(10, 5));
    t.add(createEvent(0, 0));
    t.add(createEvent(10, 6));
    t.add(createEvent(11, 8));
    t.add(createEvent(10, 7));
    t.add(createEvent(0, 1));
    t.add(createEvent(0, 2));
    t.add(createEvent(15, 9));
    t.add(createEvent(0, 3));
    t.add(createEvent(1, 4));

    // now compare the events.
    // The note param will tell us the
    // the expected position
    long lastTick = 0;
    for (int i = 0; i < t.size(); i++) {
        MidiEvent ev = t.get(i);
        if (ev.getMessage() instanceof ShortMessage) {
            ShortMessage msg = (ShortMessage) ev.getMessage();
            log(""+i+": ShortMessage at tick "+ev.getTick()
                +" with expected position "+msg.getData1());
            if (ev.getTick() < lastTick) {
                log("  FAILED: last tick is larger than this event's tick!");
                failed = true;
            }
            if (i != msg.getData1()) {
                log("  FAILED: Track did not order correctly.");
                failed = true;
            }
        }
    }

    if (failed) throw new Exception("Test FAILED!");
    log("Test passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:TrackAddSameTick.java

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

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

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

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

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

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

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

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


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