diff options
author | David Robillard <d@drobilla.net> | 2006-08-11 03:24:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-08-11 03:24:57 +0000 |
commit | 30c08ba655330232767554c48bda1975bfb5628c (patch) | |
tree | c6bf6b62de69afdd6b2a42ef3a7d9f80e0f65f7c /libs/ardour/midi_playlist.cc | |
parent | ab6f1ed9bafa869648b6e94ee5186ff317b32c3e (diff) |
- Changed IO's vector<Port*>'s to PortList
- Added new Port classes, code to drive them
- Added PortList, which is a filthy mess ATM (nevermind that, it's the interface that's important at this stage)
- Added ChanCount, though it isn't very thoroughly used yet. That's the next step....
- Fixed a few bugs relating to loading sessions saved with trunk
- Fixed a few random other bugs
Slowly working towards type agnosticism while keeping all the former code/logic intact is the name of the game here
Warning: Removing ports is currently (intentionally) broken due solely to laziness.
git-svn-id: svn://localhost/ardour2/branches/midi@786 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_playlist.cc')
-rw-r--r-- | libs/ardour/midi_playlist.cc | 62 |
1 files changed, 17 insertions, 45 deletions
diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 007856e3a7..db28c06f17 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -164,71 +164,43 @@ struct RegionSortByLayer } }; +/** FIXME: semantics of return value? */ jack_nframes_t -MidiPlaylist::read (unsigned char *buf, unsigned char *mixdown_buffer, char * workbuf, jack_nframes_t start, +MidiPlaylist::read (RawMidi *buf, RawMidi *mixdown_buffer, jack_nframes_t start, jack_nframes_t cnt, unsigned chan_n) { - jack_nframes_t ret = cnt; - jack_nframes_t end; - jack_nframes_t read_frames; - jack_nframes_t skip_frames; - - /* optimizing this memset() away involves a lot of conditionals - that may well cause more of a hit due to cache misses - and related stuff than just doing this here. - - it would be great if someone could measure this - at some point. - - one way or another, parts of the requested area - that are not written to by Region::region_at() - for all Regions that cover the area need to be - zeroed. - */ - - memset (buf, 0, sizeof (unsigned char) * cnt); - /* this function is never called from a realtime thread, so its OK to block (for short intervals). */ Glib::Mutex::Lock rm (region_lock); - end = start + cnt - 1; + jack_nframes_t ret = 0; + jack_nframes_t end = start + cnt - 1; + jack_nframes_t read_frames = 0; + jack_nframes_t skip_frames = 0; - read_frames = 0; - skip_frames = 0; _read_data_count = 0; - map<uint32_t,vector<Region*> > relevant_regions; - vector<uint32_t> relevant_layers; + vector<MidiRegion*> regs; // relevent regions overlapping start <--> end for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - if ((*i)->coverage (start, end) != OverlapNone) { - - relevant_regions[(*i)->layer()].push_back (*i); - relevant_layers.push_back ((*i)->layer()); + MidiRegion* const mr = dynamic_cast<MidiRegion*>(*i); + if (mr && mr->coverage (start, end) != OverlapNone) { + regs.push_back(mr); } } - // RegionSortByLayer layer_cmp; - // relevant_regions.sort (layer_cmp); - - - for (vector<uint32_t>::iterator l = relevant_layers.begin(); l != relevant_layers.end(); ++l) { - - // FIXME: Should be vector<MidiRegion*> - vector<Region*>& r (relevant_regions[*l]); - - for (vector<Region*>::iterator i = r.begin(); i != r.end(); ++i) { - MidiRegion* const mr = dynamic_cast<MidiRegion*>(*i); - assert(mr); - mr->read_at (buf, mixdown_buffer, workbuf, start, cnt, chan_n, read_frames, skip_frames); - _read_data_count += mr->read_data_count(); - } + RegionSortByLayer layer_cmp; + sort(regs.begin(), regs.end(), layer_cmp); + for (vector<MidiRegion*>::iterator i = regs.begin(); i != regs.end(); ++i) { + (*i)->read_at (buf, mixdown_buffer, start, cnt, chan_n, read_frames, skip_frames); + ret += (*i)->read_data_count(); } + _read_data_count += ret; + return ret; } |