trigger event from soundfile

Matthew's icon

Hello,

Very new to Max/Msp and I'm sure this is easy but...
I am playing a sound file using sfplay and want to trigger events when the file reached various points as it plays. What if the best way to to do this?

e.g. file reaches 1.54 seconds, button 1 is automatically pressed, files reaches 2.73 secs button 2 is pressed.

many thanks,
Matt

Chris Muir's icon

At 10:55 PM +0100 7/18/07, cloughy wrote:
>Hello,
>
>Very new to Max/Msp and I'm sure this is easy but...
>I am playing a sound file using sfplay and want to trigger events when the file reached various points as it plays. What if the best way to to do this?

Look in the help patcher for sfplay~, particularly in the "new features" section for info on how to find out the current position.

The sfinfo~ object reports the length of the file (among other things) so you could calculate percent of file played based on the ratio of position to length

-C.

--
Chris Muir | "There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue." - Brian Eno

seejayjames's icon

You could also start a count~ object when you start playing, or for that matter a timer too, then select a specific number. Maybe better, do a comparison: so "when time > 2.73 sec" then trigger. Sometimes specific numbers get skipped when they're changing fast (i.e. the scheduler can't update the numbers to keep up with the signal~).

--CJ

fletcher's icon
damiano's icon

You can try using a delay (or pipe) of the first sfplay~ trigger?

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

Leafcutter John's icon

Fletcher the main problem with your system is that the number~ object is set to report values at 250ms intervals that means the play time coming out of it might look something like this; press play, 0,250,500,750etc. But because of the way snapshot works (it put out values regularly at a set frequency) it's output could also look like this;press play, 111, 361, 611 etc

Your >= and

Number~ can be made to report much faster like 25ms which will improve cue accuracy and i'd suggest using >= as a better option than >= and

I had a little play about with your patch and came up with a couple of options for you including a sample accurate one.

Best,

John.

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

fletcher's icon

I do not want to sound to "flowery" as someone once told me my resume was, but I am honored by your reply Leafcutter John. I now understand, thank you for that. Thank you for giving to this community. Thank you for helping me get past that hurdle.
Sincerely,
Chad Fletcher

Frans-Jan Wind's icon

I found John's solution inspiring to change a patch I use often. In this patch I translate the cycle of a phasor~ to 8th parts from which I can sync non audio objects. It works good for finding all milisecs but the zero. I can solve this by entering a number slightly higher (0.0001) but taht;s a bit off beat...

Maybe one knows how to find the zero?

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

Thanks for reading!

Stefan Tiedje's icon

Frans-Jan Wind schrieb:
> I found John's solution inspiring to change a patch I use often. In
> this patch I translate the cycle of a phasor~ to 8th parts from which
> I can sync non audio objects. It works good for finding all milisecs
> but the zero. I can solve this by entering a number slightly higher
> (0.0001) but taht;s a bit off beat...
>
> Maybe one knows how to find the zero?

It won't find a zero if there is no zero. The zero most likely is
between two samples. And how much off beat is 0.0001? Get out your
calculator, I bet its less than a scheduler tick...

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

Frans-Jan Wind's icon

You're right, I can't hear it. I guess it's between the ears then!