#pragma once #include #include #include #include #include namespace audio { enum { STREAM_TYPE_MONO, STREAM_TYPE_STEREO, _STREAM_TYPE_COUNT }; // TODO: Create a manager class and an instance class struct BoundStream_t { dsp::stream* monoStream; dsp::stream* stereoStream; dsp::StereoToMono* s2m; dsp::MonoToStereo* m2s; void (*streamRemovedHandler)(void* ctx); void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize); void* ctx; int type; }; struct AudioStream_t { io::AudioSink* audio; dsp::stream* monoAudioStream; dsp::stream* stereoAudioStream; std::vector boundStreams; dsp::stream* monoStream; dsp::Splitter* monoDynSplit; dsp::stream* stereoStream; dsp::Splitter* stereoDynSplit; int (*sampleRateChangeHandler)(void* ctx, double sampleRate); double sampleRate; int blockSize; int type; bool running = false; float volume; int sampleRateId; int deviceId; void* ctx; std::string vfoName; }; extern std::map streams; double registerMonoStream(dsp::stream* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx); double registerStereoStream(dsp::stream* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx); void startStream(std::string name); void stopStream(std::string name); void removeStream(std::string name); dsp::stream* bindToStreamMono(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx); dsp::stream* bindToStreamStereo(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx); void setBlockSize(std::string name, int blockSize); void unbindFromStreamMono(std::string name, dsp::stream* stream); void unbindFromStreamStereo(std::string name, dsp::stream* stream); std::string getNameFromVFO(std::string vfoName); void setSampleRate(std::string name, double sampleRate); void setAudioDevice(std::string name, int deviceId, double sampleRate); std::vector getStreamNameList(); };