Draw method in API

Hi guys, I hope you are well.

I would like to create my own waveforms based on mathematical functions. Is there a way to use the pencil to paint points and do all this from the API?

I hope so, that would be great but I haven’t found this in the API.


You can manipulate samples via the SampleBuffer object.

see reference on github

oh yes thanks i was playing with the SampleBuffer after making this post :blush:

So if I understand correctly can I create any waveform I want? I mean, what is stopping us from creating an fm synth using this approach? (of course, apart from the math knowledge)

@Xavi There are already some tools that are used to build audio waves. You can create any wave, mono or stereo, defining all its points through the API. You just need to experience how to create a concrete point. From there, do the math with iterations in Lua for all the points that will form the audio wave.

Thanks Raul. I tried to use a tool called Custom Wave Generator but couldn’t get it to work, maybe it’s because it’s a 2016 version.

Anyway, I’ve been reading a bit in my spare time about the fourier series, I’d like to make an fm synthesizer. Any advice you can give me?

just look at my Maciulxochitl tool source, it is ugly but you can create any wave you want.

1 Like

You can look at how other built Lua tools work, to determine the limits of the API and Lua. I’m not talking about seeing the code, but about how the tools work. For example, MUC is a tool that comes with a Wave Builder, to build a wide variety of waves. Understand what can and cannot be done.

From there, the most difficult thing is to understand the Renoise API and apply the math (Fourier or other methods).

To begin with, I recommend that you try to build a basic tool that allows you to manipulate only one point in the plane (by modifying its coordinates (height-volume, width-position-time)). If you know how to “move” one point, you’ll know how to move them all by iterating. From there apply your mathematical formulas to create the waves. You will have 2 surfaces in stereo, right channel and left channel, or one surface in mono, left channel, which will be used for both channels.

The guide is clear. Learn Lua, learn the API (how the points of an audio waveform are defined in the Renoise sampler), and then apply the math to plot different points, understanding start and end limits.

One last tip. Never copy code from another programmer. This will help you improve/learn and avoid mistakes. It is always advisable to write it out in full yourself. But you can experiment with third-party code if they give you permission, as long as you fully understand the code used. In other words, never use code that you don’t understand, because you will lose control. On the other hand, trial and error is common to test these things.

Applying the mathematics with Fourier formulas together with the API is not an easy task. There you will see the biggest complications.

First of all sorry for the late reply, I have been busy with work the last few weeks.

Thanks for the tips. I’ve been practicing a bit with the API. I was able to generate a sinewave and change frequencies. I did a bit of additive synthesis too and also read a bit about fm synths and from what I understood, that synthesis can be achieved by adding sinewaves (and other types) to the phase of a sinewave. So that’s what I did. Is it that simple or is there something I don’t understand?

From that I have been thinking of creating a tool that allows us to decompose waveforms into Fourier series… I would like to analyze different instruments (such as guitars) to see if there is any formula to make a guitar with pure code for example hehe

1 Like

Thanks! I will check it out :grin: