SpectMorph

lib/smnoisedecoder.hh

00001 /* 
00002  * Copyright (C) 2009-2010 Stefan Westerfeld
00003  *
00004  * This library is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published by the
00006  * Free Software Foundation; either version 3 of the License, or (at your
00007  * option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
00012  * for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #ifndef SPECTMORPH_NOISE_DECODER_HH
00020 #define SPECTMORPH_NOISE_DECODER_HH
00021 
00022 #include "smrandom.hh"
00023 #include "smnoisebandpartition.hh"
00024 #include "smaudio.hh"
00025 
00026 namespace SpectMorph
00027 {
00028 
00032 class NoiseDecoder
00033 {
00034   double orig_mix_freq;
00035   double mix_freq;
00036   size_t block_size;
00037 
00038   float *cos_window;
00039 
00040   Random random_gen;
00041   NoiseBandPartition *noise_band_partition;
00042 
00043   void apply_window (float *spectrum, float *fft_buffer);
00044 
00045 public:
00046   NoiseDecoder (double orig_mix_freq,
00047                 double mix_freq,
00048                 size_t block_size);
00049   ~NoiseDecoder();
00050 
00051   enum OutputMode { REPLACE, ADD, FFT_SPECTRUM, DEBUG_UNWINDOWED, DEBUG_NO_OUTPUT };
00052 
00053   void set_seed (int seed);
00054   void process (const AudioBlock& audio_block,
00055                 float *samples,
00056                 OutputMode output_mode = REPLACE);
00057 
00058   static size_t preferred_block_size (double mix_freq);
00059 };
00060 
00061 }
00062 
00063 #endif
 All Classes Functions Variables Enumerations Enumerator