Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:5000] RE: SV: python inside csound instr ?

Date2004-07-15 20:21
From"gogins@pipeline.com"
Subject[CSOUND-DEV:5000] RE: SV: python inside csound instr ?
Others can implement whatever scripting languages they wish with plugin
opcodes. I currently am interested only in Python.

I am wondering whether to borrow the Gabriel/Maurizio Python opcodes, or to
implement my own from scratch. Their system is rather complex and I wonder
if all of it is really needed. I propose:

pyimport istringfilename
x pycall istringfunctionname, xargs...

The complexity would enter in if Python were used with arate variables;
krate is no problem.

Original Message:
-----------------
From: Oeyvind Brandtsegg obrandts@online.no
Date: Thu, 15 Jul 2004 20:14:08 +0200 (CEST)
To: gogins@pipeline.com
Subject: SV: python inside csound instr ?


I think it would be very useful if you could put them into cs5.
It would make the csound language so much more powerful,
and it's very handy to have it "all in one box" as it is easier to let
csound and python interact. 

Would this perhaps create a discussion of what scripting language(s) to
support ?

Oeyvind

> From: gogins@pipeline.com
> Sent: 2004-07-14 22:47:12 CEST
> To: obrandts@online.no
> Subject: RE: python inside csound instr ?
> 
> Sorry, no. But Gabriel Maldonado has a version of Csound that implements
> Maurizio Puxeddo's Python opcodes that do allow you to do that. I have
> considered putting them into Csound 5, or putting my own version of such
> opcodes in, but I have not gotten around to it.
> 
> Original Message:
> -----------------
> From: Oeyvind Brandtsegg obrandts@online.no
> Date: Wed, 14 Jul 2004 20:36:22 +0200 (CEST)
> To: gogins@pipeline.com, csound@lists.bath.ac.uk
> Subject: python inside csound instr ?
> 
> 
> With csound 5, can python scripts be used inside a csound orchestra ?
> Like, including a Lindenmayer system in an instrument, requesting more
> iterations by reinitializing the instrument,
> or something like that.
> 
> best
> Oeyvind
> 
> 
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
> 
> 


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

Date2004-07-15 21:33
FromAnthony Kozar
Subject[CSOUND-DEV:5003] RE: SV: python inside csound instr ?
I was just thinking about this.  I don't think that I completely understand
how opcodes work, so I have some questions regarding plugins.

It seems to me that there are three main types of opcodes: those that run at
orchestra load time, init-time, or performance time.  One of the important
parts of Maurizio's python opcodes was the "pystartup" opcode which would go
in instrument 0 and run at orchestra load time.  I think initializing the
interpreter would be an important step for many potential embedded languages
and would not be a step you would want to delay until performance time.

So, is it possible already in CS5 to have a plugin opcode be in i0 or to run
at load time?  Or is there a better way to perform initialization for a set
of opcodes?

Another aspect of Maurizio's system was the ability to have multi-line
chunks of Python code embedded into the orchestra file.  He used something
like {{ and }} to delimit these blocks.  This feature of course required
changes to the orchestra parser.

Michael, your suggested opcodes below are certainly general enough from a
functional standpoint.  However, I imagine a lot of people would prefer to
put their code directly into the orchestra file.  Can we consider having one
syntax in CS5 for passing multi-line string arguments to opcodes?  There may
not be any built-in opcodes in CS5 to require this, but it would be usable
by anyone writing their own scripting plugin.

Also -- I am not sure that this makes sense, it is just a vague idea in my
head right now, but -- should we consider some way of having "score opcode
plugins" or some mechanism that would allow a block of text in a score to be
interpreted by a plugin library (or host app) and return a block of standard
score events ???

Just some thoughts ...

Anthony Kozar
anthony.kozar@utoledo.edu
http://akozar.spymac.net/

On 7/15/04 3:21 PM, gogins@pipeline.com etched in
stone:

