History

Pushed v1.39 code

- Fixed yet another issue where junk could be drawn after the loop end point in the sample data's waveform in the sample editor (if zoomed out) - Fixed an issue with loading XMs with more than 128 instruments (OpenMPT etc). This only worked if the extra instruments were empty. Now it will properly load the extra instruments and discard them after the loading was complete (since we only support up to 128 instruments) - Small code cleanup

Olav Sørensen committed 6 years ago

Commit ee4c8981 parent a58a77611 files · +350 −316Browse files

Unified · Split

11 files
  1. src/ft2_audio.c +18 −20
  2. src/ft2_header.h +1 −1
  3. src/ft2_module_loader.c +191 −163
  4. src/ft2_replayer.c +3 −3
  5. src/ft2_sample_ed.c +20 −14
  6. src/ft2_scopes.c +2 −0
  7. src/mixer/ft2_center_mix.c +36 −36
  8. src/mixer/ft2_center_mix.h +36 −36
  9. src/mixer/ft2_mix.c +36 −36
  10. src/mixer/ft2_mix.h +1 −1
  11. src/mixer/ft2_mix_macros.h +6 −6
src/ft2_audio.c+18−20
@@ -545,7 +545,7 @@ static void sendSamples32BitMultiChan(uint8_t *stream, uint32_t sampleBlockLengt · 544 unmodified lines
545 }545 }
546}546}
547 547
548static void doChannelMixing(int32_t samplesToMix)548static void doChannelMixing(int32_t bufferPosition, int32_t samplesToMix)
549{549{
550 voice_t *v = voice; // normal voices550 voice_t *v = voice; // normal voices
551 voice_t *r = &voice[MAX_VOICES]; // volume ramp fadeout-voices551 voice_t *r = &voice[MAX_VOICES]; // volume ramp fadeout-voices
@@ -572,29 +572,17 @@ static void doChannelMixing(int32_t samplesToMix) · 20 unmodified lines
572 centerMixFlag = v->dVolL == v->dVolR;572 centerMixFlag = v->dVolL == v->dVolR;
573 }573 }
574 574
575 mixFuncTab[(centerMixFlag * 36) + (volRampFlag * 18) + v->mixFuncOffset](v, samplesToMix);575 mixFuncTab[(centerMixFlag * 36) + (volRampFlag * 18) + v->mixFuncOffset](v, bufferPosition, samplesToMix);
576 }576 }
577 577
578 if (r->active) // volume ramp fadeout-voice578 if (r->active) // volume ramp fadeout-voice
579 {579 {
580 const bool centerMixFlag = (r->dDestVolL == r->dDestVolR) && (r->dVolDeltaL == r->dVolDeltaR);580 const bool centerMixFlag = (r->dDestVolL == r->dDestVolR) && (r->dVolDeltaL == r->dVolDeltaR);
581 mixFuncTab[(centerMixFlag * 36) + 18 + r->mixFuncOffset](r, samplesToMix);581 mixFuncTab[(centerMixFlag * 36) + 18 + r->mixFuncOffset](r, bufferPosition, samplesToMix);
582 }582 }
583 }583 }
584}584}
585 585
586static void mixAudio(uint8_t *stream, uint32_t sampleBlockLength, uint8_t numAudioChannels)
587{
588 assert(sampleBlockLength <= MAX_WAV_RENDER_SAMPLES_PER_TICK);
589 memset(audio.dMixBufferL, 0, sampleBlockLength * sizeof (double));
590 memset(audio.dMixBufferR, 0, sampleBlockLength * sizeof (double));
591
592 doChannelMixing(sampleBlockLength);
593
594 // normalize mix buffer and send to audio stream
595 sendAudSamplesFunc(stream, sampleBlockLength, numAudioChannels);
596}
597
598// used for song-to-WAV renderer586// used for song-to-WAV renderer
599void mixReplayerTickToBuffer(uint32_t samplesToMix, uint8_t *stream, uint8_t bitDepth)587void mixReplayerTickToBuffer(uint32_t samplesToMix, uint8_t *stream, uint8_t bitDepth)
600{588{
@@ -602,7 +590,7 @@ void mixReplayerTickToBuffer(uint32_t samplesToMix, uint8_t *stream, uint8_t bit · 1 unmodified line
602 memset(audio.dMixBufferL, 0, samplesToMix * sizeof (double));590 memset(audio.dMixBufferL, 0, samplesToMix * sizeof (double));
603 memset(audio.dMixBufferR, 0, samplesToMix * sizeof (double));591 memset(audio.dMixBufferR, 0, samplesToMix * sizeof (double));
604 592
605 doChannelMixing(samplesToMix);593 doChannelMixing(0, samplesToMix);
606 594
607 // normalize mix buffer and send to audio stream595 // normalize mix buffer and send to audio stream
608 if (bitDepth == 16)596 if (bitDepth == 16)
@@ -932,10 +920,17 @@ static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len) · 323 unmodified lines
932 if (editor.wavIsRendering)920 if (editor.wavIsRendering)
933 return;921 return;
934 922
935 int32_t samplesLeft = len / pmpCountDiv;923 len /= pmpCountDiv; // bytes -> samples
936 if (samplesLeft <= 0)924 if (len <= 0)
937 return;925 return;
938 926
927 assert(len <= MAX_WAV_RENDER_SAMPLES_PER_TICK);
928 memset(audio.dMixBufferL, 0, len * sizeof (double));
929 memset(audio.dMixBufferR, 0, len * sizeof (double));
930
931 int32_t bufferPosition = 0;
932
933 int32_t samplesLeft = len;
939 while (samplesLeft > 0)934 while (samplesLeft > 0)
940 {935 {
941 if (audio.dTickSampleCounter <= 0.0)936 if (audio.dTickSampleCounter <= 0.0)
@@ -962,13 +957,16 @@ static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len) · 20 unmodified lines
962 if (samplesToMix > remainingTick)957 if (samplesToMix > remainingTick)
963 samplesToMix = remainingTick;958 samplesToMix = remainingTick;
964 959
965 mixAudio(stream, samplesToMix, pmpChannels);960 doChannelMixing(bufferPosition, samplesToMix);
966 stream += samplesToMix * pmpCountDiv;
967 961
962 bufferPosition += samplesToMix;
968 samplesLeft -= samplesToMix;963 samplesLeft -= samplesToMix;
969 audio.dTickSampleCounter -= samplesToMix;964 audio.dTickSampleCounter -= samplesToMix;
970 }965 }
971 966
967 // normalize mix buffer and send to audio stream
968 sendAudSamplesFunc(stream, len, pmpChannels);
969
972 (void)userdata; // make compiler not complain970 (void)userdata; // make compiler not complain
973}971}
974 972
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#endif12#endif
13#include "ft2_replayer.h"13#include "ft2_replayer.h"
14 14
15#define PROG_VER_STR "1.38"15#define PROG_VER_STR "1.39"
16 16
17// do NOT change these! It will only mess things up...17// do NOT change these! It will only mess things up...
18 18
src/ft2_module_loader.c+191−163
@@ -138,7 +138,7 @@ static SDL_Thread *thread; · 137 unmodified lines
138static int16_t pattLensTmp[MAX_PATTERNS];138static int16_t pattLensTmp[MAX_PATTERNS];
139static uint32_t extraSampleLengths[32-MAX_SMP_PER_INST]; // ModPlug Tracker & OpenMPT supports up to 32 samples per instrument in .XM139static uint32_t extraSampleLengths[32-MAX_SMP_PER_INST]; // ModPlug Tracker & OpenMPT supports up to 32 samples per instrument in .XM
140static tonTyp *pattTmp[MAX_PATTERNS];140static tonTyp *pattTmp[MAX_PATTERNS];
141static instrTyp *instrTmp[1+MAX_INST];141static instrTyp *instrTmp[1+256];
142static songTyp songTmp;142static songTyp songTmp;
143 143
144static void setupLoadedModule(void);144static void setupLoadedModule(void);
@@ -1724,6 +1724,12 @@ bool doLoadMusic(bool externalThreadFlag) · 1579 unmodified lines
1724 goto xmLoadError;1724 goto xmLoadError;
1725 }1725 }
1726 1726
1727 if (h.antInstrs > 256) // if >128 instruments, we fake-load up to 128 extra instruments and discard them
1728 {
1729 showMsg(0, "System message", "Error loading XM: This file is corrupt.");
1730 goto xmLoadError;
1731 }
1732
1727 fseek(f, 60 + h.headerSize, SEEK_SET);1733 fseek(f, 60 + h.headerSize, SEEK_SET);
1728 if (filelength != 336 && feof(f)) // 336 in length at this point = empty XM1734 if (filelength != 336 && feof(f)) // 336 in length at this point = empty XM
1729 {1735 {
@@ -1806,8 +1812,24 @@ bool doLoadMusic(bool externalThreadFlag) · 76 unmodified lines
1806 1812
1807 for (i = 1; i <= h.antInstrs; i++)1813 for (i = 1; i <= h.antInstrs; i++)
1808 {1814 {
1809 if (!loadInstrHeader(f, i, externalThreadFlag)) goto xmLoadError;1815 if (!loadInstrHeader(f, i, externalThreadFlag))
1810 if (!loadInstrSample(f, i, externalThreadFlag)) goto xmLoadError;1816 goto xmLoadError;
1817
1818 if (!loadInstrSample(f, i, externalThreadFlag))
1819 goto xmLoadError;
1820 }
1821 }
1822
1823 // if we temporarily loaded more than 128 instruments, clear the extra allocated memory
1824 if (h.antInstrs > MAX_INST)
1825 {
1826 for (i = MAX_INST+1; i <= h.antInstrs; i++)
1827 {
1828 if (instrTmp[i] != NULL)
1829 {
1830 free(instrTmp[i]);
1831 instrTmp[i] = NULL;
1832 }
1811 }1833 }
1812 }1834 }
1813 1835
@@ -1937,8 +1959,8 @@ static void freeTmpModule(void) // called on module load error · 123 unmodified lines
1937 }1959 }
1938 }1960 }
1939 1961
1940 // free all samples1962 // free all instruments and samples
1941 for (i = 1; i <= MAX_INST; i++)1963 for (i = 1; i <= 256; i++) // if >128 instruments, we fake-load up to 128 extra (and discard them later)
1942 {1964 {
1943 if (instrTmp[i] != NULL)1965 if (instrTmp[i] != NULL)
1944 {1966 {
@@ -1996,7 +2018,7 @@ static bool loadInstrHeader(FILE *f, uint16_t i, bool externalThreadFlag) · 51 unmodified lines
1996 return false;2018 return false;
1997 }2019 }
1998 2020
1999 if (i <= MAX_INST)2021 if (i <= MAX_INST) // copy over instrument names
2000 {2022 {
2001 // trim off spaces at end of name2023 // trim off spaces at end of name
2002 for (k = 21; k >= 0; k--)2024 for (k = 21; k >= 0; k--)
@@ -2013,73 +2035,70 @@ static bool loadInstrHeader(FILE *f, uint16_t i, bool externalThreadFlag) · 10 unmodified lines
2013 2035
2014 if (ih.antSamp > 0)2036 if (ih.antSamp > 0)
2015 {2037 {
2016 if (i <= MAX_INST)2038 if (!allocateTmpInstr(i))
2017 {2039 {
2018 if (!allocateTmpInstr(i))2040 showMsg(0, "System message", "Not enough memory!");
2019 {2041 return false;
2020 showMsg(0, "System message", "Not enough memory!");2042 }
2021 return false;
2022 }
2023 2043
2024 // copy instrument header elements to our instrument struct2044 // copy instrument header elements to our instrument struct
2025 2045
2026 ins = instrTmp[i];2046 ins = instrTmp[i];
2027 memcpy(ins->ta, ih.ta, 96);2047 memcpy(ins->ta, ih.ta, 96);
2028 memcpy(ins->envVP, ih.envVP, 12*2*sizeof(int16_t));2048 memcpy(ins->envVP, ih.envVP, 12*2*sizeof(int16_t));
2029 memcpy(ins->envPP, ih.envPP, 12*2*sizeof(int16_t));2049 memcpy(ins->envPP, ih.envPP, 12*2*sizeof(int16_t));
2030 ins->envVPAnt = ih.envVPAnt;2050 ins->envVPAnt = ih.envVPAnt;
2031 ins->envPPAnt = ih.envPPAnt;2051 ins->envPPAnt = ih.envPPAnt;
2032 ins->envVSust = ih.envVSust;2052 ins->envVSust = ih.envVSust;
2033 ins->envVRepS = ih.envVRepS;2053 ins->envVRepS = ih.envVRepS;
2034 ins->envVRepE = ih.envVRepE;2054 ins->envVRepE = ih.envVRepE;
2035 ins->envPSust = ih.envPSust;2055 ins->envPSust = ih.envPSust;
2036 ins->envPRepS = ih.envPRepS;2056 ins->envPRepS = ih.envPRepS;
2037 ins->envPRepE = ih.envPRepE;2057 ins->envPRepE = ih.envPRepE;
2038 ins->envVTyp = ih.envVTyp;2058 ins->envVTyp = ih.envVTyp;
2039 ins->envPTyp = ih.envPTyp;2059 ins->envPTyp = ih.envPTyp;
2040 ins->vibTyp = ih.vibTyp;2060 ins->vibTyp = ih.vibTyp;
2041 ins->vibSweep = ih.vibSweep;2061 ins->vibSweep = ih.vibSweep;
2042 ins->vibDepth = ih.vibDepth;2062 ins->vibDepth = ih.vibDepth;
2043 ins->vibRate = ih.vibRate;2063 ins->vibRate = ih.vibRate;
2044 ins->fadeOut = ih.fadeOut;2064 ins->fadeOut = ih.fadeOut;
2045 ins->midiOn = (ih.midiOn == 1) ? true : false;2065 ins->midiOn = (ih.midiOn == 1) ? true : false;
2046 ins->midiChannel = ih.midiChannel;2066 ins->midiChannel = ih.midiChannel;
2047 ins->midiProgram = ih.midiProgram;2067 ins->midiProgram = ih.midiProgram;
2048 ins->midiBend = ih.midiBend;2068 ins->midiBend = ih.midiBend;
2049 ins->mute = (ih.mute == 1) ? true : false;2069 ins->mute = (ih.mute == 1) ? true : false;
2050 ins->antSamp = ih.antSamp; // used in loadInstrSample()2070 ins->antSamp = ih.antSamp; // used in loadInstrSample()
2051 2071
2052 // sanitize stuff for broken/unsupported instruments2072 // sanitize stuff for broken/unsupported instruments
2053 ins->midiProgram = CLAMP(ins->midiProgram, 0, 127);2073 ins->midiProgram = CLAMP(ins->midiProgram, 0, 127);
2054 ins->midiBend = CLAMP(ins->midiBend, 0, 36);2074 ins->midiBend = CLAMP(ins->midiBend, 0, 36);
2055 2075
2056 if (ins->midiChannel > 15) ins->midiChannel = 15;2076 if (ins->midiChannel > 15) ins->midiChannel = 15;
2057 if (ins->vibDepth > 0x0F) ins->vibDepth = 0x0F;2077 if (ins->vibDepth > 0x0F) ins->vibDepth = 0x0F;
2058 if (ins->vibRate > 0x3F) ins->vibRate = 0x3F;2078 if (ins->vibRate > 0x3F) ins->vibRate = 0x3F;
2059 if (ins->vibTyp > 3) ins->vibTyp = 0;2079 if (ins->vibTyp > 3) ins->vibTyp = 0;
2060 2080
2061 for (j = 0; j < 96; j++)2081 for (j = 0; j < 96; j++)
2062 {2082 {
2063 if (ins->ta[j] >= MAX_SMP_PER_INST)2083 if (ins->ta[j] >= MAX_SMP_PER_INST)
2064 ins->ta[j] = MAX_SMP_PER_INST-1;2084 ins->ta[j] = MAX_SMP_PER_INST-1;
2065 }2085 }
2066 2086
2067 if (ins->envVPAnt > 12) ins->envVPAnt = 12;2087 if (ins->envVPAnt > 12) ins->envVPAnt = 12;
2068 if (ins->envVRepS > 11) ins->envVRepS = 11;2088 if (ins->envVRepS > 11) ins->envVRepS = 11;
2069 if (ins->envVRepE > 11) ins->envVRepE = 11;2089 if (ins->envVRepE > 11) ins->envVRepE = 11;
2070 if (ins->envVSust > 11) ins->envVSust = 11;2090 if (ins->envVSust > 11) ins->envVSust = 11;
2071 if (ins->envPPAnt > 12) ins->envPPAnt = 12;2091 if (ins->envPPAnt > 12) ins->envPPAnt = 12;
2072 if (ins->envPRepS > 11) ins->envPRepS = 11;2092 if (ins->envPRepS > 11) ins->envPRepS = 11;
2073 if (ins->envPRepE > 11) ins->envPRepE = 11;2093 if (ins->envPRepE > 11) ins->envPRepE = 11;
2074 if (ins->envPSust > 11) ins->envPSust = 11;2094 if (ins->envPSust > 11) ins->envPSust = 11;
2075 2095
2076 for (j = 0; j < 12; j++)2096 for (j = 0; j < 12; j++)
2077 {2097 {
2078 if ((uint16_t)ins->envVP[j][0] > 32767) ins->envVP[j][0] = 32767;2098 if ((uint16_t)ins->envVP[j][0] > 32767) ins->envVP[j][0] = 32767;
2079 if ((uint16_t)ins->envPP[j][0] > 32767) ins->envPP[j][0] = 32767;2099 if ((uint16_t)ins->envPP[j][0] > 32767) ins->envPP[j][0] = 32767;
2080 if ((uint16_t)ins->envVP[j][1] > 64) ins->envVP[j][1] = 64;2100 if ((uint16_t)ins->envVP[j][1] > 64) ins->envVP[j][1] = 64;
2081 if ((uint16_t)ins->envPP[j][1] > 63) ins->envPP[j][1] = 63;2101 if ((uint16_t)ins->envPP[j][1] > 63) ins->envPP[j][1] = 63;
2082 }
2083 }2102 }
2084 2103
2085 int32_t sampleHeadersToRead = ih.antSamp;2104 int32_t sampleHeadersToRead = ih.antSamp;
@@ -2103,43 +2122,40 @@ static bool loadInstrHeader(FILE *f, uint16_t i, bool externalThreadFlag) · 17 unmodified lines
2103 }2122 }
2104 }2123 }
2105 2124
2106 if (i <= MAX_INST)2125 for (j = 0; j < sampleHeadersToRead; j++)
2107 {2126 {
2108 for (j = 0; j < sampleHeadersToRead; j++)2127 s = &instrTmp[i]->samp[j];
2109 {2128 src = &ih.samp[j];
2110 s = &instrTmp[i]->samp[j];
2111 src = &ih.samp[j];
2112
2113 // copy sample header elements to our sample struct
2114
2115 s->len = src->len;
2116 s->repS = src->repS;
2117 s->repL = src->repL;
2118 s->vol = src->vol;
2119 s->fine = src->fine;
2120 s->typ = src->typ;
2121 s->pan = src->pan;
2122 s->relTon = src->relTon;
2123 memcpy(s->name, src->name, 22);
2124 s->name[22] = '\0';
2125
2126 // dst->pek is set up later
2127
2128 // trim off spaces at end of name
2129 for (k = 21; k >= 0; k--)
2130 {
2131 if (s->name[k] == ' ' || s->name[k] == 0x1A)
2132 s->name[k] = '\0';
2133 else
2134 break;
2135 }
2136 2129
2137 // sanitize stuff broken/unsupported samples2130 // copy sample header elements to our sample struct
2138 if (s->vol > 64)
2139 s->vol = 64;
2140 2131
2141 s->relTon = CLAMP(s->relTon, -48, 71);2132 s->len = src->len;
2133 s->repS = src->repS;
2134 s->repL = src->repL;
2135 s->vol = src->vol;
2136 s->fine = src->fine;
2137 s->typ = src->typ;
2138 s->pan = src->pan;
2139 s->relTon = src->relTon;
2140 memcpy(s->name, src->name, 22);
2141 s->name[22] = '\0';
2142
2143 // dst->pek is set up later
2144
2145 // trim off spaces at end of name
2146 for (k = 21; k >= 0; k--)
2147 {
2148 if (s->name[k] == ' ' || s->name[k] == 0x1A)
2149 s->name[k] = '\0';
2150 else
2151 break;
2142 }2152 }
2153
2154 // sanitize stuff broken/unsupported samples
2155 if (s->vol > 64)
2156 s->vol = 64;
2157
2158 s->relTon = CLAMP(s->relTon, -48, 71);
2143 }2159 }
2144 }2160 }
2145 2161
@@ -2165,90 +2181,102 @@ static bool loadInstrSample(FILE *f, uint16_t i, bool externalThreadFlag) · 19 unmodified lines
2165 2181
2166 showMsg = externalThreadFlag ? okBoxThreadSafe : okBox;2182 showMsg = externalThreadFlag ? okBoxThreadSafe : okBox;
2167 2183
2168 if (i > MAX_INST || instrTmp[i] == NULL)2184 if (instrTmp[i] == NULL)
2169 return true; // yes, let's just pretend they got loaded2185 return true; // empty instrument, let's just pretend it got loaded successfully
2170 2186
2171 k = instrTmp[i]->antSamp;2187 k = instrTmp[i]->antSamp;
2172 if (k > MAX_SMP_PER_INST)2188 if (k > MAX_SMP_PER_INST)
2173 k = MAX_SMP_PER_INST;2189 k = MAX_SMP_PER_INST;
2174 2190
2175 for (j = 0; j < k; j++)2191 if (i > MAX_INST) // insNum > 128, just skip sample data
2176 {2192 {
2177 s = &instrTmp[i]->samp[j];2193 for (j = 0; j < k; j++)
2178
2179 // if a sample has both forward loop and pingpong loop set, make it pingpong loop only (FT2 mixer behavior)
2180 if ((s->typ & 3) == 3)
2181 s->typ &= 0xFE;
2182
2183 l = s->len;
2184 if (l <= 0)
2185 {2194 {
2186 s->pek = NULL;2195 s = &instrTmp[i]->samp[j];
2187 s->len = 0;2196 if (s->len > 0)
2188 s->repL = 0;2197 fseek(f, s->len, SEEK_CUR);
2189 s->repS = 0;
2190
2191 if (s->typ & 32)
2192 s->typ &= ~32; // remove stereo flag
2193 }2198 }
2194 else2199 }
2200 else
2201 {
2202 for (j = 0; j < k; j++)
2195 {2203 {
2196 bytesToSkip = 0;2204 s = &instrTmp[i]->samp[j];
2197 if (l > MAX_SAMPLE_LEN)
2198 {
2199 bytesToSkip = l - MAX_SAMPLE_LEN;
2200 l = MAX_SAMPLE_LEN;
2201 }
2202 2205
2203 s->pek = NULL;2206 // if a sample has both forward loop and pingpong loop set, make it pingpong loop only (FT2 mixer behavior)
2204 s->origPek = (int8_t *)malloc(l + LOOP_FIX_LEN);2207 if ((s->typ & 3) == 3)
2205 if (s->origPek == NULL)2208 s->typ &= 0xFE;
2206 {
2207 showMsg(0, "System message", "Not enough memory!");
2208 return false;
2209 }
2210 2209
2211 s->pek = s->origPek + SMP_DAT_OFFSET;2210 l = s->len;
2212 2211 if (l <= 0)
2213 const int32_t bytesRead = (int32_t)fread(s->pek, 1, l, f);
2214 if (bytesRead < l)
2215 {2212 {
2216 const int32_t bytesToClear = l - bytesRead;2213 s->pek = NULL;
2217 memset(&s->pek[bytesRead], 0, bytesToClear);2214 s->len = 0;
2215 s->repL = 0;
2216 s->repS = 0;
2217
2218 if (s->typ & 32)
2219 s->typ &= ~32; // remove stereo flag
2218 }2220 }
2221 else
2222 {
2223 bytesToSkip = 0;
2224 if (l > MAX_SAMPLE_LEN)
2225 {
2226 bytesToSkip = l - MAX_SAMPLE_LEN;
2227 l = MAX_SAMPLE_LEN;
2228 }
2229
2230 s->pek = NULL;
2231 s->origPek = (int8_t *)malloc(l + LOOP_FIX_LEN);
2232 if (s->origPek == NULL)
2233 {
2234 showMsg(0, "System message", "Not enough memory!");
2235 return false;
2236 }
2219 2237
2220 if (bytesToSkip > 0)2238 s->pek = s->origPek + SMP_DAT_OFFSET;
2221 fseek(f, bytesToSkip, SEEK_CUR);
2222 2239
2223 delta2Samp(s->pek, l, s->typ);2240 const int32_t bytesRead = (int32_t)fread(s->pek, 1, l, f);
2241 if (bytesRead < l)
2242 {
2243 const int32_t bytesToClear = l - bytesRead;
2244 memset(&s->pek[bytesRead], 0, bytesToClear);
2245 }
2224 2246
2225 if (s->typ & 32) // stereo sample - already downmixed to mono in delta2samp()2247 if (bytesToSkip > 0)
2226 {2248 fseek(f, bytesToSkip, SEEK_CUR);
2227 s->typ &= ~32; // remove stereo flag
2228 2249
2229 s->len >>= 1;2250 delta2Samp(s->pek, l, s->typ);
2230 s->repL >>= 1;
2231 s->repS >>= 1;
2232 2251
2233 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);2252 if (s->typ & 32) // stereo sample - already downmixed to mono in delta2samp()
2234 if (newPtr != NULL)
2235 {2253 {
2236 s->origPek = newPtr;2254 s->typ &= ~32; // remove stereo flag
2237 s->pek = s->origPek + SMP_DAT_OFFSET;2255
2256 s->len >>= 1;
2257 s->repL >>= 1;
2258 s->repS >>= 1;
2259
2260 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
2261 if (newPtr != NULL)
2262 {
2263 s->origPek = newPtr;
2264 s->pek = s->origPek + SMP_DAT_OFFSET;
2265 }
2238 }2266 }
2239 }2267 }
2240 }
2241 2268
2242 // NON-FT2 FIX: Align to 2-byte if 16-bit sample2269 // NON-FT2 FIX: Align to 2-byte if 16-bit sample
2243 if (s->typ & 16)2270 if (s->typ & 16)
2244 {2271 {
2245 s->repL &= 0xFFFFFFFE;2272 s->repL &= 0xFFFFFFFE;
2246 s->repS &= 0xFFFFFFFE;2273 s->repS &= 0xFFFFFFFE;
2247 s->len &= 0xFFFFFFFE;2274 s->len &= 0xFFFFFFFE;
2248 }2275 }
2249 2276
2250 checkSampleRepeat(s);2277 checkSampleRepeat(s);
2251 fixSample(s);2278 fixSample(s);
2279 }
2252 }2280 }
2253 2281
2254 if (instrTmp[i]->antSamp > MAX_SMP_PER_INST)2282 if (instrTmp[i]->antSamp > MAX_SMP_PER_INST)
src/ft2_replayer.c+3−3
@@ -2943,7 +2943,7 @@ void playTone(uint8_t stmm, uint8_t inst, uint8_t ton, int8_t vol, uint16_t midi · 2942 unmodified lines
2943 if (ins == NULL)2943 if (ins == NULL)
2944 return;2944 return;
2945 2945
2946 assert(stmm < MAX_VOICES && inst < MAX_INST && ton <= 97);2946 assert(stmm < MAX_VOICES && inst <= MAX_INST && ton <= 97);
2947 ch = &stm[stmm];2947 ch = &stm[stmm];
2948 2948
2949 // FT2 bugfix: Don't play tone if certain requirements are not met2949 // FT2 bugfix: Don't play tone if certain requirements are not met
@@ -3010,7 +3010,7 @@ void playSample(uint8_t stmm, uint8_t inst, uint8_t smpNr, uint8_t ton, uint16_t · 60 unmodified lines
3010 editor.curPlayInstr = 255;3010 editor.curPlayInstr = 255;
3011 editor.curPlaySmp = 255;3011 editor.curPlaySmp = 255;
3012 3012
3013 assert(stmm < MAX_VOICES && inst < MAX_INST && smpNr < MAX_SMP_PER_INST && ton <= 97);3013 assert(stmm < MAX_VOICES && inst <= MAX_INST && smpNr < MAX_SMP_PER_INST && ton <= 97);
3014 ch = &stm[stmm];3014 ch = &stm[stmm];
3015 3015
3016 memcpy(&instr[130]->samp[0], &instr[inst]->samp[smpNr], sizeof (sampleTyp));3016 memcpy(&instr[130]->samp[0], &instr[inst]->samp[smpNr], sizeof (sampleTyp));
@@ -3066,7 +3066,7 @@ void playRange(uint8_t stmm, uint8_t inst, uint8_t smpNr, uint8_t ton, uint16_t · 49 unmodified lines
3066 editor.curPlayInstr = 255;3066 editor.curPlayInstr = 255;
3067 editor.curPlaySmp = 255;3067 editor.curPlaySmp = 255;
3068 3068
3069 assert(stmm < MAX_VOICES && inst < MAX_INST && smpNr < MAX_SMP_PER_INST && ton <= 97);3069 assert(stmm < MAX_VOICES && inst <= MAX_INST && smpNr < MAX_SMP_PER_INST && ton <= 97);
3070 3070
3071 ch = &stm[stmm];3071 ch = &stm[stmm];
3072 s = &instr[130]->samp[0];3072 s = &instr[130]->samp[0];
src/ft2_sample_ed.c+20−14
@@ -1069,7 +1069,7 @@ static void getMinMax8(const void *p, uint32_t scanLen, int8_t *min8, int8_t *ma · 1068 unmodified lines
1069 }1069 }
1070}1070}
1071 1071
1072// for scanning sample data peak where loopEnd+NUM_FIXED_TAP_SAMPLES is within scan range (fixed interpolation tap samples)1072// for scanning sample data peak where loopEnd+SINC_RIGHT_TAPS is within scan range (fixed interpolation tap samples)
1073static void getSpecialMinMax16(sampleTyp *s, int32_t index, int32_t scanEnd, int16_t *min16, int16_t *max16)1073static void getSpecialMinMax16(sampleTyp *s, int32_t index, int32_t scanEnd, int16_t *min16, int16_t *max16)
1074{1074{
1075 int16_t minVal, maxVal, minVal2, maxVal2;1075 int16_t minVal, maxVal, minVal2, maxVal2;
@@ -1079,19 +1079,22 @@ static void getSpecialMinMax16(sampleTyp *s, int32_t index, int32_t scanEnd, int · 3 unmodified lines
1079 minVal = 32767;1079 minVal = 32767;
1080 maxVal = -32768;1080 maxVal = -32768;
1081 1081
1082 // read peak samples before fixed samples1082 // read samples before fixed samples (if needed)
1083 if (index < s->fixedPos)1083 if (index < s->fixedPos)
1084 {1084 {
1085 getMinMax16(&ptr16[index], s->fixedPos-index, &minVal, &maxVal);1085 getMinMax16(&ptr16[index], s->fixedPos-index, &minVal, &maxVal);
1086 index += s->fixedPos-index;1086 index = s->fixedPos;
1087 }1087 }
1088 1088
1089 // read fixed samples1089 // read fixed samples (we are guaranteed to be within the fixed samples here)
1090 int32_t tmpScanEnd = index+SINC_RIGHT_TAPS;1090 const int32_t tapIndex = index-s->fixedPos;
1091 const int32_t scanLength = SINC_RIGHT_TAPS-tapIndex;
1092
1093 int32_t tmpScanEnd = index+scanLength;
1091 if (tmpScanEnd > scanEnd)1094 if (tmpScanEnd > scanEnd)
1092 tmpScanEnd = scanEnd;1095 tmpScanEnd = scanEnd;
1093 1096
1094 const int16_t *smpReadPtr = s->fixedSmp;1097 const int16_t *smpReadPtr = s->fixedSmp + tapIndex;
1095 for (; index < tmpScanEnd; index++)1098 for (; index < tmpScanEnd; index++)
1096 {1099 {
1097 const int16_t smp16 = *smpReadPtr++;1100 const int16_t smp16 = *smpReadPtr++;
@@ -1099,7 +1102,7 @@ static void getSpecialMinMax16(sampleTyp *s, int32_t index, int32_t scanEnd, int · 1 unmodified line
1099 if (smp16 > maxVal) maxVal = smp16;1102 if (smp16 > maxVal) maxVal = smp16;
1100 }1103 }
1101 1104
1102 // read peak samples after fixed samples1105 // read samples after fixed samples (if needed)
1103 if (index < scanEnd)1106 if (index < scanEnd)
1104 {1107 {
1105 getMinMax16(&ptr16[index], scanEnd-index, &minVal2, &maxVal2);1108 getMinMax16(&ptr16[index], scanEnd-index, &minVal2, &maxVal2);
@@ -1111,7 +1114,7 @@ static void getSpecialMinMax16(sampleTyp *s, int32_t index, int32_t scanEnd, int · 5 unmodified lines
1111 *max16 = maxVal;1114 *max16 = maxVal;
1112}1115}
1113 1116
1114// for scanning sample data peak where loopEnd+NUM_FIXED_TAP_SAMPLES is within scan range (fixed interpolation tap samples)1117// for scanning sample data peak where loopEnd+SINC_RIGHT_TAPS is within scan range (fixed interpolation tap samples)
1115static void getSpecialMinMax8(sampleTyp *s, int32_t index, int32_t scanEnd, int8_t *min8, int8_t *max8)1118static void getSpecialMinMax8(sampleTyp *s, int32_t index, int32_t scanEnd, int8_t *min8, int8_t *max8)
1116{1119{
1117 int8_t minVal, maxVal, minVal2, maxVal2;1120 int8_t minVal, maxVal, minVal2, maxVal2;
@@ -1121,19 +1124,22 @@ static void getSpecialMinMax8(sampleTyp *s, int32_t index, int32_t scanEnd, int8 · 3 unmodified lines
1121 minVal = 127;1124 minVal = 127;
1122 maxVal = -128;1125 maxVal = -128;
1123 1126
1124 // read peak samples before fixed samples1127 // read samples before fixed samples (if needed)
1125 if (index < s->fixedPos)1128 if (index < s->fixedPos)
1126 {1129 {
1127 getMinMax8(&ptr8[index], s->fixedPos-index, &minVal, &maxVal);1130 getMinMax8(&ptr8[index], s->fixedPos-index, &minVal, &maxVal);
1128 index += s->fixedPos-index;1131 index = s->fixedPos;
1129 }1132 }
1130 1133
1131 // read fixed samples1134 // read fixed samples (we are guaranteed to be within the fixed samples here)
1132 int32_t tmpScanEnd = index+SINC_RIGHT_TAPS;1135 const int32_t tapIndex = index-s->fixedPos;
1136 const int32_t scanLength = SINC_RIGHT_TAPS-tapIndex;
1137
1138 int32_t tmpScanEnd = index+scanLength;
1133 if (tmpScanEnd > scanEnd)1139 if (tmpScanEnd > scanEnd)
1134 tmpScanEnd = scanEnd;1140 tmpScanEnd = scanEnd;
1135 1141
1136 const int16_t *smpReadPtr = (const int16_t *)s->fixedSmp;1142 const int16_t *smpReadPtr = (const int16_t *)s->fixedSmp + tapIndex;
1137 for (; index < tmpScanEnd; index++)1143 for (; index < tmpScanEnd; index++)
1138 {1144 {
1139 const int8_t smp8 = (int8_t)(*smpReadPtr++);1145 const int8_t smp8 = (int8_t)(*smpReadPtr++);
@@ -1141,7 +1147,7 @@ static void getSpecialMinMax8(sampleTyp *s, int32_t index, int32_t scanEnd, int8 · 1 unmodified line
1141 if (smp8 > maxVal) maxVal = smp8;1147 if (smp8 > maxVal) maxVal = smp8;
1142 }1148 }
1143 1149
1144 // read peak samples after fixed samples1150 // read samples after fixed samples (if needed)
1145 if (index < scanEnd)1151 if (index < scanEnd)
1146 {1152 {
1147 getMinMax8(&ptr8[index], scanEnd-index, &minVal2, &maxVal2);1153 getMinMax8(&ptr8[index], scanEnd-index, &minVal2, &maxVal2);
src/ft2_scopes.c+2−0
@@ -153,6 +153,8 @@ static void redrawScope(int32_t ch) · 152 unmodified lines
153 chanLookup = chansPerRow - 1;153 chanLookup = chansPerRow - 1;
154 scopeLens = scopeLenTab[chanLookup];154 scopeLens = scopeLenTab[chanLookup];
155 155
156 // get x,y,len for scope according to channel (we must do it this way since 'len' can differ!)
157
156 x = 2;158 x = 2;
157 y = 94;159 y = 94;
158 160
src/mixer/ft2_center_mix.c+36−36
@@ -10,7 +10,7 @@ · 9 unmodified lines
10/* 8-BIT CENTER MIXING ROUTINES */10/* 8-BIT CENTER MIXING ROUTINES */
11/* ----------------------------------------------------------------------- */11/* ----------------------------------------------------------------------- */
12 12
13void centerMix8bNoLoop(voice_t *v, uint32_t numSamples)13void centerMix8bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
14{14{
15 const int8_t *base, *smpPtr;15 const int8_t *base, *smpPtr;
16 double dSample, *dMixBufferL, *dMixBufferR;16 double dSample, *dMixBufferL, *dMixBufferR;
@@ -52,7 +52,7 @@ void centerMix8bNoLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
52 SET_BACK_MIXER_POS52 SET_BACK_MIXER_POS
53}53}
54 54
55void centerMix8bLoop(voice_t *v, uint32_t numSamples)55void centerMix8bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
56{56{
57 const int8_t *base, *smpPtr;57 const int8_t *base, *smpPtr;
58 double dSample, *dMixBufferL, *dMixBufferR;58 double dSample, *dMixBufferL, *dMixBufferR;
@@ -94,7 +94,7 @@ void centerMix8bLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
94 SET_BACK_MIXER_POS94 SET_BACK_MIXER_POS
95}95}
96 96
97void centerMix8bBidiLoop(voice_t *v, uint32_t numSamples)97void centerMix8bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
98{98{
99 const int8_t *base, *revBase, *smpPtr;99 const int8_t *base, *revBase, *smpPtr;
100 double dSample, *dMixBufferL, *dMixBufferR;100 double dSample, *dMixBufferL, *dMixBufferR;
@@ -138,7 +138,7 @@ void centerMix8bBidiLoop(voice_t *v, uint32_t numSamples) · 37 unmodified lines
138 SET_BACK_MIXER_POS138 SET_BACK_MIXER_POS
139}139}
140 140
141void centerMix8bNoLoopSIntrp(voice_t *v, uint32_t numSamples)141void centerMix8bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
142{142{
143 const int8_t *base, *smpPtr;143 const int8_t *base, *smpPtr;
144 double dSample, *dMixBufferL, *dMixBufferR;144 double dSample, *dMixBufferL, *dMixBufferR;
@@ -180,7 +180,7 @@ void centerMix8bNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
180 SET_BACK_MIXER_POS180 SET_BACK_MIXER_POS
181}181}
182 182
183void centerMix8bLoopSIntrp(voice_t *v, uint32_t numSamples)183void centerMix8bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
184{184{
185 const int8_t *base, *smpPtr;185 const int8_t *base, *smpPtr;
186 int8_t *smpTapPtr;186 int8_t *smpTapPtr;
@@ -247,7 +247,7 @@ void centerMix8bLoopSIntrp(voice_t *v, uint32_t numSamples) · 60 unmodified lines
247 SET_BACK_MIXER_POS247 SET_BACK_MIXER_POS
248}248}
249 249
250void centerMix8bBidiLoopSIntrp(voice_t *v, uint32_t numSamples)250void centerMix8bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
251{251{
252 const int8_t *base, *revBase, *smpPtr;252 const int8_t *base, *revBase, *smpPtr;
253 int8_t *smpTapPtr;253 int8_t *smpTapPtr;
@@ -317,7 +317,7 @@ void centerMix8bBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 63 unmodified lines
317 SET_BACK_MIXER_POS317 SET_BACK_MIXER_POS
318}318}
319 319
320void centerMix8bNoLoopLIntrp(voice_t *v, uint32_t numSamples)320void centerMix8bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
321{321{
322 const int8_t *base, *smpPtr;322 const int8_t *base, *smpPtr;
323 double dSample, *dMixBufferL, *dMixBufferR;323 double dSample, *dMixBufferL, *dMixBufferR;
@@ -359,7 +359,7 @@ void centerMix8bNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
359 SET_BACK_MIXER_POS359 SET_BACK_MIXER_POS
360}360}
361 361
362void centerMix8bLoopLIntrp(voice_t *v, uint32_t numSamples)362void centerMix8bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
363{363{
364 const int8_t *base, *smpPtr;364 const int8_t *base, *smpPtr;
365 double dSample, *dMixBufferL, *dMixBufferR;365 double dSample, *dMixBufferL, *dMixBufferR;
@@ -401,7 +401,7 @@ void centerMix8bLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
401 SET_BACK_MIXER_POS401 SET_BACK_MIXER_POS
402}402}
403 403
404void centerMix8bBidiLoopLIntrp(voice_t *v, uint32_t numSamples)404void centerMix8bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
405{405{
406 const int8_t *base, *revBase, *smpPtr;406 const int8_t *base, *revBase, *smpPtr;
407 double dSample, *dMixBufferL, *dMixBufferR;407 double dSample, *dMixBufferL, *dMixBufferR;
@@ -445,7 +445,7 @@ void centerMix8bBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 37 unmodified lines
445 SET_BACK_MIXER_POS445 SET_BACK_MIXER_POS
446}446}
447 447
448void centerMix8bRampNoLoop(voice_t *v, uint32_t numSamples)448void centerMix8bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
449{449{
450 const int8_t *base, *smpPtr;450 const int8_t *base, *smpPtr;
451 double dSample, *dMixBufferL, *dMixBufferR;451 double dSample, *dMixBufferL, *dMixBufferR;
@@ -495,7 +495,7 @@ void centerMix8bRampNoLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
495 SET_BACK_MIXER_POS495 SET_BACK_MIXER_POS
496}496}
497 497
498void centerMix8bRampLoop(voice_t *v, uint32_t numSamples)498void centerMix8bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
499{499{
500 const int8_t *base, *smpPtr;500 const int8_t *base, *smpPtr;
501 double dSample, *dMixBufferL, *dMixBufferR;501 double dSample, *dMixBufferL, *dMixBufferR;
@@ -545,7 +545,7 @@ void centerMix8bRampLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
545 SET_BACK_MIXER_POS545 SET_BACK_MIXER_POS
546}546}
547 547
548void centerMix8bRampBidiLoop(voice_t *v, uint32_t numSamples)548void centerMix8bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
549{549{
550 const int8_t *base, *revBase, *smpPtr;550 const int8_t *base, *revBase, *smpPtr;
551 double dSample, *dMixBufferL, *dMixBufferR;551 double dSample, *dMixBufferL, *dMixBufferR;
@@ -597,7 +597,7 @@ void centerMix8bRampBidiLoop(voice_t *v, uint32_t numSamples) · 45 unmodified lines
597 SET_BACK_MIXER_POS597 SET_BACK_MIXER_POS
598}598}
599 599
600void centerMix8bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples)600void centerMix8bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
601{601{
602 const int8_t *base, *smpPtr;602 const int8_t *base, *smpPtr;
603 double dSample, *dMixBufferL, *dMixBufferR;603 double dSample, *dMixBufferL, *dMixBufferR;
@@ -647,7 +647,7 @@ void centerMix8bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
647 SET_BACK_MIXER_POS647 SET_BACK_MIXER_POS
648}648}
649 649
650void centerMix8bRampLoopSIntrp(voice_t *v, uint32_t numSamples)650void centerMix8bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
651{651{
652 const int8_t *base, *smpPtr;652 const int8_t *base, *smpPtr;
653 int8_t *smpTapPtr;653 int8_t *smpTapPtr;
@@ -727,7 +727,7 @@ void centerMix8bRampLoopSIntrp(voice_t *v, uint32_t numSamples) · 73 unmodified lines
727 SET_BACK_MIXER_POS727 SET_BACK_MIXER_POS
728}728}
729 729
730void centerMix8bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples)730void centerMix8bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
731{731{
732 const int8_t *base, *revBase, *smpPtr;732 const int8_t *base, *revBase, *smpPtr;
733 int8_t *smpTapPtr;733 int8_t *smpTapPtr;
@@ -809,7 +809,7 @@ void centerMix8bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 75 unmodified lines
809 SET_BACK_MIXER_POS809 SET_BACK_MIXER_POS
810}810}
811 811
812void centerMix8bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples)812void centerMix8bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
813{813{
814 const int8_t *base, *smpPtr;814 const int8_t *base, *smpPtr;
815 double dSample, *dMixBufferL, *dMixBufferR;815 double dSample, *dMixBufferL, *dMixBufferR;
@@ -859,7 +859,7 @@ void centerMix8bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
859 SET_BACK_MIXER_POS859 SET_BACK_MIXER_POS
860}860}
861 861
862void centerMix8bRampLoopLIntrp(voice_t *v, uint32_t numSamples)862void centerMix8bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
863{863{
864 const int8_t *base, *smpPtr;864 const int8_t *base, *smpPtr;
865 double dSample, *dMixBufferL, *dMixBufferR;865 double dSample, *dMixBufferL, *dMixBufferR;
@@ -909,7 +909,7 @@ void centerMix8bRampLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
909 SET_BACK_MIXER_POS909 SET_BACK_MIXER_POS
910}910}
911 911
912void centerMix8bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples)912void centerMix8bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
913{913{
914 const int8_t *base, *revBase, *smpPtr;914 const int8_t *base, *revBase, *smpPtr;
915 double dSample, *dMixBufferL, *dMixBufferR;915 double dSample, *dMixBufferL, *dMixBufferR;
@@ -965,7 +965,7 @@ void centerMix8bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 49 unmodified lines
965/* 16-BIT CENTER MIXING ROUTINES */965/* 16-BIT CENTER MIXING ROUTINES */
966/* ----------------------------------------------------------------------- */966/* ----------------------------------------------------------------------- */
967 967
968void centerMix16bNoLoop(voice_t *v, uint32_t numSamples)968void centerMix16bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
969{969{
970 const int16_t *base, *smpPtr;970 const int16_t *base, *smpPtr;
971 double dSample, *dMixBufferL, *dMixBufferR;971 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1007,7 +1007,7 @@ void centerMix16bNoLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1007 SET_BACK_MIXER_POS1007 SET_BACK_MIXER_POS
1008}1008}
1009 1009
1010void centerMix16bLoop(voice_t *v, uint32_t numSamples)1010void centerMix16bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1011{1011{
1012 const int16_t *base, *smpPtr;1012 const int16_t *base, *smpPtr;
1013 double dSample, *dMixBufferL, *dMixBufferR;1013 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1049,7 +1049,7 @@ void centerMix16bLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1049 SET_BACK_MIXER_POS1049 SET_BACK_MIXER_POS
1050}1050}
1051 1051
1052void centerMix16bBidiLoop(voice_t *v, uint32_t numSamples)1052void centerMix16bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1053{1053{
1054 const int16_t *base, *revBase, *smpPtr;1054 const int16_t *base, *revBase, *smpPtr;
1055 double dSample, *dMixBufferL, *dMixBufferR;1055 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1093,7 +1093,7 @@ void centerMix16bBidiLoop(voice_t *v, uint32_t numSamples) · 37 unmodified lines
1093 SET_BACK_MIXER_POS1093 SET_BACK_MIXER_POS
1094}1094}
1095 1095
1096void centerMix16bNoLoopSIntrp(voice_t *v, uint32_t numSamples)1096void centerMix16bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1097{1097{
1098 const int16_t *base, *smpPtr;1098 const int16_t *base, *smpPtr;
1099 double dSample, *dMixBufferL, *dMixBufferR;1099 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1135,7 +1135,7 @@ void centerMix16bNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1135 SET_BACK_MIXER_POS1135 SET_BACK_MIXER_POS
1136}1136}
1137 1137
1138void centerMix16bLoopSIntrp(voice_t *v, uint32_t numSamples)1138void centerMix16bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1139{1139{
1140 const int16_t *base, *smpPtr;1140 const int16_t *base, *smpPtr;
1141 int16_t *smpTapPtr;1141 int16_t *smpTapPtr;
@@ -1202,7 +1202,7 @@ void centerMix16bLoopSIntrp(voice_t *v, uint32_t numSamples) · 60 unmodified lines
1202 SET_BACK_MIXER_POS1202 SET_BACK_MIXER_POS
1203}1203}
1204 1204
1205void centerMix16bBidiLoopSIntrp(voice_t *v, uint32_t numSamples)1205void centerMix16bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1206{1206{
1207 const int16_t *base, *revBase, *smpPtr;1207 const int16_t *base, *revBase, *smpPtr;
1208 int16_t *smpTapPtr;1208 int16_t *smpTapPtr;
@@ -1271,7 +1271,7 @@ void centerMix16bBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 62 unmodified lines
1271 SET_BACK_MIXER_POS1271 SET_BACK_MIXER_POS
1272}1272}
1273 1273
1274void centerMix16bNoLoopLIntrp(voice_t *v, uint32_t numSamples)1274void centerMix16bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1275{1275{
1276 const int16_t *base, *smpPtr;1276 const int16_t *base, *smpPtr;
1277 double dSample, *dMixBufferL, *dMixBufferR;1277 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1313,7 +1313,7 @@ void centerMix16bNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1313 SET_BACK_MIXER_POS1313 SET_BACK_MIXER_POS
1314}1314}
1315 1315
1316void centerMix16bLoopLIntrp(voice_t *v, uint32_t numSamples)1316void centerMix16bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1317{1317{
1318 const int16_t *base, *smpPtr;1318 const int16_t *base, *smpPtr;
1319 double dSample, *dMixBufferL, *dMixBufferR;1319 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1355,7 +1355,7 @@ void centerMix16bLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1355 SET_BACK_MIXER_POS1355 SET_BACK_MIXER_POS
1356}1356}
1357 1357
1358void centerMix16bBidiLoopLIntrp(voice_t *v, uint32_t numSamples)1358void centerMix16bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1359{1359{
1360 const int16_t *base, *revBase, *smpPtr;1360 const int16_t *base, *revBase, *smpPtr;
1361 double dSample, *dMixBufferL, *dMixBufferR;1361 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1400,7 +1400,7 @@ void centerMix16bBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 38 unmodified lines
1400}1400}
1401 1401
1402 1402
1403void centerMix16bRampNoLoop(voice_t *v, uint32_t numSamples)1403void centerMix16bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1404{1404{
1405 const int16_t *base, *smpPtr;1405 const int16_t *base, *smpPtr;
1406 double dSample, *dMixBufferL, *dMixBufferR;1406 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1450,7 +1450,7 @@ void centerMix16bRampNoLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1450 SET_BACK_MIXER_POS1450 SET_BACK_MIXER_POS
1451}1451}
1452 1452
1453void centerMix16bRampLoop(voice_t *v, uint32_t numSamples)1453void centerMix16bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1454{1454{
1455 const int16_t *base, *smpPtr;1455 const int16_t *base, *smpPtr;
1456 double dSample, *dMixBufferL, *dMixBufferR;1456 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1500,7 +1500,7 @@ void centerMix16bRampLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1500 SET_BACK_MIXER_POS1500 SET_BACK_MIXER_POS
1501}1501}
1502 1502
1503void centerMix16bRampBidiLoop(voice_t *v, uint32_t numSamples)1503void centerMix16bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1504{1504{
1505 const int16_t *base, *revBase, *smpPtr;1505 const int16_t *base, *revBase, *smpPtr;
1506 double dSample, *dMixBufferL, *dMixBufferR;1506 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1552,7 +1552,7 @@ void centerMix16bRampBidiLoop(voice_t *v, uint32_t numSamples) · 45 unmodified lines
1552 SET_BACK_MIXER_POS1552 SET_BACK_MIXER_POS
1553}1553}
1554 1554
1555void centerMix16bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples)1555void centerMix16bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1556{1556{
1557 const int16_t *base, *smpPtr;1557 const int16_t *base, *smpPtr;
1558 double dSample, *dMixBufferL, *dMixBufferR;1558 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1602,7 +1602,7 @@ void centerMix16bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1602 SET_BACK_MIXER_POS1602 SET_BACK_MIXER_POS
1603}1603}
1604 1604
1605void centerMix16bRampLoopSIntrp(voice_t *v, uint32_t numSamples)1605void centerMix16bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1606{1606{
1607 const int16_t *base, *smpPtr;1607 const int16_t *base, *smpPtr;
1608 int16_t *smpTapPtr;1608 int16_t *smpTapPtr;
@@ -1682,7 +1682,7 @@ void centerMix16bRampLoopSIntrp(voice_t *v, uint32_t numSamples) · 73 unmodified lines
1682 SET_BACK_MIXER_POS1682 SET_BACK_MIXER_POS
1683}1683}
1684 1684
1685void centerMix16bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples)1685void centerMix16bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1686{1686{
1687 const int16_t *base, *revBase, *smpPtr;1687 const int16_t *base, *revBase, *smpPtr;
1688 int16_t *smpTapPtr;1688 int16_t *smpTapPtr;
@@ -1764,7 +1764,7 @@ void centerMix16bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 75 unmodified lines
1764 SET_BACK_MIXER_POS1764 SET_BACK_MIXER_POS
1765}1765}
1766 1766
1767void centerMix16bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples)1767void centerMix16bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1768{1768{
1769 const int16_t *base, *smpPtr;1769 const int16_t *base, *smpPtr;
1770 double dSample, *dMixBufferL, *dMixBufferR;1770 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1814,7 +1814,7 @@ void centerMix16bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1814 SET_BACK_MIXER_POS1814 SET_BACK_MIXER_POS
1815}1815}
1816 1816
1817void centerMix16bRampLoopLIntrp(voice_t *v, uint32_t numSamples)1817void centerMix16bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1818{1818{
1819 const int16_t *base, *smpPtr;1819 const int16_t *base, *smpPtr;
1820 double dSample, *dMixBufferL, *dMixBufferR;1820 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1864,7 +1864,7 @@ void centerMix16bRampLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1864 SET_BACK_MIXER_POS1864 SET_BACK_MIXER_POS
1865}1865}
1866 1866
1867void centerMix16bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples)1867void centerMix16bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1868{1868{
1869 const int16_t *base, *revBase, *smpPtr;1869 const int16_t *base, *revBase, *smpPtr;
1870 double dSample, *dMixBufferL, *dMixBufferR;1870 double dSample, *dMixBufferL, *dMixBufferR;
src/mixer/ft2_center_mix.h+36−36
@@ -6,47 +6,47 @@ · 5 unmodified lines
6// no volume ramping6// no volume ramping
7 7
8// 8-bit8// 8-bit
9void centerMix8bNoLoop(voice_t *v, uint32_t numSamples);9void centerMix8bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
10void centerMix8bLoop(voice_t *v, uint32_t numSamples);10void centerMix8bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
11void centerMix8bBidiLoop(voice_t *v, uint32_t numSamples);11void centerMix8bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
12void centerMix8bNoLoopSIntrp(voice_t *v, uint32_t numSamples);12void centerMix8bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
13void centerMix8bLoopSIntrp(voice_t *v, uint32_t numSamples);13void centerMix8bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
14void centerMix8bBidiLoopSIntrp(voice_t *v, uint32_t numSamples);14void centerMix8bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
15void centerMix8bNoLoopLIntrp(voice_t *v, uint32_t numSamples);15void centerMix8bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
16void centerMix8bLoopLIntrp(voice_t *v, uint32_t numSamples);16void centerMix8bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
17void centerMix8bBidiLoopLIntrp(voice_t *v, uint32_t numSamples);17void centerMix8bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
18 18
19// 16-bit19// 16-bit
20void centerMix16bNoLoop(voice_t *v, uint32_t numSamples);20void centerMix16bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
21void centerMix16bLoop(voice_t *v, uint32_t numSamples);21void centerMix16bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
22void centerMix16bBidiLoop(voice_t *v, uint32_t numSamples);22void centerMix16bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
23void centerMix16bNoLoopSIntrp(voice_t *v, uint32_t numSamples);23void centerMix16bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
24void centerMix16bLoopSIntrp(voice_t *v, uint32_t numSamples);24void centerMix16bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
25void centerMix16bBidiLoopSIntrp(voice_t *v, uint32_t numSamples);25void centerMix16bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
26void centerMix16bNoLoopLIntrp(voice_t *v, uint32_t numSamples);26void centerMix16bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
27void centerMix16bLoopLIntrp(voice_t *v, uint32_t numSamples);27void centerMix16bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
28void centerMix16bBidiLoopLIntrp(voice_t *v, uint32_t numSamples);28void centerMix16bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
29 29
30// volume ramping30// volume ramping
31 31
32// 8-bit32// 8-bit
33void centerMix8bRampNoLoop(voice_t *v, uint32_t numSamples);33void centerMix8bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
34void centerMix8bRampLoop(voice_t *v, uint32_t numSamples);34void centerMix8bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
35void centerMix8bRampBidiLoop(voice_t *v, uint32_t numSamples);35void centerMix8bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
36void centerMix8bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples);36void centerMix8bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
37void centerMix8bRampLoopSIntrp(voice_t *v, uint32_t numSamples);37void centerMix8bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
38void centerMix8bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples);38void centerMix8bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
39void centerMix8bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples);39void centerMix8bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
40void centerMix8bRampLoopLIntrp(voice_t *v, uint32_t numSamples);40void centerMix8bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
41void centerMix8bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples);41void centerMix8bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
42 42
43// 16bit43// 16bit
44void centerMix16bRampNoLoop(voice_t *v, uint32_t numSamples);44void centerMix16bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
45void centerMix16bRampLoop(voice_t *v, uint32_t numSamples);45void centerMix16bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
46void centerMix16bRampBidiLoop(voice_t *v, uint32_t numSamples);46void centerMix16bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
47void centerMix16bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples);47void centerMix16bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
48void centerMix16bRampLoopSIntrp(voice_t *v, uint32_t numSamples);48void centerMix16bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
49void centerMix16bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples);49void centerMix16bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
50void centerMix16bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples);50void centerMix16bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
51void centerMix16bRampLoopLIntrp(voice_t *v, uint32_t numSamples);51void centerMix16bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
52void centerMix16bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples);52void centerMix16bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples);
src/mixer/ft2_mix.c+36−36
@@ -31,7 +31,7 @@ · 30 unmodified lines
31/* 8-BIT MIXING ROUTINES */31/* 8-BIT MIXING ROUTINES */
32/* ----------------------------------------------------------------------- */32/* ----------------------------------------------------------------------- */
33 33
34static void mix8bNoLoop(voice_t *v, uint32_t numSamples)34static void mix8bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
35{35{
36 const int8_t *base, *smpPtr;36 const int8_t *base, *smpPtr;
37 double dSample, *dMixBufferL, *dMixBufferR;37 double dSample, *dMixBufferL, *dMixBufferR;
@@ -73,7 +73,7 @@ static void mix8bNoLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
73 SET_BACK_MIXER_POS73 SET_BACK_MIXER_POS
74}74}
75 75
76static void mix8bLoop(voice_t *v, uint32_t numSamples)76static void mix8bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
77{77{
78 const int8_t *base, *smpPtr;78 const int8_t *base, *smpPtr;
79 double dSample, *dMixBufferL, *dMixBufferR;79 double dSample, *dMixBufferL, *dMixBufferR;
@@ -115,7 +115,7 @@ static void mix8bLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
115 SET_BACK_MIXER_POS115 SET_BACK_MIXER_POS
116}116}
117 117
118static void mix8bBidiLoop(voice_t *v, uint32_t numSamples)118static void mix8bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
119{119{
120 const int8_t *base, *revBase, *smpPtr;120 const int8_t *base, *revBase, *smpPtr;
121 double dSample, *dMixBufferL, *dMixBufferR;121 double dSample, *dMixBufferL, *dMixBufferR;
@@ -158,7 +158,7 @@ static void mix8bBidiLoop(voice_t *v, uint32_t numSamples) · 36 unmodified lines
158 SET_BACK_MIXER_POS158 SET_BACK_MIXER_POS
159}159}
160 160
161static void mix8bNoLoopSIntrp(voice_t *v, uint32_t numSamples)161static void mix8bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
162{162{
163 const int8_t *base, *smpPtr;163 const int8_t *base, *smpPtr;
164 double dSample, *dMixBufferL, *dMixBufferR;164 double dSample, *dMixBufferL, *dMixBufferR;
@@ -200,7 +200,7 @@ static void mix8bNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
200 SET_BACK_MIXER_POS200 SET_BACK_MIXER_POS
201}201}
202 202
203static void mix8bLoopSIntrp(voice_t *v, uint32_t numSamples)203static void mix8bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
204{204{
205 const int8_t *base, *smpPtr;205 const int8_t *base, *smpPtr;
206 int8_t *smpTapPtr;206 int8_t *smpTapPtr;
@@ -267,7 +267,7 @@ static void mix8bLoopSIntrp(voice_t *v, uint32_t numSamples) · 60 unmodified lines
267 SET_BACK_MIXER_POS267 SET_BACK_MIXER_POS
268}268}
269 269
270static void mix8bBidiLoopSIntrp(voice_t *v, uint32_t numSamples)270static void mix8bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
271{271{
272 const int8_t *base, *revBase, *smpPtr;272 const int8_t *base, *revBase, *smpPtr;
273 int8_t *smpTapPtr;273 int8_t *smpTapPtr;
@@ -336,7 +336,7 @@ static void mix8bBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 62 unmodified lines
336 SET_BACK_MIXER_POS336 SET_BACK_MIXER_POS
337}337}
338 338
339static void mix8bNoLoopLIntrp(voice_t *v, uint32_t numSamples)339static void mix8bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
340{340{
341 const int8_t *base, *smpPtr;341 const int8_t *base, *smpPtr;
342 double dSample, *dMixBufferL, *dMixBufferR;342 double dSample, *dMixBufferL, *dMixBufferR;
@@ -378,7 +378,7 @@ static void mix8bNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
378 SET_BACK_MIXER_POS378 SET_BACK_MIXER_POS
379}379}
380 380
381static void mix8bLoopLIntrp(voice_t *v, uint32_t numSamples)381static void mix8bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
382{382{
383 const int8_t *base, *smpPtr;383 const int8_t *base, *smpPtr;
384 double dSample, *dMixBufferL, *dMixBufferR;384 double dSample, *dMixBufferL, *dMixBufferR;
@@ -420,7 +420,7 @@ static void mix8bLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
420 SET_BACK_MIXER_POS420 SET_BACK_MIXER_POS
421}421}
422 422
423static void mix8bBidiLoopLIntrp(voice_t *v, uint32_t numSamples)423static void mix8bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
424{424{
425 const int8_t *base, *revBase, *smpPtr;425 const int8_t *base, *revBase, *smpPtr;
426 double dSample, *dMixBufferL, *dMixBufferR;426 double dSample, *dMixBufferL, *dMixBufferR;
@@ -464,7 +464,7 @@ static void mix8bBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 37 unmodified lines
464 SET_BACK_MIXER_POS464 SET_BACK_MIXER_POS
465}465}
466 466
467static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples)467static void mix8bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
468{468{
469 const int8_t *base, *smpPtr;469 const int8_t *base, *smpPtr;
470 double dSample, *dMixBufferL, *dMixBufferR;470 double dSample, *dMixBufferL, *dMixBufferR;
@@ -514,7 +514,7 @@ static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
514 SET_BACK_MIXER_POS514 SET_BACK_MIXER_POS
515}515}
516 516
517static void mix8bRampLoop(voice_t *v, uint32_t numSamples)517static void mix8bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
518{518{
519 const int8_t *base, *smpPtr;519 const int8_t *base, *smpPtr;
520 double dSample, *dMixBufferL, *dMixBufferR;520 double dSample, *dMixBufferL, *dMixBufferR;
@@ -564,7 +564,7 @@ static void mix8bRampLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
564 SET_BACK_MIXER_POS564 SET_BACK_MIXER_POS
565}565}
566 566
567static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples)567static void mix8bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
568{568{
569 const int8_t *base, *revBase, *smpPtr;569 const int8_t *base, *revBase, *smpPtr;
570 double dSample, *dMixBufferL, *dMixBufferR;570 double dSample, *dMixBufferL, *dMixBufferR;
@@ -616,7 +616,7 @@ static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples) · 45 unmodified lines
616 SET_BACK_MIXER_POS616 SET_BACK_MIXER_POS
617}617}
618 618
619static void mix8bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples)619static void mix8bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
620{620{
621 const int8_t *base, *smpPtr;621 const int8_t *base, *smpPtr;
622 double dSample, *dMixBufferL, *dMixBufferR;622 double dSample, *dMixBufferL, *dMixBufferR;
@@ -666,7 +666,7 @@ static void mix8bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
666 SET_BACK_MIXER_POS666 SET_BACK_MIXER_POS
667}667}
668 668
669static void mix8bRampLoopSIntrp(voice_t *v, uint32_t numSamples)669static void mix8bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
670{670{
671 const int8_t *base, *smpPtr;671 const int8_t *base, *smpPtr;
672 int8_t *smpTapPtr;672 int8_t *smpTapPtr;
@@ -746,7 +746,7 @@ static void mix8bRampLoopSIntrp(voice_t *v, uint32_t numSamples) · 73 unmodified lines
746 SET_BACK_MIXER_POS746 SET_BACK_MIXER_POS
747}747}
748 748
749static void mix8bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples)749static void mix8bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
750{750{
751 const int8_t *base, *revBase, *smpPtr;751 const int8_t *base, *revBase, *smpPtr;
752 int8_t *smpTapPtr;752 int8_t *smpTapPtr;
@@ -828,7 +828,7 @@ static void mix8bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 75 unmodified lines
828 SET_BACK_MIXER_POS828 SET_BACK_MIXER_POS
829}829}
830 830
831static void mix8bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples)831static void mix8bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
832{832{
833 const int8_t *base, *smpPtr;833 const int8_t *base, *smpPtr;
834 double dSample, *dMixBufferL, *dMixBufferR;834 double dSample, *dMixBufferL, *dMixBufferR;
@@ -878,7 +878,7 @@ static void mix8bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
878 SET_BACK_MIXER_POS878 SET_BACK_MIXER_POS
879}879}
880 880
881static void mix8bRampLoopLIntrp(voice_t *v, uint32_t numSamples)881static void mix8bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
882{882{
883 const int8_t *base, *smpPtr;883 const int8_t *base, *smpPtr;
884 double dSample, *dMixBufferL, *dMixBufferR;884 double dSample, *dMixBufferL, *dMixBufferR;
@@ -928,7 +928,7 @@ static void mix8bRampLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
928 SET_BACK_MIXER_POS928 SET_BACK_MIXER_POS
929}929}
930 930
931static void mix8bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples)931static void mix8bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
932{932{
933 const int8_t *base, *revBase, *smpPtr;933 const int8_t *base, *revBase, *smpPtr;
934 double dSample, *dMixBufferL, *dMixBufferR;934 double dSample, *dMixBufferL, *dMixBufferR;
@@ -984,7 +984,7 @@ static void mix8bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 49 unmodified lines
984/* 16-BIT MIXING ROUTINES */984/* 16-BIT MIXING ROUTINES */
985/* ----------------------------------------------------------------------- */985/* ----------------------------------------------------------------------- */
986 986
987static void mix16bNoLoop(voice_t *v, uint32_t numSamples)987static void mix16bNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
988{988{
989 const int16_t *base, *smpPtr;989 const int16_t *base, *smpPtr;
990 double dSample, *dMixBufferL, *dMixBufferR;990 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1026,7 +1026,7 @@ static void mix16bNoLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1026 SET_BACK_MIXER_POS1026 SET_BACK_MIXER_POS
1027}1027}
1028 1028
1029static void mix16bLoop(voice_t *v, uint32_t numSamples)1029static void mix16bLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1030{1030{
1031 const int16_t *base, *smpPtr;1031 const int16_t *base, *smpPtr;
1032 double dSample, *dMixBufferL, *dMixBufferR;1032 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1068,7 +1068,7 @@ static void mix16bLoop(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1068 SET_BACK_MIXER_POS1068 SET_BACK_MIXER_POS
1069}1069}
1070 1070
1071static void mix16bBidiLoop(voice_t *v, uint32_t numSamples)1071static void mix16bBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1072{1072{
1073 const int16_t *base, *revBase, *smpPtr;1073 const int16_t *base, *revBase, *smpPtr;
1074 double dSample, *dMixBufferL, *dMixBufferR;1074 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1112,7 +1112,7 @@ static void mix16bBidiLoop(voice_t *v, uint32_t numSamples) · 37 unmodified lines
1112 SET_BACK_MIXER_POS1112 SET_BACK_MIXER_POS
1113}1113}
1114 1114
1115static void mix16bNoLoopSIntrp(voice_t *v, uint32_t numSamples)1115static void mix16bNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1116{1116{
1117 const int16_t *base, *smpPtr;1117 const int16_t *base, *smpPtr;
1118 double dSample, *dMixBufferL, *dMixBufferR;1118 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1154,7 +1154,7 @@ static void mix16bNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1154 SET_BACK_MIXER_POS1154 SET_BACK_MIXER_POS
1155}1155}
1156 1156
1157static void mix16bLoopSIntrp(voice_t *v, uint32_t numSamples)1157static void mix16bLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1158{1158{
1159 const int16_t *base, *smpPtr;1159 const int16_t *base, *smpPtr;
1160 int16_t *smpTapPtr;1160 int16_t *smpTapPtr;
@@ -1221,7 +1221,7 @@ static void mix16bLoopSIntrp(voice_t *v, uint32_t numSamples) · 60 unmodified lines
1221 SET_BACK_MIXER_POS1221 SET_BACK_MIXER_POS
1222}1222}
1223 1223
1224static void mix16bBidiLoopSIntrp(voice_t *v, uint32_t numSamples)1224static void mix16bBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1225{1225{
1226 const int16_t *base, *revBase, *smpPtr;1226 const int16_t *base, *revBase, *smpPtr;
1227 int16_t *smpTapPtr;1227 int16_t *smpTapPtr;
@@ -1290,7 +1290,7 @@ static void mix16bBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 62 unmodified lines
1290 SET_BACK_MIXER_POS1290 SET_BACK_MIXER_POS
1291}1291}
1292 1292
1293static void mix16bNoLoopLIntrp(voice_t *v, uint32_t numSamples)1293static void mix16bNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1294{1294{
1295 const int16_t *base, *smpPtr;1295 const int16_t *base, *smpPtr;
1296 double dSample, *dMixBufferL, *dMixBufferR;1296 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1332,7 +1332,7 @@ static void mix16bNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1332 SET_BACK_MIXER_POS1332 SET_BACK_MIXER_POS
1333}1333}
1334 1334
1335static void mix16bLoopLIntrp(voice_t *v, uint32_t numSamples)1335static void mix16bLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1336{1336{
1337 const int16_t *base, *smpPtr;1337 const int16_t *base, *smpPtr;
1338 double dSample, *dMixBufferL, *dMixBufferR;1338 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1374,7 +1374,7 @@ static void mix16bLoopLIntrp(voice_t *v, uint32_t numSamples) · 35 unmodified lines
1374 SET_BACK_MIXER_POS1374 SET_BACK_MIXER_POS
1375}1375}
1376 1376
1377static void mix16bBidiLoopLIntrp(voice_t *v, uint32_t numSamples)1377static void mix16bBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1378{1378{
1379 const int16_t *base, *revBase, *smpPtr;1379 const int16_t *base, *revBase, *smpPtr;
1380 double dSample, *dMixBufferL, *dMixBufferR;1380 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1418,7 +1418,7 @@ static void mix16bBidiLoopLIntrp(voice_t *v, uint32_t numSamples) · 37 unmodified lines
1418 SET_BACK_MIXER_POS1418 SET_BACK_MIXER_POS
1419}1419}
1420 1420
1421static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples)1421static void mix16bRampNoLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1422{1422{
1423 const int16_t *base, *smpPtr;1423 const int16_t *base, *smpPtr;
1424 double dSample, *dMixBufferL, *dMixBufferR;1424 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1468,7 +1468,7 @@ static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1468 SET_BACK_MIXER_POS1468 SET_BACK_MIXER_POS
1469}1469}
1470 1470
1471static void mix16bRampLoop(voice_t *v, uint32_t numSamples)1471static void mix16bRampLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1472{1472{
1473 const int16_t *base, *smpPtr;1473 const int16_t *base, *smpPtr;
1474 double dSample, *dMixBufferL, *dMixBufferR;1474 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1518,7 +1518,7 @@ static void mix16bRampLoop(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1518 SET_BACK_MIXER_POS1518 SET_BACK_MIXER_POS
1519}1519}
1520 1520
1521static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples)1521static void mix16bRampBidiLoop(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1522{1522{
1523 const int16_t *base, *revBase, *smpPtr;1523 const int16_t *base, *revBase, *smpPtr;
1524 double dSample, *dMixBufferL, *dMixBufferR;1524 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1570,7 +1570,7 @@ static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples) · 45 unmodified lines
1570 SET_BACK_MIXER_POS1570 SET_BACK_MIXER_POS
1571}1571}
1572 1572
1573static void mix16bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples)1573static void mix16bRampNoLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1574{1574{
1575 const int16_t *base, *smpPtr;1575 const int16_t *base, *smpPtr;
1576 double dSample, *dMixBufferL, *dMixBufferR;1576 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1620,7 +1620,7 @@ static void mix16bRampNoLoopSIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1620 SET_BACK_MIXER_POS1620 SET_BACK_MIXER_POS
1621}1621}
1622 1622
1623static void mix16bRampLoopSIntrp(voice_t *v, uint32_t numSamples)1623static void mix16bRampLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1624{1624{
1625 const int16_t *base, *smpPtr;1625 const int16_t *base, *smpPtr;
1626 int16_t *smpTapPtr;1626 int16_t *smpTapPtr;
@@ -1700,7 +1700,7 @@ static void mix16bRampLoopSIntrp(voice_t *v, uint32_t numSamples) · 73 unmodified lines
1700 SET_BACK_MIXER_POS1700 SET_BACK_MIXER_POS
1701}1701}
1702 1702
1703static void mix16bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples)1703static void mix16bRampBidiLoopSIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1704{1704{
1705 const int16_t *base, *revBase, *smpPtr;1705 const int16_t *base, *revBase, *smpPtr;
1706 int16_t *smpTapPtr;1706 int16_t *smpTapPtr;
@@ -1782,7 +1782,7 @@ static void mix16bRampBidiLoopSIntrp(voice_t *v, uint32_t numSamples) · 75 unmodified lines
1782 SET_BACK_MIXER_POS1782 SET_BACK_MIXER_POS
1783}1783}
1784 1784
1785static void mix16bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples)1785static void mix16bRampNoLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1786{1786{
1787 const int16_t *base, *smpPtr;1787 const int16_t *base, *smpPtr;
1788 double dSample, *dMixBufferL, *dMixBufferR;1788 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1832,7 +1832,7 @@ static void mix16bRampNoLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1832 SET_BACK_MIXER_POS1832 SET_BACK_MIXER_POS
1833}1833}
1834 1834
1835static void mix16bRampLoopLIntrp(voice_t *v, uint32_t numSamples)1835static void mix16bRampLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1836{1836{
1837 const int16_t *base, *smpPtr;1837 const int16_t *base, *smpPtr;
1838 double dSample, *dMixBufferL, *dMixBufferR;1838 double dSample, *dMixBufferL, *dMixBufferR;
@@ -1882,7 +1882,7 @@ static void mix16bRampLoopLIntrp(voice_t *v, uint32_t numSamples) · 43 unmodified lines
1882 SET_BACK_MIXER_POS1882 SET_BACK_MIXER_POS
1883}1883}
1884 1884
1885static void mix16bRampBidiLoopLIntrp(voice_t *v, uint32_t numSamples)1885static void mix16bRampBidiLoopLIntrp(voice_t *v, uint32_t bufferPos, uint32_t numSamples)
1886{1886{
1887 const int16_t *base, *revBase, *smpPtr;1887 const int16_t *base, *revBase, *smpPtr;
1888 double dSample, *dMixBufferL, *dMixBufferR;1888 double dSample, *dMixBufferL, *dMixBufferR;
src/mixer/ft2_mix.h+1−1
@@ -3,6 +3,6 @@ · 2 unmodified lines
3#include <stdint.h>3#include <stdint.h>
4#include "../ft2_audio.h"4#include "../ft2_audio.h"
5 5
6typedef void (*mixFunc)(void *, int32_t);6typedef void (*mixFunc)(void *, uint32_t, uint32_t);
7 7
8extern const mixFunc mixFuncTab[72]; // ft2_mix.c8extern const mixFunc mixFuncTab[72]; // ft2_mix.c
src/mixer/ft2_mix_macros.h+6−6
@@ -31,15 +31,15 @@ · 30 unmodified lines
31 31
32#define GET_MIXER_VARS \32#define GET_MIXER_VARS \
33 const uint64_t delta = v->delta; \33 const uint64_t delta = v->delta; \
34 dMixBufferL = audio.dMixBufferL; \34 dMixBufferL = audio.dMixBufferL + bufferPos; \
35 dMixBufferR = audio.dMixBufferR; \35 dMixBufferR = audio.dMixBufferR + bufferPos; \
36 pos = v->pos; \36 pos = v->pos; \
37 posFrac = v->posFrac; \37 posFrac = v->posFrac; \
38 38
39#define GET_MIXER_VARS_RAMP \39#define GET_MIXER_VARS_RAMP \
40 const uint64_t delta = v->delta; \40 const uint64_t delta = v->delta; \
41 dMixBufferL = audio.dMixBufferL; \41 dMixBufferL = audio.dMixBufferL + bufferPos; \
42 dMixBufferR = audio.dMixBufferR; \42 dMixBufferR = audio.dMixBufferR + bufferPos; \
43 dVolLDelta = v->dVolDeltaL; \43 dVolLDelta = v->dVolDeltaL; \
44 dVolRDelta = v->dVolDeltaR; \44 dVolRDelta = v->dVolDeltaR; \
45 pos = v->pos; \45 pos = v->pos; \
@@ -47,8 +47,8 @@ · 1 unmodified line
47 47
48#define GET_MIXER_VARS_MONO_RAMP \48#define GET_MIXER_VARS_MONO_RAMP \
49 const uint64_t delta = v->delta; \49 const uint64_t delta = v->delta; \
50 dMixBufferL = audio.dMixBufferL; \50 dMixBufferL = audio.dMixBufferL + bufferPos; \
51 dMixBufferR = audio.dMixBufferR; \51 dMixBufferR = audio.dMixBufferR + bufferPos; \
52 dVolLDelta = v->dVolDeltaL; \52 dVolLDelta = v->dVolDeltaL; \
53 pos = v->pos; \53 pos = v->pos; \
54 posFrac = v->posFrac; \54 posFrac = v->posFrac; \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t