00001 #ifndef TIMESTRETCH_H
00002 #define TIMESTRETCH_H
00003
00004 #include "bchash.inc"
00005 #include "fourier.h"
00006 #include "guicast.h"
00007 #include "mainprogress.inc"
00008 #include "pluginaclient.h"
00009 #include "resample.inc"
00010 #include "timestretchengine.inc"
00011 #include "vframe.inc"
00012
00013
00014
00015
00016 class TimeStretch;
00017 class TimeStretchWindow;
00018 class TimeStretchConfig;
00019
00020
00021
00022 class TimeStretchScale : public BC_FPot
00023 {
00024 public:
00025 TimeStretchScale(TimeStretch *plugin, int x, int y);
00026 int handle_event();
00027 TimeStretch *plugin;
00028 };
00029
00030 class TimeStretchWindow : public BC_Window
00031 {
00032 public:
00033 TimeStretchWindow(TimeStretch *plugin, int x, int y);
00034 void create_objects();
00035 void update();
00036 int close_event();
00037 TimeStretchScale *scale;
00038 TimeStretch *plugin;
00039 };
00040
00041 PLUGIN_THREAD_HEADER(TimeStretch, TimeStretchThread, TimeStretchWindow)
00042
00043
00044 class TimeStretchConfig
00045 {
00046 public:
00047 TimeStretchConfig();
00048
00049
00050 int equivalent(TimeStretchConfig &that);
00051 void copy_from(TimeStretchConfig &that);
00052 void interpolate(TimeStretchConfig &prev,
00053 TimeStretchConfig &next,
00054 int64_t prev_frame,
00055 int64_t next_frame,
00056 int64_t current_frame);
00057
00058
00059 double scale;
00060 };
00061
00062
00063 class PitchEngine : public CrossfadeFFT
00064 {
00065 public:
00066 PitchEngine(TimeStretch *plugin);
00067 ~PitchEngine();
00068
00069
00070 int read_samples(int64_t output_sample,
00071 int samples,
00072 double *buffer);
00073 int signal_process_oversample(int reset);
00074
00075 TimeStretch *plugin;
00076 double *temp;
00077 double *input_buffer;
00078 int input_size;
00079 int input_allocated;
00080 int64_t current_input_sample;
00081 int64_t current_output_sample;
00082
00083 double *last_phase;
00084 double *new_freq;
00085 double *new_magn;
00086 double *sum_phase;
00087 double *anal_freq;
00088 double *anal_magn;
00089
00090
00091 };
00092
00093 class TimeStretch : public PluginAClient
00094 {
00095 public:
00096 TimeStretch(PluginServer *server);
00097 ~TimeStretch();
00098
00099
00100 VFrame* new_picon();
00101 char* plugin_title();
00102 int is_realtime();
00103 int get_parameters();
00104 void read_data(KeyFrame *keyframe);
00105 void save_data(KeyFrame *keyframe);
00106
00107 int process_buffer(int64_t size,
00108 double *buffer,
00109 int64_t start_position,
00110 int sample_rate);
00111
00112
00113 int show_gui();
00114 void raise_window();
00115 int set_string();
00116
00117
00118 int load_configuration();
00119 int load_defaults();
00120 int save_defaults();
00121
00122 void update_gui();
00123
00124
00125
00126 PitchEngine *pitch;
00127 Resample *resample;
00128 double *temp;
00129 int temp_allocated;
00130 double *input;
00131 int input_allocated;
00132
00133 TimeStretchEngine *stretch;
00134
00135 BC_Hash *defaults;
00136 TimeStretchConfig config;
00137 TimeStretchThread *thread;
00138
00139 };
00140
00141
00142 #endif