AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OnScreenPiano
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
imapow



Joined: 13 Mar 2008
Posts: 155
Location: Trøndelag, Norway

PostPosted: Sun Mar 16, 2008 10:25 pm    Post subject: OnScreenPiano Reply with quote

OnScreenPiano is a simple piano emulator
that use soundbeep frequencyes



data files (needed to run program)
http://www.home.no/imapow/OnScreenPiano.zip (10kb)
Code:



; Script Name: OnScreenPiano
;
; AutoHotkey Version: 1.0.47.04
; Language:       English/Norwegian
; Platform:       WinXp
; Author:         Imapow
;



tid = 200   ;set sound beep dur to "200ms"
gui, color, 000000   ;set background color "black"
gui, font, cffffff s9, arial   ;set font to "white 9"


;
; create visual piano
;





gui, add, picture, x+0 y+10, %a_scriptdir%/noter/banner.PNG      ;create banner
gui, add, picture, xm+0 y+10 gc1, %a_scriptdir%/noter/O1.PNG   ;create "C1" note
gui, add, picture, x+0 gdb1, %a_scriptdir%/noter/O2.PNG      ;create "Db1" note
gui, add, picture, x+0 gd1, %a_scriptdir%/noter/O3.PNG      ;create "D1" note
gui, add, picture, x+0 geb1, %a_scriptdir%/noter/O4.PNG      ;create "Eb1" note
gui, add, picture, x+0 ge1, %a_scriptdir%/noter/O5.PNG      ;create "E1" note
gui, add, picture, x+0 gf1, %a_scriptdir%/noter/O6.PNG      ;create "F1" note
gui, add, picture, x+0 ggb1, %a_scriptdir%/noter/O7.PNG      ;create "Gb1" note
gui, add, picture, x+0 gg1, %a_scriptdir%/noter/O8.PNG      ;create "G1" note
gui, add, picture, x+0 gab1, %a_scriptdir%/noter/O9.PNG      ;create "Ab1" note
gui, add, picture, x+0 ga1, %a_scriptdir%/noter/O10.PNG      ;create "A1" note
gui, add, picture, x+0 gbb1, %a_scriptdir%/noter/O11.PNG   ;create "Bb1" note
gui, add, picture, x+0 gb1, %a_scriptdir%/noter/O12.PNG      ;create "B1" note
gui, add, picture, x+0 gc2, %a_scriptdir%/noter/O1.PNG      ;create "C2" note
gui, add, picture, x+0 gdb2, %a_scriptdir%/noter/O2.PNG      ;create "Db2" note
gui, add, picture, x+0 gd2, %a_scriptdir%/noter/O3.PNG      ;create "D2" note
gui, add, picture, x+0 geb2, %a_scriptdir%/noter/O4.PNG      ;create "Eb2" note
gui, add, picture, x+0 ge2, %a_scriptdir%/noter/O5.PNG      ;create "E2" note
gui, add, picture, x+0 gf2, %a_scriptdir%/noter/O6.PNG      ;create "F2" note
gui, add, picture, x+0 ggb2, %a_scriptdir%/noter/O7.PNG      ;create "Gb2" note
gui, add, picture, x+0 gg2, %a_scriptdir%/noter/O8.PNG      ;create "G2" note
gui, add, picture, x+0 gab2, %a_scriptdir%/noter/O9.PNG      ;create "Ab2" note
gui, add, picture, x+0 ga2, %a_scriptdir%/noter/O10.PNG      ;create "A2" note
gui, add, picture, x+0 gbb2, %a_scriptdir%/noter/O11.PNG   ;create "Bb2" note
gui, add, picture, x+0 gb2, %a_scriptdir%/noter/O12.PNG      ;create "B2" note
gui, add, picture, x+0 gc3, %a_scriptdir%/noter/O1.PNG      ;create "C3" note
gui, add, picture, x+0 gdb3, %a_scriptdir%/noter/O2.PNG      ;create "Db3" note
gui, add, picture, x+0 gd3, %a_scriptdir%/noter/O3.PNG      ;create "D3" note
gui, add, picture, x+0 geb3, %a_scriptdir%/noter/O4.PNG      ;create "Eb3" note
gui, add, picture, x+0 ge3, %a_scriptdir%/noter/O5.PNG      ;create "E3" note
gui, add, picture, x+0 gf3, %a_scriptdir%/noter/O6.PNG      ;create "F3" note
gui, add, picture, x+0 ggb3, %a_scriptdir%/noter/O7.PNG      ;create "Gb3" note
gui, add, picture, x+0 gg3, %a_scriptdir%/noter/O8.PNG      ;create "G3" note
gui, add, picture, x+0 gab3, %a_scriptdir%/noter/O9.PNG      ;create "Ab3" note
gui, add, picture, x+0 ga3, %a_scriptdir%/noter/O10.PNG      ;create "A3" note
gui, add, picture, x+0 gbb3, %a_scriptdir%/noter/O11.PNG   ;create "Bb3" note
gui, add, picture, x+0 gb3, %a_scriptdir%/noter/O12.PNG      ;create "B3" note
gui, add, picture, x+0 gc4, %a_scriptdir%/noter/O1.PNG      ;create "C4" note
gui, add, picture, x+0 gdb4, %a_scriptdir%/noter/O2.PNG      ;create "Db4" note
gui, add, picture, x+0 gd4, %a_scriptdir%/noter/O3.PNG      ;create "D4" note
gui, add, picture, x+0 geb4, %a_scriptdir%/noter/O4.PNG      ;create "Eb4" note
gui, add, picture, x+0 ge4, %a_scriptdir%/noter/O5.PNG      ;create "E4" note
gui, add, picture, x+0 gf4, %a_scriptdir%/noter/O6.PNG      ;create "F4" note
gui, add, picture, x+0 ggb4, %a_scriptdir%/noter/O7.PNG      ;create "Gb4" note
gui, add, picture, x+0 gg4, %a_scriptdir%/noter/O8.PNG      ;create "G4" note
gui, add, picture, x+0 gab4, %a_scriptdir%/noter/O9.PNG      ;create "Ab4" note
gui, add, picture, x+0 ga4, %a_scriptdir%/noter/O10.PNG      ;create "A4" note
gui, add, picture, x+0 gbb4, %a_scriptdir%/noter/O11.PNG   ;create "Bb4" note
gui, add, picture, x+0 gb4, %a_scriptdir%/noter/O12.PNG      ;create "B4" note


