Csound Csound-dev Csound-tekno Search About

Control flow

Date2006-02-20 22:31
FromTobiah
SubjectControl flow
Is something like this possible with csound?


aout = 0

for rep in range(100):
	
	pitch = rnd(1000) + 100

	asig oscil 1000 pitch 1

	aout = aout + asig

out aout

Date2006-02-20 22:57
FromIstvan Varga
SubjectRe: Control flow
AttachmentsNone  

Date2006-02-20 23:36
FromTobiah
SubjectRe: Control flow
> If you mean 100 parallel instances of the oscillator, then you can get
> that with a recursive user defined opcode

Right.  I thought of that after my post.  Thanks for the example,
it clears up some things for me about UDO's.  I tried them for
the first time today.

> is also not as efficient as just using macros):

How do you envision this working through macros?

Thanks,

Tobiah

Date2006-02-20 23:52
FromIstvan Varga
SubjectRe: Control flow
AttachmentsNone  

Date2006-02-21 09:40
FromVictor Lazzarini
SubjectRe: Control flow
Another possibility is to use a scripting language of your choice
to produce the code and write it into a file for csound to perform.

Python seems to be a popular choice. Tcl is another one (the
file gen.tcl in the sources examples/tclcsound directory demonstrates
it). You can use any language you like, but the advantage of Python or
Tcl is that your code can also control Csound performance (using the API).

Victor

At 23:52 20/02/2006, you wrote:
>On Tuesday 21 February 2006 00:36, Tobiah wrote:
>
> > How do you envision this working through macros?
>
>Of course, macros are only an option if the number of oscillators
>is constant (otherwise you would need the dynamic instantiation
>of oscillators that is possible with user defined opcodes and
>subinstruments). The example below is uglier than the previous one,
>but is faster.
>
>
>
>sr      =  48000
>ksmps   =  32
>nchnls  =  1
>
>#define OSCIL1 #
>
>atmp    oscils 1000, rnd(1000) + 100, 0
>         vincr aout, atmp
>
>#
>
>#define OSCIL10 #
>
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>$OSCIL1
>
>#
>
>#define OSCIL100 #
>
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>$OSCIL10
>
>#
>
>         instr 1
>
>aout    =  0
>$OSCIL100
>         out aout * 0.4
>
>         endin
>
>
>
>
>i 1 0 3
>e
>
>
>
>--
>Send bugs reports to this list.
>To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth 

Date2006-02-21 19:20
FromTobiah
SubjectRe: Control flow
Victor Lazzarini wrote:
> Another possibility is to use a scripting language of your choice
> to produce the code and write it into a file for csound to perform.
> 

I guess that's really the best option.  I've definitely been driven
to that in the past.  I invariably use a program to generate scores,
and it often makes sense to do that with orchestras as well. 

Date2006-03-02 04:26
FromIain Duncan
SubjectRe: Control flow
A further advantage to the approach Victor mentions is that in the
process you learn a language that becomes an invaluable tool for
actually writing instruments and scores. I personally like python
because the python extensions for gvim are fantastic and it is very easy
to work on my orc/sco files with python from within a gvim session.

If I were to go back five years to tell myself what to learn sooner I
would say gvim, python, regular expressions. Much coding time would be
saved. ;)

Iain

Victor Lazzarini wrote:
> Another possibility is to use a scripting language of your choice
> to produce the code and write it into a file for csound to perform.
> 
> Python seems to be a popular choice. Tcl is another one (the
> file gen.tcl in the sources examples/tclcsound directory demonstrates
> it). You can use any language you like, but the advantage of Python or
> Tcl is that your code can also control Csound performance (using the API).
> 
> Victor
> 
> At 23:52 20/02/2006, you wrote:
> 
>> On Tuesday 21 February 2006 00:36, Tobiah wrote:
>>
>> > How do you envision this working through macros?
>>
>> Of course, macros are only an option if the number of oscillators
>> is constant (otherwise you would need the dynamic instantiation
>> of oscillators that is possible with user defined opcodes and
>> subinstruments). The example below is uglier than the previous one,
>> but is faster.
>>
>> 
>> 
>> sr      =  48000
>> ksmps   =  32
>> nchnls  =  1
>>
>> #define OSCIL1 #
>>
>> atmp    oscils 1000, rnd(1000) + 100, 0
>>         vincr aout, atmp
>>
>> #
>>
>> #define OSCIL10 #
>>
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>> $OSCIL1
>>
>> #
>>
>> #define OSCIL100 #
>>
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>> $OSCIL10
>>
>> #
>>
>>         instr 1
>>
>> aout    =  0
>> $OSCIL100
>>         out aout * 0.4
>>
>>         endin
>>
>> 
>> 
>>
>> i 1 0 3
>> e
>>
>> 
>> 
>> -- 
>> Send bugs reports to this list.
>> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> 
> 
> Victor Lazzarini
> Music Technology Laboratory
> Music Department
> National University of Ireland, Maynooth

Date2006-03-02 08:40
FromVictor Lazzarini
SubjectRe: Control flow
Or emacs and elisp? The csound-x emacs mode is very useful.

At 04:26 02/03/2006, you wrote:
>A further advantage to the approach Victor mentions is that in the
>process you learn a language that becomes an invaluable tool for
>actually writing instruments and scores. I personally like python
>because the python extensions for gvim are fantastic and it is very easy
>to work on my orc/sco files with python from within a gvim session.
>
>If I were to go back five years to tell myself what to learn sooner I
>would say gvim, python, regular expressions. Much coding time would be
>saved. ;)
>
>Iain
>
>Victor Lazzarini wrote:
> > Another possibility is to use a scripting language of your choice
> > to produce the code and write it into a file for csound to perform.
> >
> > Python seems to be a popular choice. Tcl is another one (the
> > file gen.tcl in the sources examples/tclcsound directory demonstrates
> > it). You can use any language you like, but the advantage of Python or
> > Tcl is that your code can also control Csound performance (using the API).
> >
> > Victor
> >
> > At 23:52 20/02/2006, you wrote:
> >
> >> On Tuesday 21 February 2006 00:36, Tobiah wrote:
> >>
> >> > How do you envision this working through macros?
> >>
> >> Of course, macros are only an option if the number of oscillators
> >> is constant (otherwise you would need the dynamic instantiation
> >> of oscillators that is possible with user defined opcodes and
> >> subinstruments). The example below is uglier than the previous one,
> >> but is faster.
> >>
> >> 
> >> 
> >> sr      =  48000
> >> ksmps   =  32
> >> nchnls  =  1
> >>
> >> #define OSCIL1 #
> >>
> >> atmp    oscils 1000, rnd(1000) + 100, 0
> >>         vincr aout, atmp
> >>
> >> #
> >>
> >> #define OSCIL10 #
> >>
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >> $OSCIL1
> >>
> >> #
> >>
> >> #define OSCIL100 #
> >>
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >> $OSCIL10
> >>
> >> #
> >>
> >>         instr 1
> >>
> >> aout    =  0
> >> $OSCIL100
> >>         out aout * 0.4
> >>
> >>         endin
> >>
> >> 
> >> 
> >>
> >> i 1 0 3
> >> e
> >>
> >> 
> >> 
> >> --
> >> Send bugs reports to this list.
> >> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk
> >
> >
> > Victor Lazzarini
> > Music Technology Laboratory
> > Music Department
> > National University of Ireland, Maynooth
>--
>Send bugs reports to this list.
>To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth 

Date2006-03-03 05:37
FromIain Duncan
SubjectRe: Control flow
> Or emacs and elisp? The csound-x emacs mode is very useful.

Yeah, that would be the "other leading brand" tee hee. For my money
though, I like the fact that python is used both within csound and gvim,
as well as for extensions to many other audio apps. Yeah I know, common
lisp music, snd, etc. I'll learn it eventually too, all the elite haxors
tell ya to eat your lisp vitamins. ;)

Iain