Help making bang only trigger audio once, and turn on and turn off at the correct times

hamela handerson's icon

Hi there,
I'm in the process of making a patch that extracts rgb data from a silent video file. The mean number from the RBG channels is calculated and the maximum number of either red green or blue is calculated, resulting in a particular piece of audio playing. For example, Green is the maximum channel so 'Green' audio is played.
Currently lots of bangs come through in quick succession meaning that the audio cuts in and out and doesn't stop at the correct time because it's been triggered on then not off.

Can anyone help me trigger the bang only once - then somehow solo that audio so none of the audio channels play at the same time?

I have been experimenting with onebang which works to an extent however sometime the bang in the right inlet doesnt send at the same time as the one in the left inlet so no audio plays (I had a metronome going through the right inlet of onebang)

I also experimented with integers from the toggle above the audio file player and "if$1 == 1 then bangout1" and connected this to a bang, connecting to another audiofile player toggle or a stop message (hoping to solo one) but it kind of overloaded and didn't work properly.

Any suggestions appreciated,

I'm fairly new to max so as simple as possible please!

Thank you

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


marker's icon

Not sure if I completely understand what you need but maybe this helps you in the right direction.
It calculates the mean highest rgb values in a video and selects a sound file to play based on red, green or blue being the highest value at a given time. Once selected it plays a sound file completely. When done playing it enables a new measurement and can trigger the same or another soundfile to play. You can use either different videos files or one video.

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

hamela handerson's icon

Thank you so much for your reply,

This is certainly helpful, however, instead of a sound file playing completely I need it to trigger on - then trigger off when a different sound file is triggered on

marker's icon

Okay... I see... then try this!
It uses the [change] object which filters out repetitions of the same data. In other words... It will prevent constantly re triggering the same sound file.
And be sure to work with only 1 playlist~ as this can only play 1 sound file at a time based on an index number.

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

marker's icon

Any succes with this?

hamela handerson's icon

Hi, apologies for the delayed reply,

Yes this is exactly what I was looking for :)

Thank you so much!