![matlab 2008 psychportaudio matlab 2008 psychportaudio](https://media.springernature.com/lw685/springer-static/image/art%3A10.3758%2Fs13428-017-0961-z/MediaObjects/13428_2017_961_Fig3_HTML.gif)
- #Matlab 2008 psychportaudio driver
- #Matlab 2008 psychportaudio code
- #Matlab 2008 psychportaudio trial
![matlab 2008 psychportaudio matlab 2008 psychportaudio](https://image1.slideserve.com/1502791/steps-to-playing-a-sound-l.jpg)
start playing a sound with PsychPortAudio('Start').fill audio buffer with PsychPortAudio('FillBuffer').open audio channel with PsychPortAudio('Open').Length of vector is sampling frequency * duration (we want sfreq samples per second for X seconds )Ĭreating sounds > samplingFreq = 48000 > duration = 5 > whitenoise = rand(1,(samplingFreq * duration)) > whoswhitenoise Name Size Bytes Class Attributes whitenoise 1x240000 1920000 double.Preparing sound data for playing > whosfunkData Name Size Bytes Class Attributes funkData 624000x1 4992000 double > funkData = funkData' > funkData = > whosfunkData Name Size Bytes Class Attributes funkData 2圆24000 9984000 double change column to row duplicate to make two rows for stereo Reading in sounds > PsychtoolboxRoot ans = /Applications/Psychtoolbox/ > cd /Applications/Psychtoolbox/PsychDemos/SoundFiles > ls COPYING motor_a8.wav phaser.wav funk.wav motor_b8.wav radar.wav > = wavread('funk.wav') > funkFreq funkFreq = 48000 > whosfunkData Name Size Bytes Class Attributes funkData 624000x1 4992000 double > plot(funkData) Reading from audiofiles = audioread() New Matlab command available in versions 2012b and later, will read many audio formats including WAV, FLAC, MP3, MPEG-4, OGG au files Y = auread(AUFILE) = auread(AUFILE) Reading from wav files Y = wavread(FILE) = wavread(FILE) You can create a sound by generating data for a matrix on your own, or you can read in from a wav file.Samples in the vector should range from -1 to 1, where 0 is silent.
![matlab 2008 psychportaudio matlab 2008 psychportaudio](https://i1.rgstatic.net/publication/354905231_Using_adaptive_psychophysics_to_identify_the_neural_network_reset_time_in_subsecond_interval_timing/links/6153a7842b34872782f77bf4/largepreview.png)
Sound data should be in the form of a matrix where each row is one sound channel.Test your audio setup with BasicSoundOutputDemo.Get help on a subcommand just like Screen:PsychPortAudio Start?.Type PsychPortAudio in the command window to see all of the subcommands, just like Screen.
#Matlab 2008 psychportaudio driver
#Matlab 2008 psychportaudio trial
Each line should contain: the trial number, which picture was presented, where it was presented, which key was pressed, the reaction time, and whether or not the keypress was correct.
#Matlab 2008 psychportaudio code
The log file should be named subjectCode_log.txt where subjectCode is the code that they entered from the command line. On each trial, write out the following information to the next line of a log file.The subject should press S for sad and A for angry. Once the picture appears, wait for the user to press a key.The edge of the picture should always be 100 pixels from the center of the screen, horizontally. The location of the picture will also be randomly chosen between the left and right side of the screen. The picture will randomly be chosen between sad.jpg and angry.jpg. Using a loop, present 20 trials of the following emotion categorization experiment.subjectCode, a string identifying the subject.Create a function called yourInitials_week4().You can draw multiple image textures to the back buffer, and then flip to show them at the same time.Rotating images Screen('DrawTexture', windowPointer, texturePointer ) set rotation angle. To scale an image, change the size of the destination rectangle.Positioning images 0,0 xOffset, yOffset xOffset + imageWidth, yOffset + imageHeight Images myTextureIndex = Screen('MakeTexture',wPtr, imageMatrix)ĭrawing Images Screen('DrawTexture', windowPointer, texturePointer ) rect defining subpart of picture to present, default is whole picture rect defining subpart of screen to present picture in (defaults to center of screen) Images A = imread('mypicture.jpg') = imread('mypicture.jpg') = imread('mypicture.jpg') Use DrawTexture to draw the texture to the screen Use MakeTexture to create an OpenGL texture using that matrix Use imread() to read the image into a matrix of numbers Can do automatic centering if you set sx to "center" or right justify if you set to "right" Can include newline characters in the text string (\n). Set up all the properties of the text we want to draw (font, size, style) using separate commands ĭrawing Text Screen('DrawText',wPtr,text,x,y,color)ĭrawing Formatted Text DrawFormattedText(wPtr,textString,sx,sy,color,wrapat,flipHorizontal,flipVertical, vSpacing, rightoleft, winRect) Advantages over DrawText: Helpful for splitting text into multiple lines. Introduction to PsychToolbox in MATLAB Psych 599, Summer 2013 Jonas Kaplan, Ph.D.