Example #1
0
 private void writeObject(ObjectOutputStream out) throws IOException {
   this.midiChannel = ftw.getMidiChannel();
   if (ftw.getMidiDevice() != null) {
     this.midiDeviceIndex = project.getMidiDeviceIndex(ftw.getMidiDevice());
   }
   out.defaultWriteObject();
 }
Example #2
0
  /**
   * 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;
  }
Example #3
0
 @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();
 }
Example #4
0
  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;
  }
Example #5
0
  /**
   * 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();
  }
Example #6
0
  /** @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;
    }
  }
Example #7
0
  /**
   * 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();
  }
Example #8
0
 public void setMidiDevice(MidiDevice dev) {
   ftw.setMidiDevice(dev);
   setUpKeys();
 }
Example #9
0
 public void setMidiChannel(int channel) {
   midiChannel = channel;
   ftw.setMidiChannel(midiChannel);
   setUpKeys();
 }
Example #10
0
 public void detachFTW() {
   ftw.detachFromSequence();
 }
Example #11
0
 // TODO Can we purge these 2 and replace with mute ?
 public void attachFTW() {
   ftw.attachToSequence();
 }
Example #12
0
 public int getMidiChannel() {
   return ftw.getMidiChannel();
 }
Example #13
0
 public MidiDevice getMidiDevice() {
   return ftw.getMidiDevice();
 }