Csound Csound-dev Csound-tekno Search About

[Csnd] Debugging a GEN Routine C-Code

Date2024-11-24 10:43
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] Debugging a GEN Routine C-Code
Hello everybody!
I’m diving into GEN routine development to learn some C and for a university class.

Over the past few days, I’ve written a GEN routine based on the Lorenz attractor to generate control data. My C code compiles and runs inside Csound, but I’m confused about the output of the GEN routine.
I’ve implemented a scaling function to map the values in the table to a specified range (e.g., between a minimum and maximum), but the results aren’t as expected. To debug, I’ve added printf statements in the C code to check the intermediate values, and everything seems fine there.

However, when I use ftprint in Csound, the table values don’t match what the C code prints. For example, if I scale the values to the range [3, 10], I end up with values in Csound between 0.3 and 1.0. The scaling logic in the C code seems correct, so I’m unsure why the output is wrong.

Here are some thoughts on what might be causing the issue:
    • Csound might be normalizing the table values to fit within the range [-1, 1], and values outside this range might not be allowed.
    • I could be compiling my GEN routine incorrectly.

Below is my C code and my compile command — maybe there’s an error I’ve overlooked. Any help would be greatly appreciated!
Thank you!
—Philipp

```gcc -shared -o lorenz-gen.dylib -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/ lorenz-gen.c```

```
#include "csdl.h"
#include "csoundCore.h"
/*
  p3 = size
  p4 = GEN routine
  p5 = choose axis to write; 0 = x, 1 = y, 2 = z
  p6 = min output
  p7 = max output
  p8 = stepsize
  p9 = x start
  p10 = y start
  p11 = z start
  f1 0 4096 "lorenz" "x" -1 1 5
 
 */
void scale_array(MYFLT *fp, MYFLT min_out, MYFLT max_out, int32_t size)
{
  MYFLT min_in = fp[0];
  MYFLT max_in = fp[0];
  
  for(int i = 1; i < size; i++){
    if(fp[i] < min_in)
      min_in = fp[i];
    if(fp[i] > max_in)
      max_in = fp[i];
  }

  MYFLT old_value;
  for(int j = 0; j < size; j++){
    old_value = fp[j];
    printf("old value: %f\n", old_value); 
    fp[j] =  min_out + ((old_value - min_in) / (max_in - min_in))
      * (max_out - min_out);
    printf("new value: %f\ns",fp[j]);
    printf("sohuld value: %f\n", (min_out + ((old_value - min_in) / (max_in - min_in))
      * (max_out - min_out))); 
  }
}

static int32_t lorenztable(FGDATA *ff, FUNC *ftp)
{
  /* function table */
  MYFLT *fp = ftp->ftable;
    
  /* default arguments */
  MYFLT sigma = 10;
  MYFLT rho = 28;
  MYFLT beta = 8.0/3.0;
  MYFLT time = 0.001;

  /* p-field arguments */
  int32_t ft_size = ftp->flen;
  MYFLT min_out = ff->e.p[6];
  MYFLT max_out = ff->e.p[7];
  MYFLT step_size = ff->e.p[8];
  MYFLT x = ff->e.p[9];
  MYFLT y = ff->e.p[10];
  MYFLT z = ff->e.p[11];

  /* write raw data to ft */
  for (int i = 0; i < ft_size; i++)
    {    
      if (ff->e.p[5] == 0){
	fp[i] = x;
      } else if (ff->e.p[5] == 1){
	fp[i] = y;
      } else if (ff->e.p[5] == 2){
	fp[i] = z;
      }
      
      for (int j = 0; j < step_size; j++){
	x += (sigma * (y - z)) * time;
	y += (x * (rho - z) - y) * time;
	z += ((x * y) - (beta * z)) * time;
      } 
    }

  /* scale data of ft */
  scale_array(fp, min_out, max_out, ft_size);
 
  return OK;
}

static NGFENS localfgens[] = {
  { "lorenz", lorenztable},
  { NULL, NULL}
};


FLINKAGE_BUILTIN(localfgens)

```
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-11-24 10:52
FromRory Walsh
SubjectRe: [Csnd] Debugging a GEN Routine C-Code
Hi Philip. If you use a negative gen number in your score it will prevent automatic normalisation of your table data. :+1:  

