本文整理汇总了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) {}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
}
}
}
}
示例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);
}
示例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();
}
}
示例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);
}