title:Linux PC speaker
keywords:pc,linux,speaker,c
# Linux PC speaker
PC speaker can make sound you whant. Here is small PC speaker player.
Set notes , set time delay and you on. You should run this code under
root if nothing happens.
```c
int main()
{
int rc,i;
note *curent_song;
curent_song = song;
struct timespec t1;
rc = syscall(SYS_open,"/dev/console",O_WRONLY,7*8*64+7*8+7); //open cosole
if (rc == 0)
rc = 1;
ioctl( rc, KIOCSOUND , 0 );
ioctl( rc , KDSETLED , 7 );
i = 0;
while ( curent_song[i].n != 0 )
{
ioctl( rc , KIOCSOUND , curent_song[i].n );
msleep( (curent_song[i].t) );
ioctl( rc , KDSETLED , i&0x0007 );
i++;
}
ioctl( rc , KDSETLED , 0 );
ioctl( rc, KIOCSOUND , 0 );
return 0;
}
```
## Downloads
linux_pc_speaker.zip -
5KiB - http://archive.main.lv/files/writeup/linux_pc_speaker/linux_pc_speaker.zip