common.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 <algorithm>
  6. #include <array>
  7. #include "common/common_types.h"
  8. namespace DSP {
  9. namespace HLE {
  10. constexpr int num_sources = 24;
  11. constexpr int samples_per_frame = 160; ///< Samples per audio frame at native sample rate
  12. /// The final output to the speakers is stereo. Preprocessing output in Source is also stereo.
  13. using StereoFrame16 = std::array<std::array<s16, 2>, samples_per_frame>;
  14. /// The DSP is quadraphonic internally.
  15. using QuadFrame32 = std::array<std::array<s32, 4>, samples_per_frame>;
  16. /**
  17. * This performs the filter operation defined by FilterT::ProcessSample on the frame in-place.
  18. * FilterT::ProcessSample is called sequentially on the samples.
  19. */
  20. template<typename FrameT, typename FilterT>
  21. void FilterFrame(FrameT& frame, FilterT& filter) {
  22. std::transform(frame.begin(), frame.end(), frame.begin(), [&filter](const auto& sample) {
  23. return filter.ProcessSample(sample);
  24. });
  25. }
  26. } // namespace HLE
  27. } // namespace DSP