A Python package for generating binaural beats and brainwave entrainment
Project description
Binaural
A Python package for generating binaural beats and other brainwave entrainment audio.
What are Binaural Beats?
Binaural beats are an auditory illusion perceived when two slightly different frequencies are presented separately to each ear. The brain processes these two frequencies and perceives a third frequency, which is the mathematical difference between the two. This perceived beat frequency can influence brainwave activity and is often used for meditation, relaxation, and cognitive enhancement.
For example, if a 200 Hz tone is played in one ear and a 210 Hz tone is played in the other ear, the brain perceives a binaural beat of 10 Hz. This 10 Hz frequency falls within the alpha brainwave range, which is associated with relaxation and calmness.
Brainwave Frequencies and Their Effects
| Brainwave Type | Frequency Range | Associated Effects |
|---|---|---|
| Delta | 0.5 - 4 Hz | Deep sleep, healing, unconscious mind |
| Theta | 4 - 8 Hz | Meditation, creativity, deep relaxation |
| Alpha | 8 - 14 Hz | Relaxation, visualization, calmness |
| Beta | 14 - 30 Hz | Alertness, concentration, cognition |
| Gamma | 30 - 100 Hz | Higher mental activity, problem-solving |
Features
- Generate binaural beats with customizable frequencies
- Create isochronic tones
- Generate monaural beats
- Adjustable parameters (frequency, duration, amplitude, etc.)
- Support for carrier frequency modulation
- Smooth attack/decay envelopes to prevent audio artifacts
- Multiple output formats (WAV, MP3, etc.)
- Solfeggio frequencies support (UT, RE, MI, etc.)
- Optional carrier frequency modulation
- Customizable waveforms (sine, square, etc.)
Installation
You can install the package via pip:
pip install binaural
Quick Start
Generate a Simple Binaural Beat
from binaural import generate_binaural_beat
# Generate a 10Hz theta binaural beat at 200Hz base frequency
left, right = generate_binaural_beat(
base_frequency=200, # Base frequency in Hz
beat_frequency=10, # Desired beat frequency in Hz
duration=5, # Duration in seconds
)
# Save as WAV file
import scipy.io.wavfile as wavfile
import numpy as np
wavfile.write('binaural_beat.wav', 44100, np.vstack((left, right)).T)
Create an Isochronic Tone
from binaural import generate_isochronic_tone
# Generate a 10Hz isochronic tone at 200Hz
tone = generate_isochronic_tone(
frequency=200, # Tone frequency in Hz
pulse_rate=10, # Pulse rate in Hz
duration=5 # Duration in seconds
)
Generate a Monaural Beat
from binaural import generate_monaural_beat
# Generate a 10Hz monaural beat
beat = generate_monaural_beat(
frequency1=200, # First frequency in Hz
frequency2=210, # Second frequency in Hz
duration=5 # Duration in seconds
)
Generate SolfeggioFrequency
from binaural import SolfeggioFrequency, generate_solfeggio_tone, mix_solfeggio_frequencies
# Generate a single UT (174 Hz) tone for healing
healing_tone = generate_solfeggio_tone(SolfeggioFrequency.UT, duration=5)
# Mix multiple frequencies
mixed = mix_solfeggio_frequencies(
frequencies=[SolfeggioFrequency.UT, SolfeggioFrequency.SOL],
duration=5,
amplitudes=[0.5, 0.5]
)
# Create a binaural beat based on 432 Hz (SOL)
left, right = generate_solfeggio_binaural(
SolfeggioFrequency.SOL,
beat_frequency=7.83, # Schumann resonance
duration=5
)
More
from binaural import (
SolfeggioFrequency,
generate_solfeggio_tone,
mix_solfeggio_frequencies,
generate_solfeggio_binaural,
generate_binaural_beat,
generate_isochronic_tone,
generate_monaural_beat
)
# Generate a single UT (174 Hz) tone for healing
healing_tone = generate_solfeggio_tone(SolfeggioFrequency.UT, duration=5)
# Mix multiple frequencies
mixed = mix_solfeggio_frequencies(
frequencies=[SolfeggioFrequency.UT, SolfeggioFrequency.SOL],
duration=5,
amplitudes=[0.5, 0.5]
)
# Create a binaural beat based on 432 Hz (SOL)
left, right = generate_solfeggio_binaural(
SolfeggioFrequency.SOL,
beat_frequency=7.83, # Schumann resonance
duration=5
)
# Generate a binaural beat with a base frequency of 200 Hz and a beat frequency of 10 Hz
left, right = generate_binaural_beat(
base_frequency=200,
beat_frequency=10,
duration=5
)
# Generate an isochronic tone with a frequency of 10 Hz and a pulse rate of 2 Hz
isochronic_tone = generate_isochronic_tone(
frequency=10,
pulse_rate=2,
duration=5
)
# Generate a monaural beat with frequencies of 200 Hz and 210 Hz
monaural_beat = generate_monaural_beat(
frequency1=200,
frequency2=210,
duration=5
)
Advanced Usage
Binaural Beat with Carrier Frequency
left, right = generate_binaural_beat(
base_frequency=200,
beat_frequency=10,
duration=5,
carrier_frequency=432, # Add carrier frequency modulation
attack=0.5, # Fade in time in seconds
decay=0.5 # Fade out time in seconds
)
API Reference
generate_binaural_beat
def generate_binaural_beat(
base_frequency: float,
beat_frequency: float,
duration: float,
sample_rate: int = 44100,
amplitude: float = 0.5,
carrier_frequency: Optional[float] = None,
attack: float = 0.1,
decay: float = 0.1
) -> Tuple[np.ndarray, np.ndarray]:
"""Generate a binaural beat."""
See function docstrings for detailed parameter descriptions and usage.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Repository Views
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binaural-0.1.2.tar.gz.
File metadata
- Download URL: binaural-0.1.2.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38785a7c88f0429a37a5ebbb1e8b08b40182d27db619f60491525ace70039046
|
|
| MD5 |
41e96a48fe7a60619a8d0a3d8cbd3630
|
|
| BLAKE2b-256 |
dc84d36d68a81b51657b65fce88bc260dd856140905409bac13a261c6d768b10
|
File details
Details for the file binaural-0.1.2-py3-none-any.whl.
File metadata
- Download URL: binaural-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab4a0c88e5ca8fe07d29e3b0f0f8fc69ae3fc178845f4b7c707c0e6b0319254a
|
|
| MD5 |
3c6203e5f7385b847ca86f852a0f5c46
|
|
| BLAKE2b-256 |
1a86404295c828a4b2519460e127f0bee592864d756fbcc3052b52f80df36580
|