Skip to content

dmeldrum6/Audio-Watermarking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Audio Watermarking System

A sophisticated browser-based audio watermarking system that embeds and detects invisible, robust digital watermarks in audio files. Built using advanced signal processing techniques including psychoacoustic masking, spread spectrum modulation, and error correction coding.

Overview

This project provides a complete end-to-end audio watermarking solution consisting of two main components:

  1. Embedder - Embeds invisible watermarks into audio files
  2. Detector - Detects and extracts watermarks from audio files

Both tools run entirely in the browser using JavaScript, requiring no server-side processing. They implement state-of-the-art digital signal processing techniques to create watermarks that are:

  • Invisible: Perceptually transparent to human listeners
  • Robust: Resistant to various signal processing operations
  • Secure: Uses cryptographic spreading sequences
  • Reliable: Incorporates error correction coding

What is Audio Watermarking?

Audio watermarking is the process of embedding imperceptible data (the "watermark") into an audio signal. Unlike metadata that can be easily stripped, watermarks are embedded directly into the audio samples themselves and remain part of the signal even after format conversions, compression, or other processing.

Use Cases

  • Copyright Protection: Prove ownership of audio content
  • Broadcast Monitoring: Track when and where content is played
  • Leak Tracking: Identify the source of unauthorized distribution
  • Content Authentication: Verify audio hasn't been tampered with
  • Metadata Embedding: Store information within the audio itself

Quick Start

Embedding a Watermark

  1. Navigate to the embedder/ directory
  2. Open index.html in a modern web browser
  3. Load an audio file (WAV or MP3)
  4. Enter your watermark data (up to 50 characters)
  5. Click "Embed Watermark"
  6. Download the watermarked audio file

Example:

Input Audio: song.wav
Watermark Data: "12345ABCD"
Output: song_watermarked.wav

Detecting a Watermark

  1. Navigate to the detector/ directory
  2. Open index.html in a modern web browser
  3. Load a watermarked audio file
  4. Click "Detect Watermark"
  5. View detection results and extracted data

Example Output:

✓ Watermark Detected
Confidence Score: 87.3%
Extracted Data: "12345ABCD"

Technical Highlights

Advanced Signal Processing

  • FFT/IFFT: Fast Fourier Transform for frequency domain processing
  • Psychoacoustic Masking: Embeds watermark below human hearing threshold
  • Spread Spectrum: PN (Pseudo-Random Noise) sequence spreading with 4x redundancy
  • Error Correction: Reed-Solomon coding (can correct up to 5 symbol errors)
  • Temporal Integration: Combines detection across multiple frames

Psychoacoustic Model

The embedder uses a sophisticated psychoacoustic model based on:

  • Bark Scale: Perceptual frequency scale matching human auditory system
  • Critical Bands: 24 bands matching auditory filter banks
  • Masking Threshold: Simultaneous masking using spreading function
  • ATH: Absolute Threshold of Hearing (frequency-dependent)

This ensures watermarks remain completely inaudible while maintaining robustness.

Detection Algorithm

The detector uses correlation-based detection to find the watermark:

  1. Frame Analysis: Processes overlapping audio frames
  2. Feature Extraction: Extracts frequency domain features
  3. PN Correlation: Correlates with known spreading sequence
  4. Temporal Integration: Combines results across frames with confidence weighting
  5. Error Correction: Applies Reed-Solomon decoding
  6. Verification: Validates extracted data integrity

System Architecture

Audio Watermarking System
│
├── Embedder
│   ├── Audio Input (WAV/MP3)
│   ├── Frame Segmentation
│   ├── FFT Analysis
│   ├── Psychoacoustic Analysis
│   ├── Watermark Encoding (Reed-Solomon + PN Spreading)
│   ├── Magnitude Modification
│   ├── IFFT Reconstruction
│   └── Audio Output (WAV)
│
└── Detector
    ├── Audio Input (WAV/MP3)
    ├── Frame Segmentation
    ├── FFT Analysis
    ├── Feature Extraction
    ├── PN Correlation
    ├── Temporal Integration
    ├── Watermark Decoding (Reed-Solomon)
    └── Results Output (JSON)

Project Structure

Audio-Watermarking/
├── README.md                    # This file
├── LICENSE                      # Project license
│
├── embedder/                    # Watermark embedding tool
│   ├── index.html              # Web interface
│   ├── main.js                 # UI controller
│   ├── watermark.js            # Main watermarking engine
│   ├── psychoacoustic.js       # Psychoacoustic masking model
│   ├── fft.js                  # FFT implementation
│   ├── reed-solomon.js         # Error correction
│   └── README.md               # Embedder documentation
│
└── detector/                    # Watermark detection tool
    ├── index.html              # Web interface
    ├── main.js                 # UI controller
    ├── detector.js             # Detection engine
    ├── fft.js                  # FFT implementation
    ├── reed-solomon.js         # Error correction
    └── README.md               # Detector documentation

Key Features

Embedder Features

  • Invisible watermarking below psychoacoustic masking threshold
  • Robust error correction (Reed-Solomon coding)
  • Spread spectrum security
  • Real-time progress tracking
  • Configurable embedding strength
  • Support for WAV and MP3 input
  • Audio preview before download

Detector Features

  • Correlation-based detection
  • Confidence scoring
  • Temporal integration across frames
  • Automatic error correction
  • Detailed detection statistics
  • Support for WAV and MP3 input
  • Export results as JSON

