Make a .WAV file come out of the left speaker in Windows

2005-07-11 Thread Alan Green
I am writing a Python script that uses the win32all winsound package to
play a .wav file. I the sound come out of the left hand speaker, but
not the right hand speaker.

I've look at some Python sound libraries (PySonic, Audiere, pygame), as
well as any number of command line .wav file players. For differing
reasons, none of these were suitable. Two possiblities are:

(a) Convert the mono .WAV file to a stereo .WAV file that plays out of
the left speaker only, or

(b) Use the win32 ActiveX to adjust the Windows sound output balance
all the way to the left.

Can anybody offer suggestions as to where to start with these two? Does
anybody have other solutions to suggest?

Alan.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'

2005-07-12 Thread Alan Green
Ric Da Force wrote:
> Hi guys,
>
> Thank you all for your input!  It was good to see so much convergence in the
> approach!

Just for divergence, you can also do this with regular expressions:

>>> import re
>>> re.sub("(.*),(.*)", r"\1 and\2", "C1, C2, C3")
'C1, C2 and C3'

Alan.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching through a list of tuples

2005-07-12 Thread Alan Green
Peter Otten wrote:
> Repton wrote:
>
> > I often find myself storing data in a list of tuples, and I want to ask
> > questions like "what is the index of the first tuple whose 3rd element
> > is x", or "give me the first tuple whose 2nd element is y".

> >>> items = [(1, "a", 10), (2, "b", 20), (3, "c", 30)]
> >>> class Key(object):
> ... def __init__(self, key):
> ... self.key = key
> ... def __eq__(self, other):
> ... return self.key(other)
> ...
> >>> items.index(Key(lambda x: x[2] == 20))
> 1

Neat solution.

I'd add an extra kind of Key, since finding tuples where a given
position is equal to a given value seems to be the common case:

>>> class EqualKey(Key):
... def __init__(self, pos, val):
... super(EqualKey, self).__init__(lambda x: x[pos] == val)
... 
>>> items.index(EqualKey(2, 20))
1

Alan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Make a .WAV file come out of the left speaker in Windows

2005-07-18 Thread Alan Green
Alan  Green wrote:
> I am writing a Python script that uses the win32all winsound package to
> play a .wav file. I [need] the sound come out of the left hand speaker, but
> not the right hand speaker.

I eventually got out ctypes and used it to access the Windows
multi-media libraries. ctypes is completely amazing, especially with
the code generator to turn the windows C header files into Python
functions and constants.

Just yesterday I discovered PyMedia, and will have to have a play with
that, too.

a

-- 
http://mail.python.org/mailman/listinfo/python-list