Right now, I have a Pd patch that does what I want, playing back bits from an audio file. But it requires that I first run a Python program which computes some data about the audio file and writes that to text files, which then get loaded as tables to be used in Pd. Basically, this data gives me a sorted list of what amplitudes appear at what times, so that I can play small pieces of the audio according to any desired amplitude. I'm sure it's somehow possible to write the same functionality all within Pd, but that seemed like it would be incredibly awkward and complex, and taking days for me to write correctly (main hurdle: sorting tuples of data by one element of the tuple). It was obvious and immediate in Python.
But I'd like to avoid the step of manually running the Python preprocessing any time I want to load a new audio file. What is the best way to combine these into a single execution? Is there a way for Pd to call this Python script as a command line operation with a loadbang (or upon choosing a new audio file), and wait for it to complete before continuing? Or is this an appropriate situation to compile the Python as an external to run as an object in Pd (something I dread figuring out)?