On Sun, 24 Nov 2024 at 10:44, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Hello everybody!
I’m diving into GEN routine development to learn some C and for a university class.

Over the past few days, I’ve written a GEN routine based on the Lorenz attractor to generate control data. My C code compiles and runs inside Csound, but I’m confused about the output of the GEN routine.
I’ve implemented a scaling function to map the values in the table to a specified range (e.g., between a minimum and maximum), but the results aren’t as expected. To debug, I’ve added printf statements in the C code to check the intermediate values, and everything seems fine there.

However, when I use ftprint in Csound, the table values don’t match what the C code prints. For example, if I scale the values to the range [3, 10], I end up with values in Csound between 0.3 and 1.0. The scaling logic in the C code seems correct, so I’m unsure why the output is wrong.

Here are some thoughts on what might be causing the issue:
    • Csound might be normalizing the table values to fit within the range [-1, 1], and values outside this range might not be allowed.
    • I could be compiling my GEN routine incorrectly.

Below is my C code and my compile command — maybe there’s an error I’ve overlooked. Any help would be greatly appreciated!
Thank you!
—Philipp

```gcc -shared -o lorenz-gen.dylib -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/ lorenz-gen.c```

```
#include "csdl.h"
#include "csoundCore.h"
/*
  p3 = size
  p4 = GEN routine
  p5 = choose axis to write; 0 = x, 1 = y, 2 = z
  p6 = min output
  p7 = max output
  p8 = stepsize
  p9 = x start
  p10 = y start
  p11 = z start
  f1 0 4096 "lorenz" "x" -1 1 5

 */
void scale_array(MYFLT *fp, MYFLT min_out, MYFLT max_out, int32_t size)
{
  MYFLT min_in = fp[0];
  MYFLT max_in = fp[0];

  for(int i = 1; i < size; i++){
    if(fp[i] < min_in)
      min_in = fp[i];
    if(fp[i] > max_in)
      max_in = fp[i];
  }

  MYFLT old_value;
  for(int j = 0; j < size; j++){
    old_value = fp[j];
    printf("old value: %f\n", old_value);
    fp[j] =  min_out + ((old_value - min_in) / (max_in - min_in))
      * (max_out - min_out);
    printf("new value: %f\ns",fp[j]);
    printf("sohuld value: %f\n", (min_out + ((old_value - min_in) / (max_in - min_in))
      * (max_out - min_out)));
  }
}

static int32_t lorenztable(FGDATA *ff, FUNC *ftp)
{
  /* function table */
  MYFLT *fp = ftp->ftable;

  /* default arguments */
  MYFLT sigma = 10;
  MYFLT rho = 28;
  MYFLT beta = 8.0/3.0;
  MYFLT time = 0.001;

  /* p-field arguments */
  int32_t ft_size = ftp->flen;
  MYFLT min_out = ff->e.p[6];
  MYFLT max_out = ff->e.p[7];
  MYFLT step_size = ff->e.p[8];
  MYFLT x = ff->e.p[9];
  MYFLT y = ff->e.p[10];
  MYFLT z = ff->e.p[11];

  /* write raw data to ft */
  for (int i = 0; i < ft_size; i++)
    {   
      if (ff->e.p[5] == 0){
        fp[i] = x;
      } else if (ff->e.p[5] == 1){
        fp[i] = y;
      } else if (ff->e.p[5] == 2){
        fp[i] = z;
      }

      for (int j = 0; j < step_size; j++){
        x += (sigma * (y - z)) * time;
        y += (x * (rho - z) - y) * time;
        z += ((x * y) - (beta * z)) * time;
      }
    }

  /* scale data of ft */
  scale_array(fp, min_out, max_out, ft_size);

  return OK;
}

static NGFENS localfgens[] = {
  { "lorenz", lorenztable},
  { NULL, NULL}
};


FLINKAGE_BUILTIN(localfgens)

```
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2024-11-24 10:56
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Debugging a GEN Routine C-Code
Thanks Rory!
But i implemented the GEN routine as GEN“lorenz“ and i call it by the string „lorenz“. How can i use this with a string?
And is this a default method to every GEN routine or must this implemented in the GEN code?

