trying to make my own mode-udo

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

trying to make my own mode-udo

Stefan Thomas-2
Dear community,
I'm trying to build my own udo, using the mode-opcode.
My aim:
reading the relative partial-frequencies from a table, as many as I desire, and stop reading, when the end of the table is reached.
First I've created a csd-file, as a template for the udo. But unfortunately the code doesn't work.
When I play the first note, I get:
PERF ERROR: tab_i off end
and I can't hear a sound.
Sorry, it's my first trial with iterative code, so maybee I'm a little thumb.
Here is my code:


<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma -b-1 -B 4096 -m0d
</CsOptions>
<CsInstruments>

sr    =    48000
ksmps     =     100
nchnls    =    2
0dbfs    =    1

giPartfreqs    ftgen        0, 0, 8, -2, 1, 2,3,4,5,6,7,8

instr 1   
iamp ampmidi 1
icps cpsmidi
iq = 200
ain mpulse iamp, 0
indx init 0
        inumparts = ftlen (giPartfreqs)
loop:
indx = indx+1
ipartfreq    tab_i        indx, giPartfreqs

ipartfreq    =        ipartfreq * icps
asig         mode    ain, ipartfreq, iq
    amix    init    0
amix        =  asig+amix
amix         = amix/inumparts
        loop_le    indx, 1, inumparts, loop

outs amix, amix

endin

</CsInstruments>
; ==============================================
<CsScore>
f 0 36


</CsScore>
</CsoundSynthesizer>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: trying to make my own mode-udo

Steven Yi
Hi Stefan,

There's a couple of issues here.  First thing is that you're doing an
init-time loop though you have performance-time code within it, which
should be avoided.  Using k-vars will ensure you are doing the loop at
performance time.  Also, you can not loop and call the same opcode
over and over when it has its own state.  Your goal is to run multiple
modes, but instead you are running the same mode opcode over and over.

I'd recommend reviewing two articles of mine regarding control flow:

http://www.csounds.com/journal/2006spring/controlFlow.html
http://www.csounds.com/journal/2006summer/controlFlow_part2.html

particularly part 2 which discusses recursion.  For this scenario, I
would recommend using recursion with a UDO if you are going to have
n-number of performance time modes.

I was working on a recursive mode instrument and made a UDO a couple
of months ago.  The instrument is not complete, but the code I used
for the UDO is here:

        opcode mode2,a,akkkko

ain, kfreq, kq, kampmultiplier, kqmultiplier, icounter xin

kcurrentfreq = kfreq * (icounter + 1)

itie tival

aout mode ain, kcurrentfreq, kq, itie
;printk 1, kcurrentfreq
if (icounter < 64) then

kfreqnext = kcurrentfreq + kfreq

if (kfreqnext < (sr * .2) && icounter < 64) then

aout2 mode2 ain * kampmultiplier, kfreq, kq * kqmultiplier,
kampmultiplier, kqmultiplier, icounter + 1
aout sum aout, aout2

endif

endif

xout aout

        endop

(This UDO is also still a work in progress).

Hope that helps and good luck!
steven


On Sun, Feb 12, 2012 at 4:46 PM, Stefan Thomas
<[hidden email]> wrote:

> Dear community,
> I'm trying to build my own udo, using the mode-opcode.
> My aim:
> reading the relative partial-frequencies from a table, as many as I desire,
> and stop reading, when the end of the table is reached.
> First I've created a csd-file, as a template for the udo. But unfortunately
> the code doesn't work.
> When I play the first note, I get:
> PERF ERROR: tab_i off end
> and I can't hear a sound.
> Sorry, it's my first trial with iterative code, so maybee I'm a little
> thumb.
> Here is my code:
>
>
> <CsoundSynthesizer>
> <CsOptions>
> -odevaudio -Ma -b-1 -B 4096 -m0d
> </CsOptions>
> <CsInstruments>
>
> sr    =    48000
> ksmps     =     100
> nchnls    =    2
> 0dbfs    =    1
>
> giPartfreqs    ftgen        0, 0, 8, -2, 1, 2,3,4,5,6,7,8
>
> instr 1
> iamp ampmidi 1
> icps cpsmidi
> iq = 200
> ain mpulse iamp, 0
> indx init 0
>         inumparts = ftlen (giPartfreqs)
> loop:
> indx = indx+1
> ipartfreq    tab_i        indx, giPartfreqs
>
> ipartfreq    =        ipartfreq * icps
> asig         mode    ain, ipartfreq, iq
>     amix    init    0
> amix        =  asig+amix
> amix         = amix/inumparts
>         loop_le    indx, 1, inumparts, loop
>
> outs amix, amix
>
> endin
>
> </CsInstruments>
> ; ==============================================
> <CsScore>
> f 0 36
>
>
> </CsScore>
> </CsoundSynthesizer>
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: trying to make my own mode-udo

Stefan Thomas-2
Dear Steven,
thanks for sending Your opcode to me.
I will try it, for sure, but first I will study Your articles.
To be honest, I've started reading it and then I thought "let's do it by myself", but that seems to be a bit too early.

Am 12. Februar 2012 18:00 schrieb Steven Yi <[hidden email]>:
Hi Stefan,

There's a couple of issues here.  First thing is that you're doing an
init-time loop though you have performance-time code within it, which
should be avoided.  Using k-vars will ensure you are doing the loop at
performance time.  Also, you can not loop and call the same opcode
over and over when it has its own state.  Your goal is to run multiple
modes, but instead you are running the same mode opcode over and over.

I'd recommend reviewing two articles of mine regarding control flow:

http://www.csounds.com/journal/2006spring/controlFlow.html
http://www.csounds.com/journal/2006summer/controlFlow_part2.html

particularly part 2 which discusses recursion.  For this scenario, I
would recommend using recursion with a UDO if you are going to have
n-number of performance time modes.

I was working on a recursive mode instrument and made a UDO a couple
of months ago.  The instrument is not complete, but the code I used
for the UDO is here:

       opcode mode2,a,akkkko

ain, kfreq, kq, kampmultiplier, kqmultiplier, icounter xin

kcurrentfreq = kfreq * (icounter + 1)

itie tival

aout mode ain, kcurrentfreq, kq, itie
;printk 1, kcurrentfreq
if (icounter < 64) then

kfreqnext = kcurrentfreq + kfreq

if (kfreqnext < (sr * .2) && icounter < 64) then

aout2 mode2 ain * kampmultiplier, kfreq, kq * kqmultiplier,
kampmultiplier, kqmultiplier, icounter + 1
aout sum aout, aout2

endif

endif

xout aout

       endop

(This UDO is also still a work in progress).

Hope that helps and good luck!
steven


On Sun, Feb 12, 2012 at 4:46 PM, Stefan Thomas
<[hidden email]> wrote:
> Dear community,
> I'm trying to build my own udo, using the mode-opcode.
> My aim:
> reading the relative partial-frequencies from a table, as many as I desire,
> and stop reading, when the end of the table is reached.
> First I've created a csd-file, as a template for the udo. But unfortunately
> the code doesn't work.
> When I play the first note, I get:
> PERF ERROR: tab_i off end
> and I can't hear a sound.
> Sorry, it's my first trial with iterative code, so maybee I'm a little
> thumb.
> Here is my code:
>
>
> <CsoundSynthesizer>
> <CsOptions>
> -odevaudio -Ma -b-1 -B 4096 -m0d
> </CsOptions>
> <CsInstruments>
>
> sr    =    48000
> ksmps     =     100
> nchnls    =    2
> 0dbfs    =    1
>
> giPartfreqs    ftgen        0, 0, 8, -2, 1, 2,3,4,5,6,7,8
>
> instr 1
> iamp ampmidi 1
> icps cpsmidi
> iq = 200
> ain mpulse iamp, 0
> indx init 0
>         inumparts = ftlen (giPartfreqs)
> loop:
> indx = indx+1
> ipartfreq    tab_i        indx, giPartfreqs
>
> ipartfreq    =        ipartfreq * icps
> asig         mode    ain, ipartfreq, iq
>     amix    init    0
> amix        =  asig+amix
> amix         = amix/inumparts
>         loop_le    indx, 1, inumparts, loop
>
> outs amix, amix
>
> endin
>
> </CsInstruments>
> ; ==============================================
> <CsScore>
> f 0 36
>
>
> </CsScore>
> </CsoundSynthesizer>
>
>


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: trying to make my own mode-udo

Tito Latini
You follow the Steven's suggestions and, if you want to play with your
example, remember that the `tab' opcode doesn't check the index validity.
You have to use an index between 0 and `inumparts - 1' and not between
1 and `inumparts' (a rapid fix: `loop_lt' instead of `loop_le').

tito

On Sun, Feb 12, 2012 at 06:08:56PM +0100, Stefan Thomas wrote:

> Dear Steven,
> thanks for sending Your opcode to me.
> I will try it, for sure, but first I will study Your articles.
> To be honest, I've started reading it and then I thought "let's do it by
> myself", but that seems to be a bit too early.
>
> Am 12. Februar 2012 18:00 schrieb Steven Yi <[hidden email]>:
>
> > Hi Stefan,
> >
> > There's a couple of issues here.  First thing is that you're doing an
> > init-time loop though you have performance-time code within it, which
> > should be avoided.  Using k-vars will ensure you are doing the loop at
> > performance time.  Also, you can not loop and call the same opcode
> > over and over when it has its own state.  Your goal is to run multiple
> > modes, but instead you are running the same mode opcode over and over.
> >
> > I'd recommend reviewing two articles of mine regarding control flow:
> >
> > http://www.csounds.com/journal/2006spring/controlFlow.html
> > http://www.csounds.com/journal/2006summer/controlFlow_part2.html
> >
> > particularly part 2 which discusses recursion.  For this scenario, I
> > would recommend using recursion with a UDO if you are going to have
> > n-number of performance time modes.
> >
> > I was working on a recursive mode instrument and made a UDO a couple
> > of months ago.  The instrument is not complete, but the code I used
> > for the UDO is here:
> >
> >        opcode mode2,a,akkkko
> >
> > ain, kfreq, kq, kampmultiplier, kqmultiplier, icounter xin
> >
> > kcurrentfreq = kfreq * (icounter + 1)
> >
> > itie tival
> >
> > aout mode ain, kcurrentfreq, kq, itie
> > ;printk 1, kcurrentfreq
> > if (icounter < 64) then
> >
> > kfreqnext = kcurrentfreq + kfreq
> >
> > if (kfreqnext < (sr * .2) && icounter < 64) then
> >
> > aout2 mode2 ain * kampmultiplier, kfreq, kq * kqmultiplier,
> > kampmultiplier, kqmultiplier, icounter + 1
> > aout sum aout, aout2
> >
> > endif
> >
> > endif
> >
> > xout aout
> >
> >        endop
> >
> > (This UDO is also still a work in progress).
> >
> > Hope that helps and good luck!
> > steven
> >
> >
> > On Sun, Feb 12, 2012 at 4:46 PM, Stefan Thomas
> > <[hidden email]> wrote:
> > > Dear community,
> > > I'm trying to build my own udo, using the mode-opcode.
> > > My aim:
> > > reading the relative partial-frequencies from a table, as many as I
> > desire,
> > > and stop reading, when the end of the table is reached.
> > > First I've created a csd-file, as a template for the udo. But
> > unfortunately
> > > the code doesn't work.
> > > When I play the first note, I get:
> > > PERF ERROR: tab_i off end
> > > and I can't hear a sound.
> > > Sorry, it's my first trial with iterative code, so maybee I'm a little
> > > thumb.
> > > Here is my code:
> > >
> > >
> > > <CsoundSynthesizer>
> > > <CsOptions>
> > > -odevaudio -Ma -b-1 -B 4096 -m0d
> > > </CsOptions>
> > > <CsInstruments>
> > >
> > > sr    =    48000
> > > ksmps     =     100
> > > nchnls    =    2
> > > 0dbfs    =    1
> > >
> > > giPartfreqs    ftgen        0, 0, 8, -2, 1, 2,3,4,5,6,7,8
> > >
> > > instr 1
> > > iamp ampmidi 1
> > > icps cpsmidi
> > > iq = 200
> > > ain mpulse iamp, 0
> > > indx init 0
> > >         inumparts = ftlen (giPartfreqs)
> > > loop:
> > > indx = indx+1
> > > ipartfreq    tab_i        indx, giPartfreqs
> > >
> > > ipartfreq    =        ipartfreq * icps
> > > asig         mode    ain, ipartfreq, iq
> > >     amix    init    0
> > > amix        =  asig+amix
> > > amix         = amix/inumparts
> > >         loop_le    indx, 1, inumparts, loop
> > >
> > > outs amix, amix
> > >
> > > endin
> > >
> > > </CsInstruments>
> > > ; ==============================================
> > > <CsScore>
> > > f 0 36
> > >
> > >
> > > </CsScore>
> > > </CsoundSynthesizer>
> > >
> > >


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email [hidden email] with body "unsubscribe csound"

Loading...