Skip to main content

An OpenSesame Plug-in for playing and recording audio files with low latency on Linux

Project description

OpenSesame Plug-in: Audio Low Latency

An OpenSesame plug-in for playing and recording audio files with low latency.

Copyright, 2022, Bob Rosbag

About

The main goal of this plug-in is to play and record audio with minimal and predictable latencies to achieve a high accuracy and precision. The 'PyAlsaAudio' package which uses the Linux ALSA audio system provided the best results within Python. 'PortAudio' and 'sounddevice' are cross-platform and work on both Windows as Linux.

This plug-in consist of playback and recording items as well as foreground as background (multi-threaded) items. Both playback and recording have their own init item. These should be placed at the beginning of an experiment.

Difference between foreground and background:

  • Foreground items play/record until the file ends or the set duration has passed.
  • Background items consist of a 'start', 'wait' and 'stop' item. These are fully multi-threaded. After the start of the playback/recording, the item will immediately advance to the next item. When it reaches the 'stop' or 'wait' item, it will stop the audio or wait until the file ends or duration has passed.

Seven items for playback:

  • Play Init initialization of the playback audio device, this should be placed at the beginning of an experiment.

Foreground:

  • Play starts the playback of audio, it will play the entire audio file or will stop after the set duration has passed before continuing to the next item in the experiment.

Background:

  • Play Start starts the playback of audio, it will directly advance to the next item in the experiment.

  • Play Wait waits until the thread from 'Play Start' is finished (end of audio or surpassing the duration) before advancing to the next item in the experiment.

  • Play Stop sends a stop signal to the 'Play Start' thread to stop immediately and checks if the thread has finished.

  • Play Pause pauses playback of audio.

  • Play Resume resumes playback of audio.

Seven items for recording:

  • Record Init initialization of the playback audio device, this should be placed at the beginning of an experiment.

Foreground:

  • Record starts the recording of audio, it will record for the set duration before continuing to the next item in the experiment.

Background:

  • Record Start starts the recording of audio, it will directly advance to the next item in the experiment.

  • Record Wait waits until the thread from 'Record Start' is finished (surpassing the duration) before advancing to the next item in the experiment.

  • Record Stop sends a stop signal to the 'Record Start' thread to stop immediately and checks if the thread has finished.

  • Record Pause pauses recording of audio.

  • Record Resume resumes recording of audio.

Timestamps can be found in the log file by the name: time_stimulus_onset_[item_name]

Known bugs:

  • Recording with the PyAudio module does not seem to work at the moment

License

This software is distributed under the terms of the GNU General Public License 3. The full license should be included in the file COPYING, or can be obtained from:

This plug-in contains works of others. Icons are derivatives of the Faience icon theme, Faenza icon theme and Papirus icon theme.

Documentation

Installation instructions and documentation on OpenSesame are available on the documentation website:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opensesame_plugin_audio_low_latency-10.9.1.tar.gz (120.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opensesame_plugin_audio_low_latency-10.9.1.tar.gz.

File metadata

File hashes

Hashes for opensesame_plugin_audio_low_latency-10.9.1.tar.gz
Algorithm Hash digest
SHA256 1ff676b4b24f55c6c71502b988e477ce33351ae9c29f3ab6cca404ee6d626991
MD5 7ea13c67aac854f8a3fca40829f24d66
BLAKE2b-256 d052edb2ab206dd0a576a524ec4872f2aeb0c1a82fd2f5d28421a07a010cb01c

See more details on using hashes here.

File details

Details for the file opensesame_plugin_audio_low_latency-10.9.1-py3-none-any.whl.

File metadata

File hashes

Hashes for opensesame_plugin_audio_low_latency-10.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e3cb0bd748f26190ec96d81108e77a8a20550f76fa6a1053555531d0419f6c5
MD5 9c757c461ec4a2d03280f4cf8a2d2712
BLAKE2b-256 60298316901de48767334e273c450edb5ccdc956b82fd68d991d702e7991cc64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page