[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] mixer/sndarray voes
- To: pygame-users@xxxxxxxx
- Subject: [pygame] mixer/sndarray voes
- From: Olof Bjarnason <olof.bjarnason@xxxxxxxxx>
- Date: Fri, 22 Jan 2010 12:31:50 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Fri, 22 Jan 2010 06:37:32 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=/p55sVeKbj2afK+Cd6LFn2Wh9GIkaPJmVtYbdHC7EZ8=; b=n8IHvyEDtYYapT514knvvM3kkoaSQWFJigYnvYiwuUKKwfRd2uYSfWJ3abqhPFpDwE rW3gXLvfjG9kd/UMoykP9jLp4k2QHf89Zyzu6SsjhLxO7zWhKS8/zpHkbDG0q+DpW9vA fdaKYxLnSfrW4J9xh1xhVdBqLO5DIeay+tB1I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=swj6JZXfxiSiTBtBe47mDFST/J6jeaQClDflgRbw5w4BBvaDfN/zmDxiVP7aoxvQUo UMw/K1zqIJRGUdmEVuREGNk8F1vq02wLIZzDTr04rfkzX1hv8CvN/oNLPa13BjxyMmfC 5HM5lbKo0XUkpyXlS2QTd/nAY2PWp8WFoblDc=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
OS: Ubuntu 9.04
Python: 2.6.2
PyGame: 1.8.1release
I'm trying to generate some sounds with pygame.
I was hindered some by how to use sndarray - but it all got easier
once I set the mixer-init to easy/retro defaults.
The first experiment was to just play a "sawtooth" wave:
<code src="sndtest.py">
import pygame
import Numeric
pygame.mixer.pre_init(11025,8,1,4096) #mono, unsigned, 8-bit sound. C64 ;)
pygame.init()
print pygame.mixer.get_init() # to make sure I got what I wanted, just
watch stdout
pygame.sndarray.make_sound(Numeric.array(range(250)*100)).play()
while pygame.mixer.get_busy():
pygame.time.wait(200)
</code>
'python sndtest.py' produces slightly different audio each time.
I improved readability a little, to find out where I did go wrong, and
to my great surprise, this *silenced* my speakers:
<code src="sndtest2.py">
import pygame
import Numeric
pygame.mixer.pre_init(11025,8,1,4096) #mono, unsigned, 8-bit sound. C64 ;)
pygame.init()
print pygame.mixer.get_init() # to make sure I got what I wanted, just
watch stdout
seq = range(250)*100
na = Numeric.array(seq)
snd = pygame.sndarray.make_sound(na)
snd.play()
while pygame.mixer.get_busy():
pygame.time.wait(200)
</code>
'python sndtest2.py' only produces a low-volume "spark" then nothing
each time run.
What am I doing wrong here? There is no randomness in 'sndtest.py',
and 'sndtest2.py' should at least produce the same output, afaiks.
--
twitter.com/olofb
olofb.wordpress.com