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
  Rob Adventures in Sound
Please visit the chat
 Forum index » Discussion » Composition
glass-bead game
Post new topic   Reply to topic Moderators: elektro80
Page 2 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
Kassen
Janitor
Janitor


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

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

Blue Hell wrote:
Oh, I messed up white and black Embarassed


Likely because of the colours of the respective pawns. Uncle has a rather pale black pawn and AI is really quite black for a white pawn.

Oh, well, now the game has started... next game this may need to be fixed and we might need to consider Nescivi as "queen of the civilised side", right now that's all wrong.

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



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

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

Acoustic Interloper wrote:
I'll post this Python code after I wean the tone generation off of Max/MSP to ChucK. In fact, I plan to make tone generation a plug-in. I'd like to use some MIDI-driven synths, but I am up against a stop: Just Intonation implies prefixing each MIDI noteon with a pitch bend, but pitch bend affects all notes on a MIDI channel, and each note in Just Intonation would be bent differently. So, as far as I can see, no MIDI. Anybody see a way around thsi MIDI limitation? Not a problem for MSP or ChucK.


Poly-aftertouch mapped onto pitch? (Then again, synth modules that support poly aftertouch are not many.)

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: Wed Jun 11, 2008 7:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
Since the two are such opposites, it only makes sense that they would make opposite types of music. Still, if the king's pawn game is silent, then something is missing, perhaps "control of center" or "dynamic tension", which would give the king's pawn move a totally different but non-silent sound. This is shaping up interestingly.

Come to think of it, the Pawn-to-King-4 is my preference, musically speaking. You always get notes out of at least the last two pieces moved, so with Pawn-to-King-4 you get a nice gentle opening that builds up steam as soon as supporting pieces come into play. With Pawn-to-Queen 4 you get more sound thrown at you right away. That's one reason I made the musical search depth player-adjustable; otherwise, sometimes things sound too much the same because too many relationships are used for music after each move. Limiting search depth eliminates some of the clutter. I am still getting a feel for what works there. It's exactly like tuning an instrument!

The core of the algorithm is this:

1. Create a directed "reachable graph" that consists of Python 6-tuples, one per board space, consisting of

a. the piece occupying the space after the most recent move
b. the pieces it supports
c. the pieces it attacks
d. the pieces it is supported by
e. the pieces it is attacked by
f. coordinates of spaces to which it can move

Check detection is part of this, as well as special code for castling and en passant pawn capture. I haven't coded for checkmate detection; too many other things to do.

This part is chess-specific, but there is nothing about music generation here.

2. Call a plugin to generate a sequence of tones, where a sequence is a list of Python sublists, and each sublist is a list of tones to be played simultaneously, where each tone is a Python 5-tuple consisting of

a. a bank number to select a voice, used for routing in Max or as a Python index subscript, or could conceivably be mapped to a MIDI channel number
b. frequency (could be mapped to MIDI bend and noteon info)
c. phase
d. left channel amplitude, 0.0 to 1.0
e. right channel amplitude, 0.0 to 1.0

Right now I am using sine waves for support and triangles for conflict relationships, very basic sounds, but the bank number could map to anything.

This plugin also creates a second reach graph, like the first, populating it only with the relationships from the graph of (1) that were actually used.
This plugin also determines the order of search (breadth-first vs. depth-first, for example), depth of search, and generally how to map the structures of (1) to music. So Just Intonation is not hard wired to the overall program, just to the plugin I am using.

The second reach graph gets passed back to the UI for display, hence the black/red/green/yellow arrows on the chess board. Those are the relationships that make music.

3. There are two threads running, one for white and one for black, that are also in the plugin of (2). Their job is just to take the sequences created by (2) (one for white, one for black), embellish them as they see fit (this is where my plugin adds octave info, tempo info derived partly from player move-speed), and send lists of notes off to 4.

