More solid "fake" recording and serialization
git-svn-id: svn://localhost/ardour2/branches/midi@825 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
d752986314
commit
5952c48a84
@ -216,7 +216,7 @@ Editor::draw_measures ()
|
||||
are large.
|
||||
*/
|
||||
|
||||
if (beat_spacing < 25.0) {
|
||||
if (beat_spacing < 15.0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -153,8 +153,6 @@ MidiStreamView::setup_rec_box ()
|
||||
|
||||
if (_trackview.session().transport_rolling()) {
|
||||
|
||||
cerr << "\tSHOW: rolling\n";
|
||||
|
||||
if (!rec_active &&
|
||||
_trackview.session().record_status() == Session::Recording &&
|
||||
_trackview.get_diskstream()->record_enabled()) {
|
||||
@ -165,13 +163,11 @@ MidiStreamView::setup_rec_box ()
|
||||
|
||||
MidiRegion::SourceList sources;
|
||||
|
||||
// FIXME
|
||||
MidiDiskstream* mds = dynamic_cast<MidiDiskstream*>(_trackview.get_diskstream());
|
||||
assert(mds);
|
||||
|
||||
sources.push_back((Source*)mds->write_source());
|
||||
|
||||
// FIXME
|
||||
rec_data_ready_connections.push_back (mds->write_source()->ViewDataRangeReady.connect (bind (mem_fun (*this, &MidiStreamView::rec_data_range_ready), mds->write_source())));
|
||||
|
||||
// handle multi
|
||||
@ -224,16 +220,10 @@ MidiStreamView::setup_rec_box ()
|
||||
rec_updating = true;
|
||||
rec_active = true;
|
||||
|
||||
// Show, damn you!
|
||||
rec_rect->show();
|
||||
rec_rect->raise_to_top();
|
||||
|
||||
} else if (rec_active &&
|
||||
(_trackview.session().record_status() != Session::Recording ||
|
||||
!_trackview.get_diskstream()->record_enabled())) {
|
||||
|
||||
cerr << "NO SHOW 1\n";
|
||||
|
||||
screen_update_connection.disconnect();
|
||||
rec_active = false;
|
||||
rec_updating = false;
|
||||
@ -310,7 +300,7 @@ MidiStreamView::update_rec_regions ()
|
||||
continue;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// FIXME?
|
||||
MidiRegion * region = dynamic_cast<MidiRegion*>(*iter);
|
||||
assert(region);
|
||||
|
||||
|
@ -124,7 +124,6 @@ class Diskstream : public Stateful, public sigc::trackable
|
||||
virtual XMLNode& get_state(void) = 0;
|
||||
virtual int set_state(const XMLNode& node) = 0;
|
||||
|
||||
// FIXME: makes sense for all diskstream types?
|
||||
virtual void monitor_input (bool) {}
|
||||
|
||||
jack_nframes_t capture_offset() const { return _capture_offset; }
|
||||
|
@ -124,7 +124,7 @@ class MidiDiskstream : public Diskstream
|
||||
|
||||
int do_refill_with_alloc();
|
||||
|
||||
int read (RawMidi* buf, jack_nframes_t& start, jack_nframes_t cnt, bool reversed);
|
||||
int read (MidiBuffer& dst, jack_nframes_t& start, jack_nframes_t cnt, bool reversed);
|
||||
|
||||
void finish_capture (bool rec_monitors_input);
|
||||
void transport_stopped (struct tm&, time_t, bool abort);
|
||||
|
@ -33,6 +33,7 @@ class Session;
|
||||
class Region;
|
||||
class MidiRegion;
|
||||
class Source;
|
||||
class MidiBuffer;
|
||||
|
||||
class MidiPlaylist : public ARDOUR::Playlist
|
||||
{
|
||||
@ -55,7 +56,7 @@ public:
|
||||
MidiPlaylist (const MidiPlaylist&, jack_nframes_t start, jack_nframes_t cnt,
|
||||
string name, bool hidden = false);
|
||||
|
||||
jack_nframes_t read (RawMidi *dst, RawMidi *mixdown,
|
||||
jack_nframes_t read (MidiBuffer& buf,
|
||||
jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0);
|
||||
|
||||
int set_state (const XMLNode&);
|
||||
|
@ -41,6 +41,7 @@ class Playlist;
|
||||
class Session;
|
||||
class MidiFilter;
|
||||
class MidiSource;
|
||||
class MidiBuffer;
|
||||
|
||||
class MidiRegion : public Region
|
||||
{
|
||||
@ -56,14 +57,14 @@ class MidiRegion : public Region
|
||||
|
||||
MidiSource& midi_source (uint32_t n=0) const;
|
||||
|
||||
jack_nframes_t read_at (RawMidi* out, RawMidi* mix,
|
||||
jack_nframes_t read_at (MidiBuffer& out,
|
||||
jack_nframes_t position,
|
||||
jack_nframes_t cnt,
|
||||
uint32_t chan_n = 0,
|
||||
jack_nframes_t read_frames = 0,
|
||||
jack_nframes_t skip_frames = 0) const;
|
||||
|
||||
jack_nframes_t master_read_at (RawMidi* buf, RawMidi* mix,
|
||||
jack_nframes_t master_read_at (MidiBuffer& buf,
|
||||
jack_nframes_t position,
|
||||
jack_nframes_t cnt,
|
||||
uint32_t chan_n=0) const;
|
||||
@ -82,7 +83,7 @@ class MidiRegion : public Region
|
||||
StateManager::State* state_factory (std::string why) const;
|
||||
Change restore_state (StateManager::State&);
|
||||
|
||||
jack_nframes_t _read_at (const SourceList&, RawMidi *buf,
|
||||
jack_nframes_t _read_at (const SourceList&, MidiBuffer& buf,
|
||||
jack_nframes_t position,
|
||||
jack_nframes_t cnt,
|
||||
uint32_t chan_n = 0,
|
||||
|
@ -37,7 +37,9 @@ using std::string;
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
/** Source for raw MIDI data */
|
||||
class MidiBuffer;
|
||||
|
||||
/** Source for MIDI data */
|
||||
class MidiSource : public Source
|
||||
{
|
||||
public:
|
||||
@ -45,8 +47,8 @@ class MidiSource : public Source
|
||||
MidiSource (const XMLNode&);
|
||||
virtual ~MidiSource ();
|
||||
|
||||
virtual jack_nframes_t read (RawMidi *dst, jack_nframes_t start, jack_nframes_t cnt) const;
|
||||
virtual jack_nframes_t write (RawMidi *src, jack_nframes_t cnt);
|
||||
virtual jack_nframes_t read (MidiBuffer& dst, jack_nframes_t start, jack_nframes_t cnt) const;
|
||||
virtual jack_nframes_t write (MidiBuffer& src, jack_nframes_t cnt);
|
||||
|
||||
virtual void mark_for_remove() = 0;
|
||||
virtual void mark_streaming_write_completed () {}
|
||||
@ -68,8 +70,8 @@ class MidiSource : public Source
|
||||
int set_state (const XMLNode&);
|
||||
|
||||
protected:
|
||||
virtual jack_nframes_t read_unlocked (RawMidi* dst, jack_nframes_t start, jack_nframes_t cn) const = 0;
|
||||
virtual jack_nframes_t write_unlocked (RawMidi* dst, jack_nframes_t cnt) = 0;
|
||||
virtual jack_nframes_t read_unlocked (MidiBuffer& dst, jack_nframes_t start, jack_nframes_t cnt) const = 0;
|
||||
virtual jack_nframes_t write_unlocked (MidiBuffer& dst, jack_nframes_t cnt) = 0;
|
||||
|
||||
mutable Glib::Mutex _lock;
|
||||
string _captured_for;
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class MidiBuffer;
|
||||
|
||||
/** Standard Midi File (Type 0) Source */
|
||||
class SMFSource : public MidiSource {
|
||||
public:
|
||||
@ -86,8 +88,8 @@ class SMFSource : public MidiSource {
|
||||
|
||||
int init (string idstr, bool must_exist);
|
||||
|
||||
jack_nframes_t read_unlocked (RawMidi* dst, jack_nframes_t start, jack_nframes_t cn) const;
|
||||
jack_nframes_t write_unlocked (RawMidi* dst, jack_nframes_t cnt);
|
||||
jack_nframes_t read_unlocked (MidiBuffer& dst, jack_nframes_t start, jack_nframes_t cn) const;
|
||||
jack_nframes_t write_unlocked (MidiBuffer& dst, jack_nframes_t cnt);
|
||||
|
||||
bool find (std::string path, bool must_exist, bool& is_new);
|
||||
bool removable() const;
|
||||
|
@ -544,12 +544,14 @@ MidiDiskstream::process (jack_nframes_t transport_frame, jack_nframes_t nframes,
|
||||
// FIXME: reading from a MIDI port is different, can't just memcpy
|
||||
//memcpy (_current_capture_buffer, _io->input(0)->get_buffer (rec_nframes) + offset + rec_offset, sizeof (RawMidi) * rec_nframes);
|
||||
assert(_source_port);
|
||||
for (size_t i=0; i < _source_port->size(); ++i) {
|
||||
cerr << "DISKSTREAM GOT EVENT " << i << "!!\n";
|
||||
|
||||
/*for (size_t i=0; i < _source_port->size(); ++i) {
|
||||
cerr << "DISKSTREAM GOT EVENT(1) " << i << "!!\n";
|
||||
}
|
||||
|
||||
//if (_source_port->size() == 0)
|
||||
// cerr << "No events :/ (1)\n";
|
||||
if (_source_port->size() == 0)
|
||||
cerr << "No events :/ (1)\n";
|
||||
*/
|
||||
|
||||
|
||||
} else {
|
||||
@ -565,11 +567,15 @@ MidiDiskstream::process (jack_nframes_t transport_frame, jack_nframes_t nframes,
|
||||
// FIXME (see above)
|
||||
//RawMidi* buf = _io->input (0)->get_buffer (nframes) + offset;
|
||||
assert(_source_port);
|
||||
|
||||
/*
|
||||
for (size_t i=0; i < _source_port->size(); ++i) {
|
||||
cerr << "DISKSTREAM GOT EVENT " << i << "!!\n";
|
||||
cerr << "DISKSTREAM GOT EVENT(2) " << i << "!!\n";
|
||||
}
|
||||
//if (_source_port->size() == 0)
|
||||
// cerr << "No events :/ (2)\n";
|
||||
if (_source_port->size() == 0)
|
||||
cerr << "No events :/ (2)\n";
|
||||
*/
|
||||
|
||||
RawMidi* buf = NULL; // FIXME FIXME FIXME (make it compile)
|
||||
assert(false);
|
||||
jack_nframes_t first = _capture_vector.len[0];
|
||||
@ -592,8 +598,8 @@ MidiDiskstream::process (jack_nframes_t transport_frame, jack_nframes_t nframes,
|
||||
if (rec_nframes) {
|
||||
|
||||
// FIXME: filthy hack to fool the GUI into thinking we're doing something
|
||||
if (_write_source)
|
||||
_write_source->ViewDataRangeReady (transport_frame, rec_nframes); /* EMIT SIGNAL */
|
||||
//if (_write_source)
|
||||
// _write_source->ViewDataRangeReady (transport_frame, rec_nframes); /* EMIT SIGNAL */
|
||||
|
||||
/* data will be written to disk */
|
||||
|
||||
@ -802,7 +808,7 @@ MidiDiskstream::internal_playback_seek (jack_nframes_t distance)
|
||||
}
|
||||
|
||||
int
|
||||
MidiDiskstream::read (RawMidi* buf, jack_nframes_t& start, jack_nframes_t cnt, bool reversed)
|
||||
MidiDiskstream::read (MidiBuffer& dst, jack_nframes_t& start, jack_nframes_t cnt, bool reversed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ struct RegionSortByLayer
|
||||
|
||||
/** FIXME: semantics of return value? */
|
||||
jack_nframes_t
|
||||
MidiPlaylist::read (RawMidi *buf, RawMidi *mixdown_buffer, jack_nframes_t start,
|
||||
MidiPlaylist::read (MidiBuffer& buf, jack_nframes_t start,
|
||||
jack_nframes_t cnt, unsigned chan_n)
|
||||
{
|
||||
/* this function is never called from a realtime thread, so
|
||||
@ -199,7 +199,7 @@ MidiPlaylist::read (RawMidi *buf, RawMidi *mixdown_buffer, jack_nframes_t start,
|
||||
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);
|
||||
(*i)->read_at (buf, start, cnt, chan_n, read_frames, skip_frames);
|
||||
ret += (*i)->read_data_count();
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@ MidiRegion::MidiRegion (MidiSource& src, jack_nframes_t start, jack_nframes_t le
|
||||
if (announce) {
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
/* Basic MidiRegion constructor (one channel) */
|
||||
@ -66,6 +68,8 @@ MidiRegion::MidiRegion (MidiSource& src, jack_nframes_t start, jack_nframes_t le
|
||||
if (announce) {
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
/* Basic MidiRegion constructor (many channels) */
|
||||
@ -77,6 +81,8 @@ MidiRegion::MidiRegion (SourceList& srcs, jack_nframes_t start, jack_nframes_t l
|
||||
if (announce) {
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
|
||||
@ -89,6 +95,8 @@ MidiRegion::MidiRegion (const MidiRegion& other, jack_nframes_t offset, jack_nfr
|
||||
if (announce) {
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
MidiRegion::MidiRegion (const MidiRegion &other)
|
||||
@ -97,6 +105,7 @@ MidiRegion::MidiRegion (const MidiRegion &other)
|
||||
save_state ("initial state");
|
||||
|
||||
/* NOTE: no CheckNewRegion signal emitted here. This is the copy constructor */
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
MidiRegion::MidiRegion (MidiSource& src, const XMLNode& node)
|
||||
@ -108,6 +117,7 @@ MidiRegion::MidiRegion (MidiSource& src, const XMLNode& node)
|
||||
|
||||
save_state ("initial state");
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
assert(_type == DataType::MIDI);
|
||||
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
@ -122,6 +132,7 @@ MidiRegion::MidiRegion (SourceList& srcs, const XMLNode& node)
|
||||
|
||||
save_state ("initial state");
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
assert(_type == DataType::MIDI);
|
||||
|
||||
CheckNewRegion (this); /* EMIT SIGNAL */
|
||||
@ -167,7 +178,7 @@ MidiRegion::get_memento() const
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
MidiRegion::read_at (RawMidi *out, RawMidi* mix_buf, jack_nframes_t position,
|
||||
MidiRegion::read_at (MidiBuffer& out, jack_nframes_t position,
|
||||
jack_nframes_t cnt,
|
||||
uint32_t chan_n, jack_nframes_t read_frames, jack_nframes_t skip_frames) const
|
||||
{
|
||||
@ -175,14 +186,14 @@ MidiRegion::read_at (RawMidi *out, RawMidi* mix_buf, jack_nframes_t position,
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
MidiRegion::master_read_at (RawMidi *out, RawMidi* mix_buf, jack_nframes_t position,
|
||||
MidiRegion::master_read_at (MidiBuffer& out, jack_nframes_t position,
|
||||
jack_nframes_t cnt, uint32_t chan_n) const
|
||||
{
|
||||
return _read_at (_master_sources, out, position, cnt, chan_n, 0, 0);
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
MidiRegion::_read_at (const SourceList& srcs, RawMidi *buf,
|
||||
MidiRegion::_read_at (const SourceList& srcs, MidiBuffer& buf,
|
||||
jack_nframes_t position, jack_nframes_t cnt,
|
||||
uint32_t chan_n, jack_nframes_t read_frames, jack_nframes_t skip_frames) const
|
||||
{
|
||||
|
@ -90,14 +90,14 @@ MidiSource::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
MidiSource::read (RawMidi* dst, jack_nframes_t start, jack_nframes_t cnt) const
|
||||
MidiSource::read (MidiBuffer& dst, jack_nframes_t start, jack_nframes_t cnt) const
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
return read_unlocked (dst, start, cnt);
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
MidiSource::write (RawMidi* dst, jack_nframes_t cnt)
|
||||
MidiSource::write (MidiBuffer& dst, jack_nframes_t cnt)
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
return write_unlocked (dst, cnt);
|
||||
|
@ -2480,7 +2480,7 @@ Session::diskstream_by_id (const PBD::ID& id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* AudioRegion management */
|
||||
/* Region management */
|
||||
|
||||
string
|
||||
Session::new_region_name (string old)
|
||||
@ -2539,6 +2539,8 @@ Session::region_name (string& result, string base, bool newlevel) const
|
||||
char buf[16];
|
||||
string subbase;
|
||||
|
||||
assert(base.find("/") == string::npos);
|
||||
|
||||
if (base == "") {
|
||||
|
||||
Glib::Mutex::Lock lm (region_lock);
|
||||
|
@ -47,7 +47,7 @@ uint64_t SMFSource::header_position_offset;
|
||||
*/
|
||||
|
||||
SMFSource::SMFSource (std::string path, Flag flags)
|
||||
: MidiSource (path), _flags (flags)
|
||||
: MidiSource (region_name_from_path(path)), _flags (flags)
|
||||
{
|
||||
/* constructor used for new internal-to-session files. file cannot exist */
|
||||
|
||||
@ -55,6 +55,8 @@ SMFSource::SMFSource (std::string path, Flag flags)
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
@ -71,6 +73,8 @@ SMFSource::SMFSource (const XMLNode& node)
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
|
||||
SourceCreated (this); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
@ -91,10 +95,8 @@ SMFSource::removable () const
|
||||
int
|
||||
SMFSource::init (string pathstr, bool must_exist)
|
||||
{
|
||||
bool is_new = false;
|
||||
//bool is_new = false;
|
||||
|
||||
_length = 1024; // FIXME FIXME FIXME: force save
|
||||
|
||||
/*
|
||||
if (!find (pathstr, must_exist, is_new)) {
|
||||
cerr << "cannot find " << pathstr << " with me = " << must_exist << endl;
|
||||
@ -106,8 +108,9 @@ SMFSource::init (string pathstr, bool must_exist)
|
||||
}
|
||||
*/
|
||||
|
||||
// Yeah, we sound it. Swear.
|
||||
// Yeah, we found it. Swear.
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -124,15 +127,18 @@ SMFSource::flush_header ()
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
SMFSource::read_unlocked (RawMidi* dst, jack_nframes_t start, jack_nframes_t cnt) const
|
||||
SMFSource::read_unlocked (MidiBuffer& dst, jack_nframes_t start, jack_nframes_t cnt) const
|
||||
{
|
||||
return 0;
|
||||
dst.clear();
|
||||
return cnt;
|
||||
}
|
||||
|
||||
jack_nframes_t
|
||||
SMFSource::write_unlocked (RawMidi* dst, jack_nframes_t cnt)
|
||||
SMFSource::write_unlocked (MidiBuffer& src, jack_nframes_t cnt)
|
||||
{
|
||||
return 0;
|
||||
ViewDataRangeReady (_length, cnt); /* EMIT SIGNAL */
|
||||
_length += cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
@ -166,6 +172,8 @@ SMFSource::set_state (const XMLNode& node)
|
||||
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ sigc::signal<void,Source*> Source::SourceCreated;
|
||||
Source::Source (string name, DataType type)
|
||||
: _type(type)
|
||||
{
|
||||
assert(_name.find("/") == string::npos);
|
||||
|
||||
_name = name;
|
||||
_use_cnt = 0;
|
||||
_timestamp = 0;
|
||||
@ -62,6 +64,7 @@ Source::Source (const XMLNode& node)
|
||||
if (set_state (node) || _type == DataType::NIL) {
|
||||
throw failed_constructor();
|
||||
}
|
||||
assert(_name.find("/") == string::npos);
|
||||
}
|
||||
|
||||
Source::~Source ()
|
||||
@ -111,6 +114,7 @@ Source::set_state (const XMLNode& node)
|
||||
if ((prop = node.property ("timestamp")) != 0) {
|
||||
sscanf (prop->value().c_str(), "%ld", &_timestamp);
|
||||
}
|
||||
assert(_name.find("/") == string::npos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -203,6 +203,12 @@ region_name_from_path (string path)
|
||||
{
|
||||
string::size_type pos;
|
||||
|
||||
/* remove any leading path */
|
||||
|
||||
if ((pos = path.find_last_of ('/')) != string::npos) {
|
||||
path = path.substr(pos+1);
|
||||
}
|
||||
|
||||
/* remove filename suffixes etc. */
|
||||
|
||||
if ((pos = path.find_last_of ('.')) != string::npos) {
|
||||
|
Loading…
Reference in New Issue
Block a user