Skip to main content

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.

PyPI version License: MIT

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 .aiff by 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 / --force flag.

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mksinewave 1.0.1
File Size Uploaded
mksinewave-1.0.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mksinewave 1.0.1
File Interpreter ABI Platform
mksinewave-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / mksinewave-1.0.1.tar.gz

Download URL mksinewave-1.0.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c12082332a7ef5f4596b1476d4342b33212c03be511dad83f3395251a1ab8fdf
BLAKE2b-256 checksum
How to use checksums
b53868027bfc01afd482b66c01062115ac3e6b6c7402fdee5dd1b437c4fa188e
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.1-py3-none-any.whl

Download URL mksinewave-1.0.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63dbb3194ab6804a4a4678ba48253bee0e84fb539876ed00c88ac2cf8ef365ab
BLAKE2b-256 checksum
How to use checksums
3205e9b6259139cbe4fc62a856e134abd8833c114cea1ca3a35bc9958e5a6602
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 history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page