diff --git a/CMakeLists.txt b/CMakeLists.txt index cdbd1cc..7af5693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ list(APPEND inspectrum_sources fft.cpp mainwindow.cpp inputsource.cpp + samplebuffer.cpp spectrogram.cpp spectrogramcontrols.cpp waveformview.cpp diff --git a/samplebuffer.cpp b/samplebuffer.cpp new file mode 100644 index 0000000..29607b3 --- /dev/null +++ b/samplebuffer.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2015, Mike Walters + * + * This file is part of inspectrum. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "samplebuffer.h" + +bool SampleBuffer::getSamples(std::complex *dest, off_t start, off_t length) +{ + std::complex buf[length]; + src->getSamples(buf, start, length); + work(buf, dest, length); + return true; +} \ No newline at end of file diff --git a/samplebuffer.h b/samplebuffer.h new file mode 100644 index 0000000..f2bc9cd --- /dev/null +++ b/samplebuffer.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015, Mike Walters + * + * This file is part of inspectrum. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include +#include "samplesource.h" + +class SampleBuffer : public SampleSource +{ +private: + std::shared_ptr src; + +public: + SampleBuffer(SampleSource *src) : src(src) {}; + virtual bool getSamples(std::complex *dest, off_t start, off_t length); + virtual void work(void *input, void *output, int count) = 0; + virtual off_t count() { return src->count(); }; +};