# Calculate Time-Based Units with the Grid

Tutorial | Jun 10, 2024

In this video, I explain how to use the grid in Bitwig Studio to calculate release time for a compressor based on beats instead of milliseconds. I show how to convert a ramp signal into a sound, measure the pitch using zero crossings, and then convert it to hertz and milliseconds. Although it's a hacky approach, it's a fun challenge and allows for time-based calculations in the grid.

- You can watch the Video on Youtube
- support me on Patreon
- HZ2MS-Conversion Preset
- BPM2MS Calculator

In this video, the creator demonstrates how to use Bitwig's Grid to solve the problem of converting millisecond-based compressor release times to beat-based units like 1/16th or 1/8th notes. This involves using the Grid to calculate time-based units that adjust automatically with changes in BPM. Here’s a quick overview of the process:

### Key Points: #

**Compressor Plus Limitation**: Typically uses milliseconds for attack and release times.**Beat-based Units**: Using note values for release times can ensure consistency across BPM changes.**Grid Calculation**:- Set up an FX Grid with Compressor Plus.
- Use the transport to generate a ramp signal that reflects BPM changes.
- Convert the ramp signal into a sine wave and measure its frequency using the zero crossings method.
- Calculate the milliseconds from the frequency.

**Implementation**:- Multiply the phase signal to adjust pitch and use zero crossings to estimate frequency.
- Convert hertz to milliseconds using reciprocal calculations.
- Modulate the compressor's release time with this value.

### Detailed Steps: #

**Set Up Grid**:- Use FX Grid, add Compressor Plus, and pass audio through.

**Generate Ramp Signal**:- Use the transport module to create a ramp signal reflecting BPM.

**Convert Signal to Frequency**:- Transform the ramp signal to a sine wave and measure frequency via zero crossings.

**Calculate Time**:- Convert frequency (Hz) to milliseconds using mathematical operations (reciprocal and multiplication).

**Modulate Release Time**:- Map the calculated milliseconds to the release time of the compressor, adjusting for the logarithmic nature of the control.

This approach, although complex and a bit "hacky," allows for dynamic adjustment of compressor release times based on BPM, ensuring more musical and consistent results.

## Questions & Answers #

Maybe you dont watch the video, here are some important takeaways:

### How can the grid be used to solve certain problems? #

The grid can be used to solve problems by using different modules and calculations. In this video, the grid is used to calculate milliseconds for time-based units, such as beats, by converting a ramp signal into a sound, measuring its frequency, and then converting that frequency into milliseconds. This allows for precise modulation of release times in music production.

### What is the benefit of using time-based release time? #

The benefit of using time-based release time is that it remains consistent regardless of changes in BPM. For example, if one wants to dial in a 1/8 note release time, it will always be 1/8 note no matter the BPM setting. This makes it easier to maintain the desired musical timing and adjust the release time accordingly.

### What challenges are faced when using the grid for these calculations? #

One challenge is that there is no built-in module in the grid to directly calculate time-based units based on BPM. This requires a workaround using different modules and calculations. Additionally, some modules have limitations, such as the zero crossings module only operating within a certain frequency range, which requires finding the right settings for accurate measurements.

### Is this approach practical for everyday music production? #

While this approach can be used to achieve specific time-based modulation in music production, it is not necessarily practical for everyday use. It requires multiple calculations and workarounds, and the accuracy may not be perfect. However, for those who enjoy experimenting and finding creative solutions, it can be a fun and interesting challenge to tackle in the grid.

## Transcription #

This is what im talking about in this video. The text is transcribed by AI, so it might not be perfect. If you find any mistakes, please let me know.

You can also click on the timestamps to jump to the right part of the video, which should be helpful.

[00:00:00] Okay, so this video is maybe a bit nerdy, but it also can show you how to use the grid to

[00:00:06] solve certain problems, to find some rocker rounds to do some math inside of the grid,

[00:00:13] and maybe also show some shortcomings of the devices.

[00:00:16] So for this example, I want to use Compressor Plus, and like most compressors on the market,

[00:00:21] it uses milliseconds for attack time and release time.

[00:00:26] And this is okay, but sometimes you want to use something like beats, like 160 note,

[00:00:32] 1/8 note, 1/4 note as a release time here, right, instead of milliseconds.