> Am 24.11.2024 um 11:52 schrieb Rory Walsh :
> 
> Hi Philip. If you use a negative gen number in your score it will prevent automatic normalisation of your table data. :+1:  
> 
> On Sun, 24 Nov 2024 at 10:44, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> Hello everybody!
> I’m diving into GEN routine development to learn some C and for a university class.
> 
> Over the past few days, I’ve written a GEN routine based on the Lorenz attractor to generate control data. My C code compiles and runs inside Csound, but I’m confused about the output of the GEN routine.
> I’ve implemented a scaling function to map the values in the table to a specified range (e.g., between a minimum and maximum), but the results aren’t as expected. To debug, I’ve added printf statements in the C code to check the intermediate values, and everything seems fine there.
> 
> However, when I use ftprint in Csound, the table values don’t match what the C code prints. For example, if I scale the values to the range [3, 10], I end up with values in Csound between 0.3 and 1.0. The scaling logic in the C code seems correct, so I’m unsure why the output is wrong.
> 
> Here are some thoughts on what might be causing the issue:
>     • Csound might be normalizing the table values to fit within the range [-1, 1], and values outside this range might not be allowed.
>     • I could be compiling my GEN routine incorrectly.
> 
> Below is my C code and my compile command — maybe there’s an error I’ve overlooked. Any help would be greatly appreciated!
> Thank you!
> —Philipp
> 
> ```gcc -shared -o lorenz-gen.dylib -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/ lorenz-gen.c```
> 
> ```
> #include "csdl.h"
> #include "csoundCore.h"
> /*
>   p3 = size
>   p4 = GEN routine
>   p5 = choose axis to write; 0 = x, 1 = y, 2 = z
>   p6 = min output
>   p7 = max output
>   p8 = stepsize
>   p9 = x start
>   p10 = y start
>   p11 = z start
>   f1 0 4096 "lorenz" "x" -1 1 5
> 
>  */
> void scale_array(MYFLT *fp, MYFLT min_out, MYFLT max_out, int32_t size)
> {
>   MYFLT min_in = fp[0];
>   MYFLT max_in = fp[0];
> 
>   for(int i = 1; i < size; i++){
>     if(fp[i] < min_in)
>       min_in = fp[i];
>     if(fp[i] > max_in)
>       max_in = fp[i];
>   }
> 
>   MYFLT old_value;
>   for(int j = 0; j < size; j++){
>     old_value = fp[j];
>     printf("old value: %f\n", old_value); 
>     fp[j] =  min_out + ((old_value - min_in) / (max_in - min_in))
>       * (max_out - min_out);
>     printf("new value: %f\ns",fp[j]);
>     printf("sohuld value: %f\n", (min_out + ((old_value - min_in) / (max_in - min_in))
>       * (max_out - min_out))); 
>   }
> }
> 
> static int32_t lorenztable(FGDATA *ff, FUNC *ftp)
> {
>   /* function table */
>   MYFLT *fp = ftp->ftable;
> 
>   /* default arguments */
>   MYFLT sigma = 10;
>   MYFLT rho = 28;
>   MYFLT beta = 8.0/3.0;
>   MYFLT time = 0.001;
> 
>   /* p-field arguments */
>   int32_t ft_size = ftp->flen;
>   MYFLT min_out = ff->e.p[6];
>   MYFLT max_out = ff->e.p[7];
>   MYFLT step_size = ff->e.p[8];
>   MYFLT x = ff->e.p[9];
>   MYFLT y = ff->e.p[10];
>   MYFLT z = ff->e.p[11];
> 
>   /* write raw data to ft */
>   for (int i = 0; i < ft_size; i++)
>     {    
>       if (ff->e.p[5] == 0){
>         fp[i] = x;
>       } else if (ff->e.p[5] == 1){
>         fp[i] = y;
>       } else if (ff->e.p[5] == 2){
>         fp[i] = z;
>       }
> 
>       for (int j = 0; j < step_size; j++){
>         x += (sigma * (y - z)) * time;
>         y += (x * (rho - z) - y) * time;
>         z += ((x * y) - (beta * z)) * time;
>       } 
>     }
> 
>   /* scale data of ft */
>   scale_array(fp, min_out, max_out, ft_size);
> 
>   return OK;
> }
> 
> static NGFENS localfgens[] = {
>   { "lorenz", lorenztable},
>   { NULL, NULL}
> };
> 
> 
> FLINKAGE_BUILTIN(localfgens)
> 
> ```
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-11-24 11:07
FromRory Walsh
SubjectRe: [Csnd] Debugging a GEN Routine C-Code
This is default for all gen routines afaik. As to your first question, I'm not sure. Can you simply prepend a -? 

