6

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.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263

1 Answers1

6

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
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574