Consistent samplerate handling for playback and recording - Alex
[terminatorX.git] / src / tX_vtt.cc
index 83570024665a60a99a581c80c2abff2d07aa7b45..40f3152f7118e4e4426602f3f68e7e52ebe141e2 100644 (file)
@@ -1,6 +1,6 @@
 /*
     terminatorX - realtime audio scratching software
-    Copyright (C) 1999-2002  Alexander König
+    Copyright (C) 1999-2003  Alexander König
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -1721,6 +1721,7 @@ int vtt_class :: load(xmlDocPtr doc, xmlNodePtr node) {
                        restore_bool_ac("lowpass_panel_hidden", hidden, gui.lp_panel->hide(hidden));                    
                        restore_bool_ac("echo_panel_hidden", hidden, gui.ec_panel->hide(hidden));
                        restore_float_ac("audio_x_zoom", tmp, gui_set_audio_x_zoom(this,tmp));
+                       vg_adjust_zoom(gui.zoom, this);
                        
                        if (xmlStrcmp(cur->name, (xmlChar *) "fx")==0) {
                                xmlNodePtr fx=cur;
@@ -1989,3 +1990,18 @@ void vtt_class :: hide_control(bool hide) {
        control_hidden=hide;
        gui_hide_control_panel(this, hide);     
 }
+
+void vtt_class :: set_sample_rate(int samplerate) {
+       list <vtt_class *> :: iterator vtt;
+       double sr=(double) samplerate;
+       
+       for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
+               if ((*vtt)->audiofile) {
+                       double file_rate=(*vtt)->audiofile->get_sample_rate();
+                       (*vtt)->audiofile_pitch_correction=file_rate/sr;
+               } else {
+                       (*vtt)->audiofile_pitch_correction=1.0;
+               }
+               (*vtt)->recalc_pitch();
+       }
+}