Csound Csound-dev Csound-tekno Search About

[Cs-dev] Proposal: add ! no-carry operator to score language

Date2007-12-03 09:02
FromAnthony Kozar
Subject[Cs-dev] Proposal: add ! no-carry operator to score language
With the advent of the pcount and pindex opcodes in the orchestra, it is now
possible for instruments to easily handle a variable number of p-fields.  An
example of an application for this is an envelope with a variable number of
segments specified from the score.  One thing stands in the way of
effectively using this technique though:  the automatic carrying of i event
parameters when one i event has fewer pfields than a previous one.

In some other Music N languages, you must explicitly carry extra pfields
like this:

i1 0 1  1.0 2.0 3.0     ;  6 pfields
i1 1 1  &               ;  6 pfields
i1 1 1                  ;  3 pfields only

Since we cannot change Csound to work this way without breaking backwards
compatibility, I am instead suggesting that we add a score operator for
explicitly telling the score parser to NOT carry any additional pfields:

i1 0 1  1.0 2.0 3.0     ;  6 pfields
i1 1 1                  ;  6 pfields
i1 2 1  2.0 !           ;  4 pfields only
i1 3 1                  ;  4 fields

I've already located where the changes need to be made to add this new
operator and I think that it will be easy to do.

Is it OK to add this?

Additionally, to avoid warnings from rdscor() during performance, it would
be useful to have an optional orchestra opcode that defines the minimum and
maximum pfields that each instrument will accept without complaint.  (The
defaults would be the number of pfields explicitly referenced by the
orchestra code, as it is now).

Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://anthonykozar.net/


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-03 14:40
From"Dr. Richard Boulanger"
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Anthony,

This sounds like an excellent plan - a new score feature that would  
turn off this very very
important and very very much used historical feature.

-dB

On Dec 3, 2007, at 4:02 AM, Anthony Kozar wrote:

> With the advent of the pcount and pindex opcodes in the orchestra,  
> it is now
> possible for instruments to easily handle a variable number of p- 
> fields.  An
> example of an application for this is an envelope with a variable  
> number of
> segments specified from the score.  One thing stands in the way of
> effectively using this technique though:  the automatic carrying of  
> i event
> parameters when one i event has fewer pfields than a previous one.
>
> In some other Music N languages, you must explicitly carry extra  
> pfields
> like this:
>
> i1 0 1  1.0 2.0 3.0     ;  6 pfields
> i1 1 1  &               ;  6 pfields
> i1 1 1                  ;  3 pfields only
>
> Since we cannot change Csound to work this way without breaking  
> backwards
> compatibility, I am instead suggesting that we add a score operator  
> for
> explicitly telling the score parser to NOT carry any additional  
> pfields:
>
> i1 0 1  1.0 2.0 3.0     ;  6 pfields
> i1 1 1                  ;  6 pfields
> i1 2 1  2.0 !           ;  4 pfields only
> i1 3 1                  ;  4 fields
>
> I've already located where the changes need to be made to add this new
> operator and I think that it will be easy to do.
>
> Is it OK to add this?
>
> Additionally, to avoid warnings from rdscor() during performance,  
> it would
> be useful to have an optional orchestra opcode that defines the  
> minimum and
> maximum pfields that each instrument will accept without  
> complaint.  (The
> defaults would be the number of pfields explicitly referenced by the
> orchestra code, as it is now).
>
> Anthony Kozar
> anthonykozar AT sbcglobal DOT net
> http://anthonykozar.net/
>
>
> ---------------------------------------------------------------------- 
> ---
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 02:34
FromAnthony Kozar
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
I've finished implementing this "no-carry" operator using the proposed
symbol '!'.  Any objections to my committing the changes?

Anthony

Anthony Kozar wrote on 12/3/07 4:02 AM:

> I am instead suggesting that we add a score operator for
> explicitly telling the score parser to NOT carry any additional pfields:
> 
> i1 0 1  1.0 2.0 3.0     ;  6 pfields
> i1 1 1                  ;  6 pfields
> i1 2 1  2.0 !           ;  4 pfields only
> i1 3 1                  ;  4 fields

> Is it OK to add this?


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 03:35
FromJacob Joaquin
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Hey Anthony,

Would it be possible to see some orchestra instrument examples to go along
with the "no-carry" operator?  I might have a few suggestions, but I want to
know a little more about what you're proposing.

For the record, I really like this idea of a "no-carry" operator.

Best,
Jake

---- 
The Csound Blog 
http://www.thumbuki.com/csound/blog  



Anthony Kozar wrote:
> 
> I've finished implementing this "no-carry" operator using the proposed
> symbol '!'.  Any objections to my committing the changes?
> 
> Anthony
> 

-- 
View this message in context: http://www.nabble.com/Proposal%3A-add-%21-no-carry-operator-to-score-language-tf4935133.html#a14164643
Sent from the Csound - Dev mailing list archive at Nabble.com.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 04:39
FromAnthony Kozar
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Jacob Joaquin wrote on 12/4/07 10:35 PM:

> Would it be possible to see some orchestra instrument examples to go along
> with the "no-carry" operator?  I might have a few suggestions, but I want to
> know a little more about what you're proposing.
> 
> For the record, I really like this idea of a "no-carry" operator.

Thanks.  Here is the example that I was using to test it.  several of the
events intentionally contain errors to provoke the code that is supposed to
catch them.  The ! should always come at the end of a line containing an 'i'
event.

Anthony


; flexenv.csd
; An instrument that reads a flexible number of envelope
; parameters as pfields.







; This UDO returns a pfield value but returns 0 if it does not exist.
opcode  mypvalue, i, i
    index  xin
    inum   pcount
    if      (index > inum)  then
        iout = 0.0
    else
        iout pindex index
    endif
    
    xout    iout
endop
    
; Envelope UDO that reads parameters from a flexible number of pfields
; Syntax:   kenv  flexlinseg  ipstart
;           ipstart is the first pfield of the envelope
;               parameters.  Reads remaining pfields (up to 21 of them).
;           kenv is the output envelope.

opcode  flexlinseg, k, i
    ipstart xin
    
    iep1   mypvalue    ipstart
    iep2   mypvalue    ipstart + 1
    iep3   mypvalue    ipstart + 2
    iep4   mypvalue    ipstart + 3
    iep5   mypvalue    ipstart + 4
    iep6   mypvalue    ipstart + 5
    iep7   mypvalue    ipstart + 6
    iep8   mypvalue    ipstart + 7
    iep9   mypvalue    ipstart + 8
    iepa   mypvalue    ipstart + 9
    iepb   mypvalue    ipstart + 10
    iepc   mypvalue    ipstart + 11
    iepd   mypvalue    ipstart + 12
    iepe   mypvalue    ipstart + 13
    iepf   mypvalue    ipstart + 14
    iepg   mypvalue    ipstart + 15
    ieph   mypvalue    ipstart + 16
    iepi   mypvalue    ipstart + 17
    iepj   mypvalue    ipstart + 18
    iepk   mypvalue    ipstart + 19
    iepl   mypvalue    ipstart + 20

    kenv   linseg     iep1, iep2, iep3, iep4, iep5, iep6, iep7, iep8, \
                       iep9, iepa, iepb, iepc, iepd, iepe, iepf, iepg, \
                       ieph, iepi, iepj, iepk, iepl
    
    xout   kenv
endop
    
instr 1
    ; This instrument only requires 3 pfields but can accept up to 24.
    ; (You will still get warnings about more than 3).
    
    kenv   flexlinseg  4            ; envelope params start at p4
    aout   oscili  kenv*15000, 256, 1

    out       aout
endin



f1  0 8192 10 1

i1  0 2  0.0 1.0 1.0 1.0 0.0
i1  2 2  0.0 0.1 1.0 1.0 1.0 0.1 0.0
i1  4 2  0.0 0.5 0.0          ; one problem is that "missing" pfields carry
i1  6 2  0.0 0.5 0.0 !        ; now we can fix this problem with !
i1  8 10  0.0  3.0 1.0  0.3 0.1  0.3 1.0  0.3 0.1  0.3 1.0  0.3 0.1  \
    0.8 0.9  5.0 0.0
i1  18 1  !234                ; this is an error
i1  !                         ; error - not allowed in p1, p2, or p3
i!                            ; error

f2  0 8192 10 1 !1 1          ; error - ! only allowed for 'i' events
 
e




-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 20:08
FromJacob Joaquin
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Anthony,

Here's some pseudo code that explains some thoughts I've had:

--------
instr 1
    iamp pfieldgrab p4, 1.0  ; Get amplitude.  If no p4 exists, use default
value of 1.0
    ifreq pfieldgrab cpspch( p5 ), 440  ; Get pch, convert to frequency.  If
no p5 exists, use 440.

    a1 oscil iamp, ifreq, 1
    out a1 * 0dbfs
endin
...
f1 0 8192 10 1

i1 0 1 1 8.00
i1 + . . 8.02
i1 + . . !  ; p5 uses default value of 440
i1 + . ! ; p4 & p5 use default values 1.0 and 440
i1 + . ? 8.04 ; p4 uses default value, and uses cpspch( 8.04 )
--------

There are two things I've added.

First is the opcode pfieldgrab.  The first parameter is the pfield it tries
to grab a value from.  If it exists, it uses it.  However, if no value
exists, it will use the value in the second parameter.

The second thing I introduced is "?" in the score.  The idea is to be able
to skip a p-field in the score, while still being able to enter in values
for p-fields beyond the skipped p-field.  Alternatively, I guess we could
re-use the "!" glyph for skipping p-fields.  For example (assume there are 6
p-fields):

--------
; all of these are valid
i2 0 1 1 8.00 0.5
i2 1 1 1 8.00 !
i2 2 1 1 !
i2 3 1 !
i2 4 1 1 ! 0.5 ; skip p5, and still grab the value in p6
i2 5 1 ! ! 0.5; skip p4 and p5
--------

Basically, if there are no more p-fields after "!", then use default values
for all proceeding p-fields.  If there are more values after "!", then use
these specified values.

Just some ideas I had.  Hopefully useful.  The name pfieldgrab and the score
glyph "?" are completely temporary.

Best,
Jake

---- 
The Csound Blog 
http://www.thumbuki.com/csound/blog  





Anthony Kozar wrote:
> 
> Thanks.  Here is the example that I was using to test it.  several of the
> events intentionally contain errors to provoke the code that is supposed
> to
> catch them.  The ! should always come at the end of a line containing an
> 'i'
> event.
> 

-- 
View this message in context: http://www.nabble.com/Proposal%3A-add-%21-no-carry-operator-to-score-language-tf4935133.html#a14179526
Sent from the Csound - Dev mailing list archive at Nabble.com.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 21:19
FromAnthony Kozar
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Jacob Joaquin wrote on 12/5/07 3:08 PM:

> --------
> instr 1
> iamp pfieldgrab p4, 1.0  ; Get amplitude.  If no p4 exists, use default
> value of 1.0
> ifreq pfieldgrab cpspch( p5 ), 440  ; Get pch, convert to frequency.  If
> no p5 exists, use 440.

pfieldgrab could be implemented rather easily as an UDO -- almost identical
to the mypvalue UDO in the example that I posted.  But you would have to use
"4" instead of "p4".  "p4" will just try to pass the _value_ of p4 to the
UDO.  Your semantics in the second example (cpspch(p5) affecting the output
instead of the input to the UDO) are also problematic.  I see no easy way to
make either of these semantic changes for a parameter to any opcode.

> i1 0 1 1 8.00
> i1 + . . 8.02
> i1 + . . !  ; p5 uses default value of 440
> i1 + . ! ; p4 & p5 use default values 1.0 and 440

The above score lines should all work with ! as I have implemented it and an
UDO pfieldgrab.

> i1 + . ? 8.04 ; p4 uses default value, and uses cpspch( 8.04 )

This is very problematic.  The score parser maintains a count of the pfields
associated with each score event and assumes they are in order p1, p2, etc.
Trying to allow for non-existent fields in the middle of the array would
(IMHO) be horribly complicated.  You could probably achieve a similar result
by assigning your own semantics to certain values.  For example, since
neither amplitude nor pitch make much sense when negative, your orchestra
code could interpret a -1 value as "use the default".

> Just some ideas I had.  Hopefully useful.  The name pfieldgrab and the score
> glyph "?" are completely temporary.

Using ! to prevent carrying so that an instrument can infer default values
is a fine example of its intended applications.  But I personally do not see
how we can reasonably implement your proposed extension for skipping
arbitrary p-fields.  Sorry.

Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://anthonykozar.net/


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-05 22:10
FromJacob Joaquin
SubjectRe: [Cs-dev] Proposal: add ! no-carry operator to score language
Don't worry about.  I understand that Csound coded itself into a corner over
the years, and that it's not really all that flexible internally, as just
about every recommendation I've ever posted has been shot down for
"technical" reasons.  Like the old adage goes, "A girl can dream, can't
she?"  :)

Best, 
Jake 

---- 
The Csound Blog 
http://www.thumbuki.com/csound/blog  




Anthony Kozar wrote:
> 
> Using ! to prevent carrying so that an instrument can infer default values
> is a fine example of its intended applications.  But I personally do not
> see
> how we can reasonably implement your proposed extension for skipping
> arbitrary p-fields.  Sorry.
> 

-- 
View this message in context: http://www.nabble.com/Proposal%3A-add-%21-no-carry-operator-to-score-language-tf4935133.html#a14181190
Sent from the Csound - Dev mailing list archive at Nabble.com.


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-12 02:53
FromAnthony Kozar
Subject[Cs-dev] Added ! no-carry operator to score language
I have committed the no-carry operator (!) changes.  It can be reverted if
there are problems.

Anthony

Anthony Kozar wrote on 12/4/07 9:34 PM:

> I've finished implementing this "no-carry" operator using the proposed symbol
> '!'.  Any objections to my committing the changes?


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net