summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-03-15 19:42:42 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-03-15 19:42:42 +0000
commit702411f6582073e198fb8c6ae6b0ba43b00a5840 (patch)
treefa975802e3e0e5d776f2a06779d1831c16be49d5
parent6fadaae2cbc6ed0bc83136cde7536623894f819d (diff)
edit groups tab gets headers (carl); use sampo's SSE find_peaks code; fix build for find_peaks on x86; don't duplicate sources when embedding; use Glib::ustring for all source-related strings; fixup plugin UI automation buttons
git-svn-id: svn://localhost/ardour2/trunk@1595 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--SConstruct2
-rw-r--r--gtk2_ardour/ardour_ui_ed.cc3
-rw-r--r--gtk2_ardour/ardour_ui_options.cc2
-rw-r--r--gtk2_ardour/editor.cc2
-rw-r--r--gtk2_ardour/editor_audio_import.cc20
-rw-r--r--gtk2_ardour/ladspa_pluginui.cc15
-rw-r--r--libs/ardour/SConscript18
-rw-r--r--libs/ardour/ardour/audiofilesource.h46
-rw-r--r--libs/ardour/ardour/audiosource.h24
-rw-r--r--libs/ardour/ardour/mix.h2
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/ardour/sndfilesource.h6
-rw-r--r--libs/ardour/audiofilesource.cc111
-rw-r--r--libs/ardour/audiosource.cc39
-rw-r--r--libs/ardour/playlist.cc4
-rw-r--r--libs/ardour/session.cc18
-rw-r--r--libs/ardour/sndfilesource.cc17
-rw-r--r--libs/ardour/sse_functions_xmm.cc2
-rw-r--r--libs/pbd/pbd/strsplit.h2
-rw-r--r--libs/pbd/strsplit.cc39
20 files changed, 223 insertions, 150 deletions
diff --git a/SConstruct b/SConstruct
index 95fa911a8d..d7ec207268 100644
--- a/SConstruct
+++ b/SConstruct
@@ -16,7 +16,7 @@ import SCons.Node.FS
SConsignFile()
EnsureSConsVersion(0, 96)
-ardour_version = '2.0beta11.1'
+ardour_version = '2.0beta12'
subst_dict = { }
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc
index 3fdcee5d6a..3ab6c30e55 100644
--- a/gtk2_ardour/ardour_ui_ed.cc
+++ b/gtk2_ardour/ardour_ui_ed.cc
@@ -394,6 +394,9 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_toggle_action (option_actions, X_("UseOSC"), _("Use OSC"), mem_fun (*this, &ARDOUR_UI::toggle_use_osc));
+#ifndef HAVE_LIBLO
+ act->set_sensitive (false);
+#endif
ActionManager::register_toggle_action (option_actions, X_("StopPluginsWithTransport"), _("Stop plugins with transport"), mem_fun (*this, &ARDOUR_UI::toggle_StopPluginsWithTransport));
ActionManager::register_toggle_action (option_actions, X_("VerifyRemoveLastCapture"), _("Verify remove last capture"), mem_fun (*this, &ARDOUR_UI::toggle_VerifyRemoveLastCapture));
diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc
index a90e06bc61..c7db8f4ec6 100644
--- a/gtk2_ardour/ardour_ui_options.cc
+++ b/gtk2_ardour/ardour_ui_options.cc
@@ -853,11 +853,13 @@ ARDOUR_UI::parameter_changed (const char* parameter_name)
} else if (PARAM_IS ("use-osc")) {
+#ifdef HAVE_LIBLO
if (Config->get_use_osc()) {
osc->start ();
} else {
osc->stop ();
}
+#endif
ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 9a1456ca46..5abfc3caf4 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -508,7 +508,7 @@ Editor::Editor ()
edit_group_display.set_name ("EditGroupList");
edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
- edit_group_display.set_headers_visible (false);
+ edit_group_display.set_headers_visible (true);
edit_group_display.set_reorderable (false);
edit_group_display.set_rules_hint (true);
edit_group_display.set_size_request (75, -1);
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 57c0d00639..fa6b9da5fa 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -370,11 +370,21 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
for (int n = 0; n < finfo.channels; ++n)
{
try {
- source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable
- (*session, path, n,
- (mode == ImportAsTapeTrack ?
- AudioFileSource::Destructive :
- AudioFileSource::Flag (0))));
+
+ /* check if we have this thing embedded already */
+
+ boost::shared_ptr<Source> s;
+
+ if ((s = session->source_by_path_and_channel (path, n)) == 0) {
+ cerr << "source doesn't exist yet\n";
+ source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable
+ (*session, path, n,
+ (mode == ImportAsTapeTrack ?
+ AudioFileSource::Destructive :
+ AudioFileSource::Flag (0))));
+ } else {
+ source = boost::dynamic_pointer_cast<AudioFileSource> (s);
+ }
sources.push_back(source);
}
diff --git a/gtk2_ardour/ladspa_pluginui.cc b/gtk2_ardour/ladspa_pluginui.cc
index 4d78dc70e0..0de6f50751 100644
--- a/gtk2_ardour/ladspa_pluginui.cc
+++ b/gtk2_ardour/ladspa_pluginui.cc
@@ -292,12 +292,14 @@ LadspaPluginUI::ControlUI::ControlUI ()
: automate_button (X_("")) // force creation of a label
{
automate_button.set_name ("PluginAutomateButton");
- ARDOUR_UI::instance()->tooltips().set_tip (automate_button,
- _("Automation control"));
+ ARDOUR_UI::instance()->tooltips().set_tip (automate_button, _("Automation control"));
- /* don't fix the height, it messes up the bar controllers */
+ /* XXX translators: use a string here that will be at least as long
+ as the longest automation label (see ::automation_state_changed()
+ below). be sure to include a descender.
+ */
- set_size_request_to_display_given_text (automate_button, X_("lngnuf"), 2, 2);
+ set_size_request_to_display_given_text (*automate_button.get_child(), _("Mgnual"), 5, 5);
ignore_change = 0;
display = 0;
@@ -377,6 +379,8 @@ LadspaPluginUI::build_control_ui (guint32 port_index, PBD::Controllable* mcontro
control_ui->set_spacing (5);
+ Gtk::Requisition req (control_ui->automate_button.size_request());
+
if (plugin->parameter_is_input (port_index)) {
boost::shared_ptr<LadspaPlugin> lp;
@@ -455,8 +459,7 @@ LadspaPluginUI::build_control_ui (guint32 port_index, PBD::Controllable* mcontro
sigc::slot<void,char*,uint32_t> pslot = sigc::bind (mem_fun(*this, &LadspaPluginUI::print_parameter), (uint32_t) port_index);
control_ui->control = new BarController (*control_ui->adjustment, *mcontrol, pslot);
- // should really match the height of the text in the automation button+label
- control_ui->control->set_size_request (200, 22);
+ control_ui->control->set_size_request (200, req.height);
control_ui->control->set_name (X_("PluginSlider"));
control_ui->control->set_style (BarController::LeftToRight);
control_ui->control->set_use_parent (true);
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index 47015f4d07..afd5c7a2b0 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -283,19 +283,29 @@ env['BUILDERS']['SharedAsmObject'] = Builder (action = '$CXX -c -fPIC $SOURCE -o
suffix = '$SHOBJSUFFIX',
src_suffix = '.s',
single_source = 1)
+#
+# handle objects that should always be compiled with -msse in their own
+# special environment, which is exactly like "ardour" but unconditionally
+# includes -msse
+#
+
+
+always_sse_objects = []
+sse_env = ardour.Copy()
+sse_env.Append (CXXFLAGS="-msse")
if env['FPU_OPTIMIZATION']:
if env['DIST_TARGET'] == "i386":
arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
- ardour_files += ['sse_functions_xmm.cc']
+ always_sse_objects += ['sse_functions_xmm.os']
if env['DIST_TARGET'] == "i686":
arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
- ardour_files += ['sse_functions_xmm.cc']
+ always_sse_objects += ['sse_functions_xmm.os']
if env['DIST_TARGET'] == "x86_64":
arch_specific_objects = env.SharedAsmObject('sse_functions_64bit.os', 'sse_functions_64bit.s')
- ardour_files += ['sse_functions_xmm.cc']
+ always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
-libardour = ardour.SharedLibrary('ardour', ardour_files + extra_sources + arch_specific_objects)
+libardour = ardour.SharedLibrary('ardour', ardour_files + always_sse_objects + extra_sources + arch_specific_objects)
Default(libardour)
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 899b0ea3ff..6bc9ec4207 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -56,17 +56,19 @@ class AudioFileSource : public AudioSource {
virtual ~AudioFileSource ();
- int set_name (string newname, bool destructive);
+ int set_name (Glib::ustring newname, bool destructive);
+
+ Glib::ustring path() const { return _path; }
+ Glib::ustring peak_path (Glib::ustring audio_path);
+ Glib::ustring old_peak_path (Glib::ustring audio_path);
- string path() const { return _path; }
- string peak_path (string audio_path);
- string old_peak_path (string audio_path);
+ uint16_t channel() const { return _channel; }
- static void set_peak_dir (string dir) { peak_dir = dir; }
+ static void set_peak_dir (Glib::ustring dir) { peak_dir = dir; }
- static bool get_soundfile_info (string path, SoundFileInfo& _info, string& error);
+ static bool get_soundfile_info (Glib::ustring path, SoundFileInfo& _info, std::string& error);
- static bool safe_file_extension (string path);
+ static bool safe_file_extension (Glib::ustring path);
void set_allow_remove_if_empty (bool yn);
void mark_for_remove();
@@ -83,19 +85,19 @@ class AudioFileSource : public AudioSource {
virtual int update_header (nframes_t when, struct tm&, time_t) = 0;
virtual int flush_header () = 0;
- int move_to_trash (const string trash_dir_name);
+ int move_to_trash (const Glib::ustring& trash_dir_name);
- static bool is_empty (Session&, string path);
+ static bool is_empty (Session&, Glib::ustring path);
void mark_streaming_write_completed ();
- void mark_take (string);
- string take_id() const { return _take_id; }
+ void mark_take (Glib::ustring);
+ Glib::ustring take_id() const { return _take_id; }
bool is_embedded() const { return _is_embedded; }
static void set_bwf_serial_number (int);
- static void set_search_path (string);
+ static void set_search_path (Glib::ustring string);
static void set_header_position_offset (nframes_t offset );
int setup_peakfile ();
@@ -124,31 +126,31 @@ class AudioFileSource : public AudioSource {
/* constructor to be called for existing external-to-session files */
- AudioFileSource (Session&, std::string path, Flag flags);
+ AudioFileSource (Session&, Glib::ustring path, Flag flags);
/* constructor to be called for new in-session files */
- AudioFileSource (Session&, std::string path, Flag flags,
+ AudioFileSource (Session&, Glib::ustring path, Flag flags,
SampleFormat samp_format, HeaderFormat hdr_format);
/* constructor to be called for existing in-session files */
AudioFileSource (Session&, const XMLNode&, bool must_exit = true);
- int init (string idstr, bool must_exist);
+ int init (Glib::ustring idstr, bool must_exist);
- string _path;
+ Glib::ustring _path;
Flag _flags;
- string _take_id;
+ Glib::ustring _take_id;
int64_t timeline_position;
bool file_is_new;
- uint16_t channel;
+ uint16_t _channel;
bool _is_embedded;
- static bool determine_embeddedness(string path);
+ static bool determine_embeddedness(Glib::ustring path);
- static string peak_dir;
- static string search_path;
+ static Glib::ustring peak_dir;
+ static Glib::ustring search_path;
static char bwf_country_code[3];
static char bwf_organization_code[4];
@@ -159,7 +161,7 @@ class AudioFileSource : public AudioSource {
virtual void set_timeline_position (int64_t pos);
virtual void set_header_timeline_position () = 0;
- bool find (std::string path, bool must_exist, bool& is_new);
+ bool find (Glib::ustring& path, bool must_exist, bool& is_new);
bool removable() const;
bool writable() const { return _flags & Writable; }
};
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h
index efd96e94eb..b1062c43a9 100644
--- a/libs/ardour/ardour/audiosource.h
+++ b/libs/ardour/ardour/audiosource.h
@@ -22,7 +22,6 @@
#include <list>
#include <vector>
-#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
@@ -30,6 +29,7 @@
#include <time.h>
#include <glibmm/thread.h>
+#include <glibmm/ustring.h>
#include <sigc++/signal.h>
@@ -40,7 +40,7 @@
using std::list;
using std::vector;
-using std::string;
+using Glib::ustring;
namespace ARDOUR {
@@ -49,7 +49,7 @@ const nframes_t frames_per_peak = 256;
class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR::AudioSource>
{
public:
- AudioSource (Session&, string name);
+ AudioSource (Session&, ustring name);
AudioSource (Session&, const XMLNode&);
virtual ~AudioSource ();
@@ -78,8 +78,8 @@ const nframes_t frames_per_peak = 256;
virtual bool can_truncate_peaks() const { return true; }
- void set_captured_for (string str) { _captured_for = str; }
- string captured_for() const { return _captured_for; }
+ void set_captured_for (ustring str) { _captured_for = str; }
+ ustring captured_for() const { return _captured_for; }
uint32_t read_data_count() const { return _read_data_count; }
uint32_t write_data_count() const { return _write_data_count; }
@@ -94,7 +94,7 @@ const nframes_t frames_per_peak = 256;
XMLNode& get_state ();
int set_state (const XMLNode&);
- int rename_peakfile (std::string newpath);
+ int rename_peakfile (ustring newpath);
void touch_peakfile ();
static void set_build_missing_peakfiles (bool yn) {
@@ -117,13 +117,13 @@ const nframes_t frames_per_peak = 256;
bool _peaks_built;
mutable Glib::Mutex _lock;
nframes_t _length;
- string peakpath;
- string _captured_for;
+ ustring peakpath;
+ ustring _captured_for;
mutable uint32_t _read_data_count; // modified in read()
mutable uint32_t _write_data_count; // modified in write()
- int initialize_peakfile (bool newfile, string path);
+ int initialize_peakfile (bool newfile, ustring path);
int build_peaks_from_scratch ();
int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, bool force);
void truncate_peakfile();
@@ -132,8 +132,8 @@ const nframes_t frames_per_peak = 256;
virtual nframes_t read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const = 0;
virtual nframes_t write_unlocked (Sample *dst, nframes_t cnt) = 0;
- virtual string peak_path(string audio_path) = 0;
- virtual string old_peak_path(string audio_path) = 0;
+ virtual ustring peak_path(ustring audio_path) = 0;
+ virtual ustring old_peak_path(ustring audio_path) = 0;
void update_length (nframes_t pos, nframes_t cnt);
@@ -144,7 +144,7 @@ const nframes_t frames_per_peak = 256;
Sample* peak_leftovers;
nframes_t peak_leftover_frame;
- bool file_changed (string path);
+ bool file_changed (ustring path);
};
}
diff --git a/libs/ardour/ardour/mix.h b/libs/ardour/ardour/mix.h
index 68f57c1aa8..5555f5437e 100644
--- a/libs/ardour/ardour/mix.h
+++ b/libs/ardour/ardour/mix.h
@@ -68,7 +68,7 @@ void veclib_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src
float compute_peak (ARDOUR::Sample *buf, nframes_t nsamples, float current);
-void find_peaks (ARDOUR::Sample *buf, nframes_t nsamples, float *min, float *max);
+void find_peaks (ARDOUR::Sample *buf, nframes_t nsamples, float *min, float *max);
void apply_gain_to_buffer (ARDOUR::Sample *buf, nframes_t nframes, float gain);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 05840cbc43..d65903ce85 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -608,6 +608,7 @@ class Session : public PBD::StatefulDestructible
boost::shared_ptr<AudioFileSource> create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive);
boost::shared_ptr<Source> source_by_id (const PBD::ID&);
+ boost::shared_ptr<Source> source_by_path_and_channel (const Glib::ustring&, uint16_t);
/* playlist management */
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index 262dc46016..2fc3872887 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -30,11 +30,11 @@ class SndFileSource : public AudioFileSource {
public:
/* constructor to be called for existing external-to-session files */
- SndFileSource (Session&, std::string path, int chn, Flag flags);
+ SndFileSource (Session&, Glib::ustring path, int chn, Flag flags);
/* constructor to be called for new in-session files */
- SndFileSource (Session&, std::string path, SampleFormat samp_format, HeaderFormat hdr_format, nframes_t rate,
+ SndFileSource (Session&, Glib::ustring path, SampleFormat samp_format, HeaderFormat hdr_format, nframes_t rate,
Flag flags = SndFileSource::default_writable_flags);
/* constructor to be called for existing in-session files */
@@ -59,7 +59,7 @@ class SndFileSource : public AudioFileSource {
static void setup_standard_crossfades (nframes_t sample_rate);
static const AudioFileSource::Flag default_writable_flags;
- static int get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg);
+ static int get_soundfile_info (const Glib::ustring& path, SoundFileInfo& _info, string& error_msg);
protected:
void set_header_timeline_position ();
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index f636a39542..717ac91e3b 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -53,9 +53,10 @@
using namespace ARDOUR;
using namespace PBD;
+using namespace Glib;
-string AudioFileSource::peak_dir = "";
-string AudioFileSource::search_path;
+ustring AudioFileSource::peak_dir = "";
+ustring AudioFileSource::search_path;
sigc::signal<void> AudioFileSource::HeaderPositionOffsetChanged;
uint64_t AudioFileSource::header_position_offset = 0;
@@ -63,9 +64,9 @@ uint64_t AudioFileSource::header_position_offset = 0;
/* XXX maybe this too */
char AudioFileSource::bwf_serial_number[13] = "000000000000";
-AudioFileSource::AudioFileSource (Session& s, string path, Flag flags)
+AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
: AudioSource (s, path), _flags (flags),
- channel (0)
+ _channel (0)
{
/* constructor used for existing external to session files. file must exist already */
_is_embedded = AudioFileSource::determine_embeddedness (path);
@@ -76,9 +77,9 @@ AudioFileSource::AudioFileSource (Session& s, string path, Flag flags)
}
-AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
+AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
: AudioSource (s, path), _flags (flags),
- channel (0)
+ _channel (0)
{
/* constructor used for new internal-to-session files. file cannot exist */
_is_embedded = false;
@@ -90,7 +91,7 @@ AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, Samp
AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
: AudioSource (s, node), _flags (Flag (Writable|CanRename))
- /* channel is set in set_state() */
+ /* _channel is set in set_state() */
{
/* constructor used for existing internal-to-session files. file must exist */
@@ -112,7 +113,7 @@ AudioFileSource::~AudioFileSource ()
}
bool
-AudioFileSource::determine_embeddedness (std::string path)
+AudioFileSource::determine_embeddedness (ustring path)
{
return (path.find("/") == 0);
}
@@ -124,7 +125,7 @@ AudioFileSource::removable () const
}
int
-AudioFileSource::init (string pathstr, bool must_exist)
+AudioFileSource::init (ustring pathstr, bool must_exist)
{
bool is_new = false;
@@ -145,40 +146,40 @@ AudioFileSource::init (string pathstr, bool must_exist)
}
-string
-AudioFileSource::peak_path (string audio_path)
+ustring
+AudioFileSource::peak_path (ustring audio_path)
{
return _session.peak_path_from_audio_path (audio_path);
}
-string
-AudioFileSource::old_peak_path (string audio_path)
+ustring
+AudioFileSource::old_peak_path (ustring audio_path)
{
/* XXX hardly bombproof! fix me */
struct stat stat_file;
struct stat stat_mount;
- string mp = mountpoint (audio_path);
+ ustring mp = mountpoint (audio_path);
stat (audio_path.c_str(), &stat_file);
stat (mp.c_str(), &stat_mount);
char buf[32];
#ifdef __APPLE__
- snprintf (buf, sizeof (buf), "%u-%u-%d.peak", stat_mount.st_ino, stat_file.st_ino, channel);
+ snprintf (buf, sizeof (buf), "%u-%u-%d.peak", stat_mount.st_ino, stat_file.st_ino, _channel);
#else
- snprintf (buf, sizeof (buf), "%ld-%ld-%d.peak", stat_mount.st_ino, stat_file.st_ino, channel);
+ snprintf (buf, sizeof (buf), "%ld-%ld-%d.peak", stat_mount.st_ino, stat_file.st_ino, _channel);
#endif
- string res = peak_dir;
+ ustring res = peak_dir;
res += buf;
return res;
}
bool
-AudioFileSource::get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg)
+AudioFileSource::get_soundfile_info (ustring path, SoundFileInfo& _info, string& error_msg)
{
#ifdef HAVE_COREAUDIO
if (CoreAudioSource::get_soundfile_info (path, _info, error_msg) == 0) {
@@ -199,7 +200,7 @@ AudioFileSource::get_state ()
XMLNode& root (AudioSource::get_state());
char buf[32];
root.add_property (X_("flags"), enum_2_string (_flags));
- snprintf (buf, sizeof (buf), "%d", channel);
+ snprintf (buf, sizeof (buf), "%u", _channel);
root.add_property (X_("channel"), buf);
return root;
}
@@ -221,9 +222,9 @@ AudioFileSource::set_state (const XMLNode& node)
}
if ((prop = node.property (X_("channel"))) != 0) {
- channel = atoi (prop->value());
+ _channel = atoi (prop->value());
} else {
- channel = 0;
+ _channel = 0;
}
if ((prop = node.property (X_("name"))) != 0) {
@@ -265,7 +266,7 @@ AudioFileSource::mark_streaming_write_completed ()
}
void
-AudioFileSource::mark_take (string id)
+AudioFileSource::mark_take (ustring id)
{
if (writable()) {
_take_id = id;
@@ -273,14 +274,14 @@ AudioFileSource::mark_take (string id)
}
int
-AudioFileSource::move_to_trash (const string trash_dir_name)
+AudioFileSource::move_to_trash (const ustring& trash_dir_name)
{
if (is_embedded()) {
cerr << "tried to move an embedded region to trash" << endl;
return -1;
}
- string newpath;
+ ustring newpath;
if (!writable()) {
return -1;
@@ -307,7 +308,7 @@ AudioFileSource::move_to_trash (const string trash_dir_name)
char buf[PATH_MAX+1];
int version = 1;
- string newpath_v;
+ ustring newpath_v;
snprintf (buf, sizeof (buf), "%s.%d", newpath.c_str(), version);
newpath_v = buf;
@@ -358,18 +359,16 @@ AudioFileSource::move_to_trash (const string trash_dir_name)
}
bool
-AudioFileSource::find (string pathstr, bool must_exist, bool& isnew)
+AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew)
{
- string::size_type pos;
+ ustring::size_type pos;
bool ret = false;
isnew = false;
/* clean up PATH:CHANNEL notation so that we are looking for the correct path */
- if ((pos = pathstr.find_last_of (':')) == string::npos) {
- pathstr = pathstr;
- } else {
+ if ((pos = pathstr.find_last_of (':')) != ustring::npos) {
pathstr = pathstr.substr (0, pos);
}
@@ -377,10 +376,10 @@ AudioFileSource::find (string pathstr, bool must_exist, bool& isnew)
/* non-absolute pathname: find pathstr in search path */
- vector<string> dirs;
+ vector<ustring> dirs;
int cnt;
- string fullpath;
- string keeppath;
+ ustring fullpath;
+ ustring keeppath;
if (search_path.length() == 0) {
error << _("FileSource: search path not set") << endmsg;
@@ -391,7 +390,7 @@ AudioFileSource::find (string pathstr, bool must_exist, bool& isnew)
cnt = 0;
- for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
+ for (vector<ustring>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
fullpath = *i;
if (fullpath[fullpath.length()-1] != '/') {
@@ -467,7 +466,7 @@ AudioFileSource::find (string pathstr, bool must_exist, bool& isnew)
}
void
-AudioFileSource::set_search_path (string p)
+AudioFileSource::set_search_path (ustring p)
{
search_path = p;
}
@@ -500,11 +499,11 @@ AudioFileSource::set_allow_remove_if_empty (bool yn)
}
int
-AudioFileSource::set_name (string newname, bool destructive)
+AudioFileSource::set_name (ustring newname, bool destructive)
{
Glib::Mutex::Lock lm (_lock);
- string oldpath = _path;
- string newpath = Session::change_audio_path_by_name (oldpath, _name, newname, destructive);
+ ustring oldpath = _path;
+ ustring newpath = Session::change_audio_path_by_name (oldpath, _name, newname, destructive);
if (newpath.empty()) {
error << string_compose (_("programming error: %1"), "cannot generate a changed audio path") << endmsg;
@@ -529,7 +528,7 @@ AudioFileSource::set_name (string newname, bool destructive)
}
bool
-AudioFileSource::is_empty (Session& s, string path)
+AudioFileSource::is_empty (Session& s, ustring path)
{
bool ret = false;
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (s, path, 0, NoPeakFile, false));
@@ -552,26 +551,26 @@ AudioFileSource::setup_peakfile ()
}
bool
-AudioFileSource::safe_file_extension(string file)
+AudioFileSource::safe_file_extension(ustring file)
{
- return !(file.rfind(".wav") == string::npos &&
- file.rfind(".aiff")== string::npos &&
- file.rfind(".aif") == string::npos &&
- file.rfind(".snd") == string::npos &&
- file.rfind(".au") == string::npos &&
- file.rfind(".raw") == string::npos &&
- file.rfind(".sf") == string::npos &&
- file.rfind(".cdr") == string::npos &&
- file.rfind(".smp") == string::npos &&
- file.rfind(".maud")== string::npos &&
- file.rfind(".vwe") == string::npos &&
- file.rfind(".paf") == string::npos &&
+ return !(file.rfind(".wav") == ustring::npos &&
+ file.rfind(".aiff")== ustring::npos &&
+ file.rfind(".aif") == ustring::npos &&
+ file.rfind(".snd") == ustring::npos &&
+ file.rfind(".au") == ustring::npos &&
+ file.rfind(".raw") == ustring::npos &&
+ file.rfind(".sf") == ustring::npos &&
+ file.rfind(".cdr") == ustring::npos &&
+ file.rfind(".smp") == ustring::npos &&
+ file.rfind(".maud")== ustring::npos &&
+ file.rfind(".vwe") == ustring::npos &&
+ file.rfind(".paf") == ustring::npos &&
#ifdef HAVE_COREAUDIO
- file.rfind(".mp3") == string::npos &&
- file.rfind(".aac") == string::npos &&
- file.rfind(".mp4") == string::npos &&
+ file.rfind(".mp3") == ustring::npos &&
+ file.rfind(".aac") == ustring::npos &&
+ file.rfind(".mp4") == ustring::npos &&
#endif // HAVE_COREAUDIO
- file.rfind(".voc") == string::npos);
+ file.rfind(".voc") == ustring::npos);
}
void
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index e3133fa4bb..dfe88ace78 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -35,6 +35,7 @@
#include <ardour/audiosource.h>
#include <ardour/cycle_timer.h>
+#include <ardour/session.h>
#include "i18n.h"
@@ -45,7 +46,7 @@ using namespace PBD;
bool AudioSource::_build_missing_peakfiles = false;
bool AudioSource::_build_peakfiles = false;
-AudioSource::AudioSource (Session& s, string name)
+AudioSource::AudioSource (Session& s, ustring name)
: Source (s, name)
{
_peaks_built = false;
@@ -157,11 +158,11 @@ AudioSource::touch_peakfile ()
}
int
-AudioSource::rename_peakfile (string newpath)
+AudioSource::rename_peakfile (ustring newpath)
{
/* caller must hold _lock */
- string oldpath = peakpath;
+ ustring oldpath = peakpath;
if (access (oldpath.c_str(), F_OK) == 0) {
if (rename (oldpath.c_str(), newpath.c_str()) != 0) {
@@ -176,7 +177,7 @@ AudioSource::rename_peakfile (string newpath)
}
int
-AudioSource::initialize_peakfile (bool newfile, string audio_path)
+AudioSource::initialize_peakfile (bool newfile, ustring audio_path)
{
struct stat statbuf;
@@ -187,7 +188,7 @@ AudioSource::initialize_peakfile (bool newfile, string audio_path)
*/
if (!newfile && access (peakpath.c_str(), R_OK) != 0) {
- string str = old_peak_path (audio_path);
+ ustring str = old_peak_path (audio_path);
if (access (str.c_str(), R_OK) == 0) {
peakpath = str;
}
@@ -664,13 +665,10 @@ AudioSource::done_with_peakfile_writes ()
}
}
-static bool wrote_xmax = false;
-
int
AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, bool force)
{
Sample* buf2 = 0;
- Sample xmin, xmax;
nframes_t to_do;
uint32_t peaks_computed;
PeakData* peakbuf;
@@ -689,8 +687,6 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe
if (first_frame != peak_leftover_frame + peak_leftover_cnt) {
- cerr << "seek, flush out " << peak_leftover_cnt << endl;
-
/* uh-oh, ::seek() since the last ::compute_and_write_peaks(),
and we have leftovers. flush a single peak (since the leftovers
never represent more than that, and restart.
@@ -700,11 +696,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe
x.min = peak_leftovers[0];
x.max = peak_leftovers[0];
-
- for (nframes_t n = 1; n < peak_leftover_cnt; ++n) {
- x.max = max (x.max, peak_leftovers[n]);
- x.min = min (x.min, peak_leftovers[n]);
- }
+ Session::find_peaks (peak_leftovers + 1, peak_leftover_cnt - 1, &x.min, &x.max);
off_t byte = (peak_leftover_frame / frames_per_peak) * sizeof (PeakData);
@@ -768,8 +760,6 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe
if (force && (to_do < frames_per_peak)) {
/* keep the left overs around for next time */
- cerr << "save " << to_do << " leftovers\n";
-
if (peak_leftover_size < to_do) {
delete [] peak_leftovers;
peak_leftovers = new Sample[to_do];
@@ -786,17 +776,10 @@ AudioSource::compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframe
nframes_t this_time = min (frames_per_peak, to_do);
- xmin = buf[0];
- xmax = buf[0];
-
- for (nframes_t n = 1; n < this_time; ++n) {
- xmax = max (xmax, buf[n]);
- xmin = min (xmin, buf[n]);
- }
-
+ peakbuf[peaks_computed].max = buf[0];
+ peakbuf[peaks_computed].min = buf[0];
- peakbuf[peaks_computed].max = xmax;
- peakbuf[peaks_computed].min = xmin;
+ Session::find_peaks (buf+1, this_time-1, &peakbuf[peaks_computed].min, &peakbuf[peaks_computed].max);
peaks_computed++;
buf += this_time;
@@ -865,7 +848,7 @@ AudioSource::truncate_peakfile ()
}
bool
-AudioSource::file_changed (string path)
+AudioSource::file_changed (ustring path)
{
struct stat stat_file;
struct stat stat_peak;
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 375e3467b7..496be33950 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -1508,7 +1508,7 @@ Playlist::bump_name_once (string name)
} else {
int isnumber = 1;
const char *last_element = name.c_str() + period + 1;
- for (int i = 0; i < strlen(last_element); i++) {
+ for (size_t i = 0; i < strlen(last_element); i++) {
if (!isdigit(last_element[i])) {
isnumber = 0;
break;
@@ -1525,7 +1525,7 @@ Playlist::bump_name_once (string name)
} else {
char buf[32];
- snprintf (buf, sizeof(buf), "%d", version+1);
+ snprintf (buf, sizeof(buf), "%ld", version+1);
newname = name.substr (0, period+1);
newname += buf;
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 7b609e62cb..257126b6f1 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -2839,6 +2839,24 @@ Session::source_by_id (const PBD::ID& id)
return source;
}
+
+boost::shared_ptr<Source>
+Session::source_by_path_and_channel (const Glib::ustring& path, uint16_t chn)
+{
+ Glib::Mutex::Lock lm (audio_source_lock);
+
+ for (AudioSourceList::iterator i = audio_sources.begin(); i != audio_sources.end(); ++i) {
+ cerr << "comparing " << path << " with " << i->second->name() << endl;
+ boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource>(i->second);
+
+ if (afs && afs->path() == path && chn == afs->channel()) {
+ return afs;
+ }
+
+ }
+ return boost::shared_ptr<Source>();
+}
+
string
Session::peak_path_from_audio_path (string audio_path) const
{
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index 2f4c575883..8aecbc3cdc 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -35,6 +35,7 @@
using namespace std;
using namespace ARDOUR;
using namespace PBD;
+using Glib::ustring;
gain_t* SndFileSource::out_coefficient = 0;
gain_t* SndFileSource::in_coefficient = 0;
@@ -54,11 +55,11 @@ SndFileSource::SndFileSource (Session& s, const XMLNode& node)
}
}
-SndFileSource::SndFileSource (Session& s, string path, int chn, Flag flags)
+SndFileSource::SndFileSource (Session& s, ustring path, int chn, Flag flags)
/* files created this way are never writable or removable */
: AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
{
- channel = chn;
+ _channel = chn;
init ();
@@ -67,7 +68,7 @@ SndFileSource::SndFileSource (Session& s, string path, int chn, Flag flags)
}
}
-SndFileSource::SndFileSource (Session& s, string path, SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags)
+SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags)
: AudioFileSource (s, path, flags, sfmt, hf)
{
int fmt = 0;
@@ -177,7 +178,7 @@ SndFileSource::SndFileSource (Session& s, string path, SampleFormat sfmt, Header
void
SndFileSource::init ()
{
- string file;
+ ustring file;
// lets try to keep the object initalizations here at the top
xfade_buf = 0;
@@ -221,8 +222,8 @@ SndFileSource::open ()
return -1;
}
- if (channel >= _info.channels) {
- error << string_compose(_("SndFileSource: file only contains %1 channels; %2 is invalid as a channel number"), _info.channels, channel) << endmsg;
+ if (_channel >= _info.channels) {
+ error << string_compose(_("SndFileSource: file only contains %1 channels; %2 is invalid as a channel number"), _info.channels, _channel) << endmsg;
sf_close (sf);
sf = 0;
return -1;
@@ -346,7 +347,7 @@ SndFileSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
}
nread = sf_read_float (sf, interleave_buf, real_cnt);
- ptr = interleave_buf + channel;
+ ptr = interleave_buf + _channel;
nread /= _info.channels;
/* stride through the interleaved data */
@@ -841,7 +842,7 @@ SndFileSource::set_timeline_position (int64_t pos)
}
int
-SndFileSource::get_soundfile_info (string path, SoundFileInfo& info, string& error_msg)
+SndFileSource::get_soundfile_info (const ustring& path, SoundFileInfo& info, string& error_msg)
{
SNDFILE *sf;
SF_INFO sf_info;
diff --git a/libs/ardour/sse_functions_xmm.cc b/libs/ardour/sse_functions_xmm.cc
index 7b5ea143ec..d4330eb37f 100644
--- a/libs/ardour/sse_functions_xmm.cc
+++ b/libs/ardour/sse_functions_xmm.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Paul Davis
+ Copyright (C) 2007 Paul sDavis
Written by Sampo Savolainen
This program is free software; you can redistribute it and/or modify
diff --git a/libs/pbd/pbd/strsplit.h b/libs/pbd/pbd/strsplit.h
index e55ad1c825..f36a3ae5f0 100644
--- a/libs/pbd/pbd/strsplit.h
+++ b/libs/pbd/pbd/strsplit.h
@@ -3,7 +3,9 @@
#include <string>
#include <vector>
+#include <glibmm/ustring.h>
extern void split (std::string, std::vector<std::string>&, char);
+extern void split (Glib::ustring, std::vector<Glib::ustring>&, char);
#endif // __pbd_strplit_h__
diff --git a/libs/pbd/strsplit.cc b/libs/pbd/strsplit.cc
index 7f29a77887..80da357cc0 100644
--- a/libs/pbd/strsplit.cc
+++ b/libs/pbd/strsplit.cc
@@ -1,6 +1,7 @@
#include <pbd/strsplit.h>
using namespace std;
+using namespace Glib;
void
split (string str, vector<string>& result, char splitchar)
@@ -39,3 +40,41 @@ split (string str, vector<string>& result, char splitchar)
result.push_back (remaining);
}
}
+
+void
+split (ustring str, vector<ustring>& result, char splitchar)
+{
+ ustring::size_type pos;
+ ustring remaining;
+ ustring::size_type len = str.length();
+ int cnt;
+
+ cnt = 0;
+
+ if (str.empty()) {
+ return;
+ }
+
+ for (ustring::size_type n = 0; n < len; ++n) {
+ if (str[n] == splitchar) {
+ cnt++;
+ }
+ }
+
+ if (cnt == 0) {
+ result.push_back (str);
+ return;
+ }
+
+ remaining = str;
+
+ while ((pos = remaining.find_first_of (':')) != ustring::npos) {
+ result.push_back (remaining.substr (0, pos));
+ remaining = remaining.substr (pos+1);
+ }
+
+ if (remaining.length()) {
+
+ result.push_back (remaining);
+ }
+}