Lime3DS/src/core/frontend/mic.cpp

63 lines
1.7 KiB
C++
Raw Normal View History

2019-03-06 19:16:43 +01:00
// Copyright 2019 Citra Emulator Project
2019-02-27 23:13:51 +01:00
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
2019-03-05 06:47:24 +01:00
#include <array>
2019-02-27 23:13:51 +01:00
#include "core/frontend/mic.h"
#include "core/hle/service/mic_u.h"
2019-03-05 06:47:24 +01:00
namespace Frontend::Mic {
constexpr std::array<u8, 32> NOISE_SAMPLE_8_BIT = {
0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0xFF, 0xFF, 0xFF, 0x8E, 0xFF,
0xF4, 0xE1, 0xBF, 0x9A, 0x71, 0x58, 0x5B, 0x5F, 0x62, 0xC2, 0x25, 0x05, 0x01, 0x01, 0x01, 0x01};
2019-03-06 19:16:43 +01:00
constexpr std::array<u8, 32> NOISE_SAMPLE_16_BIT = {
2019-03-05 06:47:24 +01:00
0x64, 0x61, 0x74, 0x61, 0x56, 0xD7, 0x00, 0x00, 0x48, 0xF7, 0x86, 0x05, 0x77, 0x1A, 0xF4, 0x1F,
2019-03-06 19:16:43 +01:00
0x28, 0x0F, 0x6B, 0xEB, 0x1C, 0xC0, 0xCB, 0x9D, 0x46, 0x90, 0xDF, 0x98, 0xEA, 0xAE, 0xB5, 0xC4};
Interface::~Interface() = default;
void NullMic::StartSampling(const Parameters& params) {
parameters = params;
is_sampling = true;
}
void NullMic::StopSampling() {
is_sampling = false;
}
void NullMic::AdjustSampleRate(u32 sample_rate) {
parameters.sample_rate = sample_rate;
}
Samples NullMic::Read() {
return {};
}
2019-03-05 06:47:24 +01:00
StaticMic::StaticMic()
: CACHE_8_BIT{NOISE_SAMPLE_8_BIT.begin(), NOISE_SAMPLE_8_BIT.end()},
CACHE_16_BIT{NOISE_SAMPLE_16_BIT.begin(), NOISE_SAMPLE_16_BIT.end()} {}
StaticMic::~StaticMic() = default;
2019-03-06 19:16:43 +01:00
void StaticMic::StartSampling(const Parameters& params) {
2019-03-05 06:47:24 +01:00
sample_rate = params.sample_rate;
sample_size = params.sample_size;
parameters = params;
is_sampling = true;
}
void StaticMic::StopSampling() {
is_sampling = false;
}
void StaticMic::AdjustSampleRate(u32 sample_rate) {}
Samples StaticMic::Read() {
return (sample_size == 8) ? CACHE_8_BIT : CACHE_16_BIT;
}
2019-02-27 23:13:51 +01:00
2019-03-05 06:47:24 +01:00
} // namespace Frontend::Mic