EvilZone

Community => General discussion => Topic started by: techb on December 25, 2012, 01:07:29 AM

Title: Merry Happy ChristmaHunauKwanzika
Post by: techb on December 25, 2012, 01:07:29 AM
Love you guys, Windows only though. I'm sure it will be a fun little challenge to port this to Linux for those who want to =). (Yes I see you Kulver and RedBull).

Python 2.6
Code: (Python) [Select]
#Quick geek/nerd Christmas from le Tech B.
#There is at lest zip() that shows working with 2 iterables and a windows only method

import winsound, time, os

note_trans = {"C":2441, "D":2741, "E":3048, "F":3255, "G":3654, "A":4058, "B":4562}
len_trans = {1:100, 2:200, 4:400}

song = ("E", "E", "E", "E", "E", "E", "E", "G", "C", "D", "E", "F", "F", "F", "F",
        "F", "E", "E", "E", "E", "D", "D", "E", "D", "G")
       
length = (1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2)

os.system("color 02")
print "Have a programmers Christmas!!!"

for n,l in zip(song,length):
    time.sleep(.3)
    winsound.Beep(note_trans[n], len_trans[l])

print "I love you EZ, and all who see this.\nKeep being awesome people."
Title: Re: Merry Happy ChristmaHunauKwanzika
Post by: Kulverstukas on December 25, 2012, 09:47:18 AM
AHAHAHA you made me laugh man :D very nice song script :)
Title: Re: Merry Happy ChristmaHunauKwanzika
Post by: RedBullAddicted on December 25, 2012, 10:35:12 AM
Hi,

marry christmas to you, too mate :) I don't know why but none of my machines want to play it. Theoretical it should be possible to make it run on linux by installing beep (debian apt-get install beep) and run it in python with os.system e.g.

Code: (python) [Select]
winsound.Beep(note_trans[n], len_trans[l])
replaced with:

Code: (python) [Select]
os.system('beep -f %s -l %s' % (note_trans[n],len_trans[l]))
the color command is a bit more complicated as you need to write it to bash.rc. To keep it simple I would just remove the line :)
Maybe someone can try it ... really don't know why my machines won't play it. I looked through the bios settings and when I unplug the power cord a sound is played ???

I know this is not the best way but it was the only thing my hangover brain was able to do so please don't flame me.