Pyzine article Python and MIDI

2005-10-08 Thread Gorlon the Impossible
ok, here's a long shot:
would anyone here who subscribes to Pyzine be willing to send me the
article on Python and MIDI from Issue #6? I would be eternally
grateful as I am strapped for funds and cannot justify spending the
money for a 1 yr subscription when i am only interested in this one
article. Thanks.

here's the link...

http://www.pyzine.com/Issue006/index.html


please?
pretty please?
with sugar on top?

Bri
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


loop help

2005-10-27 Thread Gorlon the Impossible
Hello. I am using Python 2.3.5 with IDLE 1.0.5 on a Windows98 PC.
I have some programming experience but mostly I am still learning.
I am having some trouble understanding the behaviour of a piece of
code I have written. It plots points using PIL.
Here is my loop:

triangle = [(320,27),(172,323),(468,323)]
currentpoint = (randint(0,640),randint(0,350))
t = 0
while t < 10:
ct = choice(triangle)
mp = (currentpoint[0] + ct[0])/2, (currentpoint[1] + ct[1])/2
draw.point(mp,(0,0,0))
currentpoint = mp
t = t + 1

This works fine. But, if I try to divide by a floating point number in
the calculation of mp, instead of mp being overwritten each time thru
the loop, it starts accumulating, leading to overflow errors for large
values of t.
Why is this?
-- 
http://mail.python.org/mailman/listinfo/python-list


running functions

2005-11-16 Thread Gorlon the Impossible
 Hello
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running functions

2005-11-16 Thread Gorlon the Impossible
On Thu, 17 Nov 2005 00:08:02 GMT, [EMAIL PROTECTED] (Cameron Laird)
wrote:

>In article <[EMAIL PROTECTED]>,
>Grant Edwards  <[EMAIL PROTECTED]> wrote:
>>On 2005-11-16, Gorlon the Impossible <[EMAIL PROTECTED]> wrote:
>>
>>> I'm not sure how to phrase this question. I have a Python function
>>> that sends MIDI messages to a synth. When I run it, I of course have
>>> to wait until it is finished before I can do anything else with
>>> Python. Is it possible to run this function and still be able to do
>>> other things with Python while it is running?
>>
>>Yes.
>>
>>> Is that what threading is about?
>>
>>Exactly.  Take a look at the "treading" module:
>>
>>http://www.python.org/doc/current/lib/module-threading.html
>   .
>   .
>   .
>I don't agree, Grant (although I salute the brevity
>of your follow-up), and a couple of other correspon-
>dents have already posted follow-ups that begin to
>explore the alternatives.
>
>If I were pursuing this, the first question I'd have
>for Gorlon is whether he's OK with a "fire and for-
>get" model.  By that, I mean to ask if it's OK to
>send the MIDI message, and then return immediately
>to other Python work, OR whether Gorlon also needs
>to stay in contact with the MIDI handler, and
>perhaps react especially when the MIDI handler
>finishes with the specific message.  That choice is
>crucial in a good concurrency design.

'good concurrency design'  LOL... I'm not that proficient at
programming in general or Python... 
You bring up some interesting points, though. I am just learning and
experimenting with programming MIDI events at this level. My function
sends a series of MIDI note-on and note-off messages and that's it so
far. But, I am trying to learn more and working towards a sort of
'live-coding' set-up for musical performance. So, eventually I will
want  to be able to control other synth parameters with MIDI messages
and be able to start and stop different kinds of control functions 'on
the fly' so to speak. I checked out the threading module and its
working for what I am trying to do at the moment, but I am open to
suggestions and eager to learn all I can about other options. Thanks
for taking the time to respond.
I would be interested in hearing more about the subprocess approach...

>
>So, Gorlon, yes, threading is a prominent member of
>the family of facilities that address situations like
>yours.  It's not the only one, though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running functions

2005-11-17 Thread Gorlon the Impossible
On Thu, 17 Nov 2005 23:29:16 +, Tom Anderson
<[EMAIL PROTECTED]> wrote:

>On Wed, 16 Nov 2005, [EMAIL PROTECTED] wrote:
>
>> Gorlon the Impossible wrote:
>>
>>> Is it possible to run this function and still be able to do other 
>>> things with Python while it is running? Is that what threading is 
>>> about?
>>
>> Threading's a good answer if you really need to share all your memory. A 
>> multiprocess solution is probably preferrable, though it depends on the 
>> architecture.
>
>I'm really curious about this assertion, which both you and Ben Finney 
>make. Why do you think multiprocessing is preferable to multithreading?
>
>I've done a fair amount of threads programming, although in java rather 
>than python (and i doubt very much that it's less friendly in python than 
>java!), and i found it really fairly straightforward. Sure, if you want to 
>do complicated stuff, it can get complicated, but for this sort of thing, 
>it should be a doddle. Certainly, it seems to me, *far* easier than doing 
>anything involving multiple processes, which always seems like pulling 
>teeth to me.
>
>For example, his Impossibleness presumably has code which looks like this:
>
>do_a_bunch_of_midi(do, re, mi)
>do_something_else(fa, so, la)
>
>All he has to do to get thready with his own bad self is:
>
>import threading
>threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
>do_something_else(fa, so, la)
>
>How hard is that? Going multiprocess involves at least twice as much code, 
>if not ten times more, will have lower performance, and will make future 
>changes - like interaction between the two parallel execution streams - 
>colossally harder.
>
>tom

I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
-- 
http://mail.python.org/mailman/listinfo/python-list