Scan.chunks#
- Scan.chunks()[source]#
Play the scan in spans of whole blocks; yield each once released.
The spans are simulated in a thread of their own, ahead of their release, a stretch of them at a time: a stretch ends at the first block,
lengthor more after its start, after which the samples acquired since the start of the scan pass a multiple of2**18, so that each costs about one transform of the images; a stretch is released in spans. The sound ispypulseqpp.gradient_sound()of the gradients along the physical axes, asSequence.soundmakes it of a design: the spans’ sounds, joined, are the sound of the whole scan,floor(duration * sample_rate) + 1samples scaled so that the loudest is 0.95.- Parameters:
length (float, default=0.1) – The scan time a span lasts at least, in s, unless it ends the scan’s last stretch.
speed (float, default=None) – How many times as fast as a scanner the scan is played. Its clock starts once the simulation, at the rate it has run, stays ahead of the clock to the end of the scan, and each span is yielded once the clock has passed its end. A stretch not yet simulated by its start holds the clock until it is. As fast as the stretches are simulated when None.
sound (bool, default=True) – Whether the spans carry their sound.
sample_rate (float, default=SAMPLE_RATE) – Audio sample rate, in Hz.
channel_weights (Sequence[float], default=(1.0, 1.0, 1.0)) – Weights of the x, y and z axes in the sound.
preparing (Callable[[float], None], default=None) – Called about twice a second until the clock starts, at a speed, with the wall-clock time left before it does, in s, or None before a stretch that acquires has been simulated. An exception it raises ends the scan, and is raised where the spans are taken.
heard (Callable[[Chunk], None], default=None) – Called with each span as its sound starts to play: at a speed, once the clock reaches the span’s start, a span before the span is yielded; without one, just before it is yielded.
- Raises:
ValueError – If
lengthorspeedis not positive.