Jump to content

Script (or something similar) to show maximum peak?


Recommended Posts

When I used to work with Windows, I had Wavelab and I was able to select the whole audio in a file and it would give me the maximum peak value. The 2 apps I use (Sound Studio and very rarely Audacity) don't have this. Audacity can be used with some workaround and a simple script inside the app, but I was wondering if someone who's good with AppleScript, Shell Script, etc, knows of any script I can use for this?

I'm using Keyboard Maestro and then I can run scripts, so I would like to create a macro that would analyze a file on Finder without even opening it.

Any tips? I have ffmpeg installed and I can do a lot of things with it, but can't seem to find anything related to this particular scenario

Link to comment
Share on other sites

18 minutes ago, envlpx said:

Sox is a command line audio editing tool that has a "stats" function; maybe you could use it with Automation. Here's the result on a track:stats.thumb.png.654122b4a5728942e8c69cc6008837f3.png

Thanks for sharing.

It's not the first time I see Sox being mentioned, but I'm not familiar with scripting. I have some scripts saved on my computer that someone shared, but I don't really know how this works.

I tried to install it and it seems to be installed, but then when I run your script, it says that sox was not found

image.png.f5935677ce2ed8b803b9ba799bc13733.png

Is there something else I need to do? Can you give me a hand? Thanks!

Link to comment
Share on other sites

3 minutes ago, Danny Wyatt said:

I'm not familiar with scripting

I'm not such an expert on scripting either but a few years ago I've programmed a bunch of Automator services to run Apple's own afconvert and afinfo shell scripts in Finder. Here an afinfo example incl. an AppleScript dialog window to present the result (ignore the disabled actions, those were for debugging only):

automator_afinfo_shell_script.thumb.png.4780e87e36306550566d6c5169906867.png

I'll see if it will work just as easily with sox -n stats…

Link to comment
Share on other sites

11 minutes ago, loukash said:

I'm not such an expert on scripting either but a few years ago I've programmed a bunch of Automator services to run Apple's own afconvert and afinfo shell scripts in Finder. Here an afinfo example incl. an AppleScript dialog window to present the result (ignore the disabled actions, those were for debugging only):

automator_afinfo_shell_script.thumb.png.4780e87e36306550566d6c5169906867.png

I'll see if it will work just as easily with sox -n stats…

I tried installing sox again using brew, but I keep getting that it's not found. I think it has to do with the fact that I'm using Catalina and at the beginning of the installation they say this: 
 

==> You are using macOS 10.15.

==> We (and Apple) do not provide support for this old version.

This installation may not succeed.

After installation, you will encounter build failures with some formulae.

Please create pull requests instead of asking for help on Homebrew's GitHub,

Twitter or any other official channels. You are responsible for resolving any

issues you experience while you are running this old version.

 

I guess I will have to use Audacity then. It's not something I do very often, checking the peak, but if I could have that as a script to make it faster and easier, that would be great. 

 

Link to comment
Share on other sites

7 minutes ago, Danny Wyatt said:

I tried installing sox again using brew, but I keep getting that it's not found. I think it has to do with the fact that I'm using Catalina

Homebrew has dropped Catalina already?

On Ventura, sox works fine for me via Terminal.
In Automator it doesn't work yet, as the Shell Script action likely expects the default path to the executable. I'm currently duckducking Teh Intervebz for how to get the homebrew path to sox.

10 minutes ago, Danny Wyatt said:

I guess I will have to use Audacity then.

Usually I'm checking audio files with iZotope RX which is great.
I once started with RX 8 Elements while it was on sale for just $30. Already fantastic out of the box for this price. Then, a few months ago they had an upgrade sale to RX 10 Advanced for only $300+ which is a bargain. For how I want to "destructively" edit (in fact: repair) audio files, this is an absolutely amazing tool. I have tons of archived tapes and cassettes digitized and to be yet digitized that I want to restore; some going back over 40 years with my first attempts at "multitrack recording" using two cheap ghettoblasters when I was about 16… :D

For batch file checking/converting, I'm using Zynaptiq Myriad; previously also known as Audiofile-Engineering Sound Manager. Another amazing tool.

Link to comment
Share on other sites

4 minutes ago, loukash said:

Usually I'm checking audio files with iZotope RX

The type of work I do doesn't justify having this type of tool, to be honest.

Also, I want something that I can do without using other apps, that's why using something like ffmpeg, sox, etc, would be great. I would create a simple macro with Keyboard Maestro and I would be good to go. 

Using Audacity, even though not being a fan of the app, is more than enough for the super rare moments I need to check the peak of a particular file. It's not a big deal.

Link to comment
Share on other sites

31 minutes ago, Danny Wyatt said:

 

Using Audacity, even though not being a fan of the app, is more than enough for the super rare moments I need to check the peak of a particular file. It's not a big deal.

