Pulling datapoints from live feed at set tempo

Atlas's icon

I'm working with a live feed of data, which I'd like to play a select note based on its value. However, because of the speed of the data (100 datapoints per second!), I'd like Max to only accept a datapoint and play a note at a set BPM. Right now, it plays the notes as the data comes in at 100 beats per second, whereas I'm aiming (mostly arbitrarily) for 60 beats per minute. There is no need to store the data in any extended list, as we won't be collecting this data - only working with live feeds.

I'd also like to be able to change the BPM after it passes through the note selection expression. My hope is that if I can figure out the concept of delaying the data speed, I can move it to a different point in the patcher without too many issues.

I've attached an isolated piece of the patcher I'm working with, since I can't exactly share the live feed data here. When there is no data passing through the feed, it plays the note based on the last known location at 60bpm. However, when the data does come through, it reverts back to 100 beats per second. There are some comments to explain what I intend to do what. Apologies if it's not best practices - I only started with Max yesterday, so I'm still learning!

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

Atlas's icon

In case it's helpful, we're using a UDP receive for the livestream. The data is unpacked and some minor scaling/unit conversions are run on it before it's sent and received as "livestream".

Source Audio's icon

you must have connected something wrong.

One could understand it so that you get some numbers,
analyse them and result triggers one of that 9 notes.
If you want to output only at 60 BPM instead of 100 BPS,
and don't want to store anything, then why not store single intance of that "data" and trigger output using metro

Maybe you are after something else, like averaging input collected
between metro bangs, or something else ?

Atlas's icon

I tried the arrangement pictured above; it still defaults to the 100 beats per second. The bang just underneath the metronome is the same - with the live feed running, it also activates at 100 beats per second rather than 60bpm.

Storing a single instance of the data would be less effective for our goal - it's motion tracking, so I want the audio to be interactive and responsive to the constantly-changing location. But I don't want that audio to be triggering every time new data is received.

Atlas's icon

I'll go ahead and mark this resolved - one of my peers found a solution! The module needed is called [onebang] which allows a single bang to pass through at the rate dictated by the metronome function. We've now arranged the bottom as such. A single note plays at a rate of 60bpm, updating live as the data changes.

Pedro Santos's icon

Hi Atlas. Welcome to the community. You've had a lot of progress in two days, but since you're starting with Max, I'm sending you some optimization suggestions.

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

If you want to go further, avoid the long expr and the following selects whenever viable, trying to find the inherent principle to what you're trying to map/convert. The [scale] and [split] objects could be helpful in your case. Good luck!

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