sound?

Post questions regarding programming in C/C++ in Linux/Unix.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

sound?

Postby schloob » Fri Mar 03, 2006 8:09 pm

i can't seem to find a decent tutorial on how to produce a note with a given frequency for a given amount of time (like the windows Beep command).. does anyone have any resources? either OSS or ALSA is fine.

or better yet, does anyone read this forum?

thanks
:]
User avatar
schloob
 
Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Postby Jimbo » Sat Mar 04, 2006 12:42 am

I read the forum, but only as a learning resource :P
User avatar
Jimbo
 
Posts: 601
Joined: Thu Sep 25, 2003 6:48 pm
Location: Seattle

Postby Kybo Ren » Sun Mar 05, 2006 4:22 am

From http://www.codecomments.com/archive286- ... 82318.html :
Code: Select all
#include <linux/kd.h>

static void pc_beep(int freq) {
int fd;

/* Try both std and devfs name */
fd = open("/dev/tty1", O_RDWR|O_NONBLOCK);
if (fd < 0) {
fd = open("/dev/vc/1", O_RDWR|O_NONBLOCK);
}
if (fd >= 0) {
ioctl(fd, KDMKTONE, ((75/*ms?*/ << 16) | freq));
}
}
Kybo Ren
C++ Beginner
 
Posts: 2049
Joined: Wed Feb 11, 2004 9:28 pm


Return to Unix/Linux

Who is online

Users browsing this forum: No registered users and 0 guests