blob: 90c2eccacf5efdcd5bd68c7b9e8509d6dca9793e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
#include <exception>
#include "SlidingWindow.hpp"
namespace asr
{
/**
* @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;
int lastReadIdx= 0;
/**
* @brief Default constructor
*/
AudioCapture()
{};
/**
* @brief Function to load the audio data captured from the
* input file to memory.
*/
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 asr
|