Author |
Message |
TecnoGuy458
Joined: 26 Jan 2015 Posts: 124 Location: Ohio
|
Posted: Sat 21 Nov 2015, 16:56 Post subject:
Thomas Virtual Piano Subject description: Virtual PC speaker Piano |
|
GitHub: https://github.com/ThomasTheSpaceFox/Thomas-Virtual-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.
Description |
|

Download |
Filename |
ThomasVirtualPiano-v1.3.pet |
Filesize |
21.69 KB |
Downloaded |
223 Time(s) |
|
Back to top
|
|
 |
TecnoGuy458
Joined: 26 Jan 2015 Posts: 124 Location: Ohio
|
Posted: Sat 21 Nov 2015, 16:59 Post subject:
Thomas Virtual Piano |
|
screenshot:
Description |
|

Download |
Filename |
piano-capture29690.png |
Filesize |
12 KB |
Downloaded |
383 Time(s) |
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6608 Location: Valåmoen, Norway
|
Posted: Tue 24 Nov 2015, 00:40 Post subject:
|
|
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.
Code: | #!/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 |
_________________ Stardust resources
|
Back to top
|
|
 |
TecnoGuy458
Joined: 26 Jan 2015 Posts: 124 Location: Ohio
|
Posted: Tue 24 Nov 2015, 22:11 Post subject:
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?
|
Back to top
|
|
 |
nubc

Joined: 23 Jan 2007 Posts: 2065 Location: USA
|
Posted: Wed 25 Nov 2015, 00:18 Post subject:
|
|
Ever considered the chromatic keyboard?
|
Back to top
|
|
 |
gcmartin
Joined: 14 Oct 2005 Posts: 6730 Location: Earth
|
Posted: Wed 25 Nov 2015, 02:43 Post subject:
|
|
This would be a nice musical app for a touch-screen PC. Would be nice if it came with distro's Menu>Games folder, as, say "20key Piano" I will try it, later.
Question
As it currently is 20keys, is the number of keys selectable; say, 44keys or 88keys for large touch screens?
_________________ Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engines or use DogPile
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5389 Location: Ontario
|
Posted: Thu 26 Nov 2015, 20:45 Post subject:
|
|
There are other ways to generate a beep noise like the command speaker-test
Code: | speaker-test -c2 -t sine |
Quote: |
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.
|
|
Back to top
|
|
 |
|