What is KVR Audio? | Submit News | Advertise | Developer Account

Options (Affects News & Product results only):

OS:
Format:
Include:
Quick Search KVR

"Quick Search" KVR Audio's Product Database, News Items, Developer Listings, Forum Topics and videos here. For advanced Product Database searching please use the full product search. For the forum you can use the phpBB forum search.

To utilize the power of Google you can use the integrated Google Site Search.

Products 0

Developers 0

News 0

Forum 0

Videos 0

Search  

Scripting

Official support for: photosounder.com

Moderator: A_SN

A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Fri Apr 08, 2011 8:19 am Scripting

The new version of Photosounder is entirely scriptable, so let's make some scripts! Here are some examples, some very simple, some more advanced: http://photosounder.com/scripts.php

You can make your own scripts using Photosounder's recording feature (every action done is saved to an history/script file called history.pha in the program's folder, you can easily turn a full history into a versatile script by removing and editing a few lines in your favourite text editor) and using this reference: http://photosounder.com/PHA_spec_v1.1.pdf

This thread's purpose is to help anyone who would like to script or even for script requests.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral
jonahs
KVRist
 
468 posts since 26 Nov, 2009

Postby jonahs; Thu Apr 28, 2011 10:49 pm

Example scripts and documentation are great, but I don't understand a few things.

What am I "supposed" to do to do with base85? Looking at wikipedia is interesting... I can turn text into Ascii85, which I can then turn into sound!? That's cool. :love: I found a free tool for osx that I'll try later. If this works you could do some really bizarre and novel things. Is there a way to get photosounder to do the conversion of my file to base85? I'd be really interested to see an example I could tweak.

In my very limited testing of base85 I wasn't able to do much. I got some ultra high frequencies(pink diamonds) and sound similar to if you open a data file in a wave editor, which makes sense. The drawing tools seemed to have broken and the image only showed up on the main canvas when I zoomed in.

I haven't been able to figure out the usage of Multiply layer by <ratio>, New original image and New original sound. I don't think I've seen these in files I made in photosounder. If you could whip some super simple pha's using them as well I think I could figure them out.

Right now what I'm doing is ultra simple mostly just using the duplicate layer + move layer commands. You can build harmonies, chords and sequences that you have very precise control over editing later. I'm still researching the most musically relevant numbers to use. My only disappointment is that you can't(or I haven't figured it out) do really in depth changes over time because the number of layers is too great. Maybe in 10 years when computers are better. :lol:

I am unsure of the best way deal with all the layers that get created. I've been counting them and then running a script to merge that many times.

It's funny that photosounder records in the pha file you saving the pha file itself. :-o I make lots of version of files to test things and I have to go through and get rid of many occurrences of this.

As far as script requests, is it possible to do pitch bends? It seems like it would be. If so, any pointers to get started? Scaling the image seems unlikely, but I'll ask.:lol:

I also have some scripting functionality requests, but maybe they should be moved to the main request thread?

I would like an option to disable photosounder asking me to save when I hit the "r" button to reload. I open up the pha file while photosounder is open to do things like rename my layers and things would feel faster if I didn't have to do that.

A menu of our scripts in photosounder would be gold. Using something like /* */ to comment out large areas would be useful. The ability to enter height as note or semitone. I'm not sure if it's possible becasue you can have multiple layers with the same name currently, but selecting a layer by name would help. Maybe each layer should get a hard coded # as well?
A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Thu Apr 28, 2011 11:27 pm

Base85 is a translation of the binary representation of buffers. Note that implementations of Base85 aren't mutually intelligible, mine uses its own coding (which is described in the specification). Basically you'll want to use that if you have a program that'll generate full images to write its pixels. Photosounder uses Base85 when you save to a status PHA file as it saves raw pixel data.

'Multiply layer by <ratio>' does what it says it does, but you won't see it if you have only one layer as the end result is normalised. It changes the volume of a layer with respect to the others. It's the command written by the Layer intensity knob. New original image and New original sound will show up when you save a sound to a status PHA file. It contains the data necessary for the lossless mode to work, copies of the original sound and of the image that came out of it after analysis.

jonahs wrote:Right now what I'm doing is ultra simple mostly just using the duplicate layer + move layer commands. You can build harmonies, chords and sequences that you have very precise control over editing later. I'm still researching the most musically relevant numbers to use. My only disappointment is that you can't(or I haven't figured it out) do really in depth changes over time because the number of layers is too great. Maybe in 10 years when computers are better. :lol:

