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);
77 int vtt_class::last_sample_rate=44100;
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;
99 int vtt_class::mix_buffer_size=0;
101 #define GAIN_AUTO_ADJUST 0.8
103 vtt_class :: vtt_class (int do_create_gui)
106 sprintf (name, "Turntable %i", vtt_amount);
107 strcpy(filename, "NONE");
127 lp_setup(lp_gain, lp_reso, lp_freq);
138 main_list.push_back(this);
140 /* "connecting" the seq-parameters */
142 sp_speed.set_vtt((void *) this);
143 sp_volume.set_vtt((void *) this);
144 sp_pitch.set_vtt((void *) this);
145 sp_pan.set_vtt((void *) this);
146 sp_trigger.set_vtt((void *) this);
147 sp_loop.set_vtt((void *) this);
148 sp_sync_client.set_vtt((void *) this);
149 sp_sync_cycles.set_vtt((void *) this);
150 sp_lp_enable.set_vtt((void *) this);
151 sp_lp_gain.set_vtt((void *) this);
152 sp_lp_reso.set_vtt((void *) this);
153 sp_lp_freq.set_vtt((void *) this);
154 sp_ec_enable.set_vtt((void *) this);
155 sp_ec_length.set_vtt((void *) this);
156 sp_ec_pan.set_vtt((void *) this);
157 sp_ec_volume.set_vtt((void *) this);
158 sp_ec_feedback.set_vtt((void *) this);
159 sp_mute.set_vtt((void *) this);
160 sp_spin.set_vtt((void *) this);
165 lp_fx=new vtt_fx_lp();
166 lp_fx->set_vtt((void *) this);
167 fx_list.push_back(lp_fx);
169 ec_fx=new vtt_fx_ec();
170 ec_fx->set_vtt((void *) this);
171 fx_list.push_back(ec_fx);
176 lp_fx->set_panel_widget(gui.lp_panel->get_widget());
177 ec_fx->set_panel_widget(gui.ec_panel->get_widget());
182 set_master_volume(globals.volume);
183 set_output_buffer_size(samples_in_mix_buffer/2);
186 audiofile_pitch_correction=0;
193 control_hidden=false;
\r
196 vtt_class :: ~vtt_class()
201 main_list.remove(this);
202 if (audiofile) delete audiofile;
203 //if (buffer) free(buffer);
204 if (output_buffer) tX_freemem(output_buffer, "output_buffer", "vtt Destructor");
207 while (fx_list.size())
209 effect=(*fx_list.begin());
210 fx_list.remove(effect);
217 void vtt_class :: set_name(char *newname)
219 strcpy(name, newname);
220 gui_set_name(this, name);
223 tX_audio_error vtt_class :: load_file(char *fname)
226 int was_playing=is_playing;
228 if (is_playing) stop();
230 if (audiofile) delete(audiofile);
237 audiofile=new tx_audiofile();
238 res=audiofile->load(fname);
240 if (res==TX_AUDIO_SUCCESS) {
241 buffer=audiofile->get_buffer();
242 double file_rate=audiofile->get_sample_rate();
243 audiofile_pitch_correction=file_rate/44100.0;
245 samples_in_buffer=audiofile->get_no_samples();
246 maxpos=audiofile->get_no_samples();
247 strcpy(filename, fname);
248 if (was_playing) trigger();
249 // printf("Successfully loaded %s, %08x, %i\n", fname, buffer, samples_in_buffer);
254 gui_update_display(this);
256 ec_set_length(ec_length);
261 int vtt_class :: set_output_buffer_size(int newsize)
263 list <vtt_fx *> :: iterator effect;
265 if (ec_output_buffer) tX_freemem(ec_output_buffer, "ec_output_buffer", "vtt set_output_buffer_size()");
266 tX_malloc(ec_output_buffer, "ec_output_buffer", "vtt set_output_buffer_size()", sizeof(float)*newsize, (float *));
268 if (output_buffer) tX_freemem(output_buffer, "output_buffer", "vtt set_output_buffer_size()");
269 tX_malloc(output_buffer, "output_buffer", "vtt set_output_buffer_size()", sizeof(float)*newsize, (float *));
271 end_of_outputbuffer = output_buffer + newsize; //size_t(sizeof(float)*(newsize));
273 samples_in_outputbuffer=newsize;
274 inv_samples_in_outputbuffer=1.0/samples_in_outputbuffer;
276 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
278 (*effect)->reconnect_buffer();
281 if (output_buffer) return(0);
285 void vtt_class :: set_volume(f_prec newvol)
291 void vtt_class :: recalc_volume()
293 res_volume=rel_volume*res_master_volume;
294 f_prec ec_res_volume=res_volume*ec_volume;
298 res_volume_left=(1.0-pan)*res_volume;
299 res_volume_right=res_volume;
303 res_volume_left=res_volume;
304 res_volume_right=(1.0+pan)*res_volume;
308 res_volume_left=res_volume_right=res_volume;
313 ec_volume_left=(1.0-ec_pan)*ec_res_volume;
314 ec_volume_right=ec_res_volume;
318 ec_volume_left=ec_res_volume;
319 ec_volume_right=(1.0+ec_pan)*ec_res_volume;
323 ec_volume_left=ec_volume_right=ec_res_volume;
325 // printf("vtt_volume: %f, %f, l: %f, r: %f\n", rel_volume, res_volume, res_volume_left, res_volume_right);
328 mm_res_volume.s[0]=mm_res_volume.s[1]=res_volume;
332 void vtt_class :: set_pan(f_prec newpan)
338 void vtt_class :: set_pitch(f_prec newpitch)
341 res_pitch=globals.pitch*rel_pitch;
343 ec_set_length(ec_length);
346 void vtt_class :: recalc_pitch()
348 res_pitch=globals.pitch*rel_pitch;
349 res_pitch*=audiofile_pitch_correction;
351 ec_set_length(ec_length);
354 void vtt_class :: set_autotrigger(int newstate)
356 autotrigger=newstate;
359 void vtt_class :: set_loop(int newstate)
364 void vtt_class :: set_mute(int newstate)
370 void vtt_class :: set_mix_mute(int newstate)
376 void vtt_class :: set_mix_solo(int newstate)
378 if (mix_solo && !newstate)
384 else if (!mix_solo && newstate)
393 list <vtt_class *> :: iterator vtt;
395 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++)
401 void vtt_class :: lp_set_enable (int newstate)
407 void vtt_class :: lp_reset()
412 void vtt_class :: lp_set_gain (f_prec gain)
415 lp_resgain=lp_gain*lp_autogain;
418 void vtt_class :: lp_set_reso(f_prec reso)
422 lp_b=reso*(1.0+(1.0/lp_a));
423 lp_autogain=1.0-reso*GAIN_AUTO_ADJUST;
424 lp_resgain=lp_gain*lp_autogain;
427 void vtt_class :: lp_set_freq(f_prec freq)
432 lp_b=lp_reso*(1.0+(1.0/lp_a));
435 void vtt_class :: lp_setup(f_prec gain, f_prec reso, f_prec freq)
441 lp_b=reso*(1.0+(1.0/lp_a));
443 lp_autogain=1.0-reso*GAIN_AUTO_ADJUST;
444 lp_resgain=lp_gain*lp_autogain;
447 void vtt_class :: ec_set_enable(int newstate)
454 void vtt_class :: ec_set_pan(f_prec pan)
461 /* Max length is 1.0 */
463 void vtt_class :: ec_set_length(f_prec length)
470 ec_res_length=length*samples_in_buffer;
474 ec_res_length=length*samples_in_buffer/res_pitch;
477 if (ec_res_length<0) ec_res_length*=-1;
479 if (ec_res_length>=EC_MAX_BUFFER)
481 ec_res_length=EC_MAX_BUFFER*length;
484 delay=(int )floor(ec_res_length);
486 ec_delay=&ec_buffer[delay];
489 void vtt_class :: ec_set_feedback(f_prec feedback)
491 ec_feedback=feedback;
495 void vtt_class :: ec_set_volume(f_prec volume)
501 void vtt_class :: ec_clear_buffer()
505 for (ptr=ec_buffer; ptr<=ec_delay; ptr++)
512 void vtt_class :: render()
514 list <vtt_fx *> :: iterator effect;
521 if (sense_cycles==0) sp_speed.receive_input_value(0);
526 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
528 if ((*effect)->isEnabled()) (*effect)->run();
532 extern void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin);
534 vtt_fx_ladspa * vtt_class :: add_effect (LADSPA_Plugin *plugin)
536 vtt_fx_ladspa *new_effect;
538 new_effect = new vtt_fx_ladspa (plugin, this);
539 pthread_mutex_lock(&render_lock);
540 fx_list.push_back(new_effect);
541 if (is_playing) new_effect->activate();
542 pthread_mutex_unlock(&render_lock);
543 vg_create_fx_gui(this, new_effect, plugin);
548 void vtt_class :: calc_speed()
554 if (speed != speed_target)
557 speed_step=speed_target-speed_real;
561 if (speed_target != speed_real)
563 speed_real+=speed_step;
564 if ((speed_step<0) && (speed_real<speed_target)) speed_real=speed_target;
566 if ((speed_step>0) && (speed_real>speed_target)) speed_real=speed_target;
571 if ((speed_last==0) && (speed_real !=0))
579 if ((speed_last!=0) && (speed_real==0))
586 speed_last = speed_real;
588 if (res_mute != res_mute_old)
592 fade_out=1; fade_in=0;
597 fade_in=1; fade_out=0;
600 res_mute_old=res_mute;
604 if (res_mute) do_mute=1;
608 void vtt_class :: render_scratch()
629 for (sample =0,out=output_buffer, fade_vol=0.0; sample < samples_in_outputbuffer;sample++, out++, fade_vol+=inv_samples_in_outputbuffer)
631 if ((speed_real!=0) || (fade_out))
646 master_triggered_at=sample;
666 master_triggered_at=sample;
676 pos_a_f=floor(pos_f);
677 pos_i=(unsigned int) pos_a_f;
679 amount_b=pos_f-pos_a_f;
680 amount_a=1.0-amount_b;
689 sample_a=(f_prec) *ptr;
691 if (pos_i == samples_in_buffer)
698 sample_b=(f_prec) *ptr;
701 sample_res=(sample_a*amount_a)+(sample_b*amount_b);
705 sample_res*=fade_vol;
710 sample_res*=1.0-fade_vol;
723 void vtt_class :: forward_turntable()
734 if ((speed_real==0) && (!fade_out)) return;
737 /* following code is problematic as adding speed_real*n is
738 different from adding speed_real n times to pos_f.
740 well it speeds things up quite a bit and double precision
741 seems to do a satisfying job.
743 #define pos_f_test to prove that.
746 pos_f_tmp=pos_f+speed_real*samples_in_outputbuffer;
748 if ((pos_f_tmp > 0) && (pos_f_tmp < maxpos))
758 /* now the slow way ;) */
760 for (sample =0; sample < samples_in_outputbuffer; sample++)
774 master_triggered_at=sample;
794 master_triggered_at=sample;
808 diff=pos_f_tmp-pos_f;
809 if (diff!=0) printf("fast: %f, slow: %f, diff: %f, tt: %s\n", pos_f_tmp, pos_f, diff, name);
815 The following lowpass filter is based on some sample code by
816 Paul Kellett <paul.kellett@maxim.abel.co.uk>
819 void vtt_class :: render_lp()
823 for (sample = output_buffer; sample<end_of_outputbuffer; sample++)
825 lp_buf0 = lp_a * lp_buf0 + lp_freq * ((*sample)*lp_resgain + lp_b * (lp_buf0 - lp_buf1));
826 lp_buf1 = lp_a * lp_buf1 + lp_freq * lp_buf0;
832 void vtt_class :: render_ec()
838 for (i=0, sample = output_buffer, ec_sample=ec_output_buffer; i<samples_in_outputbuffer; i++, ec_sample++,sample++, ec_ptr++)
840 if (ec_ptr>ec_delay) ec_ptr=ec_buffer;
841 *ec_sample=(*ec_ptr) *ec_feedback;
842 *ec_ptr=*sample+*ec_sample;
846 int vtt_class :: set_mix_buffer_size(int no_samples)
848 list <vtt_class *> :: iterator vtt;
851 // printf("vtt_class::set_mix_buffer_size(), mix_buffer: %12x, mix_out: %12x, samples: %i\n", mix_buffer, mix_out_buffer, no_samples);
853 if (mix_buffer) tX_freemem(mix_buffer, "mix_buffer", "vtt set_mix_buffer_size()");
854 samples_in_mix_buffer=no_samples*2;
856 tX_malloc(mix_buffer, "mix_buffer", "vtt set_mix_buffer_size()", sizeof(float)*samples_in_mix_buffer, (float *));
857 mix_buffer_end=mix_buffer+samples_in_mix_buffer;
859 // printf("mix_buffer: %12x\n", mix_buffer);
860 // printf("mix_samples: %i, out_samples: %i", samples_in_mix_buffer, no_samples);
862 if (mix_out_buffer) tX_freemem(mix_out_buffer, "mix_out_buffer", "vtt set_mix_buffer_size()");
863 tX_malloc(mix_out_buffer, "mix_out_buffer", "vtt set_mix_buffer_size()", sizeof(int16_t)*samples_in_mix_buffer + 4, (int16_t *));
865 // printf("mix_out_buffer: %12x\n", mix_out_buffer);
867 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
869 res|=(*vtt)->set_output_buffer_size(no_samples);
872 if ((!mix_buffer) || (!mix_out_buffer) || res) return(1);
874 mix_buffer_size=no_samples;
879 int16_t * vtt_class :: render_all_turntables()
881 list <vtt_class *> :: iterator vtt, next;
902 #ifndef OVERRIDE_MOVQ_AUTODETECT
904 #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
905 #endif /* GCC_VERSION */
907 #if (GCC_VERSION < 2096)
908 #warning "*************************"
909 #warning "* gcc < 2.96 *"
910 #warning "* assuming working movq *"
911 #warning "*************************"
912 #undef GCC_MOVQ_BUG_WORKAROUND
914 #warning "*************************"
915 #warning "* gcc >= 2.96 *"
916 #warning "* using movq-workaround *"
917 #warning "*************************"
918 #define GCC_MOVQ_BUG_WORKAROUND 1
919 #endif /* GCC < 2.96 */
920 #endif /* OVERRIDE MOVQ AUTODETECVT */
922 #ifdef GCC_MOVQ_BUG_WORKAROUND
923 /* REQUIRED DUE TO GCC BUG (2.96-3.0.2) */
924 mmx_t *mm_src1_ptr=&mm_src1;
925 mmx_t *mm_src2_ptr=&mm_src2;
926 mmx_t *mm_volume_ptr=&mm_volume;
927 mmx_t *mm_max_ptr=&mm_max;
928 mmx_t *mm_min_ptr=&mm_min;
930 #define MM_VAR_ACC(var) (* var ## _ptr)
931 #define MM_VAR_MOVQ(var) * var ## _ptr
933 #define MM_VAR_ACC(var) var
934 #define MM_VAR_MOVQ(var) var
936 int32_t *temp_int=&mm_max.d[1];
940 pthread_mutex_lock(&render_lock);
942 if (render_list.size()==0)
944 for (sample=0; sample<samples_in_mix_buffer; sample++)
946 mix_out_buffer[sample]=0;
951 vtt=render_list.begin();
953 max=(*vtt)->max_value;
957 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
959 temp=(*vtt)->output_buffer[sample];
960 mix_buffer[mix_sample]=temp*(*vtt)->res_volume_left;
962 mix_buffer[mix_sample]=temp*(*vtt)->res_volume_right;
965 if (temp>max) max=temp;
966 else if (temp<min) min=temp;
969 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->res_volume_left;
970 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->res_volume_right;
972 MM_VAR_ACC(mm_max).s[1]=MM_VAR_ACC(mm_max).s[0]=max;
973 MM_VAR_ACC(mm_min).s[1]=MM_VAR_ACC(mm_min).s[0]=min;
975 movq_m2r(MM_VAR_MOVQ(mm_max), mm1);
976 movq_m2r(MM_VAR_MOVQ(mm_min), mm2);
978 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
980 mix=(mmx_t*)mix_buffer;
982 for (f_prec* src=(*vtt)->output_buffer; mix < (mmx_t*) mix_buffer_end;)
985 MM_VAR_ACC(mm_src1).s[0]=*src;
986 MM_VAR_ACC(mm_src1).s[1]=*src;
988 /* sample * l/r volume */
989 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
995 MM_VAR_ACC(mm_src2).s[0]=*src;
996 MM_VAR_ACC(mm_src2).s[1]=*src;
998 /* sample * l/r volume */
999 movq_m2r(MM_VAR_MOVQ(mm_src2), mm3);
1000 pfmul_r2r(mm0, mm3);
1001 movq_r2m(mm3, *mix);
1003 /* calculating min/max */
1004 MM_VAR_ACC(mm_src1).s[1]=MM_VAR_ACC(mm_src2).s[0];
1005 movq_m2r(mm_src1, mm3);
1006 pfmax_r2r(mm3, mm1);
1007 pfmin_r2r(mm3, mm2);
1012 movq_r2m(mm1, MM_VAR_MOVQ(mm_max));
1013 movq_r2m(mm2, MM_VAR_MOVQ(mm_min));
1017 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];
1018 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];
1022 if (min>max) (*vtt)->max_value=min; else (*vtt)->max_value=max;
1024 if ((*vtt)->ec_enable)
1027 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1029 temp=(*vtt)->ec_output_buffer[sample];
1031 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_left;
1033 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_right;
1037 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->ec_volume_left;
1038 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->ec_volume_right;
1040 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1041 mix =(mmx_t*)mix_buffer;
1043 for (f_prec* src=(*vtt)->ec_output_buffer; mix < (mmx_t*) mix_buffer_end; src++, mix++)
1046 MM_VAR_ACC(mm_src1).s[0]=*src;
1047 MM_VAR_ACC(mm_src1).s[1]=*src;
1049 /* sample * l/r volume */
1050 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1051 pfmul_r2r(mm0, mm3);
1053 /* accumulating complete mix */
1054 movq_m2r(*mix, mm4);
1055 pfadd_r2r(mm4, mm3);
1056 movq_r2m(mm3, *mix);
1062 if (master_triggered)
1064 pthread_mutex_unlock(&render_lock);
1065 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1067 if ((*vtt)->is_sync_client)
1069 if ((*vtt)->sync_countdown)
1071 (*vtt)->sync_countdown--;
1075 (*vtt)->sync_countdown=(*vtt)->sync_cycles;
1080 pthread_mutex_lock(&render_lock);
1083 vtt=render_list.begin();
1084 for (vtt++; vtt!=render_list.end(); vtt++)
1087 max=(*vtt)->max_value;
1091 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1093 temp=(*vtt)->output_buffer[sample];
1094 mix_buffer[mix_sample]+=temp*(*vtt)->res_volume_left;
1096 mix_buffer[mix_sample]+=temp*(*vtt)->res_volume_right;
1099 if (temp>max) max=temp;
1100 else if (temp<min) min=temp;
1103 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->res_volume_left;
1104 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->res_volume_right;
1106 MM_VAR_ACC(mm_max).s[1]=MM_VAR_ACC(mm_max).s[0]=max;
1107 MM_VAR_ACC(mm_min).s[1]=MM_VAR_ACC(mm_min).s[0]=min;
1109 movq_m2r(MM_VAR_MOVQ(mm_max), mm1);
1110 movq_m2r(MM_VAR_MOVQ(mm_min), mm2);
1112 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1113 mix=(mmx_t*)mix_buffer;
1115 for (f_prec* src=(*vtt)->output_buffer; mix < (mmx_t*) mix_buffer_end;)
1118 MM_VAR_ACC(mm_src1).s[0]=*src;
1119 MM_VAR_ACC(mm_src1).s[1]=*src;
1121 /* sample * l/r volume */
1122 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1123 pfmul_r2r(mm0, mm3);
1125 /* accumulating complete mix */
1126 movq_m2r(*mix, mm4);
1127 pfadd_r2r(mm4, mm3);
1128 movq_r2m(mm3, *mix);
1132 MM_VAR_ACC(mm_src2).s[0]=*src;
1133 MM_VAR_ACC(mm_src2).s[1]=*src;
1135 /* sample * l/r volume */
1136 movq_m2r(MM_VAR_MOVQ(mm_src2), mm3);
1137 pfmul_r2r(mm0, mm3);
1139 /* accumulating complete mix */
1140 movq_m2r(*mix, mm4);
1141 pfadd_r2r(mm4, mm3);
1142 movq_r2m(mm3, *mix);
1144 /* calculating min/max */
1145 MM_VAR_ACC(mm_src1).s[1]=MM_VAR_ACC(mm_src2).s[0];
1146 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1147 pfmax_r2r(mm3, mm1);
1148 pfmin_r2r(mm3, mm2);
1153 movq_r2m(mm1, MM_VAR_MOVQ(mm_max));
1154 movq_r2m(mm2, MM_VAR_MOVQ(mm_min));
1158 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];
1159 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];
1163 if (min>max) (*vtt)->max_value=min; else (*vtt)->max_value=max;
1165 if ((*vtt)->ec_enable)
1168 for (sample=0, mix_sample=0; sample<(*vtt)->samples_in_outputbuffer; sample++)
1170 temp=(*vtt)->ec_output_buffer[sample];
1172 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_left;
1174 mix_buffer[mix_sample]+=temp*(*vtt)->ec_volume_right;
1178 MM_VAR_ACC(mm_volume).s[0]=(*vtt)->ec_volume_left;
1179 MM_VAR_ACC(mm_volume).s[1]=(*vtt)->ec_volume_right;
1181 movq_m2r(MM_VAR_MOVQ(mm_volume), mm0);
1182 mix =(mmx_t*)mix_buffer;
1184 for (f_prec* src=(*vtt)->ec_output_buffer; mix < (mmx_t*) mix_buffer_end; src++, mix++)
1187 MM_VAR_ACC(mm_src1).s[0]=*src;
1188 MM_VAR_ACC(mm_src1).s[1]=*src;
1190 /* sample * l/r volume */
1191 movq_m2r(MM_VAR_MOVQ(mm_src1), mm3);
1192 pfmul_r2r(mm0, mm3);
1194 /* accumulating complete mix */
1195 movq_m2r(*mix, mm4);
1196 pfadd_r2r(mm4, mm3);
1197 movq_r2m(mm3, *mix);
1210 for (sample=0; sample<samples_in_mix_buffer; sample+=2)
1212 temp=mix_buffer[sample];
1215 #define FL_SHRT_MAX 32767.0
1216 #define FL_SHRT_MIN -32768.0
1217 if(temp < FL_SHRT_MIN) temp = FL_SHRT_MIN;
1218 else if (temp > FL_SHRT_MAX) temp = FL_SHRT_MAX;
1221 mix_out_buffer[sample]=(int16_t) temp;
1223 if (temp>max) max=temp;
1224 else if (temp<min) min=temp;
1228 if (min>max) mix_max_l=min; else mix_max_l=max;
1235 for (sample=1; sample<samples_in_mix_buffer; sample+=2)
1237 temp=mix_buffer[sample];
1240 if(temp < FL_SHRT_MIN) temp = FL_SHRT_MIN;
1241 else if (temp > FL_SHRT_MAX) temp = FL_SHRT_MAX;
1244 mix_out_buffer[sample]=(int16_t) temp;
1246 if (temp>max) max=temp;
1247 else if (temp<min) min=temp;
1251 if (min>max) mix_max_r=min; else mix_max_r=max;
1256 vtt=render_list.begin();
1257 while (vtt!=render_list.end())
1262 if ((*vtt)->want_stop) (*vtt)->stop_nolock();
1265 pthread_mutex_unlock(&render_lock);
1267 return(mix_out_buffer);
1270 void vtt_class :: forward_all_turntables()
1272 list <vtt_class *> :: iterator vtt, next;
1274 if (render_list.size()>0)
1276 vtt=render_list.begin();
1277 (*vtt)->forward_turntable();
1279 if (master_triggered)
1281 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1283 if ((*vtt)->is_sync_client)
1285 if ((*vtt)->sync_countdown)
1287 (*vtt)->sync_countdown--;
1291 (*vtt)->sync_countdown=(*vtt)->sync_cycles;
1298 vtt=render_list.begin();
1299 for (vtt++; vtt!=render_list.end(); vtt++)
1301 (*vtt)->forward_turntable();
1306 vtt=render_list.begin();
1307 while (vtt!=render_list.end())
1312 if ((*vtt)->want_stop) (*vtt)->stop_nolock();
1318 int vtt_class :: trigger()
1320 list <vtt_fx *> :: iterator effect;
1322 if (!buffer) return (1);
1324 if (!is_playing) pthread_mutex_lock(&render_lock);
1326 if (res_pitch>=0) pos_f=0;
1330 speed_real=res_pitch;
1331 speed_target=res_pitch;
1334 /* activating plugins */
1335 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
1337 (*effect)->activate();
1348 master_triggered_at=0;
1357 render_list.push_front(this);
1361 render_list.push_back(this);
1363 pthread_mutex_unlock(&render_lock);
1368 int vtt_class :: stop_nolock()
1370 list <vtt_fx *> :: iterator effect;
1374 pthread_mutex_unlock(&render_lock);
1377 render_list.remove(this);
1388 /* deactivating plugins */
1389 for (effect=fx_list.begin(); effect != fx_list.end(); effect++)
1391 (*effect)->deactivate();
1397 int vtt_class :: stop()
1401 pthread_mutex_lock(&render_lock);
1405 pthread_mutex_unlock(&render_lock);
1410 void vtt_class :: set_sync_master(int master)
1414 if (sync_master) sync_master->set_sync_master(0);
1420 if (sync_master==this) sync_master=0;
1422 gui_clear_master_button(this);
1426 void vtt_class :: set_sync_client(int slave, int cycles)
1428 is_sync_client=slave;
1430 // sync_countdown=cycles;
1434 void vtt_class :: set_sync_client_ug(int slave, int cycles)
1436 set_sync_client(slave, cycles);
1439 void vtt_class :: set_master_volume(f_prec new_volume)
1441 list <vtt_class *> :: iterator vtt;
1443 master_volume=new_volume;
1444 globals.volume=new_volume;
1446 if (main_list.size()>0)
1448 vol_channel_adjust=sqrt((f_prec) main_list.size());
1449 res_master_volume=master_volume/vol_channel_adjust;
1452 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1454 (*vtt)->recalc_volume();
1458 void vtt_class :: set_master_pitch(f_prec new_pitch)
1460 list <vtt_class *> :: iterator vtt;
1462 globals.pitch=new_pitch;
1463 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++)
1465 (*vtt)->recalc_pitch();
1469 void vtt_class :: enable_saturate (int newstate)
1471 do_saturate=newstate;
1474 void vtt_class :: focus_no(int no)
1476 list <vtt_class *> :: iterator vtt;
1479 for (i=0, vtt=main_list.begin(); vtt!=main_list.end(); vtt++, i++)
1488 void vtt_class :: focus_next()
1490 list <vtt_class *> :: iterator vtt;
1494 if (main_list.size())
1496 focused_vtt=(*main_list.begin());
1501 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
1502 if ((*vtt)==focused_vtt) {
1503 /* Ok, we found ourselves.. */
1506 while ((vtt!=main_list.end()) && ((*vtt)->audio_hidden) ) {
1510 if (vtt==main_list.end()) {
1511 /* No other "focusable" after this vtt so we're looking for the next */
1513 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
1514 if (! (*vtt)->audio_hidden) {
1519 /* When we get here there's no "focusable" vtt at all... damn */
1529 focused_vtt=(*main_list.begin());
1532 void vtt_class :: set_scratch(int newstate)
1536 sp_spin.receive_input_value(0);
1538 sense_cycles=globals.sense_cycles;
1542 sp_spin.receive_input_value(1);
1548 void vtt_class :: unfocus()
1553 void vtt_class :: set_x_input_parameter(tX_seqpar *sp)
1558 void vtt_class :: set_y_input_parameter(tX_seqpar *sp)
1563 void vtt_class :: xy_input(f_prec x_value, f_prec y_value)
1565 if (x_par) x_par->handle_mouse_input(x_value*globals.mouse_speed);
1566 if (y_par) y_par->handle_mouse_input(y_value*globals.mouse_speed);
1569 #define store(data); if (fwrite((void *) &data, sizeof(data), 1, output)!=1) res+=1;
1571 int vtt_class :: save(FILE *rc, char *indent) {
1572 list <vtt_fx *> :: iterator effect;
1573 char tmp_xml_buffer[4096];
1577 fprintf(rc, "%s<turntable>\n", indent);
1578 strcat(indent, "\t");
1580 store_string("name", name);
1582 store_string("audiofile", filename);
1584 store_string("audiofile", "");
1586 store_bool("sync_master", is_sync_master);
1587 store_bool("autotrigger", autotrigger);
1588 store_bool_sp("loop", loop, sp_loop);
1590 store_bool_sp("sync_client", is_sync_client, sp_sync_client);
1591 store_int_sp("sync_cycles", sync_cycles, sp_sync_cycles);
1593 store_float_sp("volume", rel_volume, sp_volume);
1594 store_float_sp("pitch", rel_pitch, sp_pitch);
1595 store_bool_sp("mute", mute, sp_mute);
1596 store_float_sp("pan", pan, sp_pan);
1598 store_bool_sp("lowpass_enable", lp_enable, sp_lp_enable);
1599 store_float_sp("lowpass_gain", lp_gain, sp_lp_gain);
1600 store_float_sp("lowpass_reso", lp_reso, sp_lp_reso);
1601 store_float_sp("lowpass_freq", lp_freq, sp_lp_freq);
1603 store_bool_sp("echo_enable", ec_enable, sp_ec_enable);
1604 store_float_sp("echo_length", ec_length, sp_ec_length);
1605 store_float_sp("echo_feedback", ec_feedback, sp_ec_feedback);
1606 store_float_sp("echo_pan", ec_pan, sp_ec_pan);
1607 store_float_sp("echo_volume", ec_volume, sp_ec_volume);
1609 store_id("speed", sp_speed.get_persistence_id());
1610 store_id("trigger", sp_trigger.get_persistence_id());
1611 store_id("spin", sp_spin.get_persistence_id());
1615 store_int("x_axis_mapping", x_par->get_persistence_id());
1619 store_int("y_axis_mapping", y_par->get_persistence_id());
1622 store_bool("audio_panel_hidden", audio_hidden);
1623 store_bool("control_panel_hidden", control_hidden);
1624 store_bool("main_panel_hidden", gui.main_panel->is_hidden());
1625 store_bool("trigger_panel_hidden", gui.trigger_panel->is_hidden());
1626 store_bool("lowpass_panel_hidden", gui.lp_panel->is_hidden());
1627 store_bool("echo_panel_hidden", gui.ec_panel->is_hidden());
1629 store_float("audio_x_zoom", gui_get_audio_x_zoom(this));
1631 fprintf(rc, "%s<fx>\n", indent);
1632 strcat(indent, "\t");
1634 for (effect=fx_list.begin(); effect!=fx_list.end(); effect++) {
1635 (*effect)->save(rc, indent);
1637 indent[strlen(indent)-1]=0;
1638 fprintf(rc, "%s</fx>\n", indent);
1640 indent[strlen(indent)-1]=0;
1641 fprintf(rc, "%s</turntable>\n", indent);
1646 #define TX_XML_SETFILE_VERSION "1.0"
1648 int vtt_class :: save_all(FILE* rc) {
1650 list <vtt_class *> :: iterator vtt;
1653 tX_seqpar :: create_persistence_ids();
1655 fprintf(rc, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n");
1656 fprintf(rc, "<terminatorXset version=\"%s\">\n", TX_XML_SETFILE_VERSION);
1658 strcpy(indent, "\t");
1660 //store_int(vtt_amount); obsolete
1662 store_float_sp("master_volume", master_volume, sp_master_volume);
1663 store_float_sp("master_pitch", globals.pitch, sp_master_pitch);
1665 for (vtt=main_list.begin(); vtt!=main_list.end(); vtt++) {
1666 res+=(*vtt)->save(rc, indent);
1669 sequencer.save(rc, indent);
1671 fprintf(rc, "</terminatorXset>\n");
1676 int vtt_class :: load(xmlDocPtr doc, xmlNodePtr node) {
1686 char tmp_xml_buffer[4096];
1688 for (xmlNodePtr cur=node->xmlChildrenNode; cur != NULL; cur = cur->next) {
1689 if (cur->type == XML_ELEMENT_NODE) {
1692 restore_string_ac("name", buffer, set_name(buffer));
1693 restore_string("audiofile", filename);
1694 restore_bool("sync_master", is_sync_master);
1695 restore_bool("autotrigger", autotrigger);
1696 restore_bool_id("loop", loop, sp_loop, nop);
1697 restore_bool_id("sync_client", is_sync_client, sp_sync_client, set_sync_client(is_sync_client, sync_cycles));
1698 restore_int_id("sync_cycles", sync_cycles, sp_sync_cycles, set_sync_client(is_sync_client, sync_cycles));
1699 restore_float_id("volume", rel_volume, sp_volume, recalc_volume());
1700 restore_float_id("pitch", rel_pitch, sp_pitch, recalc_pitch());
1701 restore_bool_id("mute", mute, sp_mute, set_mute(mute));
1702 restore_float_id("pan", pan, sp_pan, set_pan(pan));
1704 restore_bool_id("lowpass_enable", lp_enable, sp_lp_enable, lp_set_enable(lp_enable));
1705 restore_float_id("lowpass_gain", lp_gain, sp_lp_gain, lp_set_gain(lp_gain));
1706 restore_float_id("lowpass_reso", lp_reso, sp_lp_reso, lp_set_reso(lp_reso));
1707 restore_float_id("lowpass_freq", lp_freq, sp_lp_freq, lp_set_freq(lp_freq));
1709 restore_bool_id("echo_enable", ec_enable, sp_ec_enable, ec_set_enable(ec_enable));
1710 restore_float_id("echo_length", ec_length, sp_ec_length, ec_set_length(ec_length));
1711 restore_float_id("echo_feedback", ec_feedback, sp_ec_feedback, ec_set_feedback(ec_feedback));
1712 restore_float_id("echo_pan", ec_pan, sp_ec_pan, ec_set_pan(ec_pan));
1713 restore_float_id("echo_volume", ec_volume, sp_ec_volume, ec_set_volume(ec_volume));
1715 restore_id("speed", sp_speed);
1716 restore_id("trigger", sp_trigger);
1717 restore_id("spin", sp_spin);
1719 restore_int("x_axis_mapping", xpar_id);
1720 restore_int("y_axis_mapping", ypar_id);
1722 restore_bool("audio_panel_hidden", audio_hidden);
1723 restore_bool("control_panel_hidden", control_hidden);
1724 restore_bool_ac("main_panel_hidden", hidden, gui.main_panel->hide(hidden));
1725 restore_bool_ac("trigger_panel_hidden", hidden, gui.trigger_panel->hide(hidden));
1726 restore_bool_ac("lowpass_panel_hidden", hidden, gui.lp_panel->hide(hidden));
1727 restore_bool_ac("echo_panel_hidden", hidden, gui.ec_panel->hide(hidden));
1728 restore_float_ac("audio_x_zoom", tmp, gui_set_audio_x_zoom(this,tmp));
1729 vg_adjust_zoom(gui.zoom, this);
1731 if (xmlStrcmp(cur->name, (xmlChar *) "fx")==0) {
1735 for (xmlNodePtr cur=fx->xmlChildrenNode; cur != NULL; cur = cur->next) {
1736 if (cur->type == XML_ELEMENT_NODE) {
1739 if (xmlStrcmp(cur->name, (xmlChar *) "cutoff")==0) {
1740 for (unsigned int t=0; t<fx_list.size(); t++) effect_down(lp_fx);
1742 } else if (xmlStrcmp(cur->name, (xmlChar *) "lowpass")==0) {
1743 for (unsigned int t=0; t<fx_list.size(); t++) effect_down(ec_fx);
1745 } else if (xmlStrcmp(cur->name, (xmlChar *) "ladspa_plugin")==0) {
1746 xmlNodePtr pluginNode=cur;
1750 for (xmlNodePtr cur=pluginNode->xmlChildrenNode; cur!=NULL; cur = cur->next) {
1752 if (cur->type == XML_ELEMENT_NODE) {
1755 restore_int("ladspa_id", ladspa_id);
1756 if (elementFound) break;
1760 if (ladspa_id!=-1) {
1761 LADSPA_Plugin *plugin=LADSPA_Plugin::getPluginByUniqueID(ladspa_id);
1763 vtt_fx_ladspa *ladspa_effect=add_effect(plugin);
1764 ladspa_effect->load(doc, pluginNode);
1766 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);
1767 tx_note(buffer, true);
1770 tX_warning("ladspa_plugin section without a ladspa_id element.");
1774 tX_warning("unhandled element %s in fx section.", cur->name);
1781 tX_warning("unhandled element %s in turntable secion.", cur->name);
1789 set_x_input_parameter(tX_seqpar :: get_sp_by_persistence_id(xpar_id));
1791 else set_x_input_parameter(NULL);
1794 set_y_input_parameter(tX_seqpar :: get_sp_by_persistence_id(ypar_id));
1796 else set_y_input_parameter(NULL);
1802 int vtt_class :: load_all(xmlDocPtr doc, char *fname) {
1803 xmlNodePtr root=xmlDocGetRootElement(doc);
1814 tX_error("no root element? What kind of XML document is this?");
1818 if (xmlStrcmp(root->name, (const xmlChar *) "terminatorXset")) {
1819 tX_error("this is not a terminatorXset file.")
1823 if (xmlGetProp(root,(xmlChar *) "version")==NULL) {
1824 tX_error("the set file lacks a version attribute.");
1828 if (xmlStrcmp(xmlGetProp(root, (xmlChar *) "version"), (xmlChar *) TX_XML_SETFILE_VERSION)) {
1829 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);
1832 /* delete current tables... */
1833 while (main_list.size()) {
1834 delete((*main_list.begin()));
1839 /* counting turntables.. */
1840 for (xmlNodePtr cur=root->xmlChildrenNode; cur != NULL; cur = cur->next) {
1841 if (cur->type == XML_ELEMENT_NODE) {
1842 if (xmlStrcmp(cur->name, (xmlChar *) "turntable")==0) {
1848 tX_debug("Found %i turntables in set.", table_ctr);
1850 ld_create_loaddlg(TX_LOADDLG_MODE_MULTI, table_ctr);
1851 ld_set_setname(fname);
1854 for (xmlNodePtr cur=root->xmlChildrenNode; cur != NULL; cur = cur->next) {
1855 if (cur->type == XML_ELEMENT_NODE) {
1858 restore_float_id("master_volume", master_volume, sp_master_volume, set_master_volume(master_volume));
1859 restore_float_id("master_pitch", globals.pitch, sp_master_pitch, set_master_pitch(globals.pitch));
1861 if ((!elementFound) && (xmlStrcmp(cur->name, (xmlChar *) "turntable")==0)) {
1863 vtt_class *vtt=new vtt_class(1);
1864 vtt->load(doc, cur);
1866 tX_debug("loading a turntable..");
1868 if (strlen(vtt->filename)) {
1869 strcpy(fn_buff, vtt->filename);
1870 ld_set_filename(fn_buff);
1872 restmp=(int) vtt->load_file(fn_buff);
1876 gtk_box_pack_start(GTK_BOX(control_parent), vtt->gui.control_box, TRUE, TRUE, 0);
1877 gtk_box_pack_start(GTK_BOX(audio_parent), vtt->gui.audio_box, TRUE, TRUE, 0);
1878 if (vtt->audio_hidden) vtt->hide_audio(vtt->audio_hidden);
1879 if (vtt->control_hidden) vtt->hide_control(vtt->control_hidden);
\r
1881 if ((!elementFound) && (xmlStrcmp(cur->name, (xmlChar *) "sequencer")==0)) {
1883 sequencer.load(doc, cur);
1885 if (!elementFound) {
1886 tX_warning("unhandled element %s in setfile %s", cur->name, fname);
1896 void add_vtt(GtkWidget *ctrl, GtkWidget *audio, char *fn)
1899 hmmpg = new vtt_class(1);
1900 gtk_box_pack_start(GTK_BOX(ctrl), hmmpg->gui.control_box, TRUE, TRUE, 0);
1901 gtk_box_pack_start(GTK_BOX(audio), hmmpg->gui.audio_box, TRUE, TRUE, 0);
1902 if (fn) hmmpg->load_file(fn);
1905 extern void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt);
1906 extern void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt);
1908 //#define debug_fx_stack(); for (i=fx_list.begin(); i != fx_list.end(); i++) puts((*i)->get_info_string());
1909 #define debug_fx_stack();
1911 void vtt_class :: effect_up(vtt_fx *effect)
1913 list <vtt_fx *> :: iterator i;
1914 list <vtt_fx *> :: iterator previous;
1919 if ((*fx_list.begin())==effect) return;
1921 for (previous=i=fx_list.begin(); i != fx_list.end(); i++)
1933 pthread_mutex_lock(&render_lock);
1934 fx_list.remove(effect);
1935 fx_list.insert(previous, effect);
1936 pthread_mutex_unlock(&render_lock);
1938 vg_move_fx_panel_up(effect->get_panel_widget(), this);
1944 void vtt_class :: effect_down(vtt_fx *effect)
1946 list <vtt_fx *> :: iterator i;
1951 for (i=fx_list.begin(); i != fx_list.end(); i++)
1960 if ((ok) && (i!=fx_list.end()))
1963 if (i==fx_list.end()) return;
1966 pthread_mutex_lock(&render_lock);
1967 fx_list.remove(effect);
1969 fx_list.insert(i, effect);
1970 vg_move_fx_panel_down(effect->get_panel_widget(), this);
1971 pthread_mutex_unlock(&render_lock);
1977 void vtt_class :: effect_remove(vtt_fx_ladspa *effect)
1979 pthread_mutex_lock(&render_lock);
1980 fx_list.remove(effect);
1981 pthread_mutex_unlock(&render_lock);
1986 extern void gui_hide_control_panel(vtt_class *vtt, bool hide);
1987 extern void gui_hide_audio_panel(vtt_class *vtt, bool hide);
1989 void vtt_class :: hide_audio(bool hide) {
1991 gui_hide_audio_panel(this, hide);
1994 void vtt_class :: hide_control(bool hide) {
1995 control_hidden=hide;
1996 gui_hide_control_panel(this, hide);
1999 void vtt_class :: set_sample_rate(int samplerate) {
2000 list <vtt_class *> :: iterator vtt;
2001 double sr=(double) samplerate;
2003 last_sample_rate=samplerate;
2005 for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
2006 if ((*vtt)->audiofile) {
2007 double file_rate=(*vtt)->audiofile->get_sample_rate();
2008 (*vtt)->audiofile_pitch_correction=file_rate/sr;
2010 (*vtt)->audiofile_pitch_correction=1.0;
2012 (*vtt)->recalc_pitch();
2015 int no_samples=(int) (sr*0.001); // Forcing 1 ms blocksize
2017 set_mix_buffer_size(no_samples);