Python opcodes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Python opcodes

David Akbari
Hi List,

I recently was building and getting into the Python opcodes but for
some reason I keep getting the following error. I don't always get it,
just sometimes.

Fatal Python error: PyThreadState_Get: no current thread
Csound tidy up: Abort trap
inactive allocs returned to freespace
end of score.              overall amps:      0.0      0.0
            overall samples out of range:        0        0
0 errors in performance

What does this mean ? Attached is the .CSD file that I was using

<CsoundSynthesizer>
<CsInstruments>


sr = 44100
kr = 441
ksmps = 100
nchnls = 2

gifn1 ftgen 0, 0, 16384, 10, 1

        pyruni {{
                from random import random, choice

                class GetNumberFromPool:
                        def __init__(self, e, begin=0, end=100, step=1):
                                self.pool = [i ** e for i in range(begin, end, step)

                        def __call__(self, n, p):
                                #substitute an old number with the number ?
                                if random() < p:
                                        i = choice(range(len(pool)))
                                        pool[i] = n

                                # return a random number from the pool
                                return choice(pool)

                get_number_from_pool1 = GetNumberFromPool(1.3)
                get_number_from_pool2 = GetNumberFromPool(1.5, 50, 250, 2)
}}

/*--- ---*/

                instr 1

k1 oscil 1, 3, 1
k3 oscil 1, 2.5, 1
               
k2 pycall1 "get_number_from_pool1", k1, 0.5
k4 pycall1 "get_number_from_pool2", k3, 0.5

        printk 0.25, k2
        printk 0.25, k4

                endin

/*--- ---*/
</CsInstruments>
<CsScore>
i1  0  10
s

i1  0  10

e
</CsScore>

</CsoundSynthesizer>


-David

--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Python opcodes

Istvan Varga
David Akbari wrote:

> I recently was building and getting into the Python opcodes but for some
> reason I keep getting the following error. I don't always get it, just
> sometimes.
>
> Fatal Python error: PyThreadState_Get: no current thread
> Csound tidy up: Abort trap

You need to call pyinit from the orchestra header before using
the python opcodes. I also had to fix a few errors to make the
CSD file work, and the changed version is attached.
Not directly related to this issue, but I also had some errors
related to Python libraries on Linux (perhaps some changes to
SConstruct will be needed), and I noticed that the opcodes do
not terminate the current note on init/perf errors.

<CsoundSynthesizer>
<CsInstruments>
sr        =    44100
kr        =    441
ksmps     =    100
nchnls    =    2

gifn1    ftgen    0, 0, 16384, 10, 1

pyinit

pyruni {{
from random import random, choice

class GetNumberFromPool:
    def __init__(self, e, begin=0, end=100, step=1):
        self.pool = [i ** e for i in range(begin, end, step)]

    def __call__(self, n, p):
        #substitute an old number with the number ?
        if random() < p:
            i = choice(range(len(self.pool)))
            self.pool[i] = n

        # return a random number from the pool
        return choice(self.pool)

get_number_from_pool1 = GetNumberFromPool(1.3)
get_number_from_pool2 = GetNumberFromPool(1.5, 50, 250, 2)
}}

/*--- ---*/

        instr    1

k1    oscil    1, 3, gifn1
k3    oscil    1, 2.5, gifn1
       
k2    pycall1    "get_number_from_pool1", k1, 0.5
k4    pycall1    "get_number_from_pool2", k3, 0.5

    printk    0.25, k2
    printk    0.25, k4

        endin

/*--- ---*/
</CsInstruments>
<CsScore>
i1  0  10
s

i1  0  10

e
</CsScore>

</CsoundSynthesizer>
Reply | Threaded
Open this post in threaded view
|

Re: Python opcodes

David Akbari

On Oct 30, 2005, at 3:44 PM, Istvan Varga wrote:

> You need to call pyinit from the orchestra header before using
> the python opcodes.

Thanks a million, Istvan!

It's always these things that you never expect that turn out to be the
problem...


Many thanks,


-David

--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]