Add more audio settings / diagnostics.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
fec69e1f72
commit
3e03e3ba57
6 changed files with 99 additions and 8 deletions
|
@ -18,6 +18,8 @@
|
|||
#include "Debugger/Debug.h"
|
||||
#include "Debugger/DebugDefs.h"
|
||||
|
||||
#include "imgui_internal.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -326,18 +328,51 @@ namespace sa2
|
|||
if (ImGui::BeginTabItem("Audio"))
|
||||
{
|
||||
const int volumeMax = GetPropertySheet().GetVolumeMax();
|
||||
mySpeakerVolume = volumeMax - SpkrGetVolume();
|
||||
if (ImGui::SliderInt("Speaker volume", &mySpeakerVolume, 0, volumeMax))
|
||||
{
|
||||
SpkrSetVolume(volumeMax - mySpeakerVolume, volumeMax);
|
||||
REGSAVE(TEXT(REGVALUE_SPKR_VOLUME), SpkrGetVolume());
|
||||
}
|
||||
|
||||
myMockingboardVolume = volumeMax - MB_GetVolume();
|
||||
if (ImGui::SliderInt("Mockingboard volume", &myMockingboardVolume, 0, volumeMax))
|
||||
{
|
||||
MB_SetVolume(volumeMax - myMockingboardVolume, volumeMax);
|
||||
REGSAVE(TEXT(REGVALUE_MB_VOLUME), MB_GetVolume());
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginTable("Devices", 5, ImGuiTableFlags_RowBg))
|
||||
{
|
||||
myAudioInfo = getAudioInfo();
|
||||
ImGui::TableSetupColumn("Running");
|
||||
ImGui::TableSetupColumn("Channels");
|
||||
ImGui::TableSetupColumn("Volume");
|
||||
ImGui::TableSetupColumn("Buffer");
|
||||
ImGui::TableSetupColumn("Queue");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); // this requires imgui_internal.h
|
||||
for (SoundInfo & device : myAudioInfo)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("", &device.running);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", device.channels);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::SliderFloat("", &device.volume, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::SliderFloat("", &device.buffer, 0.0f, device.size, "%.3f");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::SliderFloat("", &device.queue, 0.0f, device.size, "%.3f");
|
||||
}
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, false);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "frontends/sdl/imgui/gles.h"
|
||||
#include "frontends/sdl/sdirectsound.h"
|
||||
|
||||
namespace sa2
|
||||
{
|
||||
|
@ -23,12 +24,14 @@ namespace sa2
|
|||
bool mySyncCPU = true;
|
||||
|
||||
int myStepCycles = 0;
|
||||
int mySpeakerVolume = 50;
|
||||
int myMockingboardVolume = 50;
|
||||
int mySpeakerVolume;
|
||||
int myMockingboardVolume;
|
||||
|
||||
MemoryEditor myMainMemoryEditor;
|
||||
MemoryEditor myAuxMemoryEditor;
|
||||
|
||||
std::vector<SoundInfo> myAudioInfo;
|
||||
|
||||
void showSettings();
|
||||
void showDebugger(SDLFrame* frame);
|
||||
void showMemory();
|
||||
|
|
|
@ -204,7 +204,7 @@ void run_sdl(int argc, const char * argv [])
|
|||
const double actualClock = g_nCumulativeCycles / timeInSeconds;
|
||||
std::cerr << "Expected clock: " << g_fCurrentCLK6502 << " Hz, " << g_nCumulativeCycles / g_fCurrentCLK6502 << " s" << std::endl;
|
||||
std::cerr << "Actual clock: " << actualClock << " Hz, " << timeInSeconds << " s" << std::endl;
|
||||
sa2::stop();
|
||||
sa2::stopAudio();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace
|
|||
void writeAudio();
|
||||
|
||||
void printInfo() const;
|
||||
sa2::SoundInfo getInfo() const;
|
||||
|
||||
private:
|
||||
IDirectSoundBuffer * myBuffer;
|
||||
|
@ -46,6 +47,7 @@ namespace
|
|||
DirectSoundGenerator::DirectSoundGenerator(IDirectSoundBuffer * buffer)
|
||||
: myBuffer(buffer)
|
||||
, myAudioDevice(0)
|
||||
, myBytesPerSecond(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -116,6 +118,26 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
sa2::SoundInfo DirectSoundGenerator::getInfo() const
|
||||
{
|
||||
sa2::SoundInfo info;
|
||||
info.running = isRunning();
|
||||
info.channels = myAudioSpec.channels;
|
||||
info.volume = myBuffer->GetLogarithmicVolume();
|
||||
|
||||
if (info.running && myBytesPerSecond > 0.0)
|
||||
{
|
||||
const DWORD bytesInBuffer = myBuffer->GetBytesInBuffer();
|
||||
const Uint32 bytesInQueue = SDL_GetQueuedAudioSize(myAudioDevice);
|
||||
const float coeff = 1.0 / myBytesPerSecond;
|
||||
info.buffer = bytesInBuffer * coeff;
|
||||
info.queue = bytesInQueue * coeff;
|
||||
info.size = myBuffer->bufferSize * coeff;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void DirectSoundGenerator::stop()
|
||||
{
|
||||
if (myAudioDevice)
|
||||
|
@ -196,7 +218,7 @@ void unregisterSoundBuffer(IDirectSoundBuffer * buffer)
|
|||
namespace sa2
|
||||
{
|
||||
|
||||
void stop()
|
||||
void stopAudio()
|
||||
{
|
||||
for (auto & it : activeSoundGenerators)
|
||||
{
|
||||
|
@ -214,7 +236,7 @@ namespace sa2
|
|||
}
|
||||
}
|
||||
|
||||
void printInfo()
|
||||
void printAudioInfo()
|
||||
{
|
||||
for (auto & it : activeSoundGenerators)
|
||||
{
|
||||
|
@ -222,4 +244,19 @@ namespace sa2
|
|||
generator->printInfo();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SoundInfo> getAudioInfo()
|
||||
{
|
||||
std::vector<SoundInfo> info;
|
||||
info.reserve(activeSoundGenerators.size());
|
||||
|
||||
for (auto & it : activeSoundGenerators)
|
||||
{
|
||||
const std::shared_ptr<DirectSoundGenerator> & generator = it.second;
|
||||
info.push_back(generator->getInfo());
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace sa2
|
||||
{
|
||||
void stop();
|
||||
|
||||
struct SoundInfo
|
||||
{
|
||||
bool running = false;
|
||||
int channels = 0;
|
||||
|
||||
// in seconds
|
||||
// float to work with ImGui.
|
||||
float buffer = 0.0;
|
||||
float queue = 0.0;
|
||||
float size = 0.0;
|
||||
float volume = 0.0;
|
||||
};
|
||||
|
||||
void stopAudio();
|
||||
void writeAudio();
|
||||
void printInfo();
|
||||
void printAudioInfo();
|
||||
std::vector<SoundInfo> getAudioInfo();
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ namespace sa2
|
|||
}
|
||||
case SDLK_F1:
|
||||
{
|
||||
sa2::printInfo();
|
||||
sa2::printAudioInfo();
|
||||
break;
|
||||
}
|
||||
case SDLK_LALT:
|
||||
|
|
Loading…
Add table
Reference in a new issue