本文整理汇总了Java中javax.sound.midi.ShortMessage.NOTE_OFF属性的典型用法代码示例。如果您正苦于以下问题:Java ShortMessage.NOTE_OFF属性的具体用法?Java ShortMessage.NOTE_OFF怎么用?Java ShortMessage.NOTE_OFF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.sound.midi.ShortMessage
的用法示例。
在下文中一共展示了ShortMessage.NOTE_OFF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseMessage
private void parseMessage(MidiMessage message) throws MidiPlayerException{
byte[] data = message.getMessage();
if( data.length > 0 ){
//NOTE ON
if(((data[0] & 0xFF) & 0xF0) == ShortMessage.NOTE_ON){
parseNoteOn(data, findChannel(message), findVoice(message), findBendMode(message));
}
//NOTE OFF
else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.NOTE_OFF){
parseNoteOff(data, findChannel(message), findVoice(message), findBendMode(message));
}
//PITCH BEND
else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.PITCH_BEND){
parsePitchBend(data, findChannel(message), findVoice(message), findBendMode(message));
}
//PROGRAM CHANGE
else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.PROGRAM_CHANGE){
parseProgramChange(data, findChannel(message));
}
//CONTROL CHANGE
else if(((data[0] & 0xFF) & 0xF0) == ShortMessage.CONTROL_CHANGE){
parseControlChange(data, findChannel(message));
}
}
}
示例2: send
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;
}
}
}
示例3: render
@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));
}
}
示例4: isRunningStatusMessage
/**
* Checks whether a status byte represents a running-status message, which means that multiple messages can be
* sent without re-sending the status byte, for example to support multiple note-on messages in a row by simply
* sending a stream of data byte pairs after the note-on status byte.
*
* @param status the status byte which is being processed.
*
* @return true if we should stay in this status after receiving our full complement of data bytes.
*/
private boolean isRunningStatusMessage (int status) {
switch( status & 0xF0 ) {
case ShortMessage.NOTE_OFF:
case ShortMessage.NOTE_ON:
case ShortMessage.POLY_PRESSURE:
case ShortMessage.CONTROL_CHANGE:
case ShortMessage.PROGRAM_CHANGE:
case ShortMessage.CHANNEL_PRESSURE:
case ShortMessage.PITCH_BEND:
return true;
default:
return false;
}
}
示例5: messageReceived
@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);
}
}
}
}
}
示例6: calcLastNoteTick
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;
}
示例7: send
@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);
}
示例8: midiMessage
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);
}
}
}
}
}
示例9: consume
/**
* 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;
}
}
示例10: processMessage
public void processMessage(int ch, int cmd, int data1, int data2) {
synchronized (synth.control_mutex) {
activity();
}
if (cmd == 0xF0) {
int status = cmd | ch;
switch (status) {
case ShortMessage.ACTIVE_SENSING:
synchronized (synth.control_mutex) {
active_sensing_on = true;
}
break;
default:
break;
}
return;
}
SoftChannel[] channels = synth.channels;
if (ch >= channels.length)
return;
SoftChannel softchannel = channels[ch];
switch (cmd) {
case ShortMessage.NOTE_ON:
if(delay_midievent != 0)
softchannel.noteOn(data1, data2, delay_midievent);
else
softchannel.noteOn(data1, data2);
break;
case ShortMessage.NOTE_OFF:
softchannel.noteOff(data1, data2);
break;
case ShortMessage.POLY_PRESSURE:
softchannel.setPolyPressure(data1, data2);
break;
case ShortMessage.CONTROL_CHANGE:
softchannel.controlChange(data1, data2);
break;
case ShortMessage.PROGRAM_CHANGE:
softchannel.programChange(data1);
break;
case ShortMessage.CHANNEL_PRESSURE:
softchannel.setChannelPressure(data1);
break;
case ShortMessage.PITCH_BEND:
softchannel.setPitchBend(data1 + data2 * 128);
break;
default:
break;
}
}
示例11: if
public void noteReceived(ShortMessage inMessage, long inTimeStamp)
{
byte pitch = (byte)inMessage.getData1(),
velocity = (byte)inMessage.getData2(),
stringIndex = (byte)getString(inMessage.getChannel());
if(stringIndex != -1)
{
byte fretIndex = (byte)getFret(pitch, stringIndex);
if(fretIndex != -1)
{
switch(inMessage.getCommand())
{
case ShortMessage.NOTE_ON:
{
switch(f_Mode)
{
case MiConfig.MODE_FRETBOARD_ECHO:
if(velocity == 0 || velocity > f_MinVelocity) // questo VA MODIFICATO!!!
echo(stringIndex, fretIndex, velocity > 0);
break;
case MiConfig.MODE_CHORDS_RECORDING:
if(velocity == 0 || velocity > f_MinVelocity) // questo VA MODIFICATO!!!
echo(stringIndex, fretIndex, velocity > 0);
chord_AddNote(stringIndex, fretIndex, pitch, velocity, inTimeStamp);
break;
case MiConfig.MODE_SCALES_RECOGNITION:
if(velocity == 0 || velocity > f_MinVelocity) // questo VA MODIFICATO!!!
echo(stringIndex, fretIndex, velocity > 0);
scale_AddNote(stringIndex, fretIndex, pitch, velocity, inTimeStamp);
break;
case MiConfig.MODE_SONG_RECORDING:
if(velocity == 0 || velocity > f_MinVelocity) // questo VA MODIFICATO!!!
echo(stringIndex, fretIndex, velocity > 0);
MiRecorder.instance().addNote(stringIndex, fretIndex, pitch, velocity, inTimeStamp);
break;
}
}
break;
case ShortMessage.NOTE_OFF:
switch(f_Mode)
{
case MiConfig.MODE_FRETBOARD_ECHO:
echo(stringIndex, fretIndex, false);
break;
case MiConfig.MODE_CHORDS_RECORDING:
echo(stringIndex, fretIndex, false);
chord_AddNote(stringIndex, fretIndex, pitch, (byte)0, inTimeStamp);
break;
case MiConfig.MODE_SCALES_RECOGNITION:
echo(stringIndex, fretIndex, false);
scale_AddNote(stringIndex, fretIndex, pitch, (byte)0, inTimeStamp);
break;
case MiConfig.MODE_SONG_RECORDING:
echo(stringIndex, fretIndex, false);
MiRecorder.instance().addNote(stringIndex, fretIndex, pitch, (byte)0, inTimeStamp);
break;
}
break;
}
}
}
}
示例12: processMessage
public void processMessage(int ch, int cmd, int data1, int data2) {
synchronized (synth.control_mutex) {
activity();
}
if (cmd == 0xF0) {
int status = cmd | ch;
switch (status) {
case ShortMessage.ACTIVE_SENSING:
synchronized (synth.control_mutex) {
active_sensing_on = true;
}
break;
default:
break;
}
return;
}
SoftChannel[] channels = synth.channels;
if (ch >= channels.length)
return;
SoftChannel softchannel = channels[ch];
switch (cmd) {
case ShortMessage.NOTE_ON:
softchannel.noteOn(data1, data2);
break;
case ShortMessage.NOTE_OFF:
softchannel.noteOff(data1, data2);
break;
case ShortMessage.POLY_PRESSURE:
softchannel.setPolyPressure(data1, data2);
break;
case ShortMessage.CONTROL_CHANGE:
softchannel.controlChange(data1, data2);
break;
case ShortMessage.PROGRAM_CHANGE:
softchannel.programChange(data1);
break;
case ShortMessage.CHANNEL_PRESSURE:
softchannel.setChannelPressure(data1);
break;
case ShortMessage.PITCH_BEND:
softchannel.setPitchBend(data1 + data2 * 128);
break;
default:
break;
}
}
示例13: decodeMessage
private static String decodeMessage(ShortMessage message) {
String result = null;
switch (message.getCommand()) {
case ShortMessage.NOTE_OFF:
result = "note Off " + keyName(message.getData1()) + " velocity: " + message.getData2();
break;
case ShortMessage.NOTE_ON:
result = "note On " + keyName(message.getData1()) + " velocity: " + message.getData2();
break;
case ShortMessage.POLY_PRESSURE:
result = "polyphonic key pressure " + keyName(message.getData1()) + " pressure: " + message.getData2();
break;
case ShortMessage.CONTROL_CHANGE:
if(message.getData1() == 1) result = "Using channel " + (message.getData2() >> 3);
else result = "control change " + message.getData1() + " value: " + message.getData2();
break;
case ShortMessage.PROGRAM_CHANGE:
result = "program change " + message.getData1();
break;
case 0xd0:
result = "key pressure " + keyName(message.getData1()) + " pressure: " + message.getData2();
break;
case ShortMessage.PITCH_BEND:
result = "pitch wheel change " + MidiIO.toInt14(message.getData1(), message.getData2());
break;
case 0xF0:
result = SYSTEM_MESSAGES[message.getChannel()];
switch (message.getChannel()) {
case 0x1:
int nQType = (message.getData1() & 0x70) >> 4;
int nQData = message.getData1() & 0x0F;
if (nQType == 7)
nQData = nQData & 0x1;
result += QUARTER_FRAME_MESSAGES[nQType] + nQData;
if (nQType == 7) {
int nFrameType = (message.getData1() & 0x06) >> 1;
result += ", frame type: " + FRAME_TYPE[nFrameType];
}
break;
case 0x2:
result += MidiIO.toInt14(message.getData1(), message.getData2());
break;
case 0x3:
result += message.getData1();
break;
}
break;
default:
result = "unknown message: status = " + message.getStatus() + ", byte1 = " + message.getData1() + ", byte2 = " + message.getData2();
break;
}
if (message.getCommand() != 0xF0)
result = "channel " + (message.getChannel() + 1) + ": " + result;
return "["+toHexString(message)+"] "+ result;
}
示例14: encodeCommand
/**
* Encodes the midi command from a readable string
*
* @param command
* The command as readable string
* @return The midi encoded command, -1 if it could not be encoded
*/
private static int encodeCommand(String command) {
int result;
switch (command) {
case NOTE_OFF:
result = ShortMessage.NOTE_OFF;
break;
case NOTE_ON:
result = ShortMessage.NOTE_ON;
break;
case POLYPHONIC_KEY_PRESSURE:
result = ShortMessage.POLY_PRESSURE;
break;
case CONTROL_CHANGE:
result = ShortMessage.CONTROL_CHANGE;
break;
case PROGRAM_CHANGE:
result = ShortMessage.PROGRAM_CHANGE;
break;
case KEY_PRESSURE:
result = 0xd0;
break;
case PITCH_WHEEL_CHANGE:
result = 0xe0;
break;
case SYSTEM_MESSAGE:
result = 0xF0;
default:
result = -1;
break;
}
return result;
}
示例15: expectedDataLength
/**
* Determine how many data bytes are expected for a given MIDI message other than a SYSEX message, which varies.
*
* @param status the status byte introducing the MIDI message.
*
* @return the number of data bytes which must be received for the message to be complete.
*
* @throws InvalidMidiDataException if the status byte is not valid.
*/
private int expectedDataLength (byte status) throws InvalidMidiDataException {
// system common and system real-time messages
switch( status &0xFF ) {
case ShortMessage.TUNE_REQUEST:
case ShortMessage.END_OF_EXCLUSIVE:
// System real-time messages
case ShortMessage.TIMING_CLOCK:
case 0xF9: // Undefined
case ShortMessage.START:
case ShortMessage.CONTINUE:
case ShortMessage.STOP:
case 0xFD: // Undefined
case ShortMessage.ACTIVE_SENSING:
case ShortMessage.SYSTEM_RESET:
return 0;
case ShortMessage.MIDI_TIME_CODE:
case ShortMessage.SONG_SELECT:
return 1;
case ShortMessage.SONG_POSITION_POINTER:
return 2;
default: // Fall through to next switch
}
// channel voice and mode messages
switch( status & 0xF0 ) {
case ShortMessage.NOTE_OFF:
case ShortMessage.NOTE_ON:
case ShortMessage.POLY_PRESSURE:
case ShortMessage.CONTROL_CHANGE:
case ShortMessage.PITCH_BEND:
return 2;
case ShortMessage.PROGRAM_CHANGE:
case ShortMessage.CHANNEL_PRESSURE:
return 1;
default:
throw new InvalidMidiDataException("Invalid status byte: " + status);
}
}