private void writeObject(ObjectOutputStream out) throws IOException { this.midiChannel = ftw.getMidiChannel(); if (ftw.getMidiDevice() != null) { this.midiDeviceIndex = project.getMidiDeviceIndex(ftw.getMidiDevice()); } out.defaultWriteObject(); }
/** * The index of the midiDevice according to the stored order in the saved project * * @return */ public Integer getMidiDeviceIndex() { // // PJL added this (not sure about this) if (midiDeviceIndex == null) { this.midiChannel = ftw.getMidiChannel(); if (ftw.getMidiDevice() != null) { this.midiDeviceIndex = project.getMidiDeviceIndex(ftw.getMidiDevice()); } } // //----------------- return midiDeviceIndex; }
@Override /** This will set the correct MidiDevice when the project is reloaded */ public void onLoad() { super.onLoad(); ftw.setMidiChannel(midiChannel); if (midiDeviceIndex != null) { try { ftw.setMidiDevice(project.getSequencer().listMidiOutDevices().get(midiDeviceIndex)); } catch (Exception e) { System.out.println("WARNING: Was unable to connect to external midi device"); } } setUpKeys(); }
public MyPatch getProgram() { MyPatch patch = programEvent.getPatch(); if (patch != null) { return patch; } FrinikaTrackWrapper track = ftw; int count = track.size(); for (int i = 0; i < count; i++) { MidiEvent event = track.get(i); if (event.getTick() != 0) { return patch; } MidiMessage msg = event.getMessage(); if (msg instanceof ShortMessage) { ShortMessage sms = (ShortMessage) msg; if (sms.getCommand() == ShortMessage.PROGRAM_CHANGE) { if (patch == null) { patch = new MyPatch(0, 0, 0); } patch.prog = sms.getData1(); } if (sms.getCommand() == ShortMessage.CONTROL_CHANGE) { if (sms.getData1() == 0) { if (patch == null) { patch = new MyPatch(0, 0, 0); } patch.msb = sms.getData2(); } if (sms.getData1() == 0x20) { if (patch == null) { patch = new MyPatch(0, 0, 0); } patch.lsb = sms.getData2(); } } } } return patch; }
/** * Construct an empty lane * * @param ftw * @param project */ public MidiLane(FrinikaTrackWrapper ftw, ProjectContainer project) { super("Midi " + nameCount++, project); this.ftw = ftw; // cntrlList=new ControllerList(); // TODO different lists // We do not want this part to be in the part list trackHeaderPart = new MidiPart(); trackHeaderPart.lane = this; programEvent = new ProgramChangeEvent(trackHeaderPart, 0, 0, 0, 0); programEvent.commitAdd(); midiChannel = ftw.getMidiChannel(); }
/** @return The reciever associated with this lane */ public Receiver getReceiver() { MidiDevice dev = ftw.getMidiDevice(); if (dev == null) { return null; } try { // Jens: // return getTrack().getMidiDevice().getReceiver(); Receiver r = ftw.getMidiDevice().getReceiver(); if (r != null) { return new MonitorReceiver(midiMessageListeners, r); } else { return null; } } catch (MidiUnavailableException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
/** * Constructor for deepClone * * @param cloneMe */ private MidiLane(MidiLane cloneMe) { super("Copy of " + cloneMe.getName(), cloneMe.project); trackHeaderPart = (MidiPart) (cloneMe.trackHeaderPart.deepCopy(null)); trackHeaderPart.lane = this; midiDeviceIndex = cloneMe.midiDeviceIndex; midiChannel = cloneMe.midiChannel; keyNames = cloneMe.keyNames; for (Part part : cloneMe.getParts()) { part.deepCopy(this); } ftw = cloneMe.ftw.getSequence().createFrinikaTrack(); ftw.setMidiChannel(midiChannel); setUpKeys(); }
public void setMidiDevice(MidiDevice dev) { ftw.setMidiDevice(dev); setUpKeys(); }
public void setMidiChannel(int channel) { midiChannel = channel; ftw.setMidiChannel(midiChannel); setUpKeys(); }
public void detachFTW() { ftw.detachFromSequence(); }
// TODO Can we purge these 2 and replace with mute ? public void attachFTW() { ftw.attachToSequence(); }
public int getMidiChannel() { return ftw.getMidiChannel(); }
public MidiDevice getMidiDevice() { return ftw.getMidiDevice(); }