[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Screeching, Howling Garbage in One Ear pygame.sndarray
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Screeching, Howling Garbage in One Ear pygame.sndarray
- From: "andrew baker" <failrate@xxxxxxxxx>
- Date: Thu, 4 May 2006 23:52:50 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Fri, 05 May 2006 02:52:57 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=pC/m/WVzsZG40PqBb15gaZjeg5RZgsy9RgRqID4OSgEeLmFax56S5e2OrDOMG0dVx6q8C3kDMdUkRjwPs4hz6a+4CiYDWSFFpz1vf8eHtgczRREG6zNcQz9VbfcnThqXfksH29VC4Y7L+sPGn3ZPgKpiFYZeuJVBMMwRpPBPeLQ=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Howdy,
I'm trying to build a stereo tone generator module. It sort of works, but I'm getting hellacious garbage noise in the left channel.
Here's a greatly simplified version of my code (the function definition is the same, but I've condensed my main):
def tone6(limit = 2770, length = 17960, granularity = 10, phones = 2, envelope = 10, attack = None):
switch_amplitude = 1
cur_level = 0
out = []
for l in range(0,length):
if abs(cur_level) >= limit:
if switch_amplitude == 1:
switch_amplitude = -1
elif switch_amplitude == -1:
switch_amplitude = 1
cur_level += switch_amplitude * granularity
out.append([cur_level,cur_level])
print "sa", switch_amplitude
return Numeric.array(out)
pygame.init()
pygame.mixer.init(11025, 16, 1)
channels = []
channels.append(pygame.mixer.Channel(0))
if not channels[0].get_sound():
channels[0].play(pygame.sndarray.make_sound(tone6()))
The array out in the function tone6 outputs values:
array([[ 10, 10],
[ 20, 20],
[ 30, 30],
[ 40, 40],
[ 50, 50],
[ 60, 60],
[ 70, 70],
[ 80, 80],
[ 90, 90],
[100, 100],
...snip...
[350, 350],
[360, 360],
[370, 370],
[380, 380],
[390, 390],
[400, 400],
[410, 410],
[420, 420],
[430, 430]])
Not sure what I'm doing wrong here. Wrong scale of numbers? Wrong array format? I'm quite stuck at the moment. Someone please educate me.
Thanks a bunch,
--
Andrew Ulysses Baker
"failrate"