C example.
See full example cpp/sound4.impactfm.cl-pipe.cpp
Sample to create the processing instance
see Process creation/destruction and Update Management
if (!pInstance) {
std::cerr << "Failed to create the process instance"<< std::endl;
return 1;
}
std::thread updater([pInstance](){
std::cerr << "impactfm_StartUpdateThread (no json port)" << std::endl;
std::cerr << "impactfm_StartUpdateThread END" << std::endl;
});
std::cerr << "Waiting update thread" << std::endl;
std::cerr << "Timeout to create the process instance"<< std::endl;
}
std::cerr << "Waiting update thread DONE" << std::endl;
#if (IMPACTFM_HAS_WEBSERVER)
std::cerr << "Starting web server" << std::endl;
int listenport= 8080;
int listenport_secure= 8443;
if (listenport || listenport_secure) {
std::cerr << "Starting web server FAILED" << std::endl;
} else {
if (listenport) {
std::cerr << "Web server listening on port " << listenport;
} else {
std::cerr << "Web server failed to listen on port " << listenport;
}
}
if (listenport_secure) {
std::cerr << "Web server listening on secure port " << listenport_secure;
} else {
std::cerr << "Web server failed to listen on secure port " << listenport_secure;
}
}
std::cerr << "Starting web server DONE" << std::endl;
}
}
#endif
Sample processing loop
see Direct processing
bool stopthread=false;
#if defined(_WIN32) || defined(WIN32)
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
while (!stopthread)
{
std::cerr << "ProcessLoop: input stopped"<< std::endl;
stopthread=true;
break;
}
if (stopthread) break;
std::cerr << "Failed to write audio output" << std::endl;
stopthread=true;
}
}
Sample to stop the processing instance
see Process creation/destruction
#if (IMPACTFM_HAS_WEBSERVER)
std::cerr << "Stopping web server" << std::endl;
std::cerr << "Stopping web server DONE" << std::endl;
#endif
std::cerr << "Stopping Update thread" << std::endl;
std::cerr << "Stopping Update thread DONE" << std::endl;
updater.join();