Hey so I just wanted to add some code that works as a BPM based metronome that can be added to a script via a class. I've called it using "ss.playMetronome(this);". Any new functions you create for your script could also live within that class file as long as you refrence ss.functionetc();
Only use the import class code once in your main script. I'm thinking of rolling up my functions into a func_beta.groovy file so they can be shared with everyone writing repeat code (like metronomes). Instead of working out how to code a metronome, you just call ss.playMetronome(this);
myscript.groovy
Code:
// IMPORT CLASS
def si = new groovy.lang.GroovyClassLoader(); si.addClasspath("scripts/myscript/");
def ss = si.loadClass("Functions");
// PLAY METRONOME ... for 10 secs at 240BPM
int sCount = ss.playMetronome(this, 10, 240);
show("You just stroked " +sCount+" times."); wait(5);
scripts/myscript/Functions.groovy
Code:
class Functions {
// Metronome method speed in BPM, runtime in seconds ...
def static playMetronome(main, ON = 30, BPM = 60) {
def BPS = BPM / 60;
def strokes = BPS * ON;
int speed = ((60 / BPM) * 1000);
(1..strokes).each {
main.playBackgroundSound("tom.wav");
main.sleep(speed);
}
return strokes;
}
}
The more I think about the thuddy sound of metronomes for stroking the more I think there should be a "swooshy beat" sound file for girls. Less thud .. thud .. thud, more swoosh from side to side.