Use correct sound buffer size everywhere

This commit is contained in:
meepingsnesroms
2018-10-10 15:13:11 -07:00
parent fe361ca97c
commit 47124bda2e
7 changed files with 8 additions and 5 deletions

View File

@@ -93,7 +93,7 @@ void EmuWrapper::emuThreadRun(){
emulateFrame();
if(!emuNewFrameReady){
memcpy(emuDoubleBufferVideo, emuVideoWidth == 320 ? palmExtendedFramebuffer : palmFramebuffer, emuVideoWidth * emuVideoHeight * sizeof(uint16_t));
memcpy(emuDoubleBufferAudio, palmAudio, AUDIO_SAMPLES);
memcpy(emuDoubleBufferAudio, palmAudio, AUDIO_SAMPLES * 2/*channels*/ * sizeof(int16_t));
emuNewFrameReady = true;
}
}
@@ -207,7 +207,7 @@ uint32_t EmuWrapper::init(const QString& romPath, const QString& bootloaderPath,
emuPaused = false;
emuNewFrameReady = false;
emuDoubleBufferVideo = new uint16_t[emuVideoWidth * emuVideoHeight];
emuDoubleBufferAudio = new int16_t[CRYSTAL_FREQUENCY * AUDIO_DUTY_CYCLE_SIZE * 2/*channels*/];
emuDoubleBufferAudio = new int16_t[AUDIO_SAMPLES * 2/*channels*/];
emuThread = std::thread(&EmuWrapper::emuThreadRun, this);
}
else{

View File

@@ -170,7 +170,7 @@ void MainWindow::updateDisplay(){
ui->display->repaint();
//audio
audioOut->write((const char*)emu.getAudioSamples(), AUDIO_SAMPLES * sizeof(int16_t));
audioOut->write((const char*)emu.getAudioSamples(), AUDIO_SAMPLES * 2/*channels*/ * sizeof(int16_t));
//power LED
ui->powerButtonLed->setStyleSheet(emu.getPowerButtonLed() ? "background: lime" : "");

View File

@@ -95,7 +95,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
memset(palmExtendedFramebuffer, 0x00, 320 * 320 * sizeof(uint16_t));
//add 320*320 silkscreen image later, 2xBRZ should be able to make 320*320 version of the 160*160 silkscreen
}
memset(palmAudio, 0x00, AUDIO_SAMPLES * 2 * sizeof(int16_t));
memset(palmAudio, 0x00, AUDIO_SAMPLES * 2/*channels*/ * sizeof(int16_t));
m68328Reset();
sed1376Reset();
ads7846Reset();

View File

@@ -112,12 +112,12 @@ typedef struct{
}misc_hw_t;
//config options
#define EMU_FPS 60
#define AUDIO_DUTY_CYCLE_SIZE 20//the amount of frequencys the PWM can play
#define SAVE_STATE_VERSION 0
//system constants
#define CRYSTAL_FREQUENCY 32768
#define EMU_FPS 60
#define AUDIO_SAMPLES (CRYSTAL_FREQUENCY / EMU_FPS * AUDIO_DUTY_CYCLE_SIZE)
//emulator data, some are GUI interface variables, some should be left alone

1
tests/audioAddress.txt Normal file
View File

@@ -0,0 +1 @@
Audio write, PC:0x10087FC4(printed 4 times)

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@