Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Apple Lossless Audio Codec (ALAC) on Mac OS 9  (Read 12609 times)

ivan_holmes

  • 16 MB
  • ***
  • Posts: 28
  • New Member
Apple Lossless Audio Codec (ALAC) on Mac OS 9
« on: February 02, 2020, 11:07:47 AM »

Hi all,

A while ago I tried to play some music (encoded as ALAC .m4a) from my NAS on Mac OS 9 and it didn't work. I did a bit of a search on the issue and found this thread: http://macos9lives.com/smforum/index.php/topic,4169.msg28636.html#msg28636 which confirmed my suspicions that it wasn't supported.

I have some limited experience in C(++) development, so I wanted to have a go at providing some sort of support for this format. As Apple open-sourced the ALAC code in about 2011 I thought that would be a good place to start. A little bit of wrangling (changing options to make errors go away) got it to compile in CodeWarrior. I used SIOUX and ccommand to get it up and running quickly. Once I'd done this I realised that the provided utility, alacconvert, only supported ALAC in the CAF container format, which is used by basically nobody.

I did some more digging online and found an unofficial ALAC decoder released by David Hammerton around 2005, last updated 2009. As no applications available for Mac OS 9 support the format, I don't think encoding support is very important. This code is more useful to me than the Apple supplied code because it reads .m4a files.

I imported it into CodeWarrior and after changing a few options and altering the code slightly to work with SIOUX I was able to convert my first file! Just to be sure I decoded the same file on my modern Hackintosh and compared the results – exactly the same!

I have attached the utility to this post, it can be used by:
  • Open the 'alac' application
  • In the text field enter '-f <path to output wave file>.wav <path to input m4a file>.m4a'. You can also enter '-h' to see the original help. The window will vanish and the computer will do nothing for as long as it takes to decode your file
  • Play your freshly decoded file!

The logical next step to my mind is to create a drag-and-drop conversion utility so you can drop a few .m4a files and have them converted to .wav or raw PCM. It would be good if there was a progress bar too. I am working on this at the moment but as I say my experience of Mac OS 9 development is non-existent. Happily I have found an example for a drop utility bundled with CodeWarrior 8 Pro. I am not clear on how to go from an FSSpec to a FILE pointer... maybe I am thinking too much into it. I am going to do some reading into the subject. EDIT: I have found the function I need, it's FSP_fopen.

I am intrigued by a comment made by the original author on his webpage – 'In theory one should be able to stream data to the decoder.' – this makes me think it would be theoretically possible to write a QuickTime plugin to allow the files to be played natively. From what I gather the way to do this in the Classic Mac OS is to write a Sound Manager component. If anyone knows more on this topic or can point me to documentation with minimal effort I would be interested.

I have downloaded OGG Vorbis components for Mac OS 9. I haven't had a chance to look at them yet but I am hoping the source is included or at least available somewhere...

Cheers,
Ivan

TL;DR Very basic command line utility to decode ALAC now available for Mac OS 9!
« Last Edit: February 02, 2020, 03:04:24 PM by ivan_holmes »
Logged

Philgood

  • 256 MB
  • *****
  • Posts: 421
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #1 on: February 02, 2020, 12:25:32 PM »

Amazing what is still done for our beloved OS9. Thanks a lot.

I personally use it a lot. Mostly for the VST instruments I grew up with through the early 2000.
Logged
*G4 MDD 1.25GHz (Single 2003)* with 2x 80Gb harddrives, 1Gb RAM, Tascam US-428 and Edirol FA-101 USB/Firewire soundcards-*iMac G3 DV 400MHz* with installs from OS 8.6-OSX Tiger on different harddrives-*Powerbook G4 1.67Ghz* with new SSD ! Love it.

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4651
  • just a number
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #2 on: February 02, 2020, 01:03:42 PM »

good work, thank you.

from my perspective it would be even more useful to be able to directly play files.

can you elaborate on how realistic a quicktime codec for a previous unsupported format would be?
Logged
insert arbitrary signature here

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4651
  • just a number
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #3 on: February 02, 2020, 01:06:10 PM »

damn, once more i posted a reply before i´ve read the last two sentences.

yes, that ogg for quicktime should be open source, good idea.
Logged
insert arbitrary signature here

ivan_holmes

  • 16 MB
  • ***
  • Posts: 28
  • New Member
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #4 on: February 02, 2020, 02:13:09 PM »

