# Making my internal speaker beep

**URL:** <https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019>\
**Category:** Ruby\
**Created:** [February 20, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019 "2006-02-20T19:16:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 20, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/1 "2006-02-20T19:16:00Z")

</div>

Hello. I’m trying to execute a beep on my computer with ruby as an  
alert, but I can’t seem to get it to work.

I’ve looked online and I have this.

require “Win32API”  
def beep  
o = Win32API.new(“kernel32”,“Beep”,%w(i i) , ‘v’)  
o.call(2000,50)  
end

It seems to be calling the API exactly how I need, but it won’t execute  
the beep. Any tips/ideas?

Thanks,  
Matt

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 20, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/2 "2006-02-20T19:22:17Z")

</div>

Matt R. wrote:

> Hello. I’m trying to execute a beep on my computer with ruby as an  
> alert, but I can’t seem to get it to work.

This works for me on Win2k

def beep  
puts “\C-G”  
puts “\C-G”  
sleep(1)  
puts “\C-G”  
puts “\C-G”  
end

–  
James B.

“You harmonize; then you customize.”

- Wilson Pickett

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 20, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/3 "2006-02-20T19:24:17Z")

</div>

Thanks for the quick response.

What is the C-G? Is there a way to change the frequency?

Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 21, 2006, 12:00am UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/4 "2006-02-21T00:00:31Z")

</div>

Matt R. wrote:

> It seems to be calling the API exactly how I need, but it won’t execute  
> the beep. Any tips/ideas?
> 
> Thanks,  
> Matt
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

print “\a”

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 20, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/5 "2006-02-20T19:25:25Z")

</div>

puts “\007”

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 21, 2006, 12:09am UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/6 "2006-02-21T00:09:49Z")

</div>

Quoting William J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> print “\a”

mnemonic: “a” is for audiable

-mental

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [February 21, 2006, 1:04am UTC](https://www.ruby-forum.com/t/making-my-internal-speaker-beep/54019/7 "2006-02-21T01:04:43Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Quoting William J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > print “\a”
> 
> mnemonic: “a” is for audiable
> 
> -mental

Or perhaps for “alert”.  
This also works in awk.
