Max crashes when reading/playing long mp3/m4a files

ironside's icon

Hi all,

I'm running into a crash/limitation of sfplay~. I'm reading long (5/6 hour) .m4a and .mp3 files, and when I load these into sfplay~ Max (macOS Sierra) crashes. In 32-bit mode the program unexpectedly quits, and in 64-bit it just hangs indefinitely. This must be something to do with sfplay~ and how it handles compressed files. I wouldn't normally use m4a or mp3s but in this case it's unavoidable.

Is there a workaround for this, without converting the files to aif/wav etc? Is this a bug other people have noticed?

Best
Jamie

11OLSEN's icon

I noticed sfplay~ does not stream from disk when it comes to compressed formats. It decodes the whole file into RAM on open file. even with normal length mp3 there is an annoing delay/block before playback is possible. your 5h file will be 6 Gb in memory.

ironside's icon

Thanks for your answer - that makes sense... it basically behaves like buffer~. Interesting... And annoying.
I was looking at an approach using Jitter and the old spigot~ object, but am finding it glitchy - plus, I can't seem to jump ahead in the file (I need to basic 'seek' functionality of sfplay~ for this). You ever had any luck with using Jitter?

11OLSEN's icon

No, I'm currently trying to solve the loadtime problem with a custom external. But it is writing to buffer~ which is limiting the maximum size, too. At least I don't have to wait with playback for a complete decode anymore. You would need a version of my code with a perform method and a kind of buffer that is filled as needed by the decode process. That would make it a "real" stream from disk msp object that doesn't care about file length and format. For now I have only a Windows prototype external. So I'm not even at the stage of porting it to mac.

ironside's icon

Sounds interesting. Best of luck with it!

Ullstein's icon

I had a problem with a 40 min 8-track .wav-file and the same thing happened to me as to Ironside. With .aiff files of the same configuration and size it works. I had a conversation with c74, they noticed it and promised to check.

volker böhm's icon

hi
some time ago, when I was trying to learn more about core audio, I made a max-external that could play back compressed audio files as an exercise. It's very basic and I can't guarantee that it works for your purposes, but if you're interested in trying it out, let me know.
obviously only works on macos, though.
vb

ironside's icon

Hi Volker - I would be interested in trying it, if it's not too much hassle. EDIT: I mean not too much hassle for you - I don't mind if it's a hassle.

volker böhm's icon

ok, here you go (scroll down to the bottom)
http://vboehm.net/downloads/

please note, it's not really ready for prime time and i'm sure you'll find some quirks (one being it stops playback about half a second before the end of the file...). and despite it's name (playmp3~) it should play other formats aswell, but I only tested mp3 and m4a.
Let me know how it goes.

ironside's icon

Thanks Volker. Running Max 7 (I don't have any earlier versions on this computer) I get an error message saying: "err: 1869902714" in the console after I've loaded an mp3 and press play. I do seem to be able to play around half a second of the start of the file when I press resume or the toggle button, but then the error message comes up and the audio stops.

volker böhm's icon

ha, half a second is not much...
I can't really reproduce the error here, but I have a suspicion and changed (fixed?) something about the frame count.
If you like, you can give it another shot and re-download from the same url.

ironside's icon

Hi Volker - thanks for posting the updated file. Unfortunately, I still get the same error and behaviour as last time.

volker böhm's icon

hm, can't say much more then.
maybe check again, that you downloaded the updated version (maybe need to clear your browser cache), as it's running without hickups here on three different machines.