4. This step send lists of bank-freq-phase-lamplitude-ramplitude off to a sound generator, for now to Max via OSC/UDP. I will make this Python class a plugin as well, when I get around to ChucK, if ChucK's OSC is on top of TCP instead of UDP. I can't tell from the ChucK docs, although I can find out in 5 minutes by using Ethereal to sniff the ChucK demo packets.

Once I make this a plugin, I could also create a MIDI plugin that converts frequency info to bend-noteon pitch, etc., subject to the many limitations of MIDI in generating sounds outside of equally tempered scales.

A given music plugin can expose as many config parameters to the user interface as it likes, and they show up in a separate GUI window, where you can tweak the instrument to your heart's content as you play, given the limits of the instrument itself. My current plugin exposes most of the Just Intonation roots and transforms, some of the meter data, and the note-search-depth to the player, for inspection and alteration.

I guess now that this thing is getting some character, I am starting to have a goal, which is instrument design in the algorithmic composition space, rather than primarily in the sound generation space, for which there are better experts. I'll put the code up here after I am happy with it, which could be weeks or at most end of summer, because there is some ugly stuff (e.g., unwanted global variables) from the early stages that I want to factor out, and also make the channel to the tone generator more parameterized. Generally, when doing a "reusable" architecture, you don't know if it is really "reusable" until you hit it with two distinct uses, so I probably should do one more music plugin that does equal temper MIDI, just to shake out the architecture.

Then the code will come to this thread. I need to get some conference papers published so I get tenure in my new job, so I'll use any feedback on game-based-instrument-design for that as well as for enhancing the program. But this is not primarily an 'academic study,' it's just play, augmented with a paper or two on the side. I have a potential ally in the music department where I am going to teach CS, so we'll probably foist some of this on students some time as well.

By the way, Kassen, I've been reading The Glass Bead game for the first time in 35 years, thanks to your original post, and have some insights after 35 years or working and playing, that I'll post later. Gotta get back to my day job!

_________________
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 11, 2008 7:16 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Oh, well, now the game has started... next game this may need to be fixed and we might need to consider Nescivi as "queen of the civilised side", right now that's all wrong.

I'll go check her out and probably make the change. Thanks! I was rather hasty in grabbing avatars, my main goal being visual appeal of the icons over strictly light-dark shading, and also using avatars whose owners are posting to this thread (where possible). There were some more I would have liked to use, not enough pieces, although of course you tune this by creating a new 50x50 GIF in the avatars/KB.gif file (for black king, for example), so you can create your own using pets or whatever. American Civil War chess sets (or War Between the States for those of you south of Mason/Dixon) are fairly common over here.

dewdrop_world wrote:
Poly-aftertouch mapped onto pitch? (Then again, synth modules that support poly aftertouch are not many.)

James

Thanks, I'll take a look. Don't know if the couple of MIDI synths I have support it, but it's worth a look. I also have SC on my todo list, but as with all of us, that todo list never shrinks. Very Happy

There will be a one hour demo session of this at EM2008 where people can sit down and play some speed chess. With any luck it will be out there virally before that as well.

_________________
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 11, 2008 7:43 am    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:
I also have SC on my todo list


If you want I can hack up some nice sounds in SC that you could run with OSC. We could use some custom OSC messages to send midi-like note-on and note-off messages, but with OSC you could use fractional MIDI note numbers or raw frequencies.

// half a midi note == 24th-root of 2
(60.5.midicps / 60.midicps) == (2**(1/24))
--> true Cool

I have a module in my library that does the bookkeeping transparently - setup should be really easy.

What kinds of sounds do you want?

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: Wed Jun 11, 2008 7:44 am    Post subject: Reply with quote  Mark this post and the followings unread

I think the white queen's a bit of a mess, well , the picture is, I don't even recognise it. Why isn't Bernat's Avatar the white queen? it's looks perfect for that and she's in the US.

Nescivi turns out not to have a avatar. That's quite annoying. We may have to disqualify her anyway as she's in Canada at last count so that hardly counts as "the civilised world".

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


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

PostPosted: Wed Jun 11, 2008 7:47 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:

If you want I can hack up some nice sounds in SC that you could run with OSC. We could use some custom OSC messages to send midi-like note-on and note-off messages, but with OSC you could use fractional MIDI note numbers or raw frequencies.


Cool! Write a standard and I'll volunteer for the CK version. If it's going to be OSC I'll wait for a round of OSC cleanup in ChucK though, if you don't mind.... The current situation looks quite messy to me.

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



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

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

Ah, right... OSC is central to SC's operations so it has a very simple API for the end user. All the parsing takes place in the backend.

I think something along the lines of

/midi.noteOn, channel, freq, unit, velocity (normalized 0-1), ... key/value pairs for other synth parameters (or rather, a more abstract representation to be mapped to specific synth controls) ...

where "unit" is a symbol 'hz' or 'midi' (or something else) pointing to a hash table containing functions to convert frequency.

Code:
var conversions = (hz: { |f| f }, midi: _.midicps);

// then, on an incoming message
freq = conversions[unit].value(freq);


/midi.noteOff, channel, freq, unit

/midi.cc, channel, ccID, value

"Channel" would of course not have to be limited to 0-15 - it could even be a string to look up in another hash table.

Just some quick thoughts... not sure if we need an all-out standard for this Smile

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net

Last edited by dewdrop_world on Wed Jun 11, 2008 9:03 am; edited 1 time in total
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 11, 2008 9:01 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
If you want I can hack up some nice sounds in SC that you could run with OSC. We could use some custom OSC messages to send midi-like note-on and note-off messages, but with OSC you could use fractional MIDI note numbers or raw frequencies.

Thanks, James. I'll have to hold off on my part until I make the chess-to-sound-program-protocol module a plugin, so this is "planned work" at present, but my current chess-board-to-music plugin uses only two values for voice, one for support relationships and the other for attack. Attack is pretty much tongue-in-cheek, obviously, so I tend to go light on the noise. I'd go for two voices that pair reasonably well.

Kassen wrote:
I think the white queen's a bit of a mess, well , the picture is, I don't even recognise it. Why isn't Bernat's Avatar the white queen? it's looks perfect for that and she's in the US.

Nescivi turns out not to have a avatar. That's quite annoying. We may have to disqualify her anyway as she's in Canada at last count so that hardly counts as "the civilised world".

Point me at an avatar, and on the board she'll go. I agree, by the way, and will move Bernat back across the pond as soon as I have a new Black Queen avatar.

Yeah, Canada's not letting in U.S. citizens convicted of civil disobedience in opposing the war, and presumably they are getting long laundry lists of, ahem, suspected terrorists. Mad

As far as an API standard, I need to get the architecture and example code cleaned up first. For example, I want to put in saved games with automatic replay, including timing, so that somebody else doesn't do this some other way as soon as I post it. I promise to post as soon as I'm happy with it, but I've got to pass some milestones first. It won't be long 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
Kassen
Janitor
Janitor


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

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

For replays; You may want to generate a random-seed at the start of a game, save this with the saved data and supply it to the sound clients.
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dewdrop_world



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

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

Couldn't resist hacking up a quick prototype in psycollider on my lunch hour. Plenty of room for extension if needed later... but as a proof-of-concept, it shows how easily it can be done.

James

Code:
// preparation
(
~conversions = (hz: _.value, midi: _.midicps);

// quick and dirty voicer
~vc = Voicer(10, \default);

// id -> voicer
~channels = (0: ~vc);

~responders = [
   OSCresponderNode(nil, '/midi.noteOn', { |time, resp, msg|
      var   name, channel, freq, unit, vel;
      #name, channel, freq, unit, vel = msg;
      ~channels[channel].trigger(~conversions[unit].value(freq), vel);
   }).add,
   OSCresponderNode(nil, '/midi.noteOff', { |time, resp, msg|
      var   name, channel, freq, unit;
      #name, channel, freq, unit = msg;
      ~channels[channel].release(~conversions[unit].value(freq));
   }).add
];

a = NetAddr("127.0.0.1", NetAddr.langPort);
)


// as a test, I'll send a message to myself - synth node gets created
a.sendMsg('/midi.noteOn', 0, 440, 'hz', 0.5);

// and it gets released here
a.sendMsg('/midi.noteOff', 0, 440, 'hz');

_________________
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: Wed Jun 11, 2008 9:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Wow, this is turning into quite the collaboration! I didn't realize the code was so functional yet. Now I kind of wish there was some kind of contribution that I could make. I know nothing about OSC besides a link to the OSC docs that Jan gave me. Maybe I could help with the games database or something? I presume you'd want to read in text files of games in algebraic notation or something. I know that games databases have been standardized and are available on CD's. Perhaps we could set up the program to interface with such a CD, or perhaps I could create our own little games database with a few sample games in it? Let me know.
_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Acoustic Interloper



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

PostPosted: Wed Jun 11, 2008 10:31 am    Post subject: Reply with quote  Mark this post and the followings unread

OK, it looks like I am not going to get away Scot free in spilling out a little premature code. The Python class that sends notes via OSC/UDP is attached. If a ChucK or SC program can accept these packets, it will generate tones. This class WILL change, by the way, when I make it a plugin, but the wire protocol may not. When I make it a plugin, you could create a ChucK or SC specific derived plugin class that manages packets differently. Although, from what I've read of ChucK, it should work with this wire protocol as is unless ChucK OSC uses TCP instead of UDP. I haven't gotten to look at ChucK OSC that deeply yet.

This bit in the code (I hope the spaces are preserved):
Quote:

# The following are for transport which we will hide behind an API later.
from binascii import a2b_hex, b2a_hex
from struct import pack

class tonegen(object):
....def __init__(self, udphost, udpport):
........self.udphost = udphost
........self.udpport = udpport
........self.skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
........self.lock = RLock()
....def send(self,tonelist):
........if (len(tonelist) == 0):
............raise ChessException, "empty tonelist parameter"
........tonebank = tonelist[0] / 32
........toneslot = tonelist[0] % 32
........banklist = [tonebank, toneslot] + tonelist[1:]
........listhead = a2b_hex('6c697374000000002c') # 'list\0\0\0\0,'
........hdrlen = 9
........listtail = ''
........# print "DEBUG ABOUT TO SEND LIST: " + str(banklist)
........for val in banklist:
............if (type(val) == int):
................listhead = listhead + a2b_hex('69') # 'i'
................listtail = listtail + pack('>i', val)
............elif (type(val) == float):
................listhead = listhead + a2b_hex('66') # 'f'
................listtail = listtail + pack('>f', val)
............else:
................raise ChessException, "invalid type for tonelist value " \
....................+ str(val) + ": " + str(type(val))
............hdrlen = hdrlen + 1
........while (hdrlen % 4):
............listhead = listhead + a2b_hex('00')
............hdrlen = hdrlen + 1
........self.lock.acquire()
........try:
............self.skt.sendto(listhead+listtail, (self.udphost, self.udpport))
........finally:
............self.lock.release()

t = tonegen('192.168.1.3', 7401)

Creates a header in the UDP data consisting of the word 'list', , four '\0' null characters, a comma ',' character, a type string of "i" for integer and "f" for float, optionally some more nulls to get a multiple of 4 address, and then the actual int and float values as binary fields. This protocol came from having Max send to Python and then I used Python to reverse engineer what Max was sending. From what I've read of ChucK, this should be trivial if ChucK OSC uses UDP. The Max manual claims Max uses OSC.

Here's an Ethereal trace of the UDP datagram's payload in bold for the first note of pawn-to-king-4

0000 00 1c 23 29 65 43 00 90 f5 3f a3 e3 08 00 45 00 ..#)eC...?....E.
0010 00 44 16 ae 00 00 80 11 a0 a3 c0 a8 01 04 c0 a8 .D..............
0020 01 03 04 71 1c e9 00 30 d8 8f 6c 69 73 74 00 00 ...q...0..list..
0030 00 00 2c 69 69 66 66 66 66 00 00 00 00 00 00 00 ..,iiffff.......
0040 00 00 43 77 80 00 00 00 00 00 3e c0 00 00 3e 00 ..Cw......>...>.
0050 00 00
..

6c 69 73 74 00 00 00 00 2c are 'list\0\0\0\0,'

69 69 66 66 66 66 00are 'iiffff\0' for type tags. Ints and floats are both 32 bits

These 6 type tags are for bank #, oscillator #, freq, phase (0.0 .. 1.0, left amplitude (0.0..1.0) and right amplitude (0.0..1.0), with a trailing null to round the byte count to a multiple of 4.

Next come the actual values for the 6 fields:

00 00 00 00 integer bank (voice) # 0

00 00 00 00 integer oscillator number 0 (each bank in Max has oscillators 00..31 for a total of 64 oscillator, first half generating sines, second half generating triangles)

43 77 80 00 float frequency, note in Python:


>>> from struct import *
>>> unpack('>f', a2b_hex('43778000'))
(247.5,)

Looks like 247.5 hz, when I was expecting a fifth above an A, 220 * 1.5 = 330

>>> 247.5 / 220.0
1.125 Looks like 1/8 above 220.

May be a couple of down tranposes from 440, or may be a bug! Always something to check. The ">" binary format is big endian, which is what Max apparently uses. Anyway,

00 00 00 00 float phase of 0.0

3e c0 00 00 twice, once for left amplitude, once for right.

>>> unpack('>f', a2b_hex('3ec00000'))
(0.375,)
>>>

Anyway, that's the wire protocol at present, so if ChucK or SC can eat these UDP packets, they can work with the existing code. Of course, once I make this a plugin, the code coming into tonegen.send() can adapt the incoming music data to any outgoing wire protocol. I suspect that the plugin that generates music from the chess board (my items (2) and (3) above) and the plugin to send over the wire (4) may have to be unified as one plugin, since music generation may be aimed at a specific sound generator target, anyway. Then the chess engine will work with any sound generation scheme that you care to plug in. We'll see . . .

EDIT: "t = tonegen('192.168.1.3', 7401)" in the attachment should say 'localhost' but I needed to force to another machine in order to use Ethereal.


tonegen.py
 Description:

Download
 Filename:  tonegen.py
 Filesize:  1.56 KB
 Downloaded:  84 Time(s)


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

Last edited by Acoustic Interloper on Wed Jun 11, 2008 10:44 am; edited 1 time 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: Wed Jun 11, 2008 10:42 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
Wow, this is turning into quite the collaboration! I didn't realize the code was so functional yet. Now I kind of wish there was some kind of contribution that I could make. I know nothing about OSC besides a link to the OSC docs that Jan gave me. Maybe I could help with the games database or something? I presume you'd want to read in text files of games in algebraic notation or something. I know that games databases have been standardized and are available on CD's. Perhaps we could set up the program to interface with such a CD, or perhaps I could create our own little games database with a few sample games in it? Let me know.

The game stuff is all in Python, so a first step will be learning Python, primarily to write your own music plugin after I have things a little more, ahem, solid. Figuring out how to read a game DB into Python might be useful. Or, if you prefer to stay wigth Chuck, custom sound generation. That's one area where I don't get to spend time.

_________________
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
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20615
Location: The Netherlands, Enschede
Audio files: 148
G2 patch files: 318

PostPosted: Wed Jun 11, 2008 10:49 am    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:
(I hope the spaces are preserved)


