blob: 898bf911f40e608caa5e1591aab1e154ff5c4f59 [file] [log] [blame]
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01001//
George Gekov23c26272021-08-16 11:32:10 +01002// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <string>
9#include <iostream>
George Gekov23c26272021-08-16 11:32:10 +010010#include <cmath>
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010011#include <vector>
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010012#include <exception>
13
14#include "SlidingWindow.hpp"
15
George Gekov23c26272021-08-16 11:32:10 +010016namespace audio
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010017{
18
19/**
20* @brief Class used to capture the audio data loaded from file, and to provide a method of
21 * extracting correctly positioned and appropriately sized audio windows
22*
23*/
24 class AudioCapture
25 {
26 public:
27
28 SlidingWindow<const float> m_window;
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010029
30 /**
31 * @brief Default constructor
32 */
George Gekov23c26272021-08-16 11:32:10 +010033 AudioCapture() = default;
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010034
35 /**
36 * @brief Function to load the audio data captured from the
37 * input file to memory.
38 */
George Gekov23c26272021-08-16 11:32:10 +010039 static std::vector<float> LoadAudioFile(std::string filePath);
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010040
41 /**
42 * @brief Function to initialize the sliding window. This will set its position in memory, its
43 * window size and its stride.
44 */
45 void InitSlidingWindow(float* data, size_t dataSize, int minSamples, size_t stride);
46
47 /**
48 * Checks whether there is another block of audio in memory to read
49 */
50 bool HasNext();
51
52 /**
53 * Retrieves the next block of audio if its available
54 */
55 std::vector<float> Next();
56 };
George Gekov23c26272021-08-16 11:32:10 +010057} // namespace audio