├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main └── java └── com └── sudharsan └── selenium ├── KeyInfo.java ├── Main.java ├── PianoPlayer.java ├── SongNote.java ├── Stanza.java └── songs ├── CoffinDance.java ├── GameOfThrone.java └── HappyBirthday.java /README.md: -------------------------------------------------------------------------------- 1 | # selenium-piano-player 2 | Selenium Automation script to play music notes on online piano. 3 | 4 | [![DEMO](https://img.youtube.com/vi/veu43DYfnSk/0.jpg)](https://www.youtube.com/watch?v=veu43DYfnSk "Selenium piano player") 5 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group 'com.sudharsan.selenium' 6 | version '1.0-SNAPSHOT' 7 | 8 | sourceCompatibility = 1.8 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | compile (group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59') 16 | } 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudharsan-selvaraj/selenium-piano-player/e55eb54149ea68bc116dce495ccd21af63a0d659/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'pianoplayer' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/KeyInfo.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium; 2 | 3 | public class KeyInfo { 4 | 5 | public int position; 6 | public String keyName; 7 | 8 | public KeyInfo(int position, String keyName) { 9 | this.position = position; 10 | this.keyName = keyName; 11 | } 12 | 13 | public int getPosition() { 14 | return position; 15 | } 16 | 17 | public String getKeyName() { 18 | return keyName; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/Main.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium; 2 | 3 | import com.sudharsan.selenium.songs.CoffinDance; 4 | import com.sudharsan.selenium.songs.GameOfThrone; 5 | import com.sudharsan.selenium.songs.HappyBirthday; 6 | 7 | public class Main { 8 | 9 | public static void main(String[] args) { 10 | System.setProperty("webdriver.chrome.driver", "/Users/sudharsan/Documents/Applications/chromedriver"); 11 | 12 | PianoPlayer player = new PianoPlayer().initialize(); 13 | 14 | System.out.println("Playing HAPPY BIRTHDAY song..\n"); 15 | player.sleep(2000); 16 | player.playSong(HappyBirthday.songNotes); 17 | 18 | System.out.println("\nPlaying GAME OF THRONES THEME music..\n"); 19 | player.sleep(2000); 20 | player.playSong(GameOfThrone.songNotes); 21 | 22 | 23 | System.out.println("\nPlaying COFFIN DANCE music..\n"); 24 | player.sleep(2000); 25 | player.playSong(CoffinDance.songNotes); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/PianoPlayer.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium; 2 | 3 | import org.openqa.selenium.By; 4 | import org.openqa.selenium.Dimension; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.WebElement; 7 | import org.openqa.selenium.chrome.ChromeDriver; 8 | import org.openqa.selenium.interactions.Actions; 9 | 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.logging.Level; 14 | 15 | public class PianoPlayer { 16 | 17 | private WebDriver driver; 18 | private WebElement canvas; 19 | private static Map keyboardKeyInfo; 20 | private static int canvasStartPoint = -678, keyWidth = 22; 21 | 22 | static { 23 | keyboardKeyInfo = new HashMap() {{ 24 | put("a0", new KeyInfo(23, "c")); 25 | put("a0#", new KeyInfo(34, "f")); 26 | put("b0", new KeyInfo(25, "v")); 27 | 28 | put("c", new KeyInfo(26, "i")); 29 | put("c#", new KeyInfo(27, "9")); 30 | put("d", new KeyInfo(28, "o")); 31 | put("d#", new KeyInfo(29, "0")); 32 | put("e", new KeyInfo(30, "p")); 33 | put("f", new KeyInfo(31, "z")); 34 | put("f#", new KeyInfo(32, "s")); 35 | put("g", new KeyInfo(33, "x")); 36 | put("g#", new KeyInfo(34, "d")); 37 | put("a", new KeyInfo(35, "y")); 38 | put("a#", new KeyInfo(36, "7")); 39 | put("b", new KeyInfo(37, "u")); 40 | 41 | put("c1", new KeyInfo(38, "b")); 42 | put("c1#", new KeyInfo(39, "h")); 43 | put("d1", new KeyInfo(40, "n")); 44 | put("d1#", new KeyInfo(41, "j")); 45 | put("e1", new KeyInfo(42, "m")); 46 | put("f1", new KeyInfo(43, ",")); 47 | put("f1#", new KeyInfo(44, "l")); 48 | put("g1", new KeyInfo(45, ".")); 49 | put("g1#", new KeyInfo(46, ";")); 50 | put("a1", new KeyInfo(47, "c")); 51 | put("a1#", new KeyInfo(48, "f")); 52 | put("b1", new KeyInfo(49, "v")); 53 | }}; 54 | } 55 | 56 | 57 | public PianoPlayer initialize() { 58 | driver = new ChromeDriver(); 59 | driver.get("https://www.onlinepianist.com/virtual-piano"); 60 | driver.manage().window().setSize(new Dimension(1350, 900)); 61 | 62 | sleep(10000); 63 | canvas = driver.findElement(By.tagName("canvas")); 64 | 65 | java.util.logging.Logger.getLogger("org.openqa").setLevel(Level.OFF); 66 | return this; 67 | } 68 | 69 | 70 | public void playSong(List songStanzaList) { 71 | for (Stanza stanza : songStanzaList) { 72 | for (int i = 0; i < stanza.getLoopCount(); i++) { 73 | for (SongNote note : stanza.getSongNotes()) { 74 | for (int j = 0; j < note.getLoopCount(); j++) { 75 | System.out.println("Current note is " + note.getKeyName()); 76 | keyPress(keyboardKeyInfo.get(note.getKeyName()), note.getReleaseTime()); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | 83 | private void keyPress(KeyInfo keyInfo, Integer keyReleaseDelay) { 84 | int y = 20; 85 | int x = (canvasStartPoint + (keyInfo.getPosition() * keyWidth)); 86 | 87 | new Actions(driver).moveToElement(canvas, x, y).clickAndHold().perform(); 88 | 89 | if (keyReleaseDelay > 0) { 90 | sleep(keyReleaseDelay); 91 | } 92 | new Actions(this.driver).moveToElement(canvas, x, y).release().perform(); 93 | } 94 | 95 | 96 | void sleep(Integer time) { 97 | try { 98 | Thread.sleep(time); 99 | } catch (Exception e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/SongNote.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium; 2 | 3 | public class SongNote { 4 | private String keyName; 5 | private Integer releaseTime = 0; 6 | private Integer loopCount = 0; 7 | 8 | public SongNote(String keyName, Integer releaseTime, Integer loopCount) { 9 | this.keyName = keyName; 10 | this.releaseTime = releaseTime; 11 | this.loopCount = loopCount; 12 | } 13 | 14 | public String getKeyName() { 15 | return keyName; 16 | } 17 | 18 | public Integer getReleaseTime() { 19 | return releaseTime; 20 | } 21 | 22 | public Integer getLoopCount() { 23 | return loopCount; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/Stanza.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium; 2 | import java.util.ArrayList; 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Stanza { 7 | 8 | private List notes = new ArrayList<>(); 9 | private int loopCount = 1; 10 | 11 | public Stanza note(String keyName) { 12 | return note(keyName, 0); 13 | } 14 | 15 | public Stanza note(String keyName, Integer sleepTime) { 16 | this.notes.add(new SongNote(keyName, sleepTime, 1)); 17 | return this; 18 | } 19 | 20 | public Stanza note(String keyName, Integer sleepTime, Integer loopCount) { 21 | this.notes.add(new SongNote(keyName, sleepTime, loopCount)); 22 | return this; 23 | } 24 | 25 | 26 | public Stanza notes(List notes) { 27 | return notes(notes, 1); 28 | } 29 | 30 | public Stanza notes(List notes, Integer loopCount) { 31 | for(int c=0; c< loopCount;c++) { 32 | Collections.addAll(this.notes, notes.toArray(new SongNote[]{})); 33 | } 34 | return this; 35 | } 36 | 37 | public Stanza loop(Integer loopCount) { 38 | this.loopCount = loopCount; 39 | return this; 40 | } 41 | 42 | public Integer getLoopCount() { 43 | return this.loopCount; 44 | } 45 | 46 | public List getSongNotes() { 47 | return notes; 48 | } 49 | } 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/songs/CoffinDance.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium.songs; 2 | 3 | import com.sudharsan.selenium.Stanza; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class CoffinDance { 9 | 10 | public static List songNotes = new ArrayList<>(); 11 | 12 | static { 13 | 14 | songNotes.add( 15 | new Stanza() 16 | .note("g",300) 17 | .note("g") 18 | .note("d1") 19 | .note("c1",300) 20 | .note("a#",300) 21 | .note("a",300) 22 | .note("a", 0, 2) 23 | .note("c1", 300) 24 | .note("a#",0) 25 | .note("a",0) 26 | ); 27 | 28 | 29 | songNotes.add( 30 | new Stanza() 31 | .note("g", 200) 32 | .note("g") 33 | .note("a1#") 34 | .note("a1") 35 | .note("a1#") 36 | .note("a1") 37 | .note("a1#") 38 | .loop(2) 39 | ); 40 | 41 | songNotes.add( 42 | new Stanza() 43 | .note("g",300) 44 | .note("g") 45 | .note("d1") 46 | .note("c1",300) 47 | .note("a#",300) 48 | .note("a",300) 49 | .note("a", 0, 2) 50 | .note("c1", 300) 51 | .note("a#",0) 52 | .note("a",0) 53 | ); 54 | 55 | 56 | songNotes.add( 57 | new Stanza() 58 | .note("g", 200) 59 | .note("g") 60 | .note("a1#") 61 | .note("a1") 62 | .note("a1#") 63 | .note("a1") 64 | .note("a1#",100) 65 | .loop(2) 66 | ); 67 | 68 | songNotes.add( 69 | new Stanza() 70 | .note("a1#", 50, 2) 71 | .note("a1", 50, 2) 72 | .note("d1", 50,4) 73 | .note("c1", 50,4) 74 | .note("f1", 50, 4) 75 | .note("g1", 50, 9) 76 | .note("d1", 50) 77 | .note("c1", 50) 78 | .note("a#", 50) 79 | .note("a", 50) 80 | .note("f", 100) 81 | ); 82 | 83 | songNotes.add( 84 | new Stanza() 85 | .note("g",300) 86 | .note("g") 87 | .note("d1") 88 | .note("c1",300) 89 | .note("a#",300) 90 | .note("a",300) 91 | .note("a", 0, 2) 92 | .note("c1", 300) 93 | .note("a#",0) 94 | .note("a",0) 95 | ); 96 | 97 | 98 | songNotes.add( 99 | new Stanza() 100 | .note("g", 200) 101 | .note("g") 102 | .note("a1#") 103 | .note("a1") 104 | .note("a1#") 105 | .note("a1") 106 | .note("a1#") 107 | .loop(2) 108 | ); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/songs/GameOfThrone.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium.songs; 2 | 3 | import com.sudharsan.selenium.Stanza; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class GameOfThrone { 9 | public static List songNotes = new ArrayList<>(); 10 | 11 | public static Stanza mainStanza, loopTone1, secondStanza, loopTone2; 12 | static { 13 | 14 | mainStanza = new Stanza() 15 | .note("a1", 1000) 16 | .note("d1", 1000) 17 | .note("f1") 18 | .note("g1") 19 | .note("a1", 1000) 20 | .note("d1", 1000) 21 | .note("f1", 50) 22 | .note("g1", 50) 23 | .note("e1", 200); 24 | 25 | loopTone1 = new Stanza() 26 | .note("a", 200) 27 | .note("c1") 28 | .note("d1") 29 | .note("e1", 200); 30 | 31 | loopTone2 = new Stanza() 32 | .note("a1", 200) 33 | .note("d1") 34 | .note("f1") 35 | .note("g1", 200); 36 | 37 | secondStanza = new Stanza() 38 | .note("g1", 1000) 39 | .note("c1", 1000) 40 | .note("e1") 41 | .note("f1") 42 | .note("g1", 1000) 43 | .note("c1", 500) 44 | .note("f1", 50) 45 | .note("e1", 50) 46 | .note("d1", 200); 47 | 48 | songNotes.add( 49 | new Stanza() 50 | .notes(mainStanza.getSongNotes()) 51 | .notes(loopTone1.getSongNotes(), 4) 52 | .notes(secondStanza.getSongNotes()) 53 | .notes(loopTone1.getSongNotes(), 4) 54 | .notes(loopTone2.getSongNotes(), 4) 55 | .notes(loopTone1.getSongNotes(), 4) 56 | .notes(loopTone2.getSongNotes(), 4) 57 | .notes(loopTone1.getSongNotes(), 4) 58 | 59 | ); 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/sudharsan/selenium/songs/HappyBirthday.java: -------------------------------------------------------------------------------- 1 | package com.sudharsan.selenium.songs; 2 | 3 | import com.sudharsan.selenium.Stanza; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class HappyBirthday { 9 | public static List songNotes = new ArrayList<>(); 10 | 11 | static { 12 | 13 | songNotes.add( 14 | new Stanza() 15 | .note("c", 100, 2) 16 | .note("d", 500) 17 | .note("c", 900) 18 | .note("f", 500) 19 | .note("e", 900) 20 | ); 21 | 22 | songNotes.add( 23 | new Stanza() 24 | .note("c", 100, 2) 25 | .note("d", 500) 26 | .note("c", 900) 27 | .note("g", 500) 28 | .note("f", 900) 29 | ); 30 | 31 | songNotes.add( 32 | new Stanza() 33 | .note("c", 100, 2) 34 | .note("c1", 500) 35 | .note("a", 500) 36 | .note("g", 500) 37 | .note("e", 500) 38 | .note("d", 900) 39 | ); 40 | 41 | 42 | songNotes.add( 43 | new Stanza() 44 | .note("a#", 100, 2) 45 | .note("a", 500) 46 | .note("f", 900) 47 | .note("g", 900) 48 | .note("f", 1200) 49 | ); 50 | 51 | } 52 | } 53 | --------------------------------------------------------------------------------