Audio: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m Reverted edits by P.dewater (talk) to last revision by E.vandenberge Tag: Rollback |
||
| Line 1: | Line 1: | ||
When using | When using audio in your experiment, especially when presenting time-critical stimuli, special care should be taken to optimize the audio settings on multiple levels (hardware, OS, script), as many things can go wrong along the way. | ||
This page outlines some best practices | This page outlines some best practices, however we advise to always consult a TSG member if you plan to run an audio experiment in the labs. | ||
==Recording== | ==Recording== | ||
When recording | When recording audio for stimuli material or as input for your experiment, please: | ||
Use a high | * Use a high quality microphone, with a [https://www.audio-technica.com/en-us/support/a-brief-guide-to-microphones-whats-the-pattern/ polar pattern] suitable for your application. | ||
Use a high | * Use a high quality recorder or audio interface, capable of recording at 24bit and 48kHz or higher. | ||
* Place the microphone at an appropriate distance from your subject. Set the levels so the audio does not clip (exceeding maximum volume). | |||
Record in a | * Record in a quiet environment. | ||
You can use | |||
You can use our [[Sound Recording Lab]]s for high quality voice recording. | |||
==Editing== | ==Editing== | ||
We recommend using | We recommend using Audacity for editing and converting audio files. Audacity is open-source and fairly easy to use, available here: https://www.audacityteam.org/ | ||
===Export Settings=== | |||
We recommend using the following export settings: | |||
* File format: .wav (PCM). | |||
* Sample Frequency: 48kHz. | |||
* Bit depth: 16 bit. | |||
The [[Lab Computer]] audio output is also set to 16 bit, 48kHz. We found that this is good enough for most applications; higher settings will increase file size with limited perceivable quality gains. | |||
We | |||
When using multiple audio files in your experiment, make sure they all use the same settings for consistent playback in your experiment. | |||
In Audacity, you can set up Macros to automate processing and exporting your audio files: https://manual.audacityteam.org/man/macros.html | |||
==Windows Settings== | ==Windows Settings== | ||
Windows 10 has a habit of automatically enabling ''' | Windows 10 has a habit of automatically enabling '''audio enhancements''' when connecting new speakers or headphones. These "enhancements" can distort your audio and cause timing issues. Therefore, please make sure they are turned off: | ||
# Right click sound icon on taskbar (next to clock) -> Sounds | |||
# Goto Playback tab. Select your audio output device and click "Properties" | |||
# Goto Enhancements tab. Make sure "Disable all enhancements" is checked. | |||
# Click Apply. | |||
==Playback== | ==Playback== | ||
=== | === Psychopy === | ||
This is an example of a Python script that plays a . | This is an example of a Python script that plays a .wav file with high time accuracy. | ||
<syntaxhighlight lang="python" line> | |||
from psychopy import sound, core | |||
from psychopy import prefs | |||
prefs.hardware['audioLib'] = ['PTB'] | |||
# Path to audio file | |||
audio_file = "voice.wav" | |||
# Load audio | |||
# preBuffer – integer to control streaming/buffering -1 means store all | |||
audio = sound.Sound(audio_file,preBuffer=-1) | |||
# Play audio | |||
audio.play() | |||
# Wait for audio to finish playing | |||
core.wait(audio.getDuration()) | |||
Close | # Close audio | ||
audio.stop() | |||
audio.close() | |||
</syntaxhighlight> | |||