Documente Academic
Documente Profesional
Documente Cultură
Acousticstimulus
Acoustic stimulus
AlthoughalargenumberofacousticstimulicanbefoundontheexperimentalPC,itisoftendesirabletodesignyourown.AnumberofMATLABroutineshavebeendevelopedto
generatesinglechannelwavfiles.
Cookbook
Inprinciple,youneedto:
1. generateasignal
2. filterthesignal
3. applyaramp
4. checkforsetupidiosyncrasies
5. writethesignaltoafile
Thesestepsareshowninfigure1,anddescribedbelow.
Figure1.Stepsingeneratinganacousticstimulus.
Thisfigureiscreatedwithpa_how2createsounds_example
1. Signal
ThefollowingMATLABroutinescanbeusedforthemostfrequentlyusedstimulustypes:
pa_gengwngenerateGaussianWhiteNoise(bydefiningarandomlydistributedtime
signal).Thissoundismostoftenusedforsoundlocalizationexperiments.Seebelowforexample.
pa_gengwnflatgenerateGaussianWhiteNoise(bydefiningaflatmagnitudeandrandom
phaseinthefrequencydomain)
pa_gensweepgenerateafrequencysweepwithaflatpowerspectrum.Thisisusedtorecordheadrelatedtransferfunctions.
pa_gentonegenerateapuretone,forsoundelevationlocalizationexperiments
pa_genripplegeneratearipple,forspectrotemporalresolutionelectrophysiologicalandpsychophysicalmeasurements
Guide
Guide
pa_gendmrgeneratedynamicmovingripple
Forthehoop/soundlocalizationsetup,thesamplingrateoftheRP2.1forDAconversionissetat48828.125Hz,sothattheintersamplingdistanceis20.48sec.
2. Filter
http://www.neuralcode.com/index.php/tutorials/stimulus/sound/52acousticstimulus
1/3
3/27/2015
Acousticstimulus
Afterthegenerationofasignal,yougenerallywanttofilteryoursignal,eithertobandpassyoursignal:
pa_lowpasslowpassfilterthesignal(removehighfrequencyfrequenciesthatarenotheard,topreventaliasing,orforspecificresearchquestions)
pa_highpasshighpassfilterthesignal(importanttoremovelowfrequencysignalsthatusuallyendupdistortedwhenplayedbythespeaker)
ortoequalizethesignal:
pa_equalizersotheplayedstimulushasaflatspectrum
3. Ramp
Topreventonsetdistortions,youneedtorampthedata
pa_rampaddasquaredsineonsetandsquaredcosineoffset
4. Level Ramp
Becauseofanidiosyncrasyinoursetup,weneedtopreandappend20millisecondsofzerostothesignal.ThisisbecausethesecondTDTRP2.1DAchannelisusedtocontrol
thesoundlevel.Switchingthisonwillalsocreateasuddenonsetpeak,thatneedstobeprevented.ThisissolvedbyalevelrampwithintheRCO.Weneedtoconsiderthislevel
rampbyapplying:
pa_fart_levelramp
Allsteps(generation,filtering,equalizing,andramping)canbedonebyTDT,butatpresentthistakesprecioustime.
5. Save wav-file
Andwhenthisisdone,weneedtosavethedata,sothatitcanbeusedbytheTDTsystem:
pa_writewavsavesthestimulusasawavfilefortheDAconverter(thisalsoappliesanormalization)
Youcancheckwhetherthestimulusgenerationhassucceeded,with:
wavreadMATLABroutinetoreadanexistingwavfileinMATLABformat
audioplayerMatlabroutinetoplaysounds(wavplay)
psdMatlabroutine,todeterminepowerspectraldensity
pa_getpowergetpowerspectrum
Some examples
LetsgenerateaGWNstimulus.Stimulus3.0sec,bandwidthfrom0.5to20kHz,withonandoffsetenvelopes.
InMatlab:
Noise=pa_gengwn(3);%Defaultenvelope(250pnts)andfilter
%noiseislpfilteredat20kHz
%andhpfilteredat500Hz
psd(Noise);
Frequenciesbelow500Hzareneveruseful,andproducedistortionsonspeakers,sotheyshouldbefilteredoutwithahighpassfilter.Thisisalreadydonebydefaultingengwn.
TheGWNstimulusisawelllocalizablesoundelicitingallbinauraldifference(ITDandILD)cuesandspectralcues.Sometimes,itisdesirabletouselowpassorhighpassfiltered
noise,toseparatetheeffectsofITDandILD.ThesesoundsarecreatedbygeneratingaGWNasabove,andfilteringitwiththefunctionslowpassnoiseandhighpassnoise:
HP=pa_highpass(Noise);%noiseishpfilteredat3kHz
psd(HP);
LP=pa_lowpass(Noise);%noiseislpfilteredat3kHz
psd(LP);
Youmightwanttoequalizethesignal:
Noise=pa_equalizer(Noise);
http://www.neuralcode.com/index.php/tutorials/stimulus/sound/52acousticstimulus
2/3
3/27/2015
Acousticstimulus
HP=pa_equalizer(HP);
LP=pa_equalizer(LP);
Thenapplyaramp:
Noise=pa_ramp(Noise);
HP=pa_ramp(HP);
LP=pa_ramp(LP);
IntheFART1setup,speakerswillhaveononsetrampproducedbytheTDTsystemtoramptoavoltageonthespeakers.Youwillhavetotakethisintoaccount,byputtingzerosin
frontofthestimuli(ofabout20msworth20*48.8828125978samples):
Noise=pa_levelramp(Noise);%This"prepends"thezerovectortotheNoise
HP=pa_levelramp(HP);
LP=pa_levelramp(LP);
Afterthis,youshouldsavethematrixtoawavfile,thatcanbeplayedwiththeTDTsystem:
writewav(Noise,"snd001.wav);
writewav(HP,"snd002.wav");
writewav(LP,"snd003.wav");
http://www.neuralcode.com/index.php/tutorials/stimulus/sound/52acousticstimulus
3/3