[00:00:38] And we have your auto timing, which kind of does something like this in the background,

[00:00:42] but it's not represented inside of the GUI.

[00:00:46] So you don't know what it's calculating in the background.

[00:00:49] You can maybe see it inside of the graph, you can maybe hear it, but it's not represented

[00:00:55] as a number, right, so you don't know what's happening.

[00:00:59] So what to use the grid actually here to calculate the milliseconds for some time-based units.

[00:01:11] So let's say we want to change the BPM, the release time has to change, right?

[00:01:16] So if I show you this here in a drawing, so let's say you have, I don't know, a kick drum,

[00:01:24] and then you have a snare drum, and then you have a kick drum again, right?

[00:01:28] So the distance here between the kick drum and the snare drum is, of course, you can

[00:01:34] measure this in milliseconds, right?

[00:01:36] But it's also exactly maybe one 16 note, right?

[00:01:41] So when you change the BPM, milliseconds change because this one gets closer to the previous

[00:01:50] sound, right?

[00:01:51] So the snare drum is closer to the kick drum because you play it faster.

[00:01:55] So the milliseconds change, but one 16 note is always the same.

[00:02:00] So when you dial in one 16 note, milliseconds basically change in the background.

[00:02:04] So this is the benefit of having basically a time-based release time.

[00:02:09] You dial in one 16 note and it stays basically always one 16 note, and if you change the BPM,

[00:02:15] it's changed in the background accordingly.

[00:02:19] So this is basically what we are trying to achieve.

[00:02:24] And inside of the grid, there's actually no way to calculate something based on the BPM.

[00:02:31] So let's say we use here an FX grid, put this in, and we use here the compressor plus inside

[00:02:40] of post FX, of course, we want to modulate at the release time.

[00:02:45] So in the grid, we just pass the audio through the device itself.

[00:02:52] And then we want to calculate based on the BPM.

[00:02:55] So there's no module inside of grid that gives you just a number of one of the 31 BPM.

[00:03:02] We can just use here maybe a constant and just type it in manually, right?

[00:03:07] Something like this.

[00:03:09] And then we do some calculations with this.

[00:03:11] That is possible.

[00:03:12] And it's probably just the easiest way.

[00:03:15] But when you change the BPM setting, right, it's just actually not what you do all the

[00:03:20] time.

[00:03:21] So it's a constructed problem.

[00:03:23] You usually don't change the BPM in your project all the time.

[00:03:27] So it's maybe something you do in the beginning once or twice and that's it.

[00:03:32] So you're completely fine with just using constant and then calculating the time based

[00:03:39] units with this.

[00:03:41] But you know, I want to construct a problem yet just to make a video.

[00:03:47] So my idea for this was instead of using here the constant, I'm using the transport.

[00:03:56] So the transport here gives out more or less a ramp signal.

[00:04:03] Maybe let's go too fast.

[00:04:06] So you can see we have here now a ramp signal going from zero to one.

[00:04:10] And we now need to kind of calculate the distance between zero and one.

[00:04:17] So how long is this actually in milliseconds?

[00:04:20] Because this ramp signal changes when I change here.

[00:04:25] When I change the BPM, you can see now it's the ramp signal is much more steeper and the

[00:04:29] distance between zero and one is much shorter, which is exactly what we need.

[00:04:34] So how do we actually calculate the distance between zero and one?

[00:04:39] It's not an easy task because inside of the grid, there's no module that does something

[00:04:44] like this where you can measure milliseconds.

[00:04:48] So we have to hack around this problem.

[00:04:52] And my idea for this was let's actually convert this into a sound.

[00:04:58] We take the ramp signal, which is a phase signal and just put this into the sign.

[00:05:04] Look up module here, which takes in a phase.

[00:05:07] You can see it's in purple.

[00:05:09] So we can take the signal into the sign and generate the sound.

[00:05:14] The problem now is that the sound is very low in frequency.

[00:05:21] We put this pitch maybe fast, slow.

[00:05:24] So it's almost like an LFO.

[00:05:26] It's not audible.

[00:05:27] It's maybe, I don't know, three hertz or two hertz.

[00:05:32] So my idea was to actually measure this frequency by using zero crossings, which is just a rough

[00:05:39] pitch estimator, right?

[00:05:41] It gives you basically the pitch from this.

[00:05:45] And when we take your readout to see, you put this to hertz here, you can see it does

[00:05:52] nothing.

[00:05:53] It doesn't give you any value because the zero crossings only operates between 20 hertz

[00:05:58] and five kilohertz.

[00:06:00] So this pitch is way too low.

[00:06:03] So the next idea was, okay, when this pitch is still low, why not just pitch it up, right?

[00:06:10] So we use here a multiply and you multiply the phase signal here by a constant.

[00:06:22] And the constant is just some random value that's just high enough that gives you a decent

[00:06:30] pitch here out of the zero crossings module.

[00:06:33] So you can see here it's, you can change the constant, but the pitch is kind of the same,

[00:06:39] roughly the same.

[00:06:45] So we have 50, 54 hertz here, which is still low.

[00:06:49] So maybe get higher.

[00:06:52] So I think 120 hertz, it's just a nice middle ground between 20 hertz and five kilohertz.

[00:07:00] So now the zero crossings module has to measure a pitch of a very pure sine wave.

[00:07:06] It should be fairly easy for the zero crossings module.

[00:07:10] And we get here a value of C2 around 130 hertz.

[00:07:17] So now we get basically into the range of a time-based measurement.

[00:07:21] We have hertz because hertz is actually, it's per second.

[00:07:27] So one hertz is basically one event or one cycle per second.

[00:07:32] We have here 130 events, 130 zero crossings per cycle.

[00:07:40] And we can actually calculate milliseconds from this, believe it or not.

[00:07:46] So let's remove this here.

[00:07:47] Let's go there.

[00:07:49] So from this stage here, we can now use actually one of the new modules called pitch to hertz.

[00:08:02] So now we get an, instead of having here just to use this read out to get actually the hertz,

[00:08:08] now we get this as a number.

[00:08:10] So we can switch this here to number and then go in here.

[00:08:13] And you can see we have now here 130 hertz, more or less.

[00:08:18] It's actually different than this.

[00:08:19] Let me see.

[00:08:21] No, it's 129.

[00:08:22] It's the same thing.

[00:08:25] So now we get basically 130 hertz here as a number and we can calculate now with this

[00:08:31] number.

[00:08:32] But the problem is it's not the right number because we multiplied here the sine or the

[00:08:40] frequency of the sine by 250 or let's say 260 times.

[00:08:46] So this is not the right number.

[00:08:48] So what we have to do now is basically to bring it down again.

[00:08:53] So we divide this number by the same amount.

[00:08:57] So all we do basically here with this multiplication and this division is basically, yeah, it's

[00:09:06] basically just a way to actually make zero crossings work correctly.

[00:09:11] That's why we use a multiplication in this.

[00:09:13] If actually zero crossings would calculate lower frequencies, we don't need to do this,

[00:09:22] these two steps.

[00:09:23] It's just so we can calculate here or get the pitch from the signal.

[00:09:29] So now we get here basically, yeah, we get the hertz or the time-based hertz of one, well,

[00:09:42] it's actually 16, 16, 16 nodes, maybe go down.

[00:09:45] So this is one 16 node.

[00:09:49] So we have eight hertz.

[00:09:53] So this is here time-based hertz.

[00:10:00] Yeah, this is basically what we get as hertz value here.

[00:10:07] So when we speed this up, you can see hertz goes up.

[00:10:12] If you go down to 100 here, maybe, yeah, 100 gives you basically six hertz.

[00:10:21] Then you can say, does this one eight node, this gives you three hertz.

[00:10:26] So you can already calculate time-based on the BPM how many hertz basically one eight

[00:10:33] node is.

[00:10:35] So all we have to do now is basically convert hertz to milliseconds.

[00:10:41] And that's not really hard because we know already one hertz is basically one cycle per

[00:10:49] second.

[00:10:50] So we can take one second and divide it by this number, right?

[00:10:55] And we can do this by using reciprocal, that's how it's called.

[00:11:02] All those basically here uses a one and divides it by the incoming number, right?

[00:11:08] We do one divided by this number.

[00:11:13] And then we get basically here time-based more or less in seconds.

