How to make a snd resource

I don't know how much use there is for this but I was fiddling with audio the other day and for some reason ended up making a little program that creates snd resources from audio files. No other alternatives exist for Intel macs, as far as I'm aware.

Get the 'MakeSnd' utility from the link in my sig.

This is an applescript + python script which first converts your audio file to AIFF and then creates a 'snd ' resource from the AIFF. All sounds are saved as IMA 4:1 mono with the same sample rate as the source.

Let me know how you get on.

(update) Now rewritten in python with 95% less 'hack'.

This post has been edited by Guy : 09 March 2017 - 02:22 PM

I would be happy to test it out. I have some new sounds I need to port into my TC, and as of right now that means I have to fire up SheepShaver to emulate OS9 and use ResEdit to work with the files.

I'll let you know how it goes.

No luck so far in my testing. I've dropped sound files of a few different formats and bitrates into it, but it fails to produce the .rsrc file. No error message is given.

Is it picky about receiving only a certain type of file into it? I've tested stereo and mono .aif, .mp3, and .wav files.

It shouldn't be picky. Do you have the OS X command line tools installed? The system should prompt you to install them if you haven't but just in case, open a Terminal and enter:
xcode-select --install

If you do have them installed but it still isn't working, try attaching one of the files here and I'll take a look.

Or if you're comfortable on the command line, you could help with the debugging yourself:
Right-click on MakeSnd and show package contents
Find Contents/Resources/makesnd.sh
Drag this file onto a new Terminal window
Drag the file to convert onto the Terminal
Enter an output name such as "output.rsrc"
The full command should look like: /path/to/makesnd.sh /path/to/audiofile output.rsrc
Push return to execute and tell me the output. If it worked properly it would create output.rsrc in your home folder.

This post has been edited by Guy : 12 April 2015 - 09:53 PM

@guy, on 12 April 2015 - 09:53 PM, said in How to make a snd resource:

It shouldn't be picky. Do you have the OS X command line tools installed? The system should prompt you to install them if you haven't but just in case, open a Terminal and enter:
xcode-select --install

If you do have them installed but it still isn't working, try attaching one of the files here and I'll take a look.

Or if you're comfortable on the command line, you could help with the debugging yourself:
Right-click on MakeSnd and show package contents
Find Contents/Resources/makesnd.sh
Drag this file onto a new Terminal window
Drag the file to convert onto the Terminal
Enter an output name such as "output.rsrc"
The full command should look like: /path/to/makesnd.sh /path/to/audiofile output.rsrc
Push return to execute and tell me the output. If it worked properly it would create output.rsrc in your home folder.

I consider myself rather fluent in the OSX command line interface, and would be happy to help with debugging. It just so happens that scripting is a significant portion of my real-life I.T. job! I will have a look inside the application either later today or some time this week to see what's going on. I may be able to help the application with some sanity checks, as well, so that it either irons out the file formats on its own, or at least just denies any that don't fit the mold. I don't make any guarantees, though; every time I muster up the hubris to think that I'm good enough at scripting, I find a new script/command that completely baffles me. <_<

Great, always good to have another coder around. Hopefully this one won't baffle you.

Did you get a chance to look at it yet? I've just made a few small tweaks to it.

Sorry, not yet. It's been finals season here, and I work for a school board, so I've been swamped with work surrounding exams and making sure my schools are prepared for them.

I'll have a look when I can.

arch: Unknown architecture: 32

Ever since my laptop was stolen back in Dec 16, I was forced to using my old 2007 Mac Mini that still runs Snow Leopard.

Hm, perhaps the -32 switch is newer than snow leopard. Try editing Contents/Resources/aif2snd.py and change -32 to -i386 (first line). If you get an error about python not found or something, try changing python2.7 to python2.6.

Okay, after making those 2 changes, here's what I get:

aifc.Error: unrecognized chunk type FLLR

Trying editing the AppleScript: Look for "afconvert -d ima4" and change to "afconvert -d ima4 --no-filler".

@guy, on 16 June 2017 - 02:51 AM, said in How to make a snd resource:

Trying editing the AppleScript: Look for "afconvert -d ima4" and change to "afconvert -d ima4 --no-filler".

Attached File error.png (62.16K)
Number of downloads: 9
I'm not good at reading code, but I get the impression that a bad syntax was created on my part.

Ah, make sure you leave a space between no-filler and /tmp.

This post has been edited by Guy : 17 June 2017 - 07:58 PM

That's what I thought. But good news, it now works! Thanks for walking me through.

Great, thanks for testing this!
I've uploaded a new version with these changes to support 10.6.

I may be able to make this into a plugin for MC...

This post has been edited by Guy : 17 June 2017 - 09:54 PM

Sounds promising and I hope you do.

Log in to reply