linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Bryan <icemanind@yahoo.com>
To: linux-c-programming@vger.kernel.org
Subject: Speaker Sound
Date: Fri, 10 Mar 2006 11:33:29 -0800 (PST)	[thread overview]
Message-ID: <20060310193329.726.qmail@web51414.mail.yahoo.com> (raw)

Can someone tell me how, in linux, I could get a tone
from the PC Speaker. In DOS or Windows, I would use
something like the following code:

void Sound(int, int);

main ()
{
    Sound(1000, 100);
}

void Sound(int hertz, int duration)
{
     unsigned divisor = 1193180L / hertz;
     int portval;
     
     portval = inb( 0x61 );
     portval |= 0x03;
     outb( 0x61, portval );
     outb( 0x43, 0xB6 );
     outb( 0x42, divisor & 0xFF ) ;
     outb( 0x42, divisor >> 8 ) ; 
     sleep(duration);
     portval = inb( 0x61 );
     portval &= 0x03;
     outb( 0x61, portval );
     return;
}

The problem is, I'm not sure if I can just read and
output bytes from a port. Any alternate way would be
appreciated!

Thanks


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

             reply	other threads:[~2006-03-10 19:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-10 19:33 Alan Bryan [this message]
2006-03-11  1:32 ` Speaker Sound Progga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060310193329.726.qmail@web51414.mail.yahoo.com \
    --to=icemanind@yahoo.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).