[00:11:20] So we have zero dot two seconds.

[00:11:23] That's the distance between zero and one.

[00:11:26] It's exactly the time span of one 16 node or one eight node.

[00:11:32] Sorry.

[00:11:33] One eight node is zero dot three.

[00:11:36] I can't read it really.

[00:11:38] It's flashing.

[00:11:40] It's flickering.

[00:11:42] So then to calculate actually the milliseconds from this, we can use a constant.

[00:11:49] And here we type in 1000.

[00:11:51] Because 1000 milliseconds is one second.

[00:11:56] And then we multiply this here.

[00:12:03] So after all this, we have more or less now here the number as an integer for milliseconds.

[00:12:10] So how do we get this number now to modulate actually here something on the release?

[00:12:16] Yeah.

[00:12:17] No.

[00:12:18] So how do we get from there?

[00:12:20] To this.

[00:12:22] And my idea was to actually see.

[00:12:26] So we start here with zero milliseconds and maximum value is 2.20 seconds.

[00:12:35] So what we can do is we can use a constant here and type in the maximum number, which

[00:12:41] is 20 2200 milliseconds.

[00:12:50] Right.

[00:12:51] This is the maximum number.

[00:12:53] Let's call us here.

[00:12:55] Let's target.

[00:12:58] And then we use again reciprocal because we want to modulate here.

[00:13:04] So when you use a modulator, something like this, right?

[00:13:08] When you modulate here the release time, this value is basically this is zero and this is

[00:13:16] one, right?

[00:13:17] So zero one.

[00:13:18] So we want to bring this integer which is over or exceeds one.

[00:13:23] It's actually 300 here.

[00:13:26] So we want to bring this down between zero and one, right?

[00:13:29] So we use here the max target.

[00:13:32] We use one, which is the maximum value of this modulation amount here and divided by

[00:13:38] this maximum target here, which is 20 2200.

[00:13:45] Okay.

[00:13:48] So then we have to multiply this by the time base here in milliseconds.

[00:13:57] So we have to also rename this here.

[00:14:00] I'm based in milliseconds.

[00:14:03] Okay.

[00:14:04] So then we get actually check this here.

[00:14:12] Then we get here the target.

[00:14:18] So this is basically here the number or the material modulation value that you need to

[00:14:25] modulate here the release time.

[00:14:27] So we can go in here and just modulate this, right?

[00:14:30] So you can see here it modulates just a tiny bit.

[00:14:36] And if we change the BPM setting, you can see how the modulation goes down, right?

[00:14:43] So of course, if you have a low low BPM, the distance between the beats or the distance

[00:14:48] between the kick drum and the snare drum is bigger.

[00:14:50] So we need to along our release time.

[00:14:53] So it kind of works.

[00:14:55] But now there's a different problem.

[00:14:58] The release time is actually not linear.

[00:15:00] So this is linear here, right?

[00:15:02] So we can click on this and you can hover over here and you can see down here in the info

[00:15:08] bar, right?

[00:15:09] In the info box, I don't know how it's called.

[00:15:11] You can actually see the modulated value there.

[00:15:14] The release time is actually on 0.0 milliseconds and the modulated value is 2 milliseconds,

[00:15:24] which is probably not right because we need to have 200 milliseconds here, right?

[00:15:34] So the problem here is that this is actually locker rhythmic.

[00:15:38] So we go onto this modulator here and switch this from linear to locker rhythmic.

[00:15:45] So I can see the modulation value jumps up here.

[00:15:47] So now when we hover over this, you can see the release time is now 230 milliseconds.

[00:15:55] Maybe I have to put in something like a lag on there, maybe not lag, maybe a low pass or

[00:16:03] maybe if I bring down here this value, then it's probably, yeah, it's not jittering that

[00:16:15] much anymore.

[00:16:16] Okay, so you can see now either value a bit clearer.

[00:16:22] That's to, yeah, we have to keep it this way.

[00:16:30] Yeah, okay, that's how it works.

[00:16:37] So now you can see down here, basically, we have the right millisecond value down there

[00:16:42] as a modulation target as here, right?

[00:16:45] So this is time-based MS and then it's modulated or mapped to the release time here to the

[00:16:51] right milliseconds.

