# -*- coding: utf-8 -*- """ Editor de Spyder Este es un archivo temporal """ import pygame, math, time import numpy as np import matplotlib.pyplot as plt fs=44100 bits=16 # The size argument represents how many bits are used for each audio sample. # If the value is negative then signed sample values will be used. # Positive values mean unsigned audio samples will be used. pygame.mixer.init(frequency=fs,size=-bits,channels=1) A=2**(bits-1)-1 f = 400 t = np.arange(0,5,1.0/fs) a = A*np.sin(2*math.pi*f*t) a = a.astype(np.int16) #b=np.vstack((a,a)) sound = pygame.sndarray.make_sound(a) #sound = pygame.mixer.Sound("parte1.wav") print("length: "+str(sound.get_length())) r=np.arange(0,1000) sound.play() plt.plot(t[r],a[r]) plt.show() time.sleep(sound.get_length() +1)