diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-11 14:34:21 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-11 14:34:21 +0000 |
commit | ced90fa400b25f3b2ad385ff889215463766a32d (patch) | |
tree | 93ca36f90a18f911ce93bc85a68edf1e20ed264f | |
parent | 772b002fea964485b73fd4f73957a6c72b67d504 (diff) |
add SRC quality to import dialog; fix instances of missing waveforms where new sources are created; add fader+meter to import dialog; metering now doesn't return -inf for ninputs == 0, only if ninputs & noutputs == 0
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2457 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/editor.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_audio_import.cc | 19 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.cc | 56 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.cc | 173 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.h | 27 | ||||
-rw-r--r-- | libs/ardour/ardour/io.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/resampled_source.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 8 | ||||
-rw-r--r-- | libs/ardour/audiofilter.cc | 7 | ||||
-rw-r--r-- | libs/ardour/import.cc | 2 | ||||
-rw-r--r-- | libs/ardour/io.cc | 3 | ||||
-rw-r--r-- | libs/ardour/resampled_source.cc | 24 | ||||
-rw-r--r-- | libs/ardour/route.cc | 1 | ||||
-rw-r--r-- | libs/ardour/session_timefx.cc | 8 |
15 files changed, 263 insertions, 81 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index b48dce0ce1..9de506c2c6 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -969,13 +969,13 @@ class Editor : public PublicEditor SoundFileOmega* sfbrowser; void bring_in_external_audio (Editing::ImportMode mode, nframes64_t& pos); - void do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, nframes64_t&); + void do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&); void _do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, nframes64_t&); void do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, nframes64_t&); bool idle_do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, nframes64_t&); - int import_sndfiles (vector<Glib::ustring> paths, Editing::ImportMode mode, nframes64_t& pos, + int import_sndfiles (vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&); int embed_sndfiles (vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&); diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index a4a9a7a420..6a482b5438 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -128,8 +128,10 @@ Editor::external_audio_dialog () break; } + SrcQuality quality = sfbrowser->get_src_quality(); + if (sfbrowser->copy_files_btn.get_active()) { - do_import (paths, chns, mode, where); + do_import (paths, chns, mode, quality, where); } else { do_embed (paths, chns, mode, where); } @@ -166,7 +168,7 @@ Editor::get_nth_selected_audio_track (int nth) const } void -Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mode, nframes64_t& pos) +Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mode, SrcQuality quality, nframes64_t& pos) { boost::shared_ptr<AudioTrack> track; vector<ustring> to_import; @@ -188,7 +190,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod track = get_nth_selected_audio_track (nth++); } - if (import_sndfiles (to_import, mode, pos, 1, -1, track)) { + if (import_sndfiles (to_import, mode, quality, pos, 1, -1, track)) { goto out; } @@ -201,7 +203,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod to_import.clear (); to_import.push_back (*a); - if (import_sndfiles (to_import, mode, pos, -1, -1, track)) { + if (import_sndfiles (to_import, mode, quality, pos, -1, -1, track)) { goto out; } @@ -212,7 +214,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod /* create 1 region from all paths, add to 1 track, ignore "track" */ - if (import_sndfiles (paths, mode, pos, 1, 1, track)) { + if (import_sndfiles (paths, mode, quality, pos, 1, 1, track)) { goto out; } break; @@ -227,7 +229,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod reuse "track" across paths */ - if (import_sndfiles (to_import, mode, pos, 1, 1, track)) { + if (import_sndfiles (to_import, mode, quality, pos, 1, 1, track)) { goto out; } @@ -329,7 +331,7 @@ Editor::_do_embed (vector<ustring> paths, ImportDisposition chns, ImportMode mod } int -Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, nframes64_t& pos, +Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality quality, nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<AudioTrack>& track) { WindowTitle title = string_compose (_("importing %1"), paths.front()); @@ -346,7 +348,8 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, nframes64_t& po import_status.cancel = false; import_status.freeze = false; import_status.done = 0.0; - + import_status.quality = quality; + interthread_progress_connection = Glib::signal_timeout().connect (bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100); diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 791d6704cc..05acf08663 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -147,39 +147,41 @@ GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s) if ((r = dynamic_cast<Route*> (_io.get())) != 0) { /* - if we have a route (ie. we're not the click), + if we have a non-hidden route (ie. we're not the click or the auditioner), pack some route-dependent stuff. */ gain_display_box.pack_end (peak_display, true, true); - hbox.pack_end (meter_packer, true, true); - using namespace Menu_Helpers; - - gain_astate_menu.items().push_back (MenuElem (_("Manual"), - bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Off))); - gain_astate_menu.items().push_back (MenuElem (_("Play"), - bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Play))); - gain_astate_menu.items().push_back (MenuElem (_("Write"), - bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Write))); - gain_astate_menu.items().push_back (MenuElem (_("Touch"), - bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Touch))); - - gain_astyle_menu.items().push_back (MenuElem (_("Trim"))); - gain_astyle_menu.items().push_back (MenuElem (_("Abs"))); - - gain_astate_menu.set_name ("ArdourContextMenu"); - gain_astyle_menu.set_name ("ArdourContextMenu"); - - gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &GainMeter::gain_automation_style_button_event), false); - gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &GainMeter::gain_automation_state_button_event), false); - - r->gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &GainMeter::gain_automation_state_changed)); - r->gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &GainMeter::gain_automation_style_changed)); - fader_vbox->pack_start (gain_automation_state_button, false, false, 0); + if (!r->hidden()) { - gain_automation_state_changed (); + using namespace Menu_Helpers; + + gain_astate_menu.items().push_back (MenuElem (_("Manual"), + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Off))); + gain_astate_menu.items().push_back (MenuElem (_("Play"), + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Play))); + gain_astate_menu.items().push_back (MenuElem (_("Write"), + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Write))); + gain_astate_menu.items().push_back (MenuElem (_("Touch"), + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Touch))); + + gain_astyle_menu.items().push_back (MenuElem (_("Trim"))); + gain_astyle_menu.items().push_back (MenuElem (_("Abs"))); + + gain_astate_menu.set_name ("ArdourContextMenu"); + gain_astyle_menu.set_name ("ArdourContextMenu"); + + gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &GainMeter::gain_automation_style_button_event), false); + gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &GainMeter::gain_automation_state_button_event), false); + + r->gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &GainMeter::gain_automation_state_changed)); + r->gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &GainMeter::gain_automation_style_changed)); + + fader_vbox->pack_start (gain_automation_state_button, false, false, 0); + gain_automation_state_changed (); + } } set_spacing (2); @@ -339,7 +341,7 @@ GainMeter::update_meters () for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) { if ((*i).packed) { peak = _io->peak_input_power (n); - + (*i).meter->set (log_meter (peak)); mpeak = _io->max_peak_power(n); diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index af950d8e6e..830e446657 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -35,6 +35,7 @@ #include <gtkmm2ext/utils.h> #include <ardour/audio_library.h> +#include <ardour/auditioner.h> #include <ardour/audioregion.h> #include <ardour/audiofilesource.h> #include <ardour/region_factory.h> @@ -48,6 +49,7 @@ #include "sfdb_ui.h" #include "editing.h" #include "utils.h" +#include "gain_meter.h" #include "i18n.h" @@ -132,7 +134,7 @@ SoundFileBox::SoundFileBox () main_box.pack_start(*vbox, true, true); main_box.pack_start(bottom_box, false, false); - + play_btn.set_image (*(manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON)))); play_btn.set_label (_("Play (double click)")); @@ -168,6 +170,7 @@ SoundFileBox::set_session(Session* s) stop_btn.set_sensitive (false); } + length_clock.set_session (s); timecode_clock.set_session (s); } @@ -345,17 +348,15 @@ SoundFileBrowser::SoundFileBrowser (Gtk::Window& parent, string title, ARDOUR::S { VBox* vbox; HBox* hbox; - HBox* hpacker; set_session (s); resetting_ourselves = false; - hpacker = manage (new HBox); - hpacker->set_spacing (6); - hpacker->pack_start (notebook, true, true); - hpacker->pack_start (preview, false, false); + hpacker.set_spacing (6); + hpacker.pack_start (notebook, true, true); + hpacker.pack_start (preview, false, false); - get_vbox()->pack_start (*hpacker, true, true); + get_vbox()->pack_start (hpacker, true, true); hbox = manage(new HBox); hbox->pack_start (found_entry); @@ -371,6 +372,8 @@ SoundFileBrowser::SoundFileBrowser (Gtk::Window& parent, string title, ARDOUR::S notebook.append_page (chooser, _("Browse Files")); notebook.append_page (*vbox, _("Search Tags")); + notebook.set_size_request (500, -1); + found_list_view.get_selection()->set_mode (SELECTION_MULTIPLE); found_list_view.signal_row_activated().connect (mem_fun (*this, &SoundFileBrowser::found_list_view_activated)); @@ -406,6 +409,14 @@ SoundFileBrowser::~SoundFileBrowser () persistent_folder = chooser.get_current_folder(); } + +void +SoundFileBrowser::on_show () +{ + ArdourDialog::on_show (); + start_metering (); +} + void SoundFileBrowser::clear_selection () { @@ -430,7 +441,58 @@ SoundFileBrowser::set_session (Session* s) { ArdourDialog::set_session (s); preview.set_session (s); - + if (s) { + add_gain_meter (); + } else { + remove_gain_meter (); + } +} + +void +SoundFileBrowser::add_gain_meter () +{ + if (gm) { + delete gm; + } + + gm = new GainMeter (session->the_auditioner(), *session); + + meter_packer.set_border_width (12); + meter_packer.pack_start (*gm, false, true); + hpacker.pack_end (meter_packer, false, false); + meter_packer.show_all (); + start_metering (); +} + +void +SoundFileBrowser::remove_gain_meter () +{ + if (gm) { + meter_packer.remove (*gm); + hpacker.remove (meter_packer); + delete gm; + gm = 0; + } +} + +void +SoundFileBrowser::start_metering () +{ + metering_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &SoundFileBrowser::meter)); +} + +void +SoundFileBrowser::stop_metering () +{ + metering_connection.disconnect(); +} + +void +SoundFileBrowser::meter () +{ + if (is_mapped () && session && gm) { + gm->update_meters (); + } } bool @@ -562,12 +624,12 @@ SoundFileOmega::reset_options () } bool same_size; - bool err; - bool selection_includes_multichannel = check_multichannel_status (paths, same_size, err); + bool src_needed; + bool selection_includes_multichannel; bool selection_can_be_embedded_with_links = check_link_status (*session, paths); ImportMode mode; - if (err) { + if (check_info (paths, same_size, src_needed, selection_includes_multichannel)) { Glib::signal_idle().connect (mem_fun (*this, &SoundFileOmega::bad_file_message)); return false; } @@ -691,12 +753,18 @@ SoundFileOmega::reset_options () } else { channel_combo.set_active_text (channel_strings.front()); } + + if (src_needed) { + src_combo.set_sensitive (true); + } else { + src_combo.set_sensitive (false); + } if (Profile->get_sae()) { if (selection_can_be_embedded_with_links) { copy_files_btn.set_sensitive (true); } else { - copy_files_btn.set_sensitive (true); + copy_files_btn.set_sensitive (false); } } @@ -721,15 +789,16 @@ SoundFileOmega::bad_file_message() } bool -SoundFileOmega::check_multichannel_status (const vector<ustring>& paths, bool& same_size, bool& err) +SoundFileOmega::check_info (const vector<ustring>& paths, bool& same_size, bool& src_needed, bool& multichannel) { SNDFILE* sf; SF_INFO info; nframes64_t sz = 0; - bool some_mult = false; + bool err = false; same_size = true; - err = false; + src_needed = false; + multichannel = false; for (vector<ustring>::const_iterator i = paths.begin(); i != paths.end(); ++i) { @@ -739,7 +808,7 @@ SoundFileOmega::check_multichannel_status (const vector<ustring>& paths, bool& s sf_close (sf); if (info.channels > 1) { - some_mult = true; + multichannel = true; } if (sz == 0) { @@ -749,12 +818,17 @@ SoundFileOmega::check_multichannel_status (const vector<ustring>& paths, bool& s same_size = false; } } + + if ((nframes_t) info.samplerate != session->frame_rate()) { + src_needed = true; + } + } else { err = true; } } - return some_mult; + return err; } bool @@ -805,6 +879,8 @@ void SoundFileChooser::on_hide () { ArdourDialog::on_hide(); + stop_metering (); + if (session) { session->cancel_audition(); } @@ -835,6 +911,7 @@ SoundFileOmega::SoundFileOmega (Gtk::Window& parent, string title, ARDOUR::Sessi { VBox* vbox; HBox* hbox; + vector<string> str; set_size_request (-1, 450); @@ -844,14 +921,13 @@ SoundFileOmega::SoundFileOmega (Gtk::Window& parent, string title, ARDOUR::Sessi options.set_spacing (12); - vector<string> where_strings; - - where_strings.push_back (_("use file timestamp")); - where_strings.push_back (_("at edit cursor")); - where_strings.push_back (_("at playhead")); - where_strings.push_back (_("at session start")); - set_popdown_strings (where_combo, where_strings); - where_combo.set_active_text (where_strings.front()); + str.clear (); + str.push_back (_("use file timestamp")); + str.push_back (_("at edit cursor")); + str.push_back (_("at playhead")); + str.push_back (_("at session start")); + set_popdown_strings (where_combo, str); + where_combo.set_active_text (str.front()); Label* l = manage (new Label); l->set_text (_("Add files:")); @@ -890,6 +966,35 @@ SoundFileOmega::SoundFileOmega (Gtk::Window& parent, string title, ARDOUR::Sessi vbox->pack_start (*hbox, false, false); options.pack_start (*vbox, false, false); + str.clear (); + str.push_back (_("one track per file")); + set_popdown_strings (channel_combo, str); + channel_combo.set_active_text (str.front()); + channel_combo.set_sensitive (false); + + l = manage (new Label); + l->set_text (_("Conversion Quality:")); + + hbox = manage (new HBox); + hbox->set_border_width (12); + hbox->set_spacing (6); + hbox->pack_start (*l, false, false); + hbox->pack_start (src_combo, false, false); + vbox = manage (new VBox); + vbox->pack_start (*hbox, false, false); + options.pack_start (*vbox, false, false); + + str.clear (); + str.push_back (_("Best")); + str.push_back (_("Good")); + str.push_back (_("Quick")); + str.push_back (_("Fast")); + str.push_back (_("Fastest")); + + set_popdown_strings (src_combo, str); + src_combo.set_active_text (str.front()); + src_combo.set_sensitive (false); + reset_options (); action_combo.signal_changed().connect (mem_fun (*this, &SoundFileOmega::reset_options_noret)); @@ -957,6 +1062,24 @@ SoundFileOmega::get_position() const } } +SrcQuality +SoundFileOmega::get_src_quality() const +{ + ustring str = where_combo.get_active_text(); + + if (str == _("Best")) { + return SrcBest; + } else if (str == _("Good")) { + return SrcGood; + } else if (str == _("Quick")) { + return SrcQuick; + } else if (str == _("Fast")) { + return SrcFast; + } else { + return SrcFastest; + } +} + ImportDisposition SoundFileOmega::get_channel_disposition () const { diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h index ec057814be..366dcea4e9 100644 --- a/gtk2_ardour/sfdb_ui.h +++ b/gtk2_ardour/sfdb_ui.h @@ -47,6 +47,8 @@ namespace ARDOUR { class Session; }; +class GainMeter; + class SoundFileBox : public Gtk::VBox { public: @@ -133,6 +135,7 @@ class SoundFileBrowser : public ArdourDialog Gtk::FileFilter custom_filter; Gtk::FileFilter matchall_filter; SoundFileBox preview; + Gtk::HBox hpacker; static Glib::ustring persistent_folder; @@ -140,6 +143,15 @@ class SoundFileBrowser : public ArdourDialog Gtk::Button found_search_btn; Gtk::Notebook notebook; + GainMeter* gm; + Gtk::VBox meter_packer; + void add_gain_meter (); + void remove_gain_meter (); + void meter (); + void start_metering (); + void stop_metering (); + sigc::connection metering_connection; + void update_preview (); void found_list_view_selected (); void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*); @@ -150,6 +162,10 @@ class SoundFileBrowser : public ArdourDialog bool on_custom (const Gtk::FileFilter::Info& filter_info); virtual bool reset_options() { return true; } + + protected: + void on_show(); + }; class SoundFileChooser : public SoundFileBrowser @@ -162,9 +178,6 @@ class SoundFileChooser : public SoundFileBrowser protected: void on_hide(); - - private: - // SoundFileBrowser browser; }; class SoundFileOmega : public SoundFileBrowser @@ -178,12 +191,14 @@ class SoundFileOmega : public SoundFileBrowser Gtk::ComboBoxText action_combo; Gtk::ComboBoxText where_combo; Gtk::ComboBoxText channel_combo; - + Gtk::ComboBoxText src_combo; + Gtk::CheckButton copy_files_btn; Editing::ImportMode get_mode() const; Editing::ImportPosition get_position() const; Editing::ImportDisposition get_channel_disposition() const; + ARDOUR::SrcQuality get_src_quality() const; protected: void on_hide(); @@ -199,7 +214,9 @@ class SoundFileOmega : public SoundFileBrowser Gtk::VBox block_three; Gtk::VBox block_four; - static bool check_multichannel_status (const std::vector<Glib::ustring>& paths, bool& same_size, bool& err); + bool check_info (const std::vector<Glib::ustring>& paths, + bool& same_size, bool& src_needed, bool& multichannel); + static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths); void file_selection_changed (); diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 8dfb5cc0a9..a5a6ebd20e 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -192,9 +192,7 @@ class IO : public PBD::StatefulDestructible /* Peak metering */ float peak_input_power (uint32_t n) { - if (_ninputs == 0) { - return minus_infinity(); - } else if (n < std::max (_ninputs, _noutputs)) { + if (n < std::max (_ninputs, _noutputs)) { return _visible_peak_power[n]; } else { return minus_infinity(); @@ -202,9 +200,7 @@ class IO : public PBD::StatefulDestructible } float max_peak_power (uint32_t n) { - if (_ninputs == 0) { - return minus_infinity(); - } else if (n < std::max (_ninputs, _noutputs)) { + if (n < std::max (_ninputs, _noutputs)) { return _max_peak_power[n]; } else { return minus_infinity(); diff --git a/libs/ardour/ardour/resampled_source.h b/libs/ardour/ardour/resampled_source.h index af7b4a07fe..9a88ca9644 100644 --- a/libs/ardour/ardour/resampled_source.h +++ b/libs/ardour/ardour/resampled_source.h @@ -22,6 +22,7 @@ #include <samplerate.h> +#include <ardour/types.h> #include <ardour/importable_source.h> namespace ARDOUR { @@ -29,7 +30,7 @@ namespace ARDOUR { class ResampledImportableSource : public ImportableSource { public: - ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate); + ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate, SrcQuality); ~ResampledImportableSource (); nframes_t read (Sample* buffer, nframes_t nframes); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 3f587ec2da..5df4c7f4ee 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -564,6 +564,7 @@ class Session : public PBD::StatefulDestructible /* control info */ bool sample_convert; + SrcQuality quality; volatile bool freeze; std::vector<Glib::ustring> paths; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 397575f087..a8c6414798 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -361,6 +361,14 @@ namespace ARDOUR { typedef std::vector<boost::shared_ptr<AudioSource> > SourceList; + enum SrcQuality { + SrcBest, + SrcGood, + SrcQuick, + SrcFast, + SrcFastest + }; + } // namespace ARDOUR std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf); diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc index d10010fbf0..fb4e5af1ae 100644 --- a/libs/ardour/audiofilter.cc +++ b/libs/ardour/audiofilter.cc @@ -50,6 +50,7 @@ AudioFilter::make_new_sources (boost::shared_ptr<AudioRegion> region, SourceList try { nsrcs.push_back (boost::dynamic_pointer_cast<AudioSource> (SourceFactory::createWritable (session, path, false, session.frame_rate()))); + nsrcs.back()->prepare_for_peakfile_writes (); } catch (failed_constructor& err) { @@ -76,6 +77,12 @@ AudioFilter::finish (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs) for (SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource>(*si); + boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource>(*si); + + if (as) { + as->done_with_peakfile_writes (); + } + if (afs) { afs->update_header (region->position(), *now, xnow); afs->mark_immutable (); diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 80b88de5ea..cfb3982921 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -81,7 +81,7 @@ Session::import_audiofile (import_status& status) } if ((nframes_t) info.samplerate != frame_rate()) { - importable = new ResampledImportableSource (in, &info, frame_rate()); + importable = new ResampledImportableSource (in, &info, frame_rate(), status.quality); } else { importable = new ImportableSource (in, &info); } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index cb66830409..72d6ebe1ca 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -2475,7 +2475,7 @@ IO::meter () { Glib::Mutex::Lock lm (io_lock); // READER: meter thread. uint32_t limit = max (_ninputs, _noutputs); - + for (uint32_t n = 0; n < limit; ++n) { /* XXX we should use atomic exchange here */ @@ -2497,7 +2497,6 @@ IO::meter () _max_peak_power[n] = max (new_peak, _max_peak_power[n]); - if (Config->get_meter_falloff() == 0.0f || new_peak > _visible_peak_power[n]) { _visible_peak_power[n] = new_peak; } else { diff --git a/libs/ardour/resampled_source.cc b/libs/ardour/resampled_source.cc index 29dab6e0cb..38aa3832b9 100644 --- a/libs/ardour/resampled_source.cc +++ b/libs/ardour/resampled_source.cc @@ -28,7 +28,7 @@ using namespace PBD; const uint32_t ResampledImportableSource::blocksize = 4096U; -ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate) +ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate, SrcQuality srcq) : ImportableSource (sf, info) { int err; @@ -37,7 +37,27 @@ ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info /* Initialize the sample rate converter. */ - if ((src_state = src_new (SRC_SINC_BEST_QUALITY, sf_info->channels, &err)) == 0) { + int src_type; + + switch (srcq) { + case SrcBest: + src_type = SRC_SINC_BEST_QUALITY; + break; + case SrcGood: + src_type = SRC_SINC_MEDIUM_QUALITY; + break; + case SrcQuick: + src_type = SRC_SINC_FASTEST; + break; + case SrcFast: + src_type = SRC_ZERO_ORDER_HOLD; + break; + case SrcFastest: + src_type = SRC_LINEAR; + break; + } + + if ((src_state = src_new (src_type, sf_info->channels, &err)) == 0) { error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ; throw failed_constructor (); } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 2cd4cb70cf..20b7cd86c8 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -711,7 +711,6 @@ Route::process_output_buffers (vector<Sample*>& bufs, uint32_t nbufs, -------------------------------------------------------------------------------------------------- */ if (meter && (_meter_point == MeterPostFader)) { -// cerr << "meter post" << endl; if ((_gain == 0 && !apply_gain_automation) || dmg == 0) { uint32_t no = n_outputs(); diff --git a/libs/ardour/session_timefx.cc b/libs/ardour/session_timefx.cc index 37b0aa1d48..e2cd6f6543 100644 --- a/libs/ardour/session_timefx.cc +++ b/libs/ardour/session_timefx.cc @@ -95,12 +95,12 @@ Session::tempoize_region (TimeStretchRequest& tsr) try { sources.push_back (boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (*this, path, false, frame_rate()))); + sources.back()->prepare_for_peakfile_writes (); } catch (failed_constructor& err) { error << string_compose (_("tempoize: error creating new audio file %1 (%2)"), path, strerror (errno)) << endmsg; goto out; } - } try { @@ -166,6 +166,12 @@ Session::tempoize_region (TimeStretchRequest& tsr) for (it = sources.begin(); it != sources.end(); ++it) { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource>(*it); + boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource>(*it); + + if (as) { + as->done_with_peakfile_writes (); + } + if (afs) { afs->update_header (tsr.region->position(), *xnow, now); } |