Sound buffer size now configurable.
This commit is contained in:
parent
5788188ce9
commit
6e51e8975e
22 changed files with 92 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ibm.h"
|
#include "ibm.h"
|
||||||
#include "dac.h"
|
#include "dac.h"
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
uint8_t dac,dac2;
|
uint8_t dac,dac2;
|
||||||
uint8_t dacctrl;
|
uint8_t dacctrl;
|
||||||
|
|
@ -43,7 +44,7 @@ void pollss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t dacbuffer[SOUNDBUFLEN+20];
|
int16_t dacbuffer[MAXSOUNDBUFLEN+20];
|
||||||
int dacbufferpos=0;
|
int dacbufferpos=0;
|
||||||
void getdacsamp()
|
void getdacsamp()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -485,8 +485,6 @@ float VGACONST1,VGACONST2;
|
||||||
float RTCCONST;
|
float RTCCONST;
|
||||||
int gated,speakval,speakon;
|
int gated,speakval,speakon;
|
||||||
|
|
||||||
#define SOUNDBUFLEN (48000/20)
|
|
||||||
|
|
||||||
|
|
||||||
/*Sound Blaster*/
|
/*Sound Blaster*/
|
||||||
#define SADLIB 1 /*No DSP*/
|
#define SADLIB 1 /*No DSP*/
|
||||||
|
|
|
||||||
7
src/pc.c
7
src/pc.c
|
|
@ -36,6 +36,7 @@
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "sound_cms.h"
|
#include "sound_cms.h"
|
||||||
|
#include "sound_dbopl.h"
|
||||||
#include "sound_opl.h"
|
#include "sound_opl.h"
|
||||||
#include "sound_sb.h"
|
#include "sound_sb.h"
|
||||||
#include "sound_speaker.h"
|
#include "sound_speaker.h"
|
||||||
|
|
@ -430,6 +431,8 @@ void resetpchard()
|
||||||
ioctl_reset();
|
ioctl_reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sound_update_buf_length();
|
||||||
}
|
}
|
||||||
|
|
||||||
char romsets[17][40]={"IBM PC","IBM XT","Generic Turbo XT","Euro PC","Tandy 1000","Amstrad PC1512","Sinclair PC200","Amstrad PC1640","IBM AT","AMI 286 clone","Dell System 200","Misc 286","IBM AT 386","Misc 386","386 clone","486 clone","486 clone 2"};
|
char romsets[17][40]={"IBM PC","IBM XT","Generic Turbo XT","Euro PC","Tandy 1000","Amstrad PC1512","Sinclair PC200","Amstrad PC1640","IBM AT","AMI 286 clone","Dell System 200","Misc 286","IBM AT 386","Misc 386","386 clone","486 clone","486 clone 2"};
|
||||||
|
|
@ -631,6 +634,8 @@ void loadconfig(char *fn)
|
||||||
window_x = config_get_int(CFG_GLOBAL, NULL, "window_x", 0);
|
window_x = config_get_int(CFG_GLOBAL, NULL, "window_x", 0);
|
||||||
window_y = config_get_int(CFG_GLOBAL, NULL, "window_y", 0);
|
window_y = config_get_int(CFG_GLOBAL, NULL, "window_y", 0);
|
||||||
window_remember = config_get_int(CFG_GLOBAL, NULL, "window_remember", 0);
|
window_remember = config_get_int(CFG_GLOBAL, NULL, "window_remember", 0);
|
||||||
|
|
||||||
|
sound_buf_len = config_get_int(CFG_GLOBAL, NULL, "sound_buf_len", 200);
|
||||||
|
|
||||||
GAMEBLASTER = config_get_int(CFG_MACHINE, NULL, "gameblaster", 0);
|
GAMEBLASTER = config_get_int(CFG_MACHINE, NULL, "gameblaster", 0);
|
||||||
GUS = config_get_int(CFG_MACHINE, NULL, "gus", 0);
|
GUS = config_get_int(CFG_MACHINE, NULL, "gus", 0);
|
||||||
|
|
@ -781,6 +786,8 @@ void saveconfig(char *fn)
|
||||||
config_set_int(CFG_GLOBAL, NULL, "window_x", window_x);
|
config_set_int(CFG_GLOBAL, NULL, "window_x", window_x);
|
||||||
config_set_int(CFG_GLOBAL, NULL, "window_y", window_y);
|
config_set_int(CFG_GLOBAL, NULL, "window_y", window_y);
|
||||||
config_set_int(CFG_GLOBAL, NULL, "window_remember", window_remember);
|
config_set_int(CFG_GLOBAL, NULL, "window_remember", window_remember);
|
||||||
|
|
||||||
|
config_set_int(CFG_GLOBAL, NULL, "sound_buf_len", sound_buf_len);
|
||||||
|
|
||||||
config_set_int(CFG_MACHINE, NULL, "gameblaster", GAMEBLASTER);
|
config_set_int(CFG_MACHINE, NULL, "gameblaster", GAMEBLASTER);
|
||||||
config_set_int(CFG_MACHINE, NULL, "gus", GUS);
|
config_set_int(CFG_MACHINE, NULL, "gus", GUS);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,15 @@ BEGIN
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Disc activity indicator", IDM_VID_DISC
|
MENUITEM "Disc activity indicator", IDM_VID_DISC
|
||||||
END
|
END
|
||||||
|
POPUP "&Sound"
|
||||||
|
BEGIN
|
||||||
|
POPUP "&Buffer length"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&100ms", IDM_BUF_100MS
|
||||||
|
MENUITEM "&200ms", IDM_BUF_200MS
|
||||||
|
MENUITEM "&400ms", IDM_BUF_400MS
|
||||||
|
END
|
||||||
|
END
|
||||||
END
|
END
|
||||||
POPUP "&Misc"
|
POPUP "&Misc"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@
|
||||||
#define IDM_VID_FS_43 40072
|
#define IDM_VID_FS_43 40072
|
||||||
#define IDM_VID_FS_SQ 40073
|
#define IDM_VID_FS_SQ 40073
|
||||||
#define IDM_VID_FS_INT 40074
|
#define IDM_VID_FS_INT 40074
|
||||||
|
#define IDM_BUF_100MS 40080
|
||||||
|
#define IDM_BUF_200MS 40081
|
||||||
|
#define IDM_BUF_400MS 40082
|
||||||
#define IDM_CDROM_EMPTY 40100
|
#define IDM_CDROM_EMPTY 40100
|
||||||
#define IDM_CDROM_REAL 40100
|
#define IDM_CDROM_REAL 40100
|
||||||
#define IDM_CDROM_DISABLED 40200
|
#define IDM_CDROM_DISABLED 40200
|
||||||
|
|
|
||||||
31
src/sound.c
31
src/sound.c
|
|
@ -120,7 +120,18 @@ static int16_t cd_buffer[CD_BUFLEN * 2];
|
||||||
static thread_t *sound_cd_thread_h;
|
static thread_t *sound_cd_thread_h;
|
||||||
static event_t *sound_cd_event;
|
static event_t *sound_cd_event;
|
||||||
static unsigned int cd_vol_l, cd_vol_r;
|
static unsigned int cd_vol_l, cd_vol_r;
|
||||||
static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN;
|
|
||||||
|
int sound_buf_len = 48000 / 10;
|
||||||
|
|
||||||
|
void sound_update_buf_length()
|
||||||
|
{
|
||||||
|
int new_buf_len = (48000 / (1000 / sound_buf_len)) / 4;
|
||||||
|
|
||||||
|
if (new_buf_len > MAXSOUNDBUFLEN)
|
||||||
|
new_buf_len = MAXSOUNDBUFLEN;
|
||||||
|
|
||||||
|
SOUNDBUFLEN = new_buf_len;
|
||||||
|
}
|
||||||
|
|
||||||
void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r)
|
void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r)
|
||||||
{
|
{
|
||||||
|
|
@ -194,7 +205,7 @@ void sound_init()
|
||||||
initalmain(0,NULL);
|
initalmain(0,NULL);
|
||||||
inital();
|
inital();
|
||||||
|
|
||||||
outbuffer = malloc(SOUNDBUFLEN * 2 * sizeof(int32_t));
|
outbuffer = malloc(MAXSOUNDBUFLEN * 2 * sizeof(int32_t));
|
||||||
|
|
||||||
sound_cd_event = thread_create_event();
|
sound_cd_event = thread_create_event();
|
||||||
sound_cd_thread_h = thread_create(sound_cd_thread, NULL);
|
sound_cd_thread_h = thread_create(sound_cd_thread, NULL);
|
||||||
|
|
@ -207,9 +218,17 @@ void sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), vo
|
||||||
sound_handlers_num++;
|
sound_handlers_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cd_pos = 0;
|
||||||
void sound_poll(void *priv)
|
void sound_poll(void *priv)
|
||||||
{
|
{
|
||||||
sound_poll_time += sound_poll_latch;
|
sound_poll_time += sound_poll_latch;
|
||||||
|
|
||||||
|
cd_pos++;
|
||||||
|
if (cd_pos == (CD_BUFLEN * 48000) / CD_FREQ)
|
||||||
|
{
|
||||||
|
cd_pos = 0;
|
||||||
|
thread_set_event(sound_cd_event);
|
||||||
|
}
|
||||||
|
|
||||||
sound_pos_global++;
|
sound_pos_global++;
|
||||||
if (sound_pos_global == SOUNDBUFLEN)
|
if (sound_pos_global == SOUNDBUFLEN)
|
||||||
|
|
@ -238,14 +257,8 @@ void sound_poll(void *priv)
|
||||||
|
|
||||||
if (soundon) givealbuffer(outbuffer);
|
if (soundon) givealbuffer(outbuffer);
|
||||||
|
|
||||||
cd_buf_update--;
|
|
||||||
if (!cd_buf_update)
|
|
||||||
{
|
|
||||||
cd_buf_update = (48000 / SOUNDBUFLEN) / (CD_FREQ / CD_BUFLEN);
|
|
||||||
thread_set_event(sound_cd_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
sound_pos_global = 0;
|
sound_pos_global = 0;
|
||||||
|
sound_update_buf_length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,9 @@ void inital();
|
||||||
|
|
||||||
void givealbuffer(int32_t *buf);
|
void givealbuffer(int32_t *buf);
|
||||||
void givealbuffer_cd(int16_t *buf);
|
void givealbuffer_cd(int16_t *buf);
|
||||||
|
|
||||||
|
extern int sound_buf_len;
|
||||||
|
void sound_update_buf_length();
|
||||||
|
|
||||||
|
extern int SOUNDBUFLEN;
|
||||||
|
#define MAXSOUNDBUFLEN (48000 / 10)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ typedef struct ad1848_t
|
||||||
|
|
||||||
int timer_count, timer_latch;
|
int timer_count, timer_latch;
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
int16_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
int pos;
|
int pos;
|
||||||
} ad1848_t;
|
} ad1848_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ typedef struct adgold_t
|
||||||
int vol_l, vol_r;
|
int vol_l, vol_r;
|
||||||
int treble, bass;
|
int treble, bass;
|
||||||
|
|
||||||
int16_t opl_buffer[SOUNDBUFLEN * 2];
|
int16_t opl_buffer[MAXSOUNDBUFLEN * 2];
|
||||||
int16_t mma_buffer[2][SOUNDBUFLEN];
|
int16_t mma_buffer[2][MAXSOUNDBUFLEN];
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ typedef struct cms_t
|
||||||
int noisecount[2][2];
|
int noisecount[2][2];
|
||||||
int noisetype[2][2];
|
int noisetype[2][2];
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
int16_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
} cms_t;
|
} cms_t;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ typedef struct emu8k_t
|
||||||
int16_t out_l, out_r;
|
int16_t out_l, out_r;
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
int32_t buffer[SOUNDBUFLEN * 2];
|
int32_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
} emu8k_t;
|
} emu8k_t;
|
||||||
|
|
||||||
void emu8k_init(emu8k_t *emu8k, int onboard_ram);
|
void emu8k_init(emu8k_t *emu8k, int onboard_ram);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ typedef struct gus_t
|
||||||
|
|
||||||
int32_t out_l, out_r;
|
int32_t out_l, out_r;
|
||||||
|
|
||||||
int16_t buffer[2][SOUNDBUFLEN];
|
int16_t buffer[2][MAXSOUNDBUFLEN];
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
int samp_timer, samp_latch;
|
int samp_timer, samp_latch;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
typedef struct opl_t
|
typedef struct opl_t
|
||||||
{
|
{
|
||||||
int chip_nr[2];
|
int chip_nr[2];
|
||||||
|
|
@ -7,7 +9,7 @@ typedef struct opl_t
|
||||||
|
|
||||||
int16_t filtbuf[2];
|
int16_t filtbuf[2];
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
int16_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
int pos;
|
int pos;
|
||||||
} opl_t;
|
} opl_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ typedef struct pas16_t
|
||||||
opl_t opl;
|
opl_t opl;
|
||||||
sb_dsp_t dsp;
|
sb_dsp_t dsp;
|
||||||
|
|
||||||
int16_t pcm_buffer[2][SOUNDBUFLEN];
|
int16_t pcm_buffer[2][MAXSOUNDBUFLEN];
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
} pas16_t;
|
} pas16_t;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ typedef struct ps1_audio_t
|
||||||
|
|
||||||
uint8_t dac_val;
|
uint8_t dac_val;
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN];
|
int16_t buffer[MAXSOUNDBUFLEN];
|
||||||
int pos;
|
int pos;
|
||||||
} ps1_audio_t;
|
} ps1_audio_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ typedef struct pssj_t
|
||||||
int wave_pos;
|
int wave_pos;
|
||||||
int pulse_width;
|
int pulse_width;
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN];
|
int16_t buffer[MAXSOUNDBUFLEN];
|
||||||
int pos;
|
int pos;
|
||||||
} pssj_t;
|
} pssj_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ typedef struct sb_dsp_t
|
||||||
|
|
||||||
int wb_time, wb_full;
|
int wb_time, wb_full;
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
int16_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
int pos;
|
int pos;
|
||||||
} sb_dsp_t;
|
} sb_dsp_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SN76496,
|
SN76496,
|
||||||
|
|
@ -23,7 +25,7 @@ typedef struct sn76489_t
|
||||||
int type;
|
int type;
|
||||||
int extra_divide;
|
int extra_divide;
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN];
|
int16_t buffer[MAXSOUNDBUFLEN];
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
double psgconst;
|
double psgconst;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
int speaker_mute = 0;
|
int speaker_mute = 0;
|
||||||
|
|
||||||
static int16_t speaker_buffer[SOUNDBUFLEN];
|
static int16_t speaker_buffer[MAXSOUNDBUFLEN];
|
||||||
|
|
||||||
static int speaker_pos = 0;
|
static int speaker_pos = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
typedef struct ssi2001_t
|
typedef struct ssi2001_t
|
||||||
{
|
{
|
||||||
void *psid;
|
void *psid;
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
int16_t buffer[MAXSOUNDBUFLEN * 2];
|
||||||
int pos;
|
int pos;
|
||||||
} ssi2001_t;
|
} ssi2001_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ ALuint buffers_cd[4]; // front and back buffers
|
||||||
static ALuint source[2]; // audio source
|
static ALuint source[2]; // audio source
|
||||||
#endif
|
#endif
|
||||||
#define FREQ 48000
|
#define FREQ 48000
|
||||||
|
|
||||||
|
int SOUNDBUFLEN = 48000/20;
|
||||||
|
|
||||||
#define BUFLEN SOUNDBUFLEN
|
#define BUFLEN SOUNDBUFLEN
|
||||||
|
|
||||||
void closeal();
|
void closeal();
|
||||||
|
|
|
||||||
22
src/win.c
22
src/win.c
|
|
@ -646,6 +646,9 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
|
||||||
CheckMenuItem(menu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(menu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED);
|
||||||
CheckMenuItem(menu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(menu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
CheckMenuItem(menu, IDM_BUF_100MS, (sound_buf_len == 100) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
CheckMenuItem(menu, IDM_BUF_200MS, (sound_buf_len == 200) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
CheckMenuItem(menu, IDM_BUF_400MS, (sound_buf_len == 400) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
|
||||||
if (!loadbios())
|
if (!loadbios())
|
||||||
{
|
{
|
||||||
|
|
@ -1051,6 +1054,25 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
saveconfig(NULL);
|
saveconfig(NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDM_BUF_100MS: case IDM_BUF_200MS: case IDM_BUF_400MS:
|
||||||
|
switch (LOWORD(wParam))
|
||||||
|
{
|
||||||
|
case IDM_BUF_100MS:
|
||||||
|
sound_buf_len = 100;
|
||||||
|
break;
|
||||||
|
case IDM_BUF_200MS:
|
||||||
|
sound_buf_len = 200;
|
||||||
|
break;
|
||||||
|
case IDM_BUF_400MS:
|
||||||
|
sound_buf_len = 400;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
CheckMenuItem(hmenu, IDM_BUF_100MS, (sound_buf_len == 100) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
CheckMenuItem(hmenu, IDM_BUF_200MS, (sound_buf_len == 200) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
CheckMenuItem(hmenu, IDM_BUF_400MS, (sound_buf_len == 400) ? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
saveconfig(NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_CDROM_DISABLED:
|
case IDM_CDROM_DISABLED:
|
||||||
if (cdrom_enabled)
|
if (cdrom_enabled)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue