Forums > MaxMSP

Suggestions for how to generate a click track sync'd to wave file

Jul 18 2012 | 10:36 am

I have a short wave file (length is 4 beats) that I need to play as a loop and that will be heard for about 16 bars at occasional points in the song.
I’m going to have to feed our drummer with a click derived from this loop so that he can make sure that the band is always playing at the right speed for when the loop is audible.

I know I can use sfplay~ to play the wave file and I could use the seek message to start and end it (the actual loop is a few samples less than the actual wavefile) and retrigger that seek message from the bang that’s generated each time the wave file plays.

The problem is that I need to generate a click that triggers every beat, not every 4 beats and I’m wondering how best to do that.

The "obvious" solution that comes to my mind is to have four sfplay~ objects each of which has a seek message with 1 beat’s worth of sample start/end time and then daisy chain them using the "end of play" bang that comes out (and using that bang to generate a click), but this seems quite kludgy.

I’m wondering if anyone knows of a cleaner solution for this.


Jul 18 2012 | 10:38 am

I’m not even sure the ‘seek’ message is good enough as it only seems to have a resolution of 1 millisecond and I would need to have sample-accurate playback to avoid clicks in between each chunk.

Jul 18 2012 | 11:17 am

By the way, I looked at splitting up the original wave file into four parts which could then be loaded into buffers and played back using the [groove~] object but there does not seem to be any way to detect when [groove~] has finished playing one buffer so that the next one can be started.

Jul 18 2012 | 11:47 am

How about recording your click track and then sync’n the playback of the two files.

Jul 18 2012 | 11:47 am

(This is turning into a documentary on problem solving – but maybe it will be useful to someone else)

Looks like I might be able to just have the entire loop in [groove] and then use snapshot to detect the current position and then trigger something every quarter of the way through.

Jul 18 2012 | 11:49 am

caveat, i am not yet fully awake. here is what i use for click tracks when playing back from (groove).

-- Pasted Max Patch, click to expand. --

Jul 18 2012 | 12:01 pm

OK, problem solved — I suspect this has been solved many times but here’s my quick hack solution in case it’s useful to anyone.

-- Pasted Max Patch, click to expand. --

Jul 18 2012 | 12:09 pm

Sorry, I didn’t realize that others had replied and so I apologize for having ignored the posts (just noticed via email).
@kthozoid, my sympathies, I’ve been up since 4:30am having realized last night that I was going to have to figure something out.
Thanks for your suggestion, which I will have to study, it seems a lot more complicated than what I did so I presume it has other benefits that I don’t yet understand.

Jul 18 2012 | 12:20 pm

@dhj, no worries. indeed my solution is probably overcooked. it just has a few extra functionalities for metric sub-divisions and altering the click track sounds and that kind of thing.

Jul 18 2012 | 12:23 pm

ok —- I am not generating the click sound inside Max — I will be sending MIDI events to a remote device that the drummer can hear. So I just needed to make sure that I could break up a long loop into the right number of even segments….not having much familiarity with the MSP side of Max, I wasn’t aware of [groove] and more importantly [snapshot]. Once I discovered the latter, the problem became trivial for me.

Jul 18 2012 | 12:36 pm

ok, then your solution will do just fine then. and here is a quick (sfplay) version just for the general purpose of completion.

-- Pasted Max Patch, click to expand. --

Jul 20 2012 | 8:22 pm

I just noticed that the groove stuff using a buffer seems to only have audio coming out one channel. The example for groove shows a single channel being split into two. How can I play a stereo sample?

Here’s my current patch

-- Pasted Max Patch, click to expand. --

Jul 21 2012 | 9:13 am

your buffer~ was mono.

-- Pasted Max Patch, click to expand. --

Jul 21 2012 | 11:24 am

Thanks, pid, I had tried that before (although I used a positive value for the duration (while being annoyed that I had to put the duration before the number of channels so glad to see one can put -1 there) and it didn’t work. I’ll check that again.

Jul 21 2012 | 12:34 pm

This doesn’t work — unless I’m doing something really stupid (which is quite possible), there’s something else wrong.
I’ve attached the patches (and the stereo aiff file) if you’re willing to take a quick look

-- Pasted Max Patch, click to expand. --

-- Pasted Max Patch, click to expand. --

Jul 21 2012 | 7:50 pm

Works here.

-- Pasted Max Patch, click to expand. --

Jul 21 2012 | 8:34 pm

Hmmm, that’s Max 6 — I’m doing it with Max 5 right now — I wonder if that’s an issue.
(But at least I know there’s nothing wrong with the sample or my patcher)

Jul 21 2012 | 9:12 pm

Try this…

-- Pasted Max Patch, click to expand. --

Viewing 18 posts - 1 through 18 (of 18 total)

Forums > MaxMSP