6
$\begingroup$

Audio objects can be file backed and support out of core processing. How can I test if an Audio object is file backed and programmatically extract the file path?

This information is displayed, but I want to get it programmatically.

enter image description here

Note that Audio objects are atomic so First[au] doesn't work. I can convert to a non-atomic form in several ways, but I consider this a nasty hack.

$\endgroup$
6
$\begingroup$

Use the undocumented function Audio`AudioInformation[]:

au = ExampleData[{"Audio", "Bird"}];

"ResourcePath" /. Audio`AudioInformation[au]

For an Audio[] object that is not file-backed, None is returned instead of the file path.


(Szabolcs)

This also works:

Audio`AudioInformation[au, "ResourcePath"]

Finally, you can use Audio`AudioStreamQ[] to directly query if an Audio[] object is file-backed:

Audio`AudioStreamQ[au]
   True
$\endgroup$
  • $\begingroup$ Oops, didn't see this! $\endgroup$ – Szabolcs Oct 7 '16 at 15:14
  • 2
    $\begingroup$ There are properties which are not returned by AudioInformation[au], but can be queried explicitly, e.g. AudioInformation[au, "AudioID"]. $\endgroup$ – Szabolcs Oct 7 '16 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.