Albert Hopkins <mar...@letterboxes.org> [10-08-18 04:16]:
> On Tue, 2010-08-17 at 19:41 -0400, Albert Hopkins wrote:
> > Here is my edit of his Python script. 
> 
> ... which I actually forgot to attach :|
> 
> -a
> 

> #!/usr/bin/env python
> ## A tiny, nifty script for playing musical notes on each keypress.
> ##
> ##  Copyright Sayan "Riju" Chakrabarti (sayanriju) 2009
> ##  me[at]sayanriju[dot]co[dot]cc ##
> ##      Released under WTFPL Version 2
> ## (DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE)
> ##  Copy of license text can be found online at ##      
> http://sam.zoy.org/wtfpl/COPYING
> ## http://rants.sayanriju.co.cc/script-to-make-tick-tick-sound-on-keypress
> 
> from Xlib.display import Display
> import subprocess
> import time
> 
> KEYPRESSFILE = 'typewriter-key-1.wav'
> RETURNFILE = 'typewriter-line-break-1.wav'
> 
> notes=[440,494,523,587,659,698,784]
> 
> ZERO,SHIFT,ALT,CTL=[],[],[],[]
> ENTER = [0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>         0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
> for i in range(0,32):
>     ZERO.append(0)
>     if i==6:
>         SHIFT.append(4)
>     else:
>         SHIFT.append(0)
>     if i==4:
>         CTL.append(32)
>     else:
>         CTL.append(0)
>     if i==8:
>         ALT.append(1)
>     else:
>         ALT.append(0)
> 
> ignorelist=[ZERO,ALT,SHIFT,CTL]
> 
> def main():
>     disp = Display()    # connect to display
> 
>     while 1:    #event loop
>         keymap = disp.query_keymap()
>         if keymap not in ignorelist:
>             filename = RETURNFILE if keymap == ENTER else KEYPRESSFILE
>             subprocess.Popen(['aplay', filename], stderr=open('/dev/null',
>                 'w'))
>             time.sleep(0.1)
> 
> 
> if __name__ == '__main__':
>     main()

Hi,

 I checked the script -- it works :)
 But it is to slow (my computer is to slow, I am too fast?)
 I can press twice the number of keys which got "sounded" by
 the script.
 Or is something wrong with the setup of my sound interface?
 My computer is a Athlon XP2 64 (32 bit Gentoo) 3800+, so I
 think, that it is not /that/ slow :)
 Any ideas?
 Best regards,
 mcc



Reply via email to