Even when scripting the best approach is to do things the way you would do them in Photosounder. That means that instead of duplicating a lot of layers you use one Convolution layer and you put dots on it, each dot representing one copy, the dot at the same place as the convolution centre representing the original. By the way careful with the Move layer commands, just today I've realised that the sign of the vertical offset is inverted (I've written in the specification about it). No big deal, you just have to write with the opposite sign, and in the future it'll be corrected although if your document says it's a Photosounder Archive v1.1 it will interpret the offset the old way. Don't worry about it though as now at the end of the specification I note those type of forward-compatibility issues. If you use the latest beta it already says v1.1.1 but the sign hasn't been changed whereas it will actually be changed when it's all released. For scripting I strongly recommend to stick to the latest official release.

Anyway remember, all you have to do to figure out how to do anything is merely to actually do it in Photosounder and then look at how it's written.

jonahs wrote:It's funny that photosounder records in the pha file you saving the pha file itself. :-o I make lots of version of files to test things and I have to go through and get rid of many occurrences of this.

It's always commented out with //, so you don't have to remove that. It's made so that you can easily enable the saving and recording what you've done without systematically doing it. Although in the case of saving an history file it doesn't really make sense since a Save command to a .pha file defaults to a status file.

Concerning pitch bends, you can already do that. All you need is a Vertical Propagation layer on which you draw a curve that represents your pitch bend. In the future I will make a function to scale the image, although most likely only in time. And you can already enter height as a note. That's what all the notes in the blue examples in the specification are about.

You can make your requests here. I intend to have a Scripts menu where the scripts in one folder would be listed and so you could run them without having to go through Open. How about a Shift+R to Resume Last Session without asking if you want to save?

And the way to select a layer is a tricky problem, mostly because of what you can do with edits to an history file that would mess things up. As you said the problem with selecting by name is that you can have several layers with the same name, and the problem with the numbers thing is how do you get a consistent and unique number? Let's say you do a New layer command, how do you get a consistent number for it that you know of? By specifying it? And let's say you have a New layer command in a script and you run with the script twice, creating two same numbered layers twice. You see what I mean. That's why I prefer to keep it as it is, with the option to select layers either using their absolute index or index relative to the currently selected layer.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral
wasi
KVRian
 
547 posts since 27 Jun, 2011

Postby wasi; Fri Oct 19, 2012 1:32 pm

Sorry for being so dense, but is the usage of these scripts like this:

I open the file I want to apply the script to, then I chose "open file" again, it prompts me to save the current file, I say no? yes? (does ist matter?).

Then I open the script (which is a history file with the file loading portions removed), because it's a script, instead of loading a new file it applies the script to the current file?

Honestly that's not really intuitive and it has taken me until now to understand that that is apparently what I'm supposed to do (the manual is cryptic and the website says nothing).

Couldn't you make a 'Scripts' folder in the main Photosounder folder that you can drop the scripts into and then select them from a submenu of the 'tools' menu or something? They are tools, ultimately, and could enhance photosounder but as it is you feel like you're hacking.
A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Wed Oct 31, 2012 12:47 pm

wasi wrote:Sorry for being so dense, but is the usage of these scripts like this:

I open the file I want to apply the script to, then I chose "open file" again, it prompts me to save the current file, I say no? yes? (does ist matter?).

Then I open the script (which is a history file with the file loading portions removed), because it's a script, instead of loading a new file it applies the script to the current file?

Honestly that's not really intuitive and it has taken me until now to understand that that is apparently what I'm supposed to do (the manual is cryptic and the website says nothing).

Couldn't you make a 'Scripts' folder in the main Photosounder folder that you can drop the scripts into and then select them from a submenu of the 'tools' menu or something? They are tools, ultimately, and could enhance photosounder but as it is you feel like you're hacking.

Sorry about the awkwardness of loading scripts, scripting was a brand new thing in the last public release of Photosounder and then it wasn't a feature as much as a by-product of the history saving thing. The reason why it asks you if you want to save is that it opens a script like it opens a document, and depending on what the script does it might destroy all you have in memory. My idea would be indeed to have a Script menu that would list all the scripts in a script folder, and it would make using them much faster. It would have been pretty hard to do with the current code base, but like I just said in another thread I took the decision to rewrite Photosounder with a more complete framework which will allow me to do that easily, so I guess you can count on that in the next version.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral
jpmaus
KVRer
 
2 posts since 19 Aug, 2014

Postby jpmaus; Tue Aug 19, 2014 11:26 pm Re: Scripting

Thanks for the amazing software! It provides a window into dimensions of sound and music that I had no idea about before!

