Forum: Ruby Making my internal speaker beep

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matt R. (Guest)
on 2006-02-20 20:16
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
James B. (Guest)
on 2006-02-20 20:22
(Received via mailing list)
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
Matt R. (Guest)
on 2006-02-20 20:24
Thanks for the quick response.

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



Thanks again :)
Matthew M. (Guest)
on 2006-02-20 20:25
(Received via mailing list)
puts "\007"
William J. (Guest)
on 2006-02-21 01:00
(Received via mailing list)
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/.

print "\a"
unknown (Guest)
on 2006-02-21 01:09
(Received via mailing list)
Quoting William J. <removed_email_address@domain.invalid>:

> print "\a"

mnemonic: "a" is for audiable

-mental
William J. (Guest)
on 2006-02-21 02:04
(Received via mailing list)
removed_email_address@domain.invalid wrote:
> Quoting William J. <removed_email_address@domain.invalid>:
>
> > print "\a"
>
> mnemonic: "a" is for audiable
>
> -mental

Or perhaps for "alert".
This also works in awk.
This topic is locked and can not be replied to.