Thomas Virtual Piano

Audio editors, music players, video players, burning software, etc.
Post Reply
Message
Author
TecnoGuy458
Posts: 123
Joined: Mon 26 Jan 2015, 20:38
Location: Ohio

Thomas Virtual Piano

#1 Post by TecnoGuy458 »

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.
Attachments
ThomasVirtualPiano-v1.3.pet
(21.69 KiB) Downloaded 254 times

TecnoGuy458
Posts: 123
Joined: Mon 26 Jan 2015, 20:38
Location: Ohio

Thomas Virtual Piano

#2 Post by TecnoGuy458 »

screenshot:
Attachments
piano-capture29690.png
(12 KiB) Downloaded 403 times

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#3 Post by zigbert »

Like it - even if beep don't give sound on my system :D

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

TecnoGuy458
Posts: 123
Joined: Mon 26 Jan 2015, 20:38
Location: Ohio

ill look into it later.

#4 Post by TecnoGuy458 »

looks nice! :D i will try it later. currently busy extending my Terminal Image System's color pallet. 8)

btw on a side note,

that $WHEREAMI thing is a neat trick isn't it? :D

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#5 Post by nubc »

Ever considered the chromatic keyboard?

gcmartin

#6 Post by gcmartin »

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?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#7 Post by don570 »

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.

Post Reply