Generating Sound

Hi There!

I use Brown noise throughout my task so I have a few pointers that might help.

  1. Generating the sound/noise. I found it easiest to generate noise outside of psychopy using Audacity (free software available - http://www.audacityteam.org/). Here you can generate most kinds of noise (pink/white/brown) . I then use psychopy to play/stop/set the intensity of this.

  2. I found it better/easier to control the presentation of noise using a code component.

  3. You can adjust the sound following a response using something like the below.

BEFORE LOOKING AT THE CODE NOTE:
you will see that I set my sound using the equation
Vol=((0.34/0.1)/(10**(111.8/20)))*(10**(thisVol/20))

this is because I callibrated my headphones to obtain the following values

Vol=((a/0.1)/(10**(b/20)))*(10**(thisVol/20))

where a is the Psychopy unit level required to output 0.1vRMS (measured with voltmeter), b is the dBSPL output from 0.1vRMS and thisVol is the output required in dBSPL. If you do not have a voltmeter and SPL meter to hand usually this info can be obtained for your speakers/heaphones in the manual. (For your initial set up the code will still work with my values - but its definitely worth calibrating your set up to obtain these values before you begin your experiment)

from __future__ import division
from psychopy import sound, event, visual, core

#set the sound
Noise=sound.SoundPyo('BrownNoiseT.wav')#change this path to your sound/wav file

#What volume do you want to start at in dB.
thisVol =  50
#how much do you want the volume to increase by following a response?
increase=1
#how many trials you want 
trials=10

for i in range(trials):
    Vol=((0.34/0.1)/(10**(111.8/20)))*(10**(thisVol/20))#Changes the volume of the sound in line with current intensity
    Noise.setVolume(Vol)
    print 'sound playing at',thisVol, 'db' 
    Noise.play()
    event.waitKeys()
    Noise.stop()
    thisVol=thisVol+increase

core.quit()

Hopefully this helps/works for you!! let me know if you have any further questions

Becca