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