RaymondBerg.com

I had something fun planned for tonight, but WordPress ate it. You just get the raw bits now.

Basically, use this (amazingly short bit of python code) to wreak havoc on your mate’s computer.

'''
Created on Mar 20, 2010
@author: Raymond
'''
import win32api
import threading
class Beep(threading.Thread):
def __init__(self,frequency,duration):
threading.Thread.__init__(self)
self.frequency = frequency
self.duration = duration
def run(self):
win32api.Beep(self.frequency,self.duration)
for a in range(0,200):
a = Beep(a*20,1000)
a.start()
a.join()

And no, I’m not even white-spacing it for you.

Here’s a fun mp3 (if you’re lazy) with picture of the audacity output. See, no volume change! Only frequency. I love science.

And the exe if you’re lazy and you don’t like to practice safe-computing.

Posted on April 4th, 2010 | filed under Uncategorized | Trackback |

4 Comments

  1. Anthony:

    Hang on a sec…

    win32api

    :(

  2. rwb:

    Let me know when you find a way to invoke PC beeps across platforms without code reworks :D . I’ll rewrite ASAP.

    Until then, use a real operating system.

  3. Anthony Hook:

    Well, you just simply print \a to the terminal when you want sound as it will produce the terminal bell sound. As far as changing frequencies and stuff, I did find one way to make this happen:


    def beep(frequency, amplitude, duration):
    sample = 8000
    half_period = int(sample/frequency/2)
    beep = chr(amplitude)*half_period+chr(0)*half_period
    beep *= int(duration*frequency)
    audio = file('/dev/audio', 'wb')
    audio.write(beep)
    audio.close()

    // and call it with:
    beep(440, 63, 1)

  4. rwb:

    Excellent, thanks for the Linux approach. And look, you didn’t even need a library. I love /dev/audio .

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    follow me on Twitter