+IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, breathing)
+void
+Note_performer::listen_breathing (Stream_event *ev)
+{
+ //Shorten previous note if needed
+ SCM f = ev->get_property ("midi-length");
+ if (ly_is_procedure (f))
+ for (vsize i = 0; i < last_notes_.size (); i++)
+ {
+ Audio_note *tie_head = last_notes_[i]->tie_head ();
+ //Give midi-length the available time since the note started,
+ //including rests. It returns how much is left for the note.
+ Moment available = now_mom () - tie_head->audio_column_->when ();
+ Moment len = robust_scm2moment (scm_call_2 (f, available.smobbed_copy (),
+ context ()->self_scm ()), available);
+ if (len < tie_head->length_mom_)
+ tie_head->length_mom_ = len;
+ }
+}
+