111 |
|
|
112 |
DiscSignal &DiscSignal::windowing( unsigned fst, unsigned snd ) const |
DiscSignal &DiscSignal::windowing( unsigned fst, unsigned snd ) const |
113 |
{ |
{ |
114 |
|
assert(fst > 0 && snd > 0 && snd > fst); |
|
assert(fst > 0 && snd > 0 && snd > fst); |
|
115 |
if (snd > this->length()) |
if (snd > this->length()) |
116 |
snd = length(); |
snd = length(); |
117 |
double *dres = (double *)malloc(sizeof(double) * (snd - fst)); |
double *dres = (double *)malloc(sizeof(double) * (snd - fst)); |
118 |
memcpy(dres, (this->get_data() + fst), snd - fst); |
memcpy(dres, (this->get_data() + fst), sizeof(double) * (snd - fst)); |
119 |
DiscSignal *res = new DiscSignal(dres, snd - fst); |
DiscSignal *res = new DiscSignal(dres, snd - fst); |
120 |
return *res; |
return *res; |
121 |
} |
} |
122 |
|
|
123 |
|
|
124 |
|
DiscSignal &DiscSignal::windowing_size( unsigned fst, unsigned size ) const |
125 |
|
{ |
126 |
|
if (fst < 0) |
127 |
|
fst = 0; |
128 |
|
if (size + fst >= length()) |
129 |
|
fst -= size + fst - length(); |
130 |
|
double *dres = (double *)malloc(sizeof(double) * size); |
131 |
|
memcpy(dres, (this->get_data() + fst), sizeof(double) * size); |
132 |
|
DiscSignal *res = new DiscSignal(dres, size); |
133 |
|
return *res; |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
DiscSignal &DiscSignal::hamming () const |
DiscSignal &DiscSignal::hamming () const |
138 |
{ |
{ |
139 |
int it; |
int it; |