On Sun, 24 Nov 2024 at 10:56, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Thanks Rory!
But i implemented the GEN routine as GEN“lorenz“ and i call it by the string „lorenz“. How can i use this with a string?
And is this a default method to every GEN routine or must this implemented in the GEN code?

> Am 24.11.2024 um 11:52 schrieb Rory Walsh <rorywalsh@EAR.IE>:
>
> Hi Philip. If you use a negative gen number in your score it will prevent automatic normalisation of your table data. :+1: 
>
> On Sun, 24 Nov 2024 at 10:44, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> Hello everybody!
> I’m diving into GEN routine development to learn some C and for a university class.
>
> Over the past few days, I’ve written a GEN routine based on the Lorenz attractor to generate control data. My C code compiles and runs inside Csound, but I’m confused about the output of the GEN routine.
> I’ve implemented a scaling function to map the values in the table to a specified range (e.g., between a minimum and maximum), but the results aren’t as expected. To debug, I’ve added printf statements in the C code to check the intermediate values, and everything seems fine there.
>
> However, when I use ftprint in Csound, the table values don’t match what the C code prints. For example, if I scale the values to the range [3, 10], I end up with values in Csound between 0.3 and 1.0. The scaling logic in the C code seems correct, so I’m unsure why the output is wrong.
>
> Here are some thoughts on what might be causing the issue:
>     • Csound might be normalizing the table values to fit within the range [-1, 1], and values outside this range might not be allowed.
>     • I could be compiling my GEN routine incorrectly.
>
> Below is my C code and my compile command — maybe there’s an error I’ve overlooked. Any help would be greatly appreciated!
> Thank you!
> —Philipp
>
> ```gcc -shared -o lorenz-gen.dylib -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/ lorenz-gen.c```
>
> ```
> #include "csdl.h"
> #include "csoundCore.h"
> /*
>   p3 = size
>   p4 = GEN routine
>   p5 = choose axis to write; 0 = x, 1 = y, 2 = z
>   p6 = min output
>   p7 = max output
>   p8 = stepsize
>   p9 = x start
>   p10 = y start
>   p11 = z start
>   f1 0 4096 "lorenz" "x" -1 1 5
>
>  */
> void scale_array(MYFLT *fp, MYFLT min_out, MYFLT max_out, int32_t size)
> {
>   MYFLT min_in = fp[0];
>   MYFLT max_in = fp[0];
>
>   for(int i = 1; i < size; i++){
>     if(fp[i] < min_in)
>       min_in = fp[i];
>     if(fp[i] > max_in)
>       max_in = fp[i];
>   }
>
>   MYFLT old_value;
>   for(int j = 0; j < size; j++){
>     old_value = fp[j];
>     printf("old value: %f\n", old_value);
>     fp[j] =  min_out + ((old_value - min_in) / (max_in - min_in))
>       * (max_out - min_out);
>     printf("new value: %f\ns",fp[j]);
>     printf("sohuld value: %f\n", (min_out + ((old_value - min_in) / (max_in - min_in))
>       * (max_out - min_out)));
>   }
> }
>
> static int32_t lorenztable(FGDATA *ff, FUNC *ftp)
> {
>   /* function table */
>   MYFLT *fp = ftp->ftable;
>
>   /* default arguments */
>   MYFLT sigma = 10;
>   MYFLT rho = 28;
>   MYFLT beta = 8.0/3.0;
>   MYFLT time = 0.001;
>
>   /* p-field arguments */
>   int32_t ft_size = ftp->flen;
>   MYFLT min_out = ff->e.p[6];
>   MYFLT max_out = ff->e.p[7];
>   MYFLT step_size = ff->e.p[8];
>   MYFLT x = ff->e.p[9];
>   MYFLT y = ff->e.p[10];
>   MYFLT z = ff->e.p[11];
>
>   /* write raw data to ft */
>   for (int i = 0; i < ft_size; i++)
>     {   
>       if (ff->e.p[5] == 0){
>         fp[i] = x;
>       } else if (ff->e.p[5] == 1){
>         fp[i] = y;
>       } else if (ff->e.p[5] == 2){
>         fp[i] = z;
>       }
>
>       for (int j = 0; j < step_size; j++){
>         x += (sigma * (y - z)) * time;
>         y += (x * (rho - z) - y) * time;
>         z += ((x * y) - (beta * z)) * time;
>       }
>     }
>
>   /* scale data of ft */
>   scale_array(fp, min_out, max_out, ft_size);
>
>   return OK;
> }
>
> static NGFENS localfgens[] = {
>   { "lorenz", lorenztable},
>   { NULL, NULL}
> };
>
>
> FLINKAGE_BUILTIN(localfgens)
>
> ```
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2024-11-24 11:20
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Debugging a GEN Routine C-Code
Thank you for this hint!

