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().

urlstr

Where to get them.

forcebool

Fetch them again even if they are already there, replacing the directory they are in.

Returns:
Path

The directory they are in.

Raises:
RuntimeError

If gzip is not installed. The archive is in the old compress format, which Python’s standard library does not read and gzip does; 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 tarfile cannot 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 a TypeError once the download was done.

OSError

If 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:

Path

See also

hrir

reads one direction out of them.

music.setup_engine

the 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')