2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999, 2000 Alexander König
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 Description: Header to tX_vtt.cc
23 08 Dec 1999 - added audiofile support
39 #include "tX_vttgui.h"
43 #include "tX_audiofile.h"
44 #include "tX_seqpar.h"
46 #include "tX_ladspa.h"
52 #define EC_MAX_BUFFER 256000
54 #define CONTROL_NOTHING 0
55 #define CONTROL_SCRATCH 1
56 #define CONTROL_VOLUME 2
57 #define CONTROL_CUTOFF 3
58 #define CONTROL_FEEDBACK 4
60 #define NEED_FADE_OUT 0
61 #define NEED_FADE_IN 1
63 #define SAMPLE_MAX 32760.0
64 #define SAMPLE_BORDER 30000.0
71 static int vtt_amount;
72 static list <vtt_class *> main_list;
73 static list <vtt_class *> render_list;
75 static f_prec *mix_buffer;
76 static f_prec *mix_buffer_end;
78 static int16_t *mix_out_buffer;
79 static f_prec mix_max;
80 static int samples_in_mix_buffer;
81 static pthread_mutex_t render_lock;
82 static pthread_mutex_t main_lock;
84 static f_prec master_volume;
85 static f_prec res_master_volume;
86 static f_prec vol_channel_adjust;
88 static f_prec saturate_fac;
89 static int do_saturate;
91 static vtt_class * sync_master;
92 static int master_triggered;
93 static int master_triggered_at;
94 static vtt_class * focused_vtt;
100 /* main object vars */
101 char name[256]; // Turntable's name
102 char filename[PATH_MAX]; // The corresponding audiofile
120 int16_t *buffer; // Actual audio data
121 int samples_in_buffer; // No. of samples in audio data
124 f_prec *output_buffer;
125 f_prec *end_of_outputbuffer;
126 f_prec samples_in_outputbuffer;
127 f_prec inv_samples_in_outputbuffer;
129 /* main playback vars */
130 f_prec rel_volume; // The (user-selected) relative volume
131 f_prec res_volume; // The resulting volume
135 f_prec rel_pitch; // The (user-selected) relative pitch
158 /* input control vars */
162 /* seq par mapping for x/y axis */
181 f_prec ec_buffer[EC_MAX_BUFFER];
186 f_prec ec_res_length;
189 /* sequenceable parameters */
190 tX_seqpar_vtt_speed sp_speed;
191 tX_seqpar_vtt_volume sp_volume;
192 tX_seqpar_vtt_pitch sp_pitch;
193 tX_seqpar_vtt_trigger sp_trigger;
194 tX_seqpar_vtt_loop sp_loop;
195 tX_seqpar_vtt_sync_client sp_sync_client;
196 tX_seqpar_vtt_sync_cycles sp_sync_cycles;
197 tX_seqpar_vtt_lp_enable sp_lp_enable;
198 tX_seqpar_vtt_lp_gain sp_lp_gain;
199 tX_seqpar_vtt_lp_reso sp_lp_reso;
200 tX_seqpar_vtt_lp_freq sp_lp_freq;
201 tX_seqpar_vtt_ec_enable sp_ec_enable;
202 tX_seqpar_vtt_ec_length sp_ec_length;
203 tX_seqpar_vtt_ec_feedback sp_ec_feedback;
204 tX_seqpar_vtt_mute sp_mute;
205 tX_seqpar_spin sp_spin;
207 tx_audiofile *audiofile;
209 list <vtt_fx *> fx_list;
216 /* Parameter setup methods */
217 void set_name(char *);
219 void set_file_data(char *, int16_t *, int);
221 int set_output_buffer_size(int);
223 void set_volume(f_prec);
224 void recalc_volume();
226 void set_pitch(f_prec);
229 void set_autotrigger(int);
234 void set_controls(int, int);
235 void set_y_input_parameter(tX_seqpar *);
236 void set_x_input_parameter(tX_seqpar *);
238 void lp_set_enable(int);
239 void lp_set_gain(f_prec);
240 void lp_set_reso(f_prec);
241 void lp_set_freq(f_prec);
242 void lp_setup(f_prec, f_prec, f_prec);
244 void ec_set_enable(int);
245 void ec_set_length(f_prec);
246 void ec_set_feedback(f_prec);
247 void ec_clear_buffer();
249 void set_sync_master(int);
250 void set_sync_client(int, int);
251 void set_sync_client_ug(int, int); // and update gui
253 void set_scratch(int);
254 void xy_input(f_prec, f_prec);
255 void handle_input(int, f_prec);
257 vtt_fx_ladspa * add_effect(LADSPA_Plugin *);
261 void forward_turntable();
263 static int16_t *render_all_turntables();
264 static void forward_all_turntables();
266 static int set_mix_buffer_size(int);
267 static void set_master_volume(f_prec);
268 static void set_master_pitch(f_prec);
269 static void enable_saturate(int);
270 static void focus_no(int);
271 static void focus_next();
272 static void unfocus();
283 static int load_all_10(FILE *, char *fname); /* fname is for display only*/
284 static int load_all_11(FILE *, char *fname); /* fname is for display only*/
285 static int load_all_12(FILE *, char *fname); /* fname is for display only*/
286 static int save_all(FILE *);
287 int load_file(char *name);
289 void render_scratch();
293 void effect_up(vtt_fx *effect);
294 void effect_down(vtt_fx *effect);
295 void effect_remove(vtt_fx_ladspa *effect);