daily pastebin goal
66%
SHARE
TWEET

ahxplay v0.23

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