Amazing what is still done for our beloved OS9. Thanks a lot.
good work, thank you.
No problem, although I should emphasise that this initial proof of concept involved very little work!
I personally use it a lot. Mostly for the VST instruments I grew up with through the early 2000.
I'm not old enough to have used it back in the day, but I really like the simplicity and charm of OS 9. There's also something very cool about giving new functionality to a supposedly dead system.

from my perspective it would be even more useful to be able to directly play files.
can you elaborate on how realistic a quicktime codec for a previous unsupported format would be?
yes, that ogg for quicktime should be open source, good idea.
I agree with you and this would be my ultimate goal. I think a port is absolutely realistic as a possibility because third party components are not at all out of the ordinary. The problem will more likely be my skills! As you say the OGG Vorbis component will almost certainly be open source so that will hopefully be a good place to start.
At the moment, a drag and drop application is more reachable for me as a goal so I will see how I get on with that.
Logged

mrhappy

  • 1024 MB
  • ******
  • Posts: 1156
  • new to the forums
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #5 on: February 03, 2020, 07:17:59 AM »


I'm not old enough to have used it back in the day, but I really like the simplicity and charm of OS 9.


It's GREAT to see young 'whipper-snappers' here breathing new life into that good ol' OS9 that us old geezers love so much!!! Nice work...thanks! ;D ;D
Logged

MacTron

  • Staff Member
  • 2048 MB
  • ******
  • Posts: 2116
  • keep it simple
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #6 on: February 03, 2020, 01:28:53 PM »

Thank You for sharing your work. :)
this is a very useful and interesting project.
Logged
Please don't PM about things that are not private.

ivan_holmes

  • 16 MB
  • ***
  • Posts: 28
  • New Member
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #7 on: February 03, 2020, 04:15:59 PM »

Thanks to all for your kind words.

Great news – I have succeeded in making a very basic drag and drop conversion utility. It crashes when I drop multiple files on it; I am going to look at fixing this. I haven't looked into it at all yet so hopefully it will be easy!

I will upload the utility here soon whether I find a fix or not.

This project so far has certainly been an unconventional way to brush up on my C++...
Logged

ivan_holmes

  • 16 MB
  • ***
  • Posts: 28
  • New Member
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #8 on: February 05, 2020, 04:00:44 PM »

I've fixed the problem I was having when trying to use the drag and drop utility with multiple files – the original code had a memory leak which didn't matter until I tried to run it more than once, which I fixed. It also didn't check to see if the pointer for the buffer was null, which it could be even after fixing the leak due to memory fragmentation. I fixed that and increased the size of the heap to avoid frequent error messages.

None of this would have been a problem in the code's original form as it was only intended to run once, and it was written for modern operating systems where the heap size is not fixed.

As a result of all this, I am now able to release an alpha version of the drag-and-drop conversion utility, 'Drop ALAC'.
I have attached a binary and the source code to this post. To use the application, simply drop one or more ALAC-encoded .m4a files on to its icon, and a .wav file with the same name will be produced in the same folder.
There is no progress bar when the utility is working, but you can watch the small flashing indicator in the top left of the screen to be assured that it's still running.

This is an early alpha version and all the usual disclaimers apply – I make no promises as to its stability etc. That said, if you try it out and have problems please let me know.
Logged

MacTron

  • Staff Member
  • 2048 MB
  • ******
  • Posts: 2116
  • keep it simple
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #9 on: February 06, 2020, 08:09:21 AM »

Thank You, it works OK. ;D
I just had to rebuild the desktop to refresh the application icon and BNDL resources and thus "enabling" drag and drop. This a common issue in Mac OS 9. ;D
Logged
Please don't PM about things that are not private.

ivan_holmes

  • 16 MB
  • ***
  • Posts: 28
  • New Member
Re: Apple Lossless Audio Codec (ALAC) on Mac OS 9
« Reply #10 on: February 06, 2020, 08:59:41 AM »

Thank You, it works OK. ;D
I just had to rebuild the desktop to refresh the application icon and BNDL resources and thus "enabling" drag and drop. This a common issue in Mac OS 9. ;D
Glad it is working for you!
I had a similar problem (not accepting drops) during development and I ended up trashing the CodeWarrior project and setting it up again. I am aware that you'd want to rebuild the desktop to fix missing/weird icons but didn't realise drag and drop could be affected too, good to know.
I wonder if there's anything I could have done before stuffing it to make it work properly from the start? It was of course working perfectly on my system before I stuffed it.
Logged
Pages: [1]   Go Up

Recent Topics