00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SPECTMORPH_LIVEDECODER_HH
00020 #define SPECTMORPH_LIVEDECODER_HH
00021
00022 #include "smwavset.hh"
00023 #include "smsinedecoder.hh"
00024 #include "smnoisedecoder.hh"
00025 #include "smlivedecodersource.hh"
00026 #include "smpolyphaseinter.hh"
00027 #include <birnet/birnet.hh>
00028 #include <vector>
00029
00030 namespace SpectMorph {
00031
00032 class LiveDecoder
00033 {
00034 struct PartialState
00035 {
00036 float freq;
00037 float phase;
00038 };
00039 std::vector<PartialState> pstate[2], *last_pstate;
00040
00041 WavSet *smset;
00042 Audio *audio;
00043
00044 IFFTSynth *ifft_synth;
00045 NoiseDecoder *noise_decoder;
00046 LiveDecoderSource *source;
00047 PolyPhaseInter *pp_inter;
00048
00049 bool sines_enabled;
00050 bool noise_enabled;
00051 bool debug_fft_perf_enabled;
00052 bool original_samples_enabled;
00053
00054 size_t frame_size, frame_step;
00055 size_t zero_values_at_start_scaled;
00056 size_t loop_start_scaled;
00057 size_t loop_end_scaled;
00058 int loop_point;
00059 float current_freq;
00060 float current_mix_freq;
00061
00062 size_t have_samples;
00063 size_t block_size;
00064 size_t pos;
00065 size_t env_pos;
00066 size_t frame_idx;
00067 float original_sample_pos;
00068
00069 Birnet::AlignedArray<float,16> *sse_samples;
00070 public:
00071 LiveDecoder (WavSet *smset);
00072 LiveDecoder (LiveDecoderSource *source);
00073 ~LiveDecoder();
00074
00075 void enable_noise (bool ne);
00076 void enable_sines (bool se);
00077 void enable_debug_fft_perf (bool dfp);
00078 void enable_original_samples (bool eos);
00079
00080 void precompute_tables (float mix_freq);
00081 void retrigger (int channel, float freq, int midi_velocity, float mix_freq);
00082 void process (size_t n_values,
00083 const float *freq_in,
00084 const float *freq_mod_in,
00085 float *audio_out);
00086
00087
00088 };
00089
00090 }
00091 #endif