X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fanalysis_window.cc;h=957dde3d1fcbcd60daf2ef9e9b519c942632bd96;hb=fc7a2e9ee1616cdcb78d6b60804baff336ad07ee;hp=b8318f45feae0b3967bc444a67e2aa4c207ad2c3;hpb=912da52a539981193941d8739fa6f103b5e406db;p=ardour.git diff --git a/gtk2_ardour/analysis_window.cc b/gtk2_ardour/analysis_window.cc index b8318f45fe..957dde3d1f 100644 --- a/gtk2_ardour/analysis_window.cc +++ b/gtk2_ardour/analysis_window.cc @@ -16,7 +16,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -26,7 +25,7 @@ #include #include -#include +#include #include #include "analysis_window.h" @@ -35,7 +34,7 @@ #include "time_axis_view.h" #include "public_editor.h" #include "selection.h" -#include "regionview.h" +#include "audio_region_view.h" #include "i18n.h" @@ -45,16 +44,15 @@ using namespace PBD; AnalysisWindow::AnalysisWindow() : ArdourDialog(_("analysis window")), - fft_graph (2048), - source_selection_label (_("Signal source")), source_selection_ranges_rb (_("Selected ranges")), source_selection_regions_rb (_("Selected regions")), - + display_model_label (_("Display model")), display_model_composite_separate_rb (_("Composite graphs for each track")), - display_model_composite_all_tracks_rb (_("Composite graph of all tracks")) + display_model_composite_all_tracks_rb (_("Composite graph of all tracks")), + fft_graph (2048) { track_list_ready = false; @@ -62,7 +60,7 @@ AnalysisWindow::AnalysisWindow() tlmodel = Gtk::ListStore::create(tlcols); track_list.set_model (tlmodel); track_list.append_column(_("Track"), tlcols.trackname); - track_list.append_column_editable(_("Visible"), tlcols.visible); + track_list.append_column_editable(_("Show"), tlcols.visible); track_list.set_headers_visible(true); track_list.set_reorderable(false); track_list.get_selection()->set_mode (Gtk::SELECTION_NONE); @@ -222,30 +220,33 @@ AnalysisWindow::analyze_data (Gtk::Button *button) Sample *buf = (Sample *) malloc(sizeof(Sample) * fft_graph.windowSize()); Sample *mixbuf = (Sample *) malloc(sizeof(Sample) * fft_graph.windowSize()); float *gain = (float *) malloc(sizeof(float) * fft_graph.windowSize()); - char *work = (char *) malloc(sizeof(char) * fft_graph.windowSize()); Selection s = PublicEditor::instance().get_selection(); TimeSelection ts = s.time; - AudioRegionSelection ars = s.audio_regions; - + RegionSelection ars = s.regions; for (TrackSelection::iterator i = s.tracks.begin(); i != s.tracks.end(); ++i) { - ARDOUR::Playlist *pl = (*i)->playlist(); + boost::shared_ptr pl + = boost::dynamic_pointer_cast((*i)->playlist()); + + if (!pl) + continue; + RouteUI *rui = dynamic_cast(*i); // Busses don't have playlists, so we need to check that we actually are working with a playlist if (!pl || !rui) continue; - FFTResult *res = fft_graph.prepareResult(*&rui->color(), *&rui->route().name()); + FFTResult *res = fft_graph.prepareResult(rui->color(), rui->route()->name()); // if timeSelection if (source_selection_ranges_rb.get_active()) { // cerr << "Analyzing ranges on track " << *&rui->route().name() << endl; - for (std::list::iterator j = ts.begin(); j != ts.end(); ++j) { + for (std::list::iterator j = ts.begin(); j != ts.end(); ++j) { - jack_nframes_t i = 0; + nframes_t i = 0; int n; while ( i < (*j).length() ) { @@ -257,7 +258,7 @@ AnalysisWindow::analyze_data (Gtk::Button *button) n = (*j).length() - i; } - n = pl->read(buf, mixbuf, gain, work, (*j).start + i, n); + n = pl->read(buf, mixbuf, gain, (*j).start + i, n); if ( n < fft_graph.windowSize()) { for (int j = n; j < fft_graph.windowSize(); j++) { @@ -275,24 +276,29 @@ AnalysisWindow::analyze_data (Gtk::Button *button) TimeAxisView *current_axis = (*i); - for (std::set::iterator j = ars.begin(); j != ars.end(); ++j) { + 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 ( &(*j)->get_time_axis_view() != current_axis) + if ( &arv->get_time_axis_view() != current_axis) continue; -// cerr << " - " << (*j)->region.name() << ": " << (*j)->region.length() << " samples starting at " << (*j)->region.position() << endl; - jack_nframes_t i = 0; +// cerr << " - " << (*j)->region().name() << ": " << (*j)->region().length() << " samples starting at " << (*j)->region().position() << endl; + nframes_t i = 0; int n; - while ( i < (*j)->region.length() ) { + while ( i < arv->region()->length() ) { // TODO: What about stereo+ channels? composite all to one, I guess n = fft_graph.windowSize(); - if (i + n >= (*j)->region.length() ) { - n = (*j)->region.length() - i; + if (i + n >= arv->region()->length() ) { + n = arv->region()->length() - i; } - - n = (*j)->region.read_at(buf, mixbuf, gain, work, (*j)->region.position() + i, n); + + n = arv->audio_region()->read_at(buf, mixbuf, gain, arv->region()->position() + i, n); if ( n < fft_graph.windowSize()) { for (int j = n; j < fft_graph.windowSize(); j++) { @@ -313,16 +319,15 @@ AnalysisWindow::analyze_data (Gtk::Button *button) Gtk::TreeModel::Row newrow = *(tlmodel)->append(); - newrow[tlcols.trackname] = rui->route().name(); + newrow[tlcols.trackname] = rui->route()->name(); newrow[tlcols.visible] = true; - newrow[tlcols.color] = *&rui->color(); + newrow[tlcols.color] = rui->color(); newrow[tlcols.graph] = res; } free(buf); free(mixbuf); - free(work); track_list_ready = true; } /* end lock */