summaryrefslogtreecommitdiffstats
path: root/md/writeup/linux_pc_speaker.md
blob: 1462c1ce2fb6fe53fcc0dc5b0a1e41998c98ad15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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