daily pastebin goal
25%
SHARE
TWEET

ahxplay v0.24

8bitbubsy Oct 5th, 2017 (edited) 219 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ** AHXPLAY v0.24 - 21st of June 2018 - https://16-bits.org
  3. ** =======================================================
  4. **               - NOT BIG ENDIAN SAFE! -
  5. **
  6. ** C port of AHX.cpp (Bartman of Abyss) by Olav "8bitbubsy" Sørensen
  7. ** Includes additional fixes from hively tracker (current github code)
  8. **
  9. ** Do NOT use a lower audio rate than 32kHz! This will cause problems
  10. ** with low sample periods (high rates) and BLEP.
  11. **
  12. ** The BLEP (Band-Limited Step) and high-pass filter were coded by aciddose.
  13. ** This makes the replayer sound much similar to a real Amiga 1200.
  14. **
  15. ** You need to link winmm.lib for this to compile (-lwinmm).
  16. ** Alternatively, you can wrap around your own audio callback for using
  17. ** ahxplay on other platforms (read comment near bottom).
  18. **
  19. **
  20. ** ahxplay.h:
  21. **
  22. ** #include <stdint.h>
  23. **
  24. ** int8_t ahxplay_Init(uint32_t outputFreq);
  25. ** int8_t ahxplay_LoadSong(void *Buffer, int32_t Len);
  26. ** int8_t ahxplay_Play(int32_t subSongNr);
  27. ** void ahxplay_Close(void);
  28. ** char *ahxplay_GetSongName(void);
  29. */
  30.  
  31.  
  32. /* == USER ADJUSTABLE SETTINGS == */
  33. #define STEREO_SEP (19)    /* --> Stereo separation in percent - 0 = mono, 100 = hard pan (like Amiga) */
  34. #define NORM_FACTOR (4.0f) /* --> Slightly increase this value if the song is too loud. Decrease if too quiet... */
  35. #define USE_HIGHPASS       /* --> 5.2Hz high-pass filter present in all Amigas - comment out for a speed-up */
  36. #define USE_BLEP           /* --> Reduces some unwanted aliasing (closer to real Amiga) - comment out to disable */
  37. #define AUDIO_BUF_LEN (4096)
  38.  
  39.  
  40. #ifndef _USE_MATH_DEFINES
  41. #define _USE_MATH_DEFINES
  42. #endif
  43.  
  44. #ifndef WIN32_LEAN_AND_MEAN
  45. #define WIN32_LEAN_AND_MEAN
  46. #endif
  47.  
  48. #ifndef true
  49. #define true 1
  50. #define false 0
  51. #endif
  52.  
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <stdint.h>
  56. #include <windows.h>
  57. #include <mmsystem.h>
  58. #include <math.h> // tanf()
  59.  
  60. /* don't modify these defines! */
  61. #define AMIGA_VOICES 4
  62. #define NUM_WAVEFORMS (6 + 6 + 32 + 1)
  63. #define FILTER_ITERATIONS 31
  64. #define BLEP_ZC 8
  65. #define BLEP_OS 5
  66. #define BLEP_SP 5
  67. #define BLEP_NS (BLEP_ZC * BLEP_OS / BLEP_SP)
  68. #define BLEP_RNS 7
  69.  
  70. typedef struct blep_t
  71. {
  72.     int32_t index, samplesLeft;
  73.     float buffer[BLEP_RNS + 1], lastValue;
  74. } blep_t;
  75.  
  76. #define LERP(x, y, z) ((x) + ((y) - (x)) * (z))
  77. #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
  78. #define CLAMP16(i) \
  79. { \
  80.     if ((int16_t)(i) != i) \
  81.         i = 0x7FFF ^ (i >> 31); \
  82. }
  83.  
  84. typedef struct
  85. {
  86.     int32_t Note, Fixed, Waveform, FX[2], FXParam[2];
  87. } AHXPListEntry;
  88.  
  89. typedef struct
  90. {
  91.     int32_t Speed, Length;
  92.     AHXPListEntry *Entries;
  93. } AHXPList;
  94.  
  95. typedef struct
  96. {
  97.     int32_t aFrames, aVolume;
  98.     int32_t dFrames, dVolume;
  99.     int32_t sFrames;
  100.     int32_t rFrames, rVolume;
  101. } AHXEnvelope;
  102.  
  103. typedef struct
  104. {
  105.     char* Name;
  106.     int32_t Volume, WaveLength;
  107.     int32_t FilterLowerLimit, FilterUpperLimit, FilterSpeed;
  108.     int32_t SquareLowerLimit, SquareUpperLimit, SquareSpeed;
  109.     int32_t VibratoDelay, VibratoDepth, VibratoSpeed;
  110.     int32_t HardCutRelease, HardCutReleaseFrames;
  111.     AHXEnvelope Envelope;
  112.     AHXPList PList;
  113. } AHXInstrument;
  114.  
  115. typedef struct
  116. {
  117.     int32_t Track[AMIGA_VOICES], Transpose[AMIGA_VOICES];
  118. } AHXPosition;
  119.  
  120. typedef struct
  121. {
  122.     int32_t Note, Instrument, FX, FXParam;
  123. } AHXStep;
  124.  
  125. typedef struct
  126. {
  127.     int8_t VoiceBuffer[0x280], SquareTempBuffer[0x80], *AudioPointer, *AudioSource;
  128.     int32_t InstrPeriod, TrackPeriod, VibratoPeriod;
  129.     int32_t VoiceVolume, VoicePeriod;
  130.     int32_t Track, Transpose;
  131.     int32_t NextTrack, NextTranspose;
  132.     int32_t ADSRVolume;
  133.     int32_t NoteMaxVolume, PerfSubVolume, TrackMasterVolume;
  134.     int32_t NewWaveform, Waveform, PlantSquare, PlantPeriod, IgnoreSquare;
  135.     int32_t TrackOn, FixedNote;
  136.     int32_t VolumeSlideUp, VolumeSlideDown;
  137.     int32_t HardCut, HardCutRelease, HardCutReleaseF;
  138.     int32_t PeriodSlideSpeed, PeriodSlidePeriod, PeriodSlideLimit, PeriodSlideOn, PeriodSlideWithLimit;
  139.     int32_t PeriodPerfSlideSpeed, PeriodPerfSlidePeriod, PeriodPerfSlideOn;
  140.     int32_t VibratoDelay, VibratoCurrent, VibratoDepth, VibratoSpeed;
  141.     int32_t SquareOn, SquareInit, SquareWait, SquareLowerLimit, SquareUpperLimit, SquarePos, SquareSign, SquareSlidingIn, SquareReverse;
  142.     int32_t FilterOn, FilterInit, FilterWait, FilterLowerLimit, FilterUpperLimit, FilterPos, FilterSign, FilterSpeed, FilterSlidingIn, IgnoreFilter;
  143.     int32_t PerfCurrent, PerfSpeed, PerfWait;
  144.     int32_t WaveLength;
  145.     int32_t NoteDelayWait, NoteDelayOn, NoteCutWait, NoteCutOn;
  146.     int32_t AudioPeriod, AudioVolume;
  147.     AHXEnvelope ADSR;
  148.     AHXInstrument *Instrument;
  149.     AHXPList *PerfList;
  150. } AHXVoice;
  151.  
  152. static struct
  153. {
  154.     char *Name;
  155.     int32_t *Subsongs;
  156.     int32_t Restart, PositionNr, TrackLength, TrackNr, InstrumentNr, SubsongNr;
  157.     int32_t Revision, SpeedMultiplier;
  158.     AHXPosition *Positions;
  159.     AHXStep **Tracks;
  160.     AHXInstrument *Instruments;
  161. } Song;
  162.  
  163. static struct
  164. {
  165.     int8_t LowPasses[(0xFC + 0xFC + 0x80 * 0x1F + 0x80 + 3 * 0x280) * FILTER_ITERATIONS];
  166.     int8_t Triangle04[0x04], Triangle08[0x08], Triangle10[0x10], Triangle20[0x20], Triangle40[0x40], Triangle80[0x80];
  167.     int8_t Sawtooth04[0x04], Sawtooth08[0x08], Sawtooth10[0x10], Sawtooth20[0x20], Sawtooth40[0x40], Sawtooth80[0x80];
  168.     int8_t Squares[0x80 * 32];
  169.     int8_t WhiteNoiseBig[0x280 * 3];
  170.     int8_t HighPasses[(0xFC + 0xFC + 0x80 * 0x1F + 0x80 + 3 * 0x280) * FILTER_ITERATIONS];
  171. } Waves;
  172.  
  173. typedef struct paulaVoice_t
  174. {
  175.     const int8_t *SRC_DAT, *DMA_DAT;
  176.     uint32_t SRC_LEN, DMA_LEN, DMA_POS;
  177.     float SRC_VOL, DELTA, FRAC, LASTDELTA, LASTFRAC, PANL, PANR;
  178. } paulaVoice_t;
  179.  
  180. #if defined(USE_HIGHPASS)
  181. typedef struct lossyIntegrator_t
  182. {
  183.     float buffer[2], coeff[2];
  184. } lossyIntegrator_t;
  185. #endif
  186.  
  187. static const int16_t midFilterTable[31 * (6 + 6 + 0x20 + 1)];
  188. static const int16_t lowFilterTable[31 * (6 + 6 + 0x20 + 1)];
  189. static int8_t *WaveformTab[4], SongLoaded;
  190. static int32_t StepWaitFrames, GetNewPosition, SongEndReached, PatternBreak, MaxTrack;
  191. static int32_t MainVolume, Playing, Tempo, PosNr, PosJump, NoteNr, PosJumpNote, WNRandom;
  192. static int32_t soundBufferSize, samplesPerFrame, samplesLeft;
  193. static float f_outputFreq, *mixerBufferL = NULL, *mixerBufferR = NULL;
  194. static int8_t *winmmBuffer = NULL;
  195. static volatile int8_t mixingMutex, isMixing;
  196. static paulaVoice_t AUD[AMIGA_VOICES];
  197. static AHXVoice Voices[AMIGA_VOICES];
  198. #ifdef USE_BLEP
  199. static blep_t blep[4], blepVol[4];
  200. #endif
  201. #ifdef USE_HIGHPASS
  202. static lossyIntegrator_t filterHi;
  203. #endif
  204.  
  205. const int8_t Offsets[6] = { 0x00, 0x04, 0x04+0x08, 0x04+0x08+0x10, 0x04+0x08+0x10+0x20, 0x04+0x08+0x10+0x20+0x40 };
  206.  
  207. const uint16_t waveformLen[NUM_WAVEFORMS] =
  208. {
  209.     0x04, 0x08, 0x10, 0x20, 0x40, 0x80, // sawtooth
  210.     0x04, 0x08, 0x10, 0x20, 0x40, 0x80, // triangle
  211.  
  212.     // squarewave
  213.     0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
  214.     0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
  215.     0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
  216.     0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
  217.  
  218.     0x280 * 3 // whitenoise
  219. };
  220.  
  221. static const int16_t VibratoTable[64] =
  222. {
  223.     0,24,49,74,97,120,141,161,180,197,212,224,235,244,250,253,255,
  224.     253,250,244,235,224,212,197,180,161,141,120,97,74,49,24,
  225.     0,-24,-49,-74,-97,-120,-141,-161,-180,-197,-212,-224,-235,-244,-250,-253,-255,
  226.     -253,-250,-244,-235,-224,-212,-197,-180,-161,-141,-120,-97,-74,-49,-24
  227. };
  228.  
  229. static const int16_t PeriodTable[1 + (5 * 12)] =
  230. {
  231.     0x0000, 0x0D60, 0x0CA0, 0x0BE8, 0x0B40, 0x0A98, 0x0A00, 0x0970,
  232.     0x08E8, 0x0868, 0x07F0, 0x0780, 0x0714, 0x06B0, 0x0650, 0x05F4,
  233.     0x05A0, 0x054C, 0x0500, 0x04B8, 0x0474, 0x0434, 0x03F8, 0x03C0,
  234.     0x038A, 0x0358, 0x0328, 0x02FA, 0x02D0, 0x02A6, 0x0280, 0x025C,
  235.     0x023A, 0x021A, 0x01FC, 0x01E0, 0x01C5, 0x01AC, 0x0194, 0x017D,
  236.     0x0168, 0x0153, 0x0140, 0x012E, 0x011D, 0x010D, 0x00FE, 0x00F0,
  237.     0x00E2, 0x00D6, 0x00CA, 0x00BE, 0x00B4, 0x00AA, 0x00A0, 0x0097,
  238.     0x008F, 0x0087, 0x007F, 0x0078, 0x0071
  239. };
  240.  
  241. #ifdef USE_BLEP
  242. static const uint32_t blepData[48] =
  243. {
  244.     0x3F7FE1F1, 0x3F7FD548, 0x3F7FD6A3, 0x3F7FD4E3,
  245.     0x3F7FAD85, 0x3F7F2152, 0x3F7DBFAE, 0x3F7ACCDF,
  246.     0x3F752F1E, 0x3F6B7384, 0x3F5BFBCB, 0x3F455CF2,
  247.     0x3F26E524, 0x3F0128C4, 0x3EACC7DC, 0x3E29E86B,
  248.     0x3C1C1D29, 0xBDE4BBE6, 0xBE3AAE04, 0xBE48DEDD,
  249.     0xBE22AD7E, 0xBDB2309A, 0xBB82B620, 0x3D881411,
  250.     0x3DDADBF3, 0x3DE2C81D, 0x3DAAA01F, 0x3D1E769A,
  251.     0xBBC116D7, 0xBD1402E8, 0xBD38A069, 0xBD0C53BB,
  252.     0xBC3FFB8C, 0x3C465FD2, 0x3CEA5764, 0x3D0A51D6,
  253.     0x3CEAE2D5, 0x3C92AC5A, 0x3BE4CBF7, 0x00000000,
  254.     0x00000000, 0x00000000, 0x00000000, 0x00000000,
  255.     0x00000000, 0x00000000, 0x00000000, 0x00000000
  256. };
  257. #endif
  258.  
  259. static void GenerateWaves(void);
  260. static void ProcessStep(int32_t v);
  261. static void ProcessFrame(int32_t v);
  262. static void SetAudio(int32_t v);
  263. static void PListCommandParse(int32_t v, int32_t FX, int32_t FXParam);
  264. static void PlayIRQ(void);
  265.  
  266. char *ahxplay_GetSongName(void)
  267. {
  268.     if (SongLoaded)
  269.         return (Song.Name);
  270.  
  271.     return (NULL);
  272. }
  273.  
  274. static void PaulaRestartDMA(uint8_t i)
  275. {
  276.     AUD[i].FRAC    = 0.0f;
  277.     AUD[i].DMA_POS = 0;
  278.     AUD[i].DMA_DAT = AUD[i].SRC_DAT;
  279.     AUD[i].DMA_LEN = AUD[i].SRC_LEN;
  280. }
  281.  
  282. static void PaulaSetPeriod(uint8_t i, uint16_t period)
  283. {
  284.     if (period == 0)
  285.     {
  286.         AUD[i].DELTA = 0.0f;
  287.     }
  288.     else
  289.     {
  290.         /* confirmed behavior on real Amiga */
  291.         if (period < 113)
  292.             period = 113;
  293.  
  294.         AUD[i].DELTA = (3546895.0f / period) / f_outputFreq;
  295.     }
  296.  
  297.     if (AUD[i].LASTDELTA == 0.0f)
  298.         AUD[i].LASTDELTA = AUD[i].DELTA;
  299. }
  300.  
  301. static void PaulaSetVolume(uint8_t i, uint16_t vol)
  302. {
  303.     vol &= 0x007F;
  304.     if (vol > 0x40)
  305.         vol = 0x40;
  306.  
  307.     AUD[i].SRC_VOL = vol * (1.0f / 64.0f);
  308. }
  309.  
  310. static void PaulaSetLength(uint8_t i, uint16_t len)
  311. {
  312.     AUD[i].SRC_LEN = 2 * len;
  313. }
  314.  
  315. static void PaulaSetData(uint8_t i, const int8_t *src)
  316. {
  317.     AUD[i].SRC_DAT = src;
  318. }
  319.  
  320. #if defined(USE_HIGHPASS)
  321. static void calcCoeffLossyIntegrator(float sr, float hz, lossyIntegrator_t *filter)
  322. {
  323.     filter->coeff[0] = tanf((3.1415927f * hz) / sr);
  324.     filter->coeff[1] = 1.0f / (1.0f + filter->coeff[0]);
  325. }
  326.  
  327. static void clearLossyIntegrator(lossyIntegrator_t *filter)
  328. {
  329.     filter->buffer[0] = 0.0f;
  330.     filter->buffer[1] = 0.0f;
  331. }
  332.  
  333. static inline void lossyIntegrator(lossyIntegrator_t *filter, float *in, float *out)
  334. {
  335.     float output;
  336.  
  337.     /* left channel low-pass */
  338.     output = (filter->coeff[0] * in[0] + filter->buffer[0]) * filter->coeff[1];
  339.     filter->buffer[0] = filter->coeff[0] * (in[0] - output) + output + 1e-10f;
  340.     out[0] = output;
  341.  
  342.     /* right channel low-pass */
  343.     output = (filter->coeff[0] * in[1] + filter->buffer[1]) * filter->coeff[1];
  344.     filter->buffer[1] = filter->coeff[0] * (in[1] - output) + output + 1e-10f;
  345.     out[1] = output;
  346. }
  347.  
  348. static inline void lossyIntegratorHighPass(lossyIntegrator_t *filter, float *in, float *out)
  349. {
  350.     float low[2];
  351.  
  352.     lossyIntegrator(filter, in, low);
  353.  
  354.     out[0] = in[0] - low[0];
  355.     out[1] = in[1] - low[1];
  356. }
  357. #endif
  358.  
  359. static void freeSong(void)
  360. {
  361.     int32_t i;
  362.  
  363.     if (Song.Name != NULL)
  364.     {
  365.         free(Song.Name);
  366.         Song.Name = NULL;
  367.     }
  368.  
  369.     if (Song.Subsongs != NULL)
  370.     {
  371.         free(Song.Subsongs);
  372.         Song.Subsongs = NULL;
  373.     }
  374.  
  375.     if (Song.Positions != NULL)
  376.     {
  377.         free(Song.Positions);
  378.         Song.Positions = NULL;
  379.     }
  380.  
  381.     if (Song.Tracks != NULL)
  382.     {
  383.         for (i = 0; i < MaxTrack+1; ++i)
  384.         {
  385.             if (Song.Tracks[i] != NULL)
  386.             {
  387.                 free(Song.Tracks[i]);
  388.                 Song.Tracks[i] = NULL;
  389.             }
  390.         }
  391.  
  392.         free(Song.Tracks);
  393.         Song.Tracks = NULL;
  394.     }
  395.  
  396.     if (Song.Tracks != NULL)
  397.     {
  398.     }
  399.  
  400.     if (Song.Instruments != NULL)
  401.     {
  402.         for (i = 1; i < Song.InstrumentNr + 1; ++i)
  403.         {
  404.             if (Song.Instruments[i].Name != NULL)
  405.             {
  406.                 free(Song.Instruments[i].Name);
  407.                 Song.Instruments[i].Name = NULL;
  408.             }
  409.  
  410.             if (Song.Instruments[i].PList.Entries != NULL)
  411.             {
  412.                 free(Song.Instruments[i].PList.Entries);
  413.                 Song.Instruments[i].PList.Entries = NULL;
  414.             }
  415.         }
  416.  
  417.         free(Song.Instruments);
  418.         Song.Instruments = NULL;
  419.     }
  420. }
  421.  
  422. #ifdef USE_BLEP
  423. static inline void blepAdd(blep_t *b, float offset, float amplitude)
  424. {
  425.     int8_t n;
  426.     uint32_t i;
  427.     const float *blepSrc;
  428.     float f;
  429.  
  430.     if ((offset < 0.0f) || (offset > 1.0f))
  431.         return;
  432.  
  433.     i  = (uint32_t)(offset * BLEP_SP);
  434.     blepSrc = (const float *)(blepData) + i + BLEP_OS;
  435.  
  436.     f = (offset * BLEP_SP) - i;
  437.     i = b->index;
  438.  
  439.     n = BLEP_NS;
  440.     while (n--)
  441.     {
  442.         b->buffer[i] += (amplitude * LERP(blepSrc[0], blepSrc[1], f));
  443.  
  444.         i++;
  445.         i &= BLEP_RNS;
  446.  
  447.         blepSrc += BLEP_SP;
  448.     }
  449.  
  450.     b->samplesLeft = BLEP_NS;
  451. }
  452.  
  453. static inline float blepRun(blep_t *b)
  454. {
  455.     float blepOutput;
  456.  
  457.     blepOutput = b->buffer[b->index];
  458.     b->buffer[b->index] = 0.0f;
  459.  
  460.     b->index++;
  461.     b->index &= BLEP_RNS;
  462.  
  463.     b->samplesLeft--;
  464.  
  465.     return (blepOutput);
  466. }
  467. #endif
  468.  
  469. static void PlayIRQ(void) /* main music interrupt */
  470. {
  471.     int32_t NextPos;
  472.     uint8_t i;
  473.     AHXVoice *voice;
  474.  
  475.     if (!Playing)
  476.         return;
  477.  
  478.     if (StepWaitFrames <= 0)
  479.     {
  480.         if (GetNewPosition)
  481.         {
  482.             NextPos = ((PosNr + 1) == Song.PositionNr) ? 0 : (PosNr + 1);
  483.  
  484.             for (i = 0; i < AMIGA_VOICES; ++i)
  485.             {
  486.                 voice = &Voices[i];
  487.  
  488.                 voice->Track         = Song.Positions[PosNr].Track[i];
  489.                 voice->Transpose     = Song.Positions[PosNr].Transpose[i];
  490.                 voice->NextTrack     = Song.Positions[NextPos].Track[i];
  491.                 voice->NextTranspose = Song.Positions[NextPos].Transpose[i];
  492.             }
  493.  
  494.             GetNewPosition = false;
  495.         }
  496.  
  497.         for (i = 0; i < AMIGA_VOICES; ++i)
  498.             ProcessStep(i);
  499.  
  500.         StepWaitFrames = Tempo;
  501.     }
  502.  
  503.     for (i = 0; i < AMIGA_VOICES; ++i)
  504.         ProcessFrame(i);
  505.  
  506.     if ((Tempo > 0) && (--StepWaitFrames <= 0))
  507.     {
  508.         if (!PatternBreak)
  509.         {
  510.             if (++NoteNr >= Song.TrackLength)
  511.             {
  512.                 PosJump      = PosNr + 1;
  513.                 PosJumpNote  = 0;
  514.                 PatternBreak = true;
  515.             }
  516.         }
  517.  
  518.         if (PatternBreak)
  519.         {
  520.             PatternBreak = false;
  521.  
  522.             PosNr  = PosJump;
  523.             NoteNr = PosJumpNote;
  524.  
  525.             PosJumpNote = 0;
  526.             PosJump     = 0;
  527.  
  528.             if (PosNr == Song.PositionNr)
  529.             {
  530.                 SongEndReached = true;
  531.                 PosNr = Song.Restart;
  532.             }
  533.  
  534.             GetNewPosition = true;
  535.         }
  536.     }
  537.  
  538.     for (i = 0; i < AMIGA_VOICES; ++i)
  539.         SetAudio(i);
  540. }
  541.  
  542. static void CalcADSR(AHXVoice *v)
  543. {
  544.     int32_t af, df, rf;
  545.  
  546.     af = v->ADSR.aFrames = v->Instrument->Envelope.aFrames;
  547.     df = v->ADSR.dFrames = v->Instrument->Envelope.dFrames;
  548.          v->ADSR.sFrames = v->Instrument->Envelope.sFrames;
  549.     rf = v->ADSR.rFrames = v->Instrument->Envelope.rFrames;
  550.  
  551.     if (af == 0) af = 1;
  552.     if (df == 0) df = 1;
  553.     if (rf == 0) rf = 0;
  554.  
  555.     v->ADSR.aVolume =  (v->Instrument->Envelope.aVolume * 256) / af;
  556.     v->ADSR.dVolume = ((v->Instrument->Envelope.dVolume - v->Instrument->Envelope.aVolume) * 256) / df;
  557.     v->ADSR.rVolume = ((v->Instrument->Envelope.rVolume  -v->Instrument->Envelope.dVolume) * 256) / rf;
  558. }
  559.  
  560. static void ProcessStep(int32_t v)
  561. {
  562.     int32_t i, Note, Instrument, FX, FXParam, t, Neue, Alte, SquareLower, SquareUpper, d3, d4, d6;
  563.     AHXVoice *voice;
  564.     AHXStep *step;
  565.  
  566.     voice = &Voices[v];
  567.  
  568.     if (!voice->TrackOn)
  569.         return;
  570.  
  571.     voice->VolumeSlideUp = voice->VolumeSlideDown = 0;
  572.  
  573.     step = &Song.Tracks[Song.Positions[PosNr].Track[v]][NoteNr];
  574.  
  575.     Note       = step->Note;
  576.     Instrument = step->Instrument;
  577.     FX         = step->FX;
  578.     FXParam    = step->FXParam;
  579.  
  580.     switch (FX)
  581.     {
  582.         case 0x00: // Position Jump HI
  583.         {
  584.             if (((FXParam & 0x0F) > 0) && ((FXParam & 0x0F) <= 9))
  585.                 PosJump = FXParam & 0x0F;
  586.         }
  587.         break;
  588.  
  589.         case 0x05: // Volume Slide + Tone Portamento
  590.         case 0x0A: // Volume Slide
  591.         {
  592.             voice->VolumeSlideDown = FXParam & 0x0F;
  593.             voice->VolumeSlideUp   = FXParam >> 4;
  594.         }
  595.         break;
  596.  
  597.         case 0x0B: // Position Jump
  598.         {
  599.             PosJump = (PosJump * 100) + (FXParam & 0x0F) + ((FXParam >> 4) * 10);
  600.             PatternBreak = true;
  601.         }
  602.         break;
  603.  
  604.         case 0x0D: // Patternbreak
  605.         {
  606.             PosJump = PosNr + 1;
  607.  
  608.             PosJumpNote = (FXParam & 0x0F) + (FXParam >> 4) * 10;
  609.             if (PosJumpNote > Song.TrackLength)
  610.                 PosJumpNote = 0;
  611.  
  612.             PatternBreak = true;
  613.         }
  614.         break;
  615.  
  616.         case 0x0E: // Enhanced commands
  617.         {
  618.             switch (FXParam >> 4)
  619.             {
  620.                 case 0xC: // Note Cut
  621.                 {
  622.                     if ((FXParam & 0x0f) < Tempo)
  623.                     {
  624.                         voice->NoteCutWait = FXParam & 0x0F;
  625.                         if(voice->NoteCutWait)
  626.                         {
  627.                             voice->NoteCutOn      = true;
  628.                             voice->HardCutRelease = false;
  629.                         }
  630.                     }
  631.                 }
  632.                 break;
  633.  
  634.                 case 0xD: // Note Delay
  635.                 {
  636.                     if (voice->NoteDelayOn)
  637.                     {
  638.                         voice->NoteDelayOn = false;
  639.                     }
  640.                     else
  641.                     {
  642.                         if ((FXParam & 0x0f) < Tempo)
  643.                         {
  644.                             voice->NoteDelayWait = FXParam & 0x0F;
  645.                             if (voice->NoteDelayWait)
  646.                             {
  647.                                 voice->NoteDelayOn = true;
  648.                                 return;
  649.                             }
  650.                         }
  651.                     }
  652.                 }
  653.                 break;
  654.             }
  655.         }
  656.         break;
  657.  
  658.         case 0x0F: // Speed
  659.             Tempo = FXParam;
  660.         break;
  661.     }
  662.  
  663.     if (Instrument && (Instrument <= Song.InstrumentNr))
  664.     {
  665.         voice->PerfSubVolume    = 0x40;
  666.         voice->PeriodSlideSpeed = voice->PeriodSlidePeriod = voice->PeriodSlideLimit = 0;
  667.         voice->ADSRVolume       = 0;
  668.         voice->Instrument       = &Song.Instruments[Instrument];
  669.  
  670.         CalcADSR(voice);
  671.  
  672.         voice->WaveLength     = voice->Instrument->WaveLength;
  673.         voice->NoteMaxVolume  = voice->Instrument->Volume;
  674.         voice->VibratoCurrent = 0;
  675.         voice->VibratoDelay   = voice->Instrument->VibratoDelay;
  676.         voice->VibratoDepth   = voice->Instrument->VibratoDepth;
  677.         voice->VibratoSpeed   = voice->Instrument->VibratoSpeed;
  678.         voice->VibratoPeriod  = 0;
  679.         voice->HardCutRelease = voice->Instrument->HardCutRelease;
  680.         voice->HardCut        = voice->Instrument->HardCutReleaseFrames;
  681.         voice->IgnoreSquare   = voice->SquareSlidingIn = 0;
  682.         voice->SquareWait     = voice->SquareOn = 0;
  683.  
  684.         SquareLower = voice->Instrument->SquareLowerLimit >> (5 - voice->WaveLength);
  685.         SquareUpper = voice->Instrument->SquareUpperLimit >> (5 - voice->WaveLength);
  686.  
  687.         if (SquareUpper < SquareLower)
  688.         {
  689.             t = SquareUpper;
  690.             SquareUpper = SquareLower;
  691.             SquareLower = t;
  692.         }
  693.  
  694.         voice->SquareUpperLimit = SquareUpper;
  695.         voice->SquareLowerLimit = SquareLower;
  696.         voice->IgnoreFilter     = voice->FilterWait = voice->FilterOn = 0;
  697.         voice->FilterSlidingIn  = false;
  698.  
  699.         d6 = voice->Instrument->FilterSpeed;
  700.         d3 = voice->Instrument->FilterLowerLimit;
  701.         d4 = voice->Instrument->FilterUpperLimit;
  702.  
  703.         if (d3 & 0x80) d6 |= 0x20;
  704.         if (d4 & 0x80) d6 |= 0x40;
  705.  
  706.         voice->FilterSpeed = d6;
  707.  
  708.         d3 &= ~0x80;
  709.         d4 &= ~0x80;
  710.  
  711.         if (d3 > d4)
  712.         {
  713.             t  = d3;
  714.             d3 = d4;
  715.             d4 = t;
  716.         }
  717.  
  718.         voice->FilterUpperLimit = d4;
  719.         voice->FilterLowerLimit = d3;
  720.  
  721.         voice->FilterPos = 32;
  722.         voice->PerfWait  = voice->PerfCurrent = 0;
  723.         voice->PerfSpeed = voice->Instrument->PList.Speed;
  724.         voice->PerfList  = &voice->Instrument->PList;
  725.     }
  726.  
  727.     voice->PeriodSlideOn = false;
  728.  
  729.     FX &= 0x0F;
  730.  
  731.     switch (FX)
  732.     {
  733.         case 0x09: // Set Squarewave-Offset
  734.         {
  735.             voice->SquarePos    = FXParam >> (5 - voice->WaveLength);
  736.             //voice->PlantSquare  = true;   (bug ?)
  737.             voice->IgnoreSquare = true;
  738.         }
  739.         break;
  740.  
  741.         case 0x03: // Tone Portamento (Period Slide Up/Down w/ Limit)
  742.             if (FXParam != 0)
  743.                 voice->PeriodSlideSpeed = FXParam; // fall through
  744.         case 0x05: // Tone Portamento + Volume Slide
  745.         {
  746.             if (Note)
  747.             {
  748.                 Neue = PeriodTable[Note];
  749.                 Alte = PeriodTable[voice->TrackPeriod];
  750.                 Alte -= Neue;
  751.                 Neue = Alte + voice->PeriodSlidePeriod;
  752.                 if (Neue)
  753.                     voice->PeriodSlideLimit = -Alte;
  754.             }
  755.  
  756.             voice->PeriodSlideOn        = true;
  757.             voice->PeriodSlideWithLimit = true;
  758.  
  759.             Note = 0;
  760.         }
  761.         break;
  762.     }
  763.  
  764.     if (Note)
  765.     {
  766.         voice->TrackPeriod = Note;
  767.         voice->PlantPeriod = true;
  768.     }
  769.  
  770.     switch (FX)
  771.     {
  772.         case 0x01: // Portamento up (Period slide down)
  773.         {
  774.             voice->PeriodSlideSpeed     = -FXParam;
  775.             voice->PeriodSlideOn        = true;
  776.             voice->PeriodSlideWithLimit = false;
  777.         }
  778.         break;
  779.  
  780.         case 0x02: // Portamento down (Period slide up)
  781.         {
  782.             voice->PeriodSlideSpeed     = FXParam;
  783.             voice->PeriodSlideOn        = true;
  784.             voice->PeriodSlideWithLimit = false;
  785.         }
  786.         break;
  787.  
  788.         case 0x04: // Filter override
  789.         {
  790.             if ((FXParam == 0) || (FXParam == 0x40))
  791.                 break;
  792.  
  793.             if (FXParam < 0x40)
  794.             {
  795.                 voice->IgnoreFilter = FXParam;
  796.                 break;
  797.             }
  798.  
  799.             if (FXParam > 0x7F)
  800.                 break;
  801.  
  802.             voice->FilterPos = FXParam - 0x40;
  803.         }
  804.         break;
  805.  
  806.         case 0x0C: // Volume
  807.         {
  808.             FXParam &= 0xFF;
  809.             if (FXParam <= 0x40)
  810.             {
  811.                 voice->NoteMaxVolume = FXParam;
  812.             }
  813.             else
  814.             {
  815.                 FXParam -= 0x50;
  816.                 if (FXParam <= 0x40)
  817.                 {
  818.                     for (i = 0; i < AMIGA_VOICES; ++i)
  819.                         Voices[i].TrackMasterVolume = FXParam;
  820.                 }
  821.                 else
  822.                 {
  823.                     FXParam -= 0xa0 - 0x50;
  824.                     if (FXParam <= 0x40)
  825.                         voice->TrackMasterVolume = FXParam;
  826.                 }
  827.             }
  828.         }
  829.         break;
  830.  
  831.         case 0x0E: // Extended commands
  832.         {
  833.             switch (FXParam >> 4)
  834.             {
  835.                 case 0x1: // Fineslide up (Period fineslide down)
  836.                 {
  837.                     voice->PeriodSlidePeriod -= (FXParam & 0x0F);
  838.                     voice->PlantPeriod = true;
  839.                 }
  840.                 break;
  841.  
  842.                 case 0x2: // Fineslide down (Period fineslide up)
  843.                 {
  844.                     voice->PeriodSlidePeriod += (FXParam & 0x0F);
  845.                     voice->PlantPeriod = true;
  846.                 }
  847.                 break;
  848.  
  849.                 case 0x4: // Vibrato control
  850.                     voice->VibratoDepth = FXParam & 0x0F;
  851.                 break;
  852.  
  853.                 case 0xA: // Finevolume up
  854.                 {
  855.                     voice->NoteMaxVolume += (FXParam & 0x0F);
  856.                     if (voice->NoteMaxVolume > 0x40)
  857.                         voice->NoteMaxVolume = 0x40;
  858.                 }
  859.                 break;
  860.  
  861.                 case 0xB: // Finevolume down
  862.                 {
  863.                     voice->NoteMaxVolume -= (FXParam & 0x0F);
  864.                     if (voice->NoteMaxVolume < 0)
  865.                         voice->NoteMaxVolume = 0;
  866.                 }
  867.                 break;
  868.             }
  869.         }
  870.         break;
  871.     }
  872. }
  873.  
  874. static void ProcessFrame(int32_t v)
  875. {
  876.     int8_t *SquarePtr, *AudioSource;
  877.     int32_t i, d0, d1, d2, d3, NextInstrument, Cur, FMax, Delta, X;
  878.     AHXVoice *voice;
  879.  
  880.     voice = &Voices[v];
  881.  
  882.     if (!voice->TrackOn)
  883.         return;
  884.  
  885.     if (voice->NoteDelayOn)
  886.     {
  887.         if (voice->NoteDelayWait <= 0)
  888.             ProcessStep(v);
  889.         else
  890.             voice->NoteDelayWait--;
  891.     }
  892.  
  893.     if (voice->HardCut)
  894.     {
  895.         if ((NoteNr + 1) < Song.TrackLength)
  896.             NextInstrument = Song.Tracks[voice->Track][NoteNr+1].Instrument;
  897.         else
  898.             NextInstrument = Song.Tracks[voice->NextTrack][0].Instrument;
  899.  
  900.         if (NextInstrument)
  901.         {
  902.             d1 = Tempo - voice->HardCut;
  903.             if (d1 < 0)
  904.                 d1 = 0;
  905.  
  906.             if (!voice->NoteCutOn)
  907.             {
  908.                 voice->NoteCutOn       = true;
  909.                 voice->NoteCutWait     = d1;
  910.                 voice->HardCutReleaseF = -(d1 - Tempo);
  911.             }
  912.             else
  913.             {
  914.                 voice->HardCut = 0;
  915.             }
  916.         }
  917.     }
  918.  
  919.     if (voice->NoteCutOn)
  920.     {
  921.         if (voice->NoteCutWait <= 0)
  922.         {
  923.             voice->NoteCutOn = false;
  924.  
  925.             if (voice->HardCutRelease)
  926.             {
  927.                 voice->ADSR.rVolume = -(voice->ADSRVolume - (voice->Instrument->Envelope.rVolume << 8)) / voice->HardCutReleaseF;
  928.                 voice->ADSR.rFrames = voice->HardCutReleaseF;
  929.                 voice->ADSR.aFrames = voice->ADSR.dFrames = voice->ADSR.sFrames = 0;
  930.             }
  931.             else
  932.             {
  933.                 voice->NoteMaxVolume = 0;
  934.             }
  935.         }
  936.         else
  937.         {
  938.             voice->NoteCutWait--;
  939.         }
  940.     }
  941.  
  942.     if (voice->ADSR.aFrames)
  943.     {
  944.         voice->ADSRVolume += voice->ADSR.aVolume; // Delta
  945.         if (--voice->ADSR.aFrames <= 0)
  946.               voice->ADSRVolume = voice->Instrument->Envelope.aVolume << 8;
  947.  
  948.     }
  949.     else if (voice->ADSR.dFrames)
  950.     {
  951.         voice->ADSRVolume += voice->ADSR.dVolume; // Delta
  952.         if (--voice->ADSR.dFrames <= 0)
  953.               voice->ADSRVolume = voice->Instrument->Envelope.dVolume << 8;
  954.     }
  955.     else if (voice->ADSR.sFrames)
  956.     {
  957.         voice->ADSR.sFrames--;
  958.     }
  959.     else if (voice->ADSR.rFrames)
  960.     {
  961.         voice->ADSRVolume += voice->ADSR.rVolume; // Delta
  962.         if (--voice->ADSR.rFrames <= 0)
  963.               voice->ADSRVolume = voice->Instrument->Envelope.rVolume << 8;
  964.     }
  965.  
  966.     voice->NoteMaxVolume = voice->NoteMaxVolume + voice->VolumeSlideUp - voice->VolumeSlideDown;
  967.     voice->NoteMaxVolume = CLAMP(voice->NoteMaxVolume, 0x00, 0x40);
  968.  
  969.     if (voice->PeriodSlideOn)
  970.     {
  971.         if (voice->PeriodSlideWithLimit)
  972.         {
  973.             d0 = voice->PeriodSlidePeriod - voice->PeriodSlideLimit;
  974.             d2 = voice->PeriodSlideSpeed;
  975.  
  976.             if (d0 > 0)
  977.                 d2 = -d2;
  978.  
  979.             if (d0)
  980.             {
  981.                 d3 = (d0 + d2) ^ d0;
  982.                 if (d3 >= 0)
  983.                     d0 = voice->PeriodSlidePeriod + d2;
  984.                 else
  985.                     d0 = voice->PeriodSlideLimit;
  986.  
  987.                 voice->PeriodSlidePeriod = d0;
  988.                 voice->PlantPeriod       = true;
  989.             }
  990.         }
  991.         else
  992.         {
  993.             voice->PeriodSlidePeriod += voice->PeriodSlideSpeed;
  994.             voice->PlantPeriod = true;
  995.         }
  996.     }
  997.  
  998.     if (voice->VibratoDepth)
  999.     {
  1000.         if (voice->VibratoDelay <= 0)
  1001.         {
  1002.             voice->VibratoPeriod  = (VibratoTable[voice->VibratoCurrent] * voice->VibratoDepth) >> 7;
  1003.             voice->PlantPeriod    = true;
  1004.             voice->VibratoCurrent = (voice->VibratoCurrent + voice->VibratoSpeed) & 0x3F;
  1005.         }
  1006.         else
  1007.         {
  1008.             voice->VibratoDelay--;
  1009.         }
  1010.     }
  1011.  
  1012.     if (voice->PerfList != NULL)
  1013.     {
  1014.         if (voice->Instrument && (voice->PerfCurrent < voice->Instrument->PList.Length))
  1015.         {
  1016.             if (--voice->PerfWait <= 0)
  1017.             {
  1018.                 Cur = voice->PerfCurrent++;
  1019.                 voice->PerfWait = voice->PerfSpeed;
  1020.  
  1021.                 if (voice->PerfList->Entries[Cur].Waveform)
  1022.                 {
  1023.                     voice->Waveform             = voice->PerfList->Entries[Cur].Waveform - 1;
  1024.                     voice->NewWaveform          = true;
  1025.                     voice->PeriodPerfSlideSpeed = voice->PeriodPerfSlidePeriod = 0;
  1026.                 }
  1027.  
  1028.                 voice->PeriodPerfSlideOn = false;
  1029.                 for (i = 0; i < 2; ++i)
  1030.                     PListCommandParse(v, voice->PerfList->Entries[Cur].FX[i] & 0xFF, voice->PerfList->Entries[Cur].FXParam[i] & 0xFF);
  1031.  
  1032.                 if (voice->PerfList->Entries[Cur].Note)
  1033.                 {
  1034.                     voice->InstrPeriod = voice->PerfList->Entries[Cur].Note;
  1035.                     voice->PlantPeriod = true;
  1036.                     voice->FixedNote   = voice->PerfList->Entries[Cur].Fixed;
  1037.                 }
  1038.             }
  1039.         }
  1040.         else
  1041.         {
  1042.             if (voice->PerfWait)
  1043.                 voice->PerfWait--;
  1044.             else
  1045.                 voice->PeriodPerfSlideSpeed = 0;
  1046.         }
  1047.     }
  1048.  
  1049.     if (voice->PeriodPerfSlideOn)
  1050.     {
  1051.         voice->PeriodPerfSlidePeriod -= voice->PeriodPerfSlideSpeed;
  1052.         if (voice->PeriodPerfSlidePeriod)
  1053.             voice->PlantPeriod = true;
  1054.     }
  1055.  
  1056.     if ((voice->Waveform == (3 - 1)) && voice->SquareOn)
  1057.     {
  1058.         if (--voice->SquareWait <= 0)
  1059.         {
  1060.             d1 = voice->SquareLowerLimit;
  1061.             d2 = voice->SquareUpperLimit;
  1062.             d3 = voice->SquarePos;
  1063.  
  1064.             if (voice->SquareInit)
  1065.             {
  1066.                 voice->SquareInit = false;
  1067.  
  1068.                 if (d3 <= d1)
  1069.                 {
  1070.                     voice->SquareSlidingIn = true;
  1071.                     voice->SquareSign      = 1;
  1072.                 }
  1073.                 else if (d3 >= d2)
  1074.                 {
  1075.                     voice->SquareSlidingIn = true;
  1076.                     voice->SquareSign      = -1;
  1077.                 }
  1078.             }
  1079.  
  1080.             if ((d1 == d3) || (d2 == d3))
  1081.             {
  1082.                 if (voice->SquareSlidingIn)
  1083.                     voice->SquareSlidingIn = false;
  1084.                 else
  1085.                     voice->SquareSign = -voice->SquareSign;
  1086.             }
  1087.  
  1088.             d3 += voice->SquareSign;
  1089.  
  1090.             voice->SquarePos   = d3;
  1091.             voice->PlantSquare = true;
  1092.             voice->SquareWait  = voice->Instrument->SquareSpeed;
  1093.         }
  1094.     }
  1095.  
  1096.     if (voice->FilterOn && (--voice->FilterWait <= 0))
  1097.     {
  1098.         d1 = voice->FilterLowerLimit;
  1099.         d2 = voice->FilterUpperLimit;
  1100.         d3 = voice->FilterPos;
  1101.  
  1102.         if (voice->FilterInit)
  1103.         {
  1104.             voice->FilterInit = false;
  1105.  
  1106.             if (d3 <= d1)
  1107.             {
  1108.                 voice->FilterSlidingIn = true;
  1109.                 voice->FilterSign      = 1;
  1110.             }
  1111.             else if (d3 >= d2)
  1112.             {
  1113.                 voice->FilterSlidingIn = true;
  1114.                 voice->FilterSign      = -1;
  1115.             }
  1116.         }
  1117.  
  1118.         FMax = (voice->FilterSpeed < 3) ? (5 - voice->FilterSpeed) : 1;
  1119.         for (i = 0; i < FMax; ++i)
  1120.         {
  1121.             if ((d1 == d3) || (d2 == d3))
  1122.             {
  1123.                 if (voice->FilterSlidingIn)
  1124.                     voice->FilterSlidingIn = false;
  1125.                 else
  1126.                     voice->FilterSign = -voice->FilterSign;
  1127.             }
  1128.  
  1129.             d3 += voice->FilterSign;
  1130.         }
  1131.  
  1132.         d3 = CLAMP(d3, 1, 63);
  1133.  
  1134.         voice->FilterPos   = d3;
  1135.         voice->NewWaveform = true;
  1136.  
  1137.         voice->FilterWait = voice->FilterSpeed - 3;
  1138.         if (voice->FilterWait < 1)
  1139.             voice->FilterWait = 1;
  1140.     }
  1141.  
  1142.     if ((voice->Waveform == (3 - 1)) || voice->PlantSquare)
  1143.     {
  1144.         SquarePtr = &Waves.Squares[(voice->FilterPos - 0x20) * (0xFC + 0xFC + 0x80 * 0x1F + 0x80 + 0x280 * 3)];
  1145.  
  1146.         X = voice->SquarePos << (5 - voice->WaveLength);
  1147.         if (X > 0x20)
  1148.         {
  1149.             X = 0x40 - X;
  1150.             voice->SquareReverse = true;
  1151.         }
  1152.  
  1153.         if (X > 0)
  1154.             SquarePtr += ((X - 1) << 7);
  1155.  
  1156.         Delta = 32 >> voice->WaveLength;
  1157.  
  1158.         WaveformTab[2] = voice->SquareTempBuffer;
  1159.         for (i = 0; i < ((1 << voice->WaveLength) * 4); ++i)
  1160.         {
  1161.             voice->SquareTempBuffer[i] = *SquarePtr;
  1162.             SquarePtr += Delta;
  1163.         }
  1164.  
  1165.         voice->NewWaveform = true;
  1166.         voice->Waveform    = 3 - 1;
  1167.         voice->PlantSquare = false;
  1168.     }
  1169.  
  1170.     if (voice->Waveform == (4 - 1))
  1171.         voice->NewWaveform = true;
  1172.  
  1173.     if (voice->NewWaveform)
  1174.     {
  1175.         AudioSource = WaveformTab[voice->Waveform];
  1176.         if (voice->Waveform != (3 - 1))
  1177.             AudioSource += (voice->FilterPos - 0x20) * (0xFC + 0xFC + 0x80 * 0x1F + 0x80 + 0x280 * 3);
  1178.  
  1179.         if (voice->Waveform < (3 - 1))
  1180.             AudioSource += Offsets[voice->WaveLength];
  1181.  
  1182.         if (voice->Waveform == (4 - 1))
  1183.         {
  1184.             AudioSource += (WNRandom & (2 * 0x280 - 1)) & ~1;
  1185.             WNRandom    += 2239384;
  1186.             WNRandom     = ((((WNRandom >> 8) | (WNRandom << 24)) + 782323) ^ 75) - 6735;
  1187.         }
  1188.  
  1189.         voice->AudioSource = AudioSource;
  1190.     }
  1191.  
  1192.     voice->AudioPeriod = voice->InstrPeriod;
  1193.     if (!voice->FixedNote)
  1194.         voice->AudioPeriod += (voice->Transpose + voice->TrackPeriod - 1);
  1195.  
  1196.     voice->AudioPeriod = CLAMP(voice->AudioPeriod, 0, 5 * 12);
  1197.     voice->AudioPeriod = PeriodTable[voice->AudioPeriod];
  1198.  
  1199.     if (!voice->FixedNote)
  1200.         voice->AudioPeriod += voice->PeriodSlidePeriod;
  1201.  
  1202.     voice->AudioPeriod += (voice->PeriodPerfSlidePeriod + voice->VibratoPeriod);
  1203.     voice->AudioPeriod = CLAMP(voice->AudioPeriod, 0x0071, 0x0D60);
  1204.  
  1205.     voice->AudioVolume = ((((((((voice->ADSRVolume >> 8) * voice->NoteMaxVolume) >> 6) * voice->PerfSubVolume) >> 6) * voice->TrackMasterVolume) >> 6) * MainVolume) >> 6;
  1206. }
  1207.  
  1208. static void SetAudio(int32_t v)
  1209. {
  1210.     int32_t i, WaveLoops;
  1211.  
  1212.     if (!Voices[v].TrackOn)
  1213.     {
  1214.         PaulaSetVolume(v, 0);
  1215.         return;
  1216.     }
  1217.  
  1218.     if (Voices[v].PlantPeriod)
  1219.     {
  1220.         Voices[v].PlantPeriod = false;
  1221.         PaulaSetPeriod(v, Voices[v].AudioPeriod);
  1222.     }
  1223.  
  1224.     if (Voices[v].NewWaveform)
  1225.     {
  1226.         Voices[v].NewWaveform = false;
  1227.  
  1228.         if (Voices[v].Waveform == (4 - 1))
  1229.         {
  1230.             memcpy(Voices[v].VoiceBuffer, Voices[v].AudioSource, 0x280);
  1231.         }
  1232.         else
  1233.         {
  1234.             WaveLoops = (1 << (5 - Voices[v].WaveLength)) * 5;
  1235.             for (i = 0; i < WaveLoops; ++i)
  1236.             {
  1237.                 memcpy(&Voices[v].VoiceBuffer[i * (sizeof (int32_t) * (1 << Voices[v].WaveLength))],
  1238.                         Voices[v].AudioSource,     sizeof (int32_t) * (1 << Voices[v].WaveLength));
  1239.             }
  1240.         }
  1241.     }
  1242.  
  1243.     PaulaSetVolume(v, Voices[v].AudioVolume);
  1244. }
  1245.  
  1246. static void PListCommandParse(int32_t v, int32_t FX, int32_t FXParam)
  1247. {
  1248.     switch (FX)
  1249.     {
  1250.         case 0x00:
  1251.         {
  1252.             if ((Song.Revision > 0) && (FXParam > 0) && (FXParam < 0x40))
  1253.             {
  1254.                 if (Voices[v].IgnoreFilter)
  1255.                 {
  1256.                     Voices[v].FilterPos    = Voices[v].IgnoreFilter;
  1257.                     Voices[v].IgnoreFilter = false;
  1258.                 }
  1259.                 else
  1260.                 {
  1261.                     Voices[v].FilterPos = FXParam;
  1262.                 }
  1263.  
  1264.                 Voices[v].NewWaveform = true;
  1265.             }
  1266.         }
  1267.         break;
  1268.  
  1269.         case 0x01:
  1270.         {
  1271.             Voices[v].PeriodPerfSlideSpeed = FXParam;
  1272.             Voices[v].PeriodPerfSlideOn    = true;
  1273.         }
  1274.         break;
  1275.  
  1276.         case 0x02:
  1277.         {
  1278.             Voices[v].PeriodPerfSlideSpeed = -FXParam;
  1279.             Voices[v].PeriodPerfSlideOn    = true;
  1280.         }
  1281.         break;
  1282.  
  1283.         case 0x03: // Init Square Modulation
  1284.         {
  1285.             if (!Voices[v].IgnoreSquare)
  1286.                 Voices[v].SquarePos = FXParam >> (5 - Voices[v].WaveLength);
  1287.             else
  1288.                 Voices[v].IgnoreSquare = false;
  1289.         }
  1290.         break;
  1291.  
  1292.         case 0x04: // Start/Stop Modulation
  1293.         {
  1294.             if ((Song.Revision == 0) || (FXParam == 0))
  1295.             {
  1296.                 Voices[v].SquareInit = (Voices[v].SquareOn ^= 1);
  1297.                 Voices[v].SquareSign = 1;
  1298.             }
  1299.             else
  1300.             {
  1301.                 if (FXParam & 0x0F)
  1302.                 {
  1303.                     Voices[v].SquareInit = (Voices[v].SquareOn ^= 1);
  1304.  
  1305.                     Voices[v].SquareSign = 1;
  1306.                     if ((FXParam & 0x0F) == 0x0F)
  1307.                         Voices[v].SquareSign = -1;
  1308.                 }
  1309.  
  1310.                 if (FXParam & 0xF0)
  1311.                 {
  1312.                     Voices[v].FilterInit = (Voices[v].FilterOn ^= 1);
  1313.  
  1314.                     Voices[v].FilterSign = 1;
  1315.                     if ((FXParam & 0xF0) == 0xF0)
  1316.                         Voices[v].FilterSign = -1;
  1317.                 }
  1318.             }
  1319.         }
  1320.         break;
  1321.  
  1322.         case 0x05: // Jump to Step [xx]
  1323.             Voices[v].PerfCurrent = FXParam;
  1324.         break;
  1325.  
  1326.         case 0x06: // Set Volume
  1327.         {
  1328.             if (FXParam > 0x40)
  1329.             {
  1330.                 if ((FXParam -= 0x50) >= 0)
  1331.                 {
  1332.                     if (FXParam <= 0x40)
  1333.                     {
  1334.                         Voices[v].PerfSubVolume = FXParam;
  1335.                     }
  1336.                     else
  1337.                     {
  1338.                         if ((FXParam -= (0xA0 - 0x50)) >= 0)
  1339.                         {
  1340.                             if (FXParam <= 0x40)
  1341.                                 Voices[v].TrackMasterVolume = FXParam;
  1342.                         }
  1343.                     }
  1344.                 }
  1345.             }
  1346.             else
  1347.             {
  1348.                 Voices[v].NoteMaxVolume = FXParam;
  1349.             }
  1350.         }
  1351.         break;
  1352.  
  1353.         case 0x07: // set speed
  1354.             Voices[v].PerfSpeed = Voices[v].PerfWait = FXParam;
  1355.         break;
  1356.     }
  1357. }
  1358.  
  1359. static inline int32_t clipShifted8(int32_t in)
  1360. {
  1361.     int16_t top;
  1362.  
  1363.     top = (int16_t)(in >> 16);
  1364.  
  1365.          if (top >  127) in =   127 << 16;
  1366.     else if (top < -128) in = -(128 << 16);
  1367.  
  1368.     return (in);
  1369. }
  1370.  
  1371. static void GenerateFilterWaveforms(int8_t *buf, int8_t *loBuf, int8_t *hiBuf)
  1372. {
  1373.     const int16_t *midTablePtr = midFilterTable;
  1374.     const int16_t *lowTablePtr = lowFilterTable;
  1375.     const int8_t *waveformPtr;
  1376.     int32_t freq, i, wv, mid, low, j, in, high, fre;
  1377.  
  1378.     freq = 25;
  1379.     for (i = 0; i < FILTER_ITERATIONS; ++i)
  1380.     {
  1381.         waveformPtr = buf;
  1382.         for (wv = 0; wv < NUM_WAVEFORMS; ++wv)
  1383.         {
  1384.             mid = (*midTablePtr++) << 8;
  1385.             low = (*lowTablePtr++) << 8;
  1386.  
  1387.             for (j = 0; j < waveformLen[wv]; ++j)
  1388.             {
  1389.                 in = (*waveformPtr++) << 16;
  1390.  
  1391.                 high = clipShifted8(in - mid - low);
  1392.                 fre  = (high >> 8) * freq;
  1393.                 mid  = clipShifted8(mid + fre);
  1394.                 fre  = (mid  >> 8) * freq;
  1395.                 low  = clipShifted8(low + fre);
  1396.  
  1397.                 *loBuf++ = low  >> 16;
  1398.                 *hiBuf++ = high >> 16;
  1399.             }
  1400.         }
  1401.  
  1402.         freq += 9;
  1403.     }
  1404. }
  1405.  
  1406. static void GenerateTriangle(int8_t *buf, int32_t len)
  1407. {
  1408.     int8_t c, *buf2;
  1409.     int32_t i, d2, d5, d1, d4, val;
  1410.  
  1411.     d2  = len;
  1412.     d5  = len / 4;
  1413.     d1  = 128 / d5;
  1414.     d4  = -(d2 / 2);
  1415.     val = 0;
  1416.  
  1417.     for (i = 0; i < d5; ++i)
  1418.     {
  1419.         *buf++ = val;
  1420.         val   += d1;
  1421.     }
  1422.  
  1423.     *buf++ = 0x7F;
  1424.  
  1425.     if (d5 != 1)
  1426.     {
  1427.         val = 128;
  1428.         for (i = 0; i < (d5 - 1); ++i)
  1429.         {
  1430.             val   -= d1;
  1431.             *buf++ = val;
  1432.         }
  1433.     }
  1434.  
  1435.     buf2 = buf + d4;
  1436.     for (i = 0; i < (d5 * 2); ++i)
  1437.     {
  1438.         c = *buf2++;
  1439.         if (c == 0x7F)
  1440.             c = 0x80;
  1441.         else
  1442.             c = -c;
  1443.  
  1444.         *buf++ = c;
  1445.     }
  1446. }
  1447.  
  1448. static void GenerateSquare(int8_t *buf)
  1449. {
  1450.     int32_t i, j;
  1451.  
  1452.     for (i = 1; i <= 32; ++i)
  1453.     {
  1454.         for (j = 0; j < ((64 - i) * 2); ++j)
  1455.             *buf++ = 0x80;
  1456.  
  1457.         for (j = 0; j < (i * 2); ++j)
  1458.             *buf++ = 0x7F;
  1459.     }
  1460. }
  1461.  
  1462. static void GenerateSawtooth(int8_t *buf, int32_t len)
  1463. {
  1464.     int8_t val;
  1465.     int32_t i;
  1466.  
  1467.     val = -128;
  1468.     for (i = 0; i < len; ++i)
  1469.     {
  1470.         *buf++ = val;
  1471.         val   += (256 / (len - 1));
  1472.     }
  1473. }
  1474.  
  1475. static void GenerateWhiteNoise(int8_t *buf, int32_t len)
  1476. {
  1477.     int8_t s;
  1478.     uint16_t ax, bx;
  1479.     int32_t i;
  1480.     uint32_t ays;
  1481.  
  1482.     ays = 0x41595321; // seed ("AYS!")
  1483.     for (i = 0; i < len; ++i)
  1484.     {
  1485.         s = ays;
  1486.         if (ays & 0x100)
  1487.         {
  1488.             s = 0x7f;
  1489.             if (ays & 0x8000)
  1490.                 s = 0x80;
  1491.         }
  1492.  
  1493.         *buf++ = s;
  1494.  
  1495.         ays  = (ays >> 5) | (ays << 27);
  1496.         ays  = (ays & 0xFFFFFF00) | ((ays & 0xFF) ^ 0x9A);
  1497.         bx   = ays;
  1498.         ays  = (ays << 2) | (ays >> 30);
  1499.         ax   = ays;
  1500.         bx  += ax;
  1501.         ax  ^= bx;
  1502.         ays  = (ays & 0xFFFF0000) | ax;
  1503.         ays  = (ays >> 3) | (ays << 29);
  1504.     }
  1505. }
  1506.  
  1507. static void GenerateWaves(void)
  1508. {
  1509.     // generates bit-perfect waveforms to the original Amiga replayer
  1510.  
  1511.     GenerateSawtooth(Waves.Sawtooth04, 0x04);
  1512.     GenerateSawtooth(Waves.Sawtooth08, 0x08);
  1513.     GenerateSawtooth(Waves.Sawtooth10, 0x10);
  1514.     GenerateSawtooth(Waves.Sawtooth20, 0x20);
  1515.     GenerateSawtooth(Waves.Sawtooth40, 0x40);
  1516.     GenerateSawtooth(Waves.Sawtooth80, 0x80);
  1517.     GenerateTriangle(Waves.Triangle04, 0x04);
  1518.     GenerateTriangle(Waves.Triangle08, 0x08);
  1519.     GenerateTriangle(Waves.Triangle10, 0x10);
  1520.     GenerateTriangle(Waves.Triangle20, 0x20);
  1521.     GenerateTriangle(Waves.Triangle40, 0x40);
  1522.     GenerateTriangle(Waves.Triangle80, 0x80);
  1523.     GenerateSquare(Waves.Squares);
  1524.     GenerateWhiteNoise(Waves.WhiteNoiseBig, 0x280 * 3);
  1525.     GenerateFilterWaveforms(Waves.Triangle04, Waves.LowPasses, Waves.HighPasses);
  1526. }
  1527.  
  1528. static void mixSampleBlock(int16_t *streamOut, uint32_t numSamples)
  1529. {
  1530.     uint8_t i;
  1531.     int16_t *sndOut;
  1532.     uint16_t j;
  1533.     int32_t smpL, smpR;
  1534.     float tempSample, tempVolume, out_f[2];
  1535.     paulaVoice_t *v;
  1536. #ifdef USE_BLEP
  1537.     blep_t *bSmp, *bVol;
  1538. #endif
  1539.  
  1540.     memset(mixerBufferL, 0, sizeof (float) * numSamples);
  1541.     memset(mixerBufferR, 0, sizeof (float) * numSamples);
  1542.  
  1543.     for (i = 0; i < AMIGA_VOICES; ++i)
  1544.     {
  1545.         v = &AUD[i];
  1546.  
  1547. #ifdef USE_BLEP
  1548.         bSmp = &blep[i];
  1549.         bVol = &blepVol[i];
  1550. #endif
  1551.         for (j = 0; j < numSamples; ++j)
  1552.         {
  1553.             tempSample = (v->DMA_DAT == NULL) ? 0.0f : (v->DMA_DAT[v->DMA_POS] * (1.0f / 128.0f));
  1554.             tempVolume = (v->DMA_DAT == NULL) ? 0.0f : v->SRC_VOL;
  1555.  
  1556. #ifdef USE_BLEP
  1557.             if (tempSample != bSmp->lastValue)
  1558.             {
  1559.                 if ((v->LASTDELTA > 0.0f) && (v->LASTDELTA > v->LASTFRAC))
  1560.                     blepAdd(bSmp, v->LASTFRAC / v->LASTDELTA, bSmp->lastValue - tempSample);
  1561.  
  1562.                 bSmp->lastValue = tempSample;
  1563.             }
  1564.  
  1565.             if (tempVolume != bVol->lastValue)
  1566.             {
  1567.                 blepAdd(bVol, 0.0f, bVol->lastValue - tempVolume);
  1568.                 bVol->lastValue = tempVolume;
  1569.             }
  1570.  
  1571.             if (bSmp->samplesLeft) tempSample += blepRun(bSmp);
  1572.             if (bVol->samplesLeft) tempVolume += blepRun(bVol);
  1573. #endif
  1574.  
  1575.             tempSample *= tempVolume;
  1576.  
  1577.             mixerBufferL[j] += (tempSample * v->PANL);
  1578.             mixerBufferR[j] += (tempSample * v->PANR);
  1579.  
  1580.             v->FRAC += v->DELTA;
  1581.             if (v->FRAC >= 1.0f)
  1582.             {
  1583.                 v->FRAC -= 1.0f;
  1584.  
  1585.                 v->LASTFRAC  = v->FRAC;
  1586.                 v->LASTDELTA = v->DELTA;
  1587.  
  1588.                 if (++v->DMA_POS >= v->DMA_LEN)
  1589.                 {
  1590.                     v->DMA_POS = 0;
  1591.  
  1592.                     /* re-fetch Paula register values now */
  1593.                     v->DMA_LEN = v->SRC_LEN;
  1594.                     v->DMA_DAT = v->SRC_DAT;
  1595.                 }
  1596.             }
  1597.         }
  1598.     }
  1599.  
  1600.     sndOut = streamOut;
  1601.     for (j = 0; j < numSamples; ++j)
  1602.     {
  1603.         out_f[0] = mixerBufferL[j];
  1604.         out_f[1] = mixerBufferR[j];
  1605.  
  1606. #ifdef USE_HIGHPASS
  1607.         lossyIntegratorHighPass(&filterHi, out_f, out_f);
  1608. #endif
  1609.         /* normalize amplitude */
  1610.         out_f[0] *= (32767.0f / NORM_FACTOR);
  1611.         out_f[1] *= (32767.0f / NORM_FACTOR);
  1612.  
  1613.         /* truncate to signed 32-bit integer (should compile into using SSE) */
  1614.         smpL = (int32_t)(out_f[0]);
  1615.         smpR = (int32_t)(out_f[1]);
  1616.  
  1617.         /* clamp to 16-bit signed range (fast) */
  1618.         CLAMP16(smpL);
  1619.         CLAMP16(smpR);
  1620.  
  1621.         /* truncate 32-bit to signed 16-bit integer (fast) and store in output buffer */
  1622.         *sndOut++ = (int16_t)(smpL);
  1623.         *sndOut++ = (int16_t)(smpR);
  1624.     }
  1625. }
  1626.  
  1627. static float sinApx(float x)
  1628. {
  1629.     x = x * (2.0f - x);
  1630.     return (x * 1.09742972f + x * x * 0.31678383f);
  1631. }
  1632.  
  1633. static float cosApx(float x)
  1634. {
  1635.     x = (1.0f - x) * (1.0f + x);
  1636.     return (x * 1.09742972f + x * x * 0.31678383f);
  1637. }
  1638.  
  1639. static void calculatePans(int8_t stereoSeparation)
  1640. {
  1641.     uint8_t scaledPanPos;
  1642.     float p;
  1643.  
  1644.     if (stereoSeparation > 100)
  1645.         stereoSeparation = 100;
  1646.  
  1647.     scaledPanPos = (stereoSeparation * 128) / 100;
  1648.  
  1649.     p = (128 - scaledPanPos) * (1.0f / 256.0f);
  1650.     AUD[0].PANL = cosApx(p);
  1651.     AUD[0].PANR = sinApx(p);
  1652.     AUD[3].PANL = cosApx(p);
  1653.     AUD[3].PANR = sinApx(p);
  1654.  
  1655.     p = (128 + scaledPanPos) * (1.0f / 256.0f);
  1656.     AUD[1].PANL = cosApx(p);
  1657.     AUD[1].PANR = sinApx(p);
  1658.     AUD[2].PANL = cosApx(p);
  1659.     AUD[2].PANR = sinApx(p);
  1660. }
  1661.  
  1662. void ahxplay_FillAudioBuffer(int16_t *buffer, int32_t samples)
  1663. {
  1664.     int32_t samplesTodo;
  1665.  
  1666.     while (samples)
  1667.     {
  1668.         samplesTodo = (samples < samplesLeft) ? samples : samplesLeft;
  1669.         if (samplesTodo > soundBufferSize)
  1670.             samplesTodo = soundBufferSize;
  1671.  
  1672.         if (samplesTodo > 0)
  1673.         {
  1674.             mixSampleBlock(buffer, samplesTodo);
  1675.             buffer += (samplesTodo * 2);
  1676.  
  1677.             samples -= samplesTodo;
  1678.             samplesLeft -= samplesTodo;
  1679.         }
  1680.         else
  1681.         {
  1682.             PlayIRQ();
  1683.             samplesLeft = samplesPerFrame;
  1684.         }
  1685.     }
  1686. }
  1687.  
  1688. /* the following must be changed if you want to use another audio API than WinMM */
  1689.  
  1690. #define MIX_BUF_NUM 4
  1691. static WAVEHDR waveBlocks[MIX_BUF_NUM];
  1692. static HWAVEOUT hWaveOut;
  1693. static WAVEFORMATEX wfx;
  1694.  
  1695. static void CALLBACK callbackWinMM(HWAVEOUT _hWaveOut, UINT uMsg,
  1696.     DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
  1697. {
  1698.     WAVEHDR *waveBlockHeader;
  1699.  
  1700.     /* make compiler happy! (warning C4100) */
  1701.     (void)(dwParam2);
  1702.     (void)(dwInstance);
  1703.  
  1704.     if (uMsg == MM_WOM_DONE)
  1705.     {
  1706.         mixingMutex = true;
  1707.  
  1708.         waveBlockHeader = (WAVEHDR *)(dwParam1);
  1709.         waveOutUnprepareHeader(_hWaveOut, waveBlockHeader, sizeof (WAVEHDR));
  1710.  
  1711.         if (isMixing)
  1712.         {
  1713.             memcpy(waveBlockHeader->lpData, winmmBuffer, soundBufferSize);
  1714.             waveOutPrepareHeader(_hWaveOut, waveBlockHeader, sizeof (WAVEHDR));
  1715.             waveOutWrite(_hWaveOut, waveBlockHeader, sizeof (WAVEHDR));
  1716.  
  1717.             ahxplay_FillAudioBuffer((int16_t *)(winmmBuffer), soundBufferSize / 4);
  1718.         }
  1719.  
  1720.         mixingMutex = false;
  1721.     }
  1722. }
  1723.  
  1724. static int8_t openMixer(uint32_t _samplingFrequency, uint32_t _soundBufferSize)
  1725. {
  1726.     uint8_t i;
  1727.     MMRESULT r;
  1728.  
  1729.     if (!hWaveOut)
  1730.     {
  1731.         winmmBuffer = (int8_t *)(calloc(_soundBufferSize, 1));
  1732.         if (winmmBuffer == NULL)
  1733.             return (false); /* gets free'd later */
  1734.  
  1735.         wfx.nSamplesPerSec  = _samplingFrequency;
  1736.         wfx.wBitsPerSample  = 16;
  1737.         wfx.nChannels       = 2;
  1738.         wfx.wFormatTag      = WAVE_FORMAT_PCM;
  1739.         wfx.nBlockAlign     = (wfx.wBitsPerSample * wfx.nChannels) / 8;
  1740.         wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;
  1741.  
  1742.         r = waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, (DWORD_PTR)(callbackWinMM), 0L, CALLBACK_FUNCTION);
  1743.         if (r != MMSYSERR_NOERROR)
  1744.             return (false);
  1745.  
  1746.         for (i = 0; i < MIX_BUF_NUM; ++i)
  1747.         {
  1748.             waveBlocks[i].dwBufferLength = _soundBufferSize;
  1749.  
  1750.             waveBlocks[i].lpData = (LPSTR)(calloc(_soundBufferSize, 1));
  1751.             if (waveBlocks[i].lpData == NULL)
  1752.                 return (false); /* gets free'd later */
  1753.  
  1754.             waveOutPrepareHeader(hWaveOut, &waveBlocks[i], sizeof (WAVEHDR));
  1755.             waveOutWrite(hWaveOut, &waveBlocks[i], sizeof (WAVEHDR));
  1756.         }
  1757.  
  1758.         return (true);
  1759.     }
  1760.  
  1761.     return (true);
  1762. }
  1763.  
  1764. static void closeMixer(void)
  1765. {
  1766.     uint8_t i;
  1767.  
  1768.     if (hWaveOut)
  1769.     {
  1770.         for (i = 0; i < MIX_BUF_NUM; ++i)
  1771.             waveOutUnprepareHeader(hWaveOut, &waveBlocks[i], sizeof (WAVEHDR));
  1772.  
  1773.         for (i = 0; i < MIX_BUF_NUM; ++i)
  1774.         {
  1775.             while (waveBlocks[i].dwFlags & WHDR_PREPARED) SleepEx(1, 1); // wait
  1776.  
  1777.             if (waveBlocks[i].lpData != NULL)
  1778.             {
  1779.                 free(waveBlocks[i].lpData);
  1780.                 waveBlocks[i].lpData = NULL;
  1781.             }
  1782.         }
  1783.  
  1784.         waveOutReset(hWaveOut);
  1785.         waveOutClose(hWaveOut);
  1786.  
  1787.         hWaveOut = 0;
  1788.  
  1789.         if (winmmBuffer != NULL)
  1790.         {
  1791.             free(winmmBuffer);
  1792.             winmmBuffer = NULL;
  1793.         }
  1794.     }
  1795. }
  1796.  
  1797. /* --------------------------------------------------------------------------- */
  1798.  
  1799. void ahxplay_Close(void)
  1800. {
  1801.     Playing = false;
  1802.     freeSong();
  1803.  
  1804.     if (isMixing)
  1805.     {
  1806.         isMixing = false;
  1807.         while (mixingMutex);
  1808.         closeMixer();
  1809.     }
  1810.  
  1811.     if (mixerBufferL != NULL)
  1812.     {
  1813.         free(mixerBufferL);
  1814.         mixerBufferL = NULL;
  1815.     }
  1816.  
  1817.     if (mixerBufferR != NULL)
  1818.     {
  1819.         free(mixerBufferR);
  1820.         mixerBufferR = NULL;
  1821.     }
  1822. }
  1823.  
  1824. int8_t ahxplay_Init(uint32_t outputFreq)
  1825. {
  1826.     outputFreq = CLAMP(outputFreq, 32000, 96000);
  1827.  
  1828.     mixerBufferL = (float *)(malloc(AUDIO_BUF_LEN * sizeof (float)));
  1829.     mixerBufferR = (float *)(malloc(AUDIO_BUF_LEN * sizeof (float)));
  1830.  
  1831.     if ((mixerBufferL == NULL) || (mixerBufferR == NULL))
  1832.     {
  1833.         ahxplay_Close();
  1834.         return (false);
  1835.     }
  1836.  
  1837.     if (!openMixer(outputFreq, AUDIO_BUF_LEN))
  1838.     {
  1839.         ahxplay_Close();
  1840.         return (false);
  1841.     }
  1842.  
  1843.     f_outputFreq    = (float)(outputFreq);
  1844.     soundBufferSize = AUDIO_BUF_LEN;
  1845.     samplesPerFrame = outputFreq / 50;
  1846.  
  1847.     calculatePans(STEREO_SEP);
  1848.  
  1849. #ifdef USE_HIGHPASS
  1850.     // Amiga 500 RC high-pass filter (R = 1390 ohm, C = 22uF)
  1851.     // hz = 1 / (2pi * R * C)    = ~5.2Hz
  1852.     calcCoeffLossyIntegrator(f_outputFreq, 5.2f, &filterHi);
  1853. #endif
  1854.  
  1855.     Song.Subsongs    = NULL;
  1856.     Song.Positions   = NULL;
  1857.     Song.Tracks      = NULL;
  1858.     Song.Instruments = NULL;
  1859.  
  1860.     GenerateWaves();
  1861.  
  1862.     WaveformTab[0] = Waves.Triangle04;
  1863.     WaveformTab[1] = Waves.Sawtooth04;
  1864.     WaveformTab[3] = Waves.WhiteNoiseBig;
  1865.  
  1866.     isMixing = true;
  1867.     return (true);
  1868. }
  1869.  
  1870. int8_t ahxplay_LoadSong(void *Buffer, int32_t Len)
  1871. {
  1872.     char *NamePtr;
  1873.     uint8_t *SongBuffer, *SBPtr;
  1874.     int32_t i, j, SongLength;
  1875.     AHXInstrument *ins;
  1876.     AHXPListEntry *plist;
  1877.     AHXStep *step;
  1878.     AHXPosition *pos;
  1879.  
  1880.     SongLength = Len;
  1881.     SongBuffer = (uint8_t *)(Buffer);
  1882.     SBPtr      = &SongBuffer[14];
  1883.  
  1884.     if ((SongLength < 14) || (SongLength > 65535))
  1885.         return (false);
  1886.  
  1887.     if ((SongBuffer[0] != 'T') && (SongBuffer[1] != 'H') && (SongBuffer[2] != 'X'))
  1888.         return (false);
  1889.  
  1890.     if (SongBuffer[3] > 1)
  1891.         return (false);
  1892.  
  1893.     NamePtr              = (char *)(&SongBuffer[(SongBuffer[4] << 8) | SongBuffer[5]]);
  1894.     Song.Name            = _strdup(NamePtr); NamePtr += (strlen(NamePtr) + 1);
  1895.     Song.Revision        = SongBuffer[3];
  1896.     Song.SpeedMultiplier = ((SongBuffer[6] >> 5) & 3) + 1;
  1897.     Song.PositionNr      = ((SongBuffer[6] & 0x0F) << 8) | SongBuffer[7];
  1898.     Song.Restart         = (SongBuffer[8] << 8) | SongBuffer[9];
  1899.     Song.TrackLength     = SongBuffer[10];
  1900.     Song.TrackNr         = SongBuffer[11];
  1901.     Song.InstrumentNr    = SongBuffer[12];
  1902.     Song.SubsongNr       = SongBuffer[13];
  1903.  
  1904.     if (Song.Restart >= Song.PositionNr)
  1905.         Song.Restart  = Song.PositionNr - 1;
  1906.  
  1907.     Song.Subsongs = (int32_t *)(malloc(sizeof (int32_t) * Song.SubsongNr));
  1908.     if (Song.Subsongs == NULL)
  1909.     {
  1910.         freeSong();
  1911.         return (false);
  1912.     }
  1913.  
  1914.     for (i = 0; i < Song.SubsongNr; ++i)
  1915.     {
  1916.         if ((SBPtr - SongBuffer) > SongLength)
  1917.             return (false);
  1918.  
  1919.         Song.Subsongs[i] = (SBPtr[0] << 8) | SBPtr[1];
  1920.         SBPtr += 2;
  1921.     }
  1922.  
  1923.     Song.Positions = (AHXPosition *)(malloc(sizeof (AHXPosition) * Song.PositionNr));
  1924.     if (Song.Positions == NULL)
  1925.     {
  1926.         freeSong();
  1927.         return (false);
  1928.     }
  1929.  
  1930.     for (i = 0; i < Song.PositionNr; ++i)
  1931.     {
  1932.         for (j = 0; j < AMIGA_VOICES; ++j)
  1933.         {
  1934.             if ((SBPtr - SongBuffer) > SongLength)
  1935.                 return (false);
  1936.  
  1937.             pos = &Song.Positions[i];
  1938.  
  1939.             pos->Track[j]     = *SBPtr++;
  1940.             pos->Transpose[j] = *((int8_t *)(SBPtr++));
  1941.         }
  1942.     }
  1943.  
  1944.     MaxTrack = Song.TrackNr;
  1945.  
  1946.     Song.Tracks = (AHXStep **)(malloc(sizeof (AHXStep) * (MaxTrack + 1)));
  1947.     if (Song.Tracks == NULL)
  1948.     {
  1949.         freeSong();
  1950.         return (false);
  1951.     }
  1952.  
  1953.     for (i = 0; i < MaxTrack+1; i++)
  1954.     {
  1955.         Song.Tracks[i] = (AHXStep *)(malloc(sizeof (AHXStep) * Song.TrackLength));
  1956.  
  1957.         if (((SongBuffer[6] & 0x80) == 0x80) && (i == 0))
  1958.         {
  1959.             memset(Song.Tracks[i], 0, Song.TrackLength * sizeof (AHXStep));
  1960.             continue;
  1961.         }
  1962.  
  1963.         for (j = 0; j < Song.TrackLength; ++j)
  1964.         {
  1965.             if ((SBPtr - SongBuffer) > SongLength)
  1966.                 return (false);
  1967.  
  1968.             step = &Song.Tracks[i][j];
  1969.  
  1970.             step->Note       = (SBPtr[0] >> 2) & 0x3F;
  1971.             step->Instrument = ((SBPtr[0] & 0x3) << 4) | (SBPtr[1] >> 4);
  1972.             step->FX         = SBPtr[1] & 0x0F;
  1973.             step->FXParam    = SBPtr[2];
  1974.  
  1975.             SBPtr += 3;
  1976.         }
  1977.     }
  1978.  
  1979.     Song.Instruments = (AHXInstrument *)(malloc(sizeof (AHXInstrument) * (Song.InstrumentNr + 1)));
  1980.     if (Song.Instruments == NULL)
  1981.     {
  1982.         freeSong();
  1983.         return (false);
  1984.     }
  1985.  
  1986.     for (i = 1; i < (Song.InstrumentNr + 1); ++i)
  1987.     {
  1988.         ins = &Song.Instruments[i];
  1989.  
  1990.         ins->Name = _strdup(NamePtr); NamePtr += (strlen(NamePtr) + 1);
  1991.         if ((SBPtr - SongBuffer) > SongLength)
  1992.             return (false);
  1993.  
  1994.         ins->Volume               = SBPtr[0];
  1995.         ins->FilterSpeed          = ((SBPtr[1] >> 3) & 0x1F) | ((SBPtr[12] >> 2) & 0x20);
  1996.         ins->WaveLength           = SBPtr[1] & 7;
  1997.         ins->Envelope.aFrames     = SBPtr[2];
  1998.         ins->Envelope.aVolume     = SBPtr[3];
  1999.         ins->Envelope.dFrames     = SBPtr[4];
  2000.         ins->Envelope.dVolume     = SBPtr[5];
  2001.         ins->Envelope.sFrames     = SBPtr[6];
  2002.         ins->Envelope.rFrames     = SBPtr[7];
  2003.         ins->Envelope.rVolume     = SBPtr[8];
  2004.         ins->FilterLowerLimit     = SBPtr[12] & 0x7F;
  2005.         ins->VibratoDelay         = SBPtr[13];
  2006.         ins->HardCutReleaseFrames = (SBPtr[14] >> 4) & 7;
  2007.         ins->HardCutRelease       = (SBPtr[14] & 0x80) ? true : false;
  2008.         ins->VibratoDepth         = SBPtr[14] & 0x0F;
  2009.         ins->VibratoSpeed         = SBPtr[15];
  2010.         ins->SquareLowerLimit     = SBPtr[16];
  2011.         ins->SquareUpperLimit     = SBPtr[17];
  2012.         ins->SquareSpeed          = SBPtr[18];
  2013.         ins->FilterUpperLimit     = SBPtr[19] & 0x3F;
  2014.         ins->PList.Speed          = SBPtr[20];
  2015.         ins->PList.Length         = SBPtr[21];
  2016.  
  2017.         SBPtr += 22;
  2018.  
  2019.         ins->PList.Entries = (AHXPListEntry *)(malloc(sizeof (AHXPListEntry) * ins->PList.Length));
  2020.         if (ins->PList.Entries == NULL)
  2021.         {
  2022.             freeSong();
  2023.             return (false);
  2024.         }
  2025.  
  2026.         for (j = 0; j < ins->PList.Length; ++j)
  2027.         {
  2028.             if ((SBPtr - SongBuffer) > SongLength)
  2029.                 return (false);
  2030.  
  2031.             plist = &ins->PList.Entries[j];
  2032.  
  2033.             plist->FX[1]      = (SBPtr[0] >> 5) & 7;
  2034.             plist->FX[0]      = (SBPtr[0] >> 2) & 7;
  2035.             plist->Waveform   = ((SBPtr[0] << 1) & 6) | (SBPtr[1] >> 7);
  2036.             plist->Fixed      = (SBPtr[1] >> 6) & 1;
  2037.             plist->Note       = SBPtr[1] & 0x3F;
  2038.             plist->FXParam[0] = SBPtr[2];
  2039.             plist->FXParam[1] = SBPtr[3];
  2040.  
  2041.             SBPtr += 4;
  2042.         }
  2043.     }
  2044.  
  2045.     SongLoaded = true;
  2046.     return (true);
  2047. }
  2048.  
  2049. int8_t ahxplay_Play(int32_t subSongNr)
  2050. {
  2051.     uint8_t i;
  2052.     AHXVoice *v;
  2053.  
  2054.     if (!SongLoaded || (subSongNr > Song.SubsongNr))
  2055.         return (false);
  2056.  
  2057.     PosNr = (subSongNr <= 0) ? 0 : Song.Subsongs[subSongNr - 1];
  2058.     PosJump = 0;
  2059.     PatternBreak = false;
  2060.     MainVolume = 0x40;
  2061.     NoteNr = PosJumpNote = 0;
  2062.     Tempo = 6;
  2063.     StepWaitFrames = 0;
  2064.     GetNewPosition = true;
  2065.     SongEndReached = false;
  2066.  
  2067. #ifdef USE_HIGHPASS
  2068.     clearLossyIntegrator(&filterHi);
  2069. #endif
  2070.  
  2071. #ifdef USE_BLEP
  2072.     memset(blep,    0, sizeof (blep_t));
  2073.     memset(blepVol, 0, sizeof (blep_t));
  2074. #endif
  2075.  
  2076.     for (i = 0; i < AMIGA_VOICES; ++i)
  2077.     {
  2078.         v = &Voices[i];
  2079.  
  2080.         memset(v, 0, sizeof (AHXVoice));
  2081.         v->TrackOn = true;
  2082.         v->TrackMasterVolume = 0x40;
  2083.  
  2084.         PaulaSetPeriod(i, 0x88); // dunno about this, but the original asm replayer does it!
  2085.         PaulaSetVolume(i, 0);
  2086.         PaulaSetData(i, v->VoiceBuffer);
  2087.         PaulaSetLength(i, 0x280 / 2);
  2088.         PaulaRestartDMA(i);
  2089.     }
  2090.  
  2091.     samplesPerFrame = (int32_t)(((f_outputFreq / 50.0f) / Song.SpeedMultiplier) + 0.5f);
  2092.  
  2093.     Playing = true;
  2094.     return (true);
  2095. }
  2096.  
  2097. static const int16_t midFilterTable[NUM_WAVEFORMS * FILTER_ITERATIONS] =
  2098. {
  2099.     0xFB77,0xEEC3,0xE407,0xCCDA,0x027B,0x33C7,0x088D,0x1901,0x2351,
  2100.     0x3F02,0x3494,0x14F0,0x18CD,0x319B,0x4A69,0x6336,0x7700,0x7F00,
  2101.     0x7F00,0x7F03,0x7B89,0x743C,0x6A16,0x5DFC,0x50BB,0x4304,0x3692,
  2102.     0x2C6F,0x242F,0x1D77,0x17FE,0x138A,0x0FEA,0x0CF6,0x0A8E,0x0882,
  2103.     0x06DB,0x0587,0x0475,0x038D,0x02CC,0x0233,0x01BC,0x014B,0xFD67,
  2104.     0xF7DE,0xE7E6,0xDBED,0xCACA,0x3101,0x2591,0x0F6F,0x2099,0x2BEE,
  2105.     0x4836,0x1B05,0x0F08,0x21BB,0x4377,0x6533,0x7DA3,0x7F00,0x7EC7,
  2106.     0x780E,0x6B20,0x5A61,0x47DD,0x362D,0x28BD,0x1EA3,0x1709,0x1153,
  2107.     0x0D07,0x09CB,0x075D,0x056D,0x03FF,0x02D0,0x0212,0x0161,0x0104,
  2108.     0x00AD,0x0060,0x0020,0xFFEE,0xFFC9,0xFFB1,0xFFA4,0xFFA1,0xFCBA,
  2109.     0xF363,0xE37E,0xCF9E,0xE43D,0x367A,0x1965,0x1752,0x23AD,0x3A63,
  2110.     0x41F1,0x17C1,0x0BE8,0x2AA9,0x5553,0x7A8B,0x7F00,0x7D44,0x70C0,
  2111.     0x5C86,0x4508,0x2FC9,0x2115,0x16E6,0x0FDA,0x0AF9,0x0798,0x0542,
  2112.     0x0384,0x0259,0x0173,0x00DF,0x0089,0x0040,0x0007,0xFFDE,0xFFC6,
  2113.     0xFFBB,0xFFBA,0xFFC1,0xFFCC,0xFFD9,0xFFE6,0xFFF2,0xFFFB,0x1378,
  2114.     0xEE84,0xE05A,0xC5D4,0x0B4E,0x31B3,0x1313,0x1F4A,0x2616,0x45DF,
  2115.     0x2E0E,0x13EB,0x09D8,0x3397,0x672F,0x7F00,0x7EC9,0x7012,0x564D,
  2116.     0x3949,0x2460,0x1719,0x0EAA,0x0950,0x05E9,0x038F,0x0224,0x014A,
  2117.     0x008F,0x0003,0xFFAA,0xFF7E,0xFF75,0xFF83,0xFF9F,0xFFBF,0xFFDD,
  2118.     0xFFF5,0x0006,0x000F,0x0013,0x0013,0x0010,0x000C,0x0008,0x1ADD,
  2119.     0xE985,0xDC57,0xC2A3,0x25E9,0x2A8D,0x103D,0x269A,0x2A91,0x4B24,
  2120.     0x1FD9,0x10BD,0x0865,0x3C85,0x779A,0x7F00,0x760C,0x599E,0x377B,
  2121.     0x2031,0x12AD,0x0AD6,0x0649,0x03A5,0x01F5,0x00DC,0x0051,0x0023,
  2122.     0x0002,0xFFEE,0xFFE6,0xFFE7,0xFFEC,0xFFF3,0xFFF9,0xFFFF,0x0002,
  2123.     0x0004,0x0004,0x0003,0x0002,0x0001,0x0000,0x0000,0xFFFF,0x097F,
  2124.     0xE4D4,0xD636,0xC6FE,0x31B0,0x2314,0x0E82,0x2A8C,0x314E,0x4C62,
  2125.     0x1B03,0x0EA1,0x0750,0x4573,0x7F00,0x7F6E,0x66AE,0x3FAE,0x219D,
  2126.     0x11BE,0x095D,0x04F1,0x0257,0x011B,0x002D,0xFFA4,0xFF73,0xFF7D,
  2127.     0xFFA3,0xFFCF,0xFFF2,0x0008,0x0012,0x0012,0x000E,0x0008,0x0003,
  2128.     0x0000,0xFFFE,0xFFFD,0xFFFE,0xFFFE,0xFFFF,0x0000,0x0000,0xF1BA,
  2129.     0xE0B8,0xCE39,0xD4B0,0x3539,0x1CAE,0x0D02,0x2C42,0x3A0B,0x4951,
  2130.     0x1954,0x0CF7,0x067C,0x4E61,0x7F00,0x77EB,0x5274,0x2978,0x13D3,
  2131.     0x0979,0x0487,0x01DD,0x00C4,0x0001,0xFFA3,0xFF93,0xFFAE,0xFFD4,
  2132.     0xFFF4,0x0007,0x000E,0x000D,0x0009,0x0004,0x0000,0xFFFE,0xFFFE,
  2133.     0xFFFF,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xE1AB,
  2134.     0xDD5D,0xC593,0xE91A,0x34EE,0x17FB,0x0BAC,0x2C14,0x429E,0x40DA,
  2135.     0x1781,0x0BA3,0x05D1,0x574F,0x7F00,0x6DB3,0x3CD8,0x1A34,0x0B48,
  2136.     0x04DB,0x0217,0x00BC,0x0020,0xFFD1,0xFFC0,0xFFD1,0xFFEA,0xFFFD,
  2137.     0x0007,0x0008,0x0005,0x0003,0x0000,0xFFFF,0xFFFF,0xFFFF,0x0000,
  2138.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xDC89,
  2139.     0xDAC4,0xBDC0,0xFEB1,0x32C9,0x14D5,0x0A90,0x2BB8,0x4936,0x3581,
  2140.     0x1551,0x0A8F,0x0547,0x603D,0x7F00,0x5FEC,0x2A63,0x1059,0x064E,
  2141.     0x026E,0x00B8,0x000F,0xFFC7,0xFFC5,0xFFDE,0xFFF7,0x0005,0x0008,
  2142.     0x0006,0x0002,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x0000,0x0000,
  2143.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xDE80,
  2144.     0xD8C5,0xB789,0x1114,0x2F9E,0x12C9,0x09A8,0x2BDE,0x4D5B,0x2BA2,
  2145.     0x1359,0x09A9,0x04D4,0x692B,0x7F00,0x5057,0x1D06,0x09F6,0x036B,
  2146.     0x00D4,0x0033,0xFFE2,0xFFD5,0xFFE7,0xFFFA,0x0003,0x0005,0x0003,
  2147.     0x0001,0x0000,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2148.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xE4D0,
  2149.     0xD70B,0xB2E4,0x1EB8,0x2BD7,0x1161,0x08E7,0x2D67,0x4F9C,0x2510,
  2150.     0x11C9,0x08E8,0x0474,0x7219,0x7C55,0x3F6B,0x133C,0x05D5,0x01C4,
  2151.     0x0056,0xFFF9,0xFFE0,0xFFEC,0xFFFB,0x0002,0x0003,0x0002,0x0000,
  2152.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2153.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xED7D,
  2154.     0xD522,0xB289,0x2800,0x27CE,0x1049,0x0842,0x30EC,0x50A9,0x2153,
  2155.     0x1082,0x0842,0x0421,0x7B07,0x73E8,0x2E8C,0x0C60,0x0349,0x0079,
  2156.     0x0011,0xFFEA,0xFFEE,0xFFFB,0x0002,0x0002,0x0001,0x0000,0x0000,
  2157.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2158.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF6E3,
  2159.     0xD287,0xB4A8,0x2DF5,0x23D7,0x0F53,0x07B3,0x3641,0x50A6,0x1F47,
  2160.     0x0F66,0x07B3,0x03D9,0x7F00,0x6B22,0x20FE,0x079D,0x01C1,0x002D,
  2161.     0xFFF5,0xFFF0,0xFFFB,0x0001,0x0001,0x0001,0x0000,0x0000,0x0000,
  2162.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2163.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x001D,
  2164.     0xCEB8,0xB9CD,0x3192,0x2037,0x0E6D,0x0736,0x3D2E,0x4F2F,0x1DEA,
  2165.     0x0E6C,0x0736,0x039B,0x7F00,0x622C,0x188C,0x04DD,0x00F6,0xFFB9,
  2166.     0xFFB2,0xFFEF,0x0008,0x0007,0x0001,0xFFFF,0x0000,0x0000,0x0000,
  2167.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2168.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x08B8,
  2169.     0xC94F,0xC47E,0x338E,0x1D17,0x0D96,0x06C8,0x4401,0x4BD3,0x1CA4,
  2170.     0x0D90,0x06C8,0x0364,0x7F00,0x5811,0x1100,0x02DB,0x0012,0xFF8B,
  2171.     0xFFD8,0x0008,0x0009,0x0002,0xFFFF,0xFFFF,0x0000,0x0000,0x0000,
  2172.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2173.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1065,
  2174.     0xC224,0xD328,0x3460,0x1A87,0x0CD1,0x0667,0x4B18,0x469A,0x1B42,
  2175.     0x0CCC,0x0667,0x0333,0x7F00,0x4CC9,0x0A92,0x017C,0xFF6C,0xFFAA,
  2176.     0x0002,0x000D,0x0003,0xFFFE,0x0000,0x0000,0x0000,0x0000,0x0000,
  2177.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2178.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x16E7,
  2179.     0xBA2A,0xDB0C,0x344D,0x187E,0x0C20,0x060F,0x5204,0x402F,0x19D8,
  2180.     0x0C1E,0x060F,0x0308,0x7F00,0x40F9,0x0781,0x00DD,0xFFA1,0xFFD9,
  2181.     0x0005,0x0005,0x0000,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,
  2182.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2183.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1C0C,
  2184.     0xB0D2,0xE7CE,0x337D,0x16EA,0x0B82,0x05C1,0x5814,0x399A,0x1881,
  2185.     0x0B82,0x05C1,0x02E1,0x7F00,0x3535,0x04EF,0x0074,0xFFCB,0xFFF1,
  2186.     0x0004,0x0002,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2187.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2188.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1FB5,
  2189.     0xAD77,0xF515,0x3209,0x15AE,0x0AF4,0x057A,0x5CA5,0x340E,0x174A,
  2190.     0x0AF4,0x057A,0x02BD,0x7F00,0x29BF,0x0308,0xFFC8,0xFFC8,0x0004,
  2191.     0x0004,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2192.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2193.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2170,
  2194.     0xB20F,0x01FC,0x300B,0x14AF,0x0A73,0x0539,0x6215,0x2FE7,0x1634,
  2195.     0x0A73,0x053A,0x029D,0x7F00,0x1EE1,0x01B1,0xFFDC,0xFFEA,0x0003,
  2196.     0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2197.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2198.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2128,
  2199.     0xB6D5,0x0E58,0x2D9F,0x13D8,0x09FE,0x04FF,0x68E7,0x2CD8,0x153A,
  2200.     0x09FD,0x04FF,0x027F,0x7F00,0x14ED,0x00D4,0xFFA1,0x0000,0x0004,
  2201.     0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2202.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2203.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1F29,
  2204.     0xA209,0x1989,0x2AEA,0x1313,0x0992,0x04C9,0x6FC3,0x2AA6,0x1456,
  2205.     0x0992,0x04C9,0x0264,0x7F00,0x0C3B,0x0053,0xFFDD,0x0002,0x0001,
  2206.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2207.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2208.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1BB0,
  2209.     0x8888,0x235E,0x2819,0x1258,0x092F,0x0498,0x7023,0x28FE,0x1384,
  2210.     0x092F,0x0497,0x024C,0x7F00,0x0780,0xFF65,0xFFF3,0x0004,0xFFFF,
  2211.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2212.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2213.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1740,
  2214.     0x808D,0x2BF1,0x255C,0x11A7,0x08D4,0x046A,0x7006,0x2781,0x12C3,
  2215.     0x08D4,0x046A,0x0235,0x7F00,0x0423,0xFFB7,0xFFFF,0x0000,0x0000,
  2216.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2217.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2218.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1215,
  2219.     0x800F,0x338F,0x22E6,0x10FF,0x087F,0x0440,0x6F1E,0x262F,0x120F,
  2220.     0x087F,0x043F,0x0220,0x7F00,0x01B2,0xFFEA,0x0001,0x0000,0x0000,
  2221.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2222.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2223.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0C3C,
  2224.     0x8000,0x3B79,0x20EE,0x1062,0x0831,0x0419,0x780C,0x24DF,0x1168,
  2225.     0x0831,0x0419,0x020C,0x7F00,0x004B,0xFFFA,0x0000,0x0000,0x0000,
  2226.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2227.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2228.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0541,
  2229.     0x8000,0x417D,0x1FAB,0x0FD0,0x07E9,0x03F4,0x7F00,0x2398,0x10CE,
  2230.     0x07E9,0x03F4,0x01FA,0x7E81,0x0188,0x0005,0x0000,0x0000,0x0000,
  2231.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2232.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2233.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xFD3E,
  2234.     0x8000,0x45D7,0x1F45,0x0F49,0x07A4,0x03D2,0x7F00,0x228B,0x103D,
  2235.     0x07A5,0x03D2,0x01E9,0x79D0,0x0687,0x007A,0x000A,0x0000,0x0000,
  2236.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2237.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2238.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xF416,
  2239.     0x8000,0x49EB,0x1FE3,0x0ED7,0x0765,0x03B2,0x7F00,0x21A5,0x0FB6,
  2240.     0x0765,0x03B1,0x01D9,0x74CF,0x0C02,0x013C,0x0034,0x000B,0x0003,
  2241.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2242.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2243.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xE94C,
  2244.     0x8000,0x4D8B,0x21B2,0x0E9B,0x0729,0x0395,0x7F00,0x1F2E,0x0F31,
  2245.     0x0729,0x0394,0x01CB,0x6F7D,0x11D7,0x02DB,0x00CE,0x0042,0x0017,
  2246.     0x0008,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2247.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  2248.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xDBED,
  2249.     0x8000,0x506B,0x24C0,0x0F01,0x06F8,0x0379,0x7F00,0x1956,0x0E68,
  2250.     0x06F0,0x0379,0x01BF,0x69DB,0x17E0,0x0563,0x0139,0x0087,0x0041,
  2251.     0x0021,0x0011,0x0007,0x0004,0x0002,0x0002,0x0002,0x0002,0x0002,
  2252.     0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
  2253.     0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0xCE57
  2254. };
  2255.  
  2256. static const int16_t lowFilterTable[NUM_WAVEFORMS * FILTER_ITERATIONS] =
  2257. {
  2258.     0x04A4,0x0526,0xFB66,0xEF30,0x9930,0xC5AD,0xF94C,0xFA32,0x09BE,
  2259.     0x0E1B,0x5703,0x6B3A,0x83A1,0x8C1C,0x996E,0xAB98,0xC1F8,0xDAA8,
  2260.     0xF375,0x0C42,0x2499,0x3BB1,0x50ED,0x63E3,0x744E,0x7F00,0x7F00,
  2261.     0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,
  2262.     0x7F00,0x7F00,0x7FEC,0x7F58,0x7FEE,0x7F36,0x7F93,0x7FDA,0x22B6,
  2263.     0x06E2,0x01FA,0xF97F,0xD0B0,0x9FBF,0xDEBF,0xF750,0x00F7,0x0CD8,
  2264.     0x26C6,0x64BB,0x70ED,0x86B8,0x9666,0xAF0A,0xCF0C,0xF0C8,0x127D,
  2265.     0x32F3,0x5058,0x6982,0x7DD7,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,
  2266.     0x7F00,0x7F00,0x7FFA,0x7FB8,0x7F87,0x7F00,0x7F99,0x7F00,0x7F4B,
  2267.     0x7F7E,0x7F9D,0x7FA9,0x7FA7,0x7F9B,0x7F88,0x7F70,0x7F56,0x1827,
  2268.     0x085D,0xFD8A,0xF58E,0xAAA0,0xB87E,0xE9B1,0xF78F,0x089F,0x1097,
  2269.     0x44D0,0x676B,0x7417,0x8ABF,0xA3D4,0xCA53,0xF4FD,0x1F5D,0x4681,
  2270.     0x6766,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7FE2,
  2271.     0x7F97,0x7F64,0x7FF4,0x7F25,0x7F5A,0x7F75,0x7F7C,0x7F74,0x7F62,
  2272.     0x7F4C,0x7F34,0x7F1E,0x7F0C,0x7EFE,0x7EF4,0x7EEE,0x7EEC,0x0E14,
  2273.     0x08C8,0xFA29,0xEA14,0x9750,0xCB17,0xED77,0xFA92,0x0D73,0x1B3D,
  2274.     0x5BC7,0x6C4C,0x7626,0x8FB7,0xB465,0xE741,0x1ACD,0x4A39,0x7012,
  2275.     0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F9B,
  2276.     0x7FE7,0x7FF5,0x7FDA,0x7FA9,0x7F70,0x7F3C,0x7F11,0x7EF4,0x7EE2,
  2277.     0x7EDC,0x7EDD,0x7EE2,0x7EE9,0x7EF1,0x7EF8,0x7EFD,0x7F01,0x1F29,
  2278.     0x07B7,0xF8BB,0xD9E8,0x9ADB,0xD85A,0xEF6F,0x0056,0x105E,0x2993,
  2279.     0x6293,0x6F41,0x779A,0x95A1,0xC7C2,0x0448,0x3E6E,0x6CE0,0x7F00,
  2280.     0x7F00,0x7F00,0x7F00,0x7F00,0x7FDE,0x7F77,0x7FFF,0x7F13,0x7F29,
  2281.     0x7F2D,0x7F27,0x7F1B,0x7F0F,0x7F04,0x7EFD,0x7EF9,0x7EF8,0x7EF9,
  2282.     0x7EFA,0x7EFC,0x7EFE,0x7EFF,0x7F00,0x7F00,0x7F00,0x7EFF,0x38C1,
  2283.     0x056D,0xF814,0xC623,0xA713,0xE15B,0xF142,0x07C2,0x1262,0x38E2,
  2284.     0x63C5,0x715B,0x78AE,0x9C7C,0xDBB2,0x2144,0x5DAB,0x7F00,0x7F00,
  2285.     0x7F00,0x7F00,0x7F00,0x7F00,0x7FC4,0x7FFA,0x7FD7,0x7F8E,0x7F43,
  2286.     0x7F0A,0x7EEA,0x7EDE,0x7EE0,0x7EE8,0x7EF2,0x7EFB,0x7F00,0x7F03,
  2287.     0x7F03,0x7F02,0x7F01,0x7F00,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x44FF,
  2288.     0x022D,0xF638,0xB1EC,0xB3D3,0xE6DC,0xF2F4,0x1027,0x1555,0x4964,
  2289.     0x65A0,0x7308,0x7983,0xA447,0xEFC0,0x3BF3,0x755D,0x7F00,0x7F00,
  2290.     0x7F00,0x7F00,0x7F00,0x7FA2,0x7FBC,0x7F8E,0x7F4A,0x7F13,0x7EF2,
  2291.     0x7EE6,0x7EE8,0x7EF0,0x7EF8,0x7EFE,0x7F01,0x7F02,0x7F01,0x7F00,
  2292.     0x7EFF,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x3F9E,
  2293.     0xFE6E,0xF23E,0xA271,0xBEFF,0xEA01,0xF459,0x186B,0x1AB5,0x58FD,
  2294.     0x6858,0x745C,0x7A2D,0xAD04,0x0454,0x552E,0x7F00,0x7F00,0x7F00,
  2295.     0x7F00,0x7FB7,0x7F40,0x7F6E,0x7F58,0x7F2D,0x7F08,0x7EF5,0x7EF0,
  2296.     0x7EF4,0x7EF9,0x7EFD,0x7F00,0x7F00,0x7F00,0x7EFF,0x7EFE,0x7EFE,
  2297.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x347C,
  2298.     0xFAB9,0xED47,0x9AA4,0xC870,0xEBE1,0xF572,0x1E07,0x2265,0x6469,
  2299.     0x6AD4,0x7570,0x7AB7,0xB6B2,0x16F0,0x681C,0x7F00,0x7F00,0x7F00,
  2300.     0x7FEB,0x7F45,0x7F6C,0x7F4A,0x7F1C,0x7EFC,0x7EF1,0x7EF3,0x7EF9,
  2301.     0x7EFE,0x7F00,0x7F00,0x7F00,0x7EFF,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2302.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x28BB,
  2303.     0xF78E,0xE420,0x99DD,0xD05D,0xED36,0xF656,0x2213,0x2B5A,0x6A73,
  2304.     0x6CB8,0x7655,0x7B2A,0xC151,0x2A7D,0x790E,0x7F00,0x7F00,0x7F00,
  2305.     0x7F00,0x7F48,0x7F3B,0x7F18,0x7EFF,0x7EF6,0x7EF7,0x7EFB,0x7EFE,
  2306.     0x7F00,0x7F00,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2307.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x1E75,
  2308.     0xF544,0xD834,0x9DAA,0xD6E9,0xEE5D,0xF717,0x24B5,0x34A1,0x6D21,
  2309.     0x6E35,0x7717,0x7B8B,0xCCE1,0x3DC8,0x7F00,0x7F00,0x7F00,0x7FCB,
  2310.     0x7F26,0x7F30,0x7F16,0x7F00,0x7EF9,0x7EFA,0x7EFC,0x7EFF,0x7EFF,
  2311.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2312.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x16D0,
  2313.     0xF3F4,0xCBF1,0xA3BF,0xDC27,0xEF79,0xF7BC,0x26A4,0x3DE3,0x6E84,
  2314.     0x6F7A,0x77BC,0x7BDE,0xD962,0x4F0B,0x7F00,0x7F00,0x7F00,0x7F00,
  2315.     0x7F26,0x7F16,0x7F02,0x7EFB,0x7EFB,0x7EFE,0x7EFF,0x7EFF,0x7EFF,
  2316.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2317.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x11F0,
  2318.     0xF371,0xC1E6,0xAAA0,0xE033,0xF08A,0xF84C,0x28A1,0x4735,0x6FC4,
  2319.     0x7098,0x784C,0x7C25,0xE441,0x5DE5,0x7F00,0x7F00,0x7FE9,0x7F17,
  2320.     0x7F16,0x7F05,0x7EFC,0x7EFC,0x7EFD,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2321.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2322.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x0F7C,
  2323.     0xF342,0xB6DF,0xB189,0xE338,0xF187,0xF8C9,0x2B06,0x509A,0x7144,
  2324.     0x7193,0x78C8,0x7C63,0xED84,0x6A6B,0x7F00,0x7F00,0x7F88,0x7F73,
  2325.     0x7F12,0x7EEF,0x7EF4,0x7EFE,0x7F00,0x7F00,0x7EFF,0x7EFF,0x7EFF,
  2326.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2327.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x0F12,
  2328.     0xF2B4,0xAA33,0xB822,0xE56F,0xF269,0xF936,0x2EE9,0x59B0,0x72F5,
  2329.     0x726E,0x7936,0x7C9A,0xF717,0x75F2,0x7F00,0x7F00,0x7FBB,0x7F39,
  2330.     0x7EF0,0x7EF0,0x7EFD,0x7F01,0x7F00,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2331.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2332.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x1051,
  2333.     0xF0E3,0xA18C,0xBE4C,0xE714,0xF330,0xF998,0x33B3,0x61CB,0x74A7,
  2334.     0x7332,0x7998,0x7CCB,0x00FB,0x7FF6,0x7F00,0x7FED,0x7F8C,0x7EFC,
  2335.     0x7EEA,0x7EFB,0x7F01,0x7F00,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2336.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2337.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x12E5,
  2338.     0xECCF,0x98BC,0xC3FC,0xE858,0xF3E1,0xF9EF,0x39A7,0x6850,0x7630,
  2339.     0x73E0,0x79EF,0x7CF7,0x0B2F,0x7F00,0x7F00,0x7F91,0x7F44,0x7EF7,
  2340.     0x7EF5,0x7EFE,0x7F00,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2341.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2342.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x167B,
  2343.     0xE76E,0x93CA,0xC92C,0xE964,0xF47D,0xFA3E,0x40A5,0x6D08,0x778A,
  2344.     0x747D,0x7A3E,0x7D1E,0x15B3,0x7F00,0x7F00,0x7F50,0x7F1D,0x7EF9,
  2345.     0x7EFB,0x7EFF,0x7EFF,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2346.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2347.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x1AF2,
  2348.     0xDD31,0x9374,0xCDD7,0xEA52,0xF50B,0xFA85,0x484D,0x700F,0x78BA,
  2349.     0x750B,0x7A84,0x7D42,0x2088,0x7F00,0x7F00,0x7F6F,0x7EFF,0x7EF6,
  2350.     0x7EFE,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2351.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2352.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x1FAB,
  2353.     0xD337,0x963B,0xD1F3,0xEB33,0xF58C,0xFAC5,0x4D79,0x721D,0x79CB,
  2354.     0x758C,0x7AC5,0x7D62,0x2BAD,0x7F00,0x7F00,0x7F31,0x7EFC,0x7EFC,
  2355.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2356.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2357.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x241F,
  2358.     0xCC6D,0x9B30,0xD57A,0xEC0B,0xF601,0xFB00,0x5244,0x73C4,0x7AC4,
  2359.     0x7601,0x7B00,0x7D7F,0x3722,0x7F00,0x7FA9,0x7F11,0x7EF6,0x7EFF,
  2360.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2361.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2362.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x280C,
  2363.     0xBE21,0xA145,0xD867,0xECDA,0xF66D,0xFB36,0x55B1,0x7546,0x7BA8,
  2364.     0x766D,0x7B36,0x7D9A,0x42E8,0x7F00,0x7F45,0x7F02,0x7EFC,0x7EFF,
  2365.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2366.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2367.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x2B18,
  2368.     0xA865,0xA7BA,0xDAC1,0xED9F,0xF6CF,0xFB67,0x5207,0x76C6,0x7C7B,
  2369.     0x76CF,0x7B67,0x7DB3,0x4EFE,0x7F00,0x7F4F,0x7EF5,0x7EFF,0x7EFF,
  2370.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2371.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2372.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x2D13,
  2373.     0xB2BE,0xAE1E,0xDC9C,0xEE56,0xF72B,0xFB95,0x4C1E,0x7845,0x7D3D,
  2374.     0x772B,0x7B95,0x7DC9,0x5B64,0x7F00,0x7F17,0x7EFC,0x7EFF,0x7EFF,
  2375.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2376.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2377.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x2E1B,
  2378.     0xCE29,0xB467,0xDE0E,0xEEFF,0xF77F,0xFBBF,0x4843,0x79BD,0x7DF0,
  2379.     0x777F,0x7BBE,0x7DDE,0x681B,0x7F00,0x7F02,0x7EFF,0x7EFF,0x7EFF,
  2380.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2381.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2382.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x2E32,
  2383.     0xE25E,0xBB9A,0xDF40,0xEF9C,0xF7CD,0xFBE6,0x68ED,0x7B21,0x7E96,
  2384.     0x77CD,0x7BE6,0x7DF1,0x7522,0x7F49,0x7EFE,0x7EFF,0x7EFF,0x7EFF,
  2385.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2386.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,
  2387.     0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x7EFF,0x2D4F,
  2388.     0xF4E0,0xC241,0xE05F,0xF02D,0xF817,0xFC0A,0x77E5,0x7C6A,0x7F31,
  2389.     0x7817,0x7C0B,0x7E05,0x7F00,0x7F0C,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2390.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2391.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2392.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x2B1D,
  2393.     0xEB4A,0xC91D,0xE1A6,0xF0B7,0xF85A,0xFC2C,0x6D81,0x7DA5,0x7FC1,
  2394.     0x785A,0x7C2D,0x7E16,0x7F00,0x7FD9,0x7F18,0x7F01,0x7EFE,0x7EFE,
  2395.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2396.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2397.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x2782,
  2398.     0xE163,0xCFFB,0xE34C,0xF13A,0xF89A,0xFC4C,0x615E,0x7ED9,0x7F00,
  2399.     0x7899,0x7C4B,0x7E26,0x7F00,0x7F00,0x7F44,0x7F0F,0x7F03,0x7F00,
  2400.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2401.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2402.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x2237,
  2403.     0xD728,0xD6A1,0xE592,0xF1CA,0xF8D5,0xFC6B,0x5DFA,0x7F58,0x7F00,
  2404.     0x78D6,0x7C6A,0x7E35,0x7F00,0x7F00,0x7FD9,0x7F4F,0x7F19,0x7F08,
  2405.     0x7F02,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2406.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,
  2407.     0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x7EFE,0x1A9B,
  2408.     0xCC9C,0xDCAB,0xE8B3,0xF2A3,0xF910,0xFC86,0x7B5E,0x7DF6,0x7F00,
  2409.     0x790C,0x7C86,0x7E44,0x7F00,0x7F00,0x7F00,0x7F74,0x7F3D,0x7F1D,
  2410.     0x7F0E,0x7F06,0x7F02,0x7F01,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,
  2411.     0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,
  2412.     0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x7F00,0x12E3
  2413. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top