[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Incrementing the frequency of the Pygame.mixer with a Loop?



'''
How do I change the frequency of the Pygame.mixer by incrementing the
frequency value in a loop?

Please see the example below where I am trying to initialize the frequency at 44100 and then add 2000 to the frequency each time it loops. In this example below the pitch does not change, I really want it to change.

Any links or snippet of code would be greatly appreciated, Thanks!
 
'''

import pygame
from pygame.locals import *
from sys import exit

screen = pygame.display.set_mode((800, 600), 0, 32)
frequency = 44100

while True:

   
frequency = frequency + 2000
    print
frequency

    pygame.mixer.pre_init(
frequency, 16, 2, 4096)
    pygame.init()
    test_sound = ""
    test_sound = pygame.mixer.Sound("check.wav")
    mychannel = test_sound.play()

    while pygame.mixer.get_busy() == True:
        pass
        #"passing"

    pygame.mixer.quit