AutoHotkey Community

It is currently May 26th, 2012, 4:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: OnScreenPiano
PostPosted: March 16th, 2008, 11:25 pm 
Offline

Joined: March 13th, 2008, 6:37 pm
Posts: 155
Location: Trøndelag, Norway
OnScreenPiano is a simple piano emulator
that use soundbeep frequencyes

Image

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-._.-¨¯¨-._.-


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: OnScreenPiano
PostPosted: March 30th, 2008, 1:05 pm 
What a coincidence!
Try this:
SoundBeep, % 2 ** ((A_GuiControl - 11) / 12) * 440

Image

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2008, 1:16 pm 
Hey folks, thanks for sharing this.
Btw. what means this: 마늘아빠 피아노 :?:
(It's better to know what you get tattooed, right? :wink:)


Report this post
Top
  
Reply with quote  
 Post subject: Nice to hear from you
PostPosted: March 30th, 2008, 2:31 pm 
Glad that you are interested in this script.

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2008, 3:17 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You could use the Windows' Midi interface, for much nicer sound. See here.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 12:28 am 
Offline

Joined: March 13th, 2008, 6:37 pm
Posts: 155
Location: Trøndelag, Norway
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-._.-¨¯¨-._.-


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 12:39 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: NICE!
PostPosted: April 1st, 2008, 7:28 am 
Offline

Joined: April 18th, 2007, 9:03 am
Posts: 127
have always want to do this, and now its done :evil:
anyway no i don't have to do it :P

_________________
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)...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2008, 10:48 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject: Cool
PostPosted: November 29th, 2008, 9:07 pm 
Offline

Joined: November 29th, 2008, 12:35 am
Posts: 111
Location: United Kingdom
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 :D

_________________
Adam
http://moourl.com/8w0tx
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2008, 10:59 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
very nice...
here a cat piano

Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2008, 5:13 am 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
garry wrote:
very nice...
here a cat piano

What about a Tasmanian Devil piano. Wow. :lol:

_________________
help to be helped


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2008, 10:05 am 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
didn't found a picture Tasmanian devil piano....
just a picture (2nd) ...
http://www.autohotkey.net/~garry/200811 ... niaCat.png


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2008, 6:33 pm 
Offline

Joined: November 1st, 2005, 4:44 am
Posts: 135
Roles were now switched? Do those cats play Human Piano? I can't see the whole instrument. :lol:

_________________
help to be helped


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 8th, 2010, 6:33 pm 
Lovely, I like this kind of simple scripts. Especially when the source code is provided, that way I pick up some knowlegde everytime.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group