I'm creating an experiment where each trial the noise increases. I created the noise using Audacity tone generator. It's a sine noise with 300frequency and 0.5amp. I've fiddled around with a bunch of different noise types but in every few trials, the noise still decreases despite the print(sound.get_volume())
saying that the noise volume is always increasing.
The overall code is very long but here are the parts that involve sound:
sound=pygame.mixer.Sound('sine1hour.wav')
soundPlay = True
def set_volume(initial_v):
if index_for_volume > 0:
initial_v = initial_v + sound_increase_per_trial *
index_for_volume
return initial_v
while pygame.time.get_ticks() < trial_stop:
for event in pygame.event.get():
if event.type == pygame.QUIT or (
event.type == pygame.KEYDOWN and event.key ==
escapeKey):
stop = True
if event.type == pygame.KEYDOWN and event.key == resetKey:
reset = True # if shift key has been pressed
print('resetted')
sound.set_volume(set_volume(initial))
sound.play(-1)
clock.tick()
sound_increase_per_trial = (1 - 0.1)/40
for p in range(num_practice):
stop = PracticedoTrial(recordData, p, sound.get_volume())
if stop:
break
if index_for_volume < 0:
doTrial(recordData, trial, sound.get_volume())
print(sound.get_volume())