List of usage examples for javax.sound.midi InvalidMidiDataException printStackTrace
public void printStackTrace()
From source file:org.monome.pages.MIDISequencerPagePoly.java
private void handleRecordButton(int x, int y) { int x_seq;//from www . ja va 2s . c o m int y_seq; int seqPosition = 0; int globalPitch; if (this.patSpeed[this.bank] == 0) { seqPosition = this.sequencePosition0; globalPitch = this.globalPitch0; } else { seqPosition = this.sequencePosition1; globalPitch = this.globalPitch1; } x_seq = (pattern * (this.monome.sizeX)) + x; y_seq = (depth * (this.monome.sizeY - 1)) + y; if (this.sequence[this.bank][x_seq][y_seq] == 0) { this.sequence[this.bank][x_seq][y_seq] = 1; this.monome.led(x, y, 1, this.index); } else if (this.sequence[this.bank][x_seq][y_seq] == 1) { this.sequence[bank][x_seq][y_seq] = 2; this.monome.led(x, y, 1, this.index); } else if (this.sequence[this.bank][x_seq][y_seq] == 2) { this.sequence[bank][x_seq][y_seq] = 0; //note off for bug when toggle note off at seq_position int note_num = 0; ShortMessage note_out = new ShortMessage(); note_num = this.getNoteNumber(y_seq) + globalPitch + this.patOctgUp[this.bank] * 24; if ((seqPosition % this.patlength[this.bank] == x_seq + 1 || seqPosition % this.patlength [this.bank] == x_seq)) { try { note_out.setMessage(ShortMessage.NOTE_OFF, 0, note_num, 0); if (this.recv != null) this.recv.send(note_out, -1); } catch (InvalidMidiDataException e) { e.printStackTrace(); } } this.monome.led(x, y, 0, this.index); } }
From source file:org.monome.pages.MIDISequencerPagePoly.java
public void stopNotes(int iSeq) { ShortMessage note_out = new ShortMessage(); int note_num = 0; int velocity = 0; int seq_pos_pat = 0; int velocityPrec = 0; int seqPosition = 0; int globalPitch = 0; int globalPitchOct = 0; if (this.patSpeed[iSeq] == 0) { globalPitch = this.globalPitch0prec; globalPitchOct = this.globalPitch0octPrec; } else {/*from w w w . ja va2s .c om*/ globalPitch = this.globalPitch1prec; globalPitchOct = this.globalPitch1octPrec; } for (int i = 0; i < 16; i++) { note_num = this.getNoteNumber(i) + globalPitch + this.patOctgUp[iSeq] * 24 + globalPitchOct; try { if (heldNotes[iSeq][i]) { //note_out.setMessage(ShortMessage.NOTE_OFF, 0, note_num, 0); note_out.setMessage(ShortMessage.NOTE_OFF, 0, heldNotesNum[iSeq][i], 0); heldNotes[iSeq][i] = false; this.recv.send(note_out, -1); } } catch (InvalidMidiDataException e) { e.printStackTrace(); } } }
From source file:org.monome.pages.MIDISequencerPagePoly.java
/** * Send MIDI note messages based on the sequence position. If on = 0, note off will be sent. * /*w w w .j a v a 2 s . c o m*/ * @param seq_pos The sequence position to play notes for * @param on Whether to turn notes on or off, a value of 1 means play notes * @throws InterruptedException */ public void playNotes(int seq_pos, int on, int quantPat) { ShortMessage note_out = new ShortMessage(); int note_num; int velocity; int seq_pos_pat = 0; int midiChannel = Integer.parseInt(this.midiChannel) - 1; int noteOnOff; int globalPitch = 0; int globalPitchOct = 0; boolean onOff = true; int globalRandomGateValue = 1; int globalRandomNoteValue = 1; int globalRandomVelocityValue = 1; boolean globalHold; /*if(this.globalRandomGate16) globalRandomGateValue=(int)(Math.random() + 0.5); else globalRandomGateValue=1; if(this.globalRandomNote16) globalRandomNoteValue=(int)(Math.random() * (8)) -4; else globalRandomNoteValue=0; if(this.globalRandomVelocity16) globalRandomVelocityValue=(int)(Math.random() * (63+1)); else globalRandomVelocityValue=0;*/ if (stopNotesRequest) { for (int i = 0; i < 256; i++) { this.stopNotes(i); } stopNotesRequest = false; } if (quantPat == 0) { globalPitch = this.globalPitch0; globalPitchOct = this.globalPitch0oct; onOff = this.onOff0; globalHold = this.globalHold0; } else { globalPitch = this.globalPitch1; globalPitchOct = this.globalPitch1oct; onOff = this.onOff1; globalHold = this.globalHold1; } //System.out.println("playnotes " + quantPat + " seq_pos " + seq_pos); for (int y = 0; y < 16; y++) { if (y < 15 && !this.noteSwitchs[y]) noteOnOff = 0; else noteOnOff = 1; for (int iSeq = 0; iSeq < this.bankSel.length; iSeq++) { // pat length seq_pos_pat = seq_pos % this.patlength[iSeq]; // hold mode if (this.patHold[iSeq] == 1 && this.patSpeed[iSeq] == quantPat) { if (this.bankSel[iSeq] && on == 127 && ((this.patGate[iSeq] == 1 && this.gate [iSeq]) || (this.patGate[iSeq] == 0))) { note_num = this.getNoteNumber(y) + globalPitch + this.patOctgUp[iSeq] * 24 + globalPitchOct; if (onOff) velocity = ((this.sequence[iSeq][seq_pos_pat][y] * 64) - 1) * noteOnOff; else velocity = 0; if ((seq_pos_pat > 0 && this.sequence[iSeq][seq_pos_pat - 1][y] > 0 && velocity <= 0) || (seq_pos_pat == 0 && this.sequence[iSeq][this.patlength[iSeq] - 1][y] > 0 && velocity <= 0)) { try { if (!globalHold) { heldNotes[iSeq][y] = false; //note_out.setMessage(ShortMessage.NOTE_OFF, midiChannel, note_num, 0); note_out.setMessage(ShortMessage.NOTE_OFF, midiChannel, heldNotesNum[iSeq][y], 0); if (this.bankMode == 1) this.monome.led(y % (this.monome.sizeX - 1), this.monome.sizeY - 3 + (y / (this.monome.sizeX - 1)), 0, this.index); this.recv.send(note_out, -1); } } catch (InvalidMidiDataException e) { e.printStackTrace(); } } else if (((seq_pos_pat > 0 && this.sequence[iSeq][seq_pos_pat - 1][y] == 0) || seq_pos_pat == 0) && velocity > 0) { try { heldNotes[iSeq][y] = true; note_out.setMessage(ShortMessage.NOTE_ON, midiChannel, note_num, velocity); heldNotesNum[iSeq][y] = note_num; if (this.bankMode == 1) this.monome.led(y % (this.monome.sizeX - 1), this.monome.sizeY - 3 + (y / (this.monome.sizeX - 1)), 1, this.index); this.recv.send(note_out, -1); } catch (InvalidMidiDataException e) { e.printStackTrace(); } } } // normal mode } else if (this.patSpeed[iSeq] == quantPat) { if (this.bankSel[iSeq] && on == 127 && ((this.patGate[iSeq] == 1 && this.gate [iSeq]) || (this.patGate[iSeq] == 0))) { note_num = this.getNoteNumber(y) + globalPitch + this.patOctgUp[iSeq] * 24 + globalPitchOct; if (onOff) velocity = ((this.sequence[iSeq][seq_pos_pat][y] * 64) - 1) * noteOnOff; else velocity = 0; if ((seq_pos_pat > 0 && this.sequence[iSeq][seq_pos_pat - 1][y] > 0) || (seq_pos_pat == 0 && this.sequence[iSeq][this.patlength[iSeq] - 1][y] > 0)) { try { if (!globalHold) { heldNotes[iSeq][y] = false; //note_out.setMessage(ShortMessage.NOTE_OFF, midiChannel, note_num, 0); note_out.setMessage(ShortMessage.NOTE_OFF, midiChannel, heldNotesNum[iSeq][y], 0); this.recv.send(note_out, -1); } if (this.bankMode == 1) this.monome.led(y % (this.monome.sizeX - 1), this.monome.sizeY - 3 + (y / (this.monome.sizeX - 1)), 0, this.index); } catch (InvalidMidiDataException e) { e.printStackTrace(); } } if (velocity > 0) { try { heldNotes[iSeq][y] = true; note_out.setMessage(ShortMessage.NOTE_ON, midiChannel, note_num, velocity); heldNotesNum[iSeq][y] = note_num; this.recv.send(note_out, -1); if (this.bankMode == 1) this.monome.led(y % (this.monome.sizeX - 1), this.monome.sizeY - 3 + (y / (this.monome.sizeX - 1)), 1, this.index); } catch (InvalidMidiDataException e) { e.printStackTrace(); } } } } } } }
From source file:org.monome.pages.MIDITriggersPage.java
/** * Converts a button press into a MIDI note event * //from w ww. j a v a 2s. co m * @param x The x value of the button pressed * @param y The y value of the button pressed * @param value The state, 1 = pressed, 0 = released */ public void playNote(int x, int y, int value) { int note_num = x + 12; int channel = y; int velocity = value * 127; ShortMessage note_out = new ShortMessage(); try { if (velocity == 0) { note_out.setMessage(ShortMessage.NOTE_OFF, channel, note_num, velocity); } else { note_out.setMessage(ShortMessage.NOTE_ON, channel, note_num, velocity); } } catch (InvalidMidiDataException e) { e.printStackTrace(); } if (this.recv != null) { this.recv.send(note_out, -1); } }