Yah, I think this is the best solution in the end. There are tools like DROffline but I haven't used it. r128x is a free tool but I'm not sure it runs on Catalina. It's a very simple program that can analyze multiple files offline:r128x.thumb.png.d3986b66e8413e6ba1caa064426b40f9.png

Reaper have this function as well:

reaper.thumb.png.dbd669c4d66664e9efd3f1645443df7c.png

Link to comment
Share on other sites

40 minutes ago, Danny Wyatt said:

The type of work I do doesn't justify having this type of tool, to be honest.

[slightly off topic:] Yeah, that's the audio perfectionist in me. Since I was 16 I was spending my earned money for good quality audio gear because I always found that the turntables or tape decks that my buddies owned sounded like crap. To this day, I'm still using a Technics SL-QX300 turntable and JBL TLX8 speakers – which I both bought in 1983! – almost daily. Good stuff. In fact, after 40 years I know the sound of those TLX8 in and out so that they are part of my mastering workflow. (For the record: I do mastering in Logic.)

47 minutes ago, Danny Wyatt said:

Also, I want something that I can do without using other apps, that's why using something like ffmpeg, sox, etc, would be great.

I understand. Hence also my aforementioned afconvert Automator services.
In fact, I created them specifically for Logic: A couple of years ago I found out that *.caf files can also be 24-bit with lossless ALAC compression. That's very convenient because in the long run it can save hundreds of gigabytes of storage space, while Logic and several other apps can handle them just fine, unlike regular *.m4a ALAC files in some cases. But as far as I can tell, only afconvert can create ALAC CAF.

Link to comment
Share on other sites

35 minutes ago, envlpx said:

You could do something like the following. It saves the result in the /tmp/result.txt file

I see, thanks.
But if it can write to a file, can't it also just pass the text output as a variable to the AppleScript action? 
I just don't know how to do it…

35 minutes ago, envlpx said:

Quick Action in Automator (instead of a workflow), so I can right click on any file on Finder and choose it from "Quick Actions"

Of course, that's how I'm using them as well. I have about 50 custom workflows in my ~/Library/Services folder, plus now with Ventura I have started to explore the Shortcuts app as well, the latter having certain advantages in specific scenarios.

Also, the new Default Folder v6 can now execute scripts, workflows and shortcuts directly from the Save dialog window. This particular shell script could be of good use on exporting or bouncing.

Edited by loukash
Link to comment
Share on other sites

1 hour ago, loukash said:

But if it can write to a file, can't it also just pass the text output as a variable to the AppleScript action? 

True, my solution is actually not very good, I was just trying to get something working quickly (I don't know much about Automator). This is a much better solution that redirects sox's stderr to stdout and consequentially sends the output to the next action:automator1.thumb.png.8e3b2142974dfe6a0107f49874b9e65f.png

This will open a new Textedit with Sox's result properly formatted:

result2.png.bb5fde7bd172cb902272b3e3adeb2ffa.png

 

I also tried to send the output to the dialog, by justing calling osascript from the bash script:automator2.thumb.png.cf1be30303e5785c247215af1694b749.png

But the result is unformatted: 

result1.png.48b8cf8ada589dd4b81f384c291ab2fc.png

I know programming, but I don't know how to use the variables inside Automator. There's some magic happening that I haven't learned yet 😞

Edited by envlpx
  • Like 1
Link to comment
Share on other sites

1 hour ago, loukash said:

Of course, that's how I'm using them as well. I have about 50 custom workflows in my ~/Library/Services folder, plus now with Ventura I have started to explore the Shortcuts app as well, the latter having certain advantages in specific scenarios.

That's cool! I've been meaning to do more automation on the macOS but I guess I need to stop and learn Automator properly.

Link to comment
Share on other sites

Many thanks @envlpx for your help.

The "osascript" variant already looks formatted enough for me since I know what to look for.

The Variable variant can be likely reformatted by using "text item delimiters" in the AppleScript action.

7 hours ago, envlpx said:

I guess I need to stop and learn Automator properly

That's what I'm telling to myself since… well, 18 years or so? :D

  • Haha 1
Link to comment
Share on other sites

7 hours ago, envlpx said:

the variables inside Automator

I think that in my afinfo workflow they are not even necessary. Either I put them there just for step debugging, or they are leftovers from one of my more complex afconvert workflows where I'm also reverting file creation and modification dates via AppleScript:

automator_afconvert_workflow.thumb.png.cfb76d9b840f76e331f91950531134e7.png

^ that one took me quite some time to figure out and to make it work…

  • Wow! 1
Link to comment
Share on other sites

1 hour ago, loukash said:

Works great! Thanks again!

Nice! I'm not sure if you are familiar with sed, grep, and cut. They are useful to filter data, for instance, if you only want to see the RMS data you could use grep for that:

/opt/homebrew/bin/sox "$f" -n stats 2>&1 | grep RMS

And the result would be:

Screenshot2023-11-10at11_39_47.png.15957cb7457aabd9e82205effc5b7ca3.png

Edited by envlpx
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...