Mostly MIDI fixes - Alex
authorterminatorX <>
Wed, 26 Mar 2003 20:11:27 +0000 (20:11 +0000)
committerterminatorX <>
Wed, 26 Mar 2003 20:11:27 +0000 (20:11 +0000)
13 files changed:
terminatorX/src/main.cc
terminatorX/src/tX_audiodevice.cc
terminatorX/src/tX_engine.cc
terminatorX/src/tX_engine.h
terminatorX/src/tX_global.c
terminatorX/src/tX_legacy_global.c
terminatorX/src/tX_mastergui.cc
terminatorX/src/tX_midiin.cc
terminatorX/src/tX_midiin.h
terminatorX/src/tX_sequencer.cc
terminatorX/src/tX_vtt.cc
terminatorX/src/tX_vtt.h
terminatorX/src/tX_vttfx.cc

index 011f8a89dee96850a02f79c08244e67f52cb7ea5..bb3f71fba5e8c6b445eb5c78619194abeb77450b 100644 (file)
@@ -420,8 +420,9 @@ int main(int argc, char **argv)
        while (gtk_events_pending()) gtk_main_iteration(); gdk_flush(); 
        gdk_flush();
        
-       vtt_class::set_mix_buffer_size(globals.true_block_size);
-       printf("\n* BENCHMARKING *\nBlocksize is %i samples.\n", globals.true_block_size);
+       vtt_class::set_sample_rate(48000);
+       
+       printf("\n* BENCHMARKING *\n");
        
        GTimer *bench_time = g_timer_new();
        gulong micros;
index a641d62c4c7c81b711552ec8d6a5f463e03c0d54..6c8e296b4136c55f74018e4b4ca199bb696c32cc 100644 (file)
@@ -144,7 +144,6 @@ int tX_audiodevice_oss :: open()
        i += ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blocksize);
 
        samples_per_buffer=blocksize/sizeof(int16_t);
-       globals.true_block_size=samples_per_buffer/2;
 
        tX_debug("tX_adudiodevice_oss::open() - blocksize: %i, samples_per_buffer: %i", blocksize, samples_per_buffer);
        
@@ -277,8 +276,6 @@ int tX_audiodevice_alsa :: open()
                return -1;
        }
 
-       globals.true_block_size=periodsize;
-       
        /* Apply all that setup work.. */
        if (snd_pcm_hw_params(pcm_handle, hw_params) < 0) {
                tX_error("ALSA: Failed to apply settings to PCM device \"%s\"", pcm_name);
@@ -286,7 +283,7 @@ int tX_audiodevice_alsa :: open()
                return -1;
        }
        
-       tX_debug("ALSA: samples_per_buffer: %i, bs: %i, period=%i", samples_per_buffer, globals.true_block_size, periodsize);
+       tX_debug("ALSA: samples_per_buffer: %i, period=%i", samples_per_buffer, periodsize);
        
        snd_pcm_hw_params_free (hw_params);
        return 0;
index 604c0a9a81686c79766a0dfe8c7e652a8b8318a3..9c68e178cefb7de5034e9a13be4f39b9c2e0831c 100644 (file)
@@ -68,76 +68,6 @@ void tX_engine :: set_grab_request() {
        grab_request=true;
 }
 
