SOUND4 BIGVOICE.CL Library [1.1.0]
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 
665  void SetWebServerAppHealth(int httpcode, const std::string& contenttype, const std::string& content)
666  {
667  assert(instance);
668  bigvoice_Webserver_SetAppHealth(instance, httpcode, contenttype.c_str(), content.c_str());
669  }
673  void GetWebServerAppHealth(int &httpcode, std::string& contenttype, std::string& content)
674  {
675  assert(instance);
676  char* c_contenttype=nullptr;
677  char* c_content=nullptr;
678  bigvoice_Webserver_GetAppHealth(instance, &httpcode, &c_contenttype, &c_content);
679  contenttype=c_contenttype;
680  content=c_content;
681  bigvoice_Webserver_FreeString(c_contenttype);
683  }
684 #endif // BIGVOICE_HAS_WEBSERVER
685 
692  int Terminate()
693  {
694  if (!instance) return 0;
695  return bigvoice_TerminateProcess(instance);
696  }
697 
703  void Stop()
704  {
705  if (!instance) return;
706 #if BIGVOICE_HAS_WEBSERVER
707  StopWebServer();
708 #endif // BIGVOICE_HAS_WEBSERVER
709  if (update_thread.joinable()) {
710  bigvoice_StopUpdateThread(instance); // this will exit the update thread
711  update_thread.join();
712  }
713  bigvoice_ExitProcess(instance);
714  instance=nullptr;
715  }
716 
722  unsigned int GetEstimatedDelay()
723  {
724  assert(instance);
725  return bigvoice_GetEstimatedDelay(instance);
726  }
727 
738  std::array<float,InputSampleSize>& GetBufferIn()
739  {
740  assert(instance);
741  float *buf=bigvoice_GetBufferIn(instance);
742  return reinterpret_cast< std::array<float,InputSampleSize>& >(*buf);
743 
744  }
755  std::array<float,OutputSampleSize>& GetBufferOut()
756  {
757  assert(instance);
758  float *buf= bigvoice_GetBufferOut(instance);
759  return reinterpret_cast< std::array<float,OutputSampleSize>& >(*buf);
760  }
767  {
768  assert(instance);
769  bigvoice_ProcessAudio(instance, bigvoice_GetBufferIn(instance), bigvoice_GetBufferOut(instance));
770  }
784  // void ProcessAudio_Planar(const std::array< const std::array<const float,ChunkFrames>, InputChannels>& input, std::array< std::array<float,ChunkFrames>, OutputChannels>& output)
785  void ProcessAudio_Planar(float const * const *input, float * const *output)
786  {
787  assert(instance);
788  bigvoice_ProcessAudio_Planar(instance, input, output);
789  }
790 
802  template<typename T>
803  std::vector<T> ProcessAnyAudio(const std::vector<T> input)
804  {
805  assert(instance);
806  std::vector<T> output;
807  unsigned int out_offset=0;
808  unsigned int in_offset=0;
809  unsigned int todo = input.size();
810  while (todo>0) {
811  unsigned int left = AddAudio(&input[in_offset], todo);
812  unsigned int out_avail = bigvoice_GetOutputCount(instance);
813  output.resize(out_offset + out_avail);
814  GetAudio(&output[out_offset], out_avail);
815  out_offset+=out_avail;
816  in_offset += todo-left;
817  todo=left;
818  }
819  return output;
820  }
821 
827  class CClient {
828  public:
830  {
831  assert(instance);
832  client=bigvoice_NewClient(instance);
833  if (!client) throw std::bad_alloc();
834  }
835  // non-copyable
836  CClient( const CInstance& ) = delete;
837  CClient& operator=( const CInstance& ) = delete;
839  {
840  if (client) {
841  bigvoice_DeleteClient(client);
842  client=nullptr;
843  }
844  }
852  std::string ProcessJson(const std::string &request, bool *NeedSave = nullptr)
853  {
854  assert(client);
855  int need_save=0;
856  const char *canswer = bigvoice_ProcessJson(client, request.c_str(), &need_save);
857  if (!canswer) return {};
858  std::string answer(canswer);
859  bigvoice_FreeJsonAnswer (canswer);
860  if (NeedSave) {
861  *NeedSave=(need_save!=0);
862  }
863  return answer;
864  }
865  private:
866  bigvoice_CClientInstance *client = nullptr;
867  };
875  std::shared_ptr<CClient> NewClient()
876  {
877  assert(instance);
878  return std::make_shared<CClient>(instance);
879  }
880 
881  protected:
882  template<typename T>
883  unsigned int AddAudio(const T* payload, unsigned int nFrame)
884  {
885  assert(instance);
886  return bigvoice_AddAudio(instance, reinterpret_cast<const T*>(payload), nFrame, helper::SampleFormat<T>::format);
887  }
888  template<typename T>
889  unsigned int GetAudio(T* payload, unsigned int max_nFrame)
890  {
891  assert(instance);
892  return bigvoice_GetAudio(instance, reinterpret_cast<T*>(payload), max_nFrame, helper::SampleFormat<T>::format);
893  }
894 
895  private:
896  bigvoice_CParameters* params = nullptr;
897  bigvoice_CInstance* instance = nullptr;
898  std::thread update_thread;
899  std::vector< std::pair<std::string,std::string> > init_metadata;
900 #if BIGVOICE_HAS_WEBSERVER
901  uint64_t webserver = SOUND4_INVALID_WEBSERVER_ID;
902 #endif // BIGVOICE_HAS_WEBSERVER
903  };
904 
905 }; // namespace bigvoice
906 }; // namespace sound4
907 
908 // bridge C callbacks to CPresetLoader
909 extern "C" {
910  static char *bigvoice_custom_reader(const fs_char *filename, void* userdata) {
911  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
912  std::string content=preset_loader->Read(filename);
913  return strdup(content.c_str());
914  }
915  static void bigvoice_custom_reader_free(char *content, void* userdata) {
916  if (!content) return;
917  free(content);
918  }
919  static int bigvoice_custom_writer(const fs_char *filename, const char *content, void* userdata) {
920  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
921  auto res=preset_loader->Write(filename,content);
922  return res?0:-1;
923  }
924  static int bigvoice_custom_exists(const fs_char *filename, void* userdata) {
925  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
926  auto res=preset_loader->Exists(filename);
927  return res?0:-1;
928  }
929  static fs_char** bigvoice_custom_getall(void* userdata) {
930  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
931  auto res=preset_loader->GetAll();
932  fs_char**all=(fs_char**)malloc((res.size()+1)*sizeof(const fs_char*));
933  for (size_t n=0;n<res.size();n++) {
934  all[n]=fs_strdup(res[n].c_str());
935  }
936  all[res.size()]=nullptr;
937  return all;
938  }
939  static void bigvoice_custom_getall_free(fs_char** all, void* userdata) {
940  if (!all) return;
941  for (fs_char** one=all;*one;one++) {
942  free(*one);
943  }
944  free(all);
945  }
946  static int bigvoice_custom_remove(const fs_char *filename, void* userdata) {
947  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
948  auto res=preset_loader->Remove(filename);
949  return res?0:-1;
950  }
951  static int bigvoice_custom_rename(const fs_char *from, const fs_char *to, void* userdata) {
952  sound4::bigvoice::CPresetLoader *preset_loader=reinterpret_cast<sound4::bigvoice::CPresetLoader*>(userdata);
953  auto res=preset_loader->Rename(from,to);
954  return res?0:-1;
955  }
956 
957 };
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)
void GetWebServerAppHealth(int &httpcode, std::string &contenttype, std::string &content)
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)
void SetWebServerAppHealth(int httpcode, const std::string &contenttype, const std::string &content)
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)
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)
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_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)
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)
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
C interface for library.
#define fs_strdup
helper for OS dependant file name copy
sound4cl_LogSeverity
Definition: sound4cl_cdef.h:41
Helper for Sample format types.