music.setup_hrtf¶
- music.setup_hrtf(directory=None, url='https://sound.media.mit.edu/resources/KEMAR/full.tar.Z', force=False)[source]¶
Fetch the KEMAR measurements into the cache, once.
- Parameters:
- directorypath, optional
Where to put them: a directory that does not exist yet, an empty one, or one that holds them already, or the part of them a fetch that did not finish left. Defaults to
hrtf_dir().- url
str Where to get them.
- forcebool
Fetch them again even if they are already there, replacing the directory they are in.
- Returns:
PathThe directory they are in.
- Raises:
RuntimeErrorIf
gzipis not installed. The archive is in the oldcompressformat, which Python’s standard library does not read andgzipdoes; there is no pure-Python fallback here.If directory exists and holds anything but the measurements. They were moved into place over whatever stood there, so a directory of one’s own given as directory, or as
$MUSIC_HRTF_DIR, was deleted, its files with it.If Python’s
tarfilecannot filter what it unpacks, which it can from Python 3.10.12, 3.11.4 and 3.12. The archive comes from the network, and is unpacked with the'data'filter, which refuses a member that would land outside; without it, the call failed as aTypeErroronce the download was done.OSErrorIf the download or the extraction fails. Nothing is left behind: the archive is unpacked beside the target and moved into place only once it is whole, so an interrupted fetch does not leave a directory that would pass for the measurements.
- Parameters:
- Return type:
See also
hrirreads one direction out of them.
music.setup_enginethe same arrangement, for the singing engine.
Notes
About 1.3 MB, fetched once. The measurements are Gardner and Martin’s and are freely redistributable; this only saves you finding them.
Examples
>>> setup_hrtf() PosixPath('.../music/kemar')