Commit fa692f97 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Use common hamming window function code via wmcommon.hh.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 8941a7a3
......@@ -2,10 +2,8 @@ speed detection:
- double decode
- maybe truncate cleanup
- remove pad start scaling
- average speed if more than one best-quality 50s estimate is produced
- test code
- document in README
- analyze remaining variants
possible improvements:
- dynamic bit strength
......
......@@ -49,23 +49,6 @@ std::string Params::output_label;
using std::vector;
using std::complex;
inline double
window_cos (double x) /* von Hann window */
{
if (fabs (x) > 1)
return 0;
return 0.5 * cos (x * M_PI) + 0.5;
}
inline double
window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
{
if (fabs (x) > 1)
return 0;
return 0.54 + 0.46 * cos (M_PI * x);
}
/*
* glibc log2f is a lot faster than glibc log10
*/
......
......@@ -168,6 +168,23 @@ randomize_bit_order (const std::vector<T>& bit_vec, bool encode)
return out_bits;
}
inline double
window_cos (double x) /* von Hann window */
{
if (fabs (x) > 1)
return 0;
return 0.5 * cos (x * M_PI) + 0.5;
}
inline double
window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
{
if (fabs (x) > 1)
return 0;
return 0.54 + 0.46 * cos (M_PI * x);
}
int add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream, const std::string& bits, size_t zero_frames);
int add_watermark (const std::string& infile, const std::string& outfile, const std::string& bits);
int get_watermark (const std::string& infile, const std::string& orig_pattern);
......
......@@ -133,17 +133,6 @@ public:
}
};
/* FIXME: is this the best choice */
inline double
window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
{
if (fabs (x) > 1)
return 0;
return 0.54 + 0.46 * cos (M_PI * x);
}
void
SpeedSync::prepare_mags()
{
......@@ -161,6 +150,7 @@ SpeedSync::prepare_mags()
{
const double fsize_2 = sub_frame_size / 2.0;
// const double win = window_cos ((i - fsize_2) / fsize_2);
/* FIXME: is this the best choice */
const double win = window_hamming ((i - fsize_2) / fsize_2);
//const double win = 1;
window[i] = win;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment