使用supercollider与Python [英] Using supercollider with python

查看:365
本文介绍了使用supercollider与Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做一些实时声音处理,我听到关于 supercollider

I want to do some real time sound processing and i heard about supercollider

和它看起来很棒,但我想坚持到蟒蛇就'正常'的编程问题。

and it looks great, but i want to stick to python as far as 'normal' programming is the issue.

有没有什么办法来加载一个python脚本作为一个模块supercollider或oposite?

Is there any way to load a python script as a module to supercollider or the oposite?

含义导入库到我的蟒蛇code和使用supercollider功能?

meaning importing a library to my python code and using the supercollider features?

我没有找到关于它的网站很多信息,因此任何帮助将是巨大的。

I did not find much info about it in the web so any help will be great.

推荐答案

我不知道一个Python实现SuperCollider的,但它是很容易的 OpenSoundControl 。下面是一些示例code,从<一个href=\"https://github.com/caseyanderson/workshops/blob/master/supercollider/python_SC/python_to_sc.md\"相对=nofollow>沿着这些线路,我写在艺术中心一类的教程,演示如何从Python的发送控制信息,以SC(此处用作音频引擎)。首先,SC部分:

I am not aware of a python implementation of SuperCollider, however it is very easy to communicate between SC and Python with OpenSoundControl. Here is some sample code, from a tutorial along these lines I wrote for a class at Art Center, that shows how to send control information from Python to SC (used here as the audio engine). First the SC part:

s.boot;

(
SynthDef( \sin, { | amp = 0.01, freq = 333, trig = 1 |
    var env, sig;
    env = EnvGen.kr( Env.asr( 0.001, 0.9, 0.001 ), trig, doneAction: 0 );
    sig = LFTri.ar( [ freq, freq * 0.999 ], 0.0, amp ) * env;
    Out.ar( [ 0 ], sig * 0.6 );
}).add;

h = Synth( \sin, [ \amp, 0.4 ] );

x = OSCFunc( { | msg, time, addr, port |
    var pyFreq;

    pyFreq = msg[1].asFloat;
    ( "freq is " + pyFreq ).postln;
    h.set( \freq, pyFreq );
}, '/print' );
)


现在的Python部分:


Now the Python part:

import OSC
import time, random
client = OSC.OSCClient()
client.connect( ( '127.0.0.1', 57120 ) )
msg = OSC.OSCMessage()
msg.setAddress("/print")
msg.append(500)
client.send(msg)


所以,你仍然需要写一些SC code(生成音频的类型,以及建立Python和SC之间的连接),但你可以做一切在蟒蛇。见链接教程页面深入解释显著以上(以及与SC工作的基本解释)。


So, you would still need to write some code in SC (to generate the type of audio, as well as to establish the connection between Python and SC), but you could do everything else in Python. See the link to the tutorial page for a significantly more in depth explanation (as well as a basic explanation of working with SC).

这篇关于使用supercollider与Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