X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fanalysis_window.cc;h=f653490345b70e48598789c397fe24daff6d5cbd;hb=0b1ee476edaed41f4c679f89e93a486e4d487333;hp=afa277e8e44919e8bf96b5686f5af5dcba3aa7b6;hpb=73192bc1a7ea55fa1864dc3826845b15c00dd2ec;p=ardour.git diff --git a/gtk2_ardour/analysis_window.cc b/gtk2_ardour/analysis_window.cc index afa277e8e4..f653490345 100644 --- a/gtk2_ardour/analysis_window.cc +++ b/gtk2_ardour/analysis_window.cc @@ -235,11 +235,11 @@ AnalysisWindow::analyze() } void -AnalysisWindow::analyze_data (Gtk::Button */*button*/) +AnalysisWindow::analyze_data (Gtk::Button * /*button*/) { track_list_ready = false; { - Glib::Mutex::Lock lm (track_list_lock); + Glib::Threads::Mutex::Lock lm (track_list_lock); // Empty track list & free old graphs clear_tracklist(); @@ -251,29 +251,29 @@ AnalysisWindow::analyze_data (Gtk::Button */*button*/) float *gain = (float *) malloc(sizeof(float) * fft_graph.windowSize()); Selection& s (PublicEditor::instance().get_selection()); - TimeSelection ts = s.time; - RegionSelection ars = s.regions; - for (TrackSelection::iterator i = s.tracks.begin(); i != s.tracks.end(); ++i) { - boost::shared_ptr pl - = boost::dynamic_pointer_cast((*i)->playlist()); - if (!pl) - continue; + // if timeSelection + if (source_selection_ranges_rb.get_active()) { + TimeSelection ts = s.time; - RouteUI *rui = dynamic_cast(*i); - int n_inputs = rui->route()->n_inputs().n_audio(); // FFT is audio only + for (TrackSelection::iterator i = s.tracks.begin(); i != s.tracks.end(); ++i) { + boost::shared_ptr pl + = boost::dynamic_pointer_cast((*i)->playlist()); - // Busses don't have playlists, so we need to check that we actually are working with a playlist - if (!pl || !rui) - continue; + if (!pl) + continue; - FFTResult *res = fft_graph.prepareResult(rui->color(), rui->route()->name()); + RouteUI *rui = dynamic_cast(*i); + int n_inputs = rui->route()->n_inputs().n_audio(); // FFT is audio only - // if timeSelection - if (source_selection_ranges_rb.get_active()) { -// cerr << "Analyzing ranges on track " << *&rui->route().name() << endl; + // Busses don't have playlists, so we need to check that we actually are working with a playlist + if (!pl || !rui) + continue; + // std::cerr << "Analyzing ranges on track " << rui->route()->name() << std::endl; + + FFTResult *res = fft_graph.prepareResult(rui->color(), rui->route()->name()); for (std::list::iterator j = ts.begin(); j != ts.end(); ++j) { int n; @@ -303,71 +303,78 @@ AnalysisWindow::analyze_data (Gtk::Button */*button*/) } } } - } else if (source_selection_regions_rb.get_active()) { -// cerr << "Analyzing selected regions on track " << *&rui->route().name() << endl; - - TimeAxisView *current_axis = (*i); - - for (RegionSelection::iterator j = ars.begin(); j != ars.end(); ++j) { - // Check that the region is actually audio (so we can analyze it) - AudioRegionView* arv = dynamic_cast(*j); - if (!arv) - continue; - - // Check that the region really is selected on _this_ track/solo - if ( &arv->get_time_axis_view() != current_axis) - continue; - -// cerr << " - " << (*j)->region().name() << ": " << (*j)->region().length() << " samples starting at " << (*j)->region().position() << endl; - int n; - for (int channel = 0; channel < n_inputs; channel++) { - - framecnt_t x = 0; + res->finalize(); + + Gtk::TreeModel::Row newrow = *(tlmodel)->append(); + newrow[tlcols.trackname] = rui->route()->name(); + newrow[tlcols.visible] = true; + newrow[tlcols.color] = rui->color(); + newrow[tlcols.graph] = res; + } + } else if (source_selection_regions_rb.get_active()) { + RegionSelection ars = s.regions; + // std::cerr << "Analyzing selected regions" << std::endl; + + for (RegionSelection::iterator j = ars.begin(); j != ars.end(); ++j) { + // Check that the region is actually audio (so we can analyze it) + AudioRegionView* arv = dynamic_cast(*j); + if (!arv) + continue; + + // std::cerr << " - " << (*j)->region().name() << ": " << (*j)->region().length() << " samples starting at " << (*j)->region().position() << std::endl; + RouteTimeAxisView *rtav = dynamic_cast(&arv->get_time_axis_view()); + if (!rtav) { + /* shouldn't happen... */ + continue; + } + FFTResult *res = fft_graph.prepareResult(rtav->color(), arv->get_item_name()); + int n; + for (unsigned int channel = 0; channel < arv->region()->n_channels(); channel++) { - framecnt_t length = arv->region()->length(); + framecnt_t x = 0; + framecnt_t length = arv->region()->length(); - while (x < length) { - // TODO: What about stereo+ channels? composite all to one, I guess + while (x < length) { + // TODO: What about stereo+ channels? composite all to one, I guess - n = fft_graph.windowSize(); - if (x + n >= length ) { - n = length - x; - } + n = fft_graph.windowSize(); + if (x + n >= length ) { + n = length - x; + } - n = arv->audio_region()->read_at(buf, mixbuf, gain, arv->region()->position() + x, n, channel); + memset (buf, 0, n * sizeof (Sample)); + n = arv->audio_region()->read_at(buf, mixbuf, gain, arv->region()->position() + x, n, channel); - if (n == 0) - break; + if (n == 0) + break; - if ( n < fft_graph.windowSize()) { - for (int j = n; j < fft_graph.windowSize(); j++) { - buf[j] = 0.0; - } + if ( n < fft_graph.windowSize()) { + for (int j = n; j < fft_graph.windowSize(); j++) { + buf[j] = 0.0; } - - res->analyzeWindow(buf); - - x += n; } - } -// cerr << "Found: " << (*j)->get_item_name() << endl; + res->analyzeWindow(buf); + x += n; + } } + // std::cerr << "Found: " << (*j)->get_item_name() << std::endl; + res->finalize(); - } - res->finalize(); + Gtk::TreeModel::Row newrow = *(tlmodel)->append(); + newrow[tlcols.trackname] = arv->get_item_name(); + newrow[tlcols.visible] = true; + newrow[tlcols.color] = rtav->color(); + newrow[tlcols.graph] = res; + } - Gtk::TreeModel::Row newrow = *(tlmodel)->append(); - newrow[tlcols.trackname] = rui->route()->name(); - newrow[tlcols.visible] = true; - newrow[tlcols.color] = rui->color(); - newrow[tlcols.graph] = res; } free(buf); free(mixbuf); + free(gain); track_list_ready = true; } /* end lock */