private void setTiedNoteValue(TGNote note, Caret caret) {
   TGMeasure measure = caret.getMeasure();
   TGVoice voice =
       getSongManager()
           .getMeasureManager()
           .getPreviousVoice(measure.getBeats(), caret.getSelectedBeat(), caret.getVoice());
   while (measure != null) {
     while (voice != null) {
       if (voice.isRestVoice()) {
         note.setValue(0);
         return;
       }
       // Check if is there any note at same string.
       Iterator it = voice.getNotes().iterator();
       while (it.hasNext()) {
         TGNote current = (TGNote) it.next();
         if (current.getString() == note.getString()) {
           note.setValue(current.getValue());
           return;
         }
       }
       voice =
           getSongManager()
               .getMeasureManager()
               .getPreviousVoice(measure.getBeats(), voice.getBeat(), caret.getVoice());
     }
     measure = getSongManager().getTrackManager().getPrevMeasure(measure);
     if (measure != null) {
       voice =
           getSongManager().getMeasureManager().getLastVoice(measure.getBeats(), caret.getVoice());
     }
   }
 }
 public void playBeat(TGTrack track, final List notes) {
   TGChannel tgChannel = this.songManager.getChannel(track.getChannelId());
   if (tgChannel != null) {
     int channelId = tgChannel.getChannelId();
     int bank = tgChannel.getBank();
     int program = tgChannel.getProgram();
     int volume = (int) ((this.getVolume() / 10.00) * tgChannel.getVolume());
     int balance = tgChannel.getBalance();
     int chorus = tgChannel.getChorus();
     int reverb = tgChannel.getReverb();
     int phaser = tgChannel.getPhaser();
     int tremolo = tgChannel.getTremolo();
     int size = notes.size();
     int[][] beat = new int[size][2];
     for (int i = 0; i < size; i++) {
       TGNote note = (TGNote) notes.get(i);
       beat[i][0] =
           track.getOffset()
               + (note.getValue()
                   + ((TGString) track.getStrings().get(note.getString() - 1)).getValue());
       beat[i][1] = note.getVelocity();
     }
     playBeat(channelId, bank, program, volume, balance, chorus, reverb, phaser, tremolo, beat);
   }
 }
Exemplo n.º 3
0
  private void addBeat(int key, TGBeat beat) {
    if (beat.isRestBeat()) {
      this.writer.print("r");
      this.addDuration(beat.getDuration());
    } else {
      int size = beat.countNotes();
      if (size > 1) {
        this.writer.print("<");
      }
      for (int i = 0; i < size; i++) {
        TGNote note = beat.getNote(i);

        int note_value =
            (note.getBeat().getMeasure().getTrack().getString(note.getString()).getValue()
                + note.getValue());
        this.addKey(key, note_value);
        if (!(size > 1)) {
          this.addDuration(beat.getDuration());
        }
        this.addString(note.getString());
        if (this.isAnyTiedTo(note)) {
          this.writer.print("~");
        }

        if (size > 1) {
          this.writer.print(" ");
        }
      }
      if (size > 1) {
        this.writer.print(">");
        this.addDuration(beat.getDuration());
      }

      if (beat.isChordBeat()) {
        this.writer.print("-\\tag #'chords ^\\markup \\fret-diagram #\"");
        TGChord chord = beat.getChord();
        for (int i = 0; i < chord.countStrings(); i++) {
          this.writer.print((i + 1) + "-" + getLilypondChordFret(chord.getFretValue(i)) + ";");
        }
        this.writer.print("\"");
      }

      if (beat.isTextBeat()) {
        this.writer.print("-\\tag #'texts ^\\markup {" + beat.getText().getValue() + "}");
      }

      if (beat.getMeasure().getTrack().getLyrics().getFrom() > beat.getMeasure().getNumber()) {
        this.temp.addSkippedLyricBeat(getLilypondDuration(beat.getDuration()));
      }

      this.writer.print(" ");
    }
  }
Exemplo n.º 4
0
  private void writeNote(int header, TGNote note) {
    // escribo el valor
    writeByte(note.getValue());

    // escribo la cuerda
    writeByte(note.getString());

    // escribo el velocity
    if (((header & NOTE_VELOCITY) != 0)) {
      writeByte(note.getVelocity());
    }

    // escribo los efectos
    if (((header & NOTE_EFFECT) != 0)) {
      writeNoteEffect(note.getEffect());
    }
  }
Exemplo n.º 5
0
 private int getTiedNoteValue(int string, TGTrack track) {
   int measureCount = track.countMeasures();
   if (measureCount > 0) {
     for (int m = measureCount - 1; m >= 0; m--) {
       TGMeasure measure = track.getMeasure(m);
       for (int b = measure.countBeats() - 1; b >= 0; b--) {
         TGBeat beat = measure.getBeat(b);
         TGVoice voice = beat.getVoice(0);
         for (int n = 0; n < voice.countNotes(); n++) {
           TGNote note = voice.getNote(n);
           if (note.getString() == string) {
             return note.getValue();
           }
         }
       }
     }
   }
   return -1;
 }