mksinewave
mksinewave is a Python command-line utility for generating pure sine wave audio tones with customizable configurations, smooth attenuation fades, and automatic audio container inference.
Features
- Flexible Frequency Formats: Accepts standard numbers (
440), human-friendly shortcuts (1.4k'), or explicit units (22kHz`). - Smart Fades: Prevent harsh audio pops and clicks with customizable linear head and tail attenuation (fade-in/fade-out).
- FFmpeg-Style Extension Inference: Saves directly to
.wav,.flac,.ogg, or.aiffby automatically detecting the format from your output filename. - Safety Proofed: Includes built-in human hearing range guards (20 Hz - 22 kHz) and Nyquist frequency anti-aliasing checks.
- Safe Overwriting: Protects existing files unless exlplicitly overridden with the
-f / --forceflag.
Installation
Clone the repository and install it locally using pip:
pip install mksinewave
For active local development, install using the [dev] optional dependency group in editable mode:
pip install -e "mksinewave[dev]"
Usage
Once installed, the global mksinewave command is available anywhere on your system.
Basic Syntax
mksinewave <frequency> <duration> [options]
Examples
1. Generate a standard A4 tone (440Hz) for 3 seconds:
mksinewave 440 3
2. Generate a 1.5 khz tone for 5 seconds as a compressed FLAC file with a smooth fade-in and fade-out:
mosinewave 1.5k 5 --fade-sin 0.5 --fade-out 1.0 -o output.flac -v
3. Force overwrite an existing file using a specific sample rate:
mksinewave "2.2 kHz" 2.5 -s 48000 -o alert.ogg -f
Available Command-Line Flags
- --fade-in: Length of head attenuation fade-in in seconds (Default: 0.0).
- --fade-out: Length of tail attenuation fade-out in" seconds (Default: 0.0).
- -s, --sample-rate: Audio sampling rate in Hz (Default: 44100).
- -o, --output: Output filepath inferred via extension (Default: sine_wave.wav).
- -f, --force: Overwrite the target file if it already exists.
- -v, --verbose: Enable logging output detailing the generation process.
- frequency (Positional): Target frequency. Supports formats like 440, 1.4k, 22kHz.
- duration (Positional): Total length of the audio track in seconds.
Development & Testing
This project maintains rigorus test coverage using pytest and pytest-cov.
If you installed the development dependencies, you can execute the test suite globally from the project root directory:
test-mksinewave
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for mksinewave 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mksinewave-1.0.0.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mksinewave-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / mksinewave-1.0.0.tar.gz
| Download URL | mksinewave-1.0.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a7636a9fdc3c091c9a10cf43c187c9def90dfe5fa073883fc0c4d546133a120
|
|
BLAKE2b-256 checksum How to use checksums |
ee25a8ba16f257940e0d73b1084c98950f022f51cb56b45da19f6d4257a62a8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.9 Linux/6.17.0-PRoot-Distro
|
Release files / mksinewave-1.0.0-py3-none-any.whl
| Download URL | mksinewave-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53a16db2c227d30dde09e419c6181eed9d6532c5be0950073dec66afa9fdb0fb
|
|
BLAKE2b-256 checksum How to use checksums |
a4f0e464c4137880661d9c66c6dfdaeb470e627fcbc92c681c9bea96d9faab56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.9 Linux/6.17.0-PRoot-Distro
|