Debian Codegraph @

src/inputsource.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2015, Mike Walters <[email protected]>
3 * Copyright (C) 2015, Jared Boone <[email protected]>
4 *
5 * This file is part of inspectrum.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <complex>
24 #include <QFile>
25 #include "samplesource.h"
26
27 class SampleAdapter {
28 public:
29 virtual size_t sampleSize() = 0;
30 virtual void copyRange(const void* const src, size_t start, size_t length, std::complex<float>* const dest) = 0;
31 virtual ~SampleAdapter() { };
32 };
33
34 class InputSource : public SampleSource<std::complex<float>>
35 {
36 private:
37 QFile *inputFile = nullptr;
38 size_t sampleCount = 0;
39 double sampleRate = 0.0;
40 uchar *mmapData = nullptr;
41 std::unique_ptr<SampleAdapter> sampleAdapter;
42 std::string _fmt;
43 bool _realSignal = false;
44
45 QJsonObject readMetaData(const QString &filename);
46
47 public:
48 InputSource();
49 ~InputSource();
50 void cleanup();
51 void openFile(const char *filename);
52 std::unique_ptr<std::complex<float>[]> getSamples(size_t start, size_t length);
53 size_t count() {
54 return sampleCount;
55 };
56 void setSampleRate(double rate);
57 void setFormat(std::string fmt);
58 double rate();
59 bool realSignal() {
60 return _realSignal;
61 };
62 float relativeBandwidth() {
63 return 1;
64 }
65 };