示例#1
0
 @JsonIgnore
 public void setNote(Note note) {
   if (notes.stream().anyMatch(n -> n.getId() == note.getId())) {
     notes =
         notes
             .stream()
             .map(n -> n.getId() == note.getId() ? note : n)
             .collect(Collectors.toList());
   } else {
     addNote(note);
   }
 }
示例#2
0
 @JsonIgnore
 public void resetNotesBorder(Vocal vocal) {
   if (notes == null || notes.size() < 2) {
     return;
   }
   int defaultFrontPadding = NakloidGUI.preferenceStore.getInt("ini.note.ms_front_padding");
   int defaultBackPadding = NakloidGUI.preferenceStore.getInt("ini.note.ms_back_padding");
   int defaultPadding = Math.max(defaultFrontPadding, defaultBackPadding);
   notes.set(
       0,
       new Note.Builder(notes.get(0))
           .setFrontMargin(0)
           .setFrontPadding(defaultFrontPadding)
           .build());
   for (int i = 1; i < notes.size(); i++) {
     Note tmpNote = notes.get(i), prevNote = notes.get(i - 1);
     Voice tmpVoice = vocal.getVoice(tmpNote.getPronunciationAlias()),
         prevVoice = vocal.getVoice(prevNote.getPronunciationAlias());
     if (tmpNote.getPronunciationAlias().checkVCV()
         && tmpVoice != null
         && tmpVoice.getOverlap() > 0
         && prevVoice != null) {
       int msFadeStart = tmpNote.getStart() - tmpVoice.getPreutterance();
       int msFadeEnd = msFadeStart + tmpVoice.getOverlap();
       int msPrevConsStart =
           prevNote.getStart() - prevVoice.getPreutterance() + prevVoice.getConsonant();
       if (msFadeStart < msPrevConsStart) {
         msFadeStart = msPrevConsStart;
         if (msFadeEnd - msFadeStart < defaultPadding) {
           msFadeEnd = msFadeStart + defaultPadding;
         }
       }
       int padding = msFadeEnd - msFadeStart;
       int prevBackMargin = prevNote.getPronEnd(0, prevVoice) - msFadeEnd;
       int frontMargin = msFadeStart - tmpNote.getPronStart(0, tmpVoice);
       notes.set(
           i - 1,
           new Note.Builder(notes.get(i - 1))
               .setBackPadding(padding)
               .setBackMargin(prevBackMargin)
               .build());
       notes.set(
           i,
           new Note.Builder(notes.get(i))
               .setFrontMargin(frontMargin)
               .setFrontPadding(padding)
               .build());
     } else {
       notes.set(
           i - 1,
           new Note.Builder(notes.get(i - 1))
               .setBackPadding(defaultBackPadding)
               .setBackMargin(0)
               .build());
       notes.set(
           i,
           new Note.Builder(notes.get(i))
               .setFrontMargin(0)
               .setFrontPadding(defaultFrontPadding)
               .build());
     }
   }
 }