Example code for starting a Hardt-based project
#include <iostream>
#include <signal.h>
#include "hardtapi.h"
#define SOUND_DEVICE 0
#define FREQUENCY 1000
#define AMPLITUDE 20000
#define BLOCKSIZE 1024
#define RATE H_SAMPLE_RATE_48K
#define FORMAT H_SAMPLE_FORMAT_INT_16
bool terminated = false;
static void signalIntTermHandler (int signal_value)
{
terminated = true;
}
void InstallSignalHandler() {
struct sigaction action;
action.sa_handler = [](int) { terminated = true; };
action.sa_flags = 0;
sigemptyset (&action.sa_mask);
sigaction (SIGINT, &action, NULL);
sigaction (SIGTERM, &action, NULL);
}
int main(int argc, char** argv) {
InstallSignalHandler();
HInit(std::string("readers_and_writers"), false);
std::cout << APPNAME << ": using Hardt " + getVersion() << std::endl;
try {
std::cout << "Running. Press CTRL+C to quit\n";
processor.Run();
}
std::cout <<
"HAudioIOException: " << ex->
what() <<
"\n";
}
std::cout << hex->
type() <<
": " << hex->
what() <<
"\n";
}
catch( ... ) {
std::cout << "Unknown exception type caught\n";
}
return 0;
}