mayong
2023-03-03 b2a35c75b3f405aab91bd74f59b52fc206a3fedf
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
#include "precomp.h"
 
SpeechWrap::SpeechWrap()
{
    cache_size = 0;
}
 
SpeechWrap::~SpeechWrap()
{
}
 
void SpeechWrap::reset()
{
    cache_size = 0;
}
 
void SpeechWrap::load(float *din, int len)
{
    in = din;
    in_size = len;
    total_size = cache_size + in_size;
}
 
int SpeechWrap::size()
{
    return total_size;
}
 
void SpeechWrap::update(int offset)
{
    int in_offset = offset - cache_size;
    cache_size = (total_size - offset);
    memcpy(cache, in + in_offset, cache_size * sizeof(float));
}
 
float &SpeechWrap::operator[](int i)
{
    return i < cache_size ? cache[i] : in[i - cache_size];
}