Csound Csound-dev Csound-tekno Search About

Python opcodes

Date2005-10-30 19:48
FromDavid Akbari
SubjectPython opcodes
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





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

/*--- ---*/


i1  0  10
s

i1  0  10

e





-David

Date2005-10-30 20:44
FromIstvan Varga
SubjectRe: Python opcodes
Attachmentspytest.csd  
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.

Date2005-10-30 21:20
FromDavid Akbari
SubjectRe: Python opcodes
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