Fixed anim2d bug; fixed sound bug; free oneshots now

This commit is contained in:
2023-01-16 19:20:07 +00:00
parent 01256542b6
commit 4ee6e1683b
8 changed files with 48 additions and 90 deletions

View File

@@ -2,9 +2,9 @@
#define DSP_H
#define SAMPLERATE 48000
#define BUF_FRAMES 4096
#define BUF_FRAMES 128 /* At 48k, 128 needed for 240fps consistency */
#define CHANNELS 2
#define MUSIZE 2
#include "circbuf.h"

View File

@@ -12,6 +12,8 @@ static int first = 0; /* First bus available */
static int first_on = -1; /* First bus to fill buffer with */
short mastermix[BUF_FRAMES*CHANNELS];
static int initted = 0;
void mixer_init() {
for (int i = 0; i < 256; i++) {
bus[i].next = i+1;
@@ -20,9 +22,16 @@ void mixer_init() {
}
bus[255].next = -1;
initted = 1;
}
struct bus *first_free_bus(struct dsp_filter in) {
if (!initted) {
YughError("Tried to use a mixing bus without calling mixer_init().");
return NULL;
}
if (first == -1) return NULL;
int ret = first;
first = bus[ret].next;

View File

@@ -52,7 +52,7 @@ void dsp_midi_fillbuf(struct dsp_midi_song *song, void *out, int n)
tsf_render_short(song->sf, o, TSF_BLOCK, 0);
o += TSF_BLOCK*2;
o += TSF_BLOCK*CHANNELS;
song->time += TSF_BLOCK * (1000.f/SAMPLERATE);
}