gui, add, picture, xm+0 y+0 gc1, %a_scriptdir%/noter/nf.PNG      ;add to "C1" note
gui, add, picture, x+0 gd1, %a_scriptdir%/noter/n.PNG      ;add to "D1" note
gui, add, picture, x+0 ge1, %a_scriptdir%/noter/n.PNG      ;add to "E1" note
gui, add, picture, x+0 gf1, %a_scriptdir%/noter/n.PNG      ;add to "F1" note
gui, add, picture, x+0 gg1, %a_scriptdir%/noter/n.PNG      ;add to "G1" note
gui, add, picture, x+0 ga1, %a_scriptdir%/noter/n.PNG      ;add to "A1" note
gui, add, picture, x+0 gb1, %a_scriptdir%/noter/n.PNG      ;add to "B2" note
gui, add, picture, x+0 gc2, %a_scriptdir%/noter/nf.PNG      ;add to "C2" note
gui, add, picture, x+0 gd2, %a_scriptdir%/noter/n.PNG      ;add to "D2" note
gui, add, picture, x+0 ge2, %a_scriptdir%/noter/n.PNG      ;add to "E2" note
gui, add, picture, x+0 gf2, %a_scriptdir%/noter/n.PNG      ;add to "F2" note
gui, add, picture, x+0 gg2, %a_scriptdir%/noter/n.PNG      ;add to "G2" note
gui, add, picture, x+0 ga2, %a_scriptdir%/noter/n.PNG      ;add to "A2" note
gui, add, picture, x+0 gb2, %a_scriptdir%/noter/n.PNG      ;add to "B2" note
gui, add, picture, x+0 gc3, %a_scriptdir%/noter/nf.PNG      ;add to "C2" note
gui, add, picture, x+0 gd3, %a_scriptdir%/noter/n.PNG      ;add to "D3" note
gui, add, picture, x+0 ge3, %a_scriptdir%/noter/n.PNG      ;add to "E3" note
gui, add, picture, x+0 gf3, %a_scriptdir%/noter/n.PNG      ;add to "F3" note
gui, add, picture, x+0 gg3, %a_scriptdir%/noter/n.PNG      ;add to "G3" note
gui, add, picture, x+0 ga3, %a_scriptdir%/noter/n.PNG      ;add to "A3" note
gui, add, picture, x+0 gb3, %a_scriptdir%/noter/n.PNG      ;add to "B3" note
gui, add, picture, x+0 gc4, %a_scriptdir%/noter/nf.PNG      ;add to "C4" note
gui, add, picture, x+0 gd4, %a_scriptdir%/noter/n.PNG      ;add to "D4" note
gui, add, picture, x+0 ge4, %a_scriptdir%/noter/n.PNG      ;add to "E3" note
gui, add, picture, x+0 gf4, %a_scriptdir%/noter/n.PNG      ;add to "F4" note
gui, add, picture, x+0 gg4, %a_scriptdir%/noter/n.PNG      ;add to "G4" note
gui, add, picture, x+0 ga4, %a_scriptdir%/noter/n.PNG      ;add to "A4" note
gui, add, picture, x+0 gb4, %a_scriptdir%/noter/n.PNG      ;add to "B4" note
gui, add, text, xm+0 y+0 w30, Duration      ;create "Duration" text
gui, add, slider, x+10 vtid range1-500, 250    ;create "Duration" slider