-void tX_engine :: loop_og() {
-       int16_t *temp=NULL;
-       int result;
-       
-       while (!thread_terminate) {
-               /* Waiting for the trigger */
-               pthread_mutex_lock(&start);
-               loop_is_active=true;
-               pthread_mutex_unlock(&start);
-
-               /* Render first block */
-               if (!stop_flag) {
-                       sequencer.step();
-                       temp=vtt_class::render_all_turntables();
-               }
-               
-               while (!stop_flag) {
-                       /* Checking whether to grab or not  */
-                       if (grab_request!=grab_active) {
-                               if (grab_request) {
-                                       /* Activating grab... */
-                                       result=mouse->grab(); 
-                                       if (result!=0) {
-                                               tX_error("tX_engine::loop(): failed to grab mouse - error %i", result);
-                                               grab_active=false;
-                                               /* Reseting grab_request, too - doesn't help keeping it, does it ? ;) */
-                                               grab_request=false;
-                                               mouse->ungrab();
-                                               grab_off();
-                                       } else {
-                                               grab_active=true;
-                                       }
-                               } else {
-                                       /* Deactivating grab... */
-                                       mouse->ungrab();
-                                       grab_active=false;
-                                       grab_off(); // for the mastergui this is...
-                               }
-                       }
-
-                       /* Handling input events... */
-                       if (grab_active) {
-                               if (mouse->check_event()) {
-                                       /* If we're here the user pressed ESC */
-                                       grab_request=false;
-                               }
-                       }
-
-#ifdef USE_ALSA_MIDI_IN                        
-                       if (midi->get_is_open()) midi->check_event();
-#endif                 
-               
-                       /* Playback the audio... */
-                       device->play(temp);
-               
-                       /* Record the audio if necessary... */
-                       if (is_recording()) tape->eat(temp);
-                       
-                       /* Forward the sequencer... */
-                       sequencer.step();
-                       
-                       /* Render the next block... */
-                       temp=vtt_class::render_all_turntables();                                        
-               }
-               
-               /* Stopping engine... */
-               loop_is_active=false;
-       }
-}
-
 int16_t* tX_engine :: render_cycle() {
        /* Checking whether to grab or not  */
        if (grab_request!=grab_active) {
@@ -170,9 +100,6 @@ int16_t* tX_engine :: render_cycle() {
                }
        }
 
-#ifdef USE_ALSA_MIDI_IN                        
-//     if (midi->get_is_open()) midi->check_event();
-#endif                 
        /* Forward the sequencer... */
        sequencer.step();
 
index 052ac66c5eaf4c95919061f2088405d3027d62e8..bf8c3e13cb52fb117b7b6b6f2feedb7cd993e2ba 100644 (file)
@@ -88,7 +88,6 @@ class tX_engine {
        tX_engine_error run();
        void stop();
        void loop();
-       void loop_og(); 
        
        void set_recording_request(bool recording);
        bool get_recording_request() { return recording_request; }
index b0ab2f44f7f334630360fae037b5539a21fca360..7a43fa9431c09b41bcb411afaaae5ff4038307cb 100644 (file)
@@ -67,7 +67,6 @@ void set_global_defaults() {
        globals.no_gui = 0;
        globals.alternate_rc = 0;
        
-       
        strcpy(globals.xinput_device, "");
        globals.xinput_enable=0;
        
@@ -79,7 +78,7 @@ void set_global_defaults() {
        globals.oss_buff_size=9;
        globals.oss_samplerate=44100;
 
-       strcpy(globals.alsa_device, "hw:0,0");  
+       strcpy(globals.alsa_device, "00-00: Default");  
        globals.alsa_buff_no=2;
        globals.alsa_buff_size=1024;
        globals.alsa_samplerate=44100;
@@ -129,8 +128,6 @@ void set_global_defaults() {
        
        strcpy(globals.lrdf_path, "/usr/share/ladspa/rdf:/usr/local/share/ladspa/rdf");
        globals.fullscreen_enabled=1;
-       
-       if (!globals.true_block_size) globals.true_block_size=1<globals.oss_buff_size;
 }
 
 int load_globals_xml() {
@@ -199,7 +196,6 @@ int load_globals_xml() {
                        restore_float("volume", globals.volume);
                        restore_float("flash_response", globals.flash_response);
                        restore_int("button_type", globals.button_type);
-                       restore_int("true_block_size", globals.true_block_size);
                        restore_string("tables_filename", globals.tables_filename);
                        restore_string("record_filename", globals.record_filename);
                        restore_string("file_editor", globals.file_editor);
@@ -283,7 +279,6 @@ void store_globals() {
                store_float("volume", globals.volume);
                store_float("flash_response", globals.flash_response);
                store_int("button_type", globals.button_type);
-               store_int("true_block_size", globals.true_block_size);
                store_string("tables_filename", globals.tables_filename);
                store_string("record_filename", globals.record_filename);
                store_string("file_editor", globals.file_editor);
index 04c5c42510177024b0d3e8c8bb5f405f322a3ae8..0ccf2051ab18cac781dd69e21438b0223a75032d 100644 (file)
@@ -66,7 +66,6 @@ void load_globals_old() {
        globals.current_path = NULL;
        globals.pitch=1.0;
        globals.volume=1.0;     
-       if (!globals.true_block_size) globals.true_block_size=1<globals.oss_buff_size;
 }
 
 #endif
index 8d702b9ef8c7df587c363fe90f3c7c7fd98ac091..a03ec68a9823b02e2db2b850a8a6e35ef25ba6da 100644 (file)
@@ -744,18 +744,20 @@ void seq_update_entry(const guint32 timestamp)
        char buffer[20];
        guint32 samples;
        guint32 minu,sec,hun;   
+       guint32 sr;
        
-       samples=timestamp*globals.true_block_size;
+       samples=timestamp*vtt_class::get_mix_buffer_size();
+       sr=vtt_class::get_last_sample_rate();
        
        if (samples>0)
        {
-               minu=samples/2646000;
-               samples-=2646000*minu;
+               minu=samples/(sr*60);
+               samples-=(sr*60)*minu;
        
-               sec=samples/44100;
-               samples-=44100*sec;
+               sec=samples/sr;
+               samples-=sr*sec;
        
-               hun=samples/441;
+               hun=samples/(sr/100);
        }
        else
        {
index 30d459a6148d48acdfd9d82a3d58e91f92d35ee0..2f1c401fc5a88fb3eba16710f1f60d7b152f2583 100644 (file)
@@ -140,11 +140,10 @@ int tX_midiin::check_event()
                                return -1;
                        }
 
-                       //cerr << event.type << ", " << event.number << ", " << event.value << endl;
-                       //event.print( __FUNCTION__ );
-
-                       list <tX_seqpar *> :: iterator sp;
-
+                       // This should be solved with a hash table. Possibly.
+                       
+                       list <tX_seqpar *> :: iterator sp;                      
+                       
                        for (sp=tX_seqpar::all.begin(); sp!=tX_seqpar::all.end(); sp++) {
                                if ( (*sp)->bound_midi_event.type_matches (event) ) {
                                        (*sp)->handle_midi_input (event);
@@ -162,13 +161,6 @@ void tX_midiin::configure_bindings( vtt_class* vtt )
 {
        list <tX_seqpar *> :: iterator sp;
 
-       /*
-       tX_midievent event = {0,tX_midievent::CC,0,0,0};
-       event.type = tX_midievent::CC;
-       event.number = 11;
-       event.channel = 0;
-       */
-
        GType types[3] = { G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER };
        GtkListStore* model = gtk_list_store_newv(3, types);
        GtkTreeIter iter;
@@ -187,17 +179,11 @@ void tX_midiin::configure_bindings( vtt_class* vtt )
                                                                1, tempstr,
                                                                2, (*sp),
                                                                -1 );
-
-                       //cerr << (*sp)->get_name() << endl;
                }
        }
 
        // it will delete itself.
        new midi_binding_gui(GTK_TREE_MODEL(model), this);
-
-       //cerr << "window created." << endl;
-
-       return;
 }
 
 tX_midiin::midi_binding_gui::midi_binding_gui ( GtkTreeModel* _model, tX_midiin* _midi )
@@ -262,38 +248,83 @@ tX_midiin::midi_binding_gui::midi_binding_gui ( GtkTreeModel* _model, tX_midiin*
        gtk_widget_show (bind_button);
        gtk_box_pack_start (GTK_BOX (vbox1), bind_button, FALSE, FALSE, 0);
        
+       GtkWidget* unbind_button = gtk_button_new_with_mnemonic ("Remove Binding");
+       gtk_widget_show (unbind_button);
+       gtk_box_pack_start (GTK_BOX (vbox1), unbind_button, FALSE, FALSE, 0);   
+       
        GtkWidget* close_button = gtk_button_new_with_mnemonic ("Close");
        gtk_widget_show (close_button);
        gtk_box_pack_start (GTK_BOX (vbox1), close_button, FALSE, FALSE, 0);
        
        gtk_signal_connect(GTK_OBJECT(bind_button), "clicked", (GtkSignalFunc) bind_clicked, (void *) this);
+       gtk_signal_connect(GTK_OBJECT(unbind_button), "clicked", (GtkSignalFunc) unbind_clicked, (void *) this);        
        gtk_signal_connect(GTK_OBJECT(close_button), "clicked", (GtkSignalFunc) close_clicked, (void *) this);
+       gtk_signal_connect(GTK_OBJECT(window), "destroy", (GtkSignalFunc) close_clicked, (void *) this);
        
        timer_tag = gtk_timeout_add( 100, (GtkFunction) timer, (void *) this);
        
        gtk_widget_show_all( GTK_WIDGET( window ) );
 }
 
-void tX_midiin::midi_binding_gui::bind_clicked( GtkButton *button, gpointer _this )
+void tX_midiin::midi_binding_gui::window_closed(GtkWidget *widget, gpointer _this )
+{
+       tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
+
+       delete this_;
+}
+
+void tX_midiin::midi_binding_gui::unbind_clicked( GtkButton *button, gpointer _this )
 {
        tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
        GtkTreeModel* model;
        GtkTreeSelection* selection;
        GtkTreeIter iter;
+       char tmpstr[128];
        tX_seqpar* param;
 
        selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(this_->parameter_treeview) );
        gtk_tree_selection_get_selected( selection, &model, &iter );
        gtk_tree_model_get( model, &iter, 2, &param, -1 );
+       
+       param->bound_midi_event.type=tX_midievent::NONE;
+       param->bound_midi_event.number=0;
+       param->bound_midi_event.channel=0;
+       
+       snprintf( tmpstr, sizeof(tmpstr), "Type: %d, Number: %d, Channel: %d",
+                               param->bound_midi_event.type, param->bound_midi_event.number,
+                               param->bound_midi_event.channel );
+
+       gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, param->get_name(), 1, tmpstr, 2, param, -1 );       
+}
+
+
+void tX_midiin::midi_binding_gui::bind_clicked( GtkButton *button, gpointer _this )
+{
+       tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
+       GtkTreeModel* model;
+       GtkTreeSelection* selection;
+       GtkTreeIter iter;
+       char tmpstr[128];
+       tX_seqpar* param;
 
+       selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(this_->parameter_treeview) );
+       gtk_tree_selection_get_selected( selection, &model, &iter );
+       gtk_tree_model_get( model, &iter, 2, &param, -1 );
+       
        param->bound_midi_event = this_->last_event;
+       
+       snprintf( tmpstr, sizeof(tmpstr), "Type: %d, Number: %d, Channel: %d",
+                               param->bound_midi_event.type, param->bound_midi_event.number,
+                               param->bound_midi_event.channel );
+
+       gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, param->get_name(), 1, tmpstr, 2, param, -1 );       
 }
 
 void tX_midiin::midi_binding_gui::close_clicked( GtkButton *button, gpointer _this )
 {
        tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
        
-       gtk_widget_hide( this_->window );
+       gtk_widget_destroy( this_->window );
 
        delete this_;
 }
@@ -301,9 +332,6 @@ void tX_midiin::midi_binding_gui::close_clicked( GtkButton *button, gpointer _th
 gint tX_midiin::midi_binding_gui::timer( gpointer _this )
 {
        tX_midiin::midi_binding_gui* this_ = (tX_midiin::midi_binding_gui*)_this;
-
-       //this_->midi->check_event();
-       
        tX_midievent tmpevent = this_->midi->get_last_event();
 
        if( tmpevent.type_matches( this_->last_event ) )
@@ -326,9 +354,6 @@ gint tX_midiin::midi_binding_gui::timer( gpointer _this )
 tX_midiin::midi_binding_gui::~midi_binding_gui ()
 {
        gtk_timeout_remove( timer_tag );
-
-       //g_object_unref( window );
-       gtk_widget_destroy( window );
 }
 
 #endif // USE_ALSA_MIDI_IN
index b3ff4e111241ce2e0736d4855f6674fa52a3f442..0f737762742cecb9c23c30fe8a4a7512099d0798 100644 (file)
@@ -108,6 +108,8 @@ class tX_midiin
 
                tX_midievent last_event;
 
+               static void window_closed( GtkWidget *widget, gpointer _this );
+               static void unbind_clicked( GtkButton *button, gpointer _this );          
                static void bind_clicked( GtkButton *button, gpointer _this );
                static void close_clicked( GtkButton *button, gpointer _this );
                static gint timer( gpointer _this );
index a10a97d52f7ef1c2261ff90bacfe5ec2a076bc87..18535f156a6df25aec9cd1536c9c8ecfe8bb65ee 100644 (file)
@@ -281,10 +281,8 @@ void tX_sequencer :: forward_to_start_timestamp(int dont_fake)
        int run_save=run;
        
        run=1;
-       //if (!run) return;
        
-       gui_update_max=(globals.update_idle * (globals.update_delay+1) * globals.true_block_size) >> 1;
-//     printf("%i\n", gui_update_max);
+       gui_update_max=(globals.update_idle * (globals.update_delay+1) * 1000) >> 1;
        gui_update=gui_update_max;
        
        current_timestamp=0;
index c628eff30f69e05f635750adfbe8ad3c6798c910..1d85eb81cdbaf297d4b702cc69b719fed8b67998 100644 (file)
@@ -74,7 +74,7 @@ extern int vg_get_current_page(vtt_class *vtt);
 extern f_prec gui_get_audio_x_zoom(vtt_class *vtt);
 extern void gui_set_audio_x_zoom(vtt_class *vtt, f_prec);
 
-
+int vtt_class::last_sample_rate=44100;
 int vtt_class::vtt_amount=0;
 list <vtt_class *> vtt_class::main_list;
 list <vtt_class *> vtt_class::render_list;
@@ -1998,6 +1998,8 @@ void vtt_class :: hide_control(bool hide) {
 void vtt_class :: set_sample_rate(int samplerate) {
        list <vtt_class *> :: iterator vtt;
        double sr=(double) samplerate;
+
+       last_sample_rate=samplerate;
        
        for (vtt=main_list.begin(); vtt!=main_list.end() ; vtt++) {
                if ((*vtt)->audiofile) {
index 3ce27d46144c1882741a718569ecdee22c0e6991..4c24aaed110b4413839b4313560f9a62a5acca7e 100644 (file)
@@ -90,6 +90,7 @@ class vtt_class
        static vtt_class * focused_vtt;
        static int solo_ctr;
        static int mix_buffer_size;
+       static int last_sample_rate;
        
        /* the gui */
        vtt_gui gui;
@@ -327,6 +328,8 @@ class vtt_class
        
        void set_mix_mute(int newstate);
        void set_mix_solo(int newstate);
+       static int get_last_sample_rate() { return last_sample_rate; }
+       
        void calc_mute()
        {
                res_mute=((mute) || (mix_mute && (!mix_solo)) || ((solo_ctr>0)&&(!mix_solo)));
index 93207587fec9a31dbefe04d6b98e281f09def94d..a5aca3e1e76a82e8c678b017356f5d6e0f6314ae 100644 (file)
@@ -313,7 +313,7 @@ void vtt_fx_ladspa :: load(xmlDocPtr doc, xmlNodePtr node) {
                        elementFound=0;
                        
                        restore_int("ladspa_id", dummy);
-                       restore_bool("hidden", hidden);
+                       restore_bool("panel_hidden", hidden);
                        if ((!elementFound) && (xmlStrcmp(cur->name, (xmlChar *) "param")==0)) {
                                val=0;
                                elementFound=1;