| 1 | /* |
| 2 | * Copyright (C) 2015, Mike Walters <[email protected]> |
| 3 | * |
| 4 | * This file is part of inspectrum. |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <QMutex> |
| 23 | #include <complex> |
| 24 | #include <memory> |
| 25 | #include "samplesource.h" |
| 26 | |
| 27 | template <typename Tin, typename Tout> |
| 28 | class SampleBuffer : public SampleSource<Tout>, public Subscriber |
| 29 | { |
| 30 | private: |
| 31 | std::shared_ptr<SampleSource<Tin>> src; |
| 32 | QMutex mutex; |
| 33 | |
| 34 | public: |
| 35 | SampleBuffer(std::shared_ptr<SampleSource<Tin>> src); |
| 36 | ~SampleBuffer(); |
| 37 | void invalidateEvent(); |
| 38 | virtual std::unique_ptr<Tout[]> getSamples(size_t start, size_t length); |
| 39 | virtual void work(void *input, void *output, int count, size_t sampleid) = 0; |
| 40 | virtual size_t count() { |
| 41 | return src->count(); |
| 42 | }; |
| 43 | double rate() { |
| 44 | return src->rate(); |
| 45 | }; |
| 46 | |
| 47 | float relativeBandwidth() { |
| 48 | return src->relativeBandwidth(); |
| 49 | } |
| 50 | }; |