You can use the code tags instead of the quote tags for that, as in

Code:

*
    *
        *

_________________
Jan
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 11, 2008 11:37 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
You can use the code tags instead of the quote tags for that

Thanks!

_________________
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
Inventor
Stream Operator


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

PostPosted: Wed Jun 11, 2008 11:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Acoustic Interloper wrote:
Or, if you prefer to stay wigth Chuck, custom sound generation. That's one area where I don't get to spend time.


Well, I could code up a class of functions that make some of ChucK's instruments available. That's something that I know how to do. I'm imagining a set of functions that all have the same calling interface, so all the nifty details are hidden from you so that all you would have to do is make a function call like "guitar ();" to get a guitar sound or "pling ();" to get a pling type sound. There should also be an initialization function to set the sound duration and volume.

This would give you a collection of super easy to use sounds to give you a step up from working with sinusoids and triangle waves. Sorry, but I don't know how to make it talk with OSC. Would you like me to put together such a class for the project, AI?

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



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

PostPosted: Wed Jun 11, 2008 1:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

It looks like there is enough interest in playing with this thing, to post the (somewhat volatile) code now. Here it is. Some APIs will change and others may.

Doing the ChucK OSC migration was my plan for last weekend, but I got involved in other aspects of this thing and didn't get to it. If somebody wants to verify whether ChucK OSC works with UDP and this program, May the Force be with You. My plan was just to start out using sines for bank 0 and triangles for bank 1, to have an apples-to-apples starting point; you could change to other instruments for these banks after that. If not, I'll get to it at some point.

I've also included the Max patches in a subdirectory. There's a README.txt.

Have fun.

EDIT: Deleted this attachment when I uploaded a new chess.zip on July 13 on page 6 of this thread.


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:25 am; edited 2 times in total
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 11, 2008 1:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for posting this. I'm curious to see how the OSC messages appear in SC.

SC listens to UDP datagrams normally -- the question is what the internal parser will do to the data. SC gives it to the user as an array. I'm guessing it will be something like ['list', 0, 247.5, 0, 0.375, 0.375] but I would have to verify before adapting my code above to it.

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: Wed Jun 11, 2008 1:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Thanks for posting this. I'm curious to see how the OSC messages appear in SC.

SC listens to UDP datagrams normally -- the question is what the internal parser will do to the data. SC gives it to the user as an array. I'm guessing it will be something like ['list', 0, 247.5, 0, 0.375, 0.375] but I would have to verify before adapting my code above to it.

James

To figure out Max I just got Max to talk to Max, and then let Python receive the UDP datagrams as well and poked at them inside the interactive Python interpreter. I may have also used Ethereal, although I don't know of a version of Ethereal that catches packets within a single machine. As far as I know, you actually have to go over a wire for Ethereal. (Should be at http://www.ethereal.com but I can't get there right now.)

Good luck! Given my novice status in sound design, I am looking forward to some interesting sounds.

At present the game server sits on one machine and the GUI clients are networked, but my hope in time is to duplicate the server logic as well, so we could play networked games and hear the same music, or perhaps different music for a given game, if we plug in different sound plugins. Right now both players have to be in the same room, unless you stream out the audio.

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
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20615
Location: The Netherlands, Enschede
Audio files: 148
G2 patch files: 318

PostPosted: Wed Jun 11, 2008 5:15 pm    Post subject: Reply with quote  Mark this post and the followings unread

e2-e4 d7-d5
e4-d5


chessboard-003.jpg
 Description:
 Filesize:  105.59 KB
 Viewed:  89 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

chessboard-003.jpg



_________________
Jan
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 11, 2008 7:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

You know, I wasn't sure whether or not I guessed right about the OSC but I was spot on.

Code:
z = ['list', 0, 0, 247.5, 0.0, 0.375, 0.375].asRawOSC;

z.clump(8).do({ |row| row.do({ |item| item.asHexString(2).post; " ".post; }); "".postln });


