diff options
author | George Gekov <george.gekov@arm.com> | 2021-08-16 11:32:10 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2022-02-05 19:49:06 +0000 |
commit | 23c26277086c78704a17f0dae86da947816320c0 (patch) | |
tree | 88b02fd1fae3130256d059251788a7ef68d2831f /samples/common/include/Audio/AudioCapture.hpp | |
parent | 922b912fd2d462bac0809bac5669310ad1506310 (diff) | |
download | armnn-23c26277086c78704a17f0dae86da947816320c0.tar.gz |
MLECO-2079 Adding the C++ KWS example
Signed-off-by: Eanna O Cathain <eanna.ocathain@arm.com>
Change-Id: I81899bbfaada32f478c2e2fc6441eabb94d8d0fc
Diffstat (limited to 'samples/common/include/Audio/AudioCapture.hpp')
-rw-r--r-- | samples/common/include/Audio/AudioCapture.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/samples/common/include/Audio/AudioCapture.hpp b/samples/common/include/Audio/AudioCapture.hpp new file mode 100644 index 0000000000..898bf911f4 --- /dev/null +++ b/samples/common/include/Audio/AudioCapture.hpp @@ -0,0 +1,57 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <string> +#include <iostream> +#include <cmath> +#include <vector> +#include <exception> + +#include "SlidingWindow.hpp" + +namespace audio +{ + +/** +* @brief Class used to capture the audio data loaded from file, and to provide a method of + * extracting correctly positioned and appropriately sized audio windows +* +*/ + class AudioCapture + { + public: + + SlidingWindow<const float> m_window; + + /** + * @brief Default constructor + */ + AudioCapture() = default; + + /** + * @brief Function to load the audio data captured from the + * input file to memory. + */ + static std::vector<float> LoadAudioFile(std::string filePath); + + /** + * @brief Function to initialize the sliding window. This will set its position in memory, its + * window size and its stride. + */ + void InitSlidingWindow(float* data, size_t dataSize, int minSamples, size_t stride); + + /** + * Checks whether there is another block of audio in memory to read + */ + bool HasNext(); + + /** + * Retrieves the next block of audio if its available + */ + std::vector<float> Next(); + }; +} // namespace audio
\ No newline at end of file |