gui, show
return


guiclose:      ;guiclose
exitapp

spel:
guicontrolget, tid      ;get "Note Duration" from slider
soundbeep, %frec%, %tid%      ;play note
return




c1:
frec = 131      ; set new frequency
goto, spel

db1:
frec = 139      ; set new frequency
goto, spel

d1:
frec = 147      ; set new frequency
goto, spel

eb1:
frec = 155      ; set new frequency
goto, spel

e1:
frec = 165      ; set new frequency
goto, spel

f1:
frec = 175      ; set new frequency
goto, spel

gb1:
frec = 185      ; set new frequency
goto, spel

g1:
frec = 196      ; set new frequency
goto, spel

ab1:
frec = 208      ; set new frequency
goto, spel

a1:
frec = 220      ; set new frequency
goto, spel

bb1:
frec = 233      ; set new frequency
goto, spel

b1:
frec = 247      ; set new frequency
goto, spel

c2:
frec = 262      ; set new frequency
goto, spel

db2:
frec = 277      ; set new frequency
goto, spel

d2:
frec = 294      ; set new frequency
goto, spel

eb2:
frec = 311      ; set new frequency
goto, spel

e2:
frec = 330      ; set new frequency
goto, spel

f2:
frec = 349      ; set new frequency
goto, spel

gb2:
frec = 370      ; set new frequency
goto, spel

g2:
frec = 392      ; set new frequency
goto, spel

ab2:
frec = 415      ; set new frequency
goto, spel

a2:
frec = 440      ; set new frequency
goto, spel

bb2:
frec = 466      ; set new frequency
goto, spel

b2:
frec = 494      ; set new frequency
goto, spel

c3:
frec = 523      ; set new frequency
goto, spel

db3:
frec = 554      ; set new frequency
goto, spel

d3:
frec = 587      ; set new frequency
goto, spel

eb3:
frec = 622      ; set new frequency
goto, spel

e3:
frec = 659      ; set new frequency
goto, spel

f3:
frec = 698      ; set new frequency
goto, spel

