mirror of
https://github.com/libretro/melonDS.git
synced 2024-11-27 01:50:52 +00:00
Add better mic input
This commit is contained in:
parent
bd4097f791
commit
c1ef036b4f
@ -17,6 +17,7 @@
|
||||
#include "SPU.h"
|
||||
#include "version.h"
|
||||
#include "frontend/FrontendUtil.h"
|
||||
#include "frontend/mic_blow.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "opengl.h"
|
||||
@ -61,6 +62,9 @@ static bool hybrid_options = true;
|
||||
static bool jit_options = true;
|
||||
#endif
|
||||
|
||||
static void Mic_FeedNoise();
|
||||
static u8 micNoiseType;
|
||||
|
||||
enum CurrentRenderer
|
||||
{
|
||||
None,
|
||||
@ -159,7 +163,7 @@ static bool update_option_visibility(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Show/gide Hybrid screen options
|
||||
// Show/hide Hybrid screen options
|
||||
bool hybrid_options_prev = hybrid_options;
|
||||
|
||||
hybrid_options = true;
|
||||
@ -551,6 +555,15 @@ static void check_variables(bool init)
|
||||
Config::DSiSDEnable = 0;
|
||||
}
|
||||
|
||||
var.key = "melonds_mic_input";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
if (!strcmp(var.value, "Blow Noise"))
|
||||
micNoiseType = 1;
|
||||
else
|
||||
micNoiseType = 0;
|
||||
}
|
||||
|
||||
var.key = "melonds_audio_bitrate";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
@ -580,7 +593,7 @@ static void check_variables(bool init)
|
||||
{
|
||||
if (!strcmp(var.value, "disabled"))
|
||||
Config::FirmwareOverrideSettings = true;
|
||||
else if (!strcmp(var.value, "enabled"))
|
||||
else
|
||||
Config::FirmwareOverrideSettings = false;
|
||||
}
|
||||
|
||||
@ -722,9 +735,14 @@ void retro_run(void)
|
||||
|
||||
if (input_state.holding_noise_btn)
|
||||
{
|
||||
s16 tmp[735];
|
||||
for (int i = 0; i < 735; i++) tmp[i] = rand() & 0xFFFF;
|
||||
NDS::MicInputFrame(tmp, 735);
|
||||
if (micNoiseType)
|
||||
Mic_FeedNoise();
|
||||
else
|
||||
{
|
||||
s16 tmp[735];
|
||||
for (int i = 0; i < 735; i++) tmp[i] = rand() & 0xFFFF;
|
||||
NDS::MicInputFrame(tmp, 735);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -751,6 +769,23 @@ void retro_run(void)
|
||||
NDSCart_SRAMManager::Flush();
|
||||
}
|
||||
|
||||
void Mic_FeedNoise()
|
||||
{
|
||||
int sample_len = sizeof(mic_blow) / sizeof(u16);
|
||||
static int sample_pos = 0;
|
||||
|
||||
s16 tmp[735];
|
||||
|
||||
for (int i = 0; i < 735; i++)
|
||||
{
|
||||
tmp[i] = mic_blow[sample_pos];
|
||||
sample_pos++;
|
||||
if (sample_pos >= sample_len) sample_pos = 0;
|
||||
}
|
||||
|
||||
NDS::MicInputFrame(tmp, 735);
|
||||
}
|
||||
|
||||
static bool _handle_load_game(unsigned type, const struct retro_game_info *info)
|
||||
{
|
||||
/*
|
||||
|
@ -249,6 +249,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
||||
"nearest"
|
||||
},
|
||||
#endif
|
||||
{
|
||||
"melonds_mic_input",
|
||||
"Microphone Input",
|
||||
NULL,
|
||||
"Choose the type of noise that will be used as microphone input.",
|
||||
NULL,
|
||||
"audio",
|
||||
{
|
||||
{ "Blow Noise", NULL },
|
||||
{ "White Noise", NULL },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"Blow Noise"
|
||||
},
|
||||
{
|
||||
"melonds_audio_bitrate",
|
||||
"Audio Bitrate",
|
||||
|
Loading…
Reference in New Issue
Block a user