Tux Guitar

Suggestions

Subject Guitar Pro-like Palm Muting rendering



Author Message
klim8
Post: Mar 31st 2008 at 3:00 PM

With this patch, a line is drawn from the second to the last beat of a PM phrase instead of marking each note with a PM string. Just like what Guitar Pro does.

### Eclipse Workspace Patch 1.0
#P TuxGuitarCVS
Index: src/org/herac/tuxguitar/gui/editors/tab/TGNoteImpl.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/editors/tab/TGNoteImpl.java,v
retrieving revision 1.67
diff -u -r1.67 TGNoteImpl.java
--- src/org/herac/tuxguitar/gui/editors/tab/TGNoteImpl.java 20 Mar 2008 18:12:33 -0000 1.67
+++ src/org/herac/tuxguitar/gui/editors/tab/TGNoteImpl.java 31 Mar 2008 14:52:01 -0000
@@ -11,6 +11,7 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.herac.tuxguitar.gui.editors.TGPainter;
+import org.herac.tuxguitar.gui.editors.tab.TGMeasureImpl;
import org.herac.tuxguitar.gui.editors.tab.layout.TrackSpacing;
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
import org.herac.tuxguitar.gui.editors.tab.painters.TGKeySignaturePainter;
@@ -158,7 +159,54 @@
if(effect.isPalmMute()){
int x = fromX + getPosX() + spacing;
int y = (fromY + getPaintPosition(TrackSpacing.POSITION_PALM_MUTE_EFFEC));
- painter.drawString("P.M",x, y);
+ TGBeatImpl beat;
+ String PMString = "P.M";
+
+ boolean prevPM = false;
+ beat = getBeatImpl().getPreviousBeat();
+ if (beat != null) {
+ Iterator it = beat.getNotes().iterator();
+
+ while(it.hasNext()){
+ TGNoteImpl note = (TGNoteImpl)it.next();
+ TGNoteEffect prevEffect = note.getEffect();
+
+ if (prevEffect.isPalmMute()) {
+ prevPM = true;
+ break;
+ }
+ }
+ } else {
+ prevPM = false;
+ }
+
+ boolean nextPM = false;
+ beat = getBeatImpl().getNextBeat();
+ if (beat != null) {
+ Iterator it = beat.getNotes().iterator();
+
+ while(it.hasNext()){
+ TGNoteImpl note = (TGNoteImpl)it.next();
+ TGNoteEffect nextEffect = note.getEffect();
+
+ if (nextEffect.isPalmMute()) {
+ nextPM = true;
+ break;
+ }
+ }
+ }
+
+ Point dim = painter.getStringExtent(PMString);
+
+ if (!prevPM) {
+ painter.drawString(PMString, x, y);
+ } else {
+ painter.drawLine(x-6, y+dim.y/2, x + getBeatImpl().getWidth(), y+dim.y/2);
+
+ if (!nextPM) {
+ painter.drawString("|", x + getBeatImpl().getWidth(), y);
+ }
+ }
}
if(effect.isVibrato()){
int x = fromX + getPosX() + spacing;
Index: src/org/herac/tuxguitar/gui/editors/tab/TGBeatImpl.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/editors/tab/TGBeatImpl.java,v
retrieving revision 1.10
diff -u -r1.10 TGBeatImpl.java
--- src/org/herac/tuxguitar/gui/editors/tab/TGBeatImpl.java 20 Mar 2008 15:24:28 -0000 1.10
+++ src/org/herac/tuxguitar/gui/editors/tab/TGBeatImpl.java 31 Mar 2008 14:52:01 -0000
@@ -120,10 +120,18 @@
this.previous = previous;
}

+ public TGBeatImpl getPreviousBeat(){
+ return this.previous;
+ }
+
public void setNextBeat(TGBeatImpl next){
this.next = next;
}

+ public TGBeatImpl getNextBeat(){
+ return this.next;
+ }
+
public TGBeatGroup getBeatGroup() {
return this.group;
}
Index: src/org/herac/tuxguitar/gui/editors/TGPainter.java
===================================================================
RCS file: /cvsroot/tuxguitar/TuxGuitar/src/org/herac/tuxguitar/gui/editors/TGPainter.java,v
retrieving revision 1.16
diff -u -r1.16 TGPainter.java
--- src/org/herac/tuxguitar/gui/editors/TGPainter.java 20 Mar 2008 15:24:30 -0000 1.16
+++ src/org/herac/tuxguitar/gui/editors/TGPainter.java 31 Mar 2008 14:52:01 -0000
@@ -132,8 +132,12 @@
public void drawImage(Image image, int x, int y) {
TGPainterUtils.beforeImage(this.gc);
this.gc.drawImage(image, x, y);
- }
-
+ }
+ public void drawLine(int x1, int y1, int x2, int y2) {
+ TGPainterUtils.beforeImage(this.gc);
+ this.gc.drawLine(x1, y1, x2, y2);
+ }
+
public void drawPolygon(int[] arg0) {
this.gc.drawPolygon(arg0);
}


Back to Top
 
Not Desi Arnez
Post: Dec 7th 2009 at 4:59 PM

I have no clue what that code means, but I agree with the concept presented. It's also the rendering used in any "professional" magazine/book of tabs.

This would reduce the frustration of having PMPMPMPMPMPMPMPMPMPMPMPMPMPMPM etc. over every sixteenthnote sequence that you want palmed.


Back to Top
 
Danice
Post: Dec 18th 2011 at 6:53 PM

That's a smart way of loiknog at the world.


Back to Top
 
dsgoiv
Post: Dec 19th 2011 at 8:33 AM

Pjra0V goyqeqaxsigz


Back to Top
 
Andrew
Post: Feb 15th 2012 at 5:02 AM

How do you import this exactly, or is this just an idea.


Back to Top