SOUND4 BIGVOICE.CL Library [1.0.2]
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
32 extern "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 
46 namespace sound4 {
50 namespace bigvoice {
51  static constexpr const char *process_name = "SOUND4 BIGVOICE.CL";
52  static constexpr const char *process_shortname = "bigvoice";
78 
82  namespace helper {
83  #ifdef _WIN32
89  static inline std::string WStringToUTF8(const std::wstring& wstr) {
90  if (wstr.empty()) return {};
91  int size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
92  std::string str(size, 0);
93  WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size, NULL, NULL);
94  return str;
95  }
101  static inline std::wstring UTF8ToWString(const std::string& str) {
102  if (str.empty()) return std::wstring();
103  int size = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
104  std::wstring wstr(size, 0);
105  MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstr[0], size);
106  return wstr;
107  }
108  #endif // _WIN32
109 
115  template<typename T>
116  struct SampleFormat {
117  };
118  template<>
119  struct SampleFormat<int16_t> {
121  };
122  template<>
123  struct SampleFormat<int32_t> {
125  };
126  template<>
127  struct SampleFormat<float> {
129  };
130 
131 
136  static inline void AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, bigvoice_SampleFormat fmt) {
137  bigvoice_AudioConvertFrom(payload, output, nSpl, fmt);
138  }
139  static inline void AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, bigvoice_SampleFormat fmt) {
140  bigvoice_AudioConvertTo(input, payload, nSpl, fmt);
141  }
142  static inline void StereoToMono(const float *input, float *output, size_t nSpl) {
143  bigvoice_StereoToMono(input, output, nSpl);
144  }
145  static inline void MonoToStereo(const float *input, float *output, size_t nSpl) {
146  bigvoice_MonoToStereo(input, output, nSpl);
147  }
148  static inline void StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nSpl) {
149  bigvoice_StereoToMono_Planar(inputL, inputR, output, nSpl);
150  }
151  static inline void MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nSpl) {
152  bigvoice_MonoToStereo_Planar(input, outputL, outputR, nSpl);
153  }
154  static inline void AudioMonoFromLiveStereo(const uint8_t *payload, float *output) {
155  bigvoice_AudioMonoFromLiveStereo(payload, output);
156  }
157  static inline void AudioMonoToLiveStereo(const float *input, uint8_t *payload) {
158  bigvoice_AudioMonoToLiveStereo(input, payload);
159  }
160 
161  }; // namespace helper
162 
168  static inline std::string GetVersion()
169  {
170  return std::string(bigvoice_GetVersion());
171  }
172 
183  static inline unsigned int GetChunkSizeInFrames()
184  {
186  }
187 
196  static inline std::vector<unsigned int> GetPossibleChunkSizeInFrames()
197  {
198  std::vector<unsigned int> list;
199  for (unsigned int* src=bigvoice_GetPossibleChunkSizeInFrames();*src;src++) {
200  list.push_back(*src);
201  }
202  return list;
203  }
204 
212  static inline unsigned int GetChannelCount()
213  {
214  return bigvoice_GetChannelCount();
215  }
216 
225  static inline unsigned int GetAudioInputCount()
226  {
228  }
229 
238  static inline unsigned int GetAudioOutputCount()
239  {
241  }
242 
250  static inline unsigned int GetSampleRate()
251  {
252  return bigvoice_GetSampleRate();
253  }
254 
260  static inline void SanityCheck(bool a_bCheckFrames = true)
261  {
262  // Do some sanity checks
264  throw std::runtime_error("Bad library sampling rate");
265  }
266  if (a_bCheckFrames && bigvoice_GetChunkSizeInFrames()!=ChunkFrames) {
267  throw std::runtime_error("Bad library frame size");
268  }
270  throw std::runtime_error("Bad library channel count");
271  }
273  throw std::runtime_error("Bad library input count");
274  }
276  throw std::runtime_error("Bad library output count");
277  }
278  }
279 
286  static inline std::string GetFormatName(const SampleFormat fmt)
287  {
288  return std::string(bigvoice_GetFormatName(fmt));
289  }
290 
297  static inline SampleFormat GetFormatFromName(const std::string& name)
298  {
299  return bigvoice_GetFormatFromName(name.c_str());
300  }
301 
308  static inline unsigned int GetBytesFromFormat(const SampleFormat fmt)
309  {
310  return bigvoice_GetBytesFromFormat(fmt);
311  }
312 
320  using log_cb_t = std::function<void(LogSeverity,const std::string&)>;
321 
325  static log_cb_t _log_cb;
326  extern "C" {
327  static inline void _log_cb_c(bigvoice_LogSeverity severity, const char *c_msg) {
328  _log_cb(severity, std::string(c_msg));
329  }
330  }
334  static inline void SetLogSeverity(LogSeverity severity)
335  {
336  bigvoice_SetLogSeverity(severity);
337  }
341  static inline void SetLoggerCallback(log_cb_t cb)
342  {
343  _log_cb=cb;
344  bigvoice_SetLoggerCallback(&_log_cb_c);
345  }
346 
347 #if BIGVOICE_HAS_CLOUDBUS
348  class CBus {
349  public:
351  : m_bus(bigvoice_NewBus()) {}
353  {
354  bigvoice_FreeBus(m_bus);
355  m_bus = nullptr;
356  }
357  bigvoice_CBus *Get() const { return m_bus; }
358  private:
359  bigvoice_CBus *m_bus;
360  };
361 #endif // BIGVOICE_HAS_CLOUDBUS
362 
368  public:
369  CPresetLoader() = default;
370  virtual ~CPresetLoader() = default;
371 
372  virtual bool IsReadOnly() = 0;
373  virtual bool Exists(const std::filesystem::path &name) = 0;
374  virtual bool Remove(const std::filesystem::path &name) = 0;
375  virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to) = 0;
376  virtual std::vector<std::filesystem::path> GetAll() = 0;
377  virtual std::string Read(const std::filesystem::path &filename) = 0;
378  virtual bool Write(const std::filesystem::path &filename, const std::string &content) =0;
379  };
381 
385  class CInstance {
386  public:
391  {
392  params = bigvoice_NewParameters();
393  if (!params) throw std::bad_alloc();
394  }
395  // non-copyable
396  CInstance( const CInstance& ) = delete;
397  CInstance& operator=( const CInstance& ) = delete;
402  {
403  Stop();
404  if (params) bigvoice_FreeParameters(params);
405  }
409  bool IsOk() const { return instance!=nullptr; }
417  void SetParam(const std::string& name, const std::string& value)
418  {
419  assert(params);
420  bigvoice_SetParameter(params, name.c_str(), value.c_str());
421  }
427  std::string GetParam(const std::string& name)
428  {
429  assert(params);
430  auto c_value=bigvoice_GetParameter(params, name.c_str());
431  std::string ret(c_value);
433  return ret;
434  }
435 
445  void SetPresetManager(CPresetLoader *preset_manager)
446  {
447  if (!preset_manager) return;
448  assert(params);
450  bigvoice_custom_reader,
451  bigvoice_custom_reader_free,
452  bigvoice_custom_writer,
453  bigvoice_custom_exists,
454  bigvoice_custom_getall,
455  bigvoice_custom_getall_free,
456  bigvoice_custom_remove,
457  bigvoice_custom_rename,
458  preset_manager->IsReadOnly(),
459  preset_manager
460  );
461  }
462 
463 #if BIGVOICE_HAS_CLOUDBUS
467  void SetBus(const CBus& bus) {
468  assert(params);
469  bigvoice_SetInstanceBus(params,bus.Get());
470  }
471 #endif // BIGVOICE_HAS_CLOUDBUS
472 
487  bool Create(const std::string& LoginKey, const std::string& RadioName, const std::string& AWS_Access_ID, const std::string& AWS_Access_Secret, const std::filesystem::path& save_path, int json_port = 0, unsigned int frames_per_chunk=12)
488  {
489  assert(!instance);
490  std::string l_save_path;
491  if (!save_path.empty()) {
492  l_save_path = save_path.u8string();
493  }
494  instance = bigvoice_InitProcess3(LoginKey.c_str(), RadioName.c_str(), AWS_Access_ID.c_str(), AWS_Access_Secret.c_str(), l_save_path.c_str(), params, frames_per_chunk);
495  if (!instance) return false;
496  if (!init_metadata.empty()) {
497  for (auto&& [key,value]: init_metadata) {
498  bigvoice_SetMetadata(instance, key.c_str(), value.c_str());
499  }
500  init_metadata.clear();
501  }
502  update_thread = std::thread([this, json_port](){
504  bigvoice_StartUpdateThread(instance, json_port);
506  });
507  int timeout=5000;
508  #ifdef DEBUG
509  timeout=60*1000; // For debugger pauses
510  #endif
511  if (bigvoice_WaitUpdateThreadReady(instance, timeout)<0) {
512  return false;
513  }
514  return true;
515  }
516 
524  unsigned int GetChunkFrames() {
525  if (instance) {
526  return bigvoice_GetProcessChunkFrames(instance);
527  }
528  return 0;
529  }
530 
538  void PresetManager_InformChange(const std::filesystem::path& relative_path, PresetChange_Kind change_kind)
539  {
540  bigvoice_PresetManager_InformChange(instance, relative_path.c_str(), (bigvoice_PresetChange_Kind) change_kind);
541  }
542 
554  void SetMetadata(const std::string& key, const char* value)
555  {
556  if (instance) {
557  bigvoice_SetMetadata(instance, key.c_str(), value);
558  } else {
559  init_metadata.push_back( {key, value} );
560  }
561  }
562 
572  void SetMetadataMulti(const std::unordered_map<std::string, const char*>& list)
573  {
574  if (instance) {
575  typedef const char* pchar;
576  pchar* keyvalue=new pchar[2*list.size()+1];
577  size_t n=0;
578  for (auto&& [key,value]: list) {
579  keyvalue[2*n+0]=key.c_str();
580  keyvalue[2*n+1]=value;
581  n++;
582  }
583  keyvalue[2*n+0]=nullptr;
584 
585  bigvoice_SetMetadataMulti(instance, keyvalue);
586 
587  delete[] keyvalue;
588  } else {
589  for (auto&& [key,value]: list) {
590  if (value) {
591  init_metadata.push_back( {key, value} );
592  }
593  }
594  }
595  }
596 
602  std::vector< std::tuple<std::string,std::string> > GetMetadataInfos()
603  {
604  std::vector< std::tuple<std::string,std::string> > values;
605  const char** c_values = bigvoice_GetMetadataInfos(instance);
606  if (c_values) {
607  for (const char** c_value=c_values; *c_value; ) {
608  std::string key(*c_value);
609  c_value++;
610  if (*c_value) {
611  std::string descr(*c_value);
612  c_value++;
613  values.push_back( {key,descr} );
614  }
615  }
616  bigvoice_FreeMetadataInfos(instance, c_values);
617  }
618  return values;
619  }
620 
621  // Can be overloaded, called at start of UpdateThread in the thread
622  virtual void OnUpdateThreadStart() {}
623  // Can be overloaded to call at end of UpdateThread in the thread
624  virtual void OnUpdateThreadStop() {}
625 
626 #if BIGVOICE_HAS_WEBSERVER
632  bool StartWebServer(int http_port, int https_port=0)
633  {
634  assert(instance);
635  assert(webserver==SOUND4_INVALID_WEBSERVER_ID);
636  webserver = bigvoice_Webserver(http_port,https_port,instance);
637  if (webserver==SOUND4_INVALID_WEBSERVER_ID) {
638  return false;
639  }
640  int web_status=bigvoice_Webserver_Status(webserver);
641  if (http_port && (web_status & SOUND4_WEBSERVER_HTTP_OK) == 0) {
642  return false;
643  }
644  if (https_port && (web_status & SOUND4_WEBSERVER_HTTPS_OK) == 0) {
645  return false;
646  }
647  return true;
648  }
655  {
656  if (webserver != SOUND4_INVALID_WEBSERVER_ID) {
657  bigvoice_Webserver_Stop(webserver, 1000);
658  webserver = SOUND4_INVALID_WEBSERVER_ID;
659  }
660  }
661 #endif // BIGVOICE_HAS_WEBSERVER
662 
669  int Terminate()
670  {
671  if (!instance) return 0;
672  return bigvoice_TerminateProcess(instance);
673  }
674 
680  void Stop()
681  {
682  if (!instance) return;
683 #if BIGVOICE_HAS_WEBSERVER
684  StopWebServer();
685 #endif // BIGVOICE_HAS_WEBSERVER
686  if (update_thread.joinable()) {
687  bigvoice_StopUpdateThread(instance); // this will exit the update thread
688  update_thread.join();
689  }
690  bigvoice_ExitProcess(instance);
691  instance=nullptr;
692  }
693 
699  unsigned int GetEstimatedDelay()
700  {
701  assert(instance);
702  return bigvoice_GetEstimatedDelay(instance);
703  }
704 
715  std::array<float,InputSampleSize>& GetBufferIn()
716  {
717  assert(instance);
718  float *buf=bigvoice_GetBufferIn(instance);
719  return reinterpret_cast< std::array<float,InputSampleSize>& >(*buf);
720 
721  }
732  std::array<float,OutputSampleSize>& GetBufferOut()
733  {
734  assert(instance);
735  float *buf= bigvoice_GetBufferOut(instance);
736  return reinterpret_cast< std::array<float,OutputSampleSize>& >(*buf);
737  }
744  {
745  assert(instance);
746  bigvoice_ProcessAudio(instance, bigvoice_GetBufferIn(instance), bigvoice_GetBufferOut(instance));
747  }
761  // void ProcessAudio_Planar(const std::array< const std::array<const float,ChunkFrames>, InputChannels>& input, std::array< std::array<float,ChunkFrames>, OutputChannels>& output)
762  void ProcessAudio_Planar(float const * const *input, float * const *output)
763  {
764  assert(instance);
765  bigvoice_ProcessAudio_Planar(instance, input, output);
766  }
767 
779  template<typename T>
780  std::vector<T> ProcessAnyAudio(const std::vector<T> input)
781  {
782  assert(instance);
783  std::vector<T> output;
784  unsigned int out_offset=0;
785  unsigned int in_offset=0;
786  unsigned int todo = input.size();
787  while (todo>0) {
788  unsigned int left = AddAudio(&input[in_offset], todo);
789  unsigned int out_avail = bigvoice_GetOutputCount(instance);
790  output.resize(out_offset + out_avail);
791  GetAudio(&output[out_offset], out_avail);
792  out_offset+=out_avail;
793  in_offset += todo-left;
794  todo=left;
795  }
796  return output;
797  }
798 
804  class CClient {
805  public:
807  {
808  assert(instance);
809  client=bigvoice_NewClient(instance);
810  if (!client) throw std::bad_alloc();
811  }
812  // non-copyable
813  CClient( const CInstance& ) = delete;
814  CClient& operator=( const CInstance& ) = delete;
816  {
817  if (client) {
818  bigvoice_DeleteClient(client);
819  client=nullptr;
820  }
821  }
829  std::string ProcessJson(const std::string &request, bool *NeedSave = nullptr)
830  {
831  assert(client);
832  int need_save=0;
833  const char *canswer = bigvoice_ProcessJson(client, request.c_str(), &need_save);
834  if (!canswer) return {};
835  std::string answer(canswer);
836  bigvoice_FreeJsonAnswer (canswer);
837  if (NeedSave) {
838  *NeedSave=(need_save!=0);
839  }
840  return answer;
841  }
842  private:
843  bigvoice_CClientInstance *client = nullptr;
844  };
852  std::shared_ptr<CClient> NewClient()
853  {
854  assert(instance);
855  return std::make_shared<CClient>(instance);
856  }
857 
858  protected:
859  template<typename T>
860  unsigned int AddAudio(const T* payload, unsigned int nFrame)
861  {
862  assert(instance);
863  return bigvoice_AddAudio(instance, reinterpret_cast<const T*>(payload), nFrame, helper::SampleFormat<T>::format);
864  }
865  template<typename T>
866  unsigned int GetAudio(T* payload, unsigned int max_nFrame)
867  {
868  assert(instance);
869  return bigvoice_GetAudio(instance, reinterpret_cast<T*>(payload), max_nFrame, helper::SampleFormat<T>::format);
870  }
871 
872  private:
873  bigvoice_CParameters* params = nullptr;
874  bigvoice_CInstance* instance = nullptr;
875  std::thread update_thread;
876  std::vector< std::pair<std::string,std::string> > init_metadata;
877 #if BIGVOICE_HAS_WEBSERVER
878  uint64_t webserver = SOUND4_INVALID_WEBSERVER_ID;
879 #endif // BIGVOICE_HAS_WEBSERVER
880  };
881 
882 }; // namespace bigvoice
883 }; // namespace sound4
884 
885 // bridge C callbacks to CPresetLoader
886 extern "C" {
887  static char *bigvoice_custom_reader(const fs_char *filename, void* userdata) {
888  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
889  std::string content=preset_loader->Read(filename);
890  return strdup(content.c_str());
891  }
892  static void bigvoice_custom_reader_free(char *content, void* userdata) {
893  if (!content) return;
894  free(content);
895  }
896  static int bigvoice_custom_writer(const fs_char *filename, const char *content, void* userdata) {
897  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
898  auto res=preset_loader->Write(filename,content);
899  return res?0:-1;
900  }
901  static int bigvoice_custom_exists(const fs_char *filename, void* userdata) {
902  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
903  auto res=preset_loader->Exists(filename);
904  return res?0:-1;
905  }
906  static fs_char** bigvoice_custom_getall(void* userdata) {
907  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
908  auto res=preset_loader->GetAll();
909  fs_char**all=(fs_char**)malloc((res.size()+1)*sizeof(const fs_char*));
910  for (size_t n=0;n<res.size();n++) {
911  all[n]=fs_strdup(res[n].c_str());
912  }
913  all[res.size()]=nullptr;
914  return all;
915  }
916  static void bigvoice_custom_getall_free(fs_char** all, void* userdata) {
917  if (!all) return;
918  for (fs_char** one=all;*one;one++) {
919  free(*one);
920  }
921  free(all);
922  }
923  static int bigvoice_custom_remove(const fs_char *filename, void* userdata) {
924  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
925  auto res=preset_loader->Remove(filename);
926  return res?0:-1;
927  }
928  static int bigvoice_custom_rename(const fs_char *from, const fs_char *to, void* userdata) {
929  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
930  auto res=preset_loader->Rename(from,to);
931  return res?0:-1;
932  }
933 
934 };
bigvoice_CBus * Get() const
CClient(bigvoice_CInstance *instance)
CClient & operator=(const CInstance &)=delete
std::string ProcessJson(const std::string &request, bool *NeedSave=nullptr)
Process a JSON request and returns the answer.
CClient(const CInstance &)=delete
void SetMetadataMulti(const std::unordered_map< std::string, const char * > &list)
std::string GetParam(const std::string &name)
CInstance & operator=(const CInstance &)=delete
std::vector< std::tuple< std::string, std::string > > GetMetadataInfos()
void PresetManager_InformChange(const std::filesystem::path &relative_path, PresetChange_Kind change_kind)
void ProcessAudio_Planar(float const *const *input, float *const *output)
unsigned int AddAudio(const T *payload, unsigned int nFrame)
void SetPresetManager(CPresetLoader *preset_manager)
unsigned int GetAudio(T *payload, unsigned int max_nFrame)
std::array< float, OutputSampleSize > & GetBufferOut()
std::array< float, InputSampleSize > & GetBufferIn()
std::shared_ptr< CClient > NewClient()
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 &AWS_Access_ID, const std::string &AWS_Access_Secret, const std::filesystem::path &save_path, int json_port=0, unsigned int frames_per_chunk=12)
CInstance(const CInstance &)=delete
std::vector< T > ProcessAnyAudio(const std::vector< T > input)
void SetParam(const std::string &name, const std::string &value)
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::string Read(const std::filesystem::path &filename)=0
virtual std::vector< std::filesystem::path > GetAll()=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)
@ F32_NATIVE
32-bit floating-point, native
@ S16_NATIVE
16-bit signed integer, native
@ S32_NATIVE
32-bit signed integer, native
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)
void bigvoice_ProcessAudio_Planar(struct bigvoice_CInstance *instance, float const *const *input, float *const *output)
float * bigvoice_GetBufferIn(struct bigvoice_CInstance *instance)
#define BIGVOICE_SAMPLE_RATE
#define BIGVOICE_CHANNEL_COUNT
const char * bigvoice_GetVersion()
bigvoice_LogSeverity
unsigned int * bigvoice_GetPossibleChunkSizeInFrames()
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
#define BIGVOICE_AUDIOFRAME_COUNT
unsigned int bigvoice_GetSampleRate()
void bigvoice_FreeParameterValue(const char *value)
int bigvoice_TerminateProcess(struct bigvoice_CInstance *instance)
void bigvoice_FreeParameters(struct bigvoice_CParameters *params)
void bigvoice_ExitProcess(struct bigvoice_CInstance *instance)
struct bigvoice_CInstance * bigvoice_InitProcess3(const char *LoginKey, const char *RadioName, const char *AWS_Access_ID, const char *AWS_Access_Secret, const char *save_path, const struct bigvoice_CParameters *parameters, unsigned int frames_per_chunk)
unsigned int bigvoice_GetProcessChunkFrames(struct bigvoice_CInstance *instance)
const char * bigvoice_GetParameter(struct bigvoice_CParameters *params, const char *name)
struct bigvoice_CParameters * bigvoice_NewParameters()
void bigvoice_SetParameter(struct bigvoice_CParameters *params, const char *name, const char *value)
void bigvoice_FreeMetadataInfos(struct bigvoice_CInstance *instance, const char **infos)
void bigvoice_SetMetadata(struct bigvoice_CInstance *instance, const char *key, const char *value)
void bigvoice_SetMetadataMulti(struct bigvoice_CInstance *instance, const char **keyvalue)
const char ** bigvoice_GetMetadataInfos(struct bigvoice_CInstance *instance)
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)
#define SOUND4_WEBSERVER_HTTP_OK
#define SOUND4_INVALID_WEBSERVER_ID
const size_t OutputChannels
std::function< void(LogSeverity, const std::string &)> log_cb_t
const size_t OutputSampleSize
const size_t ChunkFrames
const size_t InputChannels
const size_t InputSampleSize
bigvoice_SampleFormat SampleFormat
bigvoice_LogSeverity LogSeverity
C interface for library.
#define fs_strdup
helper for OS dependant file name copy
Helper for Sample format types.