Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a pc speaker beep in c# mono linux. so please tell me how it is possible. in windows we use inpout32.dll or inpout64.dll its working fine but in linux we no idea for pc speaker beep.

What I have tried:

i am new i have tried this code in c but its not working
#include "sound.h"
#include <sys/io.h>
 
int read_timer(unsigned int channel)
{
if (channel >2) return(0xffff);
    outb(channel<<6,0x43); //latch
                           //bit shifting has to do with the sound chip.
    return inb(0x40+channel)+(inb(0x40+channel)<<8);
}
 
void sound(long freq)
{
 freq=DIVISOR(freq);
 
//assumes that the channel has been initialized with a 0xb6

 outb(0xb6,0x43);
 outb( (freq&0xff),0x42);
 outb( ((freq>>8)&0xff),0x42);
}
    
 
void soundoff(void)
{
//Turn Sound port off
 outb(inb(0x61) &~3,0x61);
}
 
void soundon(void)
{
//Turn Sound port on
 outb((inb(0x61)| 3), 0x61);
}

int main (){

soundon();
sound(5555);
sleep(3);
soundoff();
return 0;
};
Posted
Updated 16-Jun-17 2:56am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900