Csound Csound-dev Csound-tekno Search About

[Csnd-dev] New GEN routine and new Opcode

Date2016-08-17 00:35
FromGuillermo Senna
Subject[Csnd-dev] New GEN routine and new Opcode
Attachmentsgetftargs.c  quadbezier.c  

Hi,

I've been developing a new GEN routine called "quadbezier" for creating Quadratic Bézier curves. It works fine as long as you treat it like a regular function. This means that, for example, you won't be able to create a circle and store it inside an f-table.

I think it can be useful to developers that use Csound along with a frontend. We've been working with Rory in the implementation for Cabbage. I thought it would be nice to be able to create audio and control envelopes just with the mouse.

The syntax for a quadbezier is:

f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]

where x and y are the coordinates for the line-to points and cx and cy are the coordinates for the control points.


    

It is assumed that x1 equals 0 and that x[n] can't never be equal or greater than x[n+1]. On the other hand, cx[n] can be equal to x[n] or x[n+1].

Here's a .gif from Cabbage -> https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/view?usp=sharing


Because the frontend might create this on the fly, the user may not be able to save the arguments used to create the f-table from inside Csound code. So I thought of a new Opcode that solves that. It is called "getftargs" and it should fill an S-variable with the arguments used to create the function table.

Its syntax is:

Sdst getftargs iftno, ktrig

Where Sdst is the S-variable to be filled with the arguments used to create the table. iftno represents the table number and ktrig should behave like in the puts Opcode.

I've used a lot of inspiration (and code) from other Opcodes and I promise to include all the copyright notices in the final/commented version!

I need the help of all the experienced coders to review the code, tell me how can it be improved and give me all the feedback you can. Also, can this be included in 6.08? Because otherwise Cabbage users will need to install our own cook of Csound in order to enjoy this new feature.

Thank you all, very much!



Date2016-08-17 10:28
FromRory Walsh
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Just want to say that Guillermo's new bezier tools are not yet available in the release build of Cabbage but will be soon. I really like the getftargs opcode. It makes saving and reloading modified tables super easy.   

On 17 August 2016 at 00:35, Guillermo Senna <gsenna@gmail.com> wrote:

Hi,

I've been developing a new GEN routine called "quadbezier" for creating Quadratic Bézier curves. It works fine as long as you treat it like a regular function. This means that, for example, you won't be able to create a circle and store it inside an f-table.

I think it can be useful to developers that use Csound along with a frontend. We've been working with Rory in the implementation for Cabbage. I thought it would be nice to be able to create audio and control envelopes just with the mouse.

The syntax for a quadbezier is:

f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]

where x and y are the coordinates for the line-to points and cx and cy are the coordinates for the control points.


    

It is assumed that x1 equals 0 and that x[n] can't never be equal or greater than x[n+1]. On the other hand, cx[n] can be equal to x[n] or x[n+1].

Here's a .gif from Cabbage -> https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/view?usp=sharing


Because the frontend might create this on the fly, the user may not be able to save the arguments used to create the f-table from inside Csound code. So I thought of a new Opcode that solves that. It is called "getftargs" and it should fill an S-variable with the arguments used to create the function table.

Its syntax is:

Sdst getftargs iftno, ktrig

Where Sdst is the S-variable to be filled with the arguments used to create the table. iftno represents the table number and ktrig should behave like in the puts Opcode.

I've used a lot of inspiration (and code) from other Opcodes and I promise to include all the copyright notices in the final/commented version!

I need the help of all the experienced coders to review the code, tell me how can it be improved and give me all the feedback you can. Also, can this be included in 6.08? Because otherwise Cabbage users will need to install our own cook of Csound in order to enjoy this new feature.

Thank you all, very much!




Date2016-08-17 11:25
Fromjpff
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Is the suggestn that they are incorporated into the main code-base? 
Wouldned manual pages as well.  Myself I have nt looked at them yet.

On Wed, 17 Aug 2016, Rory Walsh wrote:

> Just want to say that Guillermo's new bezier tools are not yet available in
> the release build of Cabbage but will be soon. I really like the getftargs
> opcode. It makes saving and reloading modified tables super easy.   
> 
> On 17 August 2016 at 00:35, Guillermo Senna  wrote:
>
>       Hi,
>
>       I've been developing a new GEN routine called "quadbezier" for
>       creating Quadratic Bézier curves. It works fine as long as you
>       treat it like a regular function. This means that, for example,
>       you won't be able to create a circle and store it inside an
>       f-table.
>
>       I think it can be useful to developers that use Csound along
>       with a frontend. We've been working with Rory in the
>       implementation for Cabbage. I thought it would be nice to be
>       able to create audio and control envelopes just with the mouse.
>
>       The syntax for a quadbezier is:
> 
> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
>
>       where x and y are the coordinates for the line-to points and cx
>       and cy are the coordinates for the control points.
>
>       It is assumed that x1 equals 0 and that x[n] can't never be
>       equal or greater than x[n+1]. On the other hand, cx[n] can be
>       equal to x[n] or x[n+1].
>
>       Here's a .gif from Cabbage ->https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/view?usp=shari
>       ng
> 
>
>       Because the frontend might create this on the fly, the user may
>       not be able to save the arguments used to create the f-table
>       from inside Csound code. So I thought of a new Opcode that
>       solves that. It is called "getftargs" and it should fill an
>       S-variable with the arguments used to create the function table.
>
>       Its syntax is:
> 
> Sdst getftargs iftno, ktrig
>
>       Where Sdst is the S-variable to be filled with the arguments
>       used to create the table. iftno represents the table number and
>       ktrig should behave like in the puts Opcode.
>
>       I've used a lot of inspiration (and code) from other Opcodes and
>       I promise to include all the copyright notices in the
>       final/commented version!
>
>       I need the help of all the experienced coders to review the
>       code, tell me how can it be improved and give me all the
>       feedback you can. Also, can this be included in 6.08? Because
>       otherwise Cabbage users will need to install our own cook of
>       Csound in order to enjoy this new feature.
>
>       Thank you all, very much!
> 
> 
> 
> 
>

Date2016-08-18 01:52
FromGuillermo Senna
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Well, would you think they could be useful to other people as much as to
incorporate them in the main code-base? If not I suppose we could
distribute the .so and .dll along with Cabbage. I guess one can always
use "--opcode-lib" as a command-line argument to use these new features.

In any case, I have no problem with writing the manual pages. The Readme
in the github repo seems to explain how to do it.

Thanks John.


On 17/08/16 07:25, jpff wrote:
> Is the suggestn that they are incorporated into the main code-base?
> Wouldned manual pages as well.  Myself I have nt looked at them yet.
>
> On Wed, 17 Aug 2016, Rory Walsh wrote:
>
>> Just want to say that Guillermo's new bezier tools are not yet
>> available in
>> the release build of Cabbage but will be soon. I really like the
>> getftargs
>> opcode. It makes saving and reloading modified tables super easy.   
>>
>> On 17 August 2016 at 00:35, Guillermo Senna  wrote:
>>
>>       Hi,
>>
>>       I've been developing a new GEN routine called "quadbezier" for
>>       creating Quadratic Bézier curves. It works fine as long as you
>>       treat it like a regular function. This means that, for example,
>>       you won't be able to create a circle and store it inside an
>>       f-table.
>>
>>       I think it can be useful to developers that use Csound along
>>       with a frontend. We've been working with Rory in the
>>       implementation for Cabbage. I thought it would be nice to be
>>       able to create audio and control envelopes just with the mouse.
>>
>>       The syntax for a quadbezier is:
>>
>> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
>>
>>       where x and y are the coordinates for the line-to points and cx
>>       and cy are the coordinates for the control points.
>>
>>       It is assumed that x1 equals 0 and that x[n] can't never be
>>       equal or greater than x[n+1]. On the other hand, cx[n] can be
>>       equal to x[n] or x[n+1].
>>
>>       Here's a .gif from Cabbage
>> ->https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/view?usp=shari
>>       ng
>>
>>
>>       Because the frontend might create this on the fly, the user may
>>       not be able to save the arguments used to create the f-table
>>       from inside Csound code. So I thought of a new Opcode that
>>       solves that. It is called "getftargs" and it should fill an
>>       S-variable with the arguments used to create the function table.
>>
>>       Its syntax is:
>>
>> Sdst getftargs iftno, ktrig
>>
>>       Where Sdst is the S-variable to be filled with the arguments
>>       used to create the table. iftno represents the table number and
>>       ktrig should behave like in the puts Opcode.
>>
>>       I've used a lot of inspiration (and code) from other Opcodes and
>>       I promise to include all the copyright notices in the
>>       final/commented version!
>>
>>       I need the help of all the experienced coders to review the
>>       code, tell me how can it be improved and give me all the
>>       feedback you can. Also, can this be included in 6.08? Because
>>       otherwise Cabbage users will need to install our own cook of
>>       Csound in order to enjoy this new feature.
>>
>>       Thank you all, very much!
>>
>>
>>
>>

Date2016-08-18 08:28
FromTarmo Johannes
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Hi,

this seems a very useful opcode, please include tht in main Csound!
I keep in plan to integrate similar functionality also to CsoundQt.

Thank you, Guillermo!

tarmo

2016-08-18 3:52 GMT+03:00 Guillermo Senna <gsenna@gmail.com>:
Well, would you think they could be useful to other people as much as to
incorporate them in the main code-base? If not I suppose we could
distribute the .so and .dll along with Cabbage. I guess one can always
use "--opcode-lib" as a command-line argument to use these new features.

In any case, I have no problem with writing the manual pages. The Readme
in the github repo seems to explain how to do it.

Thanks John.


On 17/08/16 07:25, jpff wrote:
> Is the suggestn that they are incorporated into the main code-base?
> Wouldned manual pages as well.  Myself I have nt looked at them yet.
>
> On Wed, 17 Aug 2016, Rory Walsh wrote:
>
>> Just want to say that Guillermo's new bezier tools are not yet
>> available in
>> the release build of Cabbage but will be soon. I really like the
>> getftargs
>> opcode. It makes saving and reloading modified tables super easy.
>>
>> On 17 August 2016 at 00:35, Guillermo Senna <gsenna@gmail.com> wrote:
>>
>>       Hi,
>>
>>       I've been developing a new GEN routine called "quadbezier" for
>>       creating Quadratic Bézier curves. It works fine as long as you
>>       treat it like a regular function. This means that, for example,
>>       you won't be able to create a circle and store it inside an
>>       f-table.
>>
>>       I think it can be useful to developers that use Csound along
>>       with a frontend. We've been working with Rory in the
>>       implementation for Cabbage. I thought it would be nice to be
>>       able to create audio and control envelopes just with the mouse.
>>
>>       The syntax for a quadbezier is:
>>
>> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
>>
>>       where x and y are the coordinates for the line-to points and cx
>>       and cy are the coordinates for the control points.
>>
>>       It is assumed that x1 equals 0 and that x[n] can't never be
>>       equal or greater than x[n+1]. On the other hand, cx[n] can be
>>       equal to x[n] or x[n+1].
>>
>>       Here's a .gif from Cabbage
>> ->https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/view?usp=shari
>>       ng
>>
>>
>>       Because the frontend might create this on the fly, the user may
>>       not be able to save the arguments used to create the f-table
>>       from inside Csound code. So I thought of a new Opcode that
>>       solves that. It is called "getftargs" and it should fill an
>>       S-variable with the arguments used to create the function table.
>>
>>       Its syntax is:
>>
>> Sdst getftargs iftno, ktrig
>>
>>       Where Sdst is the S-variable to be filled with the arguments
>>       used to create the table. iftno represents the table number and
>>       ktrig should behave like in the puts Opcode.
>>
>>       I've used a lot of inspiration (and code) from other Opcodes and
>>       I promise to include all the copyright notices in the
>>       final/commented version!
>>
>>       I need the help of all the experienced coders to review the
>>       code, tell me how can it be improved and give me all the
>>       feedback you can. Also, can this be included in 6.08? Because
>>       otherwise Cabbage users will need to install our own cook of
>>       Csound in order to enjoy this new feature.
>>
>>       Thank you all, very much!
>>
>>
>>
>>
>>


Date2016-08-18 10:17
Fromjpff
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
I have added quadbezier to the system (must addcopyright notice...)
I have issues with getftargs wich I need to fix efore it can be added.

==John ff

On Tue, 16 Aug 2016, Guillermo Senna wrote:

> 
> Hi,
> 
> I've been developing a new GEN routine called "quadbezier" for creating
> Quadratic Bézier curves. It works fine as long as you treat it like a regular
> function. This means that, for example, you won't be able to create a circle
> and store it inside an f-table.
> 
> I think it can be useful to developers that use Csound along with a frontend.
> We've been working with Rory in the implementation for Cabbage. I thought it
> would be nice to be able to create audio and control envelopes just with the
> mouse.
> 
> The syntax for a quadbezier is:
> 
> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
> 
> where x and y are the coordinates for the line-to points and cx and cy are the
> coordinates for the control points.
>
etc

Date2016-08-18 21:28
FromGuillermo Senna
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Sure, let me know if you need something when you implement it in
CsoundQt. Although I must say I didn't have to do much in Cabbage
because building upon Rory's work was not very difficult. All the pieces
kind of were already there.

Cheers.


On 18/08/16 04:28, Tarmo Johannes wrote:
> Hi,
>
> this seems a very useful opcode, please include tht in main Csound!
> I keep in plan to integrate similar functionality also to CsoundQt.
>
> Thank you, Guillermo!
>
> tarmo
>
> 2016-08-18 3:52 GMT+03:00 Guillermo Senna :
>
>> Well, would you think they could be useful to other people as much as to
>> incorporate them in the main code-base? If not I suppose we could
>> distribute the .so and .dll along with Cabbage. I guess one can always
>> use "--opcode-lib" as a command-line argument to use these new features.
>>
>> In any case, I have no problem with writing the manual pages. The Readme
>> in the github repo seems to explain how to do it.
>>
>> Thanks John.
>>
>>
>> On 17/08/16 07:25, jpff wrote:
>>> Is the suggestn that they are incorporated into the main code-base?
>>> Wouldned manual pages as well.  Myself I have nt looked at them yet.
>>>
>>> On Wed, 17 Aug 2016, Rory Walsh wrote:
>>>
>>>> Just want to say that Guillermo's new bezier tools are not yet
>>>> available in
>>>> the release build of Cabbage but will be soon. I really like the
>>>> getftargs
>>>> opcode. It makes saving and reloading modified tables super easy.
>>>>
>>>> On 17 August 2016 at 00:35, Guillermo Senna  wrote:
>>>>
>>>>       Hi,
>>>>
>>>>       I've been developing a new GEN routine called "quadbezier" for
>>>>       creating Quadratic Bézier curves. It works fine as long as you
>>>>       treat it like a regular function. This means that, for example,
>>>>       you won't be able to create a circle and store it inside an
>>>>       f-table.
>>>>
>>>>       I think it can be useful to developers that use Csound along
>>>>       with a frontend. We've been working with Rory in the
>>>>       implementation for Cabbage. I thought it would be nice to be
>>>>       able to create audio and control envelopes just with the mouse.
>>>>
>>>>       The syntax for a quadbezier is:
>>>>
>>>> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
>>>>
>>>>       where x and y are the coordinates for the line-to points and cx
>>>>       and cy are the coordinates for the control points.
>>>>
>>>>       It is assumed that x1 equals 0 and that x[n] can't never be
>>>>       equal or greater than x[n+1]. On the other hand, cx[n] can be
>>>>       equal to x[n] or x[n+1].
>>>>
>>>>       Here's a .gif from Cabbage
>>>> ->https://drive.google.com/file/d/0B3HppEiCAar1ZktnVlNFVEVscTQ/
>> view?usp=shari
>>>>       ng
>>>>
>>>>
>>>>       Because the frontend might create this on the fly, the user may
>>>>       not be able to save the arguments used to create the f-table
>>>>       from inside Csound code. So I thought of a new Opcode that
>>>>       solves that. It is called "getftargs" and it should fill an
>>>>       S-variable with the arguments used to create the function table.
>>>>
>>>>       Its syntax is:
>>>>
>>>> Sdst getftargs iftno, ktrig
>>>>
>>>>       Where Sdst is the S-variable to be filled with the arguments
>>>>       used to create the table. iftno represents the table number and
>>>>       ktrig should behave like in the puts Opcode.
>>>>
>>>>       I've used a lot of inspiration (and code) from other Opcodes and
>>>>       I promise to include all the copyright notices in the
>>>>       final/commented version!
>>>>
>>>>       I need the help of all the experienced coders to review the
>>>>       code, tell me how can it be improved and give me all the
>>>>       feedback you can. Also, can this be included in 6.08? Because
>>>>       otherwise Cabbage users will need to install our own cook of
>>>>       Csound in order to enjoy this new feature.
>>>>
>>>>       Thank you all, very much!
>>>>
>>>>
>>>>
>>>>

