forked from markondej/fm_transmitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
31 lines (28 loc) · 822 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdlib.h>
#include <iostream>
#include <unistd.h>
#include "wave_reader.h"
#include "transmitter.h"
using namespace std;
int main(int argc, char **argv)
{
if (argc < 2) {
cout << "Usage: " << argv[0] << " [FILE] [frequency]" << endl;
return 0;
}
string filename = argv[1];
double frequency = (argc < 3) ? 100.0 : (::atof(argv[2]));
try {
WaveReader *reader = new WaveReader(filename);
Transmitter *transmitter = new Transmitter(frequency);
PCMWaveHeader *header = reader->getHeader();
std::vector<float> *samples = reader->getSamples();
transmitter->transmit(samples, header->sampleRate);
delete transmitter;
delete samples;
delete reader;
} catch (exception &e) {
return 1;
}
return 0;
}