summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-02 11:32:13 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-02 11:32:13 -0400
commit8c9749e42faf7808034ed8b7afce4a2fe6dc6f33 (patch)
tree823af8a96f4e0b2a404f5e52eadf4f46e1d10229 /libs
parentf6d29abfc75c460b9e35717f2907e4e61bf38058 (diff)
parent08a1409b1f5b5558d2eccc28a3ae4cbd44391812 (diff)
merge with master and fix 4 conflicts by hand
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/file_source.h3
-rw-r--r--libs/ardour/ardour/smf_source.h9
-rw-r--r--libs/ardour/plugin_insert.cc4
-rw-r--r--libs/ardour/smf_source.cc44
-rw-r--r--libs/ardour/source_factory.cc2
-rw-r--r--libs/evoral/evoral/SMF.hpp1
-rw-r--r--libs/evoral/src/SMF.cpp22
-rw-r--r--libs/evoral/test/SequenceTest.cpp2
-rw-r--r--libs/pbd/clear_dir.cc4
-rw-r--r--libs/pbd/pbd/clear_dir.h2
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc23
11 files changed, 107 insertions, 9 deletions
diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h
index 37a7e67d2e..c0e4fba0de 100644
--- a/libs/ardour/ardour/file_source.h
+++ b/libs/ardour/ardour/file_source.h
@@ -85,6 +85,9 @@ public:
void existence_check ();
virtual void prevent_deletion ();
+ void existence_check ();
+ virtual void prevent_deletion ();
+
protected:
FileSource (Session& session, DataType type,
const std::string& path,
diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h
index 9d85f94352..44d965a4f6 100644
--- a/libs/ardour/ardour/smf_source.h
+++ b/libs/ardour/ardour/smf_source.h
@@ -36,9 +36,11 @@ template<typename T> class MidiRingBuffer;
/** Standard Midi File (Type 0) Source */
class LIBARDOUR_API SMFSource : public MidiSource, public FileSource, public Evoral::SMF {
public:
+ /** Constructor for new internal-to-session files */
+ SMFSource (Session& session, const std::string& path, Source::Flag flags);
+
/** Constructor for existing external-to-session files */
- SMFSource (Session& session, const std::string& path,
- Source::Flag flags = Source::Flag(0));
+ SMFSource (Session& session, const std::string& path);
/** Constructor for existing in-session files */
SMFSource (Session& session, const XMLNode&, bool must_exist = false);
@@ -75,6 +77,9 @@ public:
void ensure_disk_file ();
static bool safe_midi_file_extension (const std::string& path);
+ static bool valid_midi_file (const std::string& path);
+
+ void prevent_deletion ();
void prevent_deletion ();
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc
index 27cae70b62..5279a36962 100644
--- a/libs/ardour/plugin_insert.cc
+++ b/libs/ardour/plugin_insert.cc
@@ -1203,6 +1203,10 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Param
_logarithmic = desc.logarithmic;
_sr_dependent = desc.sr_dependent;
_toggled = desc.toggled;
+
+ if (desc.toggled) {
+ set_flags(Controllable::Toggle);
+ }
}
/** @param val `user' value */
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 812e06c27b..f6168f9d9b 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -35,6 +35,7 @@
#include <glibmm/fileutils.h>
#include "evoral/Control.hpp"
+#include "evoral/evoral/SMF.hpp"
#include "ardour/event_type_map.h"
#include "ardour/midi_model.h"
@@ -49,6 +50,7 @@
using namespace ARDOUR;
using namespace Glib;
using namespace PBD;
+using namespace Evoral;
/** Constructor used for new internal-to-session files. File cannot exist. */
SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
@@ -83,6 +85,39 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
_open = true;
}
+/** Constructor used for external-to-session files. File must exist. */
+SMFSource::SMFSource (Session& s, const string& path)
+ : Source(s, DataType::MIDI, path, Source::Flag (0))
+ , MidiSource(s, path, Source::Flag (0))
+ , FileSource(s, DataType::MIDI, path, string(), Source::Flag (0))
+ , Evoral::SMF()
+ , _last_ev_time_beats(0.0)
+ , _last_ev_time_frames(0)
+ , _smf_last_read_end (0)
+ , _smf_last_read_time (0)
+{
+ /* note that origin remains empty */
+
+ if (init (_path, false)) {
+ throw failed_constructor ();
+ }
+
+ assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS));
+ existence_check ();
+
+ /* file is not opened until write */
+
+ if (_flags & Writable) {
+ return;
+ }
+
+ if (open (_path)) {
+ throw failed_constructor ();
+ }
+
+ _open = true;
+}
+
/** Constructor used for existing internal-to-session files. */
SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
: Source(s, node)
@@ -465,6 +500,15 @@ SMFSource::mark_midi_streaming_write_completed (Evoral::Sequence<Evoral::Musical
}
bool
+SMFSource::valid_midi_file (const string& file)
+{
+ if (safe_midi_file_extension (file) ) {
+ return (SMF::test (file) );
+ }
+ return false;
+}
+
+bool
SMFSource::safe_midi_file_extension (const string& file)
{
static regex_t compiled_pattern;
diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc
index 0729f21592..391b205a94 100644
--- a/libs/ardour/source_factory.cc
+++ b/libs/ardour/source_factory.cc
@@ -272,7 +272,7 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
} else if (type == DataType::MIDI) {
- boost::shared_ptr<SMFSource> src (new SMFSource (s, path, SMFSource::Flag(0)));
+ boost::shared_ptr<SMFSource> src (new SMFSource (s, path));
src->load_model (true, true);
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
// boost_debug_shared_ptr_mark_interesting (src, "Source");
diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp
index 91bc928d9a..fe81b8f044 100644
--- a/libs/evoral/evoral/SMF.hpp
+++ b/libs/evoral/evoral/SMF.hpp
@@ -52,6 +52,7 @@ public:
SMF() : _smf(0), _smf_track(0), _empty(true) {};
virtual ~SMF();
+ static bool test(const std::string& path);
int open(const std::string& path, int track=1) THROW_FILE_ERROR;
int create(const std::string& path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR;
void close() THROW_FILE_ERROR;
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index 51ccda583e..dc3512a0f6 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -71,6 +71,28 @@ SMF::seek_to_track(int track)
}
}
+/** Attempt to open the SMF file just to see if it is valid.
+ *
+ * \return true on success
+ * false on failure
+ */
+bool
+SMF::test(const std::string& path)
+{
+ PBD::StdioFileDescriptor d (path, "r");
+ FILE* f = d.allocate ();
+ if (f == 0) {
+ return false;
+ }
+
+ smf_t* test_smf;
+ if ((test_smf = smf_load (f)) == NULL) {
+ return false;
+ }
+ smf_delete (test_smf);
+ return true;
+}
+
/** Attempt to open the SMF file for reading and/or writing.
*
* \return 0 on success
diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp
index 69931b8e0d..6e07776fdb 100644
--- a/libs/evoral/test/SequenceTest.cpp
+++ b/libs/evoral/test/SequenceTest.cpp
@@ -23,7 +23,7 @@ SequenceTest::preserveEventOrderingTest ()
seq->start_write();
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
- uint8_t buffer[2];
+ uint8_t buffer[3];
Event<Time>* event = new Event<Time>(
DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
);
diff --git a/libs/pbd/clear_dir.cc b/libs/pbd/clear_dir.cc
index 9d2d7ed883..36c6fcf9f8 100644
--- a/libs/pbd/clear_dir.cc
+++ b/libs/pbd/clear_dir.cc
@@ -32,7 +32,7 @@ using PBD::closedir;
#include <errno.h>
#include <string.h>
-#include <glib/gstdio.h>
+#include <glib.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h"
@@ -122,7 +122,7 @@ PBD::remove_directory (const std::string& dir) {
}
if (::g_unlink (fullpath.c_str())) {
- error << string_compose (_("cannot remove file %1 (%2)"), fullpath, strerror (errno)) << endmsg;
+ error << string_compose (_("cannot remove file %1 (%2)"), fullpath, strerror (errno)) << endmsg;
}
}
if (::g_rmdir(dir.c_str())) {
diff --git a/libs/pbd/pbd/clear_dir.h b/libs/pbd/pbd/clear_dir.h
index f669b84485..efef67012d 100644
--- a/libs/pbd/pbd/clear_dir.h
+++ b/libs/pbd/pbd/clear_dir.h
@@ -29,6 +29,8 @@
namespace PBD {
LIBPBD_API int clear_directory (const std::string&, size_t* = 0, std::vector<std::string>* = 0);
LIBPBD_API void remove_directory (const std::string& dir);
+ int clear_directory (const std::string&, size_t* = 0, std::vector<std::string>* = 0);
+ void remove_directory (const std::string& dir);
}
#endif /* __pbd_clear_dir_h__ */
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index a26617fd67..1d96a073b0 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -169,7 +169,7 @@ MIDIControllable::control_to_midi (float val)
float control_min = controllable->lower ();
float control_max = controllable->upper ();
- const float control_range = control_max - control_min;
+ float control_range = control_max - control_min;
if (controllable->is_toggle()) {
if (val >= (control_min + (control_range/2.0f))) {
@@ -177,6 +177,14 @@ MIDIControllable::control_to_midi (float val)
} else {
return 0;
}
+ } else {
+ AutomationControl *actl = dynamic_cast<AutomationControl*> (controllable);
+ if (actl) {
+ control_min = actl->internal_to_interface(control_min);
+ control_max = actl->internal_to_interface(control_max);
+ control_range = control_max - control_min;
+ val = actl->internal_to_interface(val);
+ }
}
return (val - control_min) / control_range * max_value_for_type ();
@@ -198,8 +206,17 @@ MIDIControllable::midi_to_control (int val)
float control_min = controllable->lower ();
float control_max = controllable->upper ();
- const float control_range = control_max - control_min;
-
+ float control_range = control_max - control_min;
+
+ AutomationControl *actl = dynamic_cast<AutomationControl*> (controllable);
+ if (actl) {
+ if (fv == 0.f) return control_min;
+ if (fv == 1.f) return control_max;
+ control_min = actl->internal_to_interface(control_min);
+ control_max = actl->internal_to_interface(control_max);
+ control_range = control_max - control_min;
+ return actl->interface_to_internal((fv * control_range) + control_min);
+ }
return (fv * control_range) + control_min;
}