citra/src/core/frontend/mic.cpp

87 lines
4.6 KiB
C++
Raw Normal View History

2019-02-27 23:13:51 +01:00
// Copyright 2018 Citra Emulator Project
// 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};
constexpr std::array<u8, 512> NOISE_SAMPLE_16_BIT = {
0x64, 0x61, 0x74, 0x61, 0x56, 0xD7, 0x00, 0x00, 0x48, 0xF7, 0x86, 0x05, 0x77, 0x1A, 0xF4, 0x1F,
0x28, 0x0F, 0x6B, 0xEB, 0x1C, 0xC0, 0xCB, 0x9D, 0x46, 0x90, 0xDF, 0x98, 0xEA, 0xAE, 0xB5, 0xC4,
0x9D, 0xCE, 0xB6, 0xC9, 0xDF, 0xBD, 0x82, 0xBA, 0x83, 0xCD, 0x57, 0xF9, 0x96, 0x30, 0x2C, 0x5B,
0x29, 0x64, 0xD3, 0x46, 0x0D, 0x12, 0x3E, 0xDE, 0x00, 0xBD, 0x74, 0xAE, 0xF0, 0xA4, 0x91, 0x93,
0x02, 0x80, 0x00, 0x80, 0x03, 0x80, 0x6F, 0xAA, 0x8E, 0xE8, 0xEE, 0x1A, 0x2B, 0x2C, 0xC6, 0x18,
0xF8, 0xED, 0xC2, 0xBE, 0x00, 0x99, 0xC1, 0x82, 0x00, 0x80, 0xA6, 0x8A, 0x37, 0xA8, 0x6B, 0xCE,
0x20, 0xEF, 0xD0, 0xFD,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x70, 0xEB,
0xF2, 0x0F, 0xE1, 0x15, 0x66, 0xEC, 0xC7, 0xB0, 0xE7, 0x93, 0x9D, 0xAD, 0xD1, 0xE6, 0xD3, 0x0D,
0xAC, 0x00, 0xB2, 0xC7, 0x5D, 0x8B, 0x00, 0x80, 0xA1, 0x88, 0x14, 0xBE, 0xDF, 0xFB, 0xCF, 0x32,
0xD8, 0x5B, 0x0F, 0x6F, 0x6C, 0x62, 0xD9, 0x33, 0x76, 0xF3, 0xD6, 0xBF, 0x41, 0xB3, 0x5C, 0xD1};
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;
void StaticMic::StartSampling(Parameters params) {
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
static std::shared_ptr<Mic::Interface> current_mic;
void RegisterMic(std::shared_ptr<Mic::Interface> mic) {
current_mic = mic;
}
std::shared_ptr<Mic::Interface> GetCurrentMic() {
if (!current_mic) {
current_mic = std::make_shared<Mic::NullMic>();
}
return current_mic;
}
2019-03-05 06:47:24 +01:00
} // namespace Frontend::Mic