SOUND4 IMPACT FM.CL Library [2.0.3]
Loading...
Searching...
No Matches
Sample using C++ interface wrapper

C++ example (static link).

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

Setup and sanity checks

instance.SetParam("ADMIN_USER","admin");
instance.SetParam("ADMIN_SECRET","admin");

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;
}

Communicating with the instance

See also JSON syntax

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

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;
}

Sample processing loop

while (!stopthread)
{
// Read a chunk from stdin
if (std::fread(instance.GetBufferIn().data(), sizeof(float), sound4::impactfm::InputSampleSize, stdin) != sound4::impactfm::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::impactfm::OutputSampleSize, stdout) != sound4::impactfm::OutputSampleSize) {
std::cerr << "Failed to write audio output" << std::endl;
stopthread=true;
}
}