summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DabModulator.cpp15
-rw-r--r--src/DabModulator.h4
-rw-r--r--src/FIRFilter.cpp17
-rw-r--r--src/FIRFilter.h6
4 files changed, 20 insertions, 22 deletions
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index dbd3528..ebfcd63 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -61,7 +61,7 @@ DabModulator::DabModulator(
unsigned outputRate, unsigned clockRate,
unsigned dabMode, GainMode gainMode,
float& digGain, float normalise,
- std::string filterTapsFilename
+ std::string& filterTapsFilename
) :
ModCodec(ModFormat(1), ModFormat(0)),
myOutputRate(outputRate),
@@ -219,9 +219,9 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
new GuardIntervalInserter(myNbSymbols, mySpacing,
myNullSize, mySymSize));
- FIRFilter* cifFilter = NULL;
+ shared_ptr<FIRFilter> cifFilter;
if (myFilterTapsFilename != "") {
- cifFilter = new FIRFilter(myFilterTapsFilename);
+ cifFilter = make_shared<FIRFilter>(myFilterTapsFilename);
cifFilter->enrol_at(*myRCs);
}
shared_ptr<OutputMemory> myOutput(new OutputMemory(dataOut));
@@ -362,15 +362,14 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
myFlowgraph->connect(cifOfdm, cifGain);
myFlowgraph->connect(cifGain, cifGuard);
- if (myFilterTapsFilename != "") {
- shared_ptr<FIRFilter> cifFilterptr(cifFilter);
- myFlowgraph->connect(cifGuard, cifFilterptr);
+ if (cifFilter) {
+ myFlowgraph->connect(cifGuard, cifFilter);
if (cifRes != NULL) {
shared_ptr<Resampler> res(cifRes);
- myFlowgraph->connect(cifFilterptr, res);
+ myFlowgraph->connect(cifFilter, res);
myFlowgraph->connect(res, myOutput);
} else {
- myFlowgraph->connect(cifFilterptr, myOutput);
+ myFlowgraph->connect(cifFilter, myOutput);
}
}
else { //no filtering
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 2552f50..517234c 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.h
@@ -56,7 +56,7 @@ public:
unsigned outputRate, unsigned clockRate,
unsigned dabMode, GainMode gainMode,
float& digGain, float normalise,
- std::string filterTapsFilename);
+ std::string& filterTapsFilename);
DabModulator(const DabModulator& other) = delete;
DabModulator& operator=(const DabModulator& other) = delete;
virtual ~DabModulator();
@@ -79,7 +79,7 @@ protected:
EtiReader myEtiReader;
Flowgraph* myFlowgraph;
OutputMemory* myOutput;
- std::string myFilterTapsFilename;
+ std::string& myFilterTapsFilename;
tii_config_t myTiiConfig;
RemoteControllers* myRCs;
diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp
index 9ef49c5..16ddcf5 100644
--- a/src/FIRFilter.cpp
+++ b/src/FIRFilter.cpp
@@ -298,7 +298,7 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd)
}
-FIRFilter::FIRFilter(std::string taps_file) :
+FIRFilter::FIRFilter(std::string& taps_file) :
ModCodec(ModFormat(sizeof(complexf)), ModFormat(sizeof(complexf))),
RemoteControllable("firfilter"),
myTapsFile(taps_file)
@@ -313,7 +313,7 @@ FIRFilter::FIRFilter(std::string taps_file) :
firwd.taps = new float[0];
- load_filter_taps();
+ load_filter_taps(myTapsFile);
#if __AVX__
fprintf(stderr, "FIRFilter: WARNING: using experimental AVX code !\n");
@@ -323,12 +323,11 @@ FIRFilter::FIRFilter(std::string taps_file) :
worker.start(&firwd);
}
-void
-FIRFilter::load_filter_taps()
+void FIRFilter::load_filter_taps(std::string tapsFile)
{
- std::ifstream taps_fstream(myTapsFile.c_str());
+ std::ifstream taps_fstream(tapsFile.c_str());
if(!taps_fstream) {
- fprintf(stderr, "FIRFilter: file %s could not be opened !\n", myTapsFile.c_str());
+ fprintf(stderr, "FIRFilter: file %s could not be opened !\n", tapsFile.c_str());
throw std::runtime_error("FIRFilter: Could not open file with taps! ");
}
int n_taps;
@@ -355,7 +354,7 @@ FIRFilter::load_filter_taps()
PDEBUG("FIRFilter: tap: %f\n", myFilter[n] );
if (taps_fstream.eof()) {
fprintf(stderr, "FIRFilter: file %s should contains %d taps, but EOF reached "\
- "after %d taps !\n", myTapsFile.c_str(), n_taps, n);
+ "after %d taps !\n", tapsFile.c_str(), n_taps, n);
delete[] myFilter;
throw std::runtime_error("FIRFilter: filtertaps file invalid ! ");
}
@@ -422,9 +421,9 @@ void FIRFilter::set_parameter(const string& parameter, const string& value)
throw ParameterError("Parameter 'ntaps' is read-only");
}
else if (parameter == "tapsfile") {
- myTapsFile = value;
try {
- load_filter_taps();
+ load_filter_taps(value);
+ myTapsFile = value;
}
catch (std::runtime_error &e) {
throw ParameterError(e.what());
diff --git a/src/FIRFilter.h b/src/FIRFilter.h
index 28b2f4a..af6cc5e 100644
--- a/src/FIRFilter.h
+++ b/src/FIRFilter.h
@@ -99,7 +99,7 @@ class FIRFilterWorker {
class FIRFilter : public ModCodec, public RemoteControllable
{
public:
- FIRFilter(std::string taps_file);
+ FIRFilter(std::string& taps_file);
virtual ~FIRFilter();
FIRFilter(const FIRFilter&);
FIRFilter& operator=(const FIRFilter&);
@@ -116,9 +116,9 @@ public:
protected:
- void load_filter_taps();
+ void load_filter_taps(std::string tapsFile);
- std::string myTapsFile;
+ std::string& myTapsFile;
int myNtaps;
float* myFilter;