| 1 | // used for syncing audio from Paula writes to tracker visualscxx . . $ `<file>/src/pt2_visuals_sync.c`/ |
| 2 | |
| 3 | #include <math.h> |
| 4 | #include <stdint.h> |
| 5 | #include <stdbool.h> |
| 6 | #include "pt2_audio.h"cxx . . $ `<file>/src/pt2_audio.h`/ |
| 7 | #include "pt2_visuals_sync.h"cxx . . $ `<file>/src/pt2_visuals_sync.h`/ |
| 8 | #include "pt2_scopes.h"cxx . . $ `<file>/src/pt2_scopes.h`/ |
| 9 | #include "pt2_visuals.h"cxx . . $ `<file>/src/pt2_visuals.h`/ |
| 10 | #include "pt2_tables.h"cxx . . $ `<file>/src/pt2_tables.h`/ |
| 11 | |
| 12 | typedef struct syncVoice_tcxx . . $ syncVoice_t# |
| 13 | { |
| 14 | const int8_tcxx . . $ int8_t# *newDatacxx . . $ syncVoice_t#newData., *datacxx . . $ syncVoice_t#data.; |
| 15 | uint8_tcxx . . $ uint8_t# flagscxx . . $ syncVoice_t#flags., volumecxx . . $ syncVoice_t#volume.; |
| 16 | uint16_tcxx . . $ uint16_t# periodcxx . . $ syncVoice_t#period.; |
| 17 | uint16_tcxx . . $ uint16_t# newLengthcxx . . $ syncVoice_t#newLength., lengthcxx . . $ syncVoice_t#length.; |
| 18 | } syncVoice_tcxx . . $ syncVoice_t#; |
| 19 | |
| 20 | static volatile boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! chQueueClearingcxx . . $ chQueueClearing.; |
| 21 | static uint32_tcxx . . $ uint32_t# audLatencyPerfValIntcxx . . $ audLatencyPerfValInt.; |
| 22 | static uint64_tcxx . . $ uint64_t# audLatencyPerfValFraccxx . . $ audLatencyPerfValFrac.; |
| 23 | static uint64_tcxx . . $ uint64_t# tickTime64cxx . . $ tickTime64., tickTime64Fraccxx . . $ tickTime64Frac.; |
| 24 | static uint32_tcxx . . $ uint32_t# tickTimeLenIntcxx . . $ tickTimeLenInt.; |
| 25 | static uint64_tcxx . . $ uint64_t# tickTimeLenFraccxx . . $ tickTimeLenFrac.; |
| 26 | static syncVoice_tcxx . . $ syncVoice_t# syncVoicecxx . . $ syncVoice.[PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!]; |
| 27 | static chSyncData_tcxx . . $ chSyncData_t# *chSyncEntrycxx . . $ chSyncEntry.; |
| 28 | static chSync_tcxx . . $ chSync_t# chSynccxx . . $ chSync.; |
| 29 | |
| 30 | static void startDMAcxx . . $ startDMA(d4f767463ce0a6b3).(int32_tcxx . . $ int32_t# ch) |
| 31 | { |
| 32 | syncVoice_tcxx . . $ syncVoice_t# *sv = &syncVoicecxx . . $ syncVoice.[ch]; |
| 33 | |
| 34 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 35 | { |
| 36 | sv->datacxx . . $ syncVoice_t#data. = sv->newDatacxx . . $ syncVoice_t#newData.; |
| 37 | sv->lengthcxx . . $ syncVoice_t#length. = sv->newLengthcxx . . $ syncVoice_t#newLength.; |
| 38 | sv->flagscxx . . $ syncVoice_t#flags. |= TRIGGER_SCOPEcxx . . $ TRIGGER_SCOPE.; |
| 39 | } |
| 40 | else |
| 41 | { |
| 42 | scope_tcxx . . $ scope_t# *s = &scopecxx . . $ scope.[ch]; |
| 43 | s->datacxx . . $ scope_t#data. = sv->newDatacxx . . $ syncVoice_t#newData.; |
| 44 | s->lengthcxx . . $ scope_t#length. = sv->newLengthcxx . . $ syncVoice_t#newLength. * 2; |
| 45 | scopeTriggercxx . . $ scopeTrigger(d4f767463ce0a6b3).(ch); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static void stopDMAcxx . . $ stopDMA(d4f767463ce0a6b3).(int32_tcxx . . $ int32_t# ch) |
| 50 | { |
| 51 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 52 | syncVoicecxx . . $ syncVoice.[ch].flagscxx . . $ syncVoice_t#flags. |= STOP_SCOPEcxx . . $ STOP_SCOPE.; |
| 53 | else |
| 54 | scopecxx . . $ scope.[ch].activecxx . . $ scope_t#active. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 55 | } |
| 56 | |
| 57 | void setVisualsDMACONcxx . . $ setVisualsDMACON(ed53e3bbd3fa2f69).(uint16_tcxx . . $ uint16_t# bits) |
| 58 | { |
| 59 | if (bits & 0x8000) |
| 60 | { |
| 61 | // set |
| 62 | if (bits & 1) startDMAcxx . . $ startDMA(d4f767463ce0a6b3).(0); |
| 63 | if (bits & 2) startDMAcxx . . $ startDMA(d4f767463ce0a6b3).(1); |
| 64 | if (bits & 4) startDMAcxx . . $ startDMA(d4f767463ce0a6b3).(2); |
| 65 | if (bits & 8) startDMAcxx . . $ startDMA(d4f767463ce0a6b3).(3); |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | // clear |
| 70 | if (bits & 1) stopDMAcxx . . $ stopDMA(d4f767463ce0a6b3).(0); |
| 71 | if (bits & 2) stopDMAcxx . . $ stopDMA(d4f767463ce0a6b3).(1); |
| 72 | if (bits & 4) stopDMAcxx . . $ stopDMA(d4f767463ce0a6b3).(2); |
| 73 | if (bits & 8) stopDMAcxx . . $ stopDMA(d4f767463ce0a6b3).(3); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void setVisualsVolumecxx . . $ setVisualsVolume(a7050f1a4cb56049).(int32_tcxx . . $ int32_t# ch, uint16_tcxx . . $ uint16_t# vol) |
| 78 | { |
| 79 | int32_tcxx . . $ int32_t# realVol = vol & 127; |
| 80 | if (realVol > 64) |
| 81 | realVol = 64; |
| 82 | |
| 83 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 84 | { |
| 85 | syncVoice_tcxx . . $ syncVoice_t# *sv = &syncVoicecxx . . $ syncVoice.[ch]; |
| 86 | |
| 87 | sv->volumecxx . . $ syncVoice_t#volume. = (uint8_tcxx . . $ uint8_t#)realVol; |
| 88 | sv->flagscxx . . $ syncVoice_t#flags. |= SET_SCOPE_VOLUMEcxx . . $ SET_SCOPE_VOLUME.; |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | scopecxx . . $ scope.[ch].volumecxx . . $ scope_t#volume. = (uint8_tcxx . . $ uint8_t#)realVol; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | void setVisualsPeriodcxx . . $ setVisualsPeriod(a7050f1a4cb56049).(int32_tcxx . . $ int32_t# ch, uint16_tcxx . . $ uint16_t# period) |
| 97 | { |
| 98 | if (period == 0) |
| 99 | period = 65535; // On Amiga: period 0 = one full cycle with period 65536, then period 65535 for the rest |
| 100 | else if (period < 113) |
| 101 | period = 113; // close to what happens on real Amiga (and needed for BLEP synthesis) |
| 102 | |
| 103 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 104 | { |
| 105 | syncVoice_tcxx . . $ syncVoice_t# *sv = &syncVoicecxx . . $ syncVoice.[ch]; |
| 106 | |
| 107 | sv->periodcxx . . $ syncVoice_t#period. = period; |
| 108 | sv->flagscxx . . $ syncVoice_t#flags. |= SET_SCOPE_PERIODcxx . . $ SET_SCOPE_PERIOD.; |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | scopeSetPeriodcxx . . $ scopeSetPeriod(3e454b8ccf442868).(ch, period); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void setVisualsLengthcxx . . $ setVisualsLength(a7050f1a4cb56049).(int32_tcxx . . $ int32_t# ch, uint16_tcxx . . $ uint16_t# len) |
| 117 | { |
| 118 | syncVoice_tcxx . . $ syncVoice_t# *sv = &syncVoicecxx . . $ syncVoice.[ch]; |
| 119 | |
| 120 | sv->newLengthcxx . . $ syncVoice_t#newLength. = len; |
| 121 | |
| 122 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 123 | sv->flagscxx . . $ syncVoice_t#flags. |= SET_SCOPE_LENGTHcxx . . $ SET_SCOPE_LENGTH.; |
| 124 | else |
| 125 | scopecxx . . $ scope.[ch].newLengthcxx . . $ scope_t#newLength. = len * 2; |
| 126 | } |
| 127 | |
| 128 | void setVisualsDataPtrcxx . . $ setVisualsDataPtr(70eb3de2aab3469c).(int32_tcxx . . $ int32_t# ch, const int8_tcxx . . $ int8_t# *src) |
| 129 | { |
| 130 | syncVoice_tcxx . . $ syncVoice_t# *sv = &syncVoicecxx . . $ syncVoice.[ch]; |
| 131 | |
| 132 | if (src == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 133 | src = paulaGetNullSamplePtrcxx . . $ paulaGetNullSamplePtr(d09b239063734497).(); |
| 134 | |
| 135 | sv->newDatacxx . . $ syncVoice_t#newData. = src; |
| 136 | |
| 137 | if (editorcxx . . $ editor..songPlayingcxx . . $ editor_t#songPlaying.) |
| 138 | sv->flagscxx . . $ syncVoice_t#flags. |= SET_SCOPE_DATAcxx . . $ SET_SCOPE_DATA.; |
| 139 | else |
| 140 | scopecxx . . $ scope.[ch].newDatacxx . . $ scope_t#newData. = src; |
| 141 | } |
| 142 | |
| 143 | void calcAudioLatencyVarscxx . . $ calcAudioLatencyVars(3e454b8ccf442868).(int32_tcxx . . $ int32_t# audioBufferSize, int32_tcxx . . $ int32_t# audioFreq) |
| 144 | { |
| 145 | if (audioFreq == 0) |
| 146 | return; |
| 147 | |
| 148 | const double dAudioLatencyTime = (audioBufferSize / (double)audioFreq) * (double)hpcFreqcxx . . $ hpcFreq..freq64cxx . . $ $anonymous_type_f41cb469dd1dca50_0#freq64.; |
| 149 | double dAudioLatencyTimeInt, dAudioLatencyTimeFrac = modf(dAudioLatencyTime, &dAudioLatencyTimeInt); |
| 150 | |
| 151 | audLatencyPerfValIntcxx . . $ audLatencyPerfValInt. = (uint32_tcxx . . $ uint32_t#)dAudioLatencyTimeInt; |
| 152 | audLatencyPerfValFraccxx . . $ audLatencyPerfValFrac. = (uint64_tcxx . . $ uint64_t#)(dAudioLatencyTimeFrac * TICK_TIME_FRAC_SCALEcxx . . $ `src/pt2_audio.h:17:9`!); |
| 153 | } |
| 154 | |
| 155 | void setSyncTickTimeLencxx . . $ setSyncTickTimeLen(588cb903c6b0e163).(uint32_tcxx . . $ uint32_t# timeLenInt, uint64_tcxx . . $ uint64_t# timeLenFrac) |
| 156 | { |
| 157 | tickTimeLenIntcxx . . $ tickTimeLenInt. = timeLenInt; |
| 158 | tickTimeLenFraccxx . . $ tickTimeLenFrac. = timeLenFrac; |
| 159 | } |
| 160 | |
| 161 | void resetChSyncQueuecxx . . $ resetChSyncQueue(49f6e7a06ebc5aa8).(void) |
| 162 | { |
| 163 | chSynccxx . . $ chSync..datacxx . . $ chSync_t#data.[0].timestampcxx . . $ chSyncData_t#timestamp. = 0; |
| 164 | chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. = 0; |
| 165 | chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. = 0; |
| 166 | } |
| 167 | |
| 168 | static int32_tcxx . . $ int32_t# chQueueReadSizecxx . . $ chQueueReadSize(b126dc7c1de90089).(void) |
| 169 | { |
| 170 | while (chQueueClearingcxx . . $ chQueueClearing.); |
| 171 | |
| 172 | if (chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. > chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.) |
| 173 | return chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. - chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.; |
| 174 | else if (chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. < chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.) |
| 175 | return chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. - chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. + SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`! + 1; |
| 176 | else |
| 177 | return 0; |
| 178 | } |
| 179 | |
| 180 | static int32_tcxx . . $ int32_t# chQueueWriteSizecxx . . $ chQueueWriteSize(b126dc7c1de90089).(void) |
| 181 | { |
| 182 | int32_tcxx . . $ int32_t# size; |
| 183 | |
| 184 | if (chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. > chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.) |
| 185 | { |
| 186 | size = chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. - chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. + SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`!; |
| 187 | } |
| 188 | else if (chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. < chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.) |
| 189 | { |
| 190 | chQueueClearingcxx . . $ chQueueClearing. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 191 | |
| 192 | /* Buffer is full, reset the read/write pos. This is actually really nasty since |
| 193 | ** read/write are two different threads, but because of timestamp validation it |
| 194 | ** shouldn't be that dangerous. |
| 195 | ** It will also create a small visual stutter while the buffer is getting filled, |
| 196 | ** though that is barely noticable on normal buffer sizes, and it takes a minute |
| 197 | ** or two at max BPM between each time (when queue size is default, 8191) |
| 198 | */ |
| 199 | chSynccxx . . $ chSync..datacxx . . $ chSync_t#data.[0].timestampcxx . . $ chSyncData_t#timestamp. = 0; |
| 200 | chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. = 0; |
| 201 | chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. = 0; |
| 202 | |
| 203 | size = SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`!; |
| 204 | |
| 205 | chQueueClearingcxx . . $ chQueueClearing. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 206 | } |
| 207 | else |
| 208 | { |
| 209 | size = SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`!; |
| 210 | } |
| 211 | |
| 212 | return size; |
| 213 | } |
| 214 | |
| 215 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! chQueuePushcxx . . $ chQueuePush(c8ad07dd25cd6488).(chSyncData_tcxx . . $ chSyncData_t# t) |
| 216 | { |
| 217 | if (!chQueueWriteSizecxx . . $ chQueueWriteSize(b126dc7c1de90089).()) |
| 218 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 219 | |
| 220 | ASSERTcxx . . $ `src/pt2_header.h:25:9`!(chSync.writePos <= SYNC_QUEUE_LEN); |
| 221 | chSynccxx . . $ chSync..datacxx . . $ chSync_t#data.[chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos.] = t; |
| 222 | chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. = (chSynccxx . . $ chSync..writePoscxx . . $ chSync_t#writePos. + 1) & SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`!; |
| 223 | |
| 224 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 225 | } |
| 226 | |
| 227 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! chQueuePopcxx . . $ chQueuePop(c9857a73d68e59ba).(void) |
| 228 | { |
| 229 | if (!chQueueReadSizecxx . . $ chQueueReadSize(b126dc7c1de90089).()) |
| 230 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 231 | |
| 232 | chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. = (chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos. + 1) & SYNC_QUEUE_LENcxx . . $ `src/pt2_visuals_sync.h:21:9`!; |
| 233 | ASSERTcxx . . $ `src/pt2_header.h:25:9`!(chSync.readPos <= SYNC_QUEUE_LEN); |
| 234 | |
| 235 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 236 | } |
| 237 | |
| 238 | static chSyncData_tcxx . . $ chSyncData_t# *chQueuePeekcxx . . $ chQueuePeek(53f65fdbbaf2a862).(void) |
| 239 | { |
| 240 | if (!chQueueReadSizecxx . . $ chQueueReadSize(b126dc7c1de90089).()) |
| 241 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 242 | |
| 243 | ASSERTcxx . . $ `src/pt2_header.h:25:9`!(chSync.readPos <= SYNC_QUEUE_LEN); |
| 244 | return &chSynccxx . . $ chSync..datacxx . . $ chSync_t#data.[chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.]; |
| 245 | } |
| 246 | |
| 247 | static uint64_tcxx . . $ uint64_t# getChQueueTimestampcxx . . $ getChQueueTimestamp(f708dce9a8856c70).(void) |
| 248 | { |
| 249 | if (!chQueueReadSizecxx . . $ chQueueReadSize(b126dc7c1de90089).()) |
| 250 | return 0; |
| 251 | |
| 252 | ASSERTcxx . . $ `src/pt2_header.h:25:9`!(chSync.readPos <= SYNC_QUEUE_LEN); |
| 253 | return chSynccxx . . $ chSync..datacxx . . $ chSync_t#data.[chSynccxx . . $ chSync..readPoscxx . . $ chSync_t#readPos.].timestampcxx . . $ chSyncData_t#timestamp.; |
| 254 | } |
| 255 | |
| 256 | void fillVisualsSyncBuffercxx . . $ fillVisualsSyncBuffer(49f6e7a06ebc5aa8).(void) |
| 257 | { |
| 258 | chSyncData_tcxx . . $ chSyncData_t# chSyncData; |
| 259 | |
| 260 | if (audiocxx . . $ audio..resetSyncTickTimeFlagcxx . . $ audio_t#resetSyncTickTimeFlag.) |
| 261 | { |
| 262 | audiocxx . . $ audio..resetSyncTickTimeFlagcxx . . $ audio_t#resetSyncTickTimeFlag. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 263 | |
| 264 | tickTime64cxx . . $ tickTime64. = SDL_GetPerformanceCountercxx . . $ SDL_GetPerformanceCounter(f708dce9a8856c70).() + audLatencyPerfValIntcxx . . $ audLatencyPerfValInt.; |
| 265 | tickTime64Fraccxx . . $ tickTime64Frac. = audLatencyPerfValFraccxx . . $ audLatencyPerfValFrac.; |
| 266 | } |
| 267 | |
| 268 | if (songcxx . . $ song. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 269 | { |
| 270 | moduleChannel_tcxx . . $ moduleChannel_t# *ch = songcxx . . $ song.->channelscxx . . $ module_t#channels.; |
| 271 | syncVoice_tcxx . . $ syncVoice_t# *sv = syncVoicecxx . . $ syncVoice.; |
| 272 | syncedChannel_tcxx . . $ syncedChannel_t# *sc = chSyncData.channelscxx . . $ chSyncData_t#channels.; |
| 273 | |
| 274 | for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++, ch++, sc++, sv++) |
| 275 | { |
| 276 | sc->flagscxx . . $ syncedChannel_t#flags. = sv->flagscxx . . $ syncVoice_t#flags. | ch->syncFlagscxx . . $ moduleChannel_t#syncFlags.; |
| 277 | ch->syncFlagscxx . . $ moduleChannel_t#syncFlags. = sv->flagscxx . . $ syncVoice_t#flags. = 0; // clear sync flags |
| 278 | |
| 279 | sc->volumecxx . . $ syncedChannel_t#volume. = sv->volumecxx . . $ syncVoice_t#volume.; |
| 280 | sc->periodcxx . . $ syncedChannel_t#period. = sv->periodcxx . . $ syncVoice_t#period.; |
| 281 | sc->datacxx . . $ syncedChannel_t#data. = sv->datacxx . . $ syncVoice_t#data.; |
| 282 | sc->lengthcxx . . $ syncedChannel_t#length. = sv->lengthcxx . . $ syncVoice_t#length.; |
| 283 | sc->newDatacxx . . $ syncedChannel_t#newData. = sv->newDatacxx . . $ syncVoice_t#newData.; |
| 284 | sc->newLengthcxx . . $ syncedChannel_t#newLength. = sv->newLengthcxx . . $ syncVoice_t#newLength.; |
| 285 | sc->vuVolumecxx . . $ syncedChannel_t#vuVolume. = ch->syncVuVolumecxx . . $ moduleChannel_t#syncVuVolume.; |
| 286 | sc->analyzerVolumecxx . . $ syncedChannel_t#analyzerVolume. = ch->syncAnalyzerVolumecxx . . $ moduleChannel_t#syncAnalyzerVolume.; |
| 287 | sc->analyzerPeriodcxx . . $ syncedChannel_t#analyzerPeriod. = ch->syncAnalyzerPeriodcxx . . $ moduleChannel_t#syncAnalyzerPeriod.; |
| 288 | } |
| 289 | |
| 290 | chSyncData.timestampcxx . . $ chSyncData_t#timestamp. = tickTime64cxx . . $ tickTime64.; |
| 291 | chQueuePushcxx . . $ chQueuePush(c8ad07dd25cd6488).(chSyncData); |
| 292 | } |
| 293 | |
| 294 | tickTime64cxx . . $ tickTime64. += tickTimeLenIntcxx . . $ tickTimeLenInt.; |
| 295 | |
| 296 | tickTime64Fraccxx . . $ tickTime64Frac. += tickTimeLenFraccxx . . $ tickTimeLenFrac.; |
| 297 | if (tickTime64Fraccxx . . $ tickTime64Frac. >= TICK_TIME_FRAC_SCALEcxx . . $ `src/pt2_audio.h:17:9`!) |
| 298 | { |
| 299 | tickTime64Fraccxx . . $ tickTime64Frac. &= TICK_TIME_FRAC_MASKcxx . . $ `src/pt2_audio.h:18:9`!; |
| 300 | tickTime64cxx . . $ tickTime64.++; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | void updateChannelSyncBuffercxx . . $ updateChannelSyncBuffer(49f6e7a06ebc5aa8).(void) |
| 305 | { |
| 306 | uint8_tcxx . . $ uint8_t# updateFlags[PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!]; |
| 307 | |
| 308 | chSyncEntrycxx . . $ chSyncEntry. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 309 | |
| 310 | *(uint32_tcxx . . $ uint32_t# *)updateFlags = 0; // clear all channel update flags (this is needed) |
| 311 | |
| 312 | const uint64_tcxx . . $ uint64_t# frameTime64 = SDL_GetPerformanceCountercxx . . $ SDL_GetPerformanceCounter(f708dce9a8856c70).(); |
| 313 | |
| 314 | // handle channel sync queue |
| 315 | |
| 316 | while (chQueueClearingcxx . . $ chQueueClearing.); |
| 317 | while (chQueueReadSizecxx . . $ chQueueReadSize(b126dc7c1de90089).() > 0) |
| 318 | { |
| 319 | if (frameTime64 < getChQueueTimestampcxx . . $ getChQueueTimestamp(f708dce9a8856c70).()) |
| 320 | break; // we have no more stuff to render for now |
| 321 | |
| 322 | chSyncEntrycxx . . $ chSyncEntry. = chQueuePeekcxx . . $ chQueuePeek(53f65fdbbaf2a862).(); |
| 323 | if (chSyncEntrycxx . . $ chSyncEntry. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 324 | break; |
| 325 | |
| 326 | for (int32_tcxx . . $ int32_t# i = 0; i < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; i++) |
| 327 | updateFlags[i] |= chSyncEntrycxx . . $ chSyncEntry.->channelscxx . . $ chSyncData_t#channels.[i].flagscxx . . $ syncedChannel_t#flags.; // yes, OR the status |
| 328 | |
| 329 | if (!chQueuePopcxx . . $ chQueuePop(c9857a73d68e59ba).()) |
| 330 | break; |
| 331 | } |
| 332 | |
| 333 | /* Extra validation because of possible issues when the buffer is full |
| 334 | ** and positions are being reset, which is not entirely thread safe. |
| 335 | */ |
| 336 | if (chSyncEntrycxx . . $ chSyncEntry. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && chSyncEntrycxx . . $ chSyncEntry.->timestampcxx . . $ chSyncData_t#timestamp. == 0) |
| 337 | chSyncEntrycxx . . $ chSyncEntry. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 338 | |
| 339 | // do actual updates |
| 340 | if (chSyncEntrycxx . . $ chSyncEntry. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 341 | { |
| 342 | scope_tcxx . . $ scope_t# *s = scopecxx . . $ scope.; |
| 343 | syncedChannel_tcxx . . $ syncedChannel_t# *c = chSyncEntrycxx . . $ chSyncEntry.->channelscxx . . $ chSyncData_t#channels.; |
| 344 | for (int32_tcxx . . $ int32_t# ch = 0; ch < PAULA_VOICEScxx . . $ `src/pt2_paula.h:13:9`!; ch++, s++, c++) |
| 345 | { |
| 346 | const uint8_tcxx . . $ uint8_t# flags = updateFlags[ch]; |
| 347 | if (flags == 0) |
| 348 | continue; |
| 349 | |
| 350 | if (flags & SET_SCOPE_VOLUMEcxx . . $ SET_SCOPE_VOLUME.) |
| 351 | scopecxx . . $ scope.[ch].volumecxx . . $ scope_t#volume. = c->volumecxx . . $ syncedChannel_t#volume.; |
| 352 | |
| 353 | if (flags & SET_SCOPE_PERIODcxx . . $ SET_SCOPE_PERIOD.) |
| 354 | scopeSetPeriodcxx . . $ scopeSetPeriod(3e454b8ccf442868).(ch, c->periodcxx . . $ syncedChannel_t#period.); |
| 355 | |
| 356 | // the following handling order is important, don't change it! |
| 357 | |
| 358 | if (flags & STOP_SCOPEcxx . . $ STOP_SCOPE.) |
| 359 | scopecxx . . $ scope.[ch].activecxx . . $ scope_t#active. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 360 | |
| 361 | if (flags & TRIGGER_SCOPEcxx . . $ TRIGGER_SCOPE.) |
| 362 | { |
| 363 | s->datacxx . . $ scope_t#data. = c->datacxx . . $ syncedChannel_t#data.; |
| 364 | s->lengthcxx . . $ scope_t#length. = c->lengthcxx . . $ syncedChannel_t#length. * 2; |
| 365 | scopeTriggercxx . . $ scopeTrigger(d4f767463ce0a6b3).(ch); |
| 366 | } |
| 367 | |
| 368 | if (flags & SET_SCOPE_DATAcxx . . $ SET_SCOPE_DATA.) |
| 369 | scopecxx . . $ scope.[ch].newDatacxx . . $ scope_t#newData. = c->newDatacxx . . $ syncedChannel_t#newData.; |
| 370 | |
| 371 | if (flags & SET_SCOPE_LENGTHcxx . . $ SET_SCOPE_LENGTH.) |
| 372 | scopecxx . . $ scope.[ch].newLengthcxx . . $ scope_t#newLength. = c->newLengthcxx . . $ syncedChannel_t#newLength. * 2; |
| 373 | |
| 374 | // --------------------------------------------------------------- |
| 375 | |
| 376 | if (flags & UPDATE_SPECTRUM_ANALYZERcxx . . $ UPDATE_SPECTRUM_ANALYZER.) |
| 377 | updateSpectrumAnalyzercxx . . $ updateSpectrumAnalyzer(2b0f6589498b1c50).(c->analyzerVolumecxx . . $ syncedChannel_t#analyzerVolume., c ->analyzerPeriodcxx . . $ syncedChannel_t#analyzerPeriod.); |
| 378 | |
| 379 | if (flags & UPDATE_VUMETERcxx . . $ UPDATE_VUMETER.) // for fake VU-meters only |
| 380 | { |
| 381 | if (c->vuVolumecxx . . $ syncedChannel_t#vuVolume. <= 64) |
| 382 | editorcxx . . $ editor..vuMeterVolumescxx . . $ editor_t#vuMeterVolumes.[ch] = vuMeterHeightscxx . . $ vuMeterHeights.[c->vuVolumecxx . . $ syncedChannel_t#vuVolume.]; |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | } |