Add audio namespace inside of emu
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
void Apu::Init() {
|
void Apu::Init() {
|
||||||
// Set the clock frequency
|
// Set the clock frequency
|
||||||
@@ -134,6 +135,7 @@ void Apu::WriteDspMemory(uint16_t address, uint8_t value) {
|
|||||||
dsp_.WriteGlobalReg(address, value);
|
dsp_.WriteGlobalReg(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -130,6 +131,7 @@ class Apu : public Observer {
|
|||||||
std::function<void()> ready_callback_;
|
std::function<void()> ready_callback_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
void DigitalSignalProcessor::Reset() {}
|
void DigitalSignalProcessor::Reset() {}
|
||||||
|
|
||||||
@@ -37,7 +38,8 @@ uint8_t DigitalSignalProcessor::ReadVoiceReg(uint8_t voice, uint8_t reg) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DigitalSignalProcessor::WriteVoiceReg(uint8_t voice, uint8_t reg, uint8_t value) {
|
void DigitalSignalProcessor::WriteVoiceReg(uint8_t voice, uint8_t reg,
|
||||||
|
uint8_t value) {
|
||||||
voice %= kNumVoices;
|
voice %= kNumVoices;
|
||||||
switch (reg % kNumVoiceRegs) {
|
switch (reg % kNumVoiceRegs) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -69,9 +71,13 @@ void DigitalSignalProcessor::WriteVoiceReg(uint8_t voice, uint8_t reg, uint8_t v
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the callbacks
|
// Set the callbacks
|
||||||
void DigitalSignalProcessor::SetSampleFetcher(SampleFetcher fetcher) { sample_fetcher_ = fetcher; }
|
void DigitalSignalProcessor::SetSampleFetcher(SampleFetcher fetcher) {
|
||||||
|
sample_fetcher_ = fetcher;
|
||||||
|
}
|
||||||
|
|
||||||
void DigitalSignalProcessor::SetSamplePusher(SamplePusher pusher) { sample_pusher_ = pusher; }
|
void DigitalSignalProcessor::SetSamplePusher(SamplePusher pusher) {
|
||||||
|
sample_pusher_ = pusher;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t DigitalSignalProcessor::DecodeSample(uint8_t voice_num) {
|
int16_t DigitalSignalProcessor::DecodeSample(uint8_t voice_num) {
|
||||||
Voice const& voice = voices_[voice_num];
|
Voice const& voice = voices_[voice_num];
|
||||||
@@ -82,7 +88,8 @@ int16_t DigitalSignalProcessor::DecodeSample(uint8_t voice_num) {
|
|||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t DigitalSignalProcessor::ProcessSample(uint8_t voice_num, int16_t sample) {
|
int16_t DigitalSignalProcessor::ProcessSample(uint8_t voice_num,
|
||||||
|
int16_t sample) {
|
||||||
Voice const& voice = voices_[voice_num];
|
Voice const& voice = voices_[voice_num];
|
||||||
|
|
||||||
// Adjust the pitch (for simplicity, we're just adjusting the sample value)
|
// Adjust the pitch (for simplicity, we're just adjusting the sample value)
|
||||||
@@ -276,6 +283,7 @@ void DigitalSignalProcessor::process_envelope(uint8_t voice_num) {
|
|||||||
apply_envelope_to_output(voice_num);
|
apply_envelope_to_output(voice_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
using SampleFetcher = std::function<uint8_t(uint16_t)>;
|
using SampleFetcher = std::function<uint8_t(uint16_t)>;
|
||||||
using SamplePusher = std::function<void(int16_t)>;
|
using SamplePusher = std::function<void(int16_t)>;
|
||||||
@@ -308,6 +309,8 @@ class DigitalSignalProcessor {
|
|||||||
// and apply the envelope to the audio output.
|
// and apply the envelope to the audio output.
|
||||||
void process_envelope(uint8_t voice_num);
|
void process_envelope(uint8_t voice_num);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
// Immediate
|
// Immediate
|
||||||
uint8_t Spc700::imm() {
|
uint8_t Spc700::imm() {
|
||||||
@@ -89,6 +90,7 @@ uint16_t Spc700::addr_plus_i_indexed() {
|
|||||||
return read(addr) | (read(addr + 1) << 8);
|
return read(addr) | (read(addr + 1) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
void Spc700::MOV(uint8_t& dest, uint8_t operand) {
|
void Spc700::MOV(uint8_t& dest, uint8_t operand) {
|
||||||
dest = operand;
|
dest = operand;
|
||||||
@@ -356,6 +357,7 @@ void Spc700::SLEEP() {}
|
|||||||
|
|
||||||
void Spc700::STOP() {}
|
void Spc700::STOP() {}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
void Spc700::Reset() {
|
void Spc700::Reset() {
|
||||||
PC = 0;
|
PC = 0;
|
||||||
@@ -952,6 +953,7 @@ void Spc700::LogInstruction(uint16_t initial_pc, uint8_t opcode) {
|
|||||||
log_.push_back(log_entry);
|
log_.push_back(log_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
class AudioRam {
|
class AudioRam {
|
||||||
public:
|
public:
|
||||||
@@ -261,6 +262,7 @@ class Spc700 {
|
|||||||
// CBNE DBNZ
|
// CBNE DBNZ
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ uint16_t GetHeaderOffset(const Memory& memory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio_callback(void* userdata, uint8_t* stream, int len) {
|
void audio_callback(void* userdata, uint8_t* stream, int len) {
|
||||||
auto* apu = static_cast<Apu*>(userdata);
|
auto* apu = static_cast<audio::Apu*>(userdata);
|
||||||
auto* buffer = reinterpret_cast<int16_t*>(stream);
|
auto* buffer = reinterpret_cast<int16_t*>(stream);
|
||||||
|
|
||||||
for (int i = 0; i < len / 2; i++) { // Assuming 16-bit samples
|
for (int i = 0; i < len / 2; i++) { // Assuming 16-bit samples
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ class SNES : public DMA {
|
|||||||
// Components of the SNES
|
// Components of the SNES
|
||||||
MemoryImpl memory_;
|
MemoryImpl memory_;
|
||||||
ClockImpl clock_;
|
ClockImpl clock_;
|
||||||
AudioRamImpl audio_ram_;
|
audio::AudioRamImpl audio_ram_;
|
||||||
|
|
||||||
CPU cpu_{memory_, clock_};
|
CPU cpu_{memory_, clock_};
|
||||||
Ppu ppu_{memory_, clock_};
|
Ppu ppu_{memory_, clock_};
|
||||||
Apu apu_{memory_, audio_ram_, clock_};
|
audio::Apu apu_{memory_, audio_ram_, clock_};
|
||||||
|
|
||||||
// Helper classes
|
// Helper classes
|
||||||
ROMInfo rom_info_;
|
ROMInfo rom_info_;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace emu {
|
namespace emu {
|
||||||
|
namespace audio {
|
||||||
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
using testing::Return;
|
using testing::Return;
|
||||||
@@ -461,6 +462,7 @@ TEST_F(Spc700Test, BootIplRomOk) {
|
|||||||
// EXPECT_EQ(spc700.PC, 0xFFC1 + 0x3F);
|
// EXPECT_EQ(spc700.PC, 0xFFC1 + 0x3F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace audio
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
Reference in New Issue
Block a user