Tags: posts polarity-music Audio-Effects Bitwig PlugData Plugins Sampling Tutorial OpenSource

Building a Dynamic Sampler Plugin in Plugdata - Part2

Tutorial | Sep 15, 2023

In this video, I continued working on my sampler or looping station patch inside Plug Data. I made some improvements to make it more dynamic and turned it into a plugin-like interface. First, I addressed the issue of fixed numbers by using the sample rate module to get the current sample rate of the DAW. This allows the patch to adapt to different sample rates. I also used a dynamic variable for the buffer size by using the send and resize commands. This way, the buffer size can be changed based on the desired length of audio to be recorded. Next, I made the fade out delay time dynamic by subtracting 200 milliseconds from the buffer length. I also added a feedback feature to create a decaying audio signal.

I implemented this by sending the output of the tap reader back into its input with a feedback value controlled by a knob. To improve the overall aesthetics of the patch, I used send and receive modules to organize the wiring and create a cleaner look. I also entered plugin mode to make it appear more like a real plugin interface. Lastly, I addressed the issue of initial values resetting when the patch is reloaded. I used the loadbang module to set specific initial values for the parameters. This ensures that the patch is immediately playable and ready to use upon loading. Overall, I've been enjoying working with Plug Data and exploring new possibilities outside of traditional plugins. I may continue working on this patch in a future video to add more features and make it even more interesting.

You can watch the Video on Youtube - support me on Patreon

More Videos in this Series

Questions & Answers

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

What is the purpose of this video?

The purpose is to expand on a previous video where a sampler or looping station was created using PlugData, a free and open plugin. The goal is to add more features and transform it into a more advanced plugin.

What changes are made to make the patch more dynamic?

To make the patch more dynamic, several changes are made. First, the use of fixed numbers for sample rate and buffer size is replaced with dynamic values obtained from modules. The "sample rate" module provides the current sample rate of the host, ensuring compatibility across different systems. The buffer size is updated using a "send" module, allowing for the resizing based on user input. The length of the buffer can be changed using a knob interface, making it more user-friendly. Additionally, the fade out delay and feedback values are also made dynamic to adapt to changes in sample rate and buffer size.

Question 3: How is the patch organized and presented as a plugin?

The patch is organized and presented as a plugin by using the Plugin Mode feature in PlugData. The creator uses an "eye symbol" to create a bounded area within the patch, resembling a plugin window. All the relevant interface modules such as dry level, wet level, and sampler buffer are placed within this window. The patch is cleaned up by using send and receive modules to decouple the interface modules from the main patch, resulting in a more organized and visually appealing layout. Curved connections are also used to improve the overall appearance of the patch.

How are initial values set and how does it affect the patch when reloaded?

