Csound Csound-dev Csound-tekno Search About

[Csnd] ftsave: table header format

Date2021-05-12 14:01
From"Jeanette C."
Subject[Csnd] ftsave: table header format
Hey hey,
I'm working on a small conversion tool between different formats and I'd like 
to write Csound tables ready for ftload(k) as well. Is there a simple 
documentation on the header format? I can' understand quite a few bits, but 
others I'm completely unclear about.

If it helps I want to write a single one-channel table, no extras at all. No 
guard points, loops or CPS information.

I'd be grateful for any pointer.

Best wishes and thanks,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

If only I could trade the fancy cars
For a chance today,
it's incomparable <3
(Britney Spears)

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

Date2021-05-12 17:18
Fromjohn
SubjectRe: [Csnd] ftsave: table header format
Depends on whether you are writing text or binary.
>From Opcodes/ftgen.s function ftsave


BINARY

         FUNC *ftp;
         //csound->Message(csound, "saving table %f \n", **argp);
         if ( *argp && (ftp = ft_func(csound, *argp)) != NULL) {
           MYFLT *table = ftp->ftable;
           int32 flen = ftp->flen;
           int32_t n;
           n = fwrite(ftp, sizeof(FUNC) - sizeof(MYFLT) - SSTRSIZ, 1, 
file);
           if (UNLIKELY(n!=1)) goto err4;
           n = fwrite(table, sizeof(MYFLT), flen + 1, file);
           if (UNLIKELY(n!=flen + 1)) goto err4;
         }
         else goto err;


TEXT

         FUNC *ftp;

         if ((ftp = ft_func(csound, *argp)) != NULL) {
           int32 flen = ftp->flen;
           int32 j;
           MYFLT *table = ftp->ftable;
           /* IMPORTANT!! If FUNC structure and/or GEN01ARGS structure
              will be modified, the following code has to be modified too 
*/
           fprintf(file,"======= TABLE %d size: %d values ======\n",
                   ftp->fno, ftp->flen);
           fprintf(file,"flen: %d\n", ftp->flen);
           fprintf(file,"lenmask: %d\n", ftp->lenmask);
           fprintf(file,"lobits: %d\n",ftp->lobits);
           fprintf(file,"lomask: %d\n",ftp->lomask);
           fprintf(file,"lodiv: %f\n",ftp->lodiv);
           fprintf(file,"cvtbas: %f\n",ftp->cvtbas);
           fprintf(file,"cpscvt: %f\n",ftp->cpscvt);
           fprintf(file,"loopmode1: %d\n", (int32_t) ftp->loopmode1);
           fprintf(file,"loopmode2: %d\n", (int32_t) ftp->loopmode2);
           fprintf(file,"begin1: %d\n",ftp->begin1);
           fprintf(file,"end1: %d\n",ftp->end1);
           fprintf(file,"begin2: %d\n",ftp->begin2);
           fprintf(file,"end2: %d\n",ftp->end2);
           fprintf(file,"soundend: %d\n",ftp->soundend);
           fprintf(file,"flenfrms: %d\n",ftp->flenfrms);
           fprintf(file,"nchnls: %d\n",ftp->nchanls);
           fprintf(file,"fno: %d\n",ftp->fno);

           fprintf(file,"gen01args.gen01: %f\n",ftp->gen01args.gen01);
           fprintf(file,"gen01args.ifilno: %f\n",ftp->gen01args.ifilno);
           fprintf(file,"gen01args.iskptim: %f\n",ftp->gen01args.iskptim);
           fprintf(file,"gen01args.iformat: %f\n",ftp->gen01args.iformat);
           fprintf(file,"gen01args.channel: %f\n",ftp->gen01args.channel);
           fprintf(file,"gen01args.sample_rate: %f\n",
                        ftp->gen01args.sample_rate);
           /* WARNING! skips ftp->gen01args.strarg from saving/loading in
              text format */
           fprintf(file,"---------END OF HEADER--------------\n");


No guaranty that this may not change.  I think that &%f shoud be %a for 
example



On Wed, 12 May 2021, Jeanette C. wrote:

> Hey hey,
> I'm working on a small conversion tool between different formats and I'd like 
> to write Csound tables ready for ftload(k) as well. Is there a simple 
> documentation on the header format? I can' understand quite a few bits, but 
> others I'm completely unclear about.
>
> If it helps I want to write a single one-channel table, no extras at all. No 
> guard points, loops or CPS information.
>
> I'd be grateful for any pointer.
>
> Best wishes and thanks,
>
> Jeanette
>
> -- 
> * Website: http://juliencoder.de - for summer is a state of sound
> * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
> * Audiobombs: https://www.audiobombs.com/users/jeanette_c
> * GitHub: https://github.com/jeanette-c
>
> If only I could trade the fancy cars
> For a chance today,
> it's incomparable <3
> (Britney Spears)
>
> 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

Date2021-05-12 18:00
From"Jeanette C."
SubjectRe: [Csnd] ftsave: table header format
Hi John,
thanks a lot for that. I still have some questions, if I may, about the
text format, which I'd like to write.

May 12 2021, john has written:
...
>          int32 flen = ftp->flen;
I assume this is the full length, i.e. number of values in the ftable?
...
>          fprintf(file,"lenmask: %d\n", ftp->lenmask);
>          fprintf(file,"lobits: %d\n",ftp->lobits);
>          fprintf(file,"lomask: %d\n",ftp->lomask);
What are they? Any safe values to put there?
>          fprintf(file,"lodiv: %f\n",ftp->lodiv);
>          fprintf(file,"cvtbas: %f\n",ftp->cvtbas);
>          fprintf(file,"cpscvt: %f\n",ftp->cpscvt);
>          fprintf(file,"loopmode1: %d\n", (int32_t) ftp->loopmode1);
>          fprintf(file,"loopmode2: %d\n", (int32_t) ftp->loopmode2);
>          fprintf(file,"begin1: %d\n",ftp->begin1);
>          fprintf(file,"end1: %d\n",ftp->end1);
>          fprintf(file,"begin2: %d\n",ftp->begin2);
>          fprintf(file,"end2: %d\n",ftp->end2);
>          fprintf(file,"soundend: %d\n",ftp->soundend);
Can I assume that the above can be 0 or 0.0f for a simple, non audio
data table?
>          fprintf(file,"flenfrms: %d\n",ftp->flenfrms);
For one channel/one value table the same as flen?
...
>          fprintf(file,"gen01args.gen01: %f\n",ftp->gen01args.gen01);
>          fprintf(file,"gen01args.ifilno: %f\n",ftp->gen01args.ifilno);
>          fprintf(file,"gen01args.iskptim: %f\n",ftp->gen01args.iskptim);
>          fprintf(file,"gen01args.iformat: %f\n",ftp->gen01args.iformat);
>          fprintf(file,"gen01args.channel: %f\n",ftp->gen01args.channel);
>          fprintf(file,"gen01args.sample_rate: %f\n",
>                       ftp->gen01args.sample_rate);
The above can be 0, except for the samplerate, which could be something
inoffensive?
...

Thanks again and best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Can't make you love me
I'm just a girl with a crush on you <3
(Britney Spears)

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