From dc815ea8e84d28fc01a68225c2ece4399c4a9c7e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 15 Apr 2010 20:42:05 +0000 Subject: [PATCH] forward-port from 2.X commits 5827-6000 including git-svn-id: svn://localhost/ardour2/branches/3.0@6914 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour.menus.in | 1 + gtk2_ardour/audio_region_view.cc | 2 +- gtk2_ardour/editor.cc | 26 ++++++++++- gtk2_ardour/mnemonic-us.bindings.in | 1 + gtk2_ardour/plugin_ui.h | 2 +- gtk2_ardour/sfdb_ui.cc | 3 ++ libs/ardour/ardour/ladspa_plugin.h | 2 +- libs/ardour/ardour/region.h | 5 +++ libs/ardour/ardour/vst_plugin.h | 2 +- libs/ardour/audioregion.cc | 18 +++++--- libs/ardour/audiosource.cc | 38 +++++++++------- libs/ardour/ladspa_plugin.cc | 5 +++ libs/ardour/lv2_plugin.cc | 1 + libs/ardour/playlist.cc | 4 +- libs/ardour/plugin_insert.cc | 25 +---------- libs/ardour/region.cc | 70 ++++++++++++++++++++--------- libs/ardour/sndfile_helpers.cc | 11 +++++ libs/ardour/sndfilesource.cc | 12 +++-- libs/ardour/vst_plugin.cc | 5 +++ 19 files changed, 158 insertions(+), 75 deletions(-) diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index caa9498869..b25a8a5bce 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -49,6 +49,7 @@ + diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 5a28a2f484..13e21b9a63 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -498,7 +498,7 @@ AudioRegionView::set_height (gdouble height) } } - gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE)); + gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2); } manage_zero_line (); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 715800550e..cbeaae9886 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -220,6 +220,27 @@ show_me_the_size (Requisition* r, const char* what) cerr << "size of " << what << " = " << r->width << " x " << r->height << endl; } +#ifdef GTKOSX +static void +pane_size_watcher (Paned* pane) +{ + /* if the handle of a pane vanishes into (at least) the tabs of a notebook, + it is no longer accessible. so stop that. this doesn't happen on X11, + just the quartz backend. + + ugh. + */ + + int max_width_of_lhs = GTK_WIDGET(pane->gobj())->allocation.width - 25; + + gint pos = pane->get_position (); + + if (pos > max_width_of_lhs) { + pane->set_position (max_width_of_lhs); + } +} +#endif + Editor::Editor () : _join_object_range_state (JOIN_OBJECT_RANGE_NONE) @@ -588,7 +609,10 @@ Editor::Editor () edit_pane.pack2 (the_notebook, false, true); edit_pane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Editor::pane_allocation_handler), static_cast (&edit_pane))); - +#ifdef GTKOSX + Glib::PropertyProxy proxy = edit_pane.property_position(); + proxy.signal_changed().connect (bind (sigc::ptr_fun (pane_size_watcher), static_cast (&edit_pane))); +#endif top_hbox.pack_start (toolbar_frame, false, true); HBox *hbox = manage (new HBox); diff --git a/gtk2_ardour/mnemonic-us.bindings.in b/gtk2_ardour/mnemonic-us.bindings.in index 8f6b1e46d2..3056b2e3e5 100644 --- a/gtk2_ardour/mnemonic-us.bindings.in +++ b/gtk2_ardour/mnemonic-us.bindings.in @@ -103,6 +103,7 @@ This mode provides many different operations on both regions and control points, @trans|Transport/ToggleRoll|space|toggle roll @epp|Editor/play-edit-range|<@SECONDARY@>space|play edit range @epp|Editor/play-from-edit-point-and-return|<@LEVEL4@>space|play from EP \& return +@trans|Transport/ToggleRollMaybe|<@PRIMARY@><@SECONDARY>space|stop but do not leave loop/range play @trans|Transport/ToggleRollForgetCapture|<@PRIMARY@>space|stop and destroy @trans|Transport/record-roll|<@TERTIARY@>space|start recording diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index efef275eaa..7b5e77ec18 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -176,7 +176,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox } }; - static const int32_t initial_button_rows = 6; + static const int32_t initial_button_rows = 12; static const int32_t initial_button_cols = 1; static const int32_t initial_output_rows = 1; static const int32_t initial_output_cols = 4; diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 381489cf88..c266b80883 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -423,6 +423,9 @@ SoundFileBrowser::SoundFileBrowser (Gtk::Window& parent, string title, ARDOUR::S chooser.add_shortcut_folder_uri("file:///Library/Application Support/GarageBand/Instrument Library/Sampler/Sampler Files"); } +#ifdef GTKOSX + chooser.add_shortcut_folder_uri("file:///Volumes"); +#endif //add the file chooser { diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index 00f00c99b6..bdad8009f5 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -137,7 +137,7 @@ class LadspaPlugin : public ARDOUR::Plugin class LadspaPluginInfo : public PluginInfo { public: - LadspaPluginInfo () { }; + LadspaPluginInfo (); ~LadspaPluginInfo () { }; PluginPtr load (Session& session); diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index a44b3fcb46..2cf9bab97b 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -188,6 +188,9 @@ class Region void trim_end (framepos_t new_position, void *src); void trim_to (framepos_t position, framecnt_t length, void *src); + void cut_front (nframes_t new_position, void *src); + void cut_end (nframes_t new_position, void *src); + void set_layer (layer_t l); /* ONLY Playlist can call this */ void raise (); void lower (); @@ -288,6 +291,8 @@ class Region void trim_to_internal (framepos_t position, framecnt_t length, void *src); virtual void set_position_internal (framepos_t pos, bool allow_bbt_recompute); + void modify_front (nframes_t new_position, bool reset_fade, void* src); + void modify_end (nframes_t new_position, bool reset_fade, void* src); void maybe_uncopy (); void first_edit (); diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h index 513f24d493..cfc5a117a0 100644 --- a/libs/ardour/ardour/vst_plugin.h +++ b/libs/ardour/ardour/vst_plugin.h @@ -101,7 +101,7 @@ class VSTPlugin : public ARDOUR::Plugin class VSTPluginInfo : public PluginInfo { public: - VSTPluginInfo () {} + VSTPluginInfo (); ~VSTPluginInfo () {} PluginPtr load (Session& session); diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index be6cce251a..15110e4869 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -948,15 +948,18 @@ AudioRegion::recompute_at_end () _envelope->set_max_xval (_length); _envelope->thaw (); + if (_left_of_split) { + set_default_fade_out (); + _left_of_split = false; + } else if (_fade_out->back()->when > _length) { + _fade_out->extend_to (_length); + send_change (PropertyChange (Properties::fade_out)); + } + if (_fade_in->back()->when > _length) { _fade_in->extend_to (_length); send_change (PropertyChange (Properties::fade_in)); } - - if (_fade_out->back()->when > _length) { - _fade_out->extend_to (_length); - send_change (PropertyChange (Properties::fade_out)); - } } void @@ -966,7 +969,10 @@ AudioRegion::recompute_at_start () _envelope->truncate_start (_length); - if (_fade_in->back()->when > _length) { + if (_right_of_split) { + set_default_fade_in (); + _right_of_split = false; + } else if (_fade_in->back()->when > _length) { _fade_in->extend_to (_length); send_change (PropertyChange (Properties::fade_in)); } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 8a367f32a7..60bd5804b3 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -548,22 +548,30 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t to_read = min (chunksize, (framecnt_t)(_length - current_frame)); - if (to_read == 0) { - /* XXX ARGH .. out by one error ... need to figure out why this happens - and fix it rather than do this band-aid move. + if (current_frame >= _length) { + + /* hmm, error condition - we've reached the end of the file + without generating all the peak data. cook up a zero-filled + data buffer and then use it. this is simpler than + adjusting zero_fill and npeaks and then breaking out of + this loop early */ - zero_fill = npeaks - nvisual_peaks; - npeaks -= zero_fill; - break; - } - - if ((frames_read = read_unlocked (raw_staging, current_frame, to_read)) == 0) { - error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"), - _name, to_read, current_frame, _length, strerror (errno)) - << endmsg; - goto out; - } - + + memset (raw_staging, 0, sizeof (Sample) * chunksize); + + } else { + + to_read = min (chunksize, (_length - current_frame)); + + + if ((frames_read = read_unlocked (raw_staging, current_frame, to_read)) == 0) { + error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"), + _name, to_read, current_frame, _length, strerror (errno)) + << endmsg; + goto out; + } + } + i = 0; } diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index efbc97bc91..81cdff9618 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -703,3 +703,8 @@ LadspaPluginInfo::load (Session& session) return PluginPtr ((Plugin*) 0); } } + +LadspaPluginInfo::LadspaPluginInfo() +{ + type = ARDOUR::LADSPA; +} diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 368c521d0b..9ba4533456 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -680,6 +680,7 @@ LV2PluginInfo::LV2PluginInfo (void* lv2_world, void* slv2_plugin) : _lv2_world(lv2_world) , _slv2_plugin(slv2_plugin) { + type = ARDOUR::LV2; } LV2PluginInfo::~LV2PluginInfo() diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 676d4a820a..57f49a68d5 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1004,7 +1004,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re current->suspend_property_changes (); thawlist.push_back (current); - current->trim_end (pos2, this); + current->cut_end (pos2, this); } else if (overlap == OverlapEnd) { @@ -1043,7 +1043,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re current->suspend_property_changes (); thawlist.push_back (current); - current->trim_end (pos2, this); + current->cut_end (pos2, this); } else if (overlap == OverlapStart) { diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index ddc69a74ac..f50483beaf 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -965,30 +965,7 @@ PluginInsert::signal_latency() const ARDOUR::PluginType PluginInsert::type () { - boost::shared_ptr lp; -#ifdef VST_SUPPORT - boost::shared_ptr vp; -#endif -#ifdef HAVE_AUDIOUNITS - boost::shared_ptr ap; -#endif - - PluginPtr other = plugin (); - - if ((lp = boost::dynamic_pointer_cast (other)) != 0) { - return ARDOUR::LADSPA; -#ifdef VST_SUPPORT - } else if ((vp = boost::dynamic_pointer_cast (other)) != 0) { - return ARDOUR::VST; -#endif -#ifdef HAVE_AUDIOUNITS - } else if ((ap = boost::dynamic_pointer_cast (other)) != 0) { - return ARDOUR::AudioUnit; -#endif - } else { - /* NOT REACHED */ - return (ARDOUR::PluginType) 0; - } + return plugin()->get_info()->type; } PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr list) diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 8625b17a8a..2589f94f81 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -763,13 +763,31 @@ Region::trim_start (framepos_t new_position, void */*src*/) void Region::trim_front (framepos_t new_position, void *src) +{ + modify_front (new_position, false, src); +} + +void +Region::cut_front (nframes_t new_position, void *src) +{ + modify_front (new_position, true, src); +} + +void +Region::cut_end (nframes_t new_endpoint, void *src) +{ + modify_end (new_endpoint, true, src); +} + +void +Region::modify_front (nframes_t new_position, bool reset_fade, void *src) { if (locked()) { return; } - framepos_t end = last_frame(); - framepos_t source_zero; + nframes_t end = last_frame(); + nframes_t source_zero; if (_position > _start) { source_zero = _position - _start; @@ -778,44 +796,56 @@ Region::trim_front (framepos_t new_position, void *src) } if (new_position < end) { /* can't trim it zero or negative length */ - - framecnt_t newlen; + + nframes_t newlen; /* can't trim it back passed where source position zero is located */ - + new_position = max (new_position, source_zero); - - + if (new_position > _position) { newlen = _length - (new_position - _position); } else { newlen = _length + (_position - new_position); } - + trim_to_internal (new_position, newlen, src); - if (!property_changes_suspended()) { + if (reset_fade) { + _right_of_split = true; + } + + if (!property_changes_suspended()) { recompute_at_start (); } } } +void +Region::modify_end (nframes_t new_endpoint, bool reset_fade, void *src) +{ + if (locked()) { + return; + } + + if (new_endpoint > _position) { + trim_to_internal (_position, new_endpoint - _position +1, this); + if (reset_fade) { + _left_of_split = true; + } + if (!property_changes_suspended()) { + recompute_at_end (); + } + } +} + /** @param new_endpoint New region end point, such that, for example, * a region at 0 of length 10 has an endpoint of 9. */ void -Region::trim_end (framepos_t new_endpoint, void */*src*/) +Region::trim_end (framepos_t new_endpoint, void* src) { - if (locked()) { - return; - } - - if (new_endpoint > _position) { - trim_to_internal (_position, new_endpoint - _position + 1, this); - if (!property_changes_suspended()) { - recompute_at_end (); - } - } + modify_end (new_endpoint, false, src); } void diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc index 057efff48c..32ff48f485 100644 --- a/libs/ardour/sndfile_helpers.cc +++ b/libs/ardour/sndfile_helpers.cc @@ -17,6 +17,7 @@ */ +#include #include #include @@ -177,6 +178,16 @@ sndfile_major_format(int format) sf_command (0, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)); m[format_info.format & SF_FORMAT_TYPEMASK] = format_info.name; + + /* normalize a couple of names rather than use what libsndfile gives us */ + + if (strncasecmp (format_info.name, "OGG", 3) == 0) { + m[format_info.format & SF_FORMAT_TYPEMASK] = "Ogg"; + } else if (strncasecmp (format_info.name, "WAV", 3) == 0) { + m[format_info.format & SF_FORMAT_TYPEMASK] = "WAV"; + } else { + m[format_info.format & SF_FORMAT_TYPEMASK] = format_info.name; + } } } diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index fa709cde24..0ab55d160a 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -816,9 +816,15 @@ SndFileSource::get_soundfile_info (const ustring& path, SoundFileInfo& info, str info.samplerate = sf_info.samplerate; info.channels = sf_info.channels; info.length = sf_info.frames; - info.format_name = string_compose("Format: %1, %2", - sndfile_major_format(sf_info.format), - sndfile_minor_format(sf_info.format)); + + string major = sndfile_major_format(sf_info.format); + string minor = sndfile_minor_format(sf_info.format); + + if (major.length() + minor.length() < 16) { /* arbitrary */ + info.format_name = string_compose("%1/%2", major, minor); + } else { + info.format_name = string_compose("%1\n%2", major, minor); + } info.timecode = binfo.load_from_file (sf) ? binfo.get_time_reference() : 0; diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 6367a668dd..7fb5289f9c 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -524,3 +524,8 @@ VSTPluginInfo::load (Session& session) return PluginPtr ((Plugin*) 0); } } + +VSTPluginInfo::VSTPluginInfo() +{ + type = ARDOUR::VST; +}