2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999-2002 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 NEED_FADE_OUT 0
55 #define NEED_FADE_IN 1
57 #define SAMPLE_MAX 32760.0
58 #define SAMPLE_BORDER 30000.0
65 static int vtt_amount;
66 static list <vtt_class *> main_list;
67 static list <vtt_class *> render_list;
69 static f_prec *mix_buffer;
70 static f_prec *mix_buffer_end;
72 static int16_t *mix_out_buffer;
73 static f_prec mix_max_l;
74 static f_prec mix_max_r;
75 static int samples_in_mix_buffer;
76 static pthread_mutex_t render_lock;
78 static f_prec master_volume;
79 static f_prec res_master_volume;
80 static f_prec vol_channel_adjust;
82 static f_prec saturate_fac;
83 static int do_saturate;
85 static vtt_class * sync_master;
86 static int master_triggered;
87 static int master_triggered_at;
88 static vtt_class * focused_vtt;
95 /* main object vars */
96 char name[256]; // Turntable's name
97 char filename[PATH_MAX]; // The corresponding audiofile
118 int16_t *buffer; // Actual audio data
119 unsigned int samples_in_buffer; // No. of samples in audio data
122 f_prec *output_buffer;
123 f_prec *end_of_outputbuffer;
124 f_prec samples_in_outputbuffer;
125 f_prec inv_samples_in_outputbuffer;
127 /* main playback vars */
128 f_prec rel_volume; // The (user-selected) relative volume
129 f_prec res_volume; // The resulting volume
133 f_prec rel_pitch; // The (user-selected) relative pitch
137 f_prec pan; // The logical pan value -1 left, 0 center, 1 right
138 f_prec res_volume_left;
139 f_prec res_volume_right;
165 /* seq par mapping for x/y axis */
184 f_prec ec_buffer[EC_MAX_BUFFER];
185 f_prec *ec_output_buffer;
190 f_prec ec_res_length;
194 f_prec ec_volume_left;
195 f_prec ec_volume_right;
197 /* sequenceable parameters */
198 tX_seqpar_vtt_speed sp_speed;
199 tX_seqpar_vtt_volume sp_volume;
200 tX_seqpar_vtt_pitch sp_pitch;
201 tX_seqpar_vtt_pan sp_pan;
202 tX_seqpar_vtt_trigger sp_trigger;
203 tX_seqpar_vtt_loop sp_loop;
204 tX_seqpar_vtt_sync_client sp_sync_client;
205 tX_seqpar_vtt_sync_cycles sp_sync_cycles;
206 tX_seqpar_vtt_lp_enable sp_lp_enable;
207 tX_seqpar_vtt_lp_gain sp_lp_gain;
208 tX_seqpar_vtt_lp_reso sp_lp_reso;
209 tX_seqpar_vtt_lp_freq sp_lp_freq;
210 tX_seqpar_vtt_ec_enable sp_ec_enable;
211 tX_seqpar_vtt_ec_length sp_ec_length;
212 tX_seqpar_vtt_ec_feedback sp_ec_feedback;
213 tX_seqpar_vtt_ec_pan sp_ec_pan;
214 tX_seqpar_vtt_ec_volume sp_ec_volume;
215 tX_seqpar_vtt_mute sp_mute;
216 tX_seqpar_spin sp_spin;
218 tx_audiofile *audiofile;
219 f_prec audiofile_pitch_correction;
221 list <vtt_fx *> fx_list;
228 /* Parameter setup methods */
229 void set_name(char *);
230 int set_output_buffer_size(int);
232 void set_volume(f_prec);
233 void recalc_volume();
235 void set_pan(f_prec);
237 void set_pitch(f_prec);
240 void set_autotrigger(int);
245 void set_y_input_parameter(tX_seqpar *);
246 void set_x_input_parameter(tX_seqpar *);
249 void lp_set_enable(int);
250 void lp_set_gain(f_prec);
251 void lp_set_reso(f_prec);
252 void lp_set_freq(f_prec);
253 void lp_setup(f_prec, f_prec, f_prec);
255 void ec_set_enable(int);
256 void ec_set_length(f_prec);
257 void ec_set_feedback(f_prec);
258 void ec_set_volume(f_prec);
259 void ec_set_pan(f_prec);
260 void ec_clear_buffer();
262 void set_sync_master(int);
263 void set_sync_client(int, int);
264 void set_sync_client_ug(int, int); // and update gui
266 void set_scratch(int);
267 void xy_input(f_prec, f_prec);
269 vtt_fx_ladspa * add_effect(LADSPA_Plugin *);
273 void forward_turntable();
275 static int16_t *render_all_turntables();
276 static void forward_all_turntables();
278 static int set_mix_buffer_size(int);
279 static void set_master_volume(f_prec);
280 static void set_master_pitch(f_prec);
281 static void enable_saturate(int);
282 static void focus_no(int);
283 static void focus_next();
284 static void unfocus();
297 static int load_all_10(FILE *, char *fname); /* fname is for display only*/
298 static int load_all_11(FILE *, char *fname); /* fname is for display only*/
299 static int load_all_12(FILE *, char *fname); /* fname is for display only*/
300 static int load_all_13(FILE *, char *fname); /* fname is for display only*/
301 static int load_all_14(FILE *, char *fname); /* fname is for display only*/
302 static int save_all(FILE *);
303 int load_file(char *name);
305 void render_scratch();
309 void effect_up(vtt_fx *effect);
310 void effect_down(vtt_fx *effect);
311 void effect_remove(vtt_fx_ladspa *effect);
313 void hide_audio(bool);
314 void hide_control(bool);
316 void set_mix_mute(int newstate);
317 void set_mix_solo(int newstate);
320 res_mute=((mute) || (mix_mute && (!mix_solo)) || ((solo_ctr>0)&&(!mix_solo)));