How to play and stop an audio file according to the different situation

Meng's icon

Hi

I am new to Max, so the question may be silly, but it really embarrassed me. In a patcher, I want to play different audio files when the value of a number reaches a certain range. The problem is that when the number goes from the current range to another range, both audio files will play simultaneously. Could anyone please give any idea how to fix it?

new.maxpat
Max Patch
double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.
Meng's icon

Thank you for your reply.

Yes, it is working! hurray!! ;-)

Meng's icon

Sorry to bother again. But a new problem happened. >_<

When a new number enters, if it remains in the same range, for example, it always smaller than the threshold (320), I want it to play the sound continuously, instead of starting from the beginning each time. Do you have any idea? Thank you anyway!

double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.
Source Audio's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi Mengwei.
I feel really amused about questions You are asking, and this " New Problem happend..." messages.
Don't worry, this "New Problems" are going to arrise all the time, doesn't matter how experienced
Max user You become. At least that is so in my case.
Programming in Max is somehow like playing a chess game, and that is what is so
wonderfull about it.
So have a look at this patch, which is just bringing a solution to Your next "New Problem",
- what to do if sfplay finished playing the file.
Inserting a change object without resetting it in certain condition is not going to work properly...

Meng's icon

You are awesome!! lol

Thank you soooo much!!!

Meng's icon

Thank you for your encourage( I regard so), your patcher is much better which is able to control the start and set! And yes, a change object is helpful in my case. Really admire programmers like you who are familiar with every object and every function.

Again!Thank you very much! ;-)