Tux Guitar

Suggestions

Subject Show all measure notes in fretboard when playing



Author Message
klim8
Post: Mar 17th 2008 at 6:42 PM

Guitar Pro 5 shows the notes to be played in the current measure when playing music and highlights current notes in a different color. I have developed a patch to do it in TuxGuitar. Is this the correct place to post it?

Index: src/org/herac/tuxguitar/gui/editors/fretboard/FretBoard.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/editors/fretboard/FretBoard.java,v
retrieving revision 1.65
diff -u -r1.65 FretBoard.java
--- src/org/herac/tuxguitar/gui/editors/fretboard/FretBoard.java 15 Feb 2008 16:26:12 -0000 1.65
+++ src/org/herac/tuxguitar/gui/editors/fretboard/FretBoard.java 17 Mar 2008 18:32:29 -0000
@@ -43,6 +43,7 @@
import org.herac.tuxguitar.song.managers.TGSongManager;
import org.herac.tuxguitar.song.models.TGBeat;
import org.herac.tuxguitar.song.models.TGDuration;
+import org.herac.tuxguitar.song.models.TGMeasure;
import org.herac.tuxguitar.song.models.TGNote;
import org.herac.tuxguitar.song.models.TGString;
import org.herac.tuxguitar.song.models.TGTrack;
@@ -71,6 +72,7 @@
//private List components;

private TGBeat beat;
+ private TGMeasure measure;

private int[] frets;
private int[] strings;
@@ -257,6 +259,7 @@
if(isVisible()){
if(TuxGuitar.instance().getPlayer().isRunning()){
this.beat = TuxGuitar.instance().getEditorCache().getPlayBeat();
+ this.measure = TuxGuitar.instance().getEditorCache().getPlayMeasure();
}else{
this.beat = TuxGuitar.instance().getEditorCache().getEditBeat();
}
@@ -388,6 +391,33 @@
if(this.beat != null){
TGTrack track = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack();

+ if (this.measure != null) {
+ Iterator it = this.measure.getBeats().iterator();
+ while (it.hasNext()) {
+ Iterator it2 = ((TGBeat) it.next()).getNotes().iterator();
+ while (it2.hasNext()) {
+ TGNote note = (TGNote) it2.next();
+ int fretIndex = note.getValue();
+ int stringIndex = note.getString() - 1;
+ if (fretIndex >= 0 && fretIndex < this.frets.length && stringIndex >= 0 && stringIndex < this.strings.length) {
+ int x = this.frets[fretIndex];
+ if (fretIndex > 0) {
+ x -= ((this.frets[fretIndex] - this.frets[fretIndex - 1]) / 2);
+ }
+ int y = this.strings[stringIndex];
+
+ if( (this.config.getStyle() & FretBoardConfig.DISPLAY_TEXT_NOTE) != 0 ){
+ int realValue = track.getString(note.getString()).getValue() + note.getValue();
+ paintKeyText(painter,this.config.getColorMeasureNote(), x, y, NOTE_NAMES[ (realValue % 12) ]);
+ }
+ else{
+ paintKeyOval(painter,this.config.getColorMeasureNote(), x, y);
+ }
+ }
+ }
+ }
+ }
+
Iterator it = this.beat.getNotes().iterator();
while (it.hasNext()) {
TGNote note = (TGNote) it.next();
Index: src/org/herac/tuxguitar/gui/editors/fretboard/FretBoardConfig.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/editors/fretboard/FretBoardConfig.java,v
retrieving revision 1.7
diff -u -r1.7 FretBoardConfig.java
--- src/org/herac/tuxguitar/gui/editors/fretboard/FretBoardConfig.java 1 Mar 2008 17:32:02 -0000 1.7
+++ src/org/herac/tuxguitar/gui/editors/fretboard/FretBoardConfig.java 17 Mar 2008 18:32:29 -0000
@@ -38,6 +38,7 @@
private Color colorBackground;
private Color colorString;
private Color colorFretPoint;
+ private Color colorMeasureNote;
private Color colorNote;
private Color colorScale;

@@ -65,6 +66,10 @@
return this.colorFretPoint;
}

+ public Color getColorMeasureNote() {
+ return this.colorMeasureNote;
+ }
+
public Color getColorNote() {
return this.colorNote;
}
@@ -81,6 +86,7 @@
this.colorBackground = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_BACKGROUND));
this.colorString = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_STRING));
this.colorFretPoint = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_FRET_POINT));
+ this.colorMeasureNote = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE));
this.colorNote = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_NOTE));
this.colorScale = new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_SCALE));
}
@@ -93,17 +99,19 @@
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_BACKGROUND,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_BACKGROUND));
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_STRING,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_STRING));
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_FRET_POINT,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_FRET_POINT));
+ config.setProperty(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE));
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_NOTE,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_NOTE));
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_SCALE,defaults.getProperty(TGConfigKeys.FRETBOARD_COLOR_SCALE));
}

