Classes | Public Member Functions | Public Attributes

SpectMorph::Encoder Class Reference

Encoder producing SpectMorph parametric data from sample data. More...

#include <smencoder.hh>

List of all members.

Classes

struct  Attack

Public Member Functions

 Encoder (const EncoderParams &enc_params)
void compute_stft (GslDataHandle *dhandle, int channel, const std::vector< float > &window)
void search_local_maxima ()
void link_partials ()
void validate_partials ()
void optimize_partials (const std::vector< float > &window, int optimization_level)
void spectral_subtract (const std::vector< float > &window)
void approx_noise (const std::vector< float > &window)
void compute_attack_params (const std::vector< float > &window)
void sort_freqs ()
void encode (GslDataHandle *dhandle, int channel, const std::vector< float > &window, int optimization_level, bool attack, bool track_sines)
void set_time_loop (int loop_start, int loop_end)
void save (const std::string &filename, double fundamental_freq)

Public Attributes

std::vector< AudioBlockaudio_blocks
 current state, and end result of the encoding algorithm
Attack optimal_attack
size_t zero_values_at_start
size_t sample_count
std::vector< float > original_samples

Detailed Description

Encoder producing SpectMorph parametric data from sample data.

The encoder needs to perform a number of analysis steps to get from the input signal to a parametric representation (which is built in audio_blocks). At the moment, this process needs to be controlled by the caller, but a simpler interface should be added.


Constructor & Destructor Documentation

Encoder::Encoder ( const EncoderParams enc_params  ) 

Constructor which initializes the Encoders parameters.


Member Function Documentation

void Encoder::approx_noise ( const std::vector< float > &  window  ) 

This function tries to approximate the residual by a spectral envelope for a noise signal.

DEBUG CODE {

} DEBUG_CODE

void Encoder::compute_attack_params ( const std::vector< float > &  window  ) 

This function computes the optimal attack parameters, by finding the optimal attack envelope (attack_start_ms and attack_end_ms) given the data.

void Encoder::compute_stft ( GslDataHandle *  multi_channel_dhandle,
int  channel,
const std::vector< float > &  window 
)

This function computes the short-time-fourier-transform (STFT) of the input signal using a window to cut the individual frames out of the sample.

void Encoder::encode ( GslDataHandle *  dhandle,
int  channel,
const std::vector< float > &  window,
int  optimization_level,
bool  attack,
bool  track_sines 
)

This function calls all steps necessary for encoding in the right order.

Parameters:
dhandle a data handle containing the signal to be encoded
window the analysis window
optimization_level determines if fast (0), medium (1), or very slow (2) algorithm is used
attack whether to find the optimal attack parameters
void Encoder::link_partials (  ) 

This function links the spectral peaks (contained in the Tracksel structure) of successive frames together by setting the prev and next pointers. It tries to minimize the frequency difference between the peaks that are linked together, while using a threshold of 5% frequency derivation.

void Encoder::optimize_partials ( const std::vector< float > &  window,
int  optimization_level 
)

This function reestimates the magnitudes and phases of the partials found in the previous steps.

void Encoder::save ( const std::string &  filename,
double  fundamental_freq 
)

This function saves the data produced by the encoder to a SpectMorph file.

void Encoder::search_local_maxima (  ) 

This function searches for peaks in the frame ffts. These are stored in frame_tracksels.

void Encoder::spectral_subtract ( const std::vector< float > &  window  ) 

This function subtracts the partials from the audio signal, to get the residue (remaining energy not corresponding to sine frequencies).

void Encoder::validate_partials (  ) 

This function validates that the partials found by the peak linking have good quality.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator