Fixes and results of some serious valgrinding - Alex
authorterminatorX <>
Sat, 12 Apr 2003 10:54:09 +0000 (10:54 +0000)
committerterminatorX <>
Sat, 12 Apr 2003 10:54:09 +0000 (10:54 +0000)
src/tX_audiodevice.cc
src/tX_audiodevice.h
src/tX_glade_interface.cc
src/tX_mastergui.cc
src/tX_midiin.cc
src/tX_midiin.h
src/tX_vtt.cc
src/tX_widget.c
terminatorX.glade
terminatorX.spec.in

index 1955e2453a81496aac5ec152b1983c5a0da0b28e..c03e8a03cde01feaccaff01a40e80184be905626 100644 (file)
@@ -60,6 +60,9 @@ void tX_audiodevice :: start() {
        sample_buffer[0]=new int16_t[samples_per_buffer*2];
        sample_buffer[1]=new int16_t[samples_per_buffer*2];
        int current=0;
+       vtt_buffer_size=vtt_class::get_mix_buffer_size()<<1;
+       
+       buffer_pos=0;
        
        while (!engine->is_stopped()) {
                current=current ? 0 : 1;
@@ -76,19 +79,16 @@ void tX_audiodevice :: start() {
 }
 
 void tX_audiodevice :: fill_buffer(int16_t *target_buffer, int16_t *next_target_buffer) {
-       int vtt_buffer_size=vtt_class::get_mix_buffer_size()<<1;
-       int prefill;
+       int prefill=0;
        
-       while (buffer_pos < samples_per_buffer) {
+       while (buffer_pos <= samples_per_buffer) {
                int16_t *data=engine->render_cycle();
                
-               int rest=samples_per_buffer-(buffer_pos+vtt_buffer_size);               
+               int rest=(buffer_pos+vtt_buffer_size)-samples_per_buffer;
                
-               if (rest>0) {
-                       memcpy(&target_buffer[buffer_pos], data, samples_per_buffer << 1);
+               if (rest<=0) {
+                       memcpy(&target_buffer[buffer_pos], data, vtt_buffer_size << 1);
                } else {
-                       rest*=-1;
-                                       
                        memcpy(&target_buffer[buffer_pos], data, (vtt_buffer_size-rest) << 1);
                        memcpy(next_target_buffer, &data[vtt_buffer_size-rest], rest << 1);
                        prefill=rest;
@@ -196,7 +196,6 @@ int tX_audiodevice_alsa :: open()
        char pcm_name[64];
        char foo[PATH_MAX];
        
-       snd_pcm_hw_params_alloca(&hw_params);   
        
        int card;
        int device;
@@ -206,9 +205,10 @@ int tX_audiodevice_alsa :: open()
        
        if (snd_pcm_open(&pcm_handle, pcm_name, stream, SND_PCM_NONBLOCK) < 0) {
                tX_error("ALSA: Failed to access PCM device \"%s\"", pcm_name);
-               snd_pcm_hw_params_free (hw_params);
                return -1;
        }
+
+       snd_pcm_hw_params_alloca(&hw_params);   
        
        if (snd_pcm_hw_params_any(pcm_handle, hw_params) < 0) {
                tX_error("ALSA: Failed to configure PCM device \"%s\"", pcm_name);
index 30da6c9c72136d669dcfc71c6a857aaea2f8c821..de15a733e7a2c99c229330939c9250d53d09171d 100644 (file)
@@ -46,6 +46,7 @@ class tX_audiodevice
        int16_t *sample_buffer[2];
        int current_buffer;
        int buffer_pos;
+       int vtt_buffer_size;
        tX_engine *engine;
        
        int sample_rate;
index 5877bf659c9a2a88bdf265be8cf7e8b82fb82202..c9e789a4632267968634afdab7a8cae0e94b516e 100644 (file)
@@ -719,17 +719,20 @@ create_tx_adjust (void)
   GtkWidget *dialog_vbox2;
   GtkWidget *vbox1;
   GtkWidget *label34;
-  GtkWidget *hbox3;
-  GtkWidget *label35;
+  GtkWidget *table7;
   GtkObject *master_cycles_adj;
   GtkWidget *master_cycles;
   GtkWidget *label36;
+  GtkWidget *label35;
   GtkObject *cycles_adj;
   GtkWidget *cycles;
   GtkWidget *create_event;
   GtkWidget *dialog_action_area2;
   GtkWidget *cancel;
   GtkWidget *ok;
+  GtkTooltips *tooltips;
+
+  tooltips = gtk_tooltips_new ();
 
   tx_adjust = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (tx_adjust), "Compute Pitch");
@@ -742,35 +745,46 @@ create_tx_adjust (void)
   gtk_box_pack_start (GTK_BOX (dialog_vbox2), vbox1, TRUE, TRUE, 0);
   gtk_container_set_border_width (GTK_CONTAINER (vbox1), 4);
 
-  label34 = gtk_label_new ("To compute the pitch value, please specify with how many cycles of the master turntable this turntable should be re-triggered:");
+  label34 = gtk_label_new ("In order to compute the optimum pitch value, please specify how many loops of this turntable should play as fast as how many loops of the masterturntable:");
   gtk_widget_show (label34);
   gtk_box_pack_start (GTK_BOX (vbox1), label34, FALSE, FALSE, 0);
   gtk_label_set_justify (GTK_LABEL (label34), GTK_JUSTIFY_LEFT);
   gtk_label_set_line_wrap (GTK_LABEL (label34), TRUE);
 
-  hbox3 = gtk_hbox_new (FALSE, 4);
-  gtk_widget_show (hbox3);
-  gtk_box_pack_start (GTK_BOX (vbox1), hbox3, FALSE, FALSE, 0);
-
-  label35 = gtk_label_new ("Master Cycles:");
-  gtk_widget_show (label35);
-  gtk_box_pack_start (GTK_BOX (hbox3), label35, FALSE, FALSE, 0);
-  gtk_label_set_justify (GTK_LABEL (label35), GTK_JUSTIFY_LEFT);
+  table7 = gtk_table_new (2, 2, FALSE);
+  gtk_widget_show (table7);
+  gtk_box_pack_start (GTK_BOX (vbox1), table7, TRUE, TRUE, 0);
+  gtk_table_set_col_spacings (GTK_TABLE (table7), 3);
 
   master_cycles_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
   master_cycles = gtk_spin_button_new (GTK_ADJUSTMENT (master_cycles_adj), 1, 0);
   gtk_widget_show (master_cycles);
-  gtk_box_pack_start (GTK_BOX (hbox3), master_cycles, TRUE, TRUE, 0);
+  gtk_table_attach (GTK_TABLE (table7), master_cycles, 1, 2, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, master_cycles, "Specify the number of loops for the master turntable.", NULL);
 
-  label36 = gtk_label_new ("Cycles:");
+  label36 = gtk_label_new ("Loops of the master turntable:");
   gtk_widget_show (label36);
-  gtk_box_pack_start (GTK_BOX (hbox3), label36, FALSE, FALSE, 0);
+  gtk_table_attach (GTK_TABLE (table7), label36, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
   gtk_label_set_justify (GTK_LABEL (label36), GTK_JUSTIFY_LEFT);
 
+  label35 = gtk_label_new ("Loops of this turntable turntable:");
+  gtk_widget_show (label35);
+  gtk_table_attach (GTK_TABLE (table7), label35, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_label_set_justify (GTK_LABEL (label35), GTK_JUSTIFY_LEFT);
+
   cycles_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
   cycles = gtk_spin_button_new (GTK_ADJUSTMENT (cycles_adj), 1, 0);
   gtk_widget_show (cycles);
-  gtk_box_pack_start (GTK_BOX (hbox3), cycles, TRUE, TRUE, 0);
+  gtk_table_attach (GTK_TABLE (table7), cycles, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, cycles, "Specify the number of loops of _this_ turntable.", NULL);
 
   create_event = gtk_check_button_new_with_mnemonic ("Record a sequencer event");
   gtk_widget_show (create_event);
@@ -796,15 +810,16 @@ create_tx_adjust (void)
   GLADE_HOOKUP_OBJECT_NO_REF (tx_adjust, dialog_vbox2, "dialog_vbox2");
   GLADE_HOOKUP_OBJECT (tx_adjust, vbox1, "vbox1");
   GLADE_HOOKUP_OBJECT (tx_adjust, label34, "label34");
-  GLADE_HOOKUP_OBJECT (tx_adjust, hbox3, "hbox3");
-  GLADE_HOOKUP_OBJECT (tx_adjust, label35, "label35");
+  GLADE_HOOKUP_OBJECT (tx_adjust, table7, "table7");
   GLADE_HOOKUP_OBJECT (tx_adjust, master_cycles, "master_cycles");
   GLADE_HOOKUP_OBJECT (tx_adjust, label36, "label36");
+  GLADE_HOOKUP_OBJECT (tx_adjust, label35, "label35");
   GLADE_HOOKUP_OBJECT (tx_adjust, cycles, "cycles");
   GLADE_HOOKUP_OBJECT (tx_adjust, create_event, "create_event");
   GLADE_HOOKUP_OBJECT_NO_REF (tx_adjust, dialog_action_area2, "dialog_action_area2");
   GLADE_HOOKUP_OBJECT (tx_adjust, cancel, "cancel");
   GLADE_HOOKUP_OBJECT (tx_adjust, ok, "ok");
+  GLADE_HOOKUP_OBJECT_NO_REF (tx_adjust, tooltips, "tooltips");
 
   return tx_adjust;
 }
index 21cfbf3ec659ab70b6a0161fe8a41789ea397c44..141c7ba6eae8d319e9d8006f96cac22ecc234212 100644 (file)
@@ -580,6 +580,8 @@ void mg_enable_critical_buttons(int enable)
 
 GtkSignalFunc seq_stop(GtkWidget *w, void *);
 
+static bool stop_override=false;
+
 GtkSignalFunc audio_on(GtkWidget *w, void *d)
 {
        tX_engine_error res;
@@ -589,11 +591,14 @@ GtkSignalFunc audio_on(GtkWidget *w, void *d)
                sequencer_ready=0;
                mg_enable_critical_buttons(0);
                res=tX_engine::get_instance()->run();
-               sequencer_ready=1;
 
                if (res!=NO_ERROR)
                {
                        mg_enable_critical_buttons(1);
+                       stop_override=true;
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), 0);
+                       stop_override=false;                    
+
                        switch(res)
                        {
                                case ERROR_BUSY:
@@ -607,9 +612,11 @@ GtkSignalFunc audio_on(GtkWidget *w, void *d)
                                break;
                                default:tx_note("Error starting engine: Unknown error.", true);
                        }
+                       
                        return 0;
                }
-
+               
+               sequencer_ready=1;
                stop_update=0;
                audioon=1;
                update_delay=globals.update_delay;
@@ -617,7 +624,8 @@ GtkSignalFunc audio_on(GtkWidget *w, void *d)
                gtk_widget_set_sensitive(grab_button, 1);
        }
        else
-       {               
+       {       
+               if (stop_override) return NULL;
                if (!sequencer_ready) return NULL;
                gtk_widget_set_sensitive(grab_button, 0);
                tX_engine::get_instance()->stop();
@@ -927,6 +935,7 @@ void create_master_menu() {
        menu_item = gtk_menu_item_new_with_mnemonic("_Add Turntable");
        gtk_widget_show (menu_item);
        gtk_container_add (GTK_CONTAINER (sub_menu), menu_item);
+       gtk_widget_add_accelerator (menu_item, "activate", accel_group, GDK_A, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);    
        g_signal_connect(menu_item, "activate", (GCallback) new_table, NULL);
 
        menu_item = gtk_check_menu_item_new_with_mnemonic("_Record Audio To Disk");
index e5cb2034fec43994cb385119c6049c1d9b8b45c4..d06f2e820f30a20f5bdbea0867d34dbdbdc1cbcc 100644 (file)
@@ -333,8 +333,6 @@ void tX_midiin::midi_binding_gui::close_clicked( GtkButton *button, gpointer _th
        tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
        
        gtk_widget_destroy( this_->window );
-
-       delete this_;
 }
 
 gint tX_midiin::midi_binding_gui::timer( gpointer _this )
index 1c574cba0d757ce2ee35b6396a213fe91f44fa75..dd16693b7254351314e22860fab0fca15b0367c5 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef _tx_midiin_h
 #define _tx_midiin_h 1
 
+#include <stdio.h>
+
 class vtt_class;
 
 class tX_midievent
@@ -57,7 +59,7 @@ class tX_midievent
                is_noteon = false;
        }
        
-       tX_midievent() : channel(0), type(NONE), value(0.0), is_noteon(false) {}
+       tX_midievent() : channel(0), type(NONE), number(0), value(0.0), is_noteon(false) {}
 };
 
 #include <config.h>
@@ -124,4 +126,4 @@ class tX_midiin
 
 #endif // USE_ALSA_MIDI_IN
 
-#endif // ndef _tx_midiin_h 
+#endif // ndef _tx_midiin_h
index 8fd7f0b97e22f841f0ce53dd95663d6c93c988d5..4aa6de6aac15a5cce155142e5fdc590da7f90c0d 100644 (file)
@@ -103,6 +103,15 @@ vtt_class :: vtt_class (int do_create_gui)
        strcpy(filename, "NONE");
        buffer=NULL;
        samples_in_buffer=0;
+
+       pan=0;
+       rel_pitch=1; 
+       ec_volume=1; 
+       ec_pan=1; 
+       audiofile_pitch_correction=1.0;
+       ec_length=1;
+       ec_output_buffer=NULL;
+       output_buffer=NULL;
        
        set_volume(1);
        set_pitch(1);
@@ -180,13 +189,18 @@ vtt_class :: vtt_class (int do_create_gui)
        
        audiofile = NULL;
        audiofile_pitch_correction=1.0;
+       mute=0;
        mix_solo=0;
        mix_mute=0;
        res_mute=mute;
        res_mute_old=0;
        
        audio_hidden=false;
-       control_hidden=false;\r
+       control_hidden=false;
+       
+       do_scratch=0;
+       speed_last=1;
+       speed_real=1;\r
 }
 
 vtt_class :: ~vtt_class()
@@ -1141,11 +1155,13 @@ int vtt_class :: trigger()
        return(0);
 }
 
+static bool do_unlock=true;
+
 int vtt_class :: stop_nolock()
 {
        list <vtt_fx *> :: iterator effect;
 
-       if (!is_playing) 
+       if ((!is_playing) && do_unlock)
        {
                pthread_mutex_unlock(&render_lock);
                return(1);
@@ -1174,8 +1190,12 @@ int vtt_class :: stop()
        
        pthread_mutex_lock(&render_lock);
 
+       do_unlock=false;
+       
        res=stop_nolock();
 
+       do_unlock=true;
+       
        pthread_mutex_unlock(&render_lock);
 
        return(res);
index 62d936194c5621bcb1efbe4851828439f605d2b2..0384b09f22370db1c27e079296f94fca0c736f53 100644 (file)
@@ -370,6 +370,7 @@ static void gtk_tx_update(GtkTx * tx) {
 
 void gtk_tx_prepare_pos_display(GtkTx * tx) {
        tx->cursor_pos=-1;
+       tx->lastmute=-1;
 }
 
 void gtk_tx_update_pos_display(GtkTx * tx, int sample, int mute) {
index 58271841ebedd0d8475a83e37881a5c585aedf19..9eaaeba09f2bc11881df593511b737fac35c4699 100644 (file)
          <child>
            <widget class="GtkLabel" id="label34">
              <property name="visible">True</property>
-             <property name="label" translatable="yes">To compute the pitch value, please specify with how many cycles of the master turntable this turntable should be re-triggered:</property>
+             <property name="label" translatable="yes">In order to compute the optimum pitch value, please specify how many loops of this turntable should play as fast as how many loops of the masterturntable:</property>
              <property name="use_underline">False</property>
              <property name="use_markup">False</property>
              <property name="justify">GTK_JUSTIFY_LEFT</property>
          </child>
 
          <child>
-           <widget class="GtkHBox" id="hbox3">
+           <widget class="GtkTable" id="table7">
              <property name="visible">True</property>
+             <property name="n_rows">2</property>
+             <property name="n_columns">2</property>
              <property name="homogeneous">False</property>
-             <property name="spacing">4</property>
-
-             <child>
-               <widget class="GtkLabel" id="label35">
-                 <property name="visible">True</property>
-                 <property name="label" translatable="yes">Master Cycles:</property>
-                 <property name="use_underline">False</property>
-                 <property name="use_markup">False</property>
-                 <property name="justify">GTK_JUSTIFY_LEFT</property>
-                 <property name="wrap">False</property>
-                 <property name="selectable">False</property>
-                 <property name="xalign">0.5</property>
-                 <property name="yalign">0.5</property>
-                 <property name="xpad">0</property>
-                 <property name="ypad">0</property>
-               </widget>
-               <packing>
-                 <property name="padding">0</property>
-                 <property name="expand">False</property>
-                 <property name="fill">False</property>
-               </packing>
-             </child>
+             <property name="row_spacing">0</property>
+             <property name="column_spacing">3</property>
 
              <child>
                <widget class="GtkSpinButton" id="master_cycles">
                  <property name="visible">True</property>
+                 <property name="tooltip" translatable="yes">Specify the number of loops for the master turntable.</property>
                  <property name="can_focus">True</property>
                  <property name="climb_rate">1</property>
                  <property name="digits">0</property>
                  <property name="adjustment">1 1 100 1 10 10</property>
                </widget>
                <packing>
-                 <property name="padding">0</property>
-                 <property name="expand">True</property>
-                 <property name="fill">True</property>
+                 <property name="left_attach">1</property>
+                 <property name="right_attach">2</property>
+                 <property name="top_attach">1</property>
+                 <property name="bottom_attach">2</property>
+                 <property name="y_options"></property>
                </packing>
              </child>
 
              <child>
                <widget class="GtkLabel" id="label36">
                  <property name="visible">True</property>
-                 <property name="label" translatable="yes">Cycles:</property>
+                 <property name="label" translatable="yes">Loops of the master turntable:</property>
                  <property name="use_underline">False</property>
                  <property name="use_markup">False</property>
                  <property name="justify">GTK_JUSTIFY_LEFT</property>
                  <property name="ypad">0</property>
                </widget>
                <packing>
-                 <property name="padding">0</property>
-                 <property name="expand">False</property>
-                 <property name="fill">False</property>
+                 <property name="left_attach">0</property>
+                 <property name="right_attach">1</property>
+                 <property name="top_attach">1</property>
+                 <property name="bottom_attach">2</property>
+                 <property name="x_options">fill</property>
+                 <property name="y_options"></property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkLabel" id="label35">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">Loops of this turntable turntable:</property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">False</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+               </widget>
+               <packing>
+                 <property name="left_attach">0</property>
+                 <property name="right_attach">1</property>
+                 <property name="top_attach">0</property>
+                 <property name="bottom_attach">1</property>
+                 <property name="x_options">fill</property>
+                 <property name="y_options"></property>
                </packing>
              </child>
 
              <child>
                <widget class="GtkSpinButton" id="cycles">
                  <property name="visible">True</property>
+                 <property name="tooltip" translatable="yes">Specify the number of loops of _this_ turntable.</property>
                  <property name="can_focus">True</property>
                  <property name="climb_rate">1</property>
                  <property name="digits">0</property>
                  <property name="adjustment">1 1 100 1 10 10</property>
                </widget>
                <packing>
-                 <property name="padding">0</property>
-                 <property name="expand">True</property>
-                 <property name="fill">True</property>
+                 <property name="left_attach">1</property>
+                 <property name="right_attach">2</property>
+                 <property name="top_attach">0</property>
+                 <property name="bottom_attach">1</property>
+                 <property name="y_options"></property>
                </packing>
              </child>
            </widget>
            <packing>
              <property name="padding">0</property>
-             <property name="expand">False</property>
-             <property name="fill">False</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
            </packing>
          </child>
 
index 58df630b789bf679dcf7e066d171b69b2a9be09f..2d4b94ebb04612c96251aa71717f12e1f7a99cc9 100644 (file)
@@ -12,17 +12,19 @@ Copyright: GPL2
 URL: http://www.terminatorX.cx
 Source: %{name}-%{version}.tar.gz
 Buildroot: %{_tmppath}/%{name}-%{version}-root
-Requires: gtk2, libvorbis, audiofile, libxml2
-BuildPrereq: gtk2-devel, libvorbis-devel, audiofile-devel, libxml2-devel, zlib-devel, scrollkeeper
+Requires: gtk2, libvorbis, audiofile, libxml2, zlib, scrollkeeper, yelp, sox, vorbis-tools
+BuildPrereq: gtk2-devel, libvorbis-devel, audiofile-devel, libxml2-devel, scrollkeeper
 
 %description
-terminatorX is a realtime audio synthesizer that allows you to "scratch" on
+terminatorX is a realtime audio synthesizer that allows you to "scratch" on 
 digitally sampled audio data (*.wav, *.au, *.ogg, *.mp3, etc.) the way 
 hiphop-DJs scratch on vinyl records. It features multiple turntables, realtime
-effects (buit-in as well as LADSPA plugin effects), a sequencer and an
-easy-to-use gtk+ GUI.
+effects (buit-in as well as LADSPA plugin effects), a sequencer and MIDI
+interface - all accessible through an easy-to-use gtk+ GUI.
 
 %changelog
+* Fri Apr 11 2003 Alexander König <alex@lisas.de>
+ - scrollkeeper changes and updates
 * Sat Sep 14 2002 Alexander König <alex@lisas.de>
  - Switch from xpm to pngs for GNOME icons
 * Fri May 31 2002 Alexander König <alex@lisas.de>
@@ -49,7 +51,7 @@ easy-to-use gtk+ GUI.
 %setup -q
 
 %build
-%configure
+%configure --with-docdir=/usr/share
 
 uname -a|grep SMP && make -j 2 || make
 
@@ -80,12 +82,15 @@ Icon=terminatorX-app.png
 EOF
 )
 
+# cleanup that scrollkeeper stuff
+rm -rf $RPM_BUILD_ROOT/var
+
 #do some cleanup for the documentation
-find . -name "Makefile*" -print -exec rm -rf {} \;
+#find . -name "Makefile*" -print -exec rm -rf {} \;
 
 %files
 %defattr(0644,root,root,0755)
-%doc COPYING COPYING-DOCS AUTHORS ChangeLog INSTALL NEWS README THANKS TODO README.GNOME README.PERFORMANCE doc
+%doc COPYING COPYING-DOCS AUTHORS ChangeLog INSTALL NEWS README THANKS TODO README.GNOME README.PERFORMANCE
 %attr(0755,root,root) %{_bindir}/terminatorX
 %{_mandir}/man1/terminatorX.1*
 %{_datadir}/mime-info/terminatorX.keys