My only problem is that I can't figure out how to use the scripting feature for batch file processing. I've looked closely on the boards here, but I can't seem to find any answers. First, I tried scripting (e.g., open file, process, save file, repeat... -- using the correct syntax of course), but the application always crashes after the first file has been processed. Next, I tried using a third party macro program, but for some reason, Photosounder didn't get along with it... That is, Photosounder refuses to start if the macro program is running. I also wrote a DOS batch program, but even that didn't work. When Photosounder saved the files it was as if they hadn't even been processed. Finally, I managed to find something workable. I used the DOS batch to command Photosounder to open and process each file from my list, but I still had to /save/ each result manually. This became very tedious after the 100th time, especially seeing as how I couldn't use my macro program to take care of the busy work, so I thought I'd ask if there might be an easier way.

The long and the short of it is this: I have a folder(s) of 100+ wav files I need opened, processed, and then saved... This folder is too large to be dealt with manually so I need some way to automate the task. Please let me know if you have any ideas thanks!
A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Wed Aug 20, 2014 1:44 am Re: Scripting

jpmaus wrote:Thanks for the amazing software! It provides a window into dimensions of sound and music that I had no idea about before!

My only problem is that I can't figure out how to use the scripting feature for batch file processing. I've looked closely on the boards here, but I can't seem to find any answers. First, I tried scripting (e.g., open file, process, save file, repeat... -- using the correct syntax of course), but the application always crashes after the first file has been processed. Next, I tried using a third party macro program, but for some reason, Photosounder didn't get along with it... That is, Photosounder refuses to start if the macro program is running. I also wrote a DOS batch program, but even that didn't work. When Photosounder saved the files it was as if they hadn't even been processed. Finally, I managed to find something workable. I used the DOS batch to command Photosounder to open and process each file from my list, but I still had to /save/ each result manually. This became very tedious after the 100th time, especially seeing as how I couldn't use my macro program to take care of the busy work, so I thought I'd ask if there might be an easier way.

The long and the short of it is this: I have a folder(s) of 100+ wav files I need opened, processed, and then saved... This folder is too large to be dealt with manually so I need some way to automate the task. Please let me know if you have any ideas thanks!

Show me the script!

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.

Then run the whole thing with ./Photosounder.exe script_path.pha
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral
A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Wed Aug 20, 2014 2:21 am Re: Scripting

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.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral
jpmaus
KVRer
 
2 posts since 19 Aug, 2014

Postby jpmaus; Wed Aug 20, 2014 6:45 pm Re: Scripting

Here is the code:

Code: Select all
Photosounder Archive v1.1.1

Analysis frequency range 27.5 Hz - 20000 Hz
Analysis time resolution 100 px/s
Analysis pitch resolution 60 px/octave
Analysis minimum pitch resolution 24 px/octave
Analysis transition time resolution 100 px/s

Open "C:\Users\John\Desktop\PICTURE\PICTURE-01.wav"

Synthesis noise
Gamma 3.0
Operation horizontal average

Save "C:\Users\John\Desktop\COMPLETE\PICTURE-01.wav"

// I've tried using both the Quit and Clear Image commands here, I have also tried placing all of the Open and Close commands AFTER the Synthesis, Gamma, and Operation Commands above...  I've really tried allot of different variations of this code, including the repetition of the Analysis commands here...

Open "C:\Users\John\Desktop\PICTURE\PICTURE-02.wav"

Synthesis noise
Gamma 3.0
Operation horizontal average

Save "C:\Users\John\Desktop\COMPLETE\PICTURE-02.wav"

// etc.

Perhaps we're missing the bigger point here, I've tried using a DOS batch to consecutively call hundreds of .PHA files (which I generated for each of the images I need converted, e.g., PICTURE-## in the code above), and yet for some reason, the Save command in the script only saves the file as it was originally, that is, without the processing called for above. Any advice you guys can give would be greatly appreciated, as this software is really wonderful and amazing.
A_SN
KVRian
 
720 posts since 6 May, 2008, from Berlin, Germany

Postby A_SN; Thu Aug 21, 2014 4:55 am Re: Scripting

I tried your script (obviously providing different paths) and doing Quit after one file (I think it's just as simple if you quit after each file, you know that works, relaunching is fast, and not quitting would probably work too but it's not as sure) and it worked fine. There is zero reason for the output file to be the exact same as the original given that it's impossible anyway with noise synthesis. Maybe there's something funny going on with your batch script, I don't know, feel free to post it too.

You can sort of debug the whole thing step by step by running just one line (or a group of line) in a file and load them sequentially to make sure each runs fine. But on my side everything runs correctly, the loading, the gamma and averaging and the saving too (although I'm not sure if it's my WIP build or not but it seems Save will hang indefinitely if live synthesis was on the last time you ran Photosounder, but that doesn't seem to be your problem anyway).
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Moderator: A_SN

Return to Photosounder