Csound Csound-dev Csound-tekno Search About

[Csnd] GEN23 question

Date2020-02-17 14:56
FromDave Seidel
Subject[Csnd] GEN23 question
Hi all,

Working on something that will require a table or array of 580 values, which I have defined as ratios (e.g., 81/80) in a text file, one per line. I thought at first that I could use GEN23 (with a size of 0, so that it will auto-count), but when I compile the CSD, it tells me that the table has 1158 points. It took me a minute to realize that this doesn't work as I'd hoped because GEN23 is looking for simple numeric values as opposed to expressions, and is likely using the slash character ('/') as a separator.

I will find another way (probably just convert to a big inline comma-separated list and use fillarray), but it would be cool if there was a GEN routine like 23 that accepted expressions, evaluated them at compile time, and stored the resulting values. Is this as all practical, given the way compilation works? Is it worth a feature-request ticket?

Thanks,
Dave
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

Date2020-02-17 15:39
From"Jeanette C."
SubjectRe: [Csnd] GEN23 question
Hi Dave,
just from the top of my head: could you perhaps use an include files and write 
your calculations in Csound?

If all that is too cumbersome: how about a simple script using bc - or a 
similar commandline calculator - to read a file like yours and spit out a file 
with single numbers.

Or, when this is all you need, use the file you have and calculate online in 
Csound, storing the results in a new array or do the calculations online, 
whenever you need them.

I'm sure you might have thought of - at least - some of these. And still an 
opcode to read valid Csound arithmetic expressiions might be fun for some more 
complex orchestras. :)

Best wishes,

Jeanette

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

There's no time to loose
And next week,
You might not see me here <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

Date2020-02-17 16:01
Fromjohn
SubjectRe: [Csnd] GEN23 question
Thinking out loud....

It might be possible to extend Gen23 to accept expressions say in [] but 
it woud need a careful definition of what constituted a simple expression. 
Just +-*/ or math functions, what about macros...  Could be a load of code 
as well.  Looking at the code a simple form with one operator might not be 
too difficult................

==John ff

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

Date2020-02-17 17:17
FromDave Seidel
SubjectRe: [Csnd] GEN23 question
Thanks to Jeanette and John for your replies. I ended up using converting the list to comma-separated and used it as input to fillarray -- in this context, the expressions (simple as they are) are evaluated just fine, and this is working.

Jeanette, I was able to use some simple regexes to get this into the desired format, and I used the Linux "fmt" command to wrap the lines in a reasonable way.

John, I agree, if we ever did this, we should be careful about what expressions are allowed, and they should be simple ones. Probably best to leave out macros altogether.

- Dave




On Mon, Feb 17, 2020 at 11:01 AM john <jpff@codemist.co.uk> wrote:
Thinking out loud....

It might be possible to extend Gen23 to accept expressions say in [] but
it woud need a careful definition of what constituted a simple expression.
Just +-*/ or math functions, what about macros...  Could be a load of code
as well.  Looking at the code a simple form with one operator might not be
too difficult................

==John ff

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