Tux Guitar

Suggestions

Subject There should be a countdown button



Author Message
warcry
Post: Oct 9th 2009 at 7:38 PM

It's very much easier to practice a song with that button. When it is on, you click play and the program wait three metronome hits before playing.

cheers


Back to Top
 
yet another tuxguitar fan
Post: Oct 26th 2009 at 8:23 AM

Hello, I implemented the basic feature in a rather dirty way in a
recent CVS version of TuxGuitar. If someone is interested I could send
the changed file (it's MidiPlayer.java).

First I had to add two lines in the header part:

import org.herac.tuxguitar.gui.util.MidiTickUtil;
import org.herac.tuxguitar.song.models.TGTempo;

Then I changed the play method (added a countdown parameter):

public void play() throws MidiPlayerException { play(true); }
public synchronized void play(boolean countdown) throws MidiPlayerException{

changed the call of this function in method finish() to

this.play(false);

and inserted the main code for this function inside method play(boolean countdown)

if (countdown)
{ int METRONOME_CHANNEL = 9;
int METRONOME_KEY = 37;
int vel=60;

TGMeasureHeader header = songManager.getMeasureHeaderAt(MidiTickUtil.getStart(getSequencer().getTickPosition()));
long length = header.getTempo().getInMillis();

length/=getMode().getCurrentPercent()/100.;

for(int i=0;i<3;i++,vel+=20)
{ getOutputTransmitter().sendNoteOn(METRONOME_CHANNEL, METRONOME_KEY, vel);
Thread.sleep(length);
getOutputTransmitter().sendNoteOff(METRONOME_CHANNEL, METRONOME_KEY, vel);
}
}

in-between the lines
this.setRunning(true);
this.getSequencer().start();

Seems to work.

With best regards

yatgf


Back to Top
 
MyStrat
Post: Oct 26th 2009 at 4:03 PM

I just add a new measure or 2 to the beginning of the song...adds enough time to get 'ready' to play.


Back to Top
 
Julian
Post: Oct 26th 2009 at 9:52 PM

I think you could use "wait(length)" instead of Thread.sleep(length).
the sleep method causes that the thread sleep these millis.. but nothing tells you that it will "inmediatly" executed after sleep. so you can listen wrong timing using it.

the wait method, maybe it wasn't designed for this, but it have better precision

Did you know that it's "SVN" ? ( i see that you allways say CVS instead :) )


Back to Top
 
yet another tuxguitar fan
Post: Oct 30th 2009 at 4:41 PM

> I think you could use "wait(length)" instead of Thread.sleep(length).
I changed this, thank you.

> Did you know that it's "SVN" ? ( i see that you allways say CVS
> instead :) )
Oh, of course. My little script for updating the code is called
getFromCVS.sh because it used CVS in the past ... .


Back to Top
 
Erix
Post: Dec 17th 2009 at 8:36 PM

I support the idea of a count function.
Adding an empty bar at the beginning is not a good workaround, as a count is also needed when looping in the middle of a song.

Bye, Erix.


Back to Top