Side thread: Sndobj, Python, and RT-safe

Everything and anything, but nothing about the LinuxSampler project.
User avatar
Consul
Moderator
Posts: 189
Joined: Wed Jan 23, 2008 11:19 pm
Location: Port Huron, Michigan, USA
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by Consul » Sat Mar 01, 2008 7:21 pm

That's where I'll have to play around, because I have my own ideas for modulations, filters, and oscillators that SndObj may or may not be a help in implementing.

Here's the basic idea:

Each voice has four cubic Bezier-curve oscillators, which allow the user to draw a waveform using points and handles. To avoid aliasing, the handles are moved closer to the points they control to round the waveform as the pitch goes higher. The points themselves can also be modulated by the user (for PWM-like effects).

The output can then be routed in several ways to any or all of two (or four, haven't decided yet) filters, before heading out to a final amp. I was going to build the filters with integrated non-linear waveshapers in the feedback path to simulate the non-linear characteristics of different analog filters (this would require oversampling).

I also wanted to allow FM routing between the four oscillators, if the user wants. AM routing might be possible, too, and would also require oversampling. Also, various effects, like a ring modulator (which would, yet again, need to be oversampled) could be included.

I'm kind-of aiming for something not unlike Absynth, but with a few twists. I have an idea of how to handle the routing, by storing the current value of a particular stream in a variable which can be used as input for another function at the whim of the GUI, which is basically the Csound method.

Anyway, that's my vision, as stated in text the best I can for now.
Darren Landrum

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by dahnielson » Sat Mar 01, 2008 7:28 pm

Well, you should look into how the SndObj classes are implemented and maybe write your own bezier-oscillator as an experiment if it can't be constructed out of the objects already provided by the library. All message passing and routing of signals between objects are already solved by SndObj.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
Consul
Moderator
Posts: 189
Joined: Wed Jan 23, 2008 11:19 pm
Location: Port Huron, Michigan, USA
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by Consul » Sat Mar 01, 2008 9:30 pm

That's just what I was thinking, actually. I'm going through the SndObj docs now. It looks like a very thought-out system, with all sorts of usable stuff. It'll probably even make the multirate stuff easier.

This post really had no other purpose than testing my new avatar. :D
Darren Landrum

User avatar
Consul
Moderator
Posts: 189
Joined: Wed Jan 23, 2008 11:19 pm
Location: Port Huron, Michigan, USA
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by Consul » Thu Mar 13, 2008 2:05 am

Okay, allow me to repurpose this thread to figure out why I can't get sndobj's Python bindings to work. I keep getting this error:

Code: Select all

bash-3.2# python sndobjtest.py
Traceback (most recent call last):
  File "sndobjtest.py", line 1, in <module>
    import sndobj
ImportError: No module named sndobj
Now, I know what that means, but I don't really know how to track down what the issue is. I have swig installed, but for some reason, Python can't find the sndobj library. I honestly don't know how this works. Do I point Python right to the C library in usr/local? Or is there something else that is supposed to be installed in a place Python knows about?

EDIT: Okay, I found the sndobj.py module that needs to be imported, but now it's unable to locate libsndobj.so. :roll: Well, it's some kind of progress anyway. Is there anywhere I can put sndobj.py where python can always find it by default?

Then I need to figure out how to get Python to find libsndobj.

EDIT: Looks like I figured it out. Arch doesn't use /usr/local at all, so I had to copy everything in /usr/local/lib to /usr/lib. Strange, but it works now.

This is going to be a constant source of irritation for me as I continue to use Arch, I can tell, seeing as every source package out in Cyberspace defaults to /usr/local for its install location. Why Arch can't just follow that standard I have no clue.

A place I can put that sndobj.py module where Python will always look for it would be really nice still.

EDIT: Nevermind, I figured this out, too. In fact, this entire post has absolutely no point now. I'm not going to delete it, though, as I like to have a record that I made an effort. :mrgreen:
Darren Landrum

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by dahnielson » Mon Apr 28, 2008 10:14 pm

:oops:

Ok, I feel a little bit embarrassed for not having pointed this out earlier simply because I forgot about its existence. One big non-RT-safe feature of pure Python is: garbage collection. Of course that generally doesn't matter in the case of SndObj, as mentioned earlier, since it is run in its own native C++ thread outside the mechanics of Python.
Anders Dahnielson

Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux

User avatar
Consul
Moderator
Posts: 189
Joined: Wed Jan 23, 2008 11:19 pm
Location: Port Huron, Michigan, USA
Contact:

Re: Side thread: Sndobj, Python, and RT-safe

Post by Consul » Mon Apr 28, 2008 11:04 pm

It still seems to me that any code can be called "RT-safe" as long as it runs on a fast enough machine. Still, RT-safe has a specific definition, and that's what I was after. Thanks for the help.
Darren Landrum

Post Reply