Technical Specifications

Parameter Default Value Range Description
Frame Size 2048 samples 1024-4096 FFT window size
Overlap 50% 25-75% Frame overlap percentage
Embed Strength 0.01 0.001-0.1 Watermark amplitude
Temporal Redundancy 3x 1-10x Repetition factor
Frequency Range 500-8000 Hz - Embedding frequency band
Spreading Factor 4x - PN sequence spreading
ECC Symbols 10 - Reed-Solomon error correction
Max Data Length 50 chars - Maximum watermark size

Browser Requirements

Both tools require a modern browser with support for:

  • Web Audio API
  • FileReader API
  • Typed Arrays (Float32Array, Uint8Array)
  • ES6+ JavaScript features (async/await, classes, arrow functions)

Tested on:

  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+

Performance

Processing time varies based on audio duration, sample rate, and settings:

Audio Duration Sample Rate Typical Processing Time
30 seconds 44.1 kHz 2-5 seconds
3 minutes 44.1 kHz 10-20 seconds
10 minutes 44.1 kHz 30-60 seconds

Times measured on modern desktop hardware. Mobile devices may be slower.

Limitations

  1. Parameter Matching: Detector settings must match embedder settings

    • Frame size
    • Temporal redundancy
    • Spreading factor
    • PN sequence seed
  2. No Synchronization: Current version assumes:

    • No time-shifting or trimming
    • Same sample rate as original
    • No sample position changes
  3. Single Channel: Only processes first channel of stereo audio

  4. Limited Attack Resistance: Not extensively tested against:

    • Heavy lossy compression
    • Aggressive filtering/EQ
    • Time stretching or pitch shifting
    • Analog recording and playback
  5. Format Limitations:

    • Embedder outputs WAV only
    • No MP3 output encoding (yet)

Getting Started

For End Users

  1. Clone or download this repository

    git clone https://github.com/yourusername/Audio-Watermarking.git
    cd Audio-Watermarking
  2. No installation required! Just open the HTML files:

    • embedder/index.html - To embed watermarks
    • detector/index.html - To detect watermarks
  3. Read the detailed documentation:

For Developers

Both tools are implemented in vanilla JavaScript with no external dependencies. Key modules:

  • fft.js: Cooley-Tukey radix-2 FFT implementation
  • reed-solomon.js: Reed-Solomon error correction over GF(256)
  • psychoacoustic.js: Psychoacoustic masking model
  • watermark.js / detector.js: Core embedding/detection logic
  • main.js: UI controller and audio I/O

All code is well-commented and modular for easy understanding and modification.

How It Works (Simplified)

Embedding Process

  1. Load audio file and convert to frequency domain (FFT)
  2. Analyze psychoacoustic properties to find "hiding spots"
  3. Encode watermark data with error correction
  4. Spread data using pseudo-random sequence
  5. Embed into selected frequency bins below masking threshold
  6. Convert back to audio (IFFT) and save

Detection Process

  1. Load potentially watermarked audio
  2. Convert to frequency domain (FFT)
  3. Correlate with known spreading sequence
  4. Combine detection results across frames
  5. Decode using error correction
  6. Extract and verify watermark data

Future Enhancements

  • Synchronization codes for time-shift resilience
  • Multi-channel stereo processing
  • MP3 output encoding
  • Automatic parameter detection
  • Comprehensive robustness testing
  • Batch processing support
  • Visual spectrogram display
  • Mobile app versions
  • Real-time streaming watermarking

Research & References

This implementation is based on research in:

Psychoacoustic Masking

  • Zwicker, E., & Fastl, H. (1999). Psychoacoustics: Facts and Models
  • ISO/IEC 11172-3 (MPEG-1 Audio Layer 3)

Spread Spectrum Watermarking

  • Cox, I. J., et al. (2008). Digital Watermarking and Steganography
  • Kirovski, D., & Malvar, H. (2003). Spread-spectrum watermarking of audio signals

Detection Theory

  • Kay, S. M. (1998). Fundamentals of Statistical Signal Processing: Detection Theory

Error Correction

  • Reed, I. S., & Solomon, G. (1960). Polynomial Codes Over Certain Finite Fields

License

See LICENSE file for details.

Educational Purpose

This is an educational implementation demonstrating audio watermarking concepts. It is suitable for:

  • Learning about digital signal processing
  • Understanding psychoacoustic principles
  • Studying error correction codes
  • Research and experimentation
  • Academic projects

Disclaimer

Important Notes:

  1. This tool is for educational and research purposes only
  2. Ensure you have the right to modify any audio files you process
  3. Watermarking does not constitute legal proof of ownership without proper certification infrastructure
  4. Detection results should be validated independently
  5. False positives are possible with low correlation thresholds
  6. Not intended for production use without further robustness testing

Contributing

Contributions are welcome! Areas for improvement:

  • Enhanced attack resistance
  • Better synchronization mechanisms
  • Additional output format support
  • Performance optimizations
  • Comprehensive test suite
  • Documentation improvements

Support

For detailed usage instructions and technical documentation:


Built with: Vanilla JavaScript, Web Audio API, Digital Signal Processing

Keywords: Audio Watermarking, Spread Spectrum, Psychoacoustics, FFT, Reed-Solomon, Digital Signal Processing, Copyright Protection

About

Browser based audio watermarking system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors