Added lib/cmixer and new audio system

This commit is contained in:
rxi
2017-05-06 08:53:59 +01:00
parent 834f78a0e0
commit c096249beb
7 changed files with 1002 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
#include <dos.h>
#include "lib/dmt/dmt.h"
#include "lib/cmixer/cmixer.h"
#include "vga.h"
#include "luaobj.h"
#include "keyboard.h"
@@ -46,6 +47,22 @@ static int onLuaPanic(lua_State *L) {
}
static short audioBuffer[SOUNDBLASTER_SAMPLES_PER_BUFFER * 2];
static const short* audioCallback(void) {
/* For the moment the soundblaster code expects mono audio while the cmixer
** library outputs stereo -- we process to a stereo buffer, then copy the left
** channel to the start of the buffer */
int i;
int len = SOUNDBLASTER_SAMPLES_PER_BUFFER;
cm_process(audioBuffer, len * 2);
for (i = 0; i < len; i++) {
audioBuffer[i] = audioBuffer[i * 2];
}
return audioBuffer;
}
int luaopen_love(lua_State *L);
int main(int argc, char **argv) {
@@ -57,7 +74,8 @@ int main(int argc, char **argv) {
/* Init everything */
atexit(deinit);
// soundblaster_init(mixer_getNextBlock);
cm_init(soundblaster_getSampleRate());
soundblaster_init(audioCallback);
vga_init();
palette_init();
keyboard_init();