2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999-2003 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: This implements the new virtual turntable class. It replaces
22 the old turntable.c from terminatorX 3.2 and earlier. The lowpass
23 filter is based on some sample code by Paul Kellett
24 <paul.kellett@maxim.abel.co.uk>
26 08 Dec 1999 - Switched to the new audiofile class
30 #include "tX_global.h"
34 #include "tX_mastergui.h"
35 #include "tX_sequencer.h"
47 #define tX_freemem(ptr, varname, comment); fprintf(stderr, "** free() [%s] at %08x. %s.\n", varname, ptr, comment); free(ptr);
48 #define tX_malloc(ptr, varname, comment, size, type); fprintf(stderr, "**[1/2] malloc() [%s]. Size: %i. %s.\n", varname, size, comment); ptr=type malloc(size); fprintf(stderr, "**[2/2] malloc() [%s]. ptr: %08x.\n", varname, ptr);
50 #define tX_freemem(ptr, varname, comment); free(ptr);
51 #define tX_malloc(ptr, varname, comment, size, type); ptr=type malloc(size);
54 #include "tX_loaddlg.h"
56 #define USE_PREFETCH 1
59 #define my_prefetch(base, index); __asm__ __volatile__ ("prefetch index(%0)\n" : : "r" (base));
60 #define my_prefetchw(base, index); __asm__ __volatile__ ("prefetchw index(%0)\n" : : "r" (base));
62 #define my_prefetch(base, index); /* NOP */;
63 #define my_prefetchw(base, index); /* NOP */;
66 extern void build_vtt_gui(vtt_class *);
67 extern void gui_set_name(vtt_class *vtt, char *newname);
68 extern void gui_set_filename(vtt_class *vtt, char *newname);
69 extern void delete_gui(vtt_class *vtt);
70 extern void gui_update_display(vtt_class *vtt);
71 extern void gui_clear_master_button(vtt_class *vtt);
72 extern void cleanup_vtt(vtt_class *vtt);
73 extern int vg_get_current_page(vtt_class *vtt);
74 extern f_prec gui_get_audio_x_zoom(vtt_class *vtt);
75 extern void gui_set_audio_x_zoom(vtt_class *vtt, f_prec);
78 int vtt_class::vtt_amount=0;
79 list <vtt_class *> vtt_class::main_list;
80 list <vtt_class *> vtt_class::render_list;
81 int16_t* vtt_class::mix_out_buffer=NULL;
82 f_prec * vtt_class::mix_buffer=NULL;
83 f_prec * vtt_class::mix_buffer_end=NULL;
84 int vtt_class::solo_ctr=0;
86 int vtt_class::samples_in_mix_buffer=0;
87 pthread_mutex_t vtt_class::render_lock=PTHREAD_MUTEX_INITIALIZER;
88 f_prec vtt_class::master_volume=1.0;
89 f_prec vtt_class::res_master_volume=1.0;
90 f_prec vtt_class::saturate_fac=0.1;
91 int vtt_class::do_saturate=0;
92 vtt_class * vtt_class::sync_master=NULL;
93 int vtt_class::master_triggered=0;
94 int vtt_class::master_triggered_at=0;
95 vtt_class * vtt_class::focused_vtt=NULL;
96 f_prec vtt_class::mix_max_l=0;
97 f_prec vtt_class::mix_max_r=0;
98 f_prec vtt_class::vol_channel_adjust=1.0;
100 #define GAIN_AUTO_ADJUST 0.8
102 vtt_class :: vtt_class (int do_create_gui)
105 sprintf (name, "Turntable %i", vtt_amount);
106 strcpy(filename, "NONE");
126 lp_setup(lp_gain, lp_reso, lp_freq);
137 main_list.push_back(this);
139 /* "connecting" the seq-parameters */
141 sp_speed.set_vtt((void *) this);
142 sp_volume.set_vtt((void *) this);
143 sp_pitch.set_vtt((void *) this);
144 sp_pan.set_vtt((void *) this);
145 sp_trigger.set_vtt((void *) this);
146 sp_loop.set_vtt((void *) this);
147 sp_sync_client.set_vtt((void *) this);
148 sp_sync_cycles.set_vtt((void *) this);
149 sp_lp_enable.set_vtt((void *) this);
150 sp_lp_gain.set_vtt((void *) this);
151 sp_lp_reso.set_vtt((void *) this);
152 sp_lp_freq.set_vtt((void *) this);
153 sp_ec_enable.set_vtt((void *) this);
154 sp_ec_length.set_vtt((void *) this);
155 sp_ec_pan.set_vtt((void *) this);
156 sp_ec_volume.set_vtt((void *) this);
157 sp_ec_feedback.set_vtt((void *) this);
158 sp_mute.set_vtt((void *) this);
159 sp_spin.set_vtt((void *) this);
164 lp_fx=new vtt_fx_lp();
165 lp_fx->set_vtt((void *) this);
166 fx_list.push_back(lp_fx);
168 ec_fx=new vtt_fx_ec();
169 ec_fx->set_vtt((void *) this);
170 fx_list.push_back(ec_fx);
175 lp_fx->set_panel_widget(gui.lp_panel->get_widget());
176 ec_fx->set_panel_widget(gui.ec_panel->get_widget());
181 set_master_volume(globals.volume);
182 set_output_buffer_size(samples_in_mix_buffer/2);
185 audiofile_pitch_correction=0;
192 control_hidden=false;
\r
195 vtt_class :: ~vtt_class()
200 main_list.remove(this);
201 if (audiofile) delete audiofile;
202 //if (buffer) free(buffer);
203 if (output_buffer) tX_freemem(output_buffer, "output_buffer", "vtt Destructor");
206 while (fx_list.size())
208 effect=(*fx_list.begin());
209 fx_list.remove(effect);
216 void vtt_class :: set_name(char *newname)
218 strcpy(name, newname);
219 gui_set_name(this, name);
222 tX_audio_error vtt_class :: load_file(char *fname)
225 int was_playing=is_playing;
227 if (is_playing) stop();
229 if (audiofile) delete(audiofile);
236 audiofile=new tx_audiofile();
237 res=audiofile->load(fname);
239 if (res==TX_AUDIO_SUCCESS) {
240 buffer=audiofile->get_buffer();
241 double file_rate=audiofile->get_sample_rate();
242 audiofile_pitch_correction=file_rate/44100.0;
244 samples_in_buffer=audiofile->get_no_samples();
245 maxpos=audiofile->get_no_samples();
246 strcpy(filename, fname);
247 if (was_playing) trigger();
248 // printf("Successfully loaded %s, %08x, %i\n", fname, buffer, samples_in_buffer);
253 gui_update_display(this);
255 ec_set_length(ec_length);
260 int vtt_class :: set_output_buffer_size(int newsize)
262 list <vtt_fx *> :: iterator effect;
264 if (ec_output_buffer) tX_freemem(ec_output_buffer, "ec_output_buffer", "vtt set_output_buffer_size()");
265 tX_malloc(ec_output_buffer, "ec_output_buffer", "vtt set_output_buffer_size()", sizeof(float)*newsize, (float *));
267 if (output_buffer) tX_freemem(output_buffer, "output_buffer", "vtt set_output_buffer_size()");
268 tX_malloc(output_buffer, "output_buffer", "vtt set_output_buffer_size()", sizeof(float)*newsize, (float *));
270 end_of_outputbuffer = output_buffer + newsize; //size_t(sizeof(float)*(newsize));
272 samples_in_outputbuffer=newsize;
273 inv_samples_in_outputbuffer=1.0/samples_in_outputbuffer;
275 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
277 (*effect)->reconnect_buffer();
280 if (output_buffer) return(0);
284 void vtt_class :: set_volume(f_prec newvol)
290 void vtt_class :: recalc_volume()
292 res_volume=rel_volume*res_master_volume;
293 f_prec ec_res_volume=res_volume*ec_volume;
297 res_volume_left=(1.0-pan)*res_volume;
298 res_volume_right=res_volume;
302 res_volume_left=res_volume;
303 res_volume_right=(1.0+pan)*res_volume;
307 res_volume_left=res_volume_right=res_volume;
312 ec_volume_left=(1.0-ec_pan)*ec_res_volume;
313 ec_volume_right=ec_res_volume;
317 ec_volume_left=ec_res_volume;
318 ec_volume_right=(1.0+ec_pan)*ec_res_volume;
322 ec_volume_left=ec_volume_right=ec_res_volume;
324 // printf("vtt_volume: %f, %f, l: %f, r: %f\n", rel_volume, res_volume, res_volume_left, res_volume_right);
327 mm_res_volume.s[0]=mm_res_volume.s[1]=res_volume;
331 void vtt_class :: set_pan(f_prec newpan)
337 void vtt_class :: set_pitch(f_prec newpitch)
340 res_pitch=globals.pitch*rel_pitch;
342 ec_set_length(ec_length);
345 void vtt_class :: recalc_pitch()
347 res_pitch=globals.pitch*rel_pitch;
348 res_pitch*=audiofile_pitch_correction;
350 ec_set_length(ec_length);
353 void vtt_class :: set_autotrigger(int newstate)
355 autotrigger=newstate;
358 void vtt_class :: set_loop(int newstate)
363 void vtt_class :: set_mute(int newstate)
369 void vtt_class :: set_mix_mute(int newstate)
375 void vtt_class :: set_mix_solo(int newstate)
377 if (mix_solo && !newstate)
383 else if (!mix_solo && newstate)
392 list <vtt_class *> :: iterator vtt;
394 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++)
400 void vtt_class :: lp_set_enable (int newstate)
406 void vtt_class :: lp_reset()
411 void vtt_class :: lp_set_gain (f_prec gain)
414 lp_resgain=lp_gain*lp_autogain;
417 void vtt_class :: lp_set_reso(f_prec reso)
421 lp_b=reso*(1.0+(1.0/lp_a));
422 lp_autogain=1.0-reso*GAIN_AUTO_ADJUST;
423 lp_resgain=lp_gain*lp_autogain;
426 void vtt_class :: lp_set_freq(f_prec freq)
431 lp_b=lp_reso*(1.0+(1.0/lp_a));
434 void vtt_class :: lp_setup(f_prec gain, f_prec reso, f_prec freq)
440 lp_b=reso*(1.0+(1.0/lp_a));
442 lp_autogain=1.0-reso*GAIN_AUTO_ADJUST;
443 lp_resgain=lp_gain*lp_autogain;
446 void vtt_class :: ec_set_enable(int newstate)
453 void vtt_class :: ec_set_pan(f_prec pan)
460 /* Max length is 1.0 */
462 void vtt_class :: ec_set_length(f_prec length)
469 ec_res_length=length*samples_in_buffer;
473 ec_res_length=length*samples_in_buffer/res_pitch;
476 if (ec_res_length<0) ec_res_length*=-1;
478 if (ec_res_length>=EC_MAX_BUFFER)
480 ec_res_length=EC_MAX_BUFFER*length;
483 delay=(int )floor(ec_res_length);
485 ec_delay=&ec_buffer[delay];
488 void vtt_class :: ec_set_feedback(f_prec feedback)
490 ec_feedback=feedback;
494 void vtt_class :: ec_set_volume(f_prec volume)
500 void vtt_class :: ec_clear_buffer()
504 for (ptr=ec_buffer; ptr<=ec_delay; ptr++)
511 void vtt_class :: render()
513 list <vtt_fx *> :: iterator effect;
520 if (sense_cycles==0) sp_speed.receive_input_value(0);
525 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
527 if ((*effect)->isEnabled()) (*effect)->run();
531 extern void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin);
533 vtt_fx_ladspa * vtt_class :: add_effect (LADSPA_Plugin *plugin)
535 vtt_fx_ladspa *new_effect;
537 new_effect = new vtt_fx_ladspa (plugin, this);
538 pthread_mutex_lock(&render_lock);
539 fx_list.push_back(new_effect);
540 if (is_playing) new_effect->activate();
541 pthread_mutex_unlock(&render_lock);
542 vg_create_fx_gui(this, new_effect, plugin);
547 void vtt_class :: calc_speed()
553 if (speed != speed_target)
556 speed_step=speed_target-speed_real;
560 if (speed_target != speed_real)
562 speed_real+=speed_step;
563 if ((speed_step<0) && (speed_real<speed_target)) speed_real=speed_target;
565 if ((speed_step>0) && (speed_real>speed_target)) speed_real=speed_target;
570 if ((speed_last==0) && (speed_real !=0))
578 if ((speed_last!=0) && (speed_real==0))
585 speed_last = speed_real;
587 if (res_mute != res_mute_old)
591 fade_out=1; fade_in=0;
596 fade_in=1; fade_out=0;
599 res_mute_old=res_mute;
603 if (res_mute) do_mute=1;
607 void vtt_class :: render_scratch()
628 for (sample =0,out=output_buffer, fade_vol=0.0; sample < samples_in_outputbuffer;sample++, out++, fade_vol+=inv_samples_in_outputbuffer)
630 if ((speed_real!=0) || (fade_out))
645 master_triggered_at=sample;
665 master_triggered_at=sample;
675 pos_a_f=floor(pos_f);
676 pos_i=(unsigned int) pos_a_f;
678 amount_b=pos_f-pos_a_f;
679 amount_a=1.0-amount_b;
688 sample_a=(f_prec) *ptr;
690 if (pos_i == samples_in_buffer)
697 sample_b=(f_prec) *ptr;
700 sample_res=(sample_a*amount_a)+(sample_b*amount_b);
704 sample_res*=fade_vol;
709 sample_res*=1.0-fade_vol;
722 void vtt_class :: forward_turntable()
733 if ((speed_real==0) && (!fade_out)) return;
736 /* following code is problematic as adding speed_real*n is
737 different from adding speed_real n times to pos_f.
739 well it speeds things up quite a bit and double precision
740 seems to do a satisfying job.
742 #define pos_f_test to prove that.
745 pos_f_tmp=pos_f+speed_real*samples_in_outputbuffer;
747 if ((pos_f_tmp > 0) && (pos_f_tmp < maxpos))
757 /* now the slow way ;) */
759 for (sample =0; sample < samples_in_outputbuffer; sample++)
773 master_triggered_at=sample;
793 master_triggered_at=sample;
807 diff=pos_f_tmp-pos_f;
808 if (diff!=0) printf("fast: %f, slow: %f, diff: %f, tt: %s\n", pos_f_tmp, pos_f, diff, name);
814 The following lowpass filter is based on some sample code by
815 Paul Kellett <paul.kellett@maxim.abel.co.uk>
818 void vtt_class :: render_lp()
822 for (sample = output_buffer; sample<end_of_outputbuffer; sample++)
824 lp_buf0 = lp_a * lp_buf0 + lp_freq * ((*sample)*lp_resgain + lp_b * (lp_buf0 - lp_buf1));
825 lp_buf1 = lp_a * lp_buf1 + lp_freq * lp_buf0;
831 void vtt_class :: render_ec()
837 for (i=0, sample = output_buffer, ec_sample=ec_output_buffer; i<samples_in_outputbuffer; i++, ec_sample++,sample++, ec_ptr++)
839 if (ec_ptr>ec_delay) ec_ptr=ec_buffer;
840 *ec_sample=(*ec_ptr) *ec_feedback;
841 *ec_ptr=*sample+*ec_sample;
845 int vtt_class :: set_mix_buffer_size(int no_samples)
847 list <vtt_class *> :: iterator vtt;
850 // printf("vtt_class::set_mix_buffer_size(), mix_buffer: %12x, mix_out: %12x, samples: %i\n", mix_buffer, mix_out_buffer, no_samples);
852 if (mix_buffer) tX_freemem(mix_buffer, "mix_buffer", "vtt set_mix_buffer_size()");
853 samples_in_mix_buffer=no_samples*2;
855 tX_malloc(mix_buffer, "mix_buffer", "vtt set_mix_buffer_size()", sizeof(float)*samples_in_mix_buffer, (float *));
856 mix_buffer_end=mix_buffer+samples_in_mix_buffer;
858 // printf("mix_buffer: %12x\n", mix_buffer);
859 // printf("mix_samples: %i, out_samples: %i", samples_in_mix_buffer, no_samples);
861 if (mix_out_buffer) tX_freemem(mix_out_buffer, "mix_out_buffer", "vtt set_mix_buffer_size()");
862 tX_malloc(mix_out_buffer, "mix_out_buffer", "vtt set_mix_buffer_size()", sizeof(int16_t)*samples_in_mix_buffer + 4, (int16_t *));
864 // printf("mix_out_buffer: %12x\n", mix_out_buffer);
866 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
868 res|=(*vtt)->set_output_buffer_size(no_samples);
871 if ((!mix_buffer) || (!mix_out_buffer) || res) return(1);
875 int16_t * vtt_class :: render_all_turntables()
877 list <vtt_class *> :: iterator vtt, next;
898 #ifndef OVERRIDE_MOVQ_AUTODETECT
900 #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
901 #endif /* GCC_VERSION */
903 #if (GCC_VERSION < 2096)
904 #warning "*************************"
905 #warning "* gcc < 2.96 *"
906 #warning "* assuming working movq *"
907 #warning "*************************"
908 #undef GCC_MOVQ_BUG_WORKAROUND
910 #warning "*************************"
911 #warning "* gcc >= 2.96 *"
912 #warning "* using movq-workaround *"
913 #warning "*************************"
914 #define GCC_MOVQ_BUG_WORKAROUND 1
915 #endif /* GCC < 2.96 */
916 #endif /* OVERRIDE MOVQ AUTODETECVT */
918 #ifdef GCC_MOVQ_BUG_WORKAROUND
919 /* REQUIRED DUE TO GCC BUG (2.96-3.0.2) */
920 mmx_t *mm_src1_ptr=&mm_src1;
921 mmx_t *mm_src2_ptr=&mm_src2;
922 mmx_t *mm_volume_ptr=&mm_volume;
923 mmx_t *mm_max_ptr=&mm_max;
924 mmx_t *mm_min_ptr=&mm_min;
926 #define MM_VAR_ACC(var) (* var ## _ptr)
927 #define MM_VAR_MOVQ(var) * var ## _ptr
929 #define MM_VAR_ACC(var) var
930 #define MM_VAR_MOVQ(var) var
932 int32_t *temp_int=&mm_max.d[1];
936 pthread_mutex_lock(&render_lock);
938 if (render_list.size()==0)
940 for (sample=0; sample<samples_in_mix_buffer; sample++)
942 mix_out_buffer[sample]=0;
947 vtt=render_list.begin();
949 max=(*vtt)->max_value;
953 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
955 temp=(*vtt)->output_buffer[sample];
956 mix_buffer[mix_sample]=temp*(*vtt)->res_volume_left;
958 mix_buffer[mix_sample]=temp*(*vtt)->res_volume_right;
961 if (temp>max) max=temp;
962 else if (temp<min) min=temp;
965 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->res_volume_left;
966 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->res_volume_right;
968 MM_VAR_ACC(mm_max).s[1]=MM_VAR_ACC(mm_max).s[0]=max;
969 MM_VAR_ACC(mm_min).s[1]=MM_VAR_ACC(mm_min).s[0]=min;
971 movq_m2r(MM_VAR_MOVQ(mm_max), mm1);
972 movq_m2r(MM_VAR_MOVQ(mm_min), mm2);
974 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
976 mix=(mmx_t*)mix_buffer;
978 for (f_prec* src=(*vtt)->output_buffer; mix < (mmx_t*) mix_buffer_end;)
981 MM_VAR_ACC(mm_src1).s[0]=*src;
982 MM_VAR_ACC(mm_src1).s[1]=*src;
984 /* sample * l/r volume */
985 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
991 MM_VAR_ACC(mm_src2).s[0]=*src;
992 MM_VAR_ACC(mm_src2).s[1]=*src;
994 /* sample * l/r volume */
995 movq_m2r(MM_VAR_MOVQ(mm_src2), mm3);
999 /* calculating min/max */
1000 MM_VAR_ACC(mm_src1).s[1]=MM_VAR_ACC(mm_src2).s[0];
1001 movq_m2r(mm_src1, mm3);
1002 pfmax_r2r(mm3, mm1);
1003 pfmin_r2r(mm3, mm2);
1008 movq_r2m(mm1, MM_VAR_MOVQ(mm_max));
1009 movq_r2m(mm2, MM_VAR_MOVQ(mm_min));
1013 if (MM_VAR_ACC(mm_max).s[0]>MM_VAR_ACC(mm_max).s[1]) max=MM_VAR_ACC(mm_max).s[0]; else max=MM_VAR_ACC(mm_max).s[1];
1014 if (MM_VAR_ACC(mm_min).s[0]<MM_VAR_ACC(mm_min).s[0]) min=MM_VAR_ACC(mm_min).s[0]; else min=MM_VAR_ACC(mm_min).s[1];
1018 if (min>max) (*vtt)->max_value=min; else (*vtt)->max_value=max;
1020 if ((*vtt)->ec_enable)
1023 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1025 temp=(*vtt)->ec_output_buffer[sample];
1027 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_left;
1029 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_right;
1033 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->ec_volume_left;
1034 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->ec_volume_right;
1036 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1037 mix =(mmx_t*)mix_buffer;
1039 for (f_prec* src=(*vtt)->ec_output_buffer; mix < (mmx_t*) mix_buffer_end; src++, mix++)
1042 MM_VAR_ACC(mm_src1).s[0]=*src;
1043 MM_VAR_ACC(mm_src1).s[1]=*src;
1045 /* sample * l/r volume */
1046 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1047 pfmul_r2r(mm0, mm3);
1049 /* accumulating complete mix */
1050 movq_m2r(*mix, mm4);
1051 pfadd_r2r(mm4, mm3);
1052 movq_r2m(mm3, *mix);
1058 if (master_triggered)
1060 pthread_mutex_unlock(&render_lock);
1061 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1063 if ((*vtt)->is_sync_client)
1065 if ((*vtt)->sync_countdown)
1067 (*vtt)->sync_countdown--;
1071 (*vtt)->sync_countdown=(*vtt)->sync_cycles;
1076 pthread_mutex_lock(&render_lock);
1079 vtt=render_list.begin();
1080 for (vtt++; vtt!=render_list.end(); vtt++)
1083 max=(*vtt)->max_value;
1087 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1089 temp=(*vtt)->output_buffer[sample];
1090 mix_buffer[mix_sample]+=temp*(*vtt)->res_volume_left;
1092 mix_buffer[mix_sample]+=temp*(*vtt)->res_volume_right;
1095 if (temp>max) max=temp;
1096 else if (temp<min) min=temp;
1099 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->res_volume_left;
1100 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->res_volume_right;
1102 MM_VAR_ACC(mm_max).s[1]=MM_VAR_ACC(mm_max).s[0]=max;
1103 MM_VAR_ACC(mm_min).s[1]=MM_VAR_ACC(mm_min).s[0]=min;
1105 movq_m2r(MM_VAR_MOVQ(mm_max), mm1);
1106 movq_m2r(MM_VAR_MOVQ(mm_min), mm2);
1108 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1109 mix=(mmx_t*)mix_buffer;
1111 for (f_prec* src=(*vtt)->output_buffer; mix < (mmx_t*) mix_buffer_end;)
1114 MM_VAR_ACC(mm_src1).s[0]=*src;
1115 MM_VAR_ACC(mm_src1).s[1]=*src;
1117 /* sample * l/r volume */
1118 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1119 pfmul_r2r(mm0, mm3);
1121 /* accumulating complete mix */
1122 movq_m2r(*mix, mm4);
1123 pfadd_r2r(mm4, mm3);
1124 movq_r2m(mm3, *mix);
1128 MM_VAR_ACC(mm_src2).s[0]=*src;
1129 MM_VAR_ACC(mm_src2).s[1]=*src;
1131 /* sample * l/r volume */
1132 movq_m2r(MM_VAR_MOVQ(mm_src2), mm3);
1133 pfmul_r2r(mm0, mm3);
1135 /* accumulating complete mix */
1136 movq_m2r(*mix, mm4);
1137 pfadd_r2r(mm4, mm3);
1138 movq_r2m(mm3, *mix);
1140 /* calculating min/max */
1141 MM_VAR_ACC(mm_src1).s[1]=MM_VAR_ACC(mm_src2).s[0];
1142 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1143 pfmax_r2r(mm3, mm1);
1144 pfmin_r2r(mm3, mm2);
1149 movq_r2m(mm1, MM_VAR_MOVQ(mm_max));
1150 movq_r2m(mm2, MM_VAR_MOVQ(mm_min));
1154 if (MM_VAR_ACC(mm_max).s[0]>MM_VAR_ACC(mm_max).s[1]) max=MM_VAR_ACC(mm_max).s[0]; else max=MM_VAR_ACC(mm_max).s[1];
1155 if (MM_VAR_ACC(mm_min).s[0]<MM_VAR_ACC(mm_min).s[0]) min=MM_VAR_ACC(mm_min).s[0]; else min=MM_VAR_ACC(mm_min).s[1];
1159 if (min>max) (*vtt)->max_value=min; else (*vtt)->max_value=max;
1161 if ((*vtt)->ec_enable)
1164 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1166 temp=(*vtt)->ec_output_buffer[sample];
1168 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_left;
1170 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_right;
1174 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->ec_volume_left;
1175 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->ec_volume_right;
1177 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1178 mix =(mmx_t*)mix_buffer;
1180 for (f_prec* src=(*vtt)->ec_output_buffer; mix < (mmx_t*) mix_buffer_end; src++, mix++)
1183 MM_VAR_ACC(mm_src1).s[0]=*src;
1184 MM_VAR_ACC(mm_src1).s[1]=*src;
1186 /* sample * l/r volume */
1187 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1188 pfmul_r2r(mm0, mm3);
1190 /* accumulating complete mix */
1191 movq_m2r(*mix, mm4);
1192 pfadd_r2r(mm4, mm3);
1193 movq_r2m(mm3, *mix);
1206 for (sample=0; sample<samples_in_mix_buffer; sample+=2)
1208 temp=mix_buffer[sample];
1211 #define FL_SHRT_MAX 32767.0
1212 #define FL_SHRT_MIN -32768.0
1213 if(temp < FL_SHRT_MIN) temp = FL_SHRT_MIN;
1214 else if (temp > FL_SHRT_MAX) temp = FL_SHRT_MAX;
1217 mix_out_buffer[sample]=(int16_t) temp;
1219 if (temp>max) max=temp;
1220 else if (temp<min) min=temp;
1224 if (min>max) mix_max_l=min; else mix_max_l=max;
1231 for (sample=1; sample<samples_in_mix_buffer; sample+=2)
1233 temp=mix_buffer[sample];
1236 if(temp < FL_SHRT_MIN) temp = FL_SHRT_MIN;
1237 else if (temp > FL_SHRT_MAX) temp = FL_SHRT_MAX;
1240 mix_out_buffer[sample]=(int16_t) temp;
1242 if (temp>max) max=temp;
1243 else if (temp<min) min=temp;
1247 if (min>max) mix_max_r=min; else mix_max_r=max;
1252 vtt=render_list.begin();
1253 while (vtt!=render_list.end())
1258 if ((*vtt)->want_stop) (*vtt)->stop_nolock();
1261 pthread_mutex_unlock(&render_lock);
1263 return(mix_out_buffer);
1266 void vtt_class :: forward_all_turntables()
1268 list <vtt_class *> :: iterator vtt, next;
1270 if (render_list.size()>0)
1272 vtt=render_list.begin();
1273 (*vtt)->forward_turntable();
1275 if (master_triggered)
1277 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1279 if ((*vtt)->is_sync_client)
1281 if ((*vtt)->sync_countdown)
1283 (*vtt)->sync_countdown--;
1287 (*vtt)->sync_countdown=(*vtt)->sync_cycles;
1294 vtt=render_list.begin();
1295 for (vtt++; vtt!=render_list.end(); vtt++)
1297 (*vtt)->forward_turntable();
1302 vtt=render_list.begin();
1303 while (vtt!=render_list.end())
1308 if ((*vtt)->want_stop) (*vtt)->stop_nolock();
1314 int vtt_class :: trigger()
1316 list <vtt_fx *> :: iterator effect;
1318 if (!buffer) return (1);
1320 if (!is_playing) pthread_mutex_lock(&render_lock);
1322 if (res_pitch>=0) pos_f=0;
1326 speed_real=res_pitch;
1327 speed_target=res_pitch;
1330 /* activating plugins */
1331 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
1333 (*effect)->activate();
1344 master_triggered_at=0;
1353 render_list.push_front(this);
1357 render_list.push_back(this);
1359 pthread_mutex_unlock(&render_lock);
1364 int vtt_class :: stop_nolock()
1366 list <vtt_fx *> :: iterator effect;
1370 pthread_mutex_unlock(&render_lock);
1373 render_list.remove(this);
1384 /* deactivating plugins */
1385 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
1387 (*effect)->deactivate();
1393 int vtt_class :: stop()
1397 pthread_mutex_lock(&render_lock);
1401 pthread_mutex_unlock(&render_lock);
1406 void vtt_class :: set_sync_master(int master)
1410 if (sync_master) sync_master->set_sync_master(0);
1416 if (sync_master==this) sync_master=0;
1418 gui_clear_master_button(this);
1422 void vtt_class :: set_sync_client(int slave, int cycles)
1424 is_sync_client=slave;
1426 // sync_countdown=cycles;
1430 void vtt_class :: set_sync_client_ug(int slave, int cycles)
1432 set_sync_client(slave, cycles);
1435 void vtt_class :: set_master_volume(f_prec new_volume)
1437 list <vtt_class *> :: iterator vtt;
1439 master_volume=new_volume;
1440 globals.volume=new_volume;
1442 if (main_list.size()>0)
1444 vol_channel_adjust=sqrt((f_prec) main_list.size());
1445 res_master_volume=master_volume/vol_channel_adjust;
1448 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1450 (*vtt)->recalc_volume();
1454 void vtt_class :: set_master_pitch(f_prec new_pitch)
1456 list <vtt_class *> :: iterator vtt;
1458 globals.pitch=new_pitch;
1459 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1461 (*vtt)->recalc_pitch();
1465 void vtt_class :: enable_saturate (int newstate)
1467 do_saturate=newstate;
1470 void vtt_class :: focus_no(int no)
1472 list <vtt_class *> :: iterator vtt;
1475 for (i=0, vtt=main_list.begin(); vtt!=main_list.end(); vtt++, i++)
1484 void vtt_class :: focus_next()
1486 list <vtt_class *> :: iterator vtt;
1490 if (main_list.size())
1492 focused_vtt=(*main_list.begin());
1497 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
1498 if ((*vtt)==focused_vtt) {
1499 /* Ok, we found ourselves.. */
1502 while ((vtt!=main_list.end()) && ((*vtt)->audio_hidden) ) {
1506 if (vtt==main_list.end()) {
1507 /* No other "focusable" after this vtt so we're looking for the next */
1509 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
1510 if (! (*vtt)->audio_hidden) {
1515 /* When we get here there's no "focusable" vtt at all... damn */
1525 focused_vtt=(*main_list.begin());
1528 void vtt_class :: set_scratch(int newstate)
1532 sp_spin.receive_input_value(0);
1534 sense_cycles=globals.sense_cycles;
1538 sp_spin.receive_input_value(1);
1544 void vtt_class :: unfocus()
1549 void vtt_class :: set_x_input_parameter(tX_seqpar *sp)
1554 void vtt_class :: set_y_input_parameter(tX_seqpar *sp)
1559 void vtt_class :: xy_input(f_prec x_value, f_prec y_value)
1561 if (x_par) x_par->handle_mouse_input(x_value*globals.mouse_speed);
1562 if (y_par) y_par->handle_mouse_input(y_value*globals.mouse_speed);
1565 #define store(data); if (fwrite((void *) &data, sizeof(data), 1, output)!=1) res+=1;
1567 int vtt_class :: save(FILE *rc, char *indent) {
1568 list <vtt_fx *> :: iterator effect;
1569 char tmp_xml_buffer[4096];
1573 fprintf(rc, "%s<turntable>\n", indent);
1574 strcat(indent, "\t");
1576 store_string("name", name);
1578 store_string("audiofile", filename);
1580 store_string("audiofile", "");
1582 store_bool("sync_master", is_sync_master);
1583 store_bool("autotrigger", autotrigger);
1584 store_bool_sp("loop", loop, sp_loop);
1586 store_bool_sp("sync_client", is_sync_client, sp_sync_client);
1587 store_int_sp("sync_cycles", sync_cycles, sp_sync_cycles);
1589 store_float_sp("volume", rel_volume, sp_volume);
1590 store_float_sp("pitch", rel_pitch, sp_pitch);
1591 store_bool_sp("mute", mute, sp_mute);
1592 store_float_sp("pan", pan, sp_pan);
1594 store_bool_sp("lowpass_enable", lp_enable, sp_lp_enable);
1595 store_float_sp("lowpass_gain", lp_gain, sp_lp_gain);
1596 store_float_sp("lowpass_reso", lp_reso, sp_lp_reso);
1597 store_float_sp("lowpass_freq", lp_freq, sp_lp_freq);
1599 store_bool_sp("echo_enable", ec_enable, sp_ec_enable);
1600 store_float_sp("echo_length", ec_length, sp_ec_length);
1601 store_float_sp("echo_feedback", ec_feedback, sp_ec_feedback);
1602 store_float_sp("echo_pan", ec_pan, sp_ec_pan);
1603 store_float_sp("echo_volume", ec_volume, sp_ec_volume);
1605 store_id("speed", sp_speed.get_persistence_id());
1606 store_id("trigger", sp_trigger.get_persistence_id());
1607 store_id("spin", sp_spin.get_persistence_id());
1611 store_int("x_axis_mapping", x_par->get_persistence_id());
1615 store_int("y_axis_mapping", y_par->get_persistence_id());
1618 store_bool("audio_panel_hidden", audio_hidden);
1619 store_bool("control_panel_hidden", control_hidden);
1620 store_bool("main_panel_hidden", gui.main_panel->is_hidden());
1621 store_bool("trigger_panel_hidden", gui.trigger_panel->is_hidden());
1622 store_bool("lowpass_panel_hidden", gui.lp_panel->is_hidden());
1623 store_bool("echo_panel_hidden", gui.ec_panel->is_hidden());
1625 store_float("audio_x_zoom", gui_get_audio_x_zoom(this));
1627 fprintf(rc, "%s<fx>\n", indent);
1628 strcat(indent, "\t");
1630 for (effect=fx_list.begin(); effect!=fx_list.end(); effect++) {
1631 (*effect)->save(rc, indent);
1633 indent[strlen(indent)-1]=0;
1634 fprintf(rc, "%s</fx>\n", indent);
1636 indent[strlen(indent)-1]=0;
1637 fprintf(rc, "%s</turntable>\n", indent);
1642 #define TX_XML_SETFILE_VERSION "1.0"
1644 int vtt_class :: save_all(FILE* rc) {
1646 list <vtt_class *> :: iterator vtt;
1649 tX_seqpar :: create_persistence_ids();
1651 fprintf(rc, "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>\n\n");
1652 fprintf(rc, "<terminatorXset version=\"%s\">\n", TX_XML_SETFILE_VERSION);
1654 strcpy(indent, "\t");
1656 //store_int(vtt_amount); obsolete
1658 store_float_sp("master_volume", master_volume, sp_master_volume);
1659 store_float_sp("master_pitch", globals.pitch, sp_master_pitch);
1661 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++) {
1662 res+=(*vtt)->save(rc, indent);
1665 sequencer.save(rc, indent);
1667 fprintf(rc, "</terminatorXset>\n");
1672 int vtt_class :: load(xmlDocPtr doc, xmlNodePtr node) {
1683 for (xmlNodePtr cur=node->xmlChildrenNode; cur != NULL; cur = cur->next) {
1684 if (cur->type == XML_ELEMENT_NODE) {
1687 restore_string_ac("name", buffer, set_name(buffer));
1688 restore_string("audiofile", filename);
1689 restore_bool("sync_master", is_sync_master);
1690 restore_bool("autotrigger", autotrigger);
1691 restore_bool_id("loop", loop, sp_loop, nop);
1692 restore_bool_id("sync_client", is_sync_client, sp_sync_client, set_sync_client(is_sync_client, sync_cycles));
1693 restore_int_id("sync_cycles", sync_cycles, sp_sync_cycles, set_sync_client(is_sync_client, sync_cycles));
1694 restore_float_id("volume", rel_volume, sp_volume, recalc_volume());
1695 restore_float_id("pitch", rel_pitch, sp_pitch, recalc_pitch());
1696 restore_bool_id("mute", mute, sp_mute, set_mute(mute));
1697 restore_float_id("pan", pan, sp_pan, set_pan(pan));
1699 restore_bool_id("lowpass_enable", lp_enable, sp_lp_enable, lp_set_enable(lp_enable));
1700 restore_float_id("lowpass_gain", lp_gain, sp_lp_gain, lp_set_gain(lp_gain));
1701 restore_float_id("lowpass_reso", lp_reso, sp_lp_reso, lp_set_reso(lp_reso));
1702 restore_float_id("lowpass_freq", lp_freq, sp_lp_freq, lp_set_freq(lp_freq));
1704 restore_bool_id("echo_enable", ec_enable, sp_ec_enable, ec_set_enable(ec_enable));
1705 restore_float_id("echo_length", ec_length, sp_ec_length, ec_set_length(ec_length));
1706 restore_float_id("echo_feedback", ec_feedback, sp_ec_feedback, ec_set_feedback(ec_feedback));
1707 restore_float_id("echo_pan", ec_pan, sp_ec_pan, ec_set_pan(ec_pan));
1708 restore_float_id("echo_volume", ec_volume, sp_ec_volume, ec_set_volume(ec_volume));
1710 restore_id("speed", sp_speed);
1711 restore_id("trigger", sp_trigger);
1712 restore_id("spin", sp_spin);
1714 restore_int("x_axis_mapping", xpar_id);
1715 restore_int("y_axis_mapping", ypar_id);
1717 restore_bool("audio_panel_hidden", audio_hidden);
1718 restore_bool("control_panel_hidden", control_hidden);
1719 restore_bool_ac("main_panel_hidden", hidden, gui.main_panel->hide(hidden));
1720 restore_bool_ac("trigger_panel_hidden", hidden, gui.trigger_panel->hide(hidden));
1721 restore_bool_ac("lowpass_panel_hidden", hidden, gui.lp_panel->hide(hidden));
1722 restore_bool_ac("echo_panel_hidden", hidden, gui.ec_panel->hide(hidden));
1723 restore_float_ac("audio_x_zoom", tmp, gui_set_audio_x_zoom(this,tmp));
1724 vg_adjust_zoom(gui.zoom, this);
1726 if (xmlStrcmp(cur->name, (xmlChar *) "fx")==0) {
1730 for (xmlNodePtr cur=fx->xmlChildrenNode; cur != NULL; cur = cur->next) {
1731 if (cur->type == XML_ELEMENT_NODE) {
1734 if (xmlStrcmp(cur->name, (xmlChar *) "cutoff")==0) {
1735 for (unsigned int t=0; t<fx_list.size(); t++) effect_down(lp_fx);
1737 } else if (xmlStrcmp(cur->name, (xmlChar *) "lowpass")==0) {
1738 for (unsigned int t=0; t<fx_list.size(); t++) effect_down(ec_fx);
1740 } else if (xmlStrcmp(cur->name, (xmlChar *) "ladspa_plugin")==0) {
1741 xmlNodePtr pluginNode=cur;
1745 for (xmlNodePtr cur=pluginNode->xmlChildrenNode; cur!=NULL; cur = cur->next) {
1747 if (cur->type == XML_ELEMENT_NODE) {
1750 restore_int("ladspa_id", ladspa_id);
1751 if (elementFound) break;
1755 if (ladspa_id!=-1) {
1756 LADSPA_Plugin *plugin=LADSPA_Plugin::getPluginByUniqueID(ladspa_id);
1758 vtt_fx_ladspa *ladspa_effect=add_effect(plugin);
1759 ladspa_effect->load(doc, pluginNode);
1761 sprintf(buffer,"The terminatorX set file you are loading makes use of a LADSPA plugin that is not installed on this machine. The plugin's ID is [%i].", ladspa_id);
1762 tx_note(buffer, true);
1765 tX_warning("ladspa_plugin section without a ladspa_id element.");
1769 tX_warning("unhandled element %s in fx section.", cur->name);
1776 tX_warning("unhandled element %s in turntable secion.", cur->name);
1784 set_x_input_parameter(tX_seqpar :: get_sp_by_persistence_id(xpar_id));
1786 else set_x_input_parameter(NULL);
1789 set_y_input_parameter(tX_seqpar :: get_sp_by_persistence_id(ypar_id));
1791 else set_y_input_parameter(NULL);
1797 int vtt_class :: load_all(xmlDocPtr doc, char *fname) {
1798 xmlNodePtr root=xmlDocGetRootElement(doc);
1809 tX_error("no root element? What kind of XML document is this?");
1813 if (xmlStrcmp(root->name, (const xmlChar *) "terminatorXset")) {
1814 tX_error("this is not a terminatorXset file.")
1818 if (xmlGetProp(root,(xmlChar *) "version")==NULL) {
1819 tX_error("the set file lacks a version attribute.");
1823 if (xmlStrcmp(xmlGetProp(root, (xmlChar *) "version"), (xmlChar *) TX_XML_SETFILE_VERSION)) {
1824 tX_warning("this set file is version %s - while this releases uses version %s - trying to load anyway.", xmlGetProp(root, (xmlChar *) "version"), TX_XML_SETFILE_VERSION);
1827 /* delete current tables... */
1828 while (main_list.size()) {
1829 delete((*main_list.begin()));
1834 /* counting turntables.. */
1835 for (xmlNodePtr cur=root->xmlChildrenNode; cur != NULL; cur = cur->next) {
1836 if (cur->type == XML_ELEMENT_NODE) {
1837 if (xmlStrcmp(cur->name, (xmlChar *) "turntable")==0) {
1843 tX_debug("Found %i turntables in set.", table_ctr);
1845 ld_create_loaddlg(TX_LOADDLG_MODE_MULTI, table_ctr);
1846 ld_set_setname(fname);
1849 for (xmlNodePtr cur=root->xmlChildrenNode; cur != NULL; cur = cur->next) {
1850 if (cur->type == XML_ELEMENT_NODE) {
1853 restore_float_id("master_volume", master_volume, sp_master_volume, set_master_volume(master_volume));
1854 restore_float_id("master_pitch", globals.pitch, sp_master_pitch, set_master_pitch(globals.pitch));
1856 if ((!elementFound) && (xmlStrcmp(cur->name, (xmlChar *) "turntable")==0)) {
1858 vtt_class *vtt=new vtt_class(1);
1859 vtt->load(doc, cur);
1861 tX_debug("loading a turntable..");
1863 if (strlen(vtt->filename)) {
1864 strcpy(fn_buff, vtt->filename);
1865 ld_set_filename(fn_buff);
1867 restmp=(int) vtt->load_file(fn_buff);
1871 gtk_box_pack_start(GTK_BOX(control_parent), vtt->gui.control_box, TRUE, TRUE, 0);
1872 gtk_box_pack_start(GTK_BOX(audio_parent), vtt->gui.audio_box, TRUE, TRUE, 0);
1873 if (vtt->audio_hidden) vtt->hide_audio(vtt->audio_hidden);
1874 if (vtt->control_hidden) vtt->hide_control(vtt->control_hidden);
\r
1876 if ((!elementFound) && (xmlStrcmp(cur->name, (xmlChar *) "sequencer")==0)) {
1878 sequencer.load(doc, cur);
1880 if (!elementFound) {
1881 tX_warning("unhandled element %s in setfile %s", cur->name, fname);
1891 void add_vtt(GtkWidget *ctrl, GtkWidget *audio, char *fn)
1894 hmmpg = new vtt_class(1);
1895 gtk_box_pack_start(GTK_BOX(ctrl), hmmpg->gui.control_box, TRUE, TRUE, 0);
1896 gtk_box_pack_start(GTK_BOX(audio), hmmpg->gui.audio_box, TRUE, TRUE, 0);
1897 if (fn) hmmpg->load_file(fn);
1900 extern void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt);
1901 extern void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt);
1903 //#define debug_fx_stack(); for (i=fx_list.begin(); i != fx_list.end(); i++) puts((*i)->get_info_string());
1904 #define debug_fx_stack();
1906 void vtt_class :: effect_up(vtt_fx *effect)
1908 list <vtt_fx *> :: iterator i;
1909 list <vtt_fx *> :: iterator previous;
1914 if ((*fx_list.begin())==effect) return;
1916 for (previous=i=fx_list.begin(); i != fx_list.end(); i++)
1928 pthread_mutex_lock(&render_lock);
1929 fx_list.remove(effect);
1930 fx_list.insert(previous, effect);
1931 pthread_mutex_unlock(&render_lock);
1933 vg_move_fx_panel_up(effect->get_panel_widget(), this);
1939 void vtt_class :: effect_down(vtt_fx *effect)
1941 list <vtt_fx *> :: iterator i;
1946 for (i=fx_list.begin(); i != fx_list.end(); i++)
1955 if ((ok) && (i!=fx_list.end()))
1958 if (i==fx_list.end()) return;
1961 pthread_mutex_lock(&render_lock);
1962 fx_list.remove(effect);
1964 fx_list.insert(i, effect);
1965 vg_move_fx_panel_down(effect->get_panel_widget(), this);
1966 pthread_mutex_unlock(&render_lock);
1972 void vtt_class :: effect_remove(vtt_fx_ladspa *effect)
1974 pthread_mutex_lock(&render_lock);
1975 fx_list.remove(effect);
1976 pthread_mutex_unlock(&render_lock);
1981 extern void gui_hide_control_panel(vtt_class *vtt, bool hide);
1982 extern void gui_hide_audio_panel(vtt_class *vtt, bool hide);
1984 void vtt_class :: hide_audio(bool hide) {
1986 gui_hide_audio_panel(this, hide);
1989 void vtt_class :: hide_control(bool hide) {
1990 control_hidden=hide;
1991 gui_hide_control_panel(this, hide);
1994 void vtt_class :: set_sample_rate(int samplerate) {
1995 list <vtt_class *> :: iterator vtt;
1996 double sr=(double) samplerate;
1998 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
1999 if ((*vtt)->audiofile) {
2000 double file_rate=(*vtt)->audiofile->get_sample_rate();
2001 (*vtt)->audiofile_pitch_correction=file_rate/sr;
2003 (*vtt)->audiofile_pitch_correction=1.0;
2005 (*vtt)->recalc_pitch();