-
crepuscularian
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)?
-
crepuscularian
You can resize with a message like this (you'll have to know the size in advance ... or just pick a size that will be bigger than what you need):
[resize 5000(
|What does your text file look like? As far as I can tell, the table will load from the file any numbers separated by any kind of whitespace, but it will stop reading as soon as it comes across text or punctuation or other characters.
-
crepuscularian
To load the data of file-name.txt, send the message "read file-name.txt" to the table. (Note that the table should be resized first.) So, for your situation, it would be something like this:
[bang]
|
[openpanel]
|
[read $1(
| -
crepuscularian
@hecanjog said:
You might also check out Thomas Grill's pyext, which lets you run python scripts inside pd: http://grrrr.org/research/software/py/
Great, thanks. I wasn't sure at first, but I got this to work. Not too difficult in the end, really, even passing long lists back into Pd.