gb3:
frec = 740      ; set new frequency
goto, spel

g3:
frec = 784      ; set new frequency
goto, spel

ab3:
frec = 831      ; set new frequency
goto, spel

a3:
frec = 880      ; set new frequency
goto, spel

bb3:
frec = 932      ; set new frequency
goto, spel

b3:
frec = 987      ; set new frequency
goto, spel

c4:
frec = 1046      ; set new frequency
goto, spel

db4:
frec = 1109      ; set new frequency
goto, spel

d4:
frec = 1175      ; set new frequency
goto, spel

eb4:
frec = 1244      ; set new frequency
goto, spel

e4:
frec = 1318      ; set new frequency
goto, spel

f4:
frec = 1397      ; set new frequency
goto, spel

gb4:
frec = 1480      ; set new frequency
goto, spel

g4:
frec = 1568      ; set new frequency
goto, spel

ab4:
frec = 1661      ; set new frequency
goto, spel

a4:
frec = 1760      ; set new frequency
goto, spel

bb4:
frec = 1865      ; set new frequency
goto, spel

b4:
frec = 1975      ; set new frequency
goto, spel

_________________
-._.-¨¯¨-._.-IM@PΩW-._.-¨¯¨-._.-
Back to top
View user's profile Send private message
socoop
Guest





PostPosted: Sun Mar 30, 2008 12:05 pm    Post subject: Re: OnScreenPiano Reply with quote

What a coincidence!
Try this:
SoundBeep, % 2 ** ((A_GuiControl - 11) / 12) * 440



http://pds8.egloos.com/pds/200803/30/47/piano.zip

Code:

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force

WhiteKey = white.gif
BlackKey = black.gif
v_width = 45

Gui, Margin, 0
Gui, Add, Picture, % " y0 x" v_width * 2 / 3 " v1 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 5 / 3 " v3 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 11 / 3 " v6 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 14 / 3 " v8 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 17 / 3 " v10 gPlay", %BlackKey%

Gui, Add, Picture, % " y0 x" v_width * 23 / 3 " v13 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 26 / 3 " v15 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 32 / 3 " v18 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 35 / 3 " v20 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 38 / 3 " v22 gPlay", %BlackKey%

Gui, Add, Picture, % " y0 x" v_width * 44 / 3 " v25 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 47 / 3 " v27 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 53 / 3 " v30 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 56 / 3 " v32 gPlay", %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 59 / 3 " v34 gPlay", %BlackKey%

Gui, Add, Picture, % " y0 x" v_width * 0 " v0 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 1 " v2 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 2 " v4 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 3 " v5 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 4 " v7 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 5 " v9 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 6 " v11 gPlay", %WhiteKey%

Gui, Add, Picture, % " y0 x" v_width * 7 " v12 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 8 " v14 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 9 " v16 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 10 " v17 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 11 " v19 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 12 " v21 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 13 " v23 gPlay", %WhiteKey%

Gui, Add, Picture, % " y0 x" v_width * 14 " v24 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 15 " v26 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 16 " v28 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 17 " v29 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 18 " v31 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 19 " v33 gPlay", %WhiteKey%
Gui, Add, Picture, % " y0 x" v_width * 20 " v35 gPlay", %WhiteKey%

Gui, Add, Picture, % " y0 x" v_width * 2 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 5 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 11 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 14 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 17 / 3, %BlackKey%

Gui, Add, Picture, % " y0 x" v_width * 23 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 26 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 32 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 35 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 38 / 3, %BlackKey%

Gui, Add, Picture, % " y0 x" v_width * 44 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 47 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 53 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 56 / 3, %BlackKey%
Gui, Add, Picture, % " y0 x" v_width * 59 / 3, %BlackKey%

Gui, Show, h200, 마늘아빠 피아노
Play:
   SoundBeep, % 2 ** ((A_GuiControl - 11) / 12) * 440
Return
Back to top
BoBo¨
Guest





PostPosted: Sun Mar 30, 2008 12:16 pm    Post subject: Reply with quote

