summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-08-22 03:02:38 +0000
committerDavid Robillard <d@drobilla.net>2006-08-22 03:02:38 +0000
commit50baf0382f1f98793dff151bd0a940a4d140d6c0 (patch)
treef6cde9b250dd7343c366dac02bd7a66ebcbc5fcc /libs
parent48a4dc072c82dd382caa11405bf61a125d17eb16 (diff)
Fixes for writing compliant SMF files
git-svn-id: svn://localhost/ardour2/branches/midi@843 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/smf_source.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 73d8d5f7a5..a4036a317b 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -51,12 +51,12 @@ uint64_t SMFSource::header_position_offset;
SMFSource::SMFSource (std::string path, Flag flags)
: MidiSource (region_name_from_path(path))
, _channel(0)
- , _flags (flags)
+ , _flags (Flag(flags | Writable)) // FIXME: this needs to be writable for now
, _allow_remove_if_empty(true)
, _timeline_position (0)
, _fd (0)
, _last_ev_time(0)
- , _track_size(0)
+ , _track_size(4) // compensate for the EOT event
{
/* constructor used for new internal-to-session files. file cannot exist */
@@ -81,7 +81,7 @@ SMFSource::SMFSource (const XMLNode& node)
, _timeline_position (0)
, _fd (0)
, _last_ev_time(0)
- , _track_size(0)
+ , _track_size(4) // compensate for the EOT event
{
/* constructor used for existing internal-to-session files. file must exist */
@@ -225,7 +225,6 @@ SMFSource::find_first_event_after(jack_nframes_t start)
int
SMFSource::read_event(MidiEvent& ev) const
{
-#if 0
if (feof(_fd)) {
return -1;
}
@@ -243,14 +242,13 @@ SMFSource::read_event(MidiEvent& ev) const
printf("%X ", ev.buffer[i]);
}
printf("\n");
-#endif
+
return 0;
}
jack_nframes_t
SMFSource::read_unlocked (MidiRingBuffer& dst, jack_nframes_t start, jack_nframes_t cnt) const
{
-#if 0
cerr << "SMF - read " << start << " -- " << cnt;
// FIXME: ugh
@@ -274,7 +272,7 @@ SMFSource::read_unlocked (MidiRingBuffer& dst, jack_nframes_t start, jack_nframe
}
}
}
-#endif
+#if 0
cerr << "SMF pretending to read" << endl;
MidiEvent ev;
@@ -303,7 +301,7 @@ SMFSource::read_unlocked (MidiRingBuffer& dst, jack_nframes_t start, jack_nframe
dst.write(ev);
//dst.clear();
-
+#endif
return cnt;
}
@@ -395,6 +393,15 @@ SMFSource::mark_streaming_write_completed ()
if (!writable()) {
return;
}
+
+ cerr << "SMF - Writing EOT\n";
+
+ fseek(_fd, 0, SEEK_END);
+ write_var_len(1); // whatever...
+ char eot[4] = { 0xFF, 0x2F, 0x00 }; // end-of-track meta-event
+ fwrite(eot, 1, 4, _fd);
+ fflush(_fd);
+
#if 0
Glib::Mutex::Lock lm (_lock);