| 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <stdbool.h> |
| 5 | #include "pt2_paula.h" |
| 6 | |
| 7 | enum // flags |
| 8 | { |
| 9 | SET_SCOPE_VOLUME = 1, |
| 10 | SET_SCOPE_PERIOD = 2, |
| 11 | SET_SCOPE_DATA = 4, |
| 12 | SET_SCOPE_LENGTH = 8, |
| 13 | TRIGGER_SCOPE = 16, |
| 14 | STOP_SCOPE = 32, |
| 15 | |
| 16 | UPDATE_VUMETER = 64, |
| 17 | UPDATE_SPECTRUM_ANALYZER = 128 |
| 18 | }; |
| 19 | |
| 20 | // 2^n-1 - don't change this! Total queue buffer length is already big. |
| 21 | #define SYNC_QUEUE_LEN 8191 |
| 22 | |
| 23 | #ifdef _MSC_VER |
| 24 | #pragma pack(push) |
| 25 | #pragma pack(1) |
| 26 | #endif |
| 27 | typedef struct syncedChannel_t // pack to save RAM |
| 28 | { |
| 29 | const int8_t *data, *newData; |
| 30 | uint16_t length, newLength; |
| 31 | uint16_t period, analyzerPeriod; |
| 32 | uint8_t flags; |
| 33 | uint8_t volume, analyzerVolume, vuVolume; |
| 34 | } |
| 35 | #ifdef __GNUC__ |
| 36 | __attribute__ ((packed)) |
| 37 | #endif |
| 38 | syncedChannel_t; |
| 39 | #ifdef _MSC_VER |
| 40 | #pragma pack(pop) |
| 41 | #endif |
| 42 | |
| 43 | typedef struct chSyncData_t |
| 44 | { |
| 45 | syncedChannel_t channels[PAULA_VOICES]; |
| 46 | uint64_t timestamp; |
| 47 | } chSyncData_t; |
| 48 | |
| 49 | typedef struct chSync_t |
| 50 | { |
| 51 | volatile int32_t readPos, writePos; |
| 52 | chSyncData_t data[SYNC_QUEUE_LEN + 1]; |
| 53 | } chSync_t; |
| 54 | |
| 55 | void calcAudioLatencyVars(int32_t audioBufferSize, int32_t audioFreq); |
| 56 | void setSyncTickTimeLen(uint32_t timeLenInt, uint64_t timeLenFrac); |
| 57 | void fillVisualsSyncBuffer(void); |
| 58 | void resetChSyncQueue(void); |
| 59 | void updateChannelSyncBuffer(void); |
| 60 | |
| 61 | void setVisualsDMACON(uint16_t bits); |
| 62 | void setVisualsVolume(int32_t ch, uint16_t vol); |
| 63 | void setVisualsPeriod(int32_t ch, uint16_t period); |
| 64 | void setVisualsLength(int32_t ch, uint16_t len); |
| 65 | void setVisualsDataPtr(int32_t ch, const int8_t *src); |