1
package org.herac.tuxguitar.song.managers;
3
import java.util.ArrayList;
4
import java.util.Iterator;
7
import org.herac.tuxguitar.song.factory.TGFactory;
8
import org.herac.tuxguitar.song.models.TGBeat;
9
import org.herac.tuxguitar.song.models.TGChord;
10
import org.herac.tuxguitar.song.models.TGDuration;
11
import org.herac.tuxguitar.song.models.TGMeasure;
12
import org.herac.tuxguitar.song.models.TGNote;
13
import org.herac.tuxguitar.song.models.TGString;
14
import org.herac.tuxguitar.song.models.TGText;
15
import org.herac.tuxguitar.song.models.effects.TGEffectBend;
16
import org.herac.tuxguitar.song.models.effects.TGEffectGrace;
17
import org.herac.tuxguitar.song.models.effects.TGEffectHarmonic;
18
import org.herac.tuxguitar.song.models.effects.TGEffectTremoloBar;
19
import org.herac.tuxguitar.song.models.effects.TGEffectTremoloPicking;
20
import org.herac.tuxguitar.song.models.effects.TGEffectTrill;
22
public class TGMeasureManager {
23
private TGSongManager songManager;
25
public TGMeasureManager(TGSongManager songManager){
26
this.songManager = songManager;
29
public TGSongManager getSongManager(){
30
return this.songManager;
33
public void orderBeats(TGMeasure measure){
34
for(int i = 0;i < measure.countBeats();i++){
35
TGBeat minBeat = null;
36
for(int j = i;j < measure.countBeats();j++){
37
TGBeat beat = measure.getBeat(j);
38
if(minBeat == null || beat.getStart() < minBeat.getStart()){
42
measure.moveBeat(i, minBeat);
47
* Agrega un beat al compas
49
public void addBeat(TGMeasure measure,TGBeat beat){
50
//Verifico si entra en el compas
51
if(validateDuration(measure,beat,false,false)){
54
measure.addBeat(beat);
58
public void removeBeat(TGBeat beat){
59
beat.getMeasure().removeBeat(beat);
62
public void removeBeat(TGMeasure measure,long start,boolean moveNextComponents){
63
TGBeat beat = getBeat(measure, start);
65
removeBeat(beat, moveNextComponents);
70
* Elimina un silencio del compas.
71
* si se asigna moveNextComponents = true. los componentes que le siguen
72
* se moveran para completar el espacio vacio que dejo el silencio
74
public void removeBeat(TGBeat beat,boolean moveNextBeats){
75
TGMeasure measure = beat.getMeasure();
79
long start = beat.getStart();
80
long length = beat.getDuration().getTime();
81
TGBeat next = getNextBeat(measure.getBeats(),beat);
83
length = next.getStart() - start;
85
moveBeats(beat.getMeasure(),start + length,-length, beat.getDuration());
89
public void removeBeatsBeforeEnd(TGMeasure measure,long fromStart){
90
List beats = getBeatsBeforeEnd( measure.getBeats() , fromStart);
91
Iterator it = beats.iterator();
93
TGBeat beat = (TGBeat) it.next();
98
public void addNote(TGMeasure measure,long start, TGNote note, TGDuration duration){
99
TGBeat beat = getBeat(measure, start);
101
addNote(beat, note, duration);
105
public void addNote(TGBeat beat, TGNote note, TGDuration duration){
106
addNote(beat, note, duration, beat.getStart());
109
public void addNote(TGBeat beat, TGNote note, TGDuration duration, long start){
110
//Verifico si entra en el compas
111
if(validateDuration(beat.getMeasure(),beat, duration,true,true)){
112
//Borro lo que haya en la misma posicion
113
removeNote(beat.getMeasure(),beat.getStart(),note.getString());
115
duration.copy(beat.getDuration());
117
//trato de agregar un silencio similar al lado
118
tryChangeSilenceAfter(beat.getMeasure(),beat);
120
// Despues de cambiar la duracion, verifico si hay un beat mejor para agregar la nota.
121
TGBeat realBeat = beat;
122
if(realBeat.getStart() != start){
123
TGBeat beatIn = getBeatIn(realBeat.getMeasure(), start);
124
if( beatIn != null ) {
128
realBeat.addNote(note);
132
public void removeNote(TGNote note){
133
note.getBeat().removeNote(note);
137
* Elimina los Componentes que empiecen en Start y esten en la misma cuerda
138
* Si hay un Silencio lo borra sin importar la cuerda
140
public void removeNote(TGMeasure measure,long start,int string){
141
TGBeat beat = getBeat(measure, start);
143
for( int i = 0; i < beat.countNotes(); i ++){
144
TGNote note = beat.getNote(i);
145
if(note.getString() == string){
148
//si era el unico componente agrego un silencio
149
if(beat.isRestBeat()){
150
//Borro un posible acorde
151
removeChord(measure, beat.getStart());
159
public void removeNotesAfterString(TGMeasure measure,int string){
160
List notesToRemove = new ArrayList();
162
Iterator beats = measure.getBeats().iterator();
163
while(beats.hasNext()){
164
TGBeat beat = (TGBeat)beats.next();
165
Iterator notes = beat.getNotes().iterator();
166
while(notes.hasNext()){
167
TGNote note = (TGNote)notes.next();
168
if(note.getString() > string){
169
notesToRemove.add(note);
173
Iterator it = notesToRemove.iterator();
175
TGNote note = (TGNote)it.next();
181
* Retorna Todas las Notas en la posicion Start
183
public List getNotes(TGMeasure measure,long start){
184
List notes = new ArrayList();
186
TGBeat beat = getBeat(measure, start);
188
Iterator it = beat.getNotes().iterator();
190
TGNote note = (TGNote)it.next();
198
* Retorna la Nota en la posicion y cuerda
200
public TGNote getNote(TGMeasure measure,long start,int string) {
201
TGBeat beat = getBeat(measure, start);
203
return getNote(beat, string);
209
* Retorna la Nota en la cuerda
211
public TGNote getNote(TGBeat beat,int string) {
212
Iterator it = beat.getNotes().iterator();
214
TGNote note = (TGNote)it.next();
215
if (note.getString() == string) {
222
public TGNote getPreviousNote(TGMeasure measure,long start, int string) {
223
TGBeat beat = getBeat(measure, start);
225
TGBeat previous = getPreviousBeat(measure.getBeats(),beat);
226
while(previous != null){
227
for (int i = 0; i < previous.countNotes(); i++) {
228
TGNote current = previous.getNote(i);
229
if (current.getString() == string) {
233
previous = getPreviousBeat(measure.getBeats(),previous);
239
public TGNote getNextNote(TGMeasure measure,long start, int string) {
240
TGBeat beat = getBeat(measure, start);
242
TGBeat next = getNextBeat(measure.getBeats(),beat);
244
for (int i = 0; i < next.countNotes(); i++) {
245
TGNote current = next.getNote(i);
246
if (current.getString() == string) {
250
next = getNextBeat(measure.getBeats(),next);
257
* Retorna las Nota en la posicion y cuerda
259
public TGBeat getBeat(TGMeasure measure,long start) {
260
Iterator it = measure.getBeats().iterator();
262
TGBeat beat = (TGBeat)it.next();
263
if (beat.getStart() == start) {
271
* Retorna las Nota en la posicion y cuerda
273
public TGBeat getBeatIn(TGMeasure measure,long start) {
274
Iterator it = measure.getBeats().iterator();
276
TGBeat beat = (TGBeat)it.next();
277
if (beat.getStart() <= start && (beat.getStart() + beat.getDuration().getTime() > start)) {
285
* Retorna el Siguiente Componente
287
public TGBeat getNextBeat(List beats,TGBeat beat) {
289
for (int i = 0; i < beats.size(); i++) {
290
TGBeat current = (TGBeat) beats.get(i);
291
if (current.getStart() > beat.getStart()) {
294
} else if (current.getStart() < next.getStart()) {
296
} else if (current.getStart() == next.getStart() && current.getDuration().getTime() <= next.getDuration().getTime()) {
305
* Retorna el Componente Anterior
307
public TGBeat getPreviousBeat(List beats,TGBeat beat) {
308
TGBeat previous = null;
309
for (int i = 0; i < beats.size(); i++) {
310
TGBeat current = (TGBeat) beats.get(i);
311
if (current.getStart() < beat.getStart()) {
312
if (previous == null) {
314
} else if (current.getStart() > previous.getStart()) {
316
} else if (current.getStart() == previous.getStart() && current.getDuration().getTime() <= previous.getDuration().getTime()) {
325
* Retorna el Primer Componente
327
public TGBeat getFirstBeat(List components) {
329
for (int i = 0; i < components.size(); i++) {
330
TGBeat component = (TGBeat) components.get(i);
331
if (first == null || component.getStart() < first.getStart()) {
339
* Retorna el Ultimo Componente
341
public TGBeat getLastBeat(List components) {
343
for (int i = 0; i < components.size(); i++) {
344
TGBeat component = (TGBeat) components.get(i);
345
if (last == null || last.getStart() < component.getStart()) {
353
* Retorna el Siguiente Componente
355
public TGBeat getNextRestBeat(List beats,TGBeat component) {
356
TGBeat next = getNextBeat(beats, component);
357
while(next != null && !next.isRestBeat()){
358
next = getNextBeat(beats, next);
365
* Retorna Todos los desde Start hasta el final del compas
367
public List getBeatsBeforeEnd(List beats,long fromStart) {
368
List list = new ArrayList();
369
Iterator it = beats.iterator();
371
TGBeat current = (TGBeat)it.next();
372
if (current.getStart() >= fromStart) {
379
public void moveAllBeats(TGMeasure measure,long theMove){
380
moveBeats(measure.getBeats(),theMove);
383
public boolean moveBeats(TGMeasure measure,long start,long theMove, TGDuration fillDuration){
387
boolean success = true;
388
long measureStart = measure.getStart();
389
long measureEnd = (measureStart + measure.getLength());
391
// Muevo los componentes
392
List beatsToMove = getBeatsBeforeEnd(measure.getBeats(),start);
393
moveBeats(beatsToMove,theMove);
396
List beatsToRemove = new ArrayList();
397
List beats = new ArrayList(measure.getBeats());
399
// Verifica los silencios a eliminar al principio del compas
400
TGBeat first = getFirstBeat( beats );
401
while(first != null && first.isRestBeat() && !first.isTextBeat() && first.getStart() < measureStart){
403
beatsToRemove.add(first);
404
first = getNextBeat( beats,first);
407
// Verifica los silencios a eliminar al final del compas
408
TGBeat last = getLastBeat(beats);
409
while(last != null && last.isRestBeat() && !last.isTextBeat() && (last.getStart() + last.getDuration().getTime() ) > measureEnd ){
411
beatsToRemove.add(last);
412
last = getPreviousBeat(beats,last);
415
// Si el primer o ultimo componente, quedan fuera del compas, entonces el movimiento no es satisfactorio
416
if(first != null && last != null){
417
if(first.getStart() < measureStart || (last.getStart() + last.getDuration().getTime()) > measureEnd){
423
// Elimino los silencios que quedaron fuera del compas.
424
Iterator it = beatsToRemove.iterator();
425
while( it.hasNext() ){
426
TGBeat beat = (TGBeat)it.next();
430
// Se crean silencios en los espacios vacios, si la duracion fue especificada.
431
if( fillDuration != null ){
433
last = getLastBeat(measure.getBeats());
434
TGBeat beat = getSongManager().getFactory().newBeat();
435
beat.setStart( (last != null ? last.getStart() + last.getDuration().getTime() : start ) );
436
fillDuration.copy( beat.getDuration() );
437
if( (beat.getStart() + beat.getDuration().getTime()) <= measureEnd ){
438
addBeat(measure, beat );
442
first = getFirstBeat(getBeatsBeforeEnd(measure.getBeats(),start));
443
TGBeat beat = getSongManager().getFactory().newBeat();
444
beat.setStart( start );
445
fillDuration.copy( beat.getDuration() );
446
if( (beat.getStart() + beat.getDuration().getTime()) <= (first != null ?first.getStart() : measureEnd ) ){
447
addBeat(measure, beat );
454
// Si el movimiento no es satisfactorio, regreso todo como estaba
456
moveBeats(beatsToMove,-theMove);
463
* Mueve los componentes
465
private void moveBeats(List beats,long theMove){
466
Iterator it = beats.iterator();
468
TGBeat beat = (TGBeat)it.next();
469
moveBeat(beat,theMove);
474
* Mueve el componente
476
private void moveBeat(TGBeat beat,long theMove){
477
//obtengo el start viejo
478
long start = beat.getStart();
480
//asigno el nuevo start
481
beat.setStart(start + theMove);
484
public void cleanBeat(TGBeat beat){
485
if( beat.getText() != null ){
488
if( beat.getChord() != null){
492
this.cleanBeatNotes(beat);
495
public void cleanBeatNotes(TGBeat beat){
496
while(beat.countNotes() > 0 ){
497
TGNote note = beat.getNote(0);
502
public void cleanBeatNotes(TGMeasure measure, long start){
503
TGBeat beat = getBeat(measure, start);
505
cleanBeatNotes(beat);
510
* Agrega el acorde al compas
512
public void addChord(TGMeasure measure,long start, TGChord chord){
513
TGBeat beat = getBeat(measure, start);
515
addChord(beat, chord);
520
* Agrega el acorde al compas
522
public void addChord(TGBeat beat,TGChord chord){
524
beat.setChord(chord);
528
* Retorna el acorde en la position
530
public TGChord getChord(TGMeasure measure,long start) {
531
TGBeat beat = getBeat(measure, start);
533
return beat.getChord();
539
* Borra el acorde en la position
541
public void removeChord(TGMeasure measure,long start) {
542
TGBeat beat = getBeat(measure, start);
549
* Agrega el texto al compas
551
public void addText(TGMeasure measure,long start, TGText text){
552
TGBeat beat = getBeat(measure, start);
559
* Agrega el texto al compas
561
public void addText(TGBeat beat,TGText text){
569
* Retorna el texto en la position
571
public TGText getText(TGMeasure measure,long start) {
572
TGBeat beat = getBeat(measure, start);
574
return beat.getText();
580
* Borra el texto en el pulso
582
public void removeText(TGBeat beat){
587
* Borra el texto en la position
589
public boolean removeText(TGMeasure measure,long start) {
590
TGBeat beat = getBeat(measure, start);
598
public void cleanMeasure(TGMeasure measure){
599
while( measure.countBeats() > 0){
600
removeBeat( measure.getBeat(0));
605
* Mueve la nota a la cuerda de arriba
607
public int shiftNoteUp(TGMeasure measure,long start,int string){
608
return shiftNote(measure, start, string,-1);
612
* Mueve la nota a la cuerda de abajo
614
public int shiftNoteDown(TGMeasure measure,long start,int string){
615
return shiftNote(measure, start, string,1);
619
* Mueve la nota a la siguiente cuerda
621
private int shiftNote(TGMeasure measure,long start,int string,int move){
622
TGNote note = getNote(measure,start,string);
624
int nextStringNumber = (note.getString() + move);
625
while(getNote(measure,start,nextStringNumber) != null){
626
nextStringNumber += move;
628
if(nextStringNumber >= 1 && nextStringNumber <= measure.getTrack().stringCount()){
629
TGString currentString = measure.getTrack().getString(note.getString());
630
TGString nextString = measure.getTrack().getString(nextStringNumber);
631
int noteValue = (note.getValue() + currentString.getValue());
632
if(noteValue >= nextString.getValue() && ((nextString.getValue() + 30 > noteValue) || measure.getTrack().isPercussionTrack()) ){
633
note.setValue(noteValue - nextString.getValue());
634
note.setString(nextString.getNumber());
635
return note.getString();
643
* Mueve la nota 1 semitono arriba
645
public boolean moveSemitoneUp(TGMeasure measure,long start,int string){
646
return moveSemitone(measure, start, string,1);
650
* Mueve la nota 1 semitono abajo
652
public boolean moveSemitoneDown(TGMeasure measure,long start,int string){
653
return moveSemitone(measure, start, string,-1);
657
* Mueve la nota los semitonos indicados
659
private boolean moveSemitone(TGMeasure measure,long start,int string,int semitones){
660
TGNote note = getNote(measure,start,string);
662
int newValue = (note.getValue() + semitones);
663
if(newValue >= 0 && (newValue < 30 || measure.getTrack().isPercussionTrack()) ){
664
note.setValue(newValue);
672
* Verifica si el componente se puede insertar en el compas.
673
* si no puede, con la opcion removeSilences, verifica si el motivo por el
674
* cual no entra es que lo siguen silencios. de ser asi los borra.
676
public boolean validateDuration(TGMeasure measure,TGBeat beat,boolean moveNextComponents, boolean setCurrentDuration){
677
return validateDuration(measure, beat, beat.getDuration(),moveNextComponents, setCurrentDuration);
681
public boolean validateDuration(TGMeasure measure,TGBeat beat,TGDuration duration,boolean moveNextBeats, boolean setCurrentDuration){
682
int errorMargin = 10;
683
this.orderBeats(measure);
684
long measureStart = measure.getStart();
685
long measureEnd = (measureStart + measure.getLength());
686
long beatStart = beat.getStart();
687
long beatLength = duration.getTime();
688
long beatEnd = (beatStart + beatLength);
689
List beats = measure.getBeats();
691
//Verifico si hay un beat en el mismo lugar, y comparo las duraciones.
692
TGBeat currentBeat = getBeat(measure,beatStart);
693
if(currentBeat != null && beatLength <= currentBeat.getDuration().getTime()){
694
/*if(componentAtBeat instanceof TGSilence){
695
removeSilence((TGSilence)componentAtBeat, false);
700
//Verifico si hay lugar para meter el beat
701
TGBeat nextComponent = getNextBeat(beats,beat);
702
if(currentBeat == null){
703
if(nextComponent == null && beatEnd < (measureEnd + errorMargin)){
706
if(nextComponent != null && beatEnd < (nextComponent.getStart() + errorMargin)){
711
// Busca si hay espacio disponible de silencios entre el componente y el el que le sigue.. si encuentra lo borra
712
if(nextComponent != null && nextComponent.isRestBeat()){
713
//Verifico si lo que sigue es un silencio. y lo borro
714
long nextBeatEnd = 0;
715
List nextBeats = new ArrayList();
716
while(nextComponent != null && nextComponent.isRestBeat() && !nextComponent.isTextBeat()){
717
nextBeats.add(nextComponent);
718
nextBeatEnd = nextComponent.getStart() + nextComponent.getDuration().getTime();
719
nextComponent = getNextBeat(beats,nextComponent);
721
if(nextComponent == null){
722
nextBeatEnd = measureEnd;
723
}else if(!nextComponent.isRestBeat() || nextComponent.isTextBeat()){
724
nextBeatEnd = nextComponent.getStart();
726
if(beatEnd <= (nextBeatEnd + errorMargin)){
727
while(!nextBeats.isEmpty()){
728
TGBeat currBeat = (TGBeat)nextBeats.get(0);
729
nextBeats.remove(currBeat);
730
removeBeat(currBeat, false);
736
// Busca si hay espacio disponible de silencios entre el componente y el final.. si encuentra mueve todo
738
nextComponent = getNextBeat(beats,beat);
739
if(nextComponent != null){
740
long requiredLength = (beatLength - (nextComponent.getStart() - beatStart));
741
long nextSilenceLength = 0;
742
TGBeat nextRestBeat = getNextRestBeat(beats, beat);
743
while(nextRestBeat != null && !nextRestBeat.isTextBeat()){
744
nextSilenceLength += nextRestBeat.getDuration().getTime();
745
nextRestBeat = getNextRestBeat(beats, nextRestBeat);
748
if(requiredLength <= (nextSilenceLength + errorMargin)){
749
beats = getBeatsBeforeEnd(measure.getBeats(),nextComponent.getStart());
750
while(!beats.isEmpty()){
751
TGBeat current = (TGBeat)beats.get(0);
752
if(current.isRestBeat() && !current.isTextBeat()){
753
requiredLength -= current.getDuration().getTime();
754
removeBeat(current, false);
755
}else if(requiredLength > 0){
756
moveBeat(current,requiredLength);
765
// como ultimo intento, asigno la duracion de cualquier componente existente en el lugar.
766
if(setCurrentDuration && currentBeat != null){
767
/*if(componentAtBeat instanceof TGSilence){
768
removeSilence((TGSilence)componentAtBeat, false);
770
currentBeat.getDuration().copy( duration );
777
* Cambia la Duracion del pulso.
779
public void changeDuration(TGMeasure measure,TGBeat beat,TGDuration duration,boolean tryMove){
780
//obtengo la duracion vieja
781
TGDuration oldDuration = beat.getDuration().clone(getSongManager().getFactory());
783
//si no entra vuelvo a dejar la vieja
784
if(validateDuration(measure,beat, duration,tryMove,false)){
785
//se lo agrego a todas las notas en la posicion
786
beat.setDuration(duration.clone(getSongManager().getFactory()));
788
//trato de agregar un silencio similar al lado
789
tryChangeSilenceAfter(measure,beat);
791
oldDuration.copy( beat.getDuration() );
795
public void tryChangeSilenceAfter(TGMeasure measure,TGBeat beat){
796
autoCompleteSilences(measure);
797
TGBeat nextBeat = getNextBeat(measure.getBeats(),beat);
799
long beatEnd = (beat.getStart() + beat.getDuration().getTime());
800
long measureEnd = (measure.getStart() + measure.getLength());
801
if(nextBeat != null && nextBeat.isRestBeat() && beatEnd <= measureEnd){
802
long theMove = (getRealStart(measure,beatEnd)) - getRealStart(measure,nextBeat.getStart());
803
if((nextBeat.getStart() + theMove) < measureEnd && (nextBeat.getStart() + nextBeat.getDuration().getTime() + theMove) <= measureEnd){
804
moveBeat(nextBeat,theMove);
805
changeDuration(measure,nextBeat,beat.getDuration().clone(getSongManager().getFactory()),false);
811
* Calcula si hay espacios libres. y crea nuevos silencios
813
public void autoCompleteSilences(TGMeasure measure){
814
long start = measure.getStart();
817
List components = measure.getBeats();
818
TGBeat component = getFirstBeat(components);
820
while (component != null) {
821
end = component.getStart() + component.getDuration().getTime();
822
if(component.getStart() > start){
823
diff = component.getStart() - start;
825
createSilences(measure,start,diff);
829
component = getNextBeat(components,component);
831
end = measure.getStart() + measure.getLength();
834
createSilences(measure,start,diff);
839
* Crea Silencios temporarios en base a length
841
private void createSilences(TGMeasure measure,long start,long length){
842
long nextStart = start;
843
List durations = createDurations(getSongManager().getFactory(),length);
844
Iterator it = durations.iterator();
846
TGDuration duration = (TGDuration)it.next();
847
TGBeat beat = getSongManager().getFactory().newBeat();
848
beat.setStart( getRealStart(measure, nextStart) );
849
duration.copy(beat.getDuration());
850
addBeat(measure,beat);
851
nextStart += duration.getTime();
855
public long getRealStart(TGMeasure measure,long currStart){
856
long beatLength = TGSongManager.getDivisionLength(measure.getHeader());
857
long start = currStart;
858
boolean startBeat = (start % beatLength == 0);
860
TGDuration minDuration = getSongManager().getFactory().newDuration();
861
minDuration.setValue(TGDuration.SIXTY_FOURTH);
862
minDuration.getTupleto().setEnters(3);
863
minDuration.getTupleto().setTimes(2);
864
for(int i = 0;i < minDuration.getTime();i++){
866
startBeat = (start % beatLength == 0);
881
public void changeTieNote(TGMeasure measure,long start,int string){
882
TGNote note = getNote(measure,start,string);
891
public void changeTieNote(TGNote note){
892
note.setTiedNote(!note.isTiedNote());
893
note.getEffect().setDeadNote(false);
899
public void changeVibratoNote(TGMeasure measure,long start,int string){
900
TGNote note = getNote(measure,start,string);
902
note.getEffect().setVibrato(!note.getEffect().isVibrato());
907
* Agrega una nota muerta
909
public void changeDeadNote(TGNote note){
910
note.getEffect().setDeadNote(!note.getEffect().isDeadNote());
911
note.setTiedNote(false);
917
public void changeSlideNote(TGMeasure measure,long start,int string){
918
TGNote note = getNote(measure,start,string);
920
note.getEffect().setSlide(!note.getEffect().isSlide());
927
public void changeHammerNote(TGMeasure measure,long start,int string){
928
TGNote note = getNote(measure,start,string);
930
note.getEffect().setHammer(!note.getEffect().isHammer());
935
* Agrega un palm-mute
937
public void changePalmMute(TGMeasure measure,long start,int string){
938
TGNote note = getNote(measure,start,string);
940
note.getEffect().setPalmMute(!note.getEffect().isPalmMute());
947
public void changeStaccato(TGMeasure measure,long start,int string){
948
TGNote note = getNote(measure,start,string);
950
note.getEffect().setStaccato(!note.getEffect().isStaccato());
957
public void changeTapping(TGMeasure measure,long start,int string){
958
TGNote note = getNote(measure,start,string);
960
note.getEffect().setTapping(!note.getEffect().isTapping());
967
public void changeSlapping(TGMeasure measure,long start,int string){
968
TGNote note = getNote(measure,start,string);
970
note.getEffect().setSlapping(!note.getEffect().isSlapping());
977
public void changePopping(TGMeasure measure,long start,int string){
978
TGNote note = getNote(measure,start,string);
980
note.getEffect().setPopping(!note.getEffect().isPopping());
987
public void changeBendNote(TGMeasure measure,long start,int string,TGEffectBend bend){
988
TGNote note = getNote(measure,start,string);
990
note.getEffect().setBend(bend);
995
* Agrega un tremoloBar
997
public void changeTremoloBar(TGMeasure measure,long start,int string,TGEffectTremoloBar tremoloBar){
998
TGNote note = getNote(measure,start,string);
1000
note.getEffect().setTremoloBar(tremoloBar);
1005
* Agrega un GhostNote
1007
public void changeGhostNote(TGMeasure measure,long start,int string){
1008
TGNote note = getNote(measure,start,string);
1010
note.getEffect().setGhostNote(!note.getEffect().isGhostNote());
1015
* Agrega un AccentuatedNote
1017
public void changeAccentuatedNote(TGMeasure measure,long start,int string){
1018
TGNote note = getNote(measure,start,string);
1020
note.getEffect().setAccentuatedNote(!note.getEffect().isAccentuatedNote());
1025
* Agrega un GhostNote
1027
public void changeHeavyAccentuatedNote(TGMeasure measure,long start,int string){
1028
TGNote note = getNote(measure,start,string);
1030
note.getEffect().setHeavyAccentuatedNote(!note.getEffect().isHeavyAccentuatedNote());
1035
* Agrega un harmonic
1037
public void changeHarmonicNote(TGMeasure measure,long start,int string,TGEffectHarmonic harmonic){
1038
TGNote note = getNote(measure,start,string);
1040
note.getEffect().setHarmonic(harmonic);
1047
public void changeGraceNote(TGMeasure measure,long start,int string,TGEffectGrace grace){
1048
TGNote note = getNote(measure,start,string);
1050
note.getEffect().setGrace(grace);
1057
public void changeTrillNote(TGMeasure measure,long start,int string,TGEffectTrill trill){
1058
TGNote note = getNote(measure,start,string);
1060
note.getEffect().setTrill(trill);
1065
* Agrega un tremolo picking
1067
public void changeTremoloPicking(TGMeasure measure,long start,int string,TGEffectTremoloPicking tremoloPicking){
1068
TGNote note = getNote(measure,start,string);
1070
note.getEffect().setTremoloPicking(tremoloPicking);
1077
public void changeFadeIn(TGMeasure measure,long start,int string){
1078
TGNote note = getNote(measure,start,string);
1080
note.getEffect().setFadeIn(!note.getEffect().isFadeIn());
1085
* Cambia el Velocity
1087
public void changeVelocity(int velocity,TGMeasure measure,long start,int string){
1088
TGNote note = getNote(measure,start,string);
1090
note.setVelocity(velocity);
1094
public static List createDurations(TGFactory factory,long time){
1095
List durations = new ArrayList();
1096
TGDuration tempDuration = factory.newDuration();
1097
tempDuration.setValue(TGDuration.WHOLE);
1098
tempDuration.setDotted(true);
1099
long tempTime = time;
1100
boolean finish = false;
1102
long currentDurationTime = tempDuration.getTime();
1103
if(currentDurationTime <= tempTime){
1104
durations.add(tempDuration.clone(factory));
1105
tempTime -= currentDurationTime;
1107
if(tempDuration.isDotted()){
1108
tempDuration.setDotted(false);
1110
tempDuration.setValue(tempDuration.getValue() * 2);
1111
tempDuration.setDotted(true);
1114
if(tempDuration.getValue() > TGDuration.SIXTY_FOURTH){
1122
public static List createDurations(TGFactory factory,long time){
1123
List durations = new ArrayList();
1124
TGDuration minimum = factory.newDuration();
1125
minimum.setValue(TGDuration.SIXTY_FOURTH);
1126
minimum.setDotted(false);
1127
minimum.setDoubleDotted(false);
1128
minimum.getTupleto().setEnters(3);
1129
minimum.getTupleto().setTimes(2);
1131
long missingTime = time;
1132
while( missingTime > minimum.getTime() ){
1133
TGDuration duration = TGDuration.fromTime(factory, missingTime, minimum , 10);
1134
durations.add( duration.clone(factory) );
1135
missingTime -= duration.getTime();