Date2016-08-18 21:38
FromGuillermo Senna
SubjectRe: [Csnd-dev] New GEN routine and new Opcode
Thank you very much John! I'll write the copyright notices and the
manual pages next. Then I'll see what to do about that fixed size array.
I took the idea from another Opcode actually. I can't recall which one
it was right now.


On 18/08/16 06:17, jpff wrote:
> I have added quadbezier to the system (must addcopyright notice...)
> I have issues with getftargs wich I need to fix efore it can be added.
>
> ==John ff
>
> On Tue, 16 Aug 2016, Guillermo Senna wrote:
>
>>
>> Hi,
>>
>> I've been developing a new GEN routine called "quadbezier" for creating
>> Quadratic Bézier curves. It works fine as long as you treat it like a
>> regular
>> function. This means that, for example, you won't be able to create a
>> circle
>> and store it inside an f-table.
>>
>> I think it can be useful to developers that use Csound along with a
>> frontend.
>> We've been working with Rory in the implementation for Cabbage. I
>> thought it
>> would be nice to be able to create audio and control envelopes just
>> with the
>> mouse.
>>
>> The syntax for a quadbezier is:
>>
>> f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]
>>
>> where x and y are the coordinates for the line-to points and cx and
>> cy are the
>> coordinates for the control points.
>>

Date2016-08-18 21:58
FromJohn
SubjectRe: [Csnd-dev] New GEN routine and new Opcode

The comments about extending the array are not crucial, just a tidy up.  Look forward to an example to test.

Sent from TypeApp

On 18 Aug 2016, at 21:39, Guillermo Senna <gsenna@GMAIL.COM> wrote:
Thank you very much John! I'll write the copyright notices and the
manual pages next. Then I'll see what to do about that fixed size array.
I took the idea from another Opcode actually. I can't recall which one
it was right now.


On 18/08/16 06:17, jpff wrote:
I have added quadbezier to the system (must addcopyright notice...)
I have issues with getftargs wich I need to fix efore it can be added.

==John ff

On Tue, 16 Aug 2016, Guillermo Senna wrote:


Hi,

I've been developing a ne w GEN routine called "quadbezier" for creating
Quadratic Bézier curves. It works fine as long as you treat it like a
regular
function. This means that, for example, you won't be able to create a
circle
and store it inside an f-table.

I think it can be useful to developers that use Csound along with a
frontend.
We've been working with Rory in the implementation for Cabbage. I
thought it
would be nice to be able to create audio and control envelopes just
with the
mouse.

The syntax for a quadbezier is:

f # time size "quadbezier" y1 cx1 cy1 x2 y2 [cx2 cy2 x3 y3 ...]

where x and y are the coordinates for the line-to points and cx and
cy are the
coordinates for the control points.

etc