Exemple #1
0
 public Part clone() {
   if (_type == InstrumentType.NONE) {
     return NULL_PART;
   }
   Part copy = new Part(_type);
   copy.setInstrument(_instrument);
   copy.setCloneNum(_cloneNum);
   for (PlayLevel level : _playLevel.keySet()) {
     copy.setPlayLevel(level, _playLevel.get(level));
   }
   for (int i = 0; i < _noteList.size(); i++) {
     copy.addNote(_noteList.get(i).clone());
   }
   copy.setPartVolume(_partVolume);
   copy.setPan(_pan);
   for (StepValue<Integer> sv : _volume) {
     copy.addVolume(sv.getStep(), sv.getValue());
   }
   if (_type == InstrumentType.SINGLE) {
     for (StepValue<Integer> sv : _bass) {
       copy.addBass(sv.getStep(), sv.getValue());
     }
     for (StepValue<Integer> sv : _button) {
       copy.addButton(sv.getStep(), sv.getValue());
     }
     // clef
     List<StepValue<Clef>> clef = new ArrayList<StepValue<Clef>>();
     for (StepValue<Clef> sv : _clef) {
       clef.add(sv.clone());
     }
     copy.setClef(clef);
   }
   if (_type == InstrumentType.GUITAR || _type == InstrumentType.PIANO) {
     for (StepValue<List<Chord>> sv : _chordSetList) {
       copy.addChordSet(sv.getStep(), sv.getValue());
     }
   }
   if (_type == InstrumentType.PIANO) {
     for (StepValue<Voicing> sv : _voicing) {
       copy.addVoicing(sv.getStep(), sv.getValue());
     }
   }
   copy.setToneAttack(_attack);
   copy.setToneDecay(_decay);
   copy.setToneSustain(_sustain);
   copy.setToneRelease(_release);
   copy.setVibratoShape(_shape);
   copy.setVibratoHold(_hold);
   copy.setVibratoDelay(_delay);
   copy.setVibratoDepth(_depth);
   copy.setVibratoSpeed(_speed);
   copy.setToneEffectType(_effectType);
   copy.setToneEffectValue(_effectValue);
   return copy;
 }
Exemple #2
0
 /**
  * 無駄な情報を削除する
  *
  * @param maxStep
  */
 public void trim(int maxStep) {
   if (_type == InstrumentType.NONE) {
     return;
   }
   if (_volume.isEmpty()) {
     _volume.add(new StepValue<Integer>(0, 99));
   } else {
     Collections.sort(_volume, StepValue.STEP_COMPARATOR);
     StepValue<Integer> sv = _volume.get(0);
     sv.setStep(0);
     for (int i = _volume.size() - 1; i > 0; i--) {
       StepValue<Integer> step = _volume.get(i);
       if (step.getStep() > maxStep) {
         _volume.remove(i);
       }
     }
   }
   if (_type == InstrumentType.SINGLE) {
     if (_bass.isEmpty()) {
       _bass.add(new StepValue<Integer>(0, 24));
     } else {
       Collections.sort(_bass, StepValue.STEP_COMPARATOR);
       StepValue<Integer> sv = _bass.get(0);
       sv.setStep(0);
       for (int i = _bass.size() - 1; i > 0; i--) {
         StepValue<Integer> step = _bass.get(i);
         if (step.getStep() > maxStep) {
           _bass.remove(i);
         } else {
           // 同じ値が連続しているなら削除
           StepValue<Integer> step2 = _bass.get(i - 1);
           if (step.getValue() == step2.getValue()) {
             _bass.remove(i);
           }
         }
       }
     }
     if (_button.isEmpty()) {
       _button.add(new StepValue<Integer>(0, 0));
     } else {
       Collections.sort(_button, StepValue.STEP_COMPARATOR);
       StepValue<Integer> sv = _button.get(0);
       sv.setStep(0);
       for (int i = _button.size() - 1; i > 0; i--) {
         StepValue<Integer> step = _button.get(i);
         if (step.getStep() > maxStep) {
           _button.remove(i);
         } else {
           // 同じ値が連続しているなら削除
           StepValue<Integer> step2 = _button.get(i - 1);
           if (step.getValue() == step2.getValue()) {
             _button.remove(i);
           }
         }
       }
     }
     if (_clef.isEmpty()) {
       _clef.add(new StepValue<Clef>(0, Clef.G2));
     } else {
       Collections.sort(_clef, StepValue.STEP_COMPARATOR);
       StepValue<Clef> sv = _clef.get(0);
       sv.setStep(0);
       for (int i = _clef.size() - 1; i > 0; i--) {
         StepValue<Clef> step = _clef.get(i);
         if (step.getStep() > maxStep) {
           _clef.remove(i);
         } else {
           // 同じ値が連続しているなら削除
           StepValue<Clef> step2 = _clef.get(i - 1);
           if (step.getValue() == step2.getValue()) {
             _clef.remove(i);
           }
         }
       }
     }
   } else if (_type == InstrumentType.GUITAR || _type == InstrumentType.PIANO) {
     if (!_chordSetList.isEmpty()) {
       Collections.sort(_chordSetList, StepValue.STEP_COMPARATOR);
       StepValue<List<Chord>> sv = _chordSetList.get(0);
       sv.setStep(0);
       for (int i = _chordSetList.size() - 1; i > 0; i--) {
         StepValue<List<Chord>> step = _chordSetList.get(i);
         if (step.getStep() > maxStep) {
           _chordSetList.remove(i);
         } else {
           // 同じ値が連続しているなら削除
           StepValue<List<Chord>> step2 = _chordSetList.get(i - 1);
           if (step.getValue().equals(step2.getValue())) {
             _chordSetList.remove(i);
           }
         }
       }
     }
   }
   if (_type == InstrumentType.PIANO) {
     if (!_voicing.isEmpty()) {
       Collections.sort(_voicing, StepValue.STEP_COMPARATOR);
       StepValue<Voicing> sv = _voicing.get(0);
       sv.setStep(0);
       for (int i = _voicing.size() - 1; i > 0; i--) {
         StepValue<Voicing> step = _voicing.get(i);
         if (step.getStep() > maxStep) {
           _voicing.remove(i);
         } else {
           // 同じ値が連続しているなら削除
           StepValue<Voicing> step2 = _voicing.get(i - 1);
           if (step.getValue().equals(step2.getValue())) {
             _voicing.remove(i);
           }
         }
       }
     }
   }
 }