GitHub: https://github.com/ThomasTheSpaceFox/Th ... tual-Piano
.PET attached below.
uses Bash, gtkdialog and beep, to allow the user to play a small virtual piano through their PC speaker.
piano specs: 4 piece percussion. keys 21-40.
Thomas Virtual Piano
-
- Posts: 123
- Joined: Mon 26 Jan 2015, 20:38
- Location: Ohio
Thomas Virtual Piano
- Attachments
-
- ThomasVirtualPiano-v1.3.pet
- (21.69 KiB) Downloaded 254 times
-
- Posts: 123
- Joined: Mon 26 Jan 2015, 20:38
- Location: Ohio
Like it - even if beep don't give sound on my system
If you would like to consider it, I have rearranged your code. Just to give an example of another coding structure. Thomas-Virtual-Piano.sh has gone from 224 to 68 codelines, and the gui is more compact. - Narrower, but with the same key-size.
If you would like to consider it, I have rearranged your code. Just to give an example of another coding structure. Thomas-Virtual-Piano.sh has gone from 224 to 68 codelines, and the gui is more compact. - Narrower, but with the same key-size.
Code: Select all
#!/bin/bash
WHEREAMI="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd && echo)"
cd $WHEREAMI
build_key (){
SOUND=$(cut -d_ -f1 <<< "$1")
COLOR=$(cut -d_ -f2 <<< "$1")
echo '<vbox>
<pixmap><input file>'$2'.png</input></pixmap>
<button relief="2">
<action>"beep -f '$SOUND'"</action>
<input file>"key'$COLOR'.png"</input>
</button>
</vbox>'
}
export -f build_key
export DIALOG='
<window resizable="false" title="Thomas Virtual Piano" image-name="Thomas-Virtual-Piano.png">
<vbox>
<hbox>
<pixmap>
<input file>speaker.png</input>
</pixmap>
<button ok></button>
<button>
<label>"About"</label>
<action>"'$WHEREAMI'/about.sh"</action>
</button>
<hbox scrollable="true" width-request="10" height="30" >
<pixmap>
<input file>bar.png</input>
</pixmap>
</hbox>
<button>
<action>"beep -f 300 -l 40 -n -f 400 -l 5 -n -f 250 -l 15 -n -f 100 -l 10"</action>
<input file>"cymbal.png"</input>
</button>
<button>
<action>"beep -f 300 -l 40 -n -f 400 -l 5 -n -f 300 -l 10"</action>
<input file>"hithat.png"</input>
</button>
<button>
<action>"beep -f 60 -l 40"</action>
<input file>"bdrum.png"</input>
</button>
<button>
<action>"beep -f 100 -l 40"</action>
<input file>"ldrum.png"</input>
</button>
<text>
<label>"Thomas Virtual Piano"</label>
</text>
<pixmap>
<input file>speaker.png</input>
</pixmap>
</hbox>
<hbox spacing="0">'
NR=21
for KEY in 87_w 92_b 98_w 104_b 110_w 116_b 123_w 131_w 138_b 147_w 155_b 165_w 175_w 185_b 196_w 208_b 220_w 233_b 247_w 262_w; do
export DIALOG="$DIALOG $(build_key $KEY $NR)"
NR=$(($NR+1))
done
export DIALOG="$DIALOG </hbox>
</vbox>
</window>"
gtkdialog --space-expand=true --space-fill=true --program DIALOG
-
- Posts: 123
- Joined: Mon 26 Jan 2015, 20:38
- Location: Ohio
ill look into it later.
looks nice! i will try it later. currently busy extending my Terminal Image System's color pallet.
btw on a side note,
that $WHEREAMI thing is a neat trick isn't it?
btw on a side note,
that $WHEREAMI thing is a neat trick isn't it?
Ever considered the chromatic keyboard?
There are other ways to generate a beep noise like the command speaker-test
Code: Select all
speaker-test -c2 -t sine
You might look at speaker-test, which (on an Arch machine) I find in alsa-utils package.
speaker-test -c2 -t sine run from an xterm, gave me a 440 Hz sine wave for about 6 seconds each, alternating left and right speakers. In the xterm, it gave some information about which speaker it thought it was using.
According to the man page, it can do sine waves of arbitrary frequency and pink noise.