A new 'curve' gadget using the canvas gadget (V14 available)

Share your advanced PureBasic knowledge/code with the community.
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: A new 'curve' gadget using the canvas gadget (V12 availa

Post by infratec »

Hi,

readded Danilos #CurveGadget_MinPointSpacing as #CurveGadget_MinXSpacing.
So it is V12 now :cry:
V11 was nicer, since it reminds me on a Moto Guzzi :mrgreen: :mrgreen: :mrgreen:

It was never planned to reach this version number.
But things get there own life...

Bernd
User avatar
Michael Vogel
Addict
Addict
Posts: 2808
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: A new 'curve' gadget using the canvas gadget (V9 availab

Post by Michael Vogel »

infratec wrote:
Michael Vogel wrote:Nice gadget, even when it won't be fool prove (netmaestros line sculpture can still be done :lol:)
Hi,
I can not reproduce it.
I'm out, so I can't check version 12 now...
...just move three dots on a vertically line, then move one of these points up or down.
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: A new 'curve' gadget using the canvas gadget (V12 availa

Post by infratec »

Hi Michael,

found something:
When I have 3 points on top of each other I can move the middle point over the others.
That's indeed a 'bug'.
I'll try to fix it. Stay tuned.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: A new 'curve' gadget using the canvas gadget (V12 availa

Post by Guimauve »

infratec wrote:It was never planned to reach this version number.
But things get there own life...

Bernd
The solution is very simple, just use a different version numbering system like : "x.y.z"

x --> Major number [Infinite]
y --> Minor number [0-9]
z --> Patch number [0-9]

When z reach 10 raise y by 1 then set z to 0. When y reach 10 raise x by 1 then set y to 0. With this version numbering system the time needed to reach V12 is very long.

Best regards
Guimauve
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: A new 'curve' gadget using the canvas gadget (V13 availa

Post by infratec »

Hi, hi,

I hope I'll never reach my age as version :wink:

I found the bug which Micheal pointed out.
So V13 is online.
doctornash
Enthusiast
Enthusiast
Posts: 130
Joined: Thu Oct 20, 2011 7:22 am

Re: A new 'curve' gadget using the canvas gadget (V13 availa

Post by doctornash »

One of these is the ability to add or remove points. Such an addition would allow more detailed curves instead of simply a sawtooth or square curve
Just one point of clarification: I had originally written the component for my vb-based synthesis apps not as a means of 'drawing in' an audio or LFO waveform, but as a way of imposing an envelope (ADSR) on a waveform in order to:
1. enable sculpting of the waveform amplitude or pitch over time
2. enable shaping of the filter characteristics the waveform is passed through (cutoff, resonance)
But then I found that it was useful/reusable even for more specialized applications like granular synthesis, in which I used it for specifying characteristics like grain size, width of the gaussian envelope on each grain, and grain extract point from source waveform, over time.
For all the uses above, the 5 points were found to be sufficient.
In fact, in order to allow a user to freely draw a cycle (or multiple cycles) of an oscillator waveform, 5 points would not be enough because then yes, one would be limited to fairly simple square or saw shapes. And for precisely that purpose I had created a separate control, shown below, which allowed the user to click anywhere and a segment would appear from the previous point to the newly clicked point (it was not possible for a user to 'double back' a point, ensuring that the waveform kept 'drawing forward'). The waveform created in this way below has about 9 segments. It is great that the new PB curve control lends itself to this type of usage as well, by allowing the user to specify number of points :D :-D
Image
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: A new 'curve' gadget using the canvas gadget (V13 availa

Post by infratec »

Hi,

I found one bug and I also added new functionallities.

The scaling in CurveGadgetSetState() was not done.

CurveGadgetSetState() has now an optional value to retrieve the real points instead of the scaled ones.

Now you can readout y for each x using CurveGadget_GetAttribute(Gadget, #CurveGadget_Y_Value, x)
Also in a scaled version.
To show this, I included this in the demo program.

I put the code now in the first post of this thread.

Bernd
Post Reply