electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  mosc Back on the air tonight - Twyndyllyngs
Please visit the chat
 Forum index » Discussion » Composition
glass-bead game
Post new topic   Reply to topic Moderators: elektro80
Page 4 of 7 [155 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Sat Jun 14, 2008 3:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, crap, it didn't work anyway. I don't know my way around Python so I don't know how to fix this.

The chessboard comes up but it's empty (no pieces). The "Exit GUI" button works at least.

Also, how do you configure the port to which python sends OSC?

I'm pretty excited about all this, btw.

James

Code:
>>> from chess.chessboard import *
>>> start('192.168.0.111')
MAXPIXEL is 894
192.168.0.111 - - [14/Jun/2008 18:15:20] "POST /RPC2 HTTP/1.0" 200 -
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "chess/chessboard.py", line 638, in start
    startclient(srvripaddr, color, debug)
  File "chess/chessboard.py", line 87, in startclient
    mainframe = Mainframe(color, ip, debug)
  File "chess/chessboard.py", line 145, in __init__
    ipcnxn.subscribe(self.myipaddr)
  File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
  File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/xmlrpclib.py", line 1147, in request
    return self._parse_response(h.getfile(), sock)
  File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/xmlrpclib.py", line 1286, in _parse_response
    return u.close()
  File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/xmlrpclib.py", line 744, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault>

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat Jun 14, 2008 4:15 pm    Post subject: Reply with quote  Mark this post and the followings unread

My mind is so confused right now that I cannot even follow the posts. Is this a ChucK vs SuperCollider battle? My software can beat up your software, nah nah! I'm a complex man who need simple instructions: just tell me what you want for any additional ChucKian contribution and I'll give it a shot. Spell it out clearly and I can probably do it.

BTW, I just went to a bar mitzvah (sp?) (i'm not Jewish) where I had about four or five long island iced teas, a nap, and now I'm making a sizeable dent into an 18-pack of Budweiser so don't expect much programming for another day or so! Tweet! The referee just gave a ten yard penalty to the ChucK team for open and unshameful drunkenness!

_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sat Jun 14, 2008 4:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
My mind is so confused right now that I cannot even follow the posts. Is this a ChucK vs SuperCollider battle? My software can beat up your software, nah nah! I'm a complex man who need simple instructions: just tell me what you want for any additional ChucKian contribution and I'll give it a shot. Spell it out clearly and I can probably do it.


I really don't think so. It's more of a "OSC as a abstraction layer" thing. We all like chess, AI makes the interface and various people can make sonifications for it, thanks to OSC. You can make one, James can make one and I'd like to try my hand at it as well.

If it would be a battle we would likely be losing it because OSC in ChucK right now seems in urgent need of lots of love and attention, I think we have like 4 open bugs there alone, some of which are quite structural. Bug squash


Quote:
BTW, I just went to a bar mitzvah (sp?) (i'm not Jewish) where I had about four or five long island iced teas, a nap, and now I'm making a sizeable dent into an 18-pack of Budweiser so don't expect much programming for another day or so! Tweet! The referee just gave a ten yard penalty to the ChucK team for open and unshameful drunkenness!


"18 pack"? Don't you Americans have crates? Or trays?

I'm having wine here, it's a Saturday night so that should be ok.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sat Jun 14, 2008 5:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Oh... I see, the readme says to cd to chess/chess, but really it should be one directory higher...

Listening from ipaddr = 192.168.0.111, ipport = 4000

Cool

Never mind...
James

My PYTHONPATH is set and exported to the upper chess directory, which works when you run from the lower chess directory. It should actually work from anywhere if PYTHONPATH is set correctly, but it doesn't for me. Haven't gotten to that one. Anyway, wherever it works, you'll want a copy of the avatars/ directory in your working directory if you want the avatars. You don't need them.

Well, I got some nice sounds out of your SC patch after starting to grok how SC's command interface works and also setting my ASIO sound output correctly. Thanks!

In ChucK, I sort of got Envelope to ramp the gain setting as I am doing in MSP, but the ramp isn't getting rid of the noise. Also I seem to be losing the low end in the generated sound, and am eating quite a bit of CPU.

I've got more studying to do on both languages! This exercise has certainly whetted my appetite for adding more timbre banks and associating chess-piece-type with timbre. Jury is still out on the sound language, although SC rings pretty nicely so far Very Happy

I think I'll play some banjo for a change. Going orienteering on Father's Day tomorrow. Ciao!

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sat Jun 14, 2008 6:08 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
My mind is so confused right now that I cannot even follow the posts. Is this a ChucK vs SuperCollider battle? My software can beat up your software, nah nah! I'm a complex man who need simple instructions: just tell me what you want for any additional ChucKian contribution and I'll give it a shot. Spell it out clearly and I can probably do it.

No battle Very Happy James and I have been having this discussion off and on for months. This is the first opportunity to make it concrete. I want to evaluate both ChucK and SC to some extent before I commit myself, partly because I don't know what's important to me yet. Engineering trade-offs. I like Max/MSP ugens, but for me at least, putting in control and steering logic is cumbersome in Max. I thought I liked ChucK's syntax and language constructs a little better than SC, but that's probably superficial. Ge doesn't claim that ChucK is heavily optimized, just the opposite, at least when I took his 3 hour class at EM2007 along with a room full of other people who stayed for the full session. It may turn out I need a mature, optimized sound engine more than I need the language. Don't know yet.

In addition to what Kassen said, there is the matter of making the chess OSC as general as possible by running it against multiple sound generators. For example, that word "list" shows up in the OSC packets because Max hard codes that to represent passing a list of values via OSC. SC and ChucK don't need to use the word "list," but if I want to make this work with various sound generators, then "list" becomes the common-denominator-keyword. Stuff like that.

The only bake-off aspect of this is that, like everyone else, I can only be proficient in so many programming languages, so ultimately I have to pick one. In my day job I regularly jump around between Python, Java, C and C++, with just enough Perl thrown in to annoy me Mad I keep coding Python syntax into java and vice versa lately, which makes for more re-compiles. That is why I am doing my control logic in Python -- tons of libraries and other facilities, and I am used to it -- and learning how to just knock out tones in ChucK and/or SC and/or Max. My only real criterion is using whatever sounds best with the least effort, in that order. thanks for your help in taking ChucK for a test drive!

Also, I'll be teaching a grad course in programming language theory next spring, and I have to figure out which application-oriented music language to foist on the unsuspecting students. Twisted Evil

Have a nice Father's Day!

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jun 15, 2008 4:43 am    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:

In ChucK, I sort of got Envelope to ramp the gain setting as I am doing in MSP, but the ramp isn't getting rid of the noise. Also I seem to be losing the low end in the generated sound, and am eating quite a bit of CPU.


Erm.... what? I think something is wrong there, this should be noise-less and cheap on the cpu. What are you doing and how?

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sun Jun 15, 2008 5:58 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Well, crap, it didn't work anyway. I don't know my way around Python so I don't know how to fix this.

The chessboard comes up but it's empty (no pieces). The "Exit GUI" button works at least.

Also, how do you configure the port to which python sends OSC?

I'm pretty excited about all this, btw.

James

I am guessing that the server cannot find the music plugin when you enter testd() into the server window. Assuming you have two terminal windows open, one for starting the server, and then one for starting the GUI-client,

1. Make sure PYTHONPATH is set and exported to the TOP chess directory in BOTH shells. On Cygwin under XP mine looks like this:

$ env | grep PYTHONPATH
PYTHONPATH=c:\chess;c:\gcs

dale@midime ~
$ export | grep PYTHONPATH
declare -x PYTHONPATH="c:\\chess;c:\\gcs"


2. In the terminal windows themselves you have to be sitting in the BOTTOM chess window, i.e., chess/chess/, because the server currently looks for music plugins there. I need to clean this up to work entirely off environment variables so the current directory doesn't matter.

from one chess/chess/ window:

python
from chess.chessgame import *
testd() # This pulls in the aheadSineInterpreter.py music plugin.

3. From the other terminal window:

python
from chess.chessboard import *
start(IPADDR-PRINTED-BY-SERVER)

The ports are hard coded. Here is the OSC/UDP port definition:

$ grep 7401 *.py
chessgame.py:t = tonegen('localhost', 7401)

Here are the XML/RPC/TCP ports that the GUI uses to call the server and the server uses to send update events to the GUI. It's publish and subscribe -- you can connect multiple GUIs to a server session:

$ grep "400[01]$" *.py
chessboard.py:SERVERPORT = 4000
chessboard.py:CLIENTPORT = 4001
chessgame.py:SERVERPORT = 4000
chessgame.py:CLIENTPORT = 4001

I need to put all of this stuff into a config file at some point.

Hope this helps. I'm glad you are having fun with it. me, too. banana

I'm loking forward to adding some more voices. Right now the bank number is 1 bit, value 0 when there is a support relationship and value 1 when conflict, so currently sine for support and triangle for conflict. Conflict generates a minor third transform of that note's pitch as well. I plan to try encoding the piece type (pawn, queen, etc.) in the three bits above that bottom bit, so the sound generator can optionally assign a timbre to each piece, with distinct timbre for support and conflict. The sound generator can just mask off these bits if the patch doesn't use them.

I'm being called for Father's day breakfast, then it's off to the woods for orienteering. sunny Have a good day.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sun Jun 15, 2008 6:48 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:

Erm.... what? I think something is wrong there, this should be noise-less and cheap on the cpu. What are you doing and how?

Here is the description from above, which Inventor implemented excatly as described.
Quote:
// Launch as a sound generator for chessgame.py as of
// 13 June 2008. This OSC type format is patch specific.
// There are 2 banks of ugens with 32 ugens each.
// Bank 0 generates sines and bank 1 triangles in the
// initial test. Incoming OSC fields are:
// bank(i) 0 or 1 for sine or triangle bank respectively
// osc(i) oscillator number 0..31 in that bank
// freq(f) frequency or -1.0 to shut it off
// phase(f) 0.0 .. 1.0 or -1.0 to shut it off (redundant)
// leftampl left channel amplitude 0.0 to 1.0
// rightampl right channel amplitude 0.0 to 1.0
// The amplitudes are 0.0 when freq is -1.0 for shut off.
// The output of all ACTIVE oscillators should be summed and
// normalized so that running many oscillators does not exceed
// some threshold. This entails some scaling.


I added Envelopes to ramp the gain changes for each oscillator to get rid of the noise, because I had to do something similar in MSP, but it didn't help. The code with my changes is attached. In MSP the delay on the gain ramp was set at 100 ms, but here it's down to 10 ms because I was playing around with it.

Is there any way to free an oscillator when it's not in use, and allocate it only as needed? There wasn't in MSP, hence the original description. But, the chess program never uses 64 oscillators at a time.

Thanks in advance for any suggestions.


chesstones.ck
 Description:

Download
 Filename:  chesstones.ck
 Filesize:  10.33 KB
 Downloaded:  163 Time(s)


_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Sun Jun 15, 2008 6:53 am    Post subject: Reply with quote  Mark this post and the followings unread

I see... I think my problem is that I forgot to run testd(). Embarassed

Anyway, there's still a problem:

Code:
>>> testd()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "chess/chessgame.py", line 796, in testd
    start('aheadSineInterpreter')
  File "chess/chessgame.py", line 784, in start
    m = ifactory(classname,t,None)
  File "chess/interpreter.py", line 253, in ifactory
    raise Exception, "class not found: " + classname
Exception: class not found: aheadSineInterpreter
>>>
dewdrops-computer:~/Downloads/chess dewdrop$ echo $PYTHONPATH
/Users/dewdrop/Downloads/chess


I also tried setting pythonpath to /Users/dewdrop/Downloads/chess:/Users/dewdrop/Downloads/chess/chess but no dice, same error.

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jun 15, 2008 7:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:

I added Envelopes to ramp the gain changes for each oscillator to get rid of the noise, because I had to do something similar in MSP, but it didn't help.


At first glance it appears to me that you are getting the envelope's .value() and writing that to the Gain's .gain() manually and periodically. I'm not sure this is a intentional choice but that's almost certainly where your noise comes from. It would be preferable in nearly all situations to instead set the gain to multiply (and thus act as a VCA).

Code:

//signal chain
SinOsc signal => Gain vca => dac;

//amplitude modulation
Step unity_gain => Envelope ramp => vca;

//3 means multiply
3 => vca.op;

//this gets multiplied with ramp's value
//hence, by setting it to a static "1" we get ramp.value() at the
//Ugen output.
true => unity_gain.next;

//start with silence
0 => ramp.value;

//I really prefer this to the unit-less "time" function
second => ramp.duration;

//noise-free volume modulation
1 => ramp.target;
second => now;
0 => ramp.target;
second => now;

//we can break it off in mid-modulation as well
1 => ramp.target;
.5::second => now;
0 => ramp.target;
second => now;
<<<"bye">>>;


Quote:

The code with my changes is attached. In MSP the delay on the gain ramp was set at 100 ms, but here it's down to 10 ms because I was playing around with it.


Yes, I see. As noted above I'd use the ".duration" version instead as I find it a lot more readable then the STK's unit-less inputs.... but of cource that doesn't realy make any functional difference.


Quote:
Is there any way to free an oscillator when it's not in use, and allocate it only as needed? There wasn't in MSP, hence the original description. But, the chess program never uses 64 oscillators at a time.

Thanks in advance for any suggestions.


Sure, you could simply disconnect it like this;
Code:

//connect
SinOsc s => dac;
second => now;

//disconnect (or "unchuck")
s =< dac;
second => now;

//connect
s => dac;
second => now;


A Ugen that's not connected to anything (and hence not "ticked" by the "sample sucking" dac or blackhole) won't cost any cpu. Hope that helps or at least clarifies.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sun Jun 15, 2008 12:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Anyway, there's still a problem:

I'll steal my MacBook pro back from my wife and see what I can find. I have tested an early version of the GUI there, but never the server. I should get to it Tuesday. Tomorrow is a travel day.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Sun Jun 15, 2008 12:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks, Kassen. I am committed to getting this to work, and your suggestions will help.

Take care.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jun 15, 2008 1:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hmmmmm, I was going to add some hopefully helpful insight when I remembered it could be done much simpler as well. In fact now I wonder why we were making it that complicated at all.

Check this;
Code:

SinOsc s => Envelope ramp => dac;
second => ramp.duration;

1 => ramp.target;
second => now;
0 => ramp.target;
second => now;


That would do as well. No noise, less CPU and more simple.

*hits head*

oops.
:¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 6:43 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
I see... I think my problem is that I forgot to run testd(). Embarassed

Anyway, there's still a problem:

Code:
>>> testd()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "chess/chessgame.py", line 796, in testd
    start('aheadSineInterpreter')
  File "chess/chessgame.py", line 784, in start
    m = ifactory(classname,t,None)
  File "chess/interpreter.py", line 253, in ifactory
    raise Exception, "class not found: " + classname
Exception: class not found: aheadSineInterpreter
>>>
dewdrops-computer:~/Downloads/chess dewdrop$ echo $PYTHONPATH
/Users/dewdrop/Downloads/chess


I also tried setting pythonpath to /Users/dewdrop/Downloads/chess:/Users/dewdrop/Downloads/chess/chess but no dice, same error.

James

James, I just duplicated this problem. You need to be sitting in the bottom chess directory; it appears you were sitting in the top. Also, make sure the PYTHONPATH to the top chess directory is exported from the shell -- that appears to be OK in your case.

Sorry for the confusion. I am going to test this on OSX today, will fix and post and bugs I see. It should be OK.

Code:

$ cd c:/chess # THIS FAILS

dale@midime /cygdrive/c/chess
$ pwd
/cygdrive/c/chess
dale@midime /cygdrive/c/chess
$ python
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from chess.chessgame import *

BOARD PRINTOUT

Listening from ipaddr = 192.168.1.3, ipport = 4000
>>> testd()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "chess\chessgame.py", line 796, in testd
    start('aheadSineInterpreter')
  File "chess\chessgame.py", line 784, in start
    m = ifactory(classname,t,None)
  File "chess\interpreter.py", line 253, in ifactory
    raise Exception, "class not found: " + classname
Exception: class not found: aheadSineInterpreter
>>> ^Z


dale@midime /cygdrive/c/chess
$ cd ./chess

dale@midime /cygdrive/c/chess/chess
$ pwd
/cygdrive/c/chess/chess

dale@midime /cygdrive/c/chess/chess
$ python
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from chess.chessgame import *

BOARD PRINTOUT

Listening from ipaddr = 192.168.1.3, ipport = 4000
>>> testd()
>>> ^Z


dale@midime /cygdrive/c/chess/chess
$

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.

Last edited by Acoustic Interloper on Tue Jun 17, 2008 7:16 am; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 7:08 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Check this;
Code:

SinOsc s => Envelope ramp => dac;
second => ramp.duration;

1 => ramp.target;
second => now;
0 => ramp.target;
second => now;


That would do as well. No noise, less CPU and more simple.

*hits head*

oops.
:¬)

Thanks, Kassen. I played around with this code a little, I agree with Inventor's assesment that the noise is coming from clipping, and I think my bug may be that I am scaling the combined output signals in the wrong place.

Is there a built-in transform in ChucK that you can recommend for scaling all the gains so they never exceed 1.0? MSP's normalize~ function does this. If not, I think I see a better way to write it in ChucK than what I wrote in my first try.

Thanks again.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 7:33 am    Post subject: Reply with quote  Mark this post and the followings unread

James, I just tried this out on OSX, and the GUI process is having some problems. That surprises me a little, because that is the process I had working on OSX previously, and OSX Python did entail a few coding changes. Apparently, it now entails a few more.

I'll post a fix when I have one, hopefully later today.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 4:33 pm    Post subject: Reply with quote  Mark this post and the followings unread

James, whenever you (or anybody else) feels like giving this a go, the chessgame with some fixes for OSX is attached as before. The GUI package (Tkinter) needs to run in the main thread. I was calling a few of its functions in another thread, and windows was letting me do that. The OSX implementation of Python is a little more restrictive in that regard.

The README.txt has the comments on PYTHONPATH and current directory, but basically, PYTHONPATH must be exported to point to the upper chess directory, but you must invoke Python from the lower one.

There is another window that pops up behind the chessboard that you can see by moving the chessboard window. It's got a bunch of variable assignments in it. I don't have copy/paste working on the Mac yet, but if you type into the bottom entry widget:

lookaheadlimit=N <Enter>

where N is anywhere from 1 to about 10, you will change the depth of the note search, which is what shows up as arrows on the chessboard with "Toggle Graph Trace" enabled.

The other one of interest is delay2alterseq, defaulting to 15.0 seconds, which is how long the server waits before it starts making transformations to the current note sequence. If I get bored, I play around with these two parameters, mostly by lowering them.

I find it useful after exiting either process to exit the bash window from which I invoked them, if I plan to restart them, and then restart them in fresh windows. OSX seems less forgiving about re-using XMLRPC/TCP port numbers than Windows after a process exits, but exiting the bash window seems to help.

Good luck. Let me know how it goes.

EDIT: chess.zip attachment remove, see updated code from August 2 for latest version.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.

Last edited by Acoustic Interloper on Sat Aug 02, 2008 10:26 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Tue Jun 17, 2008 5:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:

Thanks, Kassen. I played around with this code a little, I agree with Inventor's assesment that the noise is coming from clipping, and I think my bug may be that I am scaling the combined output signals in the wrong place.


I see, Well, at least these will give you less distortion caused by periodically setting the gain; that's worth something as well ;¬). Gain structures and clipping are of course quite relevant but I feel that double-floats for the internal engine mean the bottle-neck is most likely not there. If you have clipping in ChucK it's nearly always at the final dac stage, before there we have quite a few orders of magnitude of heardroom.

Quote:

Is there a built-in transform in ChucK that you can recommend for scaling all the gains so they never exceed 1.0? MSP's normalize~ function does this. If not, I think I see a better way to write it in ChucK than what I wrote in my first try.


Well, what you could always do is take the amount of sound-sources (assuming those have a max amplitude of 1), divide one by that and use that as the final gain. This will give you a hard guarantee your highest possible output will be one. For larger numbers of sound sources (say 32 chess pieces....ahum....) that sounds quite unpractical to me though, unless you are prepared for lots of dynamics and very quiet passages (this can of course be very beautiful if you have the chance and suitable neighbours!).

Instead what I'd do would be be a combination of a final gain set based on the average number of soundsources plus some headroom, combined with a "Dyno" Ugen. Dyno deals with dynamics (compression, limiting, expanding...). Of course, depending on the type of attack your sounds have a compressor-limiter may not be up to the task and some clipping samples may still slip through, I think that's more or less unavoidable in practical real-world systems. A more aggressive compressor will lead to less pleasant average performance.

Another compromise might be to at the start of a new section (a move in this case) count the number of sound sources playing in it and at that time set the gain to 1/n where "n" is the number of sound-sources. This is guaranteed to never clip and use the full bandwith but it also goes at the cost of inter-move dynamics. Personally I wouldn't take that, I'd take the loud drama of large ensembles once we start placing queens in mid-field and take the chance of a few clipped samples being theoretically possible with it.

I know a little bit about chess and a little bit about DSP and I fear it's all trade-offs in both fields, all the time, and involving ChucK doesn't change that a bit. I'd go for a informed weighing of a mix of a few strategies (in all of the above... :¬) ).

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 7:17 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
unless you are prepared for lots of dynamics and very quiet passages (this can of course be very beautiful if you have the chance and suitable neighbours!).

This actually happens, and it is sometimes a surprise to me. If a major piece is taken, the sound-search from its side of the board goes dead for a move. And, if some piece moves that is disconnected from most of the pieces involved in the action -- say a pawn off to the side -- a quiet passage will suddenly appear in the midst of the raging battle. This is also why I give the players the ability to modify the musical lookahead depth at play time -- you can expand arpeggios by increasing this number for a given configuration of pieces, or contract them by decreasing it.

Thanks for your advice and encouragement. If I can get one free day with no conflicting responsibilities, I think I will be able to post my first ChucK program. Very Happy

I am almost finished with the book, by the way. How is it going for you? I find I appreciate it more 35 years later.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Tue Jun 17, 2008 7:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

SuperCollider is definitely receiving on my end -- fun! I probably have to make some adjustments - I assumed oscillators would be released before being reused but it seems new values get pushed to them while they're active. That's not hard to fix, but it's late here, time for bed, and I'll have to do it later.

To use SC as the engine, chessgame.py needs to be edited to create the tonegen object with port 57120 (SC's receiving port for the language side).

Pity my chess skills are rudimentary at best...
James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Tue Jun 17, 2008 8:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
SuperCollider is definitely receiving on my end -- fun! I probably have to make some adjustments - I assumed oscillators would be released before being reused but it seems new values get pushed to them while they're active. That's not hard to fix, but it's late here, time for bed, and I'll have to do it later.

In general I try to use them in round robin order, so I'll go thru them all before repeating, but I may have forgotten to mention how I shut them down. From ChucK:
Code:

got (via OSC): 0 15 -1.000000 -1.000000 0.000000 0.000000
got (via OSC): 0 0 -1.000000 -1.000000 0.000000 0.000000
got (via OSC): 0 2 0.000000 0.000000 0.000000 0.000000
got (via OSC): 0 1 275.000000 0.000000 0.174860 0.058287
got (via OSC): 0 3 0.000000 0.000000 0.000000 0.000000
got (via OSC): 0 2 123.750000 0.000000 0.174860 0.058287
got (via OSC): 0 1 -1.000000 -1.000000 0.000000 0.000000
got (via OSC): 0 2 -1.000000 -1.000000 0.000000 0.000000
got (via OSC): 0 4 0.000000 0.000000 0.000000 0.000000
got (via OSC): 0 3 150.654739 0.000000 0.000000 0.000000
got (via OSC): 0 5 0.000000 0.000000 0.000000 0.000000
got (via OSC): 0 4 80.349197 0.000000 0.000000 0.000000

The -1.000 frequency means, "Ramp this oscillator down." I definitely forgot about that when specifying the ChucK program Embarassed Maybe some of my crackly noise is coming from there!

Quote:
To use SC as the engine, chessgame.py needs to be edited to create the tonegen object with port 57120 (SC's receiving port for the language side).

Making this a config parameter is on my todo list Cool

Quote:
Pity my chess skills are rudimentary at best...
James

Then we're all together on that one.

Incidentally, you could use the 'frequency' as a fundamental, or as the root of a chord, or interpret it any number of ways. A few more bits in the bank number to identify the piece might be useful, but even without it, these fields could be interpreted at your whimsy.

Have fun. I hope it doesn't crash too often.

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Wed Jun 18, 2008 5:59 am    Post subject: Reply with quote  Mark this post and the followings unread

Here's an improved version of the supercollider side. No particular whimsy in interpreting the data yet Smile

You didn't forget about the frequency = -1 thing, but I did find that I had to filter out a lot of junk messages, specifically those where the frequency or both the left and right amplitudes are zero. Those messages don't produce sound, so I suppressed synth creation for them.

Also, something went pretty horribly wrong when I put Stein in check Twisted Evil (let that be a lesson to those who want to mess around with him). Synths were created rapidly but not released. What's really odd is that I changed my code to release the existing synth if there is a re-trigger message on the same bank/oscillator pair where a synth is already playing.

Probably timing inaccuracies in sending the synth control messages to the audio server. I added timestamps to the bundles and the behavior seems to have improved quite a bit.

James


chess-music.txt
 Description:

Download
 Filename:  chess-music.txt
 Filesize:  3.23 KB
 Downloaded:  99 Time(s)


_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Wed Jun 18, 2008 6:09 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Here's an improved version of the supercollider side. No particular whimsy in interpreting the data yet Smile

Thanks! I'll get to try it out this evening. I'm glad it's working!
Quote:
You didn't forget about the frequency = -1 thing, but I did find that I had to filter out a lot of junk messages, specifically those where the frequency or both the left and right amplitudes are zero. Those messages don't produce sound, so I suppressed synth creation for them.
I vaguely recall that the intent of the -1.0 was to ramp down amplitude without changing frequency, while the intent of 0.0 amplitude generally is to shut the oscillator off, after which it can be decommissioned in any way possible. I'll have to look at the traces.
Quote:
Also, something went pretty horribly wrong when I put Stein in check Twisted Evil (let that be a lesson to those who want to mess around with him). Synths were created rapidly but not released. What's really odd is that I changed my code to release the existing synth if there is a re-trigger message on the same bank/oscillator pair where a synth is already playing.

Yes, over-write of a bank/offset pair should eliminate any oscillator already running at that slot. This is how the Max/MSP patch is wired; you cannot do dynamic oscillators in max, as far as I know.

Noise, clipping, etc. is the intent at check! I intentionally turn on a pile of oscillators and scale them up so the DAC clips. Don't know how this sounds in SC.
Quote:

Probably timing inaccuracies in sending the synth control messages to the audio server. I added timestamps to the bundles and the behavior seems to have improved quite a bit.
James

For Max/MSP I just play the notes as they arrive, without superimposing the time they were put together, but I could add timestamps. What format should a time stamp have, i.e., float versus int, and what unit of measure does it represent? I don't know if Max can do anything with that.

Have fun. Gotta go . . .

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
Acoustic Interloper



Joined: Jul 07, 2007
Posts: 1652
Location: Berks County, PA
Audio files: 38

PostPosted: Wed Jun 18, 2008 9:42 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
You didn't forget about the frequency = -1 thing, but I did find that I had to filter out a lot of junk messages, specifically those where the frequency or both the left and right amplitudes are zero. Those messages don't produce sound, so I suppressed synth creation for them.

I took another look at the Max patch to make sure I have this correct.

In Max there are two fixed banks of oscillators, 32 for sine (bank 0) and 32 for triangle (bank 1). They are always there, but incoming amplitudes for both left and right channel of 0.0 means "ramp them off." So, there shouldn't be any junk messages.

A frequency of -1.0 is always associated with a phase of -1.0 and amplitudes of 0.0. It means, "ramp oscillator down without changing its frequency." Frequency of 0.0 actually resets the frequency. Basically, for anything with both amplitudes == 0.0, you can just ramp down that oscillator, and presumably free its resources. In general I try to use the oscillator numbers in round robin order, and to free an oscillator (via both amplitudes == 0.0) before reusing it. There is no guarantee that it will be ramped to 0.0, but normally it is before reuse.

And yes, CHECK! is meant to be an ugly sound Very Happy

_________________
When the stream is deep
my wild little dog frolics,
when shallow, she drinks.
Back to top
View user's profile Send private message Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Wed Jun 18, 2008 3:01 pm    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:
A frequency of -1.0 is always associated with a phase of -1.0 and amplitudes of 0.0. It means, "ramp oscillator down without changing its frequency." Frequency of 0.0 actually resets the frequency.


OK, I see what to do with the frequency = 0 messages now.

In SuperCollider, optimal use is to create a synth node whenever activating an oscillator, and release the node (remove it from the server) at the end of every "ramp-out." So there's no distinction between -1 or 0 for frequency (or 0 amplitudes). Both should just stop the corresponding synth.

I didn't know what to do with the 0, 0... messages so the current code ignores them. Tonight I'll put up a revision that treats them the same as any other node release.

Acoustic Interloper wrote:
And yes, CHECK! is meant to be an ugly sound Very Happy


Actually, after I put in the timestamps, there were big spikes in CPU activity upon check, but the activity went back down shortly after. High CPU doesn't scare me as long as it's under control like that. Before, nodes would get stuck with no way to terminate them, kind of like a memory leak but for CPU.

I don't get clipping, though, because of the Limiter. Even without clipping, the texture carries the message "ZOMG Danger" Shocked Shocked shaking loud and clear. Nice!

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic Moderators: elektro80
Page 4 of 7 [155 Posts]
View unread posts
View new posts in the last week
Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Mark the topic unread :: View previous topic :: View next topic
 Forum index » Discussion » Composition
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use