thing
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#define AUDIOCODER_ENCODER_H
|
||||
|
||||
#define SAMPLE_RATE 48000
|
||||
#define MAX_BITS 16
|
||||
#define CLOCK_VOICE MAX_BITS
|
||||
#define CLOCK_VOICE 0
|
||||
#define DATA_VOICE 1
|
||||
#define MAX_PACKET 223
|
||||
|
||||
#include <SDL_audio.h>
|
||||
@@ -23,21 +23,23 @@ typedef struct SynthVoice {
|
||||
typedef enum {
|
||||
TX_IDLE,
|
||||
TX_PREAMBLE,
|
||||
TX_SYNC,
|
||||
TX_DATA,
|
||||
TX_PACKET,
|
||||
TX_END
|
||||
} TxState;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
unsigned int bitCount;
|
||||
unsigned int bitsPerSymbol;
|
||||
unsigned int toneCount;
|
||||
|
||||
unsigned int byteIndex;
|
||||
unsigned int bitIndex;
|
||||
uint8_t buffer[1024 * 1024 * 8];
|
||||
unsigned int bufferSize;
|
||||
|
||||
uint8_t packet[MAX_PACKET];
|
||||
uint32_t packetSize;
|
||||
uint32_t packetIndex;
|
||||
|
||||
|
||||
uint16_t startFreq;
|
||||
@@ -53,6 +55,7 @@ typedef struct {
|
||||
|
||||
uint32_t symbolSamples;
|
||||
uint32_t samplesRemaining;
|
||||
uint32_t sampleRate; // actual device sample rate
|
||||
|
||||
|
||||
TxState state;
|
||||
@@ -66,7 +69,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct AudioData {
|
||||
SynthVoice synthVoices[MAX_BITS + 1];
|
||||
SynthVoice synthVoices[2];
|
||||
Encoder *encoder;
|
||||
} AudioData;
|
||||
|
||||
@@ -74,18 +77,12 @@ extern Encoder encoder;
|
||||
extern AudioData encodedAudioData;
|
||||
extern SDL_AudioDeviceID dev;
|
||||
|
||||
// Internal audio bus for loopback - simple ring buffer
|
||||
#define INTERNAL_BUFFER_SIZE 262144
|
||||
extern float internalBusSamples[INTERNAL_BUFFER_SIZE];
|
||||
extern volatile uint32_t internalBusWrite;
|
||||
extern volatile uint32_t internalBusRead;
|
||||
|
||||
void startEncoder(Encoder *enc);
|
||||
|
||||
void stopEncoder(Encoder *enc);
|
||||
|
||||
void initAudioEncoder();
|
||||
|
||||
extern const uint8_t syncBytes[4];
|
||||
extern const uint8_t syncSymbols[8];
|
||||
|
||||
#endif //AUDIOCODER_ENCODER_H
|
||||
|
||||
Reference in New Issue
Block a user