How to clear buffer when it can't load new file?

conorb's icon

Hello!

I'm in a pickle again.

I am loading a sequence of audio files into a buffer, sometimes the files will not be there and it will give me an error message saying 'Can't open ____'.
This is ok, but I want it to then clear the buffer with silence if it cannot find a new file, rather than repeatedly playback the file that's already in the buffer.

Max Patch
Copy patch and select New From Clipboard in Max.

Any ideas?
Is there a way to tap into the error messages in the Max window and trigger events (such as clearing a buffer) if particular error messages show up?

Ben Bracken's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You could use the error object to do this. Other options are the absolutepath object (to check the file path to see if its valid) and the bang outlet of buffer~:

conorb's icon

Your absolutepath method is a wonderfully elegant way to achieve exactly what I needed.
Thank you so much!

metamax's icon
Max Patch
Copy patch and select New From Clipboard in Max.

metamax's icon

Ah. Too slow. Ben's kung fu is strong.

Roman Thilenius's icon

setting a size again should also clear it.