Line data Source code
1 : /** 2 : * \file InPointerFilter.h 3 : */ 4 : 5 : #ifndef ATK_CORE_INPOINTERFILTER_H 6 : #define ATK_CORE_INPOINTERFILTER_H 7 : 8 : #include <ATK/Core/TypedBaseFilter.h> 9 : 10 : namespace ATK 11 : { 12 : /// Filter allowing to input data from an array 13 : template<typename DataType_> 14 : class ATK_CORE_EXPORT InPointerFilter final : public TypedBaseFilter<DataType_> 15 : { 16 : protected: 17 : /// Simplify parent calls 18 : using Parent = TypedBaseFilter<DataType_>; 19 : using typename Parent::DataType; 20 : using Parent::outputs; 21 : using Parent::output_sampling_rate; 22 : 23 : public: 24 : using Parent::set_output_sampling_rate; 25 : using Parent::set_nb_output_ports; 26 : 27 : /** 28 : * @brief Create a filter for the beginning of a pipeline 29 : * @param array is the pointer to the data that will be reused during all the processing 30 : * @param size in the size of the data for one channel 31 : * @param channels is the number of total channels 32 : * @param interleaved indicates if the data is interleaved (Wav/Fortran order) or not (C order). If interleaved, size and channels switch position. 33 : */ 34 : InPointerFilter(const DataType* array, int channels, gsl::index size, bool interleaved); 35 : /// Destructor 36 189 : ~InPointerFilter() override = default; 37 1 : InPointerFilter(InPointerFilter&&) = default; 38 : InPointerFilter& operator=(InPointerFilter&&) = default; 39 : 40 : /** 41 : * @brief Resets the pointer and the internal offset 42 : * @param array is the pointer to the new array 43 : * @param size is the allocated size of the array (whether interleaved or not) 44 : */ 45 : void set_pointer(const DataType* array, gsl::index size); 46 : 47 : protected: 48 : /// This implementation retrieves inputs from other filters and converts it accordingly 49 : void process_impl(gsl::index size) const final; 50 : /// Current offset in the array 51 : mutable gsl::index offset{0}; 52 : /// Input array 53 : const DataType* array = nullptr; 54 : /// Size of the input array 55 : gsl::index mysize{0}; 56 : /// Number of channels/ports in the array 57 : unsigned int channels{0}; 58 : /// Is the output array interleaved? 59 : bool interleaved = false; 60 : }; 61 : } 62 : 63 : #endif