Login / Register  0 items | $0.00 NewWhat is KVR? Submit News Advertise

Batch processing

chris-zwarg
KVRer
 
2 posts since 3 Feb, 2016

Postby chris-zwarg; Wed Feb 03, 2016 8:22 am Batch processing

Hello,

is there a way to automatize Photosounder in such a way as to read a number of WAVs (from a directory or from a predefined list of paths and filenames), calculate the spectrograms, and write the result as BMP images to disc. I use the BMPs generated by Photosounder to analyze the pitch structure of sounds with an external application, and I need to produce thousands of such BMPs from WAV audio files. It is a very boring and time-consuming task to load each WAV manually, then having to choose BMP output from the menu, type the filename, and save.

I have tried to write a script, but so far have not succeeded in making Photosounder more than one WAV file in succession - on running the script, the first file is opened, the corresponding BMP saved, and then the application shuts down. What am I doing wrong? Or, if this is a bug hardwired into Photosounder, is there a workaround (e.g. calling the app from a Windows Batchfile)? Thank you for any suggestion.

This is my script:

Photosounder Archive v1.1
Title "BatchProcess"
Analysis frequency range 200 Hz - 3190 Hz
Analysis time resolution 20 px/s
Analysis pitch resolution 300 px/octave
Analysis minimum pitch resolution 0 px/octave
Analysis transition time resolution 20 px/s
Open "H:\WERKBANK\COL-0C-00056081-999_MC-DRA_22k.wav"
Save "H:\WERKBANK\COL-0C-00056081-999_MC-DRA_22k.bmp"
Open "H:\WERKBANK\COL-0C-00056081-999_MC-DRA_22k.wav"
Save "H:\WERKBANK\COL-0C-00056081-999_MC-DRA_22k.bmp"

(etc., absolute paths for all the required files)

Chris Zwarg
chris-zwarg
KVRer
 
2 posts since 3 Feb, 2016

Postby chris-zwarg; Wed Feb 03, 2016 11:47 am Re: Batch processing

I find that A_SN wrote on this same problem encountered by another user in a different thread:

"And the way to do is once you recorded your script, uncomment the Save commands (they're commented out because you don't want them to be executed by default when reloading a session), add a Quit command at the end, and for the initial Open command you'll have to do something to specify the path of the file inside the .pha file. You can use something like echo and cat (I'm more familiar with posix bash scripting, which you can do with msys on Windows) to do that, and you might have to do the same with the Save command."

and further:

"I just thought about something, there's a way you can do the custom Open and Save commands perhaps a bit more simply. In the main script instead of directly opening/saving the file you can Open a one-line script containing the Open and Save commands in question, so those one line scripts would contain just those custom commands which you would have written with your batch script right before running the main script in Photosounder. Think of the Open command in that case as a sort of include."

If you read this, A_SN, I am sorry to say so, but to me this explains nothing. Please give examples (code) for:

- doing something to specify the path of the file inside the .pha file (as I understand it the .pha file is a text file that has absolute paths/filenames hard-coded into it; if you suggest making a .pha file manually for each WAV I might just as well load/save every WAV/BMP manually)
- one line scripts would contain just those custom commands which you would have written with your batch script right before running the main script in Photosounder (how does one "write one-line custom commands" with a batch script, and how are these supposed to be communicated to the "main [Photosounder] script"?)

In other words, I am still at a loss to get from

- a stack of WAV files in a folder
- a list of paths/filenames for these files
- another list of paths/filenames for the BMPs to be generated
(the latter two easily generated from the filenames of the WAVs themselves)

to the desired result of automatically loading each WAV and writing its BMP equivalent to harddisk either with a Photosounder script or with a DOS script, and even more at a loss how to possibly combine the two.

The old ARSS 0.2.3 command-line version BTW did such batch processing without qualms:

"C:\Programme\arss\arss" --quiet %1 %1.bmp --analysis --min-freq 200 --max-freq 3190 --bpo 300 --pps 20 --brightness 2 --format-param 16

Unfortunately, its method of calculating the spectrograms is much less sophisticated than the one currently applied in Photosounder: With the same settings (same size BMP with the same frequency and time resolution) the results are so blurry, mostly in the time domain, as to make them useless for my purpose. I can post sample BMPs if needed. If there is a way getting identical results from ARSS with some tweaking, I should be quite happy to use that program to do the job.

Chris
A_SN
KVRian
 
895 posts since 6 May, 2008, from Poland

Postby A_SN; Wed Feb 03, 2016 6:27 pm Re: Batch processing

After the Open command the Analysis parameters are reset to their default. That means you either have to reuse them before calling Open again or generate many .pha files with the same body except with different file paths.

My suggested approach is to have a script (in whatever language you choose) to generate those many individual .pha script you need and then run them by command line (like "Photosounder.exe myscript_0001.pha" then after it's done run "Photosounder.exe myscript_0002.pha" etc...). Don't forget to add a Quit command to the end of the script.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Moderator: A_SN

Return to Photosounder