Introduction

Overview

In this documentation we do not aim at providing a comprehensive explanation of every single slab function (a complete description can be found in the Reference documentation section). Rather, we want to provide some guidance for you to start generating sounds and running experiments.

For starters, you should have a look at the Sound section. There, you will learn how to generate, manipulate and write/read Sounds in slab. Next, you should see the Psychoacoustics section which is about generating trial sequences and running experiments. With these tools you can already do plenty of things! For example…

The Filters section contains some more advanced, but powerful, methods for processing digital signals. The HRTFs section describes the handling of head related transfer functions and will only be relevant if you are interested in spatial audio.

Frequently Asked Questions

  • Where can I learn enough Python to use this module?

You can find many free courses online. We usually point our students to Google’s Python class. For those of you who prefer video, Coursera has two suitable courses: Python for Everybody and An Introduction to Interactive Programming with Python. There are also courses specifically for sound and signal processing, for instance this one.

  • Which Python environment do you use in the lab?

We recommend miniconda, which bundles Python and the conda package manager and installs quickly. You can then install only the packages that you need for your work, like IPython, numpy, scipy, and matplotlib, with a single command:

conda install ipython numpy scipy matplotlib

When programming we use the command line with IPython and a text editor with a package for syntax highlighting. Some lab members use PyCharm or Spyder as integrated development environments. We don’t recommend IDEs for beginners, because in our experience, students tend to conflate the IDE with Python itself and develop programming habits that they need to unlearn when they want to get productive. You can also use Jupyter notebooks or Google colab for demos (although they may be cumbersome for real experiments), and slab plays nice with these environments. Most classes have methods to represent themselves with nice formatting in notebooks. Sounds will play and display an interactive play button if you set slab.sound._in_notebook=True somewhere at the start of your script.

  • I get import errors when using certain functions!

Slab requires additional modules for some functionality. These modules are not installed automatically because not everyone may need them (such as HRTF file reading) or the installation is OS-dependent (such as SoundFile and curses). Please see Installation for how and what to install should you need it. The import error messages will in most cases give you the necessary installation command for Mac/Linux systems.

  • I have set the level of a sound to 70 dB but it is way louder, why?

This is because slab does not know the hardware you are using to play sound. For example, white noise is generated so that the maximum value in the time series is +1 and the minimum minus one (“full scale”). The RMS of this signal, expressed in deciBels happens to be about 82 dB, but you need to calibrate your system (see Calibrating the output) so that the calculated intensity is meaningful. Relative intensities are correct without calibration—so decreasing the intensity by 10 dB (sound.level -= 10) will work as expected.

  • What is the difference between white noise and pink noise?

White noise is a signal that consists of random numbers. This signal has equal power at all frequencies. However, our auditory system does not perceive it that way, which is why white noise appears high-pitched. In the pink noise signal, the power decreases with frequency to correct for this effect. Pink noise is thus a more appropriate choice for a masking or background noise, because it has the same power in each octave. However, there are even better options. The erb_noise() method constructs a noise with equal energy not in octaves, but in fractions of approximated auditory filters widths (equivalent rectangular bandwidths, ERB). Or the multitone_masker(), which is a noise-like combination of many pure tones at ERB intervals. This noise does not have random amplitude variations and masks evenly across frequency and time.

  • I think I found a bug!

Please see the bug reports section in the contribution guidelines.

  • How can I contribute to the project?

Please see the pull request section in the contribution guidelines if you want to contribute code or useful examples for the documentation.