'Compiles and returns incoming messages into a NoteSequence.
Blocks until capture stops. At least one of `stop_time` or `stop_signal`
must be specified. If both are specified, the one that occurs first will
stop the capture.
Args:
qpm: The integer quarters per minute to use for the captured sequence.
start_time: The float wall time in seconds to start the capture. May be in
the past. Used for beat alignment.
stop_time: The optional float wall time in seconds to stop the capture.
stop_signal: The optional mido.Message to use as a signal to use to stop
the capture.
Returns:
The captured NoteSequence proto.
Raises:
MidiHubException: When neither `stop_time` nor `stop_signal` are provided.'

def capture_sequence(self, qpm, start_time, stop_time=None, stop_signal=None):

    if ((stop_time is None) and (stop_signal is None)):
        raise MidiHubException('At    least    one    of    `stop_time`    and    `stop_signal`    must    be    provided    to    `capture_sequence`    call.')
    captor = self.start_capture(qpm, start_time, stop_time, stop_signal)
    captor.join()
    return captor.captured_sequence()
