Java Code Examples for javax.sound.midi.ShortMessage#NOTE_OFF
The following examples show how to use
javax.sound.midi.ShortMessage#NOTE_OFF .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MidiWaveformSynthesizer.java From chart-fx with Apache License 2.0 | 6 votes |
public static final void addNotesToTrack(final Track track, final Track trk) throws InvalidMidiDataException { for (int ii = 0; ii < track.size(); ii++) { final MidiEvent me = track.get(ii); final MidiMessage mm = me.getMessage(); if (mm instanceof ShortMessage) { final ShortMessage sm = (ShortMessage) mm; final int command = sm.getCommand(); int com = -1; if (command == ShortMessage.NOTE_ON) { com = LOCAL_NOTE_ON; } else if (command == ShortMessage.NOTE_OFF) { com = LOCAL_NOTE_OFF; } if (com > 0) { final byte[] b = sm.getMessage(); final int l = (b == null ? 0 : b.length); final MetaMessage metaMessage = new MetaMessage(com, b, l); final MidiEvent me2 = new MidiEvent(metaMessage, me.getTick()); trk.add(me2); } } } }
Example 2
Source File: MiPort.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
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; } } }
Example 3
Source File: MidiReceiverImpl.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
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)); } } }
Example 4
Source File: SoftMainMixer.java From hottub with GNU General Public License v2.0 | 4 votes |
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; } }
Example 5
Source File: SoftMainMixer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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; } }
Example 6
Source File: SoftMainMixer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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; } }
Example 7
Source File: SoftMainMixer.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
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; } }
Example 8
Source File: MiProvider.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
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; } } } }
Example 9
Source File: SoftMainMixer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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; } }
Example 10
Source File: SoftMainMixer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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; } }
Example 11
Source File: SoftMainMixer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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; } }
Example 12
Source File: SoftMainMixer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
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; } }
Example 13
Source File: SoftMainMixer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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; } }
Example 14
Source File: SoftMainMixer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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; } }
Example 15
Source File: SoftMainMixer.java From Bytecoder with Apache License 2.0 | 4 votes |
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; } }
Example 16
Source File: SoftMainMixer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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; } }
Example 17
Source File: SoftMainMixer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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; } }
Example 18
Source File: SoftMainMixer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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; } }
Example 19
Source File: MidiWaveformSynthesizer.java From chart-fx with Apache License 2.0 | 4 votes |
public void decode(final float[] data, final int frameSize, final int updatePeriod, final int samplingRate, final int nBits) { if (frameSize <= 0) { throw new IllegalArgumentException("Frame size must be greater than zero"); } final Track track = mergeShortMessageEvent(sequence.getTracks()); final float length = 1e-6f * sequence.getMicrosecondLength(); final float ts = 1.0f / samplingRate; final long trackTicks = track.ticks(); final float tickLength = trackTicks <= 0 ? 0 : length / trackTicks; final int frameCount = data.length / frameSize; final float scale = 2 << Math.max(1, nBits + 1); final int fftSize = 2 * frameSize; final FloatFFT_1D fft = new FloatFFT_1D(fftSize); final float[] apodization = new float[fftSize]; for (int i = 0; i < fftSize; i++) { apodization[i] = (float) Apodization.Hann.getIndex(i, apodization.length); } int frameCounter = 0; int tickIndex = 0; final float[] waveForm = new float[2 * frameSize]; final int nUpdateDistance = (int) (updatePeriod / 1000.0 * samplingRate); for (int i = 0; frameCounter < frameCount; i++) { final float t = i * ts; final MidiEvent tickEvt = track.get(tickIndex); final float tickTimeStamp = tickEvt.getTick() * tickLength; // update waveform by one sample update(samplingRate, nBits); if ((t > tickTimeStamp) && (tickIndex < track.size() - 1)) { if ((tickEvt.getMessage() instanceof ShortMessage)) { final ShortMessage sm = (ShortMessage) tickEvt.getMessage(); final int note = sm.getData1() & 0xFF; final int velocity = sm.getData2() & 0xFF; final int command = sm.getCommand(); if ((command == ShortMessage.NOTE_ON) || (command == LOCAL_NOTE_ON)) { noteAmplitude[note] = velocity; } else if ((command == ShortMessage.NOTE_OFF) || (command == LOCAL_NOTE_OFF)) { noteAmplitude[note] = 0.0f; } } tickIndex++; } if (i > 0 && (i % nUpdateDistance == 0)) { for (int j = 0; j < waveForm.length; j++) { final float noise = (1e-3f * System.nanoTime() % 2); // adds some noise waveForm[j] = apodization[j] * getSample(j) + noise / scale; } decodeFrame(fft, waveForm, data, (frameCounter * frameSize) % data.length); frameCounter++; } } // return synthesizer to its original state for (int note = 0; note < N_NOTES; note++) { noteAmplitude[note] = 0.0f; synthesizerChannel.noteOff(note, 0); } }
Example 20
Source File: SoftMainMixer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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; } }