aes67-daemon/test/createtest.cc
Andrea Bondavalli 0dd3b9bf70 Set of changes to the daemon to support additional sample rates and to enhance the test suites to verify with 192Khz and 384Khz
The build script has been modified to checkout the driver branch aes67-daemon-issue11 with fixes to support sample rates higher than 192Khz.
These changes fix #124 and #122
2023-04-19 12:49:47 +02:00

71 lines
1.5 KiB
C++

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
if (argc < 5) {
cerr << "Usage " << argv[0] << " sample_format sample_rate channels duration" << endl;
exit(1);
}
int len(0);
string format(argv[1]);
if (format == "S16_LE")
len = 2;
else if (format == "S24_3LE")
len = 3;
else if (format == "S32_LE")
len = 4;
else {
cerr << "Unsupported format " << format << endl;
exit(1);
}
int rate(atoi(argv[2]));
if (rate != 44100 && rate != 48000 && rate != 96000 && rate != 192000 && rate != 384000) {
cerr << "Unsupported rate " << rate << endl;
exit(1);
}
int channels = atoi(argv[3]);
if (channels % 2 != 0 || channels <= 0 || channels > 64) {
cerr << "Unsupported channels " << channels << endl;
exit(1);
}
int duration = atoi(argv[4]);
if (duration > 10 || duration < 1) {
cerr << "Unsupported duration " << duration << " minutes" << endl;
exit(1);
}
int secs(duration * 60);
unsigned char byte(0);
fstream myfile;
myfile.open("test.raw", ios::out|ios::binary);
while(secs--) {
int samples(rate);
while (samples--) {
int ch(channels);
while (ch--) {
myfile.put(byte);
if (len > 1) {
myfile.put(byte+1);
if (len > 2) {
myfile.put(byte+2);
if (len > 3)
myfile.put(byte+3);
}
}
}
byte+=len;
}
}
myfile.close();
return 0;
}