SOUND4 BIGVOICE.CL Library [1.1.6]
Loading...
Searching...
No Matches
Sample using C++ interface wrapper

C++ example (static link)

See full example cpp/sound4.bigvoice.cl-pipe-cxx.cpp

Setup and sanity checks

instance.SetParam("ADMIN_USER","admin");
instance.SetParam("ADMIN_SECRET","admin");
void SetParam(const std::string &name, const std::string &value)
@ verbose5
verbose5
static void SetLogSeverity(LogSeverity severity)
static void SetLoggerCallback(log_cb_t cb)
void MyLogger(sound4::bigvoice::LogSeverity severity, const std::string &msg)

Sample to create the processing instance

if (!instance.Create(LoginKey, RadioName, KeyId, AccessKey, store_path)) {
std::cerr << "Failed to create the processing instance" << std::endl;
return 1;
}
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)

Communicating with the instance

See also
jsonsyntax
auto client = instance.NewClient();
auto answer = client->ProcessJson(R"JSON({"get":{"processorname":null}})JSON");
std::cerr << "Request for processor name returned "<<answer<<std::endl;
std::shared_ptr< CClient > NewClient()

Starting a web-server

if (!instance.StartWebServer(listen_port,0)) {
std::cerr << "Failed to create the web server on port " << listen_port << std::endl;
return 1;
}
bool StartWebServer(int http_port, int https_port=0)

Sample processing loop

while (!stopthread)
{
// Read a chunk from stdin
if (std::fread(instance.GetBufferIn().data(), sizeof(float), sound4::bigvoice::InputSampleSize, stdin) != sound4::bigvoice::InputSampleSize) {
std::cerr << "ProcessLoop: input stopped"<< std::endl;
stopthread=true;
break;
}
if (stopthread) break;
// Process it
instance.ProcessAudio();
// Write it to stdout
if (fwrite(instance.GetBufferOut().data(), sizeof(float), sound4::bigvoice::OutputSampleSize, stdout) != sound4::bigvoice::OutputSampleSize) {
std::cerr << "Failed to write audio output" << std::endl;
stopthread=true;
}
}
std::array< float, OutputSampleSize > & GetBufferOut()
std::array< float, InputSampleSize > & GetBufferIn()
const size_t OutputSampleSize
const size_t InputSampleSize