Initial values are set using the Load Bang module in PlugData. This module fires a single bang every time the patch is loaded, allowing for the initialization of specific values. In this case, the creator sets initial values for parameters such as length, feedback, and dry level. These values are sent to the respective modules using the message module. When the patch is reloaded, these initial values are automatically applied, ensuring that the patch starts with the desired settings. This enhances the user experience by eliminating the need to manually adjust parameters every time the patch is

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] (gentle music)
[00:00:02] So two videos ago, we created a sampler or a looping station,
[00:00:20] something along those lines inside of PlugData,
[00:00:23] which is a free and open plugin you can use
[00:00:26] and patch your own solutions in there.
[00:00:28] So we created this and if you haven't watched this,
[00:00:31] you can rewatch it, link is in the description of course.
[00:00:34] And this time we want to flash it out,
[00:00:35] we want to add some features
[00:00:37] and almost turn it into some kind of plugin.
[00:00:41] So this is where we left off in the last video.
[00:00:44] We have one instrument channel here with the piano on there.
[00:00:47] We can play the piano.
[00:00:48] (piano music)
[00:00:51] Then our patch samples the piano in here in this buffer
[00:00:56] and place the buffer in reverse.
[00:00:58] So it's a nice audio effect.
[00:01:00] (piano music)
[00:01:03] But it's not perfect.
[00:01:05] There's a lot of stuff we can tweak in here
[00:01:08] to make this even better.
[00:01:09] So the first thing we want to change is the sample rate.
[00:01:12] We use the sample rate here in this patch already
[00:01:15] with some fixed numbers.
[00:01:17] So we typed in here basically for the V line,
[00:01:20] please start at 96,000, which is the end of the array
[00:01:24] and the array itself is also fixed here with 96,000 in size.
[00:01:28] So it's all fixed numbers and all these numbers can change.
[00:01:34] So when you send this patch over to your friend
[00:01:37] uses a different sample rate
[00:01:39] and nothing makes sense anymore.
[00:01:41] So we have to keep this dynamic.
[00:01:43] So instead of using here 96,000,
[00:01:46] we use a module called sample rate,
[00:01:50] which gives us the current sample rate of the DAW,
[00:01:53] of the host as a number.
[00:01:56] In my case here, it's 48,000, right?
[00:02:00] So we get this number from this module here.
[00:02:03] And if you send this over to your friend
[00:02:04] uses a different sample rate
[00:02:06] and this one gives back a different sample rate.
[00:02:09] So this is the idea behind it.
[00:02:11] Then we use a number here
[00:02:13] because we need to multiply the sample rate
[00:02:15] with a multiplication.
[00:02:17] Sample rate goes in here, this number goes in here.
[00:02:21] So now we can use basically the result of this
[00:02:24] for multiple places.
[00:02:26] And the first place we want to change this number
[00:02:28] is here the sample itself, which is the array
[00:02:31] or the array buffer.
[00:02:33] And this one has a fixed size of 96,000,
[00:02:35] which is basically the sample rate times two
[00:02:37] because we want to save two seconds of data.
[00:02:42] To change the size of the array,
[00:02:46] you have to use a module called send
[00:02:48] or the shortcut, which is just S.
[00:02:51] And then the name of the array, which is sampler.
[00:02:53] You can see this here, right?
[00:02:55] So we can send something to the sampler or to the array.
[00:03:00] And in this case, we send a message.
[00:03:02] And the message contains a command, which is called resize.
[00:03:08] And instead of using a fixed number again,
[00:03:11] we use a variable dollar sign one.
[00:03:14] And we replace or exchange this dollar sign one here
[00:03:19] with the input check.
[00:03:20] So the number from the multiplication here on top, right?
[00:03:24] So whatever comes out of this here gets replaced in this.
[00:03:28] Then we compile basically our command
[00:03:30] and this command is sent over to the sampler.
[00:03:32] And then the sampler is resizing the buffer size basically.
[00:03:37] All we have to do now is to use here a bang,
[00:03:40] connect this here to the sample rate,
[00:03:44] then change here maybe this to four,
[00:03:47] hit bang and you can see we have a different size here.
[00:03:49] You go back to one, see it's different size.
[00:03:53] So we can change the sample or the buffer size
[00:03:58] basically based on this number.
[00:04:01] And this number represents the seconds of data
[00:04:04] or seconds of audio we want to record.
[00:04:06] So we can change this here and can say,
[00:04:08] I want to save 11 seconds of audio, right?
[00:04:12] Then you bang it.
[00:04:13] And then this buffer size changes to the right number
[00:04:17] based on the sample rate.
[00:04:18] Okay, we can now use the result of this operation here
[00:04:22] also for the V line.
[00:04:23] The V line creates some kind of phase signal
[00:04:26] to move the pointer from the end of the array
[00:04:28] to the beginning of the array.
[00:04:30] The beginning of the array is always zero
[00:04:32] and the end of the array changes
[00:04:35] dependent on the sampling rate and also on the timeframe.
[00:04:39] Also the timeframe here is 2000 milliseconds
[00:04:42] which also change when you change the length right here.
[00:04:46] So we have to make this also dynamic.
[00:04:49] So I'm using your message.
[00:04:51] So I'm creating a new message here.
[00:04:53] And instead of typing in fixed numbers,
[00:04:56] I use dollar sign one.
[00:04:57] Then I use the beginning of the array, which is always zero.
[00:05:02] And then the timeframe is dollar sign two.
[00:05:05] So we need to replace basically a dollar sign one
[00:05:09] and dollar sign two.
[00:05:10] Dollar sign one is basically the result of this.
[00:05:14] So we could connect this,
[00:05:16] but we need also to connect your dollar sign two.
[00:05:19] And dollar sign two is basically this number here
[00:05:22] multiplied by 1000 to get milliseconds instead of seconds.
[00:05:27] And then we need to use another module called pack
[00:05:34] which packs up two floats as an input.
[00:05:38] So float one, float two, you can also use your,
[00:05:41] if you want to do more, I can use three of course
[00:05:43] and you have three input checks, right?
[00:05:46] That's how it works, but we only need two.
[00:05:49] So we pack float one and float two into one signal
[00:05:54] and connect the signal with that.
[00:05:55] And then we can use instead of this message,
[00:05:58] we can use this message which is now dynamic.
[00:06:03] And instead of triggering this here, we are mouse click,
[00:06:06] we use here the output of this
[00:06:07] and trigger this all the time, right?
[00:06:09] So we get on each trigger,
[00:06:12] we get the right sampling rate,
[00:06:14] we get also here a different buffer size, right?
[00:06:18] This changes then accordingly.
[00:06:20] Then we also have the right V line or the face signal
[00:06:25] from the right end position to the right start position
[00:06:29] in the right timeframe
[00:06:30] because we update everything here with each click.
[00:06:34] I hope this makes sense.
[00:06:36] So now instead of using fixed numbers,
[00:06:38] we use dynamic numbers that can change from PC to PC
[00:06:42] and also dependent on the seconds for the buffer size.
[00:06:47] Another value we need to change is here
[00:06:49] the delay time of the fade out.
[00:06:51] Maybe you can remember we implemented here fade in
[00:06:54] and a fade out of the audio signal
[00:06:57] to get rid of clicks and pops.
[00:06:59] And of course this value is dependent on the sample rate
[00:07:03] and it's also dependent on the buffer size, right?
[00:07:06] And how many seconds we want to record.
[00:07:09] So we can just get rid here of the fixed number
[00:07:14] and we use the input jack
[00:07:18] and we just subtract 200 milliseconds
[00:07:22] from the milliseconds of the length of our buffer,
[00:07:27] which in this case here, we go back to two, right?
[00:07:30] Two times 1000 is 2000,
[00:07:33] then we subtract 200, which is then 1800.
[00:07:37] So we get our value here.
[00:07:41] So if you want to make the fade in
[00:07:42] and fade out time also dynamic,
[00:07:44] you also have to change, make this your dynamic, right?
[00:07:46] So you have to make these three values basically dynamic.
[00:07:50] But now we get correct fade in and fade out delays here.
[00:07:54] The fade in is always at the beginning
[00:07:56] so you don't need to change something,
[00:07:59] but the fade out here happens at different points in time
[00:08:02] because the array size can change.
[00:08:05] So now we have this also dynamic,
[00:08:07] which is good.
[00:08:08] And because we can change the length of the buffer here
[00:08:11] with this number,
[00:08:12] maybe it's time to implement something like this knob here
[00:08:17] instead of using this number box.
[00:08:20] And this one has a minimum value of 0.1.
[00:08:25] And the maximum number is maybe eight seconds
[00:08:27] or maybe let's say 10 seconds.
[00:08:29] So we can change the buffer size here
[00:08:32] just with this nice interface knob.
[00:08:34] What we also have to change is here
[00:08:37] the metronome as you can see,
[00:08:38] the metronome basically triggers or retriggers
[00:08:41] the playback of this buffer every two seconds.
[00:08:46] But because we change here the size or the length
[00:08:50] of the buffer size with this,
[00:08:51] we also have to change the distance between the banks.
[00:08:55] So we use the output here of this as the input of that.
[00:08:58] And when we change here, the number,
[00:09:00] you can see the metronome basically changes
[00:09:03] or retriggers more often when the buffer is smaller.
[00:09:06] Which is exactly what we want.
[00:09:11] So let's try this out.
[00:09:13] (upbeat music)
[00:09:16] And the problem now is that the buffer is always
[00:09:30] with the next iteration completely empty.
[00:09:33] So in my opinion, there should be at least some kind
[00:09:36] of feedback line in there.
[00:09:40] And we can implement this pretty easy here.
[00:09:42] Maybe I'll move this here a bit to the side.
[00:09:44] Let's move it over here.
[00:09:46] So we use the output of the tap reader here
[00:09:50] and feed it back into the input with the tap reader.
[00:09:53] So we have a slowly decaying audio signal.
[00:09:58] So let's try this out.
[00:09:59] I probably need to use your multiplication.
[00:10:04] And we get you another knob,
[00:10:09] which is the feedback value.
[00:10:14] So maximum number is one.
[00:10:16] Maybe go to 0.9 or something like this.
[00:10:20] And then we use the output here of the tap reader.
[00:10:27] Go back into the tap reader itself, right?
[00:10:32] So let's try this out here with a,
[00:10:34] some kind of feedback value.
[00:10:36] It's almost like an echo or it is actually an echo.
[00:11:00] When this case, the echo is playing everything in reverse,
[00:11:11] which I like.
[00:11:11] So now comes the interesting part.
[00:11:15] We have a lot of weird wires inside here.
[00:11:19] And we want to make this a bit more pleasing to the eyes.
[00:11:22] So the first thing I want to do is to go down here
[00:11:26] and use this small little eye symbol.
[00:11:30] And it implements here,
[00:11:31] or at least you can see here some kind of dashed line
[00:11:35] in the background, right?
[00:11:36] And this is our, yeah, let's say plugin window.
[00:11:41] So let's move everything outside of this window.
[00:11:44] So we don't have anything in there.
[00:11:46] So what we can do now is to put everything in there
[00:11:49] we want to have to show to the user,
[00:11:51] the dry level here, the vet level,
[00:11:56] maybe the sampler buffer itself.
[00:12:00] Let's put it over here.
[00:12:01] I got a bit longer, something like this.
[00:12:04] Then we have here a feedback, of course.
[00:12:08] Let's put this over there.
[00:12:12] Maybe more space between there.
[00:12:16] Let's put the comment in here.
[00:12:21] This is the feedback.
[00:12:27] What else?
[00:12:31] We have here the length of the sampler.
[00:12:33] We can put this over here.
[00:12:36] Length.
[00:12:44] Okay.
[00:12:51] So we can also right click here,
[00:12:54] properties and then we can change the height
[00:12:57] and the width of this.
[00:12:59] Let's go for,
[00:13:01] for this and,
[00:13:06] like that.
[00:13:09] Maybe a bit more.
[00:13:12] Something like this.
[00:13:15] So now you can use the plugin mode,
[00:13:20] so called plugin mode.
[00:13:21] So you press on the right side at the top here.
[00:13:25] This is a small icon.
[00:13:26] You can say enter plugin mode.
[00:13:28] And now it looks like this.
[00:13:29] Can open it back up with this.
[00:13:33] Maybe disable here.
[00:13:35] All the information boxes
[00:13:39] and then go back into plugin mode.
[00:13:42] And then you have some kind of plugin,
[00:13:45] or at least it looks like a plugin.
[00:13:48] You can change all the,
[00:13:49] so it works and it looks like a real plugin you would use.
[00:14:11] You can also save this now here as a preset and reload it.
[00:14:15] And you have it in the same.
[00:14:17] Yeah, it looks like the same basically.
[00:14:20] Back in here,
[00:14:24] all these cables across the patch doesn't look that great.
[00:14:29] So what we can do about this is to use send
[00:14:32] and receive modules, which I like a lot.
[00:14:35] It works kind of like modulator outs in the grid.
[00:14:39] So you say, for instance,
[00:14:42] you send and call this sample.
[00:14:47] Length, for instance, right?
[00:14:50] This is some kind of ID you can use.
[00:14:55] You go into that and then you say receive sample length.
[00:15:00] And you get the data you sent in here.
[00:15:03] You get out of this box or out of this output jack, right?
[00:15:07] So you can delete this here and go into there
[00:15:12] and can save some kind of wiring with that.
[00:15:16] Let's see, so we have also got a dry level.
[00:15:21] Send volume dry.
[00:15:27] Dry level goes in here,
[00:15:36] then receive dry and we go in there.
[00:15:45] Now we can delete these two.
[00:15:47] So it becomes a bit more, you know,
[00:15:52] can clean it up a bit more.
[00:15:54] This is mogul wet.
[00:16:01] Go in there.
[00:16:04] And this is receive.
[00:16:10] It's much more pleasing now and it's, you know,
[00:16:21] in my opinion, it's cleaner.
[00:16:24] This is the feedback here.
[00:16:28] Let's keep it short.
[00:16:33] Yeah, nice.
[00:16:51] So it works exactly the same,
[00:16:53] but now we have basically all these interface modules
[00:16:56] decoupled from the rest of the patch.
[00:17:00] Just nice to have.
[00:17:02] You can also right click here on these cables
[00:17:05] and can say curved connection,
[00:17:08] then you get something like this.
[00:17:09] We can organize, you know, the wires a bit better.
[00:17:15] Maybe it's not that better, but you can do it at least.
[00:17:22] Okay, you can also use the output in here, of course,
[00:17:26] send here, maybe this to here, say send.
[00:17:31] V line.
[00:17:35] Receive,
[00:17:39] V line.
[00:17:41] Put this over here.
[00:17:43] And delete that so it's a bit cleaner.
[00:17:47] Nice.
[00:17:50] Let's look into plug-in mode here.
[00:17:53] Looks still the same.
[00:17:55] Okay, nice.
[00:18:11] So there's one problem we have to tackle with this patch.
[00:18:15] And let's imagine you have your dial in all the stuff.
[00:18:20] Everything works.
[00:18:21] You save this patch.
[00:18:25] Close it, right click here on the container,
[00:18:27] say save preset to library,
[00:18:29] and then it says tutorial, plug data sampler.
[00:18:32] You choose the category audio FX, right?
[00:18:34] You save it.
[00:18:35] And then you delete here the plug-in and you recall it.
[00:18:41] And then, well, let's actually go into plug-in mode before.
[00:18:47] Right click, save.
[00:18:49] Save.
[00:18:52] And now you reload it and all the values in here,
[00:18:55] as you can see, try that level of feedback length
[00:18:59] and so on, everything is at zero.
[00:19:00] So there are no real initial values.
[00:19:03] Also, the sampler doesn't play or doesn't record at all.
[00:19:08] You have to go into the patch here
[00:19:10] and you have to press playback here actually
[00:19:13] to start the sampler.
[00:19:14] So this is not really nice.
[00:19:16] So what we do with this is we use a module called load bang.
[00:19:22] And load bang only fires one bang
[00:19:25] every time you load the patch.
[00:19:28] So we can use this to actually start the playback.
[00:19:31] We can use this to create here a new message.
[00:19:36] Yeah, message.
[00:19:37] Let's say we use here five.
[00:19:40] So five is the number we want to have for the length.
[00:19:44] For the beginning, this is a value between zero.one and 10.
[00:19:48] So we use five here for the length, right?
[00:19:51] We can maybe also use, this is between zero and one.
[00:19:55] So we use here 0.3 maybe for the feedback, right?
[00:20:01] And the try level here is,
[00:20:07] yeah, let's say also 0.5.
[00:20:18] Okay, so we go back here into plugin mode
[00:20:22] or actually save the patch, plugin mode,
[00:20:26] save, preset the library.
[00:20:30] And then we load here the sampler back in
[00:20:36] and you can see we have now here
[00:20:38] nice initial values for everything.
[00:20:41] And also the sample is already recording and playing.
[00:20:46] So that's kind of it for this video so far.
[00:20:55] Maybe I make a third video on this plugin or on this patch
[00:20:58] and we implement even more features
[00:21:01] and make it more interesting.
[00:21:02] At the moment it's just a looper playing stuff backwards
[00:21:05] so it's not really interesting.
[00:21:08] But I really enjoy actually tinkering around
[00:21:11] with plug data at the moment,
[00:21:12] getting out of the Bitwig world,
[00:21:14] getting out of all the plugins that,
[00:21:17] coming out at the moment.
[00:21:18] I'm not really interested in that.
[00:21:21] It's kind of all the same stuff.
[00:21:23] So getting into plug data,
[00:21:25] tinkering around, learning something new.
[00:21:27] It's really interesting for me, I am enjoying it.
[00:21:30] So if you liked the video, please like the video, of course.
[00:21:35] Subscribe to the channel, ask me questions if you have one
[00:21:39] or maybe if you find some errors in this video, let me know.
[00:21:43] Okay.
[00:21:45] The preset or the patch is in the description below.
[00:21:48] You can just download it, play around with it, have a go.
[00:21:52] And yeah, that's it.
[00:21:54] Thanks for watching the video.
[00:21:56] See you next time, bye.
[00:21:57] (