Added lib/cmixer and new audio system
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user