eas_chorusdata.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*----------------------------------------------------------------------------
  2. *
  3. * File:
  4. * eas_chorusdata.h
  5. *
  6. * Contents and purpose:
  7. * Contains the prototypes for the Chorus effect.
  8. *
  9. *
  10. * Copyright Sonic Network Inc. 2006
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. *
  23. *----------------------------------------------------------------------------
  24. * Revision Control:
  25. * $Revision: 309 $
  26. * $Date: 2006-09-12 18:52:45 -0700 (Tue, 12 Sep 2006) $
  27. *----------------------------------------------------------------------------
  28. */
  29. #ifndef _EAS_CHORUS_H
  30. #define _EAS_CHORUS_H
  31. #include "eas_types.h"
  32. #include "eas_audioconst.h"
  33. //defines for chorus
  34. #define EAS_CHORUS_BYPASS_DEFAULT 1
  35. #define EAS_CHORUS_PRESET_DEFAULT 0
  36. #define EAS_CHORUS_RATE_DEFAULT 30
  37. #define EAS_CHORUS_DEPTH_DEFAULT 39
  38. #define EAS_CHORUS_LEVEL_DEFAULT 32767
  39. #define EAS_CHORUS_LEVEL_MIN 0
  40. #define EAS_CHORUS_LEVEL_MAX 32767
  41. #define EAS_CHORUS_RATE_MIN 10
  42. #define EAS_CHORUS_RATE_MAX 50
  43. #define EAS_CHORUS_DEPTH_MIN 15
  44. #define EAS_CHORUS_DEPTH_MAX 60
  45. #define CHORUS_SIZE_MS 20
  46. #define CHORUS_L_SIZE ((CHORUS_SIZE_MS*_OUTPUT_SAMPLE_RATE)/1000)
  47. #define CHORUS_R_SIZE CHORUS_L_SIZE
  48. #define CHORUS_SHAPE_SIZE 128
  49. #define CHORUS_DELAY_MS 10
  50. #define CHORUS_MAX_TYPE 4 // any Chorus numbers larger than this are invalid
  51. typedef struct
  52. {
  53. EAS_I16 m_nRate;
  54. EAS_I16 m_nDepth;
  55. EAS_I16 m_nLevel;
  56. } S_CHORUS_PRESET;
  57. typedef struct
  58. {
  59. S_CHORUS_PRESET m_sPreset[CHORUS_MAX_TYPE]; //array of presets
  60. } S_CHORUS_PRESET_BANK;
  61. /* parameters for each Chorus */
  62. typedef struct
  63. {
  64. EAS_I32 lfoLPhase;
  65. EAS_I32 lfoRPhase;
  66. EAS_I16 chorusIndexL;
  67. EAS_I16 chorusIndexR;
  68. EAS_U16 chorusTapPosition;
  69. EAS_I16 m_nRate;
  70. EAS_I16 m_nDepth;
  71. EAS_I16 m_nLevel;
  72. //delay lines used by the chorus, longer would sound better
  73. EAS_PCM chorusDelayL[CHORUS_L_SIZE];
  74. EAS_PCM chorusDelayR[CHORUS_R_SIZE];
  75. EAS_BOOL bypass;
  76. EAS_I8 preset;
  77. EAS_I16 m_nCurrentChorus; // preset number for current Chorus
  78. EAS_I16 m_nNextChorus; // preset number for next Chorus
  79. S_CHORUS_PRESET pPreset;
  80. S_CHORUS_PRESET_BANK m_sPreset;
  81. } S_CHORUS_OBJECT;
  82. /*----------------------------------------------------------------------------
  83. * WeightedTap()
  84. *----------------------------------------------------------------------------
  85. * Purpose: Does fractional array look-up using linear interpolation
  86. *
  87. * first convert indexDesired to actual desired index by taking into account indexReference
  88. * then do linear interpolation between two actual samples using fractional part
  89. *
  90. * Inputs:
  91. * array: pointer to array of signed 16 bit values, typically either PCM data or control data
  92. * indexReference: the circular buffer relative offset
  93. * indexDesired: the fractional index we are looking up (16 bits index + 16 bits fraction)
  94. * indexLimit: the total size of the array, used to compute buffer wrap
  95. *
  96. * Outputs:
  97. * Value from the input array, linearly interpolated between two actual data values
  98. *
  99. *----------------------------------------------------------------------------
  100. */
  101. static EAS_I16 WeightedTap(const EAS_I16 *array, EAS_I16 indexReference, EAS_I32 indexDesired, EAS_I16 indexLimit);
  102. /*----------------------------------------------------------------------------
  103. * ChorusReadInPresets()
  104. *----------------------------------------------------------------------------
  105. * Purpose: sets global Chorus preset bank to defaults
  106. *
  107. * Inputs:
  108. *
  109. * Outputs:
  110. *
  111. *----------------------------------------------------------------------------
  112. */
  113. static EAS_RESULT ChorusReadInPresets(S_CHORUS_OBJECT *pChorusData);
  114. /*----------------------------------------------------------------------------
  115. * ChorusUpdate
  116. *----------------------------------------------------------------------------
  117. * Purpose:
  118. * Update the Chorus preset parameters as required
  119. *
  120. * Inputs:
  121. *
  122. * Outputs:
  123. *
  124. *
  125. * Side Effects:
  126. * - chorus paramters will be changed
  127. * - m_nCurrentChorus := m_nNextChorus
  128. *----------------------------------------------------------------------------
  129. */
  130. static EAS_RESULT ChorusUpdate(S_CHORUS_OBJECT* pChorusData);
  131. #endif /* #ifndef _EAS_CHORUSDATA_H */