blob: 90c2eccacf5efdcd5bd68c7b9e8509d6dca9793e [file] [log] [blame]
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01001//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <string>
9#include <iostream>
10
11#include <math.h>
12
13#include <vector>
14
15#include <exception>
16
17#include "SlidingWindow.hpp"
18
19namespace asr
20{
21
22/**
23* @brief Class used to capture the audio data loaded from file, and to provide a method of
24 * extracting correctly positioned and appropriately sized audio windows
25*
26*/
27 class AudioCapture
28 {
29 public:
30
31 SlidingWindow<const float> m_window;
32 int lastReadIdx= 0;
33
34 /**
35 * @brief Default constructor
36 */
37 AudioCapture()
38 {};
39
40 /**
41 * @brief Function to load the audio data captured from the
42 * input file to memory.
43 */
44 std::vector<float> LoadAudioFile(std::string filePath);
45
46 /**
47 * @brief Function to initialize the sliding window. This will set its position in memory, its
48 * window size and its stride.
49 */
50 void InitSlidingWindow(float* data, size_t dataSize, int minSamples, size_t stride);
51
52 /**
53 * Checks whether there is another block of audio in memory to read
54 */
55 bool HasNext();
56
57 /**
58 * Retrieves the next block of audio if its available
59 */
60 std::vector<float> Next();
61 };
62} // namespace asr