[00:16:53] And this works great on Compressor Plus because it actually starts with zero milliseconds.

[00:16:59] If you use the old compressor here, it's a bit harder because you have to introduce maybe

[00:17:06] an offset because it only goes down to 38 milliseconds.

[00:17:11] That's where it starts and goes up to 1.41 seconds for some reason.

[00:17:18] So you have to account for that.

[00:17:20] You have to bring in a bias and play around with offsets and so on.

[00:17:26] But anyway, it just won't give you an example how you can do something like this in the

[00:17:30] grid here.

[00:17:31] And it's a, you know, it's a happy, hacky approach.

[00:17:34] It's not something like I said, it's not practical.

[00:17:37] It's not something you want to do, but you can do it.

[00:17:40] So you can work around a lot of things inside of the grid, even though it's a bit hacky.

[00:17:45] And sometimes it's fun.

[00:17:46] It's a challenge to do this kind of stuff, right?

[00:17:50] And like in this example here, it kind of works.

[00:17:54] So now you can change your basically the BPM.

[00:17:56] You can see the release time is changing.

[00:18:01] Oh, I can't go down here.

[00:18:06] Maybe you have to bring up the, yeah, you have to go up here with the higher setting.

[00:18:11] So it's maybe I go down to lower value.

[00:18:18] So you have to find a sweet spot here for the constant for your BPMs because the zero

[00:18:26] crossings module only works in a certain range very well.

[00:18:30] It's not like, you know, it's a perfect module.

[00:18:34] It's, yeah, it's a bit hacky, but you can see it kind of works.

[00:18:38] We can change release time here with the BPM.

[00:18:41] And we can also set in here, let's say 160 node, one fourth node, right?

[00:18:50] Maybe one bar.

[00:18:52] So you can accordingly change this here.

[00:18:55] This is not right.

[00:18:56] 32.

[00:18:57] We actually have to go up here with this.

[00:19:01] So yeah, you can do time-based things inside of the grid.

[00:19:05] You can calculate it on the fly based on the BPM using here the transport and then extracting

[00:19:11] this ramp value and convert it into a sound and then measure the sound of the zero crossings,

[00:19:17] get the pitch from it, convert the pitch to Hertz and then calculate with Hertz and, you

[00:19:22] know, get the milliseconds from that for 160 node, one eighth node and so on.

[00:19:28] So it's possible.

[00:19:29] You can do it in the grid.

[00:19:31] It's a, it's a hacky way.

[00:19:33] And it works.

[00:19:34] And I found it the fun way of doing this kind of challenge inside of the grid.

[00:19:40] And I want to show it to you.

[00:19:42] Like I said, it's not a practical approach.

[00:19:45] Not something I want to do.

[00:19:49] And to show you that this kind of works, I have also on my, on my website here, I have

[00:19:57] here, let's say, got the search F made a while ago, some kind of BPM to millisecond calculator

[00:20:05] here in JavaScript.

[00:20:06] So we have one and 63 BPM and we have for one eighth node, we have 184 milliseconds.

[00:20:19] So this is one eighth node here.

[00:20:20] You can see we have 185 milliseconds.

[00:20:24] So it's roughly it matches 160 node is 92.

[00:20:32] Mm.

[00:20:34] 160 node is 92.

[00:20:36] Yeah.

[00:20:37] So it's, so it's, it's roughly the same.

[00:20:39] So it kind of matches.

[00:20:40] So we can do this stuff inside of the grid with the zero crossings.

[00:20:44] It kind of works.

[00:20:46] It's maybe a few milliseconds off, but it's not a big problem in my opinion.

[00:20:51] It'd be great to have actually here a time based release unit or for the release time

[00:20:57] a unit, you know, 160 node, one fourth node and so on, or maybe the auto timing showing

[00:21:02] the correct result of the calculations would be nice to have in my opinion.

[00:21:10] So let me know what you think in the comments down below.

[00:21:12] If you have some questions, of course, also leave a like, leave a subscription and also

[00:21:17] put this preset here down in the scripture for, for free so you can download it and have

[00:21:22] some fun with it.

[00:21:23] Okay.

[00:21:24] Thanks for watching and I'll see you in the next video.

[00:21:26] Bye.

[00:21:26] [BLANK_AUDIO]