mixers.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include "audio_core/hle/common.h"
  7. #include "audio_core/hle/dsp.h"
  8. namespace DSP {
  9. namespace HLE {
  10. class Mixers final {
  11. public:
  12. Mixers() {
  13. Reset();
  14. }
  15. void Reset();
  16. DspStatus Tick(DspConfiguration& config,
  17. const IntermediateMixSamples& read_samples,
  18. IntermediateMixSamples& write_samples,
  19. const std::array<QuadFrame32, 3>& input);
  20. StereoFrame16 GetOutput() const {
  21. return current_frame;
  22. }
  23. private:
  24. StereoFrame16 current_frame = {};
  25. using OutputFormat = DspConfiguration::OutputFormat;
  26. struct {
  27. std::array<float, 3> intermediate_mixer_volume = {};
  28. bool mixer1_enabled = false;
  29. bool mixer2_enabled = false;
  30. std::array<QuadFrame32, 3> intermediate_mix_buffer = {};
  31. OutputFormat output_format = OutputFormat::Stereo;
  32. } state;
  33. /// INTERNAL: Update our internal state based on the current config.
  34. void ParseConfig(DspConfiguration& config);
  35. /// INTERNAL: Read samples from shared memory that have been modified by the ARM11.
  36. void AuxReturn(const IntermediateMixSamples& read_samples);
  37. /// INTERNAL: Write samples to shared memory for the ARM11 to modify.
  38. void AuxSend(IntermediateMixSamples& write_samples, const std::array<QuadFrame32, 3>& input);
  39. /// INTERNAL: Mix current_frame.
  40. void MixCurrentFrame();
  41. /// INTERNAL: Downmix from quadraphonic to stereo based on status.output_format and accumulate into current_frame.
  42. void DownmixAndMixIntoCurrentFrame(float gain, const QuadFrame32& samples);
  43. /// INTERNAL: Generate DspStatus based on internal state.
  44. DspStatus GetCurrentStatus() const;
  45. };
  46. } // namespace HLE
  47. } // namespace DSP