> Others can implement whatever scripting languages they wish with plugin
> opcodes. I currently am interested only in Python.
> 
> I am wondering whether to borrow the Gabriel/Maurizio Python opcodes, or to
> implement my own from scratch. Their system is rather complex and I wonder
> if all of it is really needed. I propose:
> 
> pyimport istringfilename
> x pycall istringfunctionname, xargs...
> 
> The complexity would enter in if Python were used with arate variables;
> krate is no problem.

Date2004-07-16 04:25
FromAndres Cabrera
Subject[CSOUND-DEV:5005] RE: SV: python inside csound instr ?
Anthony Kozar wrote:

>I was just thinking about this.  I don't think that I completely understand
>how opcodes work, so I have some questions regarding plugins.
>
>It seems to me that there are three main types of opcodes: those that run at
>orchestra load time, init-time, or performance time.  One of the important
>parts of Maurizio's python opcodes was the "pystartup" opcode which would go
>in instrument 0 and run at orchestra load time.  I think initializing the
>interpreter would be an important step for many potential embedded languages
>and would not be a step you would want to delay until performance time.
>
>So, is it possible already in CS5 to have a plugin opcode be in i0 or to run
>at load time?  Or is there a better way to perform initialization for a set
>of opcodes?
>
>  
>
You'll probably get some better answers, but from what I've seen, 
there's no option to separate orchestra load time and init-time opcodes. 
That means an opcode doesn't know that it should be in instrument 0 or 
inside another instrument. It is implementation that defines (or rather 
limits) this usage, but most opcodes I can think of that go in 
instrument 0 (like massign) can also go inside instruments.
Cheers,
Andres

Date2004-07-16 07:31
Fromstevenyi
Subject[CSOUND-DEV:5006] RE: SV: python inside csound instr ?
Hi Anthony,

As far as I know, any opcode with a OENTRY with thread value with 1 (or
interprets down to 1 for opcodes that can work at different rates), or
have a b out-arg type will work in instrument 0. (At least, this is
working from experience and looking at the code in otran.c:

      if ((thread = opcodlst[opnum].thread) & 06 ||
          (!thread && bp->t.pftype != 'b'))
        synterr(Str(X_1124,"perf-pass statements illegal in header
blk"));

).  I think that boils down to opcodes that run at i-rate and
functions.  (I'll add something to this effect to csound.tex in a moment
and will update if incorrect.)

steven


On Thu, 2004-07-15 at 20:25, Andres Cabrera wrote:
> Anthony Kozar wrote:
> 
> >I was just thinking about this.  I don't think that I completely understand
> >how opcodes work, so I have some questions regarding plugins.
> >
> >It seems to me that there are three main types of opcodes: those that run at
> >orchestra load time, init-time, or performance time.  One of the important
> >parts of Maurizio's python opcodes was the "pystartup" opcode which would go
> >in instrument 0 and run at orchestra load time.  I think initializing the
> >interpreter would be an important step for many potential embedded languages
> >and would not be a step you would want to delay until performance time.
> >
> >So, is it possible already in CS5 to have a plugin opcode be in i0 or to run
> >at load time?  Or is there a better way to perform initialization for a set
> >of opcodes?
> >
> >  
> >
> You'll probably get some better answers, but from what I've seen, 
> there's no option to separate orchestra load time and init-time opcodes. 
> That means an opcode doesn't know that it should be in instrument 0 or 
> inside another instrument. It is implementation that defines (or rather 
> limits) this usage, but most opcodes I can think of that go in 
> instrument 0 (like massign) can also go inside instruments.
> Cheers,
> Andres
> 
> 

Date2004-07-16 08:19
FromAnthony Kozar
Subject[CSOUND-DEV:5007] RE: SV: python inside csound instr ?
Thanks Steven and Andres for the information.  I guess it shouldn't be too
much trouble to develop plugin scripting languages then (although I still
would like the multi-line argument feature).

I guess -- as John ff. once wrote -- there really is no substitute for
reading the code.  I will take a closer look when I have some time.  :)

Thanks.

Anthony

Date2004-07-16 08:59
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5008] RE: SV: python inside csound instr ?
Csound knows (or is supposed to know) which opcodes are allowed in
instr0 but they can be used in other places.
==John ffitch