I always thought this is something you had to implement to the code and is not a csound default!

And in the „tanh“ exxample i found the solution to this:
you have to implement a p-field designated to the rescaling function and then you can make the p4 field negativ

  if(resc!=0.0)
    ff->e.p[4] = -1;


> Am 24.11.2024 um 12:07 schrieb Rory Walsh :
> 
> This is default for all gen routines afaik. As to your first question, I'm not sure. Can you simply prepend a -? 
> 
> On Sun, 24 Nov 2024 at 10:56, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> Thanks Rory!
> But i implemented the GEN routine as GEN“lorenz“ and i call it by the string „lorenz“. How can i use this with a string?
> And is this a default method to every GEN routine or must this implemented in the GEN code?
> 
> > Am 24.11.2024 um 11:52 schrieb Rory Walsh :
> > 
> > Hi Philip. If you use a negative gen number in your score it will prevent automatic normalisation of your table data. :+1:  
> > 
> > On Sun, 24 Nov 2024 at 10:44, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> > Hello everybody!
> > I’m diving into GEN routine development to learn some C and for a university class.
> > 
> > Over the past few days, I’ve written a GEN routine based on the Lorenz attractor to generate control data. My C code compiles and runs inside Csound, but I’m confused about the output of the GEN routine.
> > I’ve implemented a scaling function to map the values in the table to a specified range (e.g., between a minimum and maximum), but the results aren’t as expected. To debug, I’ve added printf statements in the C code to check the intermediate values, and everything seems fine there.
> > 
> > However, when I use ftprint in Csound, the table values don’t match what the C code prints. For example, if I scale the values to the range [3, 10], I end up with values in Csound between 0.3 and 1.0. The scaling logic in the C code seems correct, so I’m unsure why the output is wrong.
> > 
> > Here are some thoughts on what might be causing the issue:
> >     • Csound might be normalizing the table values to fit within the range [-1, 1], and values outside this range might not be allowed.
> >     • I could be compiling my GEN routine incorrectly.
> > 
> > Below is my C code and my compile command — maybe there’s an error I’ve overlooked. Any help would be greatly appreciated!
> > Thank you!
> > —Philipp
> > 
> > ```gcc -shared -o lorenz-gen.dylib -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/ lorenz-gen.c```
> > 
> > ```
> > #include "csdl.h"
> > #include "csoundCore.h"
> > /*
> >   p3 = size
> >   p4 = GEN routine
> >   p5 = choose axis to write; 0 = x, 1 = y, 2 = z
> >   p6 = min output
> >   p7 = max output
> >   p8 = stepsize
> >   p9 = x start
> >   p10 = y start
> >   p11 = z start
> >   f1 0 4096 "lorenz" "x" -1 1 5
> > 
> >  */
> > void scale_array(MYFLT *fp, MYFLT min_out, MYFLT max_out, int32_t size)
> > {
> >   MYFLT min_in = fp[0];
> >   MYFLT max_in = fp[0];
> > 
> >   for(int i = 1; i < size; i++){
> >     if(fp[i] < min_in)
> >       min_in = fp[i];
> >     if(fp[i] > max_in)
> >       max_in = fp[i];
> >   }
> > 
> >   MYFLT old_value;
> >   for(int j = 0; j < size; j++){
> >     old_value = fp[j];
> >     printf("old value: %f\n", old_value); 
> >     fp[j] =  min_out + ((old_value - min_in) / (max_in - min_in))
> >       * (max_out - min_out);
> >     printf("new value: %f\ns",fp[j]);
> >     printf("sohuld value: %f\n", (min_out + ((old_value - min_in) / (max_in - min_in))
> >       * (max_out - min_out))); 
> >   }
> > }
> > 
> > static int32_t lorenztable(FGDATA *ff, FUNC *ftp)
> > {
> >   /* function table */
> >   MYFLT *fp = ftp->ftable;
> > 
> >   /* default arguments */
> >   MYFLT sigma = 10;
> >   MYFLT rho = 28;
> >   MYFLT beta = 8.0/3.0;
> >   MYFLT time = 0.001;
> > 
> >   /* p-field arguments */
> >   int32_t ft_size = ftp->flen;
> >   MYFLT min_out = ff->e.p[6];
> >   MYFLT max_out = ff->e.p[7];
> >   MYFLT step_size = ff->e.p[8];
> >   MYFLT x = ff->e.p[9];
> >   MYFLT y = ff->e.p[10];
> >   MYFLT z = ff->e.p[11];
> > 
> >   /* write raw data to ft */
> >   for (int i = 0; i < ft_size; i++)
> >     {    
> >       if (ff->e.p[5] == 0){
> >         fp[i] = x;
> >       } else if (ff->e.p[5] == 1){
> >         fp[i] = y;
> >       } else if (ff->e.p[5] == 2){
> >         fp[i] = z;
> >       }
> > 
> >       for (int j = 0; j < step_size; j++){
> >         x += (sigma * (y - z)) * time;
> >         y += (x * (rho - z) - y) * time;
> >         z += ((x * y) - (beta * z)) * time;
> >       } 
> >     }
> > 
> >   /* scale data of ft */
> >   scale_array(fp, min_out, max_out, ft_size);
> > 
> >   return OK;
> > }
> > 
> > static NGFENS localfgens[] = {
> >   { "lorenz", lorenztable},
> >   { NULL, NULL}
> > };
> > 
> > 
> > FLINKAGE_BUILTIN(localfgens)
> > 
> > ```
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >         https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here