mirror of
https://github.com/polpo/picogus.git
synced 2026-10-25 21:40:16 +00:00
Volume scaling for bufferless_ng sbplay
This commit is contained in:
1 parent
0b92610043
commit
0027a65071
3 files changed
+9
-8
No files matched your search
@@ -401,7 +401,6 @@ uint32_t cdrom_audio_callback_simple(cdrom_t *dev, int16_t *buffer, uint32_t len
|
||||
/* printf("%u\n", samples_to_transfer); */
|
||||
// Add samples from sector buffer to FIFO
|
||||
//memcpy(buffer + samples_produced, &dev->current_sector_samples[dev->audio_sector_consumed_samples], samples_to_transfer * sizeof(int16_t));
|
||||
|
||||
for (uint32_t i = 0; i < samples_to_transfer; i++)
|
||||
{
|
||||
int32_t sample = dev->current_sector_samples[dev->audio_sector_consumed_samples + i];
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "pico_pic.h"
|
||||
#include "volctrl.h"
|
||||
|
||||
/*
|
||||
Title : SoundBlaster DSP Emulation
|
||||
@@ -211,7 +212,7 @@ static uint32_t DSP_DMA_EventHandler(Bitu val) {
|
||||
static void sbdsp_dma_isr(void) {
|
||||
const uint32_t dma_data = DMA_Complete_Write(&dma_config);
|
||||
#ifdef SB_BUFFERLESS
|
||||
sbdsp.cur_sample = (int16_t)((dma_data & 0xFF) ^ 0x80) << 8;
|
||||
sbdsp.cur_sample = (int16_t)scale_sample(((dma_data & 0xFF) ^ 0x80) << 8, sb_volume, 0);
|
||||
#else
|
||||
sbdsp_fifo_rx(dma_data & 0xFF);
|
||||
#endif
|
||||
|
||||
+7
-6
@@ -102,9 +102,10 @@ static audio_fifo_t opl_out_fifo;
|
||||
|
||||
static int16_t get_opl_sample()
|
||||
{
|
||||
int16_t opl_current_sample;
|
||||
int16_t opl_current_sample;
|
||||
OPL_Pico_simple(&opl_current_sample, 1);
|
||||
return opl_current_sample;
|
||||
opl_current_sample = scale_sample(opl_current_sample << 2, opl_volume, 0);
|
||||
return opl_current_sample;
|
||||
}
|
||||
|
||||
static Resampler<get_opl_sample> resampler;
|
||||
@@ -130,7 +131,6 @@ void audio_sample_handler(void) {
|
||||
|
||||
#ifdef SOUND_SB
|
||||
uint32_t sb_sample = sbdsp_sample();
|
||||
sb_sample = scale_sample((int32_t)sb_sample >> 1, sb_volume, 1);
|
||||
sample_l = sample_r = sb_sample;
|
||||
#endif
|
||||
|
||||
@@ -138,8 +138,10 @@ void audio_sample_handler(void) {
|
||||
static uint32_t cd_index = 0;
|
||||
const uint32_t has_cd_samples = fifo_take_samples_inline(cd_fifo, 2);
|
||||
if (has_cd_samples) {
|
||||
sample_l += cd_fifo->buffer[cd_index++];
|
||||
sample_r += cd_fifo->buffer[cd_index++];
|
||||
sample_l += scale_sample(cd_fifo->buffer[cd_index++], cd_audio_volume, 0);
|
||||
sample_r += scale_sample(cd_fifo->buffer[cd_index++], cd_audio_volume, 0);
|
||||
// sample_l += cd_fifo->buffer[cd_index++];
|
||||
// sample_r += cd_fifo->buffer[cd_index++];
|
||||
cd_index &= AUDIO_FIFO_BITS;
|
||||
}
|
||||
#endif
|
||||
@@ -148,7 +150,6 @@ void audio_sample_handler(void) {
|
||||
const uint32_t has_opl_samples = fifo_take_samples_inline(&opl_out_fifo, 1);
|
||||
if (has_opl_samples) {
|
||||
int16_t opl_sample = opl_out_fifo.buffer[opl_out_index++];
|
||||
opl_sample = scale_sample(opl_sample << 2, opl_volume, 0);
|
||||
sample_l += opl_sample;
|
||||
sample_r += opl_sample;
|
||||
opl_out_index &= AUDIO_FIFO_BITS;
|
||||
|
||||
Reference in new issue
Block a user