mirror of
https://github.com/JesseTG/melonds-ds.git
synced 2024-11-23 06:29:46 +00:00
Fix #187
This commit is contained in:
parent
65a54e6c79
commit
7df2496966
@ -16,6 +16,9 @@ a design goal is to avoid a 2.x release for as long as possible.
|
||||
- Fixed encrypted NDS ROMs failing to load without any feedback;
|
||||
loading one without using the native BIOS will now display an error message.
|
||||
[#228](https://github.com/JesseTG/melonds-ds/issues/228)
|
||||
- Fixed Blow mode for emulated microphone input not being implemented
|
||||
despite being available in the core options.
|
||||
[#187](https://github.com/JesseTG/melonds-ds/issues/187)
|
||||
|
||||
## [1.1.7] - 2024-08-20
|
||||
|
||||
|
@ -160,6 +160,7 @@ namespace MelonDsDs {
|
||||
constexpr std::optional<MicInputMode> ParseMicInputMode(std::string_view value) noexcept {
|
||||
if (value == config::values::MICROPHONE) return MicInputMode::HostMic;
|
||||
if (value == config::values::NOISE) return MicInputMode::WhiteNoise;
|
||||
if (value == config::values::BLOW) return MicInputMode::Blow;
|
||||
if (value == config::values::SILENCE) return MicInputMode::None;
|
||||
|
||||
return std::nullopt;
|
||||
|
@ -54,6 +54,7 @@ namespace MelonDsDs {
|
||||
|
||||
enum class MicInputMode {
|
||||
None,
|
||||
Blow,
|
||||
HostMic,
|
||||
WhiteNoise,
|
||||
};
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include <libretro.h>
|
||||
#include <frontend/mic_blow.h>
|
||||
|
||||
#include "config/config.hpp"
|
||||
#include "environment.hpp"
|
||||
@ -126,6 +127,18 @@ void MelonDsDs::MicrophoneState::Read(std::span<int16_t> buffer) noexcept {
|
||||
|
||||
break;
|
||||
}
|
||||
case MicInputMode::Blow: {
|
||||
constexpr size_t MIC_BLOW_LENGTH = sizeof(mic_blow) / sizeof(mic_blow[0]);
|
||||
|
||||
// builtin sample is 16-bit signed PCM
|
||||
// sample rate is 44.1KHz
|
||||
for (int i = 0; i < buffer.size(); ++i) {
|
||||
buffer[i] = static_cast<int16_t>(mic_blow[_blowSampleOffset] ^ 0x8000);
|
||||
_blowSampleOffset = (_blowSampleOffset + 1) % MIC_BLOW_LENGTH;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case MicInputMode::HostMic: {
|
||||
if (_microphone && _microphone->IsActive() && _microphone->Read(buffer)) {
|
||||
// If the microphone is open and turned on, and we read from it successfully...
|
||||
|
@ -53,6 +53,7 @@ namespace MelonDsDs {
|
||||
std::optional<retro::Microphone> _microphone {};
|
||||
MicInputMode _micInputMode = MicInputMode::None;
|
||||
MicButtonMode _micButtonMode = MicButtonMode::Hold;
|
||||
size_t _blowSampleOffset = 0;
|
||||
std::default_random_engine _randomEngine;
|
||||
std::uniform_int_distribution<int16_t> _random {std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()};
|
||||
bool _micButtonDown = false;
|
||||
|
@ -324,6 +324,14 @@ add_python_test(
|
||||
CORE_OPTION melonds_boot_mode=direct
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core accepts microphone input with Blow mode"
|
||||
TEST_MODULE basics.core_accepts_microphone_input
|
||||
CONTENT "${MICRECORD_NDS}"
|
||||
CORE_OPTION melonds_boot_mode=direct
|
||||
CORE_OPTION melonds_mic_input=blow
|
||||
)
|
||||
|
||||
add_python_test(
|
||||
NAME "Core queries device power state"
|
||||
TEST_MODULE basics.core_gets_power_state
|
||||
|
Loading…
Reference in New Issue
Block a user