summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-02-18 19:45:52 +0000
committerDavid Robillard <d@drobilla.net>2008-02-18 19:45:52 +0000
commitfbfb26b45c075da880861cf2303b851fe1acc0e8 (patch)
tree4673a82d5516535b17e9c60ffd57a206801a1e01 /libs/ardour/smf_source.cc
parent1b2fe7bf34f1e05ab4e3975ac91aeda28a4d11d0 (diff)
Preliminary (read: kludgey) MIDI import support.
Only really works when tracks contain only channel 1 data for now. git-svn-id: svn://localhost/ardour2/branches/3.0@3083 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 29f36cc2cd..59ad7269db 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -70,7 +70,7 @@ SMFSource::SMFSource (Session& s, std::string path, Flag flags)
throw failed_constructor ();
}
- //cerr << "SMF Source path: " << path << endl;
+ cerr << "SMF Source path: " << path << endl;
assert(_name.find("/") == string::npos);
}
@@ -99,7 +99,7 @@ SMFSource::SMFSource (Session& s, const XMLNode& node)
throw failed_constructor ();
}
- //cerr << "SMF Source name: " << _name << endl;
+ cerr << "SMF Source name: " << _name << endl;
assert(_name.find("/") == string::npos);
}
@@ -184,7 +184,7 @@ SMFSource::flush_header ()
const uint16_t type = GUINT16_TO_BE(0); // SMF Type 0 (single track)
const uint16_t ntracks = GUINT16_TO_BE(1); // Number of tracks (always 1 for Type 0)
- const uint16_t division = GUINT16_TO_BE(_ppqn); // Pulses per beat
+ const uint16_t division = GUINT16_TO_BE(_ppqn); // Pulses per quarter note (beat)
char data[6];
memcpy(data, &type, 2);
@@ -195,9 +195,7 @@ SMFSource::flush_header ()
assert(_fd);
fseek(_fd, 0, 0);
write_chunk("MThd", 6, data);
- //if (_track_size > 0) {
- write_chunk_header("MTrk", _track_size);
- //}
+ write_chunk_header("MTrk", _track_size);
fflush(_fd);
@@ -446,7 +444,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
void
SMFSource::append_event_unlocked(const MidiEvent& ev)
{
- /*printf("SMF - writing event, time = %lf, size = %u, data = ", ev.time(), ev.size());
+ /*printf("SMF %s - writing event, time = %lf, size = %u, data = ", _path.c_str(), ev.time(), ev.size());
for (size_t i=0; i < ev.size(); ++i) {
printf("%X ", ev.buffer()[i]);
}
@@ -636,6 +634,12 @@ SMFSource::move_to_trash (const string trash_dir_name)
return 0;
}
+bool
+SMFSource::safe_file_extension(const Glib::ustring& file)
+{
+ return (file.rfind(".mid") != Glib::ustring::npos);
+}
+
// FIXME: Merge this with audiofilesource somehow (make a generic filesource?)
bool
SMFSource::find (string pathstr, bool must_exist, bool& isnew)