Ejemplo n.º 1
0
  private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    // Create the Frinika Track Wrapper so that when reading MultiEvents the
    // MidiEvents can be generated as well

    /**
     * PJS: The sequence is created for the first time here - reason why not in the ProjectContainer
     * is because the ticksPerQuarterNote variable might not be loaded before the object is entirely
     * read. Chicken and egg problem - but this solves it...
     */
    if (this.getProject().getSequence() == null) {
      this.getProject().createSequence();
    }

    this.ftw = this.getProject().getSequence().createFrinikaTrack();

    in.defaultReadObject();

    if (programEvent == null) { // previous versions
      trackHeaderPart = new MidiPart();
      trackHeaderPart.lane = this;
      programEvent = new ProgramChangeEvent(trackHeaderPart, 0, 0, 0, 0);
    }

    midiMessageListeners = new HashSet<MidiMessageListener>(); // Jens

    programEvent.commitAdd();
    //	getPlayOptions();

    // setUpKeys();

  }
Ejemplo n.º 2
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();
  }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
0
 public void setProgram(MyPatch patch) {
   programEvent.commitRemove();
   programEvent.setProgram(patch.prog, patch.msb, patch.lsb);
   programEvent.commitAdd();
   setUpKeys();
 }
Ejemplo n.º 5
0
 public void setProgram(int prog, int msb, int lsb) {
   programEvent.commitRemove();
   programEvent.setProgram(prog, msb, lsb);
   programEvent.commitAdd();
   setUpKeys();
 }