mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added a sound api.
This commit is contained in:
parent
55e9d358cf
commit
4c1cb806ba
6 changed files with 96 additions and 3 deletions
|
@ -44,7 +44,7 @@ c/h/stdio.h
|
|||
|
||||
COMMONOBJS=c++.o thread.o io.o memory.o string.o error.o format.o
|
||||
SORTIXOBJS:=$(addprefix sortix/,$(COMMONOBJS))
|
||||
LIBMAXSIOBJS:=$(COMMONOBJS) sortix-vga.o sortix-keyboard.o
|
||||
LIBMAXSIOBJS:=$(COMMONOBJS) sortix-vga.o sortix-keyboard.o sortix-sound.o
|
||||
HEADERS=\
|
||||
error.h \
|
||||
io.h \
|
||||
|
@ -57,7 +57,8 @@ types.h \
|
|||
format.h \
|
||||
keyboard.h \
|
||||
sortix-vga.h \
|
||||
sortix-keyboard.h
|
||||
sortix-keyboard.h \
|
||||
sortix-sound.h \
|
||||
|
||||
OBJS:=$(LIBMAXSIOBJS)
|
||||
BINS:=libmaxsi.so
|
||||
|
|
39
libmaxsi/hsrc/sortix-sound.h
Normal file
39
libmaxsi/hsrc/sortix-sound.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
||||
|
||||
This file is part of LibMaxsi.
|
||||
|
||||
LibMaxsi is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with LibMaxsi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
sortix-sound.cpp
|
||||
Provides access to the sound devices. This is highly unportable and is very
|
||||
likely to be removed or changed radically.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LIBMAXSI_SORTIX_SOUND_H
|
||||
#define LIBMAXSI_SORTIX_SOUND_H
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Sound
|
||||
{
|
||||
// Sets the desired sound frequency on the current sound device. This is
|
||||
// rather crude. A frequency of 0 disables the sound output.
|
||||
void SetFrequency(unsigned frequency);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
42
libmaxsi/sortix-sound.cpp
Normal file
42
libmaxsi/sortix-sound.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
||||
|
||||
This file is part of LibMaxsi.
|
||||
|
||||
LibMaxsi is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with LibMaxsi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
sortix-sound.cpp
|
||||
Provides access to the sound devices. This is highly unportable and is very
|
||||
likely to be removed or changed radically.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include "syscall.h"
|
||||
#include "sortix-sound.h"
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Sound
|
||||
{
|
||||
DEFN_SYSCALL1_VOID(SysSetFrequency, 9, unsigned);
|
||||
|
||||
void SetFrequency(unsigned frequency)
|
||||
{
|
||||
SysSetFrequency(frequency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,8 @@ namespace Sortix
|
|||
|
||||
void Play(nat Frequency)
|
||||
{
|
||||
Log::PrintF("Playing frequency %u\n", Frequency);
|
||||
|
||||
//Set the PIT to the desired frequency
|
||||
uint32_t Div = 1193180 / Frequency;
|
||||
CPU::OutPortB(0x43, 0xB6);
|
||||
|
@ -52,6 +54,12 @@ namespace Sortix
|
|||
CPU::OutPortB(0x61, TMP | 3);
|
||||
}
|
||||
}
|
||||
|
||||
void SysSetFrequency(CPU::InterruptRegisters* R)
|
||||
{
|
||||
unsigned frequency = R->ebx;
|
||||
if ( frequency == 0 ) { Mute(); } else { Play(frequency); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Sortix
|
|||
{
|
||||
void Mute();
|
||||
void Play(nat Frequency);
|
||||
void SysSetFrequency(CPU::InterruptRegisters* R);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "panic.h"
|
||||
#include "vga.h"
|
||||
#include "keyboard.h"
|
||||
#include "sound.h"
|
||||
|
||||
namespace Sortix
|
||||
{
|
||||
|
@ -49,7 +50,7 @@ namespace Sortix
|
|||
#endif
|
||||
}
|
||||
|
||||
const size_t NumSyscalls = 9;
|
||||
const size_t NumSyscalls = 10;
|
||||
const Syscall Syscalls[NumSyscalls] =
|
||||
{
|
||||
&Scheduler::SysCreateThread,
|
||||
|
@ -61,6 +62,7 @@ namespace Sortix
|
|||
&VGA::SysChangeFrame,
|
||||
&VGA::SysDeleteFrame,
|
||||
&Keyboard::SysReceieveKeystroke,
|
||||
&Sound::SysSetFrequency,
|
||||
};
|
||||
|
||||
void Init()
|
||||
|
|
Loading…
Add table
Reference in a new issue