My output:
6C 69 73 74 00 00 00 00
2C 69 69 66 66 66 66 00
00 00 00 00 00 00 00 00
43 77 80 00 00 00 00 00
3E C0 00 00 3E C0 00 00

Ethereal output from AI:
6c 69 73 74 00 00 00 00
2c 69 69 66 66 66 66 00
00 00 00 00 00 00 00 00
43 77 80 00 00 00 00 00
3e c0 00 00 3e 00 00 00

Byte-for-frickin'-byte (except 3e 00 00 00 at the end -- see below). dancing

I also wanted to check the other way. Since z now holds the raw OSC bytes:

Code:
// the OSCresponderNode receives the parsed message, which will be printed by the function
o = OSCresponderNode(nil, 'list', { |t, r, m| m.postln }).add;
a = NetAddr("127.0.0.1", 57120);

a.sendRaw(z);


Prints: [ list, 0, 0, 247.5, 0, 0.375, 0.375 ]

And, if I edit the raw array to have exactly the same bytes as AI, the output is still intelligible.

Code:
z[z.size-3] = 0;
a.sendRaw(z);


Prints: [ list, 0, 0, 247.5, 0, 0.375, 0.125 ]

That's it, then -- you say it there, it comes out here!

Right now the message format is really tightly tied to the structure of the Max patch -- I assume the plug-in structure will decouple that and allow other types of messaging.

Anyway, no doubt in my mind now that you will be able to control supercollider this way.

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: Wed Jun 11, 2008 9:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
Byte-for-frickin'-byte (except 3e 00 00 00 at the end -- see below). dancing

Nice work!
Quote:
Right now the message format is really tightly tied to the structure of the Max patch -- I assume the plug-in structure will decouple that and allow other types of messaging.

Yes, even for Max this is limited. Since the "music plugin" generates the sequences and the "wire plugin" sends them down the line, the part that actually determines what fields to send can probably be part of the "music plugin" (it isn't right now), and the "wire plugin" can be neutral about the format, for example just send a UDP datagram without worrying about its contents. Basically, we can push the application-level-protocol back into the "music plugin," and, where possible, have the latter generate application formats that will work for Max, SC or ChucK. I guess I am going to learn some OSC the old fashioned way
Quote:

Anyway, no doubt in my mind now that you will be able to control supercollider this way.

James

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
Inventor
Stream Operator


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

PostPosted: Thu Jun 12, 2008 4:22 am    Post subject: Reply with quote  Mark this post and the followings unread

Jebus, you guys are talking way over my head! I know nothing about interprocess communication except I can't do it, and Python is a mystery to me as well. Cool concept though. Wish I could help, but it's outta my ballpark! Happy coding.
_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Acoustic Interloper



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

PostPosted: Thu Jun 12, 2008 7:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Blue Hell wrote:
Oh, I messed up white and black Embarassed

Oh, well, now the game has started... next game this may need to be fixed and we might need to consider Nescivi as "queen of the civilised side", right now that's all wrong.

All wrong and getting worse Exclamation

Quite a bad position to be in, over-aggressive and exposed to the world, so it seems.

Hermann Hesse wrote:
Here and there in the ancient literatures we encounter legends of wise and mysterious games that were conceived and played by scholars, monks, or the courtiers of cultured princes. These might take the form of chess games in which the pieces and squares had secret meanings in addition to their usual functions. And of course everyone had heard those fables and legends from the formative years of all civilizations which ascribe to music powers far greater than those of any mere art: the capacity to control men and nations. These accounts make of music a kind of secret regent, or a lawbook for men and their governments.


Peace


QBtoQB4.jpg
 Description:
 Filesize:  116.05 KB
 Viewed:  91 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

QBtoQB4.jpg



_________________
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
Display posts from previous:   
Post new topic   Reply to topic Moderators: elektro80
Page 2 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