いらないモノ、ひつようなモノ

書籍、音楽、そして若干のテクノロジー

csoundのなかでpythonのコードが使える?!

Fatal Python error: PyThreadState_Get: no current thread

このエラーが出続けて、出続けて。10月31日悩んでいました。検索しても答えが出てこない、、!!解らないので気晴らしーと、思いつつ、今日csound MLを見ると、「Python opcodes」というタイトル。もしやと思い見てみると、同じ悩みの人が、2005年10月31日 04:48:45にメールを出していた!!!まさに、ほぼ同時。シンクロニチー。
すぐにcsound5作者のIstvan Vargaからの回答。

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

そうだ!確かに!やってみるとあっけねー

<CsoundSynthesizer>
<CsInstruments>
sr=44100
ksmps=1
nchnls=2
giSinusoid	ftgen	0,	0, 8192, 10,	1
pyinit ;これこれ
pyruni "import random"
	instr 1	;Sound
        pylruni "message = 'a private random number: %f' % random.random()"
        pylrun  "print message"
	endin
</CsInstruments>
<CsScore>
i1	0.0	2.0	
e
</CsScore>
</CsoundSynthesizer>

彼のありがとうメールには、「It's always these things that you never expect that turn out to be the problem...」そうだよねー。確かに確かに。

ここまでやりましたが、楽器を作るのにpythonていうのもあるかもしれないけど、ほんとうじゃろうか?という気がします。どちらかというとスコア生成に使いたいな。