- public void save(int style,FontData fontData,RGB rgbBackground,RGB rgbString,RGB rgbFretPoint,RGB rgbNote,RGB rgbScale){
+ public void save(int style,FontData fontData,RGB rgbBackground,RGB rgbString,RGB rgbFretPoint,RGB rgbMeasureNote, RGB rgbNote,RGB rgbScale){
TGConfigManager config = TuxGuitar.instance().getConfig();
config.setProperty(TGConfigKeys.FRETBOARD_STYLE,style);
config.setProperty(TGConfigKeys.FRETBOARD_FONT,fontData);
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_BACKGROUND,rgbBackground);
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_STRING,rgbString);
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_FRET_POINT,rgbFretPoint);
+ config.setProperty(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE,rgbMeasureNote);
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_NOTE,rgbNote);
config.setProperty(TGConfigKeys.FRETBOARD_COLOR_SCALE,rgbScale);
}
@@ -138,6 +146,7 @@
final RGB rgbBackground = getColorChooser(group,TuxGuitar.getProperty("fretboard.background-color"), this.colorBackground.getRGB());
final RGB rgbString = getColorChooser(group,TuxGuitar.getProperty("fretboard.string-color"), this.colorString.getRGB());
final RGB rgbFretPoint = getColorChooser(group,TuxGuitar.getProperty("fretboard.fretpoint-color"), this.colorFretPoint.getRGB());
+ final RGB rgbMeasureNote = getColorChooser(group,TuxGuitar.getProperty("fretboard.measure-note-color"), this.colorMeasureNote.getRGB());
final RGB rgbNote = getColorChooser(group,TuxGuitar.getProperty("fretboard.note-color"), this.colorNote.getRGB());
final RGB rgbScale = getColorChooser(group,TuxGuitar.getProperty("fretboard.scale-note-color"), this.colorScale.getRGB());

@@ -184,7 +193,7 @@

dialog.dispose();

- save(style, fontData, rgbBackground, rgbString, rgbFretPoint, rgbNote, rgbScale);
+ save(style, fontData, rgbBackground, rgbString, rgbFretPoint, rgbMeasureNote, rgbNote, rgbScale);
applyChanges();
}
});
Index: src/org/herac/tuxguitar/gui/system/config/TGConfigDefaults.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/system/config/TGConfigDefaults.java,v
retrieving revision 1.21
diff -u -r1.21 TGConfigDefaults.java
--- src/org/herac/tuxguitar/gui/system/config/TGConfigDefaults.java 15 Feb 2008 15:45:12 -0000 1.21
+++ src/org/herac/tuxguitar/gui/system/config/TGConfigDefaults.java 17 Mar 2008 18:32:30 -0000
@@ -98,8 +98,9 @@
this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_BACKGROUND,"0,0,0");
this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_STRING,"227,217,217");
this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_FRET_POINT,"192,192,192");
- this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_NOTE,"0,0,255");
- this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_SCALE,"255,0,0");
+ this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE,"0,0,255");
+ this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_NOTE,"255,0,0");
+ this.loadProperty(TGConfigKeys.FRETBOARD_COLOR_SCALE,"150,150,150");
this.loadProperty(TGConfigKeys.PIANO_COLOR_KEY_NATURAL,"255,255,255");
this.loadProperty(TGConfigKeys.PIANO_COLOR_KEY_NOT_NATURAL,"0,0,0");
this.loadProperty(TGConfigKeys.PIANO_COLOR_NOTE,"0,0,255");
Index: src/org/herac/tuxguitar/gui/system/config/TGConfigKeys.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/system/config/TGConfigKeys.java,v
retrieving revision 1.20
diff -u -r1.20 TGConfigKeys.java
--- src/org/herac/tuxguitar/gui/system/config/TGConfigKeys.java 15 Feb 2008 15:45:12 -0000 1.20
+++ src/org/herac/tuxguitar/gui/system/config/TGConfigKeys.java 17 Mar 2008 18:32:30 -0000
@@ -67,6 +67,7 @@
public static final String FRETBOARD_COLOR_BACKGROUND = "fretboard.color.background";
public static final String FRETBOARD_COLOR_STRING = "fretboard.color.string";
public static final String FRETBOARD_COLOR_FRET_POINT = "fretboard.color.fret-point";
+ public static final String FRETBOARD_COLOR_MEASURE_NOTE = "fretboard.color.measure-note";
public static final String FRETBOARD_COLOR_NOTE = "fretboard.color.note";
public static final String FRETBOARD_COLOR_SCALE = "fretboard.color.scale";
public static final String PIANO_COLOR_KEY_NATURAL = "piano.color.natural-key";


Back to Top
 
Johnny
Post: Mar 19th 2008 at 9:49 AM

It's OK. I agree it is a needed feature, and you did it correctly... only you're a _little_ bit late.

If you published this diff few weeks ago, it would be fine, but now for RC1&2, it gets too complicated to be patched immediately (because config file changes and your string needs translations in dozens of languages :)

So I agree for this feature to be applied in some future releases...


Back to Top
 
Johnny
Post: Mar 19th 2008 at 9:49 AM

It's OK. I agree it is a needed feature, and you did it correctly... only you're a _little_ bit late.

If you published this diff few weeks ago, it would be fine, but now for RC1&2, it gets too complicated to be patched immediately (because config file changes and your string needs translations in dozens of languages :)

So I agree for this feature to be applied in some future releases...


Back to Top
 
Julian
Post: Mar 20th 2008 at 5:21 PM

Hi,
that feature was already planned for future versions of tuxguitar.
but with a little difference: the user must be able to enable/disable it.

Somebody can apply this patch ( it's available for download at sourceforge too ) but i found some little things:

1* this.measure = TuxGuitar.instance().getEditorCache().getPlayMeasure();
Not a bug, but will be better if you use "this.beat.getMeasure()"

2* Measure notes should be painted only when measure was changed ( like matrix editor does ). Here you are repainting it all the times when a "beat" was changed.

3* new Color(display,config.getRGBConfigValue(TGConfigKeys.FRETBOARD_COLOR_MEASURE_NOTE));
That will construct a new Color instance. but what about "dispose" it ? ( To release SWT native pointers, "dispose" method must be called )

Bye


Back to Top
 
WIL
Post: Jun 18th 2008 at 12:02 PM

HI
Ability to see the next note on the fretboard like guitar pro.But maybe this patch do the job but i haven't understood all i am french.I mean showing the current note and the next note to be played.
great soft anyway.


Back to Top