SHARE
TWEET

ahxplay v0.22

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