hi,
yeah, he had numeric and numpy installed...
I modified the script slightly to tell it to use numpy by default:
http://rene.f0o.com/~rene/stuff/MAKE_SOUND_BUG.py
<http://rene.f0o.com/%7Erene/stuff/MAKE_SOUND_BUG.py>
cu,
On Sun, May 24, 2009 at 10:05 AM, <len-l@xxxxxxxxx
<mailto:len-l@xxxxxxxxx>> wrote:
Hi,
Does DR0ID have Numeric installed? Pygame 1.8.1 sndarray uses
Numeric by default.
Lenard
May 23, 2009 03:31:02 AM, pygame-users@xxxxxxxx
<mailto:pygame-users@xxxxxxxx> wrote:
hi again,
DR0ID tested it on windows and got both the traceback you got,
and the segfault (with python2.6 and pygame 1.8.1). Will get
around to debugging it on windows later.
cu,
On Sat, May 23, 2009 at 6:33 PM, René Dudfield
<renesd@xxxxxxxxx <mailto:renesd@xxxxxxxxx>> wrote:
hello,
I haven't been able to reproduce the problem... I tried
on a ubuntu 32bit, and an osx 10.5.7 32bit python.
So maybe the bug happens only on windows.
I haven't been able to find any places in the code where
make_sound could return anything but a Sound object.
Will try it out on vista later.
cu,
On Wed, May 20, 2009 at 1:22 PM, Brian Brown
<brobab@xxxxxxxxx <mailto:brobab@xxxxxxxxx>> wrote:
Here's an attachment.
On Wed, May 13, 2009 at 9:15 PM, René Dudfield
<renesd@xxxxxxxxx <mailto:renesd@xxxxxxxxx>> wrote:
> hi,
>
> thanks for the awesome bug report.
>
> Is it possible you could send me the file as an
attachment? The email seems
> to have messed with the formatting.
>
> cheers,
>
>
>
>
> On Fri, May 8, 2009 at 8:31 AM, Brian Brown
<brobab@xxxxxxxxx <mailto:brobab@xxxxxxxxx>> wrote:
>>
>>
>>
###################################################################################################
>> # A Pygame BUG Report: (Bug found about May 2009)
>> #
>> # To Pygame People:
>> #
>> # (Best when viewed with a monospaced font.)
>> #
>> # I think I found a glitch/bug . . .
>> #
>> # pygame.sndarray.make_sound() sometimes
returns a "channel"?
>> #
>> # Below is a program that can possibley re-do the
glitch.
>> #
>>
>>
###################################################################################################
>> #
>> # requirements to run:
>> # (python 2.5 or higher)?
>> # and: (pygame 2.8.0 or pygame 2.8.1)?
>> # and: (numpy)?
>> #
>>
>>
###################################################################################################
>> #
>> # On my computer:
>> #
>> # The glitch was found with: (python 2.5.2 +
pygame 2.8.0 + numpy
>> 1.2.1) and: (python 2.6.2 + pygame 2.8.1 + numpy
1.3.0 ).
>> #
>> #
>> # after a while of running (About 2 to 10
minutes), this program
>> closes and give one of these errors?:
>> #
>> # This one: TypeError: argument 1 must be
>> pygame.mixer.Sound, not Channel <--(common)
>> #
>> # Or this one: Fatal Python error:
(pygame parachute)
>> Segmentation Fault <--(rare)
>> # This application has
requested the Runtime
>> to terminate in an unusual way.
>> # . . .
>> #
>> # (I did a google search to see if anybody else
had discovered this
>> glitch--
>> # But-- I didn't find any pages about it . . . )
>> #
>>
>>
###################################################################################################
>> # My computer stats:
>> #
>> # Windows Vista Home Premium
>> # Service Pack 1
>> # win32/32-bit Operating System
>> # Processor: Intel(R) Pentium(R) Dual CPU
E2180 @ 2.00GHz 2.00
>> GHz
>> # RAM/memmory: 3.00 GB
>> #
>>
>>
###################################################################################################
>> #
>> # Here's the program:
>> #
>>
>> def HE_HE_init():
>> global screen
>> global screen_x_size
>> global screen_y_size
>> global channel_max
>> if sys.platform == 'win32' or sys.platform ==
'win64':
>> os.environ['SDL_VIDEO_CENTERED'] = '1'
>>
>> # init the pygame.mixer according to the
pygame version number:
>> versiony_numbery = pygame.version.vernum
>> numby = int(str(versiony_numbery[0]) +
str(versiony_numbery[1]) +
>> str(versiony_numbery[2]))
>> if numby >= 181: pygame.mixer.init(44100, -16, 1)
>> else: pygame.mixer.init(22050, -16, 2)
>>
>> pygame.init()
>> random.seed()
>> channel_max = 5
>> pygame.mixer.set_num_channels(channel_max)
>> screen_x_size = 640
>> screen_y_size = 480
>> screen = pygame.display.set_mode((screen_x_size,
screen_y_size))
>> pygame.mouse.set_visible(1)
>> pygame.display.set_caption('BUG? -->
pygame.sndarray.make_sound() <--
>> BUG?')
>> pygame.display.flip()
>>
>>
>> def Lets_ROLL():
>>
>> previous_channel = None
>>
>> # Some frequencies/Hz/Cycles-per-second:
(ABCDEFGs)
>> noteyish = (440, 493.883, 261.626, 293.665,
329.628, 349.228, 391.995,
>> 440*2.0, 493.883*2.0, 261.626*2.0,
293.665*2.0,
>> 329.628*2.0, 349.228*2.0, 391.995*2.0,
>> 440/2.0, 493.883/2.0, 261.626/2.0,
293.665/2.0,
>> 329.628/2.0, 349.228/2.0, 391.995/2.0
>> )
>>
>> t = time.time()
>>
>>
>>
>>
>> while True: # <-- Main loop
>>
>>
>> # Keep program from running/executing
"too fast":
>> while t > time.time(): pass
>> t = time.time() + 0.10
>>
>>
>>
>> screen.fill((0, 0, 0))
>>
>>
>> # Close the window/program if: [Esc is
pressed] or: [The
>> X button is pressed]
>> key = pygame.key.get_pressed()
>> if key[K_ESCAPE]: END()
>> for event in pygame.event.get():
>> if event.type == QUIT: END()
>>
>>
>> ##### generate/create and display/draw
numpy_sound_data: #####
>>
>> total_duration_in_seconds = .25
>> samples_per_second = 22050
>> total_amount_of_samples =
total_duration_in_seconds *
>> samples_per_second
>> cicles_per_every_second =
noteyish[int(random.random() * ((7 *
>> 3) - 1) )] #440.0
>> numpy_sound_data = array([0] *
int(total_amount_of_samples))
>>
>>
>> # setup some variables for
drawing/displaying numpy_sound_data
>> x = 0
>> y = 200
>> x_dividey = 10
>> y_dividey = 1000
>> y_addy = 200
>> x2 = 0
>> y2 = 400
>> x2_dividey = 2
>> y2_addy_addy = 200
>>
>>
>> # yyygr should cause a "slight" "waver" in the
>> frequencies/Hz/Cycles-per-second
>> yyygr = 0.00001
>> yyygr_speed = 0.0
>> #yyygr_speed = (0.0005 / 2.0) -
random.random() * 0.0005
>>
>> specialy = len(numpy_sound_data) - 1
>> specialyy2 = specialy - 1000
>> specialyy3 = 0 + 300
>> if specialy > 2000: specialy -= 2000
>>
>> for n in range(0, len(numpy_sound_data)):
>>
>> if yyygr < 0:
>> yyygr_speed -= 0.0000005
>> elif yyygr > 0:
>> yyygr_speed += 0.0000005
>> yyygr += yyygr_speed
>>
>> wavey_gurgy = ( float(n) *
float(cicles_per_every_second +
>> yyygr) / float(samples_per_second) )
>>
>> numpy_sound_data[n] = int( math.sin(
wavey_gurgy *
>> radians(360) ) * 20000.0 )
>>
>>
>> # This "pinches" the ends of the
"numpy_sound_data":
>> if n >= specialyy2:
>> numpy_sound_data[n] *= (1.0 - (n -
specialyy2) / 1000.0)
>> if n <= specialyy3:
>> numpy_sound_data[n] *= (n / 300.0)
>>
>> # Draw/plot two stretched versions of
the "numpy_sound_data":
>> xa = x
>> ya = y
>> x = n / x_dividey
>> y = numpy_sound_data[n] / y_dividey + y_addy
>> xa2 = x2
>> ya2 = y2
>> x2 = n / x2_dividey
>> y2 = y + y2_addy_addy
>> pygame.draw.line(screen, (200, 200, 200),
(x, y), (xa, ya))
>> pygame.draw.line(screen, (200, 200, 200),
(x2, y2), (xa2, ya2))
>>
>> pygame.display.flip()
>>
>>
>>
>>
>>
>>
>> ###### convert "numpy_sound_data" to
pygame.mixer.Sound and
>> play it: #######
>>
>>
>> sound_thing = pygame.sndarray.make_sound(
numpy_sound_data )
>> # <-- This should always return a sound, right?
>>
>>
>> if previous_channel != None:
previous_channel.fadeout(300) #
>> <-- Fade out previous sound. (if any)
>>
>>
>> print type(sound_thing)
#
>> <-- Should print:
>>
>>
>> previous_channel =
>> pygame.mixer.find_channel(True).play(sound_thing,
0) # <-- This line
>> is where the program "should" give an error.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> def END():
>> print ''
>> print 'Program ended?'
>> print
>>
"###############################################################################"
>> print
>>
"###############################################################################"
>> print ''
>> pygame.quit()
>> raise SystemExit, ''
>>
>>
>> import os
>> import sys
>> import math
>> import random
>> import time
>> #import gc
>> #import copy as pythoncopy
>> #import string
>> #import struct
>> #from time import strftime, localtime
>> #import wave
>>
>> print ""
>> print
>>
"###############################################################################"
>> print
>>
"###############################################################################"
>> print "Program started? "
>> print ""
>> print ""
>> print ""
>> print ""
>> print ""
>> try:
>>
import
>> pygame
>>
from
>> pygame.locals import *
>>
if not
>> pygame.font: print '?? "pygame.font" not "found" ??'
>>
if not
>> pygame.mixer: print '?? "pygame.mixer" not "found" ??'
>>
from
>> pygame import scrap
>> except: print
>> '"pygame" not "found"???'
>> try:
>>
import
>> numpy; from numpy import *
>> except: print
>> '"numpy" not "found"??? (Oh well! Who cares!)'
>> #try:
>> #
import
>> numarray; from numarray import *
>> #except: print
>> '"numarray" not "found"??? (Oh well! Who cares!)'
>> #try:
>> #
import
>> Numeric; from Numeric import *
>> #except: print
>> '"numeric" not "found"??? (Oh well! Who cares!)'
>>
>> HE_HE_init()
>> Lets_ROLL()
>> END()
>>
>> # Thanks for your effort! I hope the bug will be fixed!
>
>