dsp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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 <cstddef>
  7. #include <memory>
  8. #include <type_traits>
  9. #include "audio_core/hle/common.h"
  10. #include "common/bit_field.h"
  11. #include "common/common_funcs.h"
  12. #include "common/common_types.h"
  13. #include "common/swap.h"
  14. namespace AudioCore {
  15. class Sink;
  16. }
  17. namespace DSP {
  18. namespace HLE {
  19. // The application-accessible region of DSP memory consists of two parts. Both are marked as IO and
  20. // have Read/Write permissions.
  21. //
  22. // First Region: 0x1FF50000 (Size: 0x8000)
  23. // Second Region: 0x1FF70000 (Size: 0x8000)
  24. //
  25. // The DSP reads from each region alternately based on the frame counter for each region much like a
  26. // double-buffer. The frame counter is located as the very last u16 of each region and is
  27. // incremented each audio tick.
  28. constexpr u32 region0_offset = 0x50000;
  29. constexpr u32 region1_offset = 0x70000;
  30. /**
  31. * The DSP is native 16-bit. The DSP also appears to be big-endian. When reading 32-bit numbers from
  32. * its memory regions, the higher and lower 16-bit halves are swapped compared to the little-endian
  33. * layout of the ARM11. Hence from the ARM11's point of view the memory space appears to be
  34. * middle-endian.
  35. *
  36. * Unusually this does not appear to be an issue for floating point numbers. The DSP makes the more
  37. * sensible choice of keeping that little-endian. There are also some exceptions such as the
  38. * IntermediateMixSamples structure, which is little-endian.
  39. *
  40. * This struct implements the conversion to and from this middle-endianness.
  41. */
  42. struct u32_dsp {
  43. u32_dsp() = default;
  44. operator u32() const {
  45. return Convert(storage);
  46. }
  47. void operator=(u32 new_value) {
  48. storage = Convert(new_value);
  49. }
  50. private:
  51. static constexpr u32 Convert(u32 value) {
  52. return (value << 16) | (value >> 16);
  53. }
  54. u32_le storage;
  55. };
  56. #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER)
  57. static_assert(std::is_trivially_copyable<u32_dsp>::value, "u32_dsp isn't trivially copyable");
  58. #endif
  59. // There are 15 structures in each memory region. A table of them in the order they appear in memory
  60. // is presented below:
  61. //
  62. // # First Region DSP Address Purpose Control
  63. // 5 0x8400 DSP Status DSP
  64. // 9 0x8410 DSP Debug Info DSP
  65. // 6 0x8540 Final Mix Samples DSP
  66. // 2 0x8680 Source Status [24] DSP
  67. // 8 0x8710 Compressor Table Application
  68. // 4 0x9430 DSP Configuration Application
  69. // 7 0x9492 Intermediate Mix Samples DSP + App
  70. // 1 0x9E92 Source Configuration [24] Application
  71. // 3 0xA792 Source ADPCM Coefficients [24] Application
  72. // 10 0xA912 Surround Sound Related
  73. // 11 0xAA12 Surround Sound Related
  74. // 12 0xAAD2 Surround Sound Related
  75. // 13 0xAC52 Surround Sound Related
  76. // 14 0xAC5C Surround Sound Related
  77. // 0 0xBFFF Frame Counter Application
  78. //
  79. // #: This refers to the order in which they appear in the DspPipe::Audio DSP pipe.
  80. // See also: DSP::HLE::PipeRead.
  81. //
  82. // Note that the above addresses do vary slightly between audio firmwares observed; the addresses
  83. // are not fixed in stone. The addresses above are only an examplar; they're what this
  84. // implementation does and provides to applications.
  85. //
  86. // Application requests the DSP service to convert DSP addresses into ARM11 virtual addresses using
  87. // the ConvertProcessAddressFromDspDram service call. Applications seem to derive the addresses for
  88. // the second region via:
  89. // second_region_dsp_addr = first_region_dsp_addr | 0x10000
  90. //
  91. // Applications maintain most of its own audio state, the memory region is used mainly for
  92. // communication and not storage of state.
  93. //
  94. // In the documentation below, filter and effect transfer functions are specified in the z domain.
  95. // (If you are more familiar with the Laplace transform, z = exp(sT). The z domain is the digital
  96. // frequency domain, just like how the s domain is the analog frequency domain.)
  97. #define INSERT_PADDING_DSPWORDS(num_words) INSERT_PADDING_BYTES(2 * (num_words))
  98. // GCC versions < 5.0 do not implement std::is_trivially_copyable.
  99. // Excluding MSVC because it has weird behaviour for std::is_trivially_copyable.
  100. #if (__GNUC__ >= 5) || defined(__clang__)
  101. #define ASSERT_DSP_STRUCT(name, size) \
  102. static_assert(std::is_standard_layout<name>::value, \
  103. "DSP structure " #name " doesn't use standard layout"); \
  104. static_assert(std::is_trivially_copyable<name>::value, \
  105. "DSP structure " #name " isn't trivially copyable"); \
  106. static_assert(sizeof(name) == (size), "Unexpected struct size for DSP structure " #name)
  107. #else
  108. #define ASSERT_DSP_STRUCT(name, size) \
  109. static_assert(std::is_standard_layout<name>::value, \
  110. "DSP structure " #name " doesn't use standard layout"); \
  111. static_assert(sizeof(name) == (size), "Unexpected struct size for DSP structure " #name)
  112. #endif
  113. struct SourceConfiguration {
  114. struct Configuration {
  115. /// These dirty flags are set by the application when it updates the fields in this struct.
  116. /// The DSP clears these each audio frame.
  117. union {
  118. u32_le dirty_raw;
  119. BitField<0, 1, u32_le> format_dirty;
  120. BitField<1, 1, u32_le> mono_or_stereo_dirty;
  121. BitField<2, 1, u32_le> adpcm_coefficients_dirty;
  122. /// Tends to be set when a looped buffer is queued.
  123. BitField<3, 1, u32_le> partial_embedded_buffer_dirty;
  124. BitField<4, 1, u32_le> partial_reset_flag;
  125. BitField<16, 1, u32_le> enable_dirty;
  126. BitField<17, 1, u32_le> interpolation_dirty;
  127. BitField<18, 1, u32_le> rate_multiplier_dirty;
  128. BitField<19, 1, u32_le> buffer_queue_dirty;
  129. BitField<20, 1, u32_le> loop_related_dirty;
  130. /// Tends to also be set when embedded buffer is updated.
  131. BitField<21, 1, u32_le> play_position_dirty;
  132. BitField<22, 1, u32_le> filters_enabled_dirty;
  133. BitField<23, 1, u32_le> simple_filter_dirty;
  134. BitField<24, 1, u32_le> biquad_filter_dirty;
  135. BitField<25, 1, u32_le> gain_0_dirty;
  136. BitField<26, 1, u32_le> gain_1_dirty;
  137. BitField<27, 1, u32_le> gain_2_dirty;
  138. BitField<28, 1, u32_le> sync_dirty;
  139. BitField<29, 1, u32_le> reset_flag;
  140. BitField<30, 1, u32_le> embedded_buffer_dirty;
  141. };
  142. // Gain control
  143. /**
  144. * Gain is between 0.0-1.0. This determines how much will this source appear on each of the
  145. * 12 channels that feed into the intermediate mixers. Each of the three intermediate mixers
  146. * is fed two left and two right channels.
  147. */
  148. float_le gain[3][4];
  149. // Interpolation
  150. /// Multiplier for sample rate. Resampling occurs with the selected interpolation method.
  151. float_le rate_multiplier;
  152. enum class InterpolationMode : u8 {
  153. Polyphase = 0,
  154. Linear = 1,
  155. None = 2,
  156. };
  157. InterpolationMode interpolation_mode;
  158. INSERT_PADDING_BYTES(1); ///< Interpolation related
  159. // Filters
  160. /**
  161. * This is the simplest normalized first-order digital recursive filter.
  162. * The transfer function of this filter is:
  163. * H(z) = b0 / (1 - a1 z^-1)
  164. * Note the feedbackward coefficient is negated.
  165. * Values are signed fixed point with 15 fractional bits.
  166. */
  167. struct SimpleFilter {
  168. s16_le b0;
  169. s16_le a1;
  170. };
  171. /**
  172. * This is a normalised biquad filter (second-order).
  173. * The transfer function of this filter is:
  174. * H(z) = (b0 + b1 z^-1 + b2 z^-2) / (1 - a1 z^-1 - a2 z^-2)
  175. * Nintendo chose to negate the feedbackward coefficients. This differs from standard
  176. * notation as in: https://ccrma.stanford.edu/~jos/filters/Direct_Form_I.html
  177. * Values are signed fixed point with 14 fractional bits.
  178. */
  179. struct BiquadFilter {
  180. s16_le a2;
  181. s16_le a1;
  182. s16_le b2;
  183. s16_le b1;
  184. s16_le b0;
  185. };
  186. union {
  187. u16_le filters_enabled;
  188. BitField<0, 1, u16_le> simple_filter_enabled;
  189. BitField<1, 1, u16_le> biquad_filter_enabled;
  190. };
  191. SimpleFilter simple_filter;
  192. BiquadFilter biquad_filter;
  193. // Buffer Queue
  194. /// A buffer of audio data from the application, along with metadata about it.
  195. struct Buffer {
  196. /// Physical memory address of the start of the buffer
  197. u32_dsp physical_address;
  198. /// This is length in terms of samples.
  199. /// Note that in different buffer formats a sample takes up different number of bytes.
  200. u32_dsp length;
  201. /// ADPCM Predictor (4 bits) and Scale (4 bits)
  202. union {
  203. u16_le adpcm_ps;
  204. BitField<0, 4, u16_le> adpcm_scale;
  205. BitField<4, 4, u16_le> adpcm_predictor;
  206. };
  207. /// ADPCM Historical Samples (y[n-1] and y[n-2])
  208. u16_le adpcm_yn[2];
  209. /// This is non-zero when the ADPCM values above are to be updated.
  210. u8 adpcm_dirty;
  211. /// Is a looping buffer.
  212. u8 is_looping;
  213. /// This value is shown in SourceStatus::previous_buffer_id when this buffer has
  214. /// finished. This allows the emulated application to tell what buffer is currently
  215. /// playing.
  216. u16_le buffer_id;
  217. INSERT_PADDING_DSPWORDS(1);
  218. };
  219. u16_le buffers_dirty; ///< Bitmap indicating which buffers are dirty (bit i -> buffers[i])
  220. Buffer buffers[4]; ///< Queued Buffers
  221. // Playback controls
  222. u32_dsp loop_related;
  223. u8 enable;
  224. INSERT_PADDING_BYTES(1);
  225. u16_le sync; ///< Application-side sync (See also: SourceStatus::sync)
  226. u32_dsp play_position; ///< Position. (Units: number of samples)
  227. INSERT_PADDING_DSPWORDS(2);
  228. // Embedded Buffer
  229. // This buffer is often the first buffer to be used when initiating audio playback,
  230. // after which the buffer queue is used.
  231. u32_dsp physical_address;
  232. /// This is length in terms of samples.
  233. /// Note a sample takes up different number of bytes in different buffer formats.
  234. u32_dsp length;
  235. enum class MonoOrStereo : u16_le {
  236. Mono = 1,
  237. Stereo = 2,
  238. };
  239. enum class Format : u16_le {
  240. PCM8 = 0,
  241. PCM16 = 1,
  242. ADPCM = 2,
  243. };
  244. union {
  245. u16_le flags1_raw;
  246. BitField<0, 2, MonoOrStereo> mono_or_stereo;
  247. BitField<2, 2, Format> format;
  248. BitField<5, 1, u16_le> fade_in;
  249. };
  250. /// ADPCM Predictor (4 bit) and Scale (4 bit)
  251. union {
  252. u16_le adpcm_ps;
  253. BitField<0, 4, u16_le> adpcm_scale;
  254. BitField<4, 4, u16_le> adpcm_predictor;
  255. };
  256. /// ADPCM Historical Samples (y[n-1] and y[n-2])
  257. u16_le adpcm_yn[2];
  258. union {
  259. u16_le flags2_raw;
  260. BitField<0, 1, u16_le> adpcm_dirty; ///< Has the ADPCM info above been changed?
  261. BitField<1, 1, u16_le> is_looping; ///< Is this a looping buffer?
  262. };
  263. /// Buffer id of embedded buffer (used as a buffer id in SourceStatus to reference this
  264. /// buffer).
  265. u16_le buffer_id;
  266. };
  267. Configuration config[num_sources];
  268. };
  269. ASSERT_DSP_STRUCT(SourceConfiguration::Configuration, 192);
  270. ASSERT_DSP_STRUCT(SourceConfiguration::Configuration::Buffer, 20);
  271. struct SourceStatus {
  272. struct Status {
  273. u8 is_enabled; ///< Is this channel enabled? (Doesn't have to be playing anything.)
  274. u8 current_buffer_id_dirty; ///< Non-zero when current_buffer_id changes
  275. u16_le sync; ///< Is set by the DSP to the value of SourceConfiguration::sync
  276. u32_dsp buffer_position; ///< Number of samples into the current buffer
  277. u16_le current_buffer_id; ///< Updated when a buffer finishes playing
  278. INSERT_PADDING_DSPWORDS(1);
  279. };
  280. Status status[num_sources];
  281. };
  282. ASSERT_DSP_STRUCT(SourceStatus::Status, 12);
  283. struct DspConfiguration {
  284. /// These dirty flags are set by the application when it updates the fields in this struct.
  285. /// The DSP clears these each audio frame.
  286. union {
  287. u32_le dirty_raw;
  288. BitField<8, 1, u32_le> mixer1_enabled_dirty;
  289. BitField<9, 1, u32_le> mixer2_enabled_dirty;
  290. BitField<10, 1, u32_le> delay_effect_0_dirty;
  291. BitField<11, 1, u32_le> delay_effect_1_dirty;
  292. BitField<12, 1, u32_le> reverb_effect_0_dirty;
  293. BitField<13, 1, u32_le> reverb_effect_1_dirty;
  294. BitField<16, 1, u32_le> volume_0_dirty;
  295. BitField<24, 1, u32_le> volume_1_dirty;
  296. BitField<25, 1, u32_le> volume_2_dirty;
  297. BitField<26, 1, u32_le> output_format_dirty;
  298. BitField<27, 1, u32_le> limiter_enabled_dirty;
  299. BitField<28, 1, u32_le> headphones_connected_dirty;
  300. };
  301. /// The DSP has three intermediate audio mixers. This controls the volume level (0.0-1.0) for
  302. /// each at the final mixer.
  303. float_le volume[3];
  304. INSERT_PADDING_DSPWORDS(3);
  305. enum class OutputFormat : u16_le {
  306. Mono = 0,
  307. Stereo = 1,
  308. Surround = 2,
  309. };
  310. OutputFormat output_format;
  311. u16_le limiter_enabled; ///< Not sure of the exact gain equation for the limiter.
  312. u16_le headphones_connected; ///< Application updates the DSP on headphone status.
  313. INSERT_PADDING_DSPWORDS(4); ///< TODO: Surround sound related
  314. INSERT_PADDING_DSPWORDS(2); ///< TODO: Intermediate mixer 1/2 related
  315. u16_le mixer1_enabled;
  316. u16_le mixer2_enabled;
  317. /**
  318. * This is delay with feedback.
  319. * Transfer function:
  320. * H(z) = a z^-N / (1 - b z^-1 + a g z^-N)
  321. * where
  322. * N = frame_count * samples_per_frame
  323. * g, a and b are fixed point with 7 fractional bits
  324. */
  325. struct DelayEffect {
  326. /// These dirty flags are set by the application when it updates the fields in this struct.
  327. /// The DSP clears these each audio frame.
  328. union {
  329. u16_le dirty_raw;
  330. BitField<0, 1, u16_le> enable_dirty;
  331. BitField<1, 1, u16_le> work_buffer_address_dirty;
  332. BitField<2, 1, u16_le> other_dirty; ///< Set when anything else has been changed
  333. };
  334. u16_le enable;
  335. INSERT_PADDING_DSPWORDS(1);
  336. u16_le outputs;
  337. /// The application allocates a block of memory for the DSP to use as a work buffer.
  338. u32_dsp work_buffer_address;
  339. /// Frames to delay by
  340. u16_le frame_count;
  341. // Coefficients
  342. s16_le g; ///< Fixed point with 7 fractional bits
  343. s16_le a; ///< Fixed point with 7 fractional bits
  344. s16_le b; ///< Fixed point with 7 fractional bits
  345. };
  346. DelayEffect delay_effect[2];
  347. struct ReverbEffect {
  348. INSERT_PADDING_DSPWORDS(26); ///< TODO
  349. };
  350. ReverbEffect reverb_effect[2];
  351. INSERT_PADDING_DSPWORDS(4);
  352. };
  353. ASSERT_DSP_STRUCT(DspConfiguration, 196);
  354. ASSERT_DSP_STRUCT(DspConfiguration::DelayEffect, 20);
  355. ASSERT_DSP_STRUCT(DspConfiguration::ReverbEffect, 52);
  356. struct AdpcmCoefficients {
  357. /// Coefficients are signed fixed point with 11 fractional bits.
  358. /// Each source has 16 coefficients associated with it.
  359. s16_le coeff[num_sources][16];
  360. };
  361. ASSERT_DSP_STRUCT(AdpcmCoefficients, 768);
  362. struct DspStatus {
  363. u16_le unknown;
  364. u16_le dropped_frames;
  365. INSERT_PADDING_DSPWORDS(0xE);
  366. };
  367. ASSERT_DSP_STRUCT(DspStatus, 32);
  368. /// Final mixed output in PCM16 stereo format, what you hear out of the speakers.
  369. /// When the application writes to this region it has no effect.
  370. struct FinalMixSamples {
  371. s16_le pcm16[samples_per_frame][2];
  372. };
  373. ASSERT_DSP_STRUCT(FinalMixSamples, 640);
  374. /// DSP writes output of intermediate mixers 1 and 2 here.
  375. /// Writes to this region by the application edits the output of the intermediate mixers.
  376. /// This seems to be intended to allow the application to do custom effects on the ARM11.
  377. /// Values that exceed s16 range will be clipped by the DSP after further processing.
  378. struct IntermediateMixSamples {
  379. struct Samples {
  380. s32_le pcm32[4][samples_per_frame]; ///< Little-endian as opposed to DSP middle-endian.
  381. };
  382. Samples mix1;
  383. Samples mix2;
  384. };
  385. ASSERT_DSP_STRUCT(IntermediateMixSamples, 5120);
  386. /// Compressor table
  387. struct Compressor {
  388. INSERT_PADDING_DSPWORDS(0xD20); ///< TODO
  389. };
  390. /// There is no easy way to implement this in a HLE implementation.
  391. struct DspDebug {
  392. INSERT_PADDING_DSPWORDS(0x130);
  393. };
  394. ASSERT_DSP_STRUCT(DspDebug, 0x260);
  395. struct SharedMemory {
  396. /// Padding
  397. INSERT_PADDING_DSPWORDS(0x400);
  398. DspStatus dsp_status;
  399. DspDebug dsp_debug;
  400. FinalMixSamples final_samples;
  401. SourceStatus source_statuses;
  402. Compressor compressor;
  403. DspConfiguration dsp_configuration;
  404. IntermediateMixSamples intermediate_mix_samples;
  405. SourceConfiguration source_configurations;
  406. AdpcmCoefficients adpcm_coefficients;
  407. struct {
  408. INSERT_PADDING_DSPWORDS(0x100);
  409. } unknown10;
  410. struct {
  411. INSERT_PADDING_DSPWORDS(0xC0);
  412. } unknown11;
  413. struct {
  414. INSERT_PADDING_DSPWORDS(0x180);
  415. } unknown12;
  416. struct {
  417. INSERT_PADDING_DSPWORDS(0xA);
  418. } unknown13;
  419. struct {
  420. INSERT_PADDING_DSPWORDS(0x13A3);
  421. } unknown14;
  422. u16_le frame_counter;
  423. };
  424. ASSERT_DSP_STRUCT(SharedMemory, 0x8000);
  425. union DspMemory {
  426. std::array<u8, 0x80000> raw_memory;
  427. struct {
  428. u8 unused_0[0x50000];
  429. SharedMemory region_0;
  430. u8 unused_1[0x18000];
  431. SharedMemory region_1;
  432. u8 unused_2[0x8000];
  433. };
  434. };
  435. static_assert(offsetof(DspMemory, region_0) == region0_offset,
  436. "DSP region 0 is at the wrong offset");
  437. static_assert(offsetof(DspMemory, region_1) == region1_offset,
  438. "DSP region 1 is at the wrong offset");
  439. extern DspMemory g_dsp_memory;
  440. // Structures must have an offset that is a multiple of two.
  441. static_assert(offsetof(SharedMemory, frame_counter) % 2 == 0,
  442. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  443. static_assert(offsetof(SharedMemory, source_configurations) % 2 == 0,
  444. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  445. static_assert(offsetof(SharedMemory, source_statuses) % 2 == 0,
  446. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  447. static_assert(offsetof(SharedMemory, adpcm_coefficients) % 2 == 0,
  448. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  449. static_assert(offsetof(SharedMemory, dsp_configuration) % 2 == 0,
  450. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  451. static_assert(offsetof(SharedMemory, dsp_status) % 2 == 0,
  452. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  453. static_assert(offsetof(SharedMemory, final_samples) % 2 == 0,
  454. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  455. static_assert(offsetof(SharedMemory, intermediate_mix_samples) % 2 == 0,
  456. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  457. static_assert(offsetof(SharedMemory, compressor) % 2 == 0,
  458. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  459. static_assert(offsetof(SharedMemory, dsp_debug) % 2 == 0,
  460. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  461. static_assert(offsetof(SharedMemory, unknown10) % 2 == 0,
  462. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  463. static_assert(offsetof(SharedMemory, unknown11) % 2 == 0,
  464. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  465. static_assert(offsetof(SharedMemory, unknown12) % 2 == 0,
  466. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  467. static_assert(offsetof(SharedMemory, unknown13) % 2 == 0,
  468. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  469. static_assert(offsetof(SharedMemory, unknown14) % 2 == 0,
  470. "Structures in DSP::HLE::SharedMemory must be 2-byte aligned");
  471. #undef INSERT_PADDING_DSPWORDS
  472. #undef ASSERT_DSP_STRUCT
  473. /// Initialize DSP hardware
  474. void Init();
  475. /// Shutdown DSP hardware
  476. void Shutdown();
  477. /**
  478. * Perform processing and updates state of current shared memory buffer.
  479. * This function is called every audio tick before triggering the audio interrupt.
  480. * @return Whether an audio interrupt should be triggered this frame.
  481. */
  482. bool Tick();
  483. /**
  484. * Set the output sink. This must be called before calling Tick().
  485. * @param sink The sink to which audio will be output to.
  486. */
  487. void SetSink(std::unique_ptr<AudioCore::Sink> sink);
  488. /**
  489. * Enables/Disables audio-stretching.
  490. * Audio stretching is an enhancement that stretches audio to match emulation
  491. * speed to prevent stuttering at the cost of some audio latency.
  492. * @param enable true to enable, false to disable.
  493. */
  494. void EnableStretching(bool enable);
  495. } // namespace HLE
  496. } // namespace DSP