I'm following this example from the book 'math for programmers' but it doesn't work for me:
import pygame, pygame.sndarray
pygame.mixer.init(frequency=44100, size=-16, channels=1)
import numpy as np
arr = np.random.randint(-32768, 32767, size=44100)
sound = pygame.sndarray.make_sound(arr)
sound.play()
It returns these errors:
... in make_sound return numpysnd.make_sound(array)" ... in make_sound return mixer.Sound(array=array) ValueError: Array must be 2-dimensionarl for stereo mixer"
The code seems to work for the author but i've tried many different ways to solve it but have failed, any ideas?