Hey folks, thanks for sharing this.
Btw. what means this: 마늘아빠 피아노 Question
(It's better to know what you get tattooed, right? Wink)
Back to top
socoop
Guest





PostPosted: Sun Mar 30, 2008 1:31 pm    Post subject: Nice to hear from you Reply with quote

Glad that you are interested in this script.

마늘아빠 is a proper noun, referring to me.
피아노 is piano in Korean.
Back to top
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Mar 30, 2008 2:17 pm    Post subject: Reply with quote

You could use the Windows' Midi interface, for much nicer sound. See here.
Back to top
View user's profile Send private message
imapow



Joined: 13 Mar 2008
Posts: 155
Location: Trøndelag, Norway

PostPosted: Sun Mar 30, 2008 11:28 pm    Post subject: Reply with quote

im creating a 1.2 versjon were i'm gonna use ".wav" files to simulate different piano types. piano, orgel, flygel and so on but im hawing a hard time finding propper sound files.
_________________
-._.-¨¯¨-._.-IM@PΩW-._.-¨¯¨-._.-
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Mar 30, 2008 11:39 pm    Post subject: Reply with quote

With Midi you can have hundreds of instruments without external files. The sound of a key can still be playing, while you hit another key. It requires less than 50 lines of AHK code, so it is better than wave files.
Back to top
View user's profile Send private message
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Tue Apr 01, 2008 6:28 am    Post subject: NICE! Reply with quote

have always want to do this, and now its done Evil or Very Mad
anyway no i don't have to do it Razz
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Imapow (guest)
Guest





PostPosted: Tue Apr 01, 2008 9:48 am    Post subject: Reply with quote

Quote:
have always want to do this, and now its done.
anyway no i don't have to do it.


yes you do.
my program is just pictures and beebsouds, not close to what a good programer can do.

so use my cript as a building frame, and build a good playing mashin behind it.
Back to top
menaphus



Joined: 28 Nov 2008
Posts: 111
Location: United Kingdom

PostPosted: Sat Nov 29, 2008 8:07 pm    Post subject: Cool Reply with quote

Great idea , i'd like to propose hotkeys for the piano keys.
For instance

Q= c note
W= C sharp note
E= D note
R= D sharp note
T= E note

and so on

except maby using the bottom row of keys for lower and top as higher
this way the notes would be slightly faster to access and you wouldnt need to scroll side to side manualy to use more notes, on a related matter you could add more notes and have an automated scroller which moves the onscreen keyboard so the note you press is always centered + have the keyboard keys displayed ont he onscreen keys

Just a few ideas i'd like to share , hope some of them help or inspire you Very Happy
_________________
Adam
http://moourl.com/8w0tx
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 2212
Location: switzerland

PostPosted: Sat Nov 29, 2008 9:59 pm    Post subject: Reply with quote

very nice...
here a cat piano

Back to top
View user's profile Send private message
iason



Joined: 01 Nov 2005
Posts: 135

PostPosted: Sun Nov 30, 2008 4:13 am    Post subject: Reply with quote

garry wrote:
very nice...
here a cat piano

What about a Tasmanian Devil piano. Wow. Laughing
_________________
help to be helped
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2212
Location: switzerland

PostPosted: Sun Nov 30, 2008 9:05 am    Post subject: Reply with quote

didn't found a picture Tasmanian devil piano....
just a picture (2nd) ...
http://www.autohotkey.net/~garry/20081130_TasmaniaCat.png
Back to top
View user's profile Send private message
iason



Joined: 01 Nov 2005
Posts: 135

PostPosted: Sun Nov 30, 2008 5:33 pm    Post subject: Reply with quote

Roles were now switched? Do those cats play Human Piano? I can't see the whole instrument. Laughing
_________________
help to be helped
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Jan 08, 2010 5:33 pm    Post subject: Reply with quote

Lovely, I like this kind of simple scripts. Especially when the source code is provided, that way I pick up some knowlegde everytime.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group