ARM-E_interpolate_noloop_gnu.s 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. @***********************************************************
  2. @ Function: WT_InterpolateNoLoop
  3. @ Processor: ARM-E
  4. @ Description: the main synthesis function when fetching
  5. @ wavetable samples.
  6. @ C-callable.
  7. @
  8. @ Usage:
  9. @ void WT_InterpolateNoLoop(
  10. @ S_WT_VOICE *pWTVoice,
  11. @ S_WT_FRAME *pWTFrame);
  12. @
  13. @ Copyright Sonic Network Inc. 2004
  14. @****************************************************************
  15. @ Revision Control:
  16. @ $Revision: 496 $
  17. @ $Date: 2006-12-11 14:33:26 -0800 (Mon, 11 Dec 2006) $
  18. @****************************************************************
  19. @
  20. @ where:
  21. @ S_WT_VOICE *pWTVoice
  22. @ PASSED IN: r0
  23. @
  24. @ S_WT_FRAME *pWTFrame;
  25. @ PASSED IN: r1
  26. @****************************************************************
  27. .include "ARM_synth_constants_gnu.inc"
  28. .arm
  29. .text
  30. .global WT_InterpolateNoLoop
  31. @ Register usage
  32. @ --------------
  33. pWTVoice .req r0
  34. pWTFrame .req r1
  35. pOutputBuffer .req r2
  36. numSamples .req r3
  37. phaseIncrement .req r4
  38. pPhaseAccum .req r5
  39. phaseFrac .req r6
  40. phaseFracMask .req r7
  41. tmp0 .req r1 @ reuse register
  42. tmp1 .req r8
  43. tmp2 .req r9
  44. @SaveRegs RLIST {r4-r9,lr}
  45. @RestoreRegs RLIST {r4-r9,pc}
  46. .func WT_InterpolateNoLoop
  47. WT_InterpolateNoLoop:
  48. STMFD sp!, {r4-r9,lr}
  49. @
  50. @ Fetch parameters from structures
  51. @----------------------------------------------------------------
  52. LDR pOutputBuffer, [pWTFrame, #m_pAudioBuffer]
  53. LDR numSamples, [pWTFrame, #m_numSamples]
  54. LDR phaseIncrement, [pWTFrame, #m_phaseIncrement]
  55. LDR pPhaseAccum, [pWTVoice, #m_pPhaseAccum]
  56. LDR phaseFrac, [pWTVoice, #m_phaseFrac]
  57. LDR phaseFracMask,=PHASE_FRAC_MASK
  58. InterpolationLoop:
  59. .ifdef SAMPLES_8_BIT
  60. LDRSB tmp0, [pPhaseAccum] @ tmp0 = x0
  61. LDRSB tmp1, [pPhaseAccum, #1] @ tmp1 = x1
  62. .else
  63. LDRSH tmp0, [pPhaseAccum] @ tmp0 = x0
  64. LDRSH tmp1, [pPhaseAccum, #2] @ tmp1 = x1
  65. .endif
  66. ADD tmp2, phaseIncrement, phaseFrac @ increment pointer here to avoid pipeline stall
  67. SUB tmp1, tmp1, tmp0 @ tmp1 = x1 - x0
  68. SMULBB tmp1, phaseFrac, tmp1 @ tmp1 = phaseFrac * tmp2
  69. @ This section performs a gain adjustment of -12dB for 16-bit samples
  70. @ or +36dB for 8-bit samples. For a high quality synthesizer, the output
  71. @ can be set to full scale, however if the filter is used, it can overflow
  72. @ with certain coefficients and signal sources. In this case, either a
  73. @ saturation operation should take in the filter before scaling back to
  74. @ 16 bits or the signal path should be increased to 18 bits or more.
  75. .ifdef SAMPLES_8_BIT
  76. MOV tmp0, tmp0, LSL #6 @ boost 8-bit signal by 36dB
  77. .else
  78. MOV tmp0, tmp0, ASR #2 @ reduce 16-bit signal by 12dB
  79. .endif
  80. ADD tmp1, tmp0, tmp1, ASR #(NUM_EG1_FRAC_BITS-6) @ tmp1 = tmp0 + (tmp1 >> (15-6))
  81. @ = x0 + f * (x1 - x0) == interpolated result
  82. STRH tmp1, [pOutputBuffer], #NEXT_OUTPUT_PCM @ *pOutputBuffer++ = interpolated result
  83. @ carry overflow from fraction to integer portion
  84. ADD pPhaseAccum, pPhaseAccum, tmp2, LSR #(NUM_PHASE_FRAC_BITS - NEXT_INPUT_PCM_SHIFT)
  85. AND phaseFrac, tmp2, phaseFracMask @ nphaseFrac = frac part
  86. SUBS numSamples, numSamples, #1
  87. BGT InterpolationLoop
  88. @ Clean up and store any changes that were caused during the loop
  89. @----------------------------------------------------------------
  90. @ update and store phase
  91. STR pPhaseAccum, [pWTVoice, #m_pPhaseAccum]
  92. STR phaseFrac, [pWTVoice, #m_phaseFrac]
  93. @
  94. @ Return to calling function
  95. @----------------------------------------------------------------
  96. LDMFD sp!,{r4-r9,lr}
  97. BX lr
  98. .endfunc
  99. .end