SOUND4 BIGVOICE.CL Library [1.1.6]
Loading...
Searching...
No Matches
sound4.bigvoice.cl.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <string>
7#include <exception>
8#include <thread>
9#include <functional>
10#include <memory>
11#include <array>
12#include <assert.h>
13#include <stdexcept>
14#include <filesystem>
15#include <string.h>
16
17#include "sound4.bigvoice.cl.h"
18
19
20// Filesystem path char type
21#ifdef _WIN32
22 #include <stringapiset.h>
23 #include <wchar.h>
25 #define fs_strdup wcsdup
26#else // !_WIN32
28 #define fs_strdup strdup
29#endif // !_WIN32
30
31// bridge C callbacks to CPresetLoader
32extern "C" {
33 static char *bigvoice_custom_reader(const fs_char *filename, void* userdata);
34 static void bigvoice_custom_reader_free(char *content, void* userdata);
35 static int bigvoice_custom_writer(const fs_char *filename, const char *content, void* userdata);
36 static int bigvoice_custom_exists(const fs_char *filename, void* userdata);
37 static fs_char** bigvoice_custom_getall(void* userdata);
38 static void bigvoice_custom_getall_free(fs_char** all, void* userdata);
39 static int bigvoice_custom_remove(const fs_char *filename, void* userdata);
40 static int bigvoice_custom_rename(const fs_char *from, const fs_char *to, void* userdata);
41};
42
46namespace sound4 {
50namespace bigvoice {
51 static constexpr const char *process_name = "SOUND4 BIGVOICE.CL";
52 static constexpr const char *process_shortname = "bigvoice";
84
88 namespace helper {
89 #ifdef _WIN32
95 static inline std::string WStringToUTF8(const std::wstring& wstr) {
96 if (wstr.empty()) return {};
97 int size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
98 std::string str(size, 0);
99 WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size, NULL, NULL);
100 return str;
101 }
107 static inline std::wstring UTF8ToWString(const std::string& str) {
108 if (str.empty()) return std::wstring();
109 int size = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
110 std::wstring wstr(size, 0);
111 MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstr[0], size);
112 return wstr;
113 }
114 #endif // _WIN32
115
121 template<typename T>
123 };
124 template<>
125 struct SampleFormat<int16_t> {
126 const bigvoice_SampleFormat format = S16_NATIVE;
127 };
128 template<>
129 struct SampleFormat<int32_t> {
130 const bigvoice_SampleFormat format = S32_NATIVE;
131 };
132 template<>
133 struct SampleFormat<float> {
134 const bigvoice_SampleFormat format = F32_NATIVE;
135 };
136
137 // --------------------------------------------------------------
148 static inline void AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, bigvoice_SampleFormat fmt) {
149 bigvoice_AudioConvertFrom(payload, output, nSpl, fmt);
150 }
151
162 static inline void AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, bigvoice_SampleFormat fmt) {
163 bigvoice_AudioConvertTo(input, payload, nSpl, fmt);
164 }
165
175 static inline void StereoToMono(const float *input, float *output, size_t nFrame) {
176 bigvoice_StereoToMono(input, output, nFrame);
177 }
178
188 static inline void MonoToStereo(const float *input, float *output, size_t nFrame) {
189 bigvoice_MonoToStereo(input, output, nFrame);
190 }
191
202 static inline void StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nFrame) {
203 bigvoice_StereoToMono_Planar(inputL, inputR, output, nFrame);
204 }
205
216 static inline void MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nFrame) {
217 bigvoice_MonoToStereo_Planar(input, outputL, outputR, nFrame);
218 }
219
226 static inline void AudioMonoFromLiveStereo(const uint8_t *payload, float *output) {
227 bigvoice_AudioMonoFromLiveStereo(payload, output);
228 }
229
236 static inline void AudioMonoToLiveStereo(const float *input, uint8_t *payload) {
237 bigvoice_AudioMonoToLiveStereo(input, payload);
238 }
239
240 }; // namespace helper
241
247 static inline std::string GetVersion()
248 {
249 return std::string(bigvoice_GetVersion());
250 }
251
262 static inline unsigned int GetChunkSizeInFrames()
263 {
265 }
266
275 static inline std::vector<unsigned int> GetPossibleChunkSizeInFrames()
276 {
277 std::vector<unsigned int> list;
278 for (unsigned int* src=bigvoice_GetPossibleChunkSizeInFrames();*src;src++) {
279 list.push_back(*src);
280 }
281 return list;
282 }
283
289 static inline unsigned int GetChannelCount()
290 {
292 }
293
301 static inline unsigned int GetAudioInputCount()
302 {
304 }
305
313 static inline unsigned int GetAudioOutputCount()
314 {
316 }
317
325 static inline unsigned int GetSampleRate()
326 {
327 return bigvoice_GetSampleRate();
328 }
329
335 static inline void SanityCheck(bool a_bCheckFrames = true)
336 {
337 // Do some sanity checks
339 throw std::runtime_error("Bad library sampling rate");
340 }
341 if (a_bCheckFrames && bigvoice_GetChunkSizeInFrames()!=ChunkFrames) {
342 throw std::runtime_error("Bad library frame size");
343 }
345 throw std::runtime_error("Bad library channel count");
346 }
348 throw std::runtime_error("Bad library input count");
349 }
351 throw std::runtime_error("Bad library output count");
352 }
353 }
354
361 static inline std::string GetFormatName(const SampleFormat fmt)
362 {
363 return std::string(bigvoice_GetFormatName(fmt));
364 }
365
372 static inline SampleFormat GetFormatFromName(const std::string& name)
373 {
374 return bigvoice_GetFormatFromName(name.c_str());
375 }
376
383 static inline unsigned int GetBytesFromFormat(const SampleFormat fmt)
384 {
385 return bigvoice_GetBytesFromFormat(fmt);
386 }
387
395 using log_cb_t = std::function<void(LogSeverity,const std::string&)>;
396
401 extern "C" {
402 static inline void _log_cb_c(bigvoice_LogSeverity severity, const char *c_msg) {
403 _log_cb(severity, std::string(c_msg));
404 }
405 }
409 static inline void SetLogSeverity(LogSeverity severity)
410 {
411 bigvoice_SetLogSeverity(severity);
412 }
416 static inline void SetLoggerCallback(log_cb_t cb)
417 {
418 _log_cb=cb;
420 }
421
422#if BIGVOICE_HAS_CLOUDBUS
428 class CBus {
429 public:
431 : m_bus(bigvoice_NewBus()) {}
433 {
434 bigvoice_FreeBus(m_bus);
435 m_bus = nullptr;
436 }
437 bigvoice_CBus *Get() const { return m_bus; }
438 private:
439 bigvoice_CBus *m_bus;
440 };
441#endif // BIGVOICE_HAS_CLOUDBUS
442
449 public:
450 CPresetLoader() = default;
451 virtual ~CPresetLoader() = default;
452
453 virtual bool IsReadOnly() = 0;
454 virtual bool Exists(const std::filesystem::path &name) = 0;
455 virtual bool Remove(const std::filesystem::path &name) = 0;
456 virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to) = 0;
457 virtual std::vector<std::filesystem::path> GetAll() = 0;
458 virtual std::string Read(const std::filesystem::path &filename) = 0;
459 virtual bool Write(const std::filesystem::path &filename, const std::string &content) =0;
460 };
462
468 class CInstance {
469 public:
474 {
475 params = bigvoice_NewParameters();
476 if (!params) throw std::bad_alloc();
477 }
478 // non-copyable
479 CInstance( const CInstance& ) = delete;
480 CInstance& operator=( const CInstance& ) = delete;
484 virtual ~CInstance()
485 {
486 Stop();
487 if (params) bigvoice_FreeParameters(params);
488 }
492 bool IsOk() const { return instance!=nullptr; }
502 void SetParam(const std::string& name, const std::string& value)
503 {
504 assert(params);
505 bigvoice_SetParameter(params, name.c_str(), value.c_str());
506 }
513 std::string GetParam(const std::string& name)
514 {
515 assert(params);
516 auto c_value=bigvoice_GetParameter(params, name.c_str());
517 std::string ret(c_value);
519 return ret;
520 }
521
522#if BIGVOICE_HAS_CLOUDBUS
531 void SetBus(const CBus& bus) {
532 assert(params);
533 bigvoice_SetInstanceBus(params,bus.Get());
534 }
535#endif // BIGVOICE_HAS_CLOUDBUS
536
547 void SetPresetManager(CPresetLoader *preset_manager)
548 {
549 if (!preset_manager) return;
550 assert(params);
560 preset_manager->IsReadOnly(),
561 preset_manager
562 );
563 }
564
587 bool Create(const std::string& LoginKey, const std::string& RadioName, const std::string& Access_Key_ID, const std::string& Access_Key_Secret, const std::filesystem::path& save_path, int json_port = 0, unsigned int frames_per_chunk=12)
588 {
589 assert(!instance);
590 std::string l_save_path;
591 if (!save_path.empty()) {
592 l_save_path = save_path.u8string();
593 }
594 instance = bigvoice_InitProcess3(LoginKey.c_str(), RadioName.c_str(), Access_Key_ID.c_str(), Access_Key_Secret.c_str(), l_save_path.c_str(), params, frames_per_chunk);
595 if (!instance) return false;
596 if (!init_metadata.empty()) {
597 for (auto&& [key,value]: init_metadata) {
598 bigvoice_SetMetadata(instance, key.c_str(), value.c_str());
599 }
600 init_metadata.clear();
601 }
602 update_thread = std::thread([this, json_port](){
604 bigvoice_StartUpdateThread(instance, json_port);
606 });
607 int timeout=5000;
608 #ifdef DEBUG
609 timeout=60*1000; // For debugger pauses
610 #endif
611 if (bigvoice_WaitUpdateThreadReady(instance, timeout)<0) {
612 return false;
613 }
614 return true;
615 }
616
624 unsigned int GetChunkFrames() {
625 if (instance) {
626 return bigvoice_GetProcessChunkFrames(instance);
627 }
628 return 0;
629 }
630
638 void PresetManager_InformChange(const std::filesystem::path& relative_path, PresetChange_Kind change_kind)
639 {
640 bigvoice_PresetManager_InformChange(instance, relative_path.c_str(), (bigvoice_PresetChange_Kind) change_kind);
641 }
642
654 void SetMetadata(const std::string& key, const char* value)
655 {
656 if (instance) {
657 bigvoice_SetMetadata(instance, key.c_str(), value);
658 } else {
659 init_metadata.push_back( {key, value} );
660 }
661 }
662
672 void SetMetadataMulti(const std::unordered_map<std::string, const char*>& list)
673 {
674 if (instance) {
675 typedef const char* pchar;
676 pchar* keyvalue=new pchar[2*list.size()+1];
677 size_t n=0;
678 for (auto&& [key,value]: list) {
679 keyvalue[2*n+0]=key.c_str();
680 keyvalue[2*n+1]=value;
681 n++;
682 }
683 keyvalue[2*n+0]=nullptr;
684
685 bigvoice_SetMetadataMulti(instance, keyvalue);
686
687 delete[] keyvalue;
688 } else {
689 for (auto&& [key,value]: list) {
690 if (value) {
691 init_metadata.push_back( {key, value} );
692 }
693 }
694 }
695 }
696
702 std::vector< std::tuple<std::string,std::string> > GetMetadataInfos()
703 {
704 std::vector< std::tuple<std::string,std::string> > values;
705 const char** c_values = bigvoice_GetMetadataInfos(instance);
706 if (c_values) {
707 for (const char** c_value=c_values; *c_value; ) {
708 std::string key(*c_value);
709 c_value++;
710 if (*c_value) {
711 std::string descr(*c_value);
712 c_value++;
713 values.push_back( {key,descr} );
714 }
715 }
716 bigvoice_FreeMetadataInfos(instance, c_values);
717 }
718 return values;
719 }
720
724 virtual void OnUpdateThreadStart() {}
728 virtual void OnUpdateThreadStop() {}
729
730#if BIGVOICE_HAS_WEBSERVER
744 bool StartWebServer(int http_port, int https_port=0)
745 {
746 assert(instance);
747 assert(webserver==SOUND4_INVALID_WEBSERVER_ID);
748 webserver = bigvoice_Webserver(http_port,https_port,instance);
749 if (webserver==SOUND4_INVALID_WEBSERVER_ID) {
750 return false;
751 }
752 int web_status=bigvoice_Webserver_Status(webserver);
753 if (http_port && (web_status & SOUND4_WEBSERVER_HTTP_OK) == 0) {
754 return false;
755 }
756 if (https_port && (web_status & SOUND4_WEBSERVER_HTTPS_OK) == 0) {
757 return false;
758 }
759 return true;
760 }
761
769 void StopWebServer(int timeout_ms = 1000)
770 {
771 if (webserver != SOUND4_INVALID_WEBSERVER_ID) {
772 bigvoice_Webserver_Stop(webserver, timeout_ms);
773 webserver = SOUND4_INVALID_WEBSERVER_ID;
774 }
775 }
776
780 void SetWebServerAppHealth(int httpcode, const std::string& contenttype, const std::string& content)
781 {
782 assert(instance);
783 bigvoice_Webserver_SetAppHealth(instance, httpcode, contenttype.c_str(), content.c_str());
784 }
788 void GetWebServerAppHealth(int &httpcode, std::string& contenttype, std::string& content)
789 {
790 assert(instance);
791 char* c_contenttype=nullptr;
792 char* c_content=nullptr;
793 bigvoice_Webserver_GetAppHealth(instance, &httpcode, &c_contenttype, &c_content);
794 contenttype=c_contenttype;
795 content=c_content;
796 bigvoice_Webserver_FreeString(c_contenttype);
798 }
799#endif // BIGVOICE_HAS_WEBSERVER
800
810 {
811 if (!instance) return 0;
812 return bigvoice_TerminateProcess(instance);
813 }
814
818 void Stop()
819 {
820 if (!instance) return;
821#if BIGVOICE_HAS_WEBSERVER
823#endif // BIGVOICE_HAS_WEBSERVER
824 if (update_thread.joinable()) {
825 bigvoice_StopUpdateThread(instance); // this will exit the update thread
826 update_thread.join();
827 }
828 bigvoice_ExitProcess(instance);
829 instance=nullptr;
830 }
831
841 unsigned int GetEstimatedDelay()
842 {
843 assert(instance);
844 return bigvoice_GetEstimatedDelay(instance);
845 }
846
859 std::array<float,InputSampleSize>& GetBufferIn()
860 {
861 assert(instance);
862 float *buf=bigvoice_GetBufferIn(instance);
863 return reinterpret_cast< std::array<float,InputSampleSize>& >(*buf);
864
865 }
877 std::array<float,OutputSampleSize>& GetBufferOut()
878 {
879 assert(instance);
880 float *buf= bigvoice_GetBufferOut(instance);
881 return reinterpret_cast< std::array<float,OutputSampleSize>& >(*buf);
882 }
887 {
888 assert(instance);
890 }
902 void ProcessAudio_Planar(float const * const *input, float * const *output)
903 {
904 assert(instance);
905 bigvoice_ProcessAudio_Planar(instance, input, output);
906 }
907
919 template<typename T>
920 std::vector<T> ProcessAnyAudio(const std::vector<T> input)
921 {
922 assert(instance);
923 std::vector<T> output;
924 unsigned int out_offset=0;
925 unsigned int in_offset=0;
926 unsigned int todo = input.size();
927 while (todo>0) {
928 unsigned int left = AddAudio(&input[in_offset], todo);
929 unsigned int out_avail = bigvoice_GetOutputCount(instance);
930 output.resize(out_offset + out_avail);
931 GetAudio(&output[out_offset], out_avail);
932 out_offset+=out_avail;
933 in_offset += todo-left;
934 todo=left;
935 }
936 return output;
937 }
938
944 class CClient {
945 public:
947 {
948 assert(instance);
949 client=bigvoice_NewClient(instance);
950 if (!client) throw std::bad_alloc();
951 }
952 // non-copyable
953 CClient( const CInstance& ) = delete;
954 CClient& operator=( const CInstance& ) = delete;
956 {
957 if (client) {
958 bigvoice_DeleteClient(client);
959 client=nullptr;
960 }
961 }
969 std::string ProcessJson(const std::string &request, bool *NeedSave = nullptr)
970 {
971 assert(client);
972 int need_save=0;
973 const char *canswer = bigvoice_ProcessJson(client, request.c_str(), &need_save);
974 if (!canswer) return {};
975 std::string answer(canswer);
976 bigvoice_FreeJsonAnswer (canswer);
977 if (NeedSave) {
978 *NeedSave=(need_save!=0);
979 }
980 return answer;
981 }
982 private:
983 bigvoice_CClientInstance *client = nullptr;
984 };
992 std::shared_ptr<CClient> NewClient()
993 {
994 assert(instance);
995 return std::make_shared<CClient>(instance);
996 }
997
1008 bool SaveState() {
1009 assert(instance);
1010 if (bigvoice_SaveState(instance)!=0) {
1011 return false;
1012 }
1013 return true;
1014 }
1015
1016 protected:
1017 template<typename T>
1018 unsigned int AddAudio(const T* payload, unsigned int nFrame)
1019 {
1020 assert(instance);
1021 return bigvoice_AddAudio(instance, reinterpret_cast<const T*>(payload), nFrame, helper::SampleFormat<T>::format);
1022 }
1023 template<typename T>
1024 unsigned int GetAudio(T* payload, unsigned int max_nFrame)
1025 {
1026 assert(instance);
1027 return bigvoice_GetAudio(instance, reinterpret_cast<T*>(payload), max_nFrame, helper::SampleFormat<T>::format);
1028 }
1029
1030 private:
1031 bigvoice_CParameters* params = nullptr;
1032 bigvoice_CInstance* instance = nullptr;
1033 std::thread update_thread;
1034 std::vector< std::pair<std::string,std::string> > init_metadata;
1035#if BIGVOICE_HAS_WEBSERVER
1036 uint64_t webserver = SOUND4_INVALID_WEBSERVER_ID;
1037#endif // BIGVOICE_HAS_WEBSERVER
1038 };
1039
1040}; // namespace bigvoice
1041}; // namespace sound4
1042
1043// bridge C callbacks to CPresetLoader
1044extern "C" {
1045 static char *bigvoice_custom_reader(const fs_char *filename, void* userdata) {
1046 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1047 std::string content=preset_loader->Read(filename);
1048 return strdup(content.c_str());
1049 }
1050 static void bigvoice_custom_reader_free(char *content, void* userdata) {
1051 if (!content) return;
1052 free(content);
1053 }
1054 static int bigvoice_custom_writer(const fs_char *filename, const char *content, void* userdata) {
1055 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1056 auto res=preset_loader->Write(filename,content);
1057 return res?0:-1;
1058 }
1059 static int bigvoice_custom_exists(const fs_char *filename, void* userdata) {
1060 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1061 auto res=preset_loader->Exists(filename);
1062 return res?0:-1;
1063 }
1064 static fs_char** bigvoice_custom_getall(void* userdata) {
1065 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1066 auto res=preset_loader->GetAll();
1067 fs_char**all=(fs_char**)malloc((res.size()+1)*sizeof(const fs_char*));
1068 for (size_t n=0;n<res.size();n++) {
1069 all[n]=fs_strdup(res[n].c_str());
1070 }
1071 all[res.size()]=nullptr;
1072 return all;
1073 }
1074 static void bigvoice_custom_getall_free(fs_char** all, void* userdata) {
1075 if (!all) return;
1076 for (fs_char** one=all;*one;one++) {
1077 free(*one);
1078 }
1079 free(all);
1080 }
1081 static int bigvoice_custom_remove(const fs_char *filename, void* userdata) {
1082 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1083 auto res=preset_loader->Remove(filename);
1084 return res?0:-1;
1085 }
1086 static int bigvoice_custom_rename(const fs_char *from, const fs_char *to, void* userdata) {
1087 sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
1088 auto res=preset_loader->Rename(from,to);
1089 return res?0:-1;
1090 }
1091
1092};
bigvoice_CBus * Get() const
CClient(bigvoice_CInstance *instance)
std::string ProcessJson(const std::string &request, bool *NeedSave=nullptr)
Process a JSON request and returns the answer.
CClient & operator=(const CInstance &)=delete
CClient(const CInstance &)=delete
void SetMetadataMulti(const std::unordered_map< std::string, const char * > &list)
void GetWebServerAppHealth(int &httpcode, std::string &contenttype, std::string &content)
std::string GetParam(const std::string &name)
std::array< float, OutputSampleSize > & GetBufferOut()
void PresetManager_InformChange(const std::filesystem::path &relative_path, PresetChange_Kind change_kind)
std::vector< T > ProcessAnyAudio(const std::vector< T > input)
void ProcessAudio_Planar(float const *const *input, float *const *output)
unsigned int AddAudio(const T *payload, unsigned int nFrame)
void StopWebServer(int timeout_ms=1000)
CInstance & operator=(const CInstance &)=delete
void SetPresetManager(CPresetLoader *preset_manager)
unsigned int GetAudio(T *payload, unsigned int max_nFrame)
bool StartWebServer(int http_port, int https_port=0)
void SetMetadata(const std::string &key, const char *value)
bool Create(const std::string &LoginKey, const std::string &RadioName, const std::string &Access_Key_ID, const std::string &Access_Key_Secret, const std::filesystem::path &save_path, int json_port=0, unsigned int frames_per_chunk=12)
void SetWebServerAppHealth(int httpcode, const std::string &contenttype, const std::string &content)
std::vector< std::tuple< std::string, std::string > > GetMetadataInfos()
CInstance(const CInstance &)=delete
std::array< float, InputSampleSize > & GetBufferIn()
std::shared_ptr< CClient > NewClient()
void SetParam(const std::string &name, const std::string &value)
Custom preset handler helper.
virtual ~CPresetLoader()=default
virtual bool Write(const std::filesystem::path &filename, const std::string &content)=0
virtual bool Exists(const std::filesystem::path &name)=0
virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to)=0
virtual bool Remove(const std::filesystem::path &name)=0
virtual std::vector< std::filesystem::path > GetAll()=0
virtual std::string Read(const std::filesystem::path &filename)=0
unsigned int bigvoice_GetOutputCount(struct bigvoice_CInstance *instance)
unsigned int bigvoice_GetAudio(struct bigvoice_CInstance *instance, uint8_t *payload, unsigned int max_nFrame, enum bigvoice_SampleFormat fmt)
bigvoice_SampleFormat
const char * bigvoice_GetFormatName(const enum bigvoice_SampleFormat fmt)
unsigned int bigvoice_GetBytesFromFormat(const enum bigvoice_SampleFormat fmt)
enum bigvoice_SampleFormat bigvoice_GetFormatFromName(const char *name)
unsigned int bigvoice_AddAudio(struct bigvoice_CInstance *instance, const uint8_t *payload, unsigned int nFrame, enum bigvoice_SampleFormat fmt)
int bigvoice_SaveState(struct bigvoice_CInstance *instance)
void bigvoice_DeleteClient(struct bigvoice_CClientInstance *client)
const char * bigvoice_ProcessJson(struct bigvoice_CClientInstance *client, const char *json_str, int *need_save)
void bigvoice_FreeJsonAnswer(const char *json_str)
struct bigvoice_CClientInstance * bigvoice_NewClient(struct bigvoice_CInstance *instance)
struct bigvoice_CBus * bigvoice_NewBus()
void bigvoice_FreeBus(struct bigvoice_CBus *bus)
void bigvoice_SetInstanceBus(struct bigvoice_CParameters *params, struct bigvoice_CBus *bus)
void bigvoice_AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, enum bigvoice_SampleFormat fmt)
void bigvoice_AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, enum bigvoice_SampleFormat fmt)
void bigvoice_AudioMonoToLiveStereo(const float *input, uint8_t *payload)
void bigvoice_StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nFrame)
void bigvoice_MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nFrame)
void bigvoice_AudioMonoFromLiveStereo(const uint8_t *payload, float *output)
void bigvoice_MonoToStereo(const float *input, float *output, size_t nFrame)
void bigvoice_StereoToMono(const float *input, float *output, size_t nFrame)
void bigvoice_ProcessAudio(struct bigvoice_CInstance *instance, const float *input, float *output)
unsigned int bigvoice_GetEstimatedDelay(struct bigvoice_CInstance *instance)
float * bigvoice_GetBufferOut(struct bigvoice_CInstance *instance)
float * bigvoice_GetBufferIn(struct bigvoice_CInstance *instance)
void bigvoice_ProcessAudio_Planar(struct bigvoice_CInstance *instance, float const *const *input, float *const *output)
#define BIGVOICE_SAMPLE_RATE
#define BIGVOICE_CHANNEL_COUNT
bigvoice_LogSeverity
unsigned int bigvoice_GetAudioInputCount()
unsigned int bigvoice_GetChannelCount()
void bigvoice_SetLoggerCallback(bigvoice_loggerfn logger)
void bigvoice_SetLogSeverity(enum bigvoice_LogSeverity severity)
#define BIGVOICE_AUDIO_OUTPUT_COUNT
unsigned int bigvoice_GetChunkSizeInFrames()
unsigned int bigvoice_GetAudioOutputCount()
#define BIGVOICE_AUDIO_INPUT_COUNT
const char * bigvoice_GetVersion()
#define BIGVOICE_AUDIOFRAME_COUNT
unsigned int bigvoice_GetSampleRate()
unsigned int * bigvoice_GetPossibleChunkSizeInFrames()
void bigvoice_FreeParameterValue(const char *value)
int bigvoice_TerminateProcess(struct bigvoice_CInstance *instance)
struct bigvoice_CInstance * bigvoice_InitProcess3(const char *LoginKey, const char *RadioName, const char *Access_Key_ID, const char *Access_Key_Secret, const char *save_path, const struct bigvoice_CParameters *parameters, unsigned int frames_per_chunk)
void bigvoice_FreeParameters(struct bigvoice_CParameters *params)
void bigvoice_ExitProcess(struct bigvoice_CInstance *instance)
struct bigvoice_CParameters * bigvoice_NewParameters()
unsigned int bigvoice_GetProcessChunkFrames(struct bigvoice_CInstance *instance)
void bigvoice_SetParameter(struct bigvoice_CParameters *params, const char *name, const char *value)
const char * bigvoice_GetParameter(struct bigvoice_CParameters *params, const char *name)
void bigvoice_FreeMetadataInfos(struct bigvoice_CInstance *instance, const char **infos)
void bigvoice_SetMetadata(struct bigvoice_CInstance *instance, const char *key, const char *value)
const char ** bigvoice_GetMetadataInfos(struct bigvoice_CInstance *instance)
void bigvoice_SetMetadataMulti(struct bigvoice_CInstance *instance, const char **keyvalue)
bigvoice_PresetChange_Kind
void bigvoice_SetPresetManager(struct bigvoice_CParameters *params, bigvoice_storage_reader reader, bigvoice_storage_reader_free, bigvoice_storage_writer writer, bigvoice_storage_exists exists, bigvoice_storage_getall getall, bigvoice_storage_getall_free getall_free, bigvoice_storage_remove remove, bigvoice_storage_rename rename, int IsReadOnly, void *userdata)
void bigvoice_PresetManager_InformChange(struct bigvoice_CInstance *instance, const fs_char *relative_path, enum bigvoice_PresetChange_Kind change_kind)
wchar_t fs_char
void bigvoice_StopUpdateThread(struct bigvoice_CInstance *instance)
int bigvoice_WaitUpdateThreadReady(struct bigvoice_CInstance *instance, int milliseconds)
void bigvoice_StartUpdateThread(struct bigvoice_CInstance *instance, unsigned int port)
#define SOUND4_WEBSERVER_HTTPS_OK
uint64_t bigvoice_Webserver(unsigned int listenport, unsigned int listenport_secure, struct bigvoice_CInstance *instance)
int bigvoice_Webserver_Stop(uint64_t id, int timeout_ms)
int bigvoice_Webserver_Status(uint64_t id)
void bigvoice_Webserver_SetAppHealth(struct bigvoice_CInstance *instance, int httpcode, const char *contenttype, const char *content)
#define SOUND4_WEBSERVER_HTTP_OK
void bigvoice_Webserver_FreeString(char *str)
#define SOUND4_INVALID_WEBSERVER_ID
void bigvoice_Webserver_GetAppHealth(struct bigvoice_CInstance *instance, int *httpcode, char **contenttype, char **content)
static std::wstring UTF8ToWString(const std::string &str)
static void MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nFrame)
static void AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, bigvoice_SampleFormat fmt)
static void MonoToStereo(const float *input, float *output, size_t nFrame)
static void StereoToMono(const float *input, float *output, size_t nFrame)
static void StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nFrame)
static std::string WStringToUTF8(const std::wstring &wstr)
static void AudioMonoToLiveStereo(const float *input, uint8_t *payload)
static void AudioMonoFromLiveStereo(const uint8_t *payload, float *output)
static void AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, bigvoice_SampleFormat fmt)
static log_cb_t _log_cb
static unsigned int GetAudioInputCount()
static std::vector< unsigned int > GetPossibleChunkSizeInFrames()
const size_t OutputChannels
static std::string GetFormatName(const SampleFormat fmt)
static SampleFormat GetFormatFromName(const std::string &name)
std::function< void(LogSeverity, const std::string &)> log_cb_t
static void SetLogSeverity(LogSeverity severity)
const size_t OutputSampleSize
static void SanityCheck(bool a_bCheckFrames=true)
static unsigned int GetSampleRate()
static constexpr const char * process_name
const size_t InputSampleSize
static unsigned int GetChannelCount()
static unsigned int GetAudioOutputCount()
static void SetLoggerCallback(log_cb_t cb)
static unsigned int GetChunkSizeInFrames()
static unsigned int GetBytesFromFormat(const SampleFormat fmt)
static constexpr const char * process_shortname
static std::string GetVersion()
static void _log_cb_c(bigvoice_LogSeverity severity, const char *c_msg)
@ S32_NATIVE
32-bit signed integer, native
Definition sound4cl.hpp:69
@ F32_NATIVE
32-bit floating-point, native
Definition sound4cl.hpp:70
@ S16_NATIVE
16-bit signed integer, native
Definition sound4cl.hpp:67
C interface for library.
static int bigvoice_custom_exists(const fs_char *filename, void *userdata)
static int bigvoice_custom_rename(const fs_char *from, const fs_char *to, void *userdata)
static int bigvoice_custom_writer(const fs_char *filename, const char *content, void *userdata)
static fs_char ** bigvoice_custom_getall(void *userdata)
static int bigvoice_custom_remove(const fs_char *filename, void *userdata)
static void bigvoice_custom_reader_free(char *content, void *userdata)
static char * bigvoice_custom_reader(const fs_char *filename, void *userdata)
static void bigvoice_custom_getall_free(fs_char **all, void *userdata)