A binaural beat is an auditory illusion perceived when two different pure-tone sine waves, both with frequencies lower than 1500 Hz, with less than a 40 Hz difference between them, are presented to a listener dichotically (one through each ear).
This project defines a number of programs and utilities for generating binaural beats:
//engine
: The binaural audio engine: a Scala library which can be consumed by JVM programs//cli
: A Scala CLI program which can generate binaural audio files based on input arguments//dubber
: Some various pydub-based audio utility programs, used during the ensembling steps//dsl
: A declarative DSL (domain-specific-language) implemented in Bazel which can be used to define Bazel targets which will generate binaural beats audio files when invoked with Bazel.
The binaural DSL (domain-specific-language) is the easiest way to work with this toolkit, as each of the libraries and programs defined within is in service to enabling this easy, expressive DSL.
These steps are all that is needed to define advanced, multi-staged binaural beats.
Note: this tutorial assumes you're editing a BUILD file in the root of this repository, and have installed the prerequisites. Examples of consuming these rules in your own WORKSPACE or making use of individual components is coming soon.
load(
"//dsl:dsl.bzl",
"binaural_stems",
"binaural_sequence",
)
Next, we'll invoke the Scala CLI program to generate some "binaural stem tracks".
A "binaural stem track" is a 2 channel (stereo) wav file containing a pure sine wave oscillating at some frequency on exactly one of the channels, with the other being blank. On it's own, there's nothing "binaural" about this audio file, but the CLI program will output two of these files which when taken together will have a binaural beat playing between them.
The binaural CLI program is capable of interleaving these for us, but this is something we'll do manually in a later step for greater control and fidelity.
PITCH = 300 # 300 Hz
DURATION = 60 # 60 seconds
This will generate two wav files (left+right) for an alpha wave binaural beat with a baseline pitch of PITCH
.
Binaural beats in the alpha pattern are at a frequency of 7–13 Hz and may encourage relaxation.
binaural_stems(
name = "alpha-stems",
pitch = PITCH,
binaural_pitch = 10,
duration = DURATION,
)
This will output two intermediate wav files for a beta binaural beat.
Binaural beats in the beta pattern are at a frequency of 13–30 Hz. This frequency range may help promote concentration and alertness.
binaural_stems(
name = "beta-stems",
pitch = PITCH,
binaural_pitch = 20,
duration = DURATION
)
Now we'll use these stem tracks as inputs to a Binaural Sequence.
A Binaural Sequence generates a stereo wav file output from an input list of stem tracks. Each "stem" consists of two wav files (one for each channel) so these are first combined into a single merged stem track, and then each of these merged intermediate files are concatenated together in the order specified below to produce the final output audio file.
This creates the final output, alpha-beta-sequence.wav
, and applies crossfading between stems for a smooth transition, as well as fade-in and fade-out at the beginning and end of the track, respectively:
binaural_sequence(
name = "alpha-beta-sequence",
stems = [
"//:alpha-stems",
"//:beta-stems",
],
crossfade = True,
fade_in = True,
fade_out = True
)
See below for information on how to invoke these targets if you're new to Bazel.
The BUILD
file in the repository root defines some targets which can be built with Bazel to generate binarual beats audio files.
bazel build //:alpha-beta-sequence
will invoke a target in the rootBUILD
file which defines a sequence of binaural beats which first play an alpha wave and then a beta wave.
This program may be useful on it's own to some users - as such, a simple CLI interface is defined and it can be invoked directly if desired.
bazel run //cli:app -- alpha
Usage: binaural [delta|theta|alpha|beta|gamma] [options]
Command: delta
Delta pattern preset; Binaural beats in the delta pattern operate at a frequency of 0.5–4 Hz with links to a dreamless sleep.
Command: theta
Theta pattern preset; Practitioners set binaural beats in the theta pattern to a frequency of 4–7 Hz. Theta patterns contribute to improved meditation, creativity, and sleep in the rapid eye movement (REM) phase.
Command: alpha
Alpha pattern preset; Binaural beats in the alpha pattern are at a frequency of 7–13 Hz and may encourage relaxation.
Command: beta
Beta pattern preset; Binaural beats in the beta pattern are at a frequency of 13–30 Hz. This frequency range may help promote concentration and alertness. However, it can also increase anxiety at the higher end of the range.
Command: gamma
Gamma pattern preset; This frequency pattern accounts for a range of 30–50 Hz. The study authors suggest that frequencies promote maintenance of arousal while a person is awake.
-p, --pitch <value> the frequency in Hz - an integer property
-b, --binaural_pitch <value> the binaural tone's frequency - a decimal property
-d, --duration <value> the duration for which to play the binaural audio - an integer property
- bazel, python, jdk, scala
- ffmpeg (dependency of pydub):
brew install ffmpeg
- sox will soon be required if you want to make use of advanced audio effects
(via Wikipedia)
A binaural beat is an auditory illusion perceived when two different pure-tone sine waves, both with frequencies lower than 1500 Hz, with less than a 40 Hz difference between them, are presented to a listener dichotically (one through each ear).
For example, if a 530 Hz pure tone is presented to a subject's right ear, while a 520 Hz pure tone is presented to the subject's left ear, the listener will perceive the auditory illusion of a third tone, in addition to the two pure-tones presented to each ear. The third sound is called a binaural beat, and in this example would have a perceived pitch correlating to a frequency of 10 Hz, that being the difference between the 530 Hz and 520 Hz pure tones presented to each ear.[citation needed]
Binaural-beat perception originates in the inferior colliculus of the midbrain and the superior olivary complex of the brainstem, where auditory signals from each ear are integrated and precipitate electrical impulses along neural pathways through the reticular formation up the midbrain to the thalamus, auditory cortex, and other cortical regions.[6]
Some potential benefits of binaural beats therapy may include: reduced stress, reduced anxiety, increased focus, increased concentration, increased motivation, increased confidence, and deeper meditation.[7]