diff options
author | Marvin Borner | 2019-09-16 19:44:04 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-16 19:47:23 +0200 |
commit | f1e62229ca1ce4d7768268724204772049341282 (patch) | |
tree | 624ef3b73c855d55f4472c14725898796a3e89e5 /src/sound | |
parent | e7834a6bc1715faaca4b60e86609f8b62598814a (diff) |
Added basic frequency sound generator
Changes to be committed:
new file: src/graphics/graphics.h
modified: src/kernel.c
new file: src/sound/frequency.c
new file: src/sound/sound.h
modified: build.sh
Changes not staged for commit:
deleted: src/graphics/vga.h
modified: src/input/ps2/keyboard.c
modified: src/input/ps2/mouse.c
modified: src/interrupts/irq.c
modified: src/interrupts/isr.c
modified: src/memory/memory.c
Diffstat (limited to 'src/sound')
-rw-r--r-- | src/sound/frequency.c | 32 | ||||
-rw-r--r-- | src/sound/sound.h | 6 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/sound/frequency.c b/src/sound/frequency.c new file mode 100644 index 0000000..e5e831c --- /dev/null +++ b/src/sound/frequency.c @@ -0,0 +1,32 @@ +#include <stdint.h> +#include "../io/io.h" +#include "../timer/timer.h" + +static void play_sound(uint32_t frequency) { + uint32_t divided; + uint8_t tmp; + + divided = 1193180 / frequency; + send(0x43, 0xb6); + send(0x42, (uint8_t) (divided)); + send(0x42, (uint8_t) (divided >> 8)); + + //And play the sound using the PC speaker + tmp = receive(0x61); + if (tmp != (tmp | 3)) { + send(0x61, tmp | 3); + } +} + +static void shut_up() { + uint8_t tmp = receive(0x61) & 0xFC; + + send(0x61, tmp); +} + +//Make a beep +void beep() { + play_sound(1000); + timer_wait(100); + shut_up(); +}
\ No newline at end of file diff --git a/src/sound/sound.h b/src/sound/sound.h new file mode 100644 index 0000000..f8692ea --- /dev/null +++ b/src/sound/sound.h @@ -0,0 +1,6 @@ +#ifndef MELVIX_SOUND_H +#define MELVIX_SOUND_H + +void beep(); + +#endif |