CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/HW/StereoResampler.h
Views: 1401
// Copyright (c) 2015- PPSSPP Project and Dolphin Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617// Adapted from Dolphin.1819#pragma once2021#include <cstdint>22#include <atomic>2324#include "Common/CommonTypes.h"2526struct AudioDebugStats;2728class StereoResampler {29public:30StereoResampler();31~StereoResampler();3233// Called from audio threads34unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit, int sampleRate);3536// Called from main thread37// This clamps the samples to 16-bit before starting to work on them.38void PushSamples(const s32* samples, unsigned int num_samples);3940void Clear();4142void GetAudioDebugStats(char *buf, size_t bufSize);43void ResetStatCounters();4445private:46void UpdateBufferSize();4748int m_maxBufsize;49int m_targetBufsize;5051unsigned int m_input_sample_rate = 44100;52int16_t *m_buffer;53std::atomic<u32> m_indexW;54std::atomic<u32> m_indexR;55float m_numLeftI = 0.0f;5657u32 m_frac = 0;58float output_sample_rate_ = 0.0;59int lastBufSize_ = 0;60int lastPushSize_ = 0;61u32 ratio_ = 0;6263int underrunCount_ = 0;64int overrunCount_ = 0;65int underrunCountTotal_ = 0;66int overrunCountTotal_ = 0;6768int droppedSamples_ = 0;6970int64_t inputSampleCount_ = 0;71int64_t outputSampleCount_ = 0;7273double startTime_ = 0.0;74};757677