How do I sync a sound to a division of a musical beat?

Get help using Construct 2

Post » Sat Aug 13, 2016 3:26 pm

I want to build a sample player and when you click a sound it "quantizes" the playback point to the next nearest division of the beat, so, if I've set the lengths of my sounds up correctly, they should all start correctly and stay in time with each other. Is there a good way of doing this with dt?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Aug 14, 2016 4:01 am

Has nothing to do with 'dt'. Just use a Timer and get the percentage of it's period to see if the click goes left or right.

http://www.blackhornettechnologies.com/ ... eBeat.capx
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Sun Aug 14, 2016 8:13 am

So, if I click "play loop" in my game, how do I use that to wait until the next division to play the loop?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Aug 14, 2016 1:31 pm

The timer is ticking at the beat. That's when you play each note.
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Mon Aug 15, 2016 7:15 am

Yeah but what I want is you click to play a loop, it waits until the timer arrives at a division (say 8th note) and then starts. Should I do it with something like a global, and when I click to play a loop it turns the global to 1 and if the global is 1 and the time is a precise division, turn global to 0 and play loop? What expression should I use to test if the timer is currently on a division of the timer? Also, this would have to be compatable with different tempos rather than just, say, 120bpm (which is easy cos it's division of a realtime minute)
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Aug 16, 2016 9:37 am

blackhornet wrote:Has nothing to do with 'dt'. Just use a Timer and get the percentage of it's period to see if the click goes left or right.

http://www.blackhornettechnologies.com/ ... eBeat.capx


@blackhornet
What bpm does the BeatFrequency correlate to?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Aug 16, 2016 2:10 pm

The timer frequency = 60/bpm, so at a freq of 0.5s, which is in the code, 0.5 = 60/bpm, bmp = 60/0.5 = 120bpm. If you think it out, the frequency is a beat every 1/2 second, so that's 2 beats per second, times 60 seconds, which is 120 bpm.

bpm are generally considered 1/4 notes, so for 1/8 notes, divide the timer freq by 2, so 120bpm would be a freq of 0.25.

I had a few bugs in my sample, so I've cleaned those up and added a start button. The trick is just to start at beat -1, so that it leads into that first beat.
http://www.blackhornettechnologies.com/ ... Beat2.capx
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Wed Aug 17, 2016 1:13 pm

blackhornet wrote:The timer frequency = 60/bpm, so at a freq of 0.5s, which is in the code, 0.5 = 60/bpm, bmp = 60/0.5 = 120bpm. If you think it out, the frequency is a beat every 1/2 second, so that's 2 beats per second, times 60 seconds, which is 120 bpm.

bpm are generally considered 1/4 notes, so for 1/8 notes, divide the timer freq by 2, so 120bpm would be a freq of 0.25.

I had a few bugs in my sample, so I've cleaned those up and added a start button. The trick is just to start at beat -1, so that it leads into that first beat.
http://www.blackhornettechnologies.com/ ... Beat2.capx

Okay, so with this, it places a marker on the visual beat, but I'm trying to wait until the moving blue box gets to a beat and THEN it plays the loop, is there a way of modifying this to get that to work easily?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Aug 17, 2016 6:23 pm

blackhornet wrote:The timer frequency = 60/bpm, so at a freq of 0.5s, which is in the code, 0.5 = 60/bpm, bmp = 60/0.5 = 120bpm. If you think it out, the frequency is a beat every 1/2 second, so that's 2 beats per second, times 60 seconds, which is 120 bpm.

bpm are generally considered 1/4 notes, so for 1/8 notes, divide the timer freq by 2, so 120bpm would be a freq of 0.25.

I had a few bugs in my sample, so I've cleaned those up and added a start button. The trick is just to start at beat -1, so that it leads into that first beat.
http://www.blackhornettechnologies.com/ ... Beat2.capx

@blackhornet I've come up with a hack that works very well for what I required, do you mind if I send you, you can see what you think to it, maybe it might be of use to you?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Aug 21, 2016 5:17 pm

You can PM me if you want. There should be no reason to 'hack' anything.
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Next

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 26 guests