Compile AW's Speaker.cpp and remove custom implementation.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
22125c9566
commit
9c442468f5
21 changed files with 84 additions and 477 deletions
|
@ -1,6 +1,7 @@
|
|||
include(FindPkgConfig)
|
||||
|
||||
add_library(appleii SHARED
|
||||
Speaker.cpp
|
||||
SoundCore.cpp
|
||||
AY8910.cpp
|
||||
Mockingboard.cpp
|
||||
|
@ -60,7 +61,6 @@ add_library(appleii SHARED
|
|||
linux/duplicates/Joystick.cpp
|
||||
linux/duplicates/Frame.cpp
|
||||
linux/duplicates/SerialComms.cpp
|
||||
linux/duplicates/Speaker.cpp
|
||||
linux/duplicates/IPropertySheet.cpp
|
||||
linux/duplicates/Applewin.cpp # defines g_CardMgr (reverse order)
|
||||
|
||||
|
|
|
@ -90,9 +90,9 @@ static bool g_bSpkrAvailable = false;
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Forward refs:
|
||||
ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSamples);
|
||||
ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples);
|
||||
void Spkr_SetActive(bool bActive);
|
||||
static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSamples);
|
||||
static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples);
|
||||
static void Spkr_SetActive(bool bActive);
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
|
|
@ -58,9 +58,6 @@ namespace
|
|||
|
||||
bool g_bTextFlashState = false;
|
||||
|
||||
double alpha = 10.0;
|
||||
double F = 0;
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
// Ctrl-C
|
||||
|
@ -136,17 +133,6 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
ULONG lastUpdate = 0;
|
||||
|
||||
void updateSpeaker()
|
||||
{
|
||||
const ULONG dCycles = g_nCumulativeCycles - lastUpdate;
|
||||
const double dt = dCycles / g_fCurrentCLK6502;
|
||||
const double coeff = exp(- alpha * dt);
|
||||
F = F * coeff;
|
||||
lastUpdate = g_nCumulativeCycles;
|
||||
}
|
||||
|
||||
typedef bool (*VideoUpdateFuncPtr_t)(int, int, int, int, int);
|
||||
|
||||
bool Update40ColCell (int x, int y, int xpixel, int ypixel, int offset)
|
||||
|
@ -264,13 +250,6 @@ void FrameRefresh()
|
|||
|
||||
mvwprintw(status, 1, 2, "D1: %d, %s, %s", g_eStatusDrive1, g_sTrackDrive1, g_sSectorDrive1);
|
||||
mvwprintw(status, 2, 2, "D2: %d, %s, %s", g_eStatusDrive2, g_sTrackDrive2, g_sSectorDrive2);
|
||||
|
||||
// approximate
|
||||
const double frequency = 0.5 * alpha * F;
|
||||
mvwprintw(status, 1, 20, "%5.fHz", frequency);
|
||||
mvwprintw(status, 2, 20, "%5.1f%%", 100 * g_relativeSpeed);
|
||||
|
||||
wrefresh(status);
|
||||
}
|
||||
|
||||
void FrameDrawDiskLEDS(HDC x)
|
||||
|
@ -404,7 +383,6 @@ void VideoUninitialize()
|
|||
void VideoRedrawScreen()
|
||||
{
|
||||
VideoUpdateFlash();
|
||||
updateSpeaker();
|
||||
FrameRefresh();
|
||||
|
||||
const int displaypage2 = (SW_PAGE2) == 0 ? 0 : 1;
|
||||
|
@ -535,19 +513,6 @@ void ProcessInput()
|
|||
paddle->poll();
|
||||
}
|
||||
|
||||
|
||||
// Speaker
|
||||
|
||||
BYTE __stdcall SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles)
|
||||
{
|
||||
CpuCalcCycles(uExecutedCycles);
|
||||
|
||||
updateSpeaker();
|
||||
F += 1;
|
||||
|
||||
return MemReadFloatingBus(uExecutedCycles);
|
||||
}
|
||||
|
||||
// Mockingboard
|
||||
void registerSoundBuffer(IDirectSoundBuffer * buffer)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,6 @@ add_executable(qapple
|
|||
video.cpp
|
||||
registry.cpp
|
||||
options.cpp
|
||||
audiogenerator.cpp
|
||||
loggingcategory.cpp
|
||||
viewbuffer.cpp
|
||||
qdirectsound.cpp
|
||||
|
|
|
@ -1,258 +0,0 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "audiogenerator.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "CPU.h"
|
||||
#include "Applewin.h"
|
||||
#include "Memory.h"
|
||||
#include "loggingcategory.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAudioOutput>
|
||||
|
||||
// Speaker
|
||||
|
||||
BYTE __stdcall SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles)
|
||||
{
|
||||
CpuCalcCycles(uExecutedCycles);
|
||||
|
||||
Q_UNUSED(pc)
|
||||
Q_UNUSED(addr)
|
||||
Q_UNUSED(bWrite)
|
||||
Q_UNUSED(d)
|
||||
|
||||
AudioGenerator::instance().toggle();
|
||||
|
||||
return MemReadFloatingBus(uExecutedCycles);
|
||||
}
|
||||
|
||||
AudioGenerator & AudioGenerator::instance()
|
||||
{
|
||||
static std::shared_ptr<AudioGenerator> audioGenerator(new AudioGenerator());
|
||||
return *audioGenerator;
|
||||
}
|
||||
|
||||
AudioGenerator::AudioGenerator()
|
||||
{
|
||||
myDevice = nullptr;
|
||||
myInitialSilence = 200;
|
||||
mySilenceDelay = 10000;
|
||||
myVolume = 0x0fff;
|
||||
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleRate(44100);
|
||||
audioFormat.setChannelCount(1);
|
||||
audioFormat.setSampleSize(sizeof(audio_t) * 8);
|
||||
audioFormat.setCodec(QString::fromUtf8("audio/pcm"));
|
||||
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||
|
||||
myAudioOutput.reset(new QAudioOutput(audioFormat));
|
||||
myAudioFormat = myAudioOutput->format();
|
||||
}
|
||||
|
||||
QAudioOutput * AudioGenerator::getAudioOutput()
|
||||
{
|
||||
return myAudioOutput.get();
|
||||
}
|
||||
|
||||
void AudioGenerator::setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume)
|
||||
{
|
||||
myInitialSilence = std::max(0, initialSilence);
|
||||
mySilenceDelay = std::max(0, silenceDelay);
|
||||
myVolume = std::max(0, volume);
|
||||
}
|
||||
|
||||
void AudioGenerator::stateChanged(QAudio::State state)
|
||||
{
|
||||
qDebug(appleAudio) << "Changed state: state =" << state << ", error =" << myAudioOutput->error() << ", free =" << myAudioOutput->bytesFree() << "bytes";
|
||||
}
|
||||
|
||||
qint64 AudioGenerator::toFrameTime(qint64 cpuCycples)
|
||||
{
|
||||
const double CLKS_PER_SEC = g_fCurrentCLK6502;
|
||||
qint64 timeInFrames = (cpuCycples - myStartCPUCycles) * myAudioFormat.sampleRate() / CLKS_PER_SEC;
|
||||
return timeInFrames;
|
||||
}
|
||||
|
||||
void AudioGenerator::toggle()
|
||||
{
|
||||
const qint64 timeInFrames = toFrameTime(g_nCumulativeCycles);
|
||||
myTicks.push(timeInFrames);
|
||||
}
|
||||
|
||||
bool AudioGenerator::isRunning()
|
||||
{
|
||||
QAudio::State state = myAudioOutput->state();
|
||||
QAudio::Error error = myAudioOutput->error();
|
||||
if (state == QAudio::ActiveState)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (state == QAudio::IdleState && error == QAudio::NoError)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AudioGenerator::start()
|
||||
{
|
||||
if (isRunning())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// restart as we are either starting or recovering from underrun
|
||||
myDevice = myAudioOutput->start();
|
||||
|
||||
if (!myDevice)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug(appleAudio) << "Restarting the AudioGenerator";
|
||||
|
||||
const int bytesSize = myAudioOutput->bufferSize();
|
||||
const qint32 frameSize = myAudioFormat.framesForBytes(bytesSize);
|
||||
|
||||
myBuffer.resize(frameSize);
|
||||
myStartCPUCycles = g_nCumulativeCycles;
|
||||
myPreviousFrameTime = 0;
|
||||
|
||||
const qint32 framePeriod = myAudioFormat.framesForBytes(myAudioOutput->periodSize());
|
||||
qDebug(appleAudio) << "AudioOutput: size =" << frameSize << "f, period =" << framePeriod << "f";
|
||||
|
||||
mySilence = 0;
|
||||
myMaximum = 0;
|
||||
myValue = 0;
|
||||
myPhysical = myVolume;
|
||||
myTicks = std::queue<qint64>();
|
||||
|
||||
writeEnoughSilence(myInitialSilence); // ms
|
||||
}
|
||||
|
||||
void AudioGenerator::writeEnoughSilence(const qint64 ms)
|
||||
{
|
||||
// write a few ms of silence
|
||||
const qint32 framesSilence = myAudioFormat.framesForDuration(ms * 1000); // target frames to write
|
||||
|
||||
const qint32 bytesFree = myAudioOutput->bytesFree();
|
||||
const qint32 framesFree = myAudioFormat.framesForBytes(bytesFree); // number of frames avilable to write
|
||||
|
||||
const qint32 framesToWrite = std::min(framesFree, framesSilence);
|
||||
|
||||
generateSilence(myBuffer.data(), myBuffer.data() + framesToWrite);
|
||||
|
||||
const qint64 bytesToWrite = myAudioFormat.bytesForFrames(framesToWrite);
|
||||
const char * data = reinterpret_cast<char *>(myBuffer.data());
|
||||
myDevice->write(data, bytesToWrite);
|
||||
|
||||
const qint64 duration = myAudioFormat.durationForFrames(framesToWrite);
|
||||
qDebug(appleAudio) << "Written some silence: frames =" << framesToWrite << ", duration =" << duration / 1000 << "ms";
|
||||
}
|
||||
|
||||
void AudioGenerator::stop()
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const qint32 bytesFree = myAudioOutput->bytesFree();
|
||||
const qint32 framesFree = myAudioFormat.framesForBytes(bytesFree);
|
||||
|
||||
// fill with zeros and stop
|
||||
generateSilence(myBuffer.data(), myBuffer.data() + framesFree);
|
||||
|
||||
const qint32 bytesToWrite = myAudioFormat.bytesForFrames(framesFree);
|
||||
const char * data = reinterpret_cast<char *>(myBuffer.data());
|
||||
myDevice->write(data, bytesToWrite);
|
||||
|
||||
const qint64 duration = myAudioFormat.durationForFrames(framesFree);
|
||||
qDebug(appleAudio) << "Stopping with silence: frames =" << framesFree << ", duration =" << duration / 1000 << "ms";
|
||||
myAudioOutput->stop();
|
||||
}
|
||||
|
||||
void AudioGenerator::writeAudio()
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we write all we have available (up to the free bytes)
|
||||
|
||||
const qint64 currentFrameTime = toFrameTime(g_nCumulativeCycles);
|
||||
const qint64 newFramesAvailable = currentFrameTime - myPreviousFrameTime;
|
||||
|
||||
const qint32 bytesFree = myAudioOutput->bytesFree();
|
||||
const qint64 framesFree = myAudioFormat.framesForBytes(bytesFree);
|
||||
|
||||
const qint64 framesToWrite = std::min(framesFree, newFramesAvailable);
|
||||
|
||||
generateSamples(myBuffer.data(), framesToWrite);
|
||||
|
||||
const qint32 bytesToWrite = myAudioFormat.bytesForFrames(framesToWrite);
|
||||
const char * data = reinterpret_cast<char *>(myBuffer.data());
|
||||
const qint64 bytesWritten = myDevice->write(data, bytesToWrite);
|
||||
if (bytesToWrite != bytesWritten)
|
||||
{
|
||||
qDebug(appleAudio) << "Mismatch:" << bytesToWrite << "!=" << bytesWritten;
|
||||
}
|
||||
const qint64 framesWritten = framesToWrite;
|
||||
myPreviousFrameTime += framesWritten;
|
||||
|
||||
const qint32 bytesFreeNow = myAudioOutput->bytesFree();
|
||||
if (bytesFreeNow > myMaximum)
|
||||
{
|
||||
// if this number is too big, it probably means we aren't providing enough data
|
||||
const qint32 bytesSize = myAudioOutput->bufferSize();
|
||||
myMaximum = bytesFreeNow;
|
||||
qDebug(appleAudio) << "Running maximum free bytes:" << myMaximum << "/" << bytesSize;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioGenerator::generateSilence(audio_t * begin, audio_t * end)
|
||||
{
|
||||
if (myValue != 0)
|
||||
{
|
||||
const audio_t delta = myPhysical > 0 ? -1 : +1;
|
||||
for (audio_t * ptr = begin; ptr != end; ++ptr)
|
||||
{
|
||||
++mySilence;
|
||||
if (myValue != 0 && mySilence > mySilenceDelay)
|
||||
{
|
||||
myValue += delta;
|
||||
}
|
||||
*ptr = myValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no need to update mySilence as myValue is already 0
|
||||
std::fill(begin, end, myValue);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioGenerator::generateSamples(audio_t *data, qint64 framesToWrite)
|
||||
{
|
||||
qint64 start = myPreviousFrameTime;
|
||||
qint64 end = myPreviousFrameTime + framesToWrite;
|
||||
|
||||
audio_t * head = data;
|
||||
while (!myTicks.empty() && (myTicks.front() < end))
|
||||
{
|
||||
qint64 next = myTicks.front() - start;
|
||||
audio_t * last = data + next;
|
||||
std::fill(head, last, myValue);
|
||||
head = last;
|
||||
myPhysical = -myPhysical;
|
||||
myValue = myPhysical;
|
||||
mySilence = 0;
|
||||
myTicks.pop();
|
||||
}
|
||||
|
||||
generateSilence(head, data + framesToWrite);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
#ifndef AUDIO_H
|
||||
#define AUDIO_H
|
||||
|
||||
#include <QAudioFormat>
|
||||
#include <QAudio>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QIODevice;
|
||||
class QAudioOutput;
|
||||
|
||||
class AudioGenerator {
|
||||
public:
|
||||
|
||||
static AudioGenerator & instance();
|
||||
|
||||
QAudioOutput * getAudioOutput();
|
||||
|
||||
void toggle();
|
||||
void start();
|
||||
void stop();
|
||||
void writeAudio();
|
||||
void stateChanged(QAudio::State state);
|
||||
|
||||
void setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume);
|
||||
|
||||
private:
|
||||
typedef short int audio_t;
|
||||
|
||||
std::queue<qint64> myTicks;
|
||||
|
||||
std::shared_ptr<QAudioOutput> myAudioOutput;
|
||||
QAudioFormat myAudioFormat;
|
||||
QIODevice * myDevice;
|
||||
std::vector<audio_t> myBuffer;
|
||||
|
||||
// options
|
||||
qint32 myInitialSilence;
|
||||
qint32 mySilenceDelay;
|
||||
qint16 myVolume;
|
||||
|
||||
qint64 myStartCPUCycles;
|
||||
qint64 myPreviousFrameTime;
|
||||
qint32 myMaximum;
|
||||
|
||||
qint32 mySilence;
|
||||
audio_t myPhysical;
|
||||
audio_t myValue;
|
||||
|
||||
AudioGenerator();
|
||||
|
||||
qint64 toFrameTime(qint64 cpuCycples);
|
||||
void generateSamples(audio_t *data, qint64 framesToWrite);
|
||||
void writeEnoughSilence(const qint64 ms);
|
||||
void generateSilence(audio_t * begin, audio_t * end);
|
||||
bool isRunning();
|
||||
};
|
||||
|
||||
#endif // AUDIO_H
|
|
@ -10,6 +10,8 @@
|
|||
#include "SaveState.h"
|
||||
#include "CPU.h"
|
||||
#include "Video.h"
|
||||
#include "Speaker.h"
|
||||
#include "Mockingboard.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QGamepad>
|
||||
|
@ -115,8 +117,6 @@ GlobalOptions GlobalOptions::fromQSettings()
|
|||
options.msGap = settings.value(REG_TIMER, 5).toInt();
|
||||
options.msFullSpeed = settings.value(REG_FULL_SPEED, 5).toInt();
|
||||
options.audioLatency = settings.value(REG_AUDIO_LATENCY, 200).toInt();
|
||||
options.silenceDelay = settings.value(REG_SILENCE_DELAY, 10000).toInt();
|
||||
options.volume = settings.value(REG_VOLUME, 0x0fff).toInt();
|
||||
|
||||
return options;
|
||||
}
|
||||
|
@ -165,17 +165,6 @@ void GlobalOptions::setData(const GlobalOptions & data)
|
|||
QSettings().setValue(REG_AUDIO_LATENCY, this->audioLatency);
|
||||
}
|
||||
|
||||
if (this->silenceDelay != data.silenceDelay)
|
||||
{
|
||||
this->silenceDelay = data.silenceDelay;
|
||||
QSettings().setValue(REG_SILENCE_DELAY, this->silenceDelay);
|
||||
}
|
||||
|
||||
if (this->volume != data.volume)
|
||||
{
|
||||
this->volume = data.volume;
|
||||
QSettings().setValue(REG_VOLUME, this->volume);
|
||||
}
|
||||
}
|
||||
|
||||
void getAppleWinPreferences(PreferenceData & data)
|
||||
|
@ -209,6 +198,9 @@ void getAppleWinPreferences(PreferenceData & data)
|
|||
|
||||
data.apple2Type = GetApple2Type();
|
||||
|
||||
data.speakerVolume = SpkrGetVolume();
|
||||
data.mockingboardVolume = MB_GetVolume();
|
||||
|
||||
const std::string & saveState = Snapshot_GetFilename();
|
||||
if (!saveState.empty())
|
||||
{
|
||||
|
@ -226,6 +218,18 @@ void setAppleWinPreferences(const PreferenceData & currentData, const Preference
|
|||
{
|
||||
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6));
|
||||
|
||||
if (currentData.speakerVolume != newData.speakerVolume)
|
||||
{
|
||||
SpkrSetVolume(newData.speakerVolume, 99);
|
||||
REGSAVE(TEXT(REGVALUE_SPKR_VOLUME), SpkrGetVolume());
|
||||
}
|
||||
|
||||
if (currentData.mockingboardVolume != newData.mockingboardVolume)
|
||||
{
|
||||
MB_SetVolume(newData.mockingboardVolume, 99);
|
||||
REGSAVE(TEXT(REGVALUE_MB_VOLUME), MB_GetVolume());
|
||||
}
|
||||
|
||||
if (currentData.apple2Type != newData.apple2Type)
|
||||
{
|
||||
SetApple2Type(newData.apple2Type);
|
||||
|
|
|
@ -22,8 +22,6 @@ public:
|
|||
int msFullSpeed;
|
||||
|
||||
int audioLatency;
|
||||
int silenceDelay;
|
||||
int volume;
|
||||
|
||||
void setData(const GlobalOptions & data);
|
||||
};
|
||||
|
@ -43,6 +41,8 @@ struct PreferenceData
|
|||
int videoType;
|
||||
bool scanLines;
|
||||
bool verticalBlend;
|
||||
int speakerVolume;
|
||||
int mockingboardVolume;
|
||||
|
||||
std::vector<QString> disks;
|
||||
std::vector<QString> hds;
|
||||
|
|
|
@ -206,8 +206,9 @@ void Preferences::setData(const PreferenceData & data)
|
|||
ui->joystick->setCurrentText(data.options.gamepadName);
|
||||
ui->screenshot->setText(data.options.screenshotTemplate);
|
||||
ui->audio_latency->setValue(data.options.audioLatency);
|
||||
ui->silence_delay->setValue(data.options.silenceDelay);
|
||||
ui->volume->setValue(data.options.volume);
|
||||
|
||||
ui->speaker_volume->setValue(ui->speaker_volume->maximum() - data.speakerVolume);
|
||||
ui->mb_volume->setValue(ui->mb_volume->maximum() - data.mockingboardVolume);
|
||||
|
||||
initialiseDisks(myDisks, data.disks);
|
||||
initialiseDisks(myHDs, data.hds);
|
||||
|
@ -248,8 +249,6 @@ PreferenceData Preferences::getData() const
|
|||
data.options.msFullSpeed = ui->full_ms->value();
|
||||
data.options.screenshotTemplate = ui->screenshot->text();
|
||||
data.options.audioLatency = ui->audio_latency->value();
|
||||
data.options.silenceDelay = ui->silence_delay->value();
|
||||
data.options.volume = ui->volume->value();
|
||||
|
||||
// because index = 0 is None
|
||||
if (ui->joystick->currentIndex() >= 1)
|
||||
|
@ -260,6 +259,8 @@ PreferenceData Preferences::getData() const
|
|||
fillData(myDisks, data.disks);
|
||||
fillData(myHDs, data.hds);
|
||||
|
||||
data.speakerVolume = ui->speaker_volume->maximum() - ui->speaker_volume->value();
|
||||
data.mockingboardVolume = ui->mb_volume->maximum() - ui->mb_volume->value();
|
||||
data.enhancedSpeed = ui->enhanced_speed->isChecked();
|
||||
data.apple2Type = computerTypes[ui->apple2Type->currentIndex()];
|
||||
data.cardInSlot4 = cardsInSlot4[ui->slot4_combo->currentIndex()];
|
||||
|
|
|
@ -566,6 +566,20 @@
|
|||
<string>Audio</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="speaker_volume">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Speaker volume</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
|
@ -583,43 +597,17 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Silence delay (frames)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="silence_delay">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Volume</string>
|
||||
<string>Mockingboard volume</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="volume">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32767</number>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
<widget class="QSlider" name="mb_volume">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "SoundCore.h"
|
||||
#include "NTSC.h"
|
||||
#include "SaveState.h"
|
||||
#include "Speaker.h"
|
||||
#include "Riff.h"
|
||||
|
||||
#include "linux/data.h"
|
||||
|
@ -28,7 +29,6 @@
|
|||
|
||||
#include "emulator.h"
|
||||
#include "memorycontainer.h"
|
||||
#include "audiogenerator.h"
|
||||
#include "qdirectsound.h"
|
||||
#include "gamepadpaddle.h"
|
||||
#include "preferences.h"
|
||||
|
@ -104,6 +104,7 @@ namespace
|
|||
|
||||
DSInit();
|
||||
MB_Initialize();
|
||||
SpkrInitialize();
|
||||
MemInitialize();
|
||||
VideoInitialize();
|
||||
|
||||
|
@ -123,6 +124,7 @@ namespace
|
|||
HD_Destroy();
|
||||
PrintDestroy();
|
||||
MemDestroy();
|
||||
SpkrDestroy();
|
||||
VideoDestroy();
|
||||
MB_Destroy();
|
||||
DSUninit();
|
||||
|
@ -133,7 +135,6 @@ namespace
|
|||
LogDone();
|
||||
RiffFinishWriteFile();
|
||||
|
||||
AudioGenerator::instance().stop();
|
||||
QDirectSound::stop();
|
||||
}
|
||||
|
||||
|
@ -231,8 +232,6 @@ QApple::QApple(QWidget *parent) :
|
|||
myEmulator = new Emulator(ui->mdiArea);
|
||||
myEmulatorWindow = ui->mdiArea->addSubWindow(myEmulator, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
|
||||
connect(AudioGenerator::instance().getAudioOutput(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(on_stateChanged(QAudio::State)));
|
||||
|
||||
readSettings();
|
||||
|
||||
myOptions = GlobalOptions::fromQSettings();
|
||||
|
@ -280,14 +279,8 @@ void QApple::startEmulator()
|
|||
ui->actionStart->trigger();
|
||||
}
|
||||
|
||||
void QApple::on_stateChanged(QAudio::State state)
|
||||
{
|
||||
AudioGenerator::instance().stateChanged(state);
|
||||
}
|
||||
|
||||
void QApple::on_timer()
|
||||
{
|
||||
AudioGenerator::instance().start();
|
||||
QDirectSound::start();
|
||||
|
||||
if (!myElapsedTimer.isValid())
|
||||
|
@ -304,7 +297,6 @@ void QApple::on_timer()
|
|||
// we got ahead of the timer by a lot
|
||||
|
||||
// just check if we got something to write
|
||||
AudioGenerator::instance().writeAudio();
|
||||
QDirectSound::writeAudio();
|
||||
|
||||
// wait next call
|
||||
|
@ -329,6 +321,7 @@ void QApple::on_timer()
|
|||
g_dwCyclesThisFrame += uActualCyclesExecuted;
|
||||
g_CardMgr.GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted);
|
||||
MB_PeriodicUpdate(uActualCyclesExecuted);
|
||||
SpkrUpdate(uActualCyclesExecuted);
|
||||
|
||||
// in case we run more than 1 frame
|
||||
g_dwCyclesThisFrame = g_dwCyclesThisFrame % dwClksPerFrame;
|
||||
|
@ -346,7 +339,6 @@ void QApple::on_timer()
|
|||
}
|
||||
else
|
||||
{
|
||||
AudioGenerator::instance().writeAudio();
|
||||
QDirectSound::writeAudio();
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +356,6 @@ void QApple::stopTimer()
|
|||
void QApple::restartTimeCounters()
|
||||
{
|
||||
// let them restart next time
|
||||
AudioGenerator::instance().stop();
|
||||
QDirectSound::stop();
|
||||
myElapsedTimer.invalidate();
|
||||
}
|
||||
|
@ -469,8 +460,7 @@ void QApple::reloadOptions()
|
|||
myEmulatorWindow->setWindowTitle(QString::fromStdString(g_pAppTitle));
|
||||
|
||||
Paddle::instance() = GamepadPaddle::fromName(myOptions.gamepadName);
|
||||
AudioGenerator::instance().setOptions(myOptions.audioLatency, myOptions.silenceDelay, myOptions.volume);
|
||||
QDirectSound::setOptions(myOptions.audioLatency, myOptions.silenceDelay, myOptions.volume);
|
||||
QDirectSound::setOptions(myOptions.audioLatency);
|
||||
}
|
||||
|
||||
void QApple::on_actionSave_state_triggered()
|
||||
|
|
|
@ -75,8 +75,6 @@ private slots:
|
|||
|
||||
void on_actionSwap_disks_triggered();
|
||||
|
||||
void on_stateChanged(QAudio::State state);
|
||||
|
||||
void on_actionLoad_state_from_triggered();
|
||||
|
||||
void on_actionNext_video_mode_triggered();
|
||||
|
|
|
@ -23,7 +23,6 @@ SOURCES += main.cpp\
|
|||
QHexView/document/qhexmetadata.cpp \
|
||||
QHexView/document/qhexrenderer.cpp \
|
||||
QHexView/qhexview.cpp \
|
||||
audiogenerator.cpp \
|
||||
loggingcategory.cpp \
|
||||
options.cpp \
|
||||
qapple.cpp \
|
||||
|
@ -50,7 +49,6 @@ HEADERS += qapple.h \
|
|||
QHexView/document/qhexmetadata.h \
|
||||
QHexView/document/qhexrenderer.h \
|
||||
QHexView/qhexview.h \
|
||||
audiogenerator.h \
|
||||
emulator.h \
|
||||
loggingcategory.h \
|
||||
options.h \
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace
|
|||
void stop();
|
||||
void writeAudio();
|
||||
void stateChanged(QAudio::State state);
|
||||
void setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume);
|
||||
void setOptions(const qint32 initialSilence);
|
||||
|
||||
private:
|
||||
IDirectSoundBuffer * myBuffer;
|
||||
|
@ -33,8 +33,8 @@ namespace
|
|||
|
||||
// options
|
||||
qint32 myInitialSilence;
|
||||
qint32 mySilenceDelay;
|
||||
|
||||
void setVolume();
|
||||
bool isRunning();
|
||||
void initialise();
|
||||
void writeEnoughSilence(const qint64 ms);
|
||||
|
@ -46,7 +46,6 @@ namespace
|
|||
DirectSoundGenerator::DirectSoundGenerator(IDirectSoundBuffer * buffer) : myBuffer(buffer)
|
||||
{
|
||||
myInitialSilence = 200;
|
||||
mySilenceDelay = 10000;
|
||||
}
|
||||
|
||||
void DirectSoundGenerator::initialise()
|
||||
|
@ -64,10 +63,9 @@ namespace
|
|||
myAudioFormat = myAudioOutput->format();
|
||||
}
|
||||
|
||||
void DirectSoundGenerator::setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume)
|
||||
void DirectSoundGenerator::setOptions(const qint32 initialSilence)
|
||||
{
|
||||
myInitialSilence = std::max(0, initialSilence);
|
||||
mySilenceDelay = std::max(0, silenceDelay);
|
||||
}
|
||||
|
||||
bool DirectSoundGenerator::isRunning()
|
||||
|
@ -90,6 +88,14 @@ namespace
|
|||
return false;
|
||||
}
|
||||
|
||||
void DirectSoundGenerator::setVolume()
|
||||
{
|
||||
LONG dwVolume = 0;
|
||||
myBuffer->GetVolume(&dwVolume);
|
||||
const qreal volume = - qreal(dwVolume) / DSBVOLUME_MIN + 1.0;
|
||||
myAudioOutput->setVolume(volume);
|
||||
}
|
||||
|
||||
void DirectSoundGenerator::start()
|
||||
{
|
||||
if (isRunning())
|
||||
|
@ -119,6 +125,8 @@ namespace
|
|||
|
||||
qDebug(appleAudio) << "Restarting the AudioGenerator";
|
||||
|
||||
setVolume();
|
||||
|
||||
const int bytesSize = myAudioOutput->bufferSize();
|
||||
const qint32 frameSize = myAudioFormat.framesForBytes(bytesSize);
|
||||
|
||||
|
@ -245,12 +253,12 @@ namespace QDirectSound
|
|||
}
|
||||
}
|
||||
|
||||
void setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume)
|
||||
void setOptions(const qint32 initialSilence)
|
||||
{
|
||||
for (auto & it : activeSoundGenerators)
|
||||
{
|
||||
const std::shared_ptr<DirectSoundGenerator> & generator = it.second;
|
||||
generator->setOptions(initialSilence, silenceDelay, volume);
|
||||
generator->setOptions(initialSilence);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace QDirectSound
|
|||
void start();
|
||||
void stop();
|
||||
void writeAudio();
|
||||
void setOptions(const qint32 initialSilence, const qint32 silenceDelay, const qint32 volume);
|
||||
void setOptions(const qint32 initialSilence);
|
||||
}
|
||||
|
||||
#endif // DIRECTSOUND_H
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "Harddisk.h"
|
||||
#include "ParallelPrinter.h"
|
||||
#include "SaveState.h"
|
||||
#include "Mockingboard.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -27,6 +28,8 @@ TCHAR VERSIONSTRING[VERSIONSTRING_SIZE] = "xx.yy.zz.ww";
|
|||
|
||||
HANDLE g_hCustomRom = INVALID_HANDLE_VALUE; // Cmd-line specified custom ROM at $C000..$FFFF(16KiB) or $D000..$FFFF(12KiB)
|
||||
|
||||
int g_nCpuCyclesFeedback = 0;
|
||||
|
||||
static bool bLogKeyReadDone = false;
|
||||
static DWORD dwLogKeyReadTickStart;
|
||||
|
||||
|
@ -49,11 +52,6 @@ std::string g_sCurrentDir; // Also Starting Dir. Debugger uses this when lo
|
|||
std::string g_pAppTitle = TITLE_APPLE_2E_ENHANCED;
|
||||
bool g_bRestart = false;
|
||||
CardManager g_CardMgr;
|
||||
const short SPKR_DATA_INIT = (short)0x8000;
|
||||
|
||||
short g_nSpeakerData = SPKR_DATA_INIT;
|
||||
bool g_bQuieterSpeaker = false;
|
||||
SoundType_e soundtype = SOUND_WAVE;
|
||||
|
||||
HINSTANCE g_hInstance = NULL;
|
||||
HWND g_hFrameWindow = NULL;
|
||||
|
@ -232,6 +230,7 @@ void LoadConfiguration(void)
|
|||
JoySetJoyType(JN_JOYSTICK1, dwJoyType);
|
||||
else
|
||||
LoadConfigOldJoystick(JN_JOYSTICK1);
|
||||
#endif
|
||||
|
||||
DWORD dwSoundType;
|
||||
if (REGLOAD(TEXT("Sound Emulation"), &dwSoundType))
|
||||
|
@ -250,6 +249,7 @@ void LoadConfiguration(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
char aySerialPortName[ CSuperSerialCard::SIZEOF_SERIALCHOICE_ITEM ];
|
||||
if (RegLoadString( TEXT("Configuration"),
|
||||
TEXT(REGVALUE_SERIAL_PORT_NAME),
|
||||
|
@ -260,6 +260,7 @@ void LoadConfiguration(void)
|
|||
sg_SSC.SetSerialPortName(aySerialPortName);
|
||||
}
|
||||
#endif
|
||||
|
||||
REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed);
|
||||
|
||||
DWORD dwEnhanceDisk;
|
||||
|
@ -267,24 +268,25 @@ void LoadConfiguration(void)
|
|||
g_CardMgr.GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk ? true : false);
|
||||
|
||||
Config_Load_Video();
|
||||
|
||||
#if 0
|
||||
REGLOAD(TEXT("Uthernet Active"), &tfe_enabled);
|
||||
#endif
|
||||
|
||||
SetCurrentCLK6502();
|
||||
|
||||
//
|
||||
|
||||
DWORD dwTmp;
|
||||
|
||||
#if 0
|
||||
if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp))
|
||||
sg_PropertySheet.SetTheFreezesF8Rom(dwTmp);
|
||||
|
||||
if(REGLOAD(TEXT(REGVALUE_SPKR_VOLUME), &dwTmp))
|
||||
SpkrSetVolume(dwTmp, sg_PropertySheet.GetVolumeMax());
|
||||
SpkrSetVolume(dwTmp, 99);
|
||||
|
||||
if(REGLOAD(TEXT(REGVALUE_MB_VOLUME), &dwTmp))
|
||||
MB_SetVolume(dwTmp, sg_PropertySheet.GetVolumeMax());
|
||||
MB_SetVolume(dwTmp, 99);
|
||||
|
||||
if(REGLOAD(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), &dwTmp))
|
||||
g_bSaveStateOnExit = dwTmp ? true : false;
|
||||
|
@ -301,7 +303,6 @@ void LoadConfiguration(void)
|
|||
|
||||
if(REGLOAD(TEXT(REGVALUE_PRINTER_APPEND), &dwTmp))
|
||||
g_bPrinterAppend = dwTmp ? true : false;
|
||||
#endif
|
||||
|
||||
if(REGLOAD(TEXT(REGVALUE_HDD_ENABLED), &dwTmp))
|
||||
HD_SetEnabled(dwTmp ? true : false);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "Debug.h"
|
||||
|
||||
DWORD extbench = 0;
|
||||
|
||||
void DebugReset(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "YamlHelper.h"
|
||||
#include "Common.h"
|
||||
|
||||
void SpkrLoadSnapshot(YamlLoadHelper&)
|
||||
{
|
||||
}
|
||||
|
||||
void SpkrSaveSnapshot(YamlSaveHelper&)
|
||||
{
|
||||
}
|
||||
|
||||
void SpkrUpdate_Timer()
|
||||
{
|
||||
}
|
|
@ -34,10 +34,6 @@ BYTE JoyReadButton(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycle
|
|||
BYTE JoyReadPosition(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles);
|
||||
void JoyResetPosition(ULONG uExecutedCycles);
|
||||
|
||||
// Speaker
|
||||
|
||||
BYTE SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles);
|
||||
|
||||
// Registry
|
||||
|
||||
BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, DWORD chars);
|
||||
|
|
|
@ -81,7 +81,7 @@ class IDirectSoundBuffer : public IUnknown
|
|||
size_t myPlayPosition = 0;
|
||||
size_t myWritePosition = 0;
|
||||
WORD myStatus = 0;
|
||||
LONG myVolume = DSBVOLUME_MIN;
|
||||
LONG myVolume = DSBVOLUME_MAX;
|
||||
|
||||
public:
|
||||
const size_t bufferSize;
|
||||
|
|
|
@ -23,20 +23,16 @@ void FrameRefreshStatus(int x, bool) { }
|
|||
|
||||
// Keyboard
|
||||
|
||||
BYTE KeybGetKeycode () { return 0; }
|
||||
BYTE KeybGetKeycode () { return 0; }
|
||||
BYTE KeybReadData() { return 0; }
|
||||
BYTE KeybReadFlag() { return 0; }
|
||||
|
||||
// Joystick
|
||||
|
||||
BYTE __stdcall JoyReadButton(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) { return 0; }
|
||||
BYTE __stdcall JoyReadPosition(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) { return 0; }
|
||||
BYTE JoyReadButton(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) { return 0; }
|
||||
BYTE JoyReadPosition(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) { return 0; }
|
||||
void JoyResetPosition(ULONG nCyclesLeft) { }
|
||||
|
||||
// Speaker
|
||||
|
||||
BYTE __stdcall SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) { return 0; }
|
||||
|
||||
// Registry
|
||||
|
||||
BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, DWORD chars) { return FALSE; }
|
||||
|
@ -60,8 +56,3 @@ LONG GetBitmapBits(HBITMAP hbit, LONG cb, LPVOID lpvBits)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL DeleteObject(HGDIOBJ ho)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue