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

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

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ていうのもあるかもしれないけど、ほんとうじゃろうか?という気がします。どちらかというとスコア生成に使いたいな。

1130852894*Python in Free Music Software

面白いものを見つけたので、CUT&PASTEで若干の整形。http://mail.python.org/pipermail/python-list/2004-October/248738.html より

pymps http://www.anti-particle.com/pymps.shtml

Pymps is the PYthon Music Playing System - a web based mp3/ogg jukebox. It's written in Python and utilises the PostgreSQL database.

m3ute2 http://sourceforge.net/projects/m3ute2/

m3ute2 is program for copying, moving, and otherwise organizing M3U playlists and directories. m3ute2 can also generate detailed reports about lists of files.

fmod http://www.fmod.org/

FMOD is the fastest, most powerful and easiest to use sound system on Windows, Linux, and Windows CE there is, and now Macintosh, GameCube, PS2 & XBox!. FMOD supports 3d sound, midi, mods, mp3, ogg vorbis, wma, aiff, recording, obstruction/occlusion, cd playback (analog or digital), cd ripping, mmx, internet streaming, dsp effects, spectrum analysis, user created samples and streams, synchronization. support, ASIO, EAX 2&3, C/C++/VB/Delphi and more.

pysonic http://pysonic.sourceforge.net/

pySonic is a Python wrapper around the high performance, cross platform FMOD sound library. You get all the benefits of the FMOD library, but in a Pythonic, object oriented package.

PMIDI http://sourceforge.net/projects/uncassist

The PMIDI library allows the generation of short MIDI sequences in Python code.The interface allows a programmer to specify songs, instruments, measures, and notes. Playback is handled by the Windows MIDI stream API so proper playback timing is handled by the OS rather than by client code. The library is especially useful for generating earcons.

PythonMIDI http://www.mxm.dk/products/public/pythonmidi

The Python Midi package is a collection of classes handling Midi in and output in the Python programming language.

PythonSound http://pythonsound.sourceforge.net/

The Python Sound Project aims to develop a productive community around Python, Csound and other synthesis engines as tools for algorithmic and computer assisted composition of electroacoustic music.

AthenaCL http://www.flexatone.net/athena.html

AthenaCL is an open-source, cross-platform, command-line program that functions as both a pitch (class) set theory utility (capable of both set and voice-leading modeling and analysis) as well as an object-orientated, Python-scriptable algorithmic front-end to Csound. Combining these features allows rapid and flexible scoring of Csound instruments with the elegance of Python-written texture algorithms. These simple algorithms allow the organization of pitch-materials by ordered content-groups, employing 12-tone set-class and pitch-class notations. Rather than writing its own music, AthenaCL is a compositional assistant: the algorithms create complex textural surfaces, leaving the limitless mixture and placement of these textures and their attributes entirely in the hands of the composer.

PyJack http://www.a2hd.com/software/

This is a Python C extension module which provides an interface to the Jack Audio Server. It is possible to access the Jack graph to perform port connections/disconnections, monitor graph change events, and to perform realtime audio capture and playback using Numeric Python arrays. This is released under the GPL.

Csound / CsoundVST http://www.csounds.com/

Csound is a programming language designed and optimized for sound rendering and signal processing. The language consists of over 450 opcodes - the operational codes that the sound designer uses to build "instruments" or patches. Although there are an increasing number of graphical "front-ends" for the language, you typically design and modify your patches using a word processor. Usually, you create two text files - a .orc (orchestra) file containing the "instruments," and a .sco (score) file containing the "notes." In Csound, the complexity of your patches is limited by your knowledge, interest, and need, but never by the language itself. For instance, a 22,050 oscillator additive synthesizer with 1024 stage envelope generators on each is merely a copy-and-paste operation. The same goes for a 1 million voice granular texture! Have you ever dreamed of sounds such as these? Well in Csound you can. And in Csound these dreams can come true!

dublin http://seqdublin.sourceforge.net/

Dublin is an object oriented framework to generate events in pd. Every objects is defined in python and then it interacts with other objects in pure-data. The goal is not only the provide an external python facility to pd but also to give the functionality of a sequencer. As for the user interface, it uses Idle, the Python IDE to edit and run event scripts.

MusicKit http://musickit.sourceforge.net/

The MusicKit is an object-oriented software system for building music, sound, signal processing, and MIDI applications. It has been used in such diverse commercial applications as music sequencers, computer games, and document processors. Professors and students in academia have used the MusicKit in a host of areas, including music performance, scientific experiments, computer-aided instruction, and physical modeling. Using the Python to Objective C bridge PyObjC enables applications and utilities to be written in Python, an interpreted object-oriented language.

GNU Solfege http://solfege.org/

GNU Solfege is a computer program written to help you practice ear training.It can be useful when practicing the simple and mechanical exercises.

Snack http://www.speech.kth.se/snack/

The Snack Sound Toolkit is designed to be used with a scripting language such as Tcl/Tk or Python. Using Snack you can create powerful multi-platform audio applications with just a few lines of code. Snack has commands for basic sound handling, such as playback, recording, file and socket I/O. Snack also provides primitives for sound visualization, e.g. waveforms and spectrograms. It was developed mainly to handle digital recordings of speech, but is just as useful for general audio. Snack has also successfully been applied to other one-dimensional signals. The combination of Snack and a scripting language makes it possible to create sound tools and applications with a minimum of effort. This is due to the rapid development nature of scripting languages. As a bonus you get an application that is cross-platform from start. It is also easy to integrate Snack based applications with existing sound analysis software.

Pygame http://pygame.org/

Pygame is a set of Python modules designed for writing games. It is written on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system.

Pyper http://www.stanford.edu/~andyszy/pyper/

Pyper is a musical development environment. It allows you to write Python scripts that generates music in real-time. Pyper uses QuickTime Musical Instruments for synthesis.

blue http://csounds.com/stevenyi/blue/index.html

blue is a java program for use with Csound. It's interface is much like a digital multitrack, but differs in that there timelines within timelines (polyObjects). This allows for a compositional organization in time that seems to me to be very intuitive, informative, and
flexible. soundObjects are the building blocks within blue's score timeline. soundObjects can be lists of notes, algorithmic generators, python script code, csound instrument definitions, and whatever plugins that are developed for blue. these soundObjects may be text
based, but they can be completely GUI based as well.

ID3.py http://id3-py.sourceforge.net/

This module allows one to read and manipulate so-called ID3 informational tags on MP3 files through an object-oriented Python interface.

id3reader.py http://www.nedbatchelder.com/code/modules/id3reader.html

Id3reader.py is a Python module that reads ID3 metadata tags in MP3 files. It can read ID3v1, ID3v2.2, ID3v2.3, or ID3v2.4 tags. It does not write tags at all.

PyID3 http://icepick.info/projects/pyid3/

pyid3 is a pure python library for reading and writing id3 tags (version 1.0, 1.1, 2.3, 2.4, readonly support for 2.2). What makes this better than all the others? Testing! This library has been tested against some 200+ MB of just tags.

OSC.py http://web.tiscali.it/mupuxeddu/csound/OSC.py

Python classes for OpenSoundControl library client functionality. The OSC homepage is at http://cnmat.cnmat.berkeley.edu/OpenSoundControl/

PMask

Python implementation of CMask, a stochastic event generator for Csound. http://web.tiscali.it/mupuxeddu/csound/index.html

winmidi.pyd http://www.sabren.net/code/python/midi/

A demo? of a python extension interfacing to the native windows midi libs. This was probably a development from this point http://www.sabren.net/rants/2000/01/20000129a.php3

PyMIDI http://www.hyperreal.org/~est/python/MIDI/

The MIDI module provides MIDI input parsers for Python.

Nam: not about music http://www.quitte.de/nam.html

A Python Extension for Digital Music Applications. Its purpose is Flexible realtime MIDI and audio processing and sequencing.

midi.py http://groups.google.com/groups?hl=en&selm=3C0F67FE.96E7CAE8%40alum.mit.edu

Python MIDI classes: meaningful data structures that represent MIDI events and other objects. You can read MIDI files to create such objects, or generate a collection of objects and use them to write a MIDI file.

hYPerSonic http://arrowtheory.com/software/hypersonic/index.html

hYPerSonic is for building and manipulating sound processing pipelines. It is designed for real-time control. It includes objects for oscillators, filters, file-io, soundcard and memory operations.

pyTTS http://www.sourceforge.net/projects/uncassist

pyTTS is a Python wrapper for the Microsoft Speech API (SAPI). The library requires Mark Hammond's win32com extension and SAPI 5.1+.

    • -

まずはAthenaCL

  1. http://www.flexatone.net/athena.htmlからたどって、athenaCL for Windows (any) download athenaCL.zip · 7.2 MBからダウンロード
  2. マニュアルを探って、http://www.flexatone.net/athenaDocs/www/sect-csound.htmをにconfiguring and using Csound というところを発見
  3. CPappコマンドで、csoundのありかを設定。ところが、「以前に説明した、ELnコマンドで作ったCsound fileが云々、、、3つ前に戻る。
  4. AthenaObject(パスインスタンス、テクスチャインスタンスやアクティブなオブジェクトをXMLで保存する)ちゅうのがあるらしい。で、それをAOl(AthenaObject loadということらしい)コマンドでロードしたり、そこに含まれているテクスチャーインスタンスをTIls(TextureInstance lsかな)確認したり。テクスチャーというのはいうなれば、『音色』なのかな?まだ自身なし。
  5. もひとつ重要概念として、イベントリスト(EventList)というのがある。これはいうなれば『スコア』とか『音符』。イベントリストを作り出すために、イベントモード(EventMode)、イベントアウトプット(EventOutput)という概念があるということ。イベントモードでは、csound,MIDIとかなんで記すのか?、イベントアウトプットでは何を書き出すのか?MIDI?csound?とか。EMlsでイベントモード表示。EOlsでイベントアウトプット表示。
  6. やっとELnでイベントリストを書くところに到着。コマンドを打つと!MIDIファイルとcsoundのorc, scoファイルが出来ている。しかもcsoundを実行するためのbatファイルまでご丁寧に!
  7. なぜか、バッチファイルは動かなくてその中身を手動で動かすと、めでたくWAVファイル作成。MIDIファイルも再生するとほぼ同じものが、、!!
  8. ELhでイベントリストを聞くことが出来た。

あんまりpythonとは関係なくなったけど、これはこれでよいのだ。スコア部分がMIDIファイルと置き換えることが出来たり、エンベロップを自由につけられたりするんならこれいいかも。と考えてしまう。

最終目標は、シーケンサーで主旋律などを作成し、MIDIに出力して、それをcsoundのスコアにしつつ、エンベロップなどをつけるとかして加工して、csoundレンダリングしてWAVファイルを作り、さらにそれを取り込んで、ミキシングして曲を仕上げ、というやりかたかな。今のところの目標は。