Skip to content

HenSeries/NaniStyle

Repository files navigation

NaniStyle Distortion Plugin

A professional-grade distortion plugin inspired by Nani Distortions, featuring multiple distortion algorithms, real-time audio processing, and a modern, intuitive interface.

Features

🎛️ 6 Distortion Algorithms

  • Soft Clip: Tube-like saturation with smooth harmonic generation
  • Hard Clip: Aggressive clipping for intense distortion
  • Foldback: Wave folding distortion for complex harmonics
  • Bit Crusher: Digital bit reduction for lo-fi effects
  • Wave Folder: Complex wave folding for experimental sounds
  • Polynomial: Harmonic distortion with mathematical precision

🎚️ Professional Controls

  • Drive: Controls the amount of distortion applied
  • Tone: Pre and post-filtering for tone shaping
  • Mix: Blend between dry and processed signal
  • Output: Master output level control

🎨 Modern Interface

  • Real-time waveform visualization
  • Intuitive knob controls with value displays
  • Built-in presets for quick setup
  • Responsive design with professional styling

Real-time Processing

  • Web Audio API integration
  • AudioWorklet support for low-latency processing
  • Fallback to ScriptProcessor for compatibility
  • Stereo processing support

Installation

Prerequisites

  • Node.js (v14 or higher)
  • Modern web browser with Web Audio API support

Setup

  1. Clone or download the plugin
  2. Install dependencies:
npm install
  1. Build the plugin:
npm run build
  1. Open demo.html in your browser to test the plugin

Usage

Basic Usage

import NaniStyleDistortion from './dist/index.js';

// Create plugin instance
const distortion = new NaniStyleDistortion({
    container: document.getElementById('plugin-container'),
    autoInitialize: true
});

// Set parameters
distortion.setDrive(0.7);
distortion.setTone(0.6);
distortion.setMix(0.8);
distortion.setOutput(0.5);
distortion.setDistortionType('soft');

// Connect to audio
const audioContext = new AudioContext();
const input = audioContext.createMediaStreamSource(stream);
const output = audioContext.destination;

await distortion.connectAudio(input, output);

Advanced Usage

// Load presets
const presets = distortion.getPresets();
distortion.loadPreset(presets[0]); // Load first preset

// Get current parameters
const params = distortion.getParameters();
console.log(params);

// Process audio data offline
const audioData = new Float32Array(1024);
const processed = distortion.processAudioData(audioData);

// Process stereo audio
const leftChannel = new Float32Array(1024);
const rightChannel = new Float32Array(1024);
const stereoResult = distortion.processStereoAudioData(leftChannel, rightChannel);

API Reference

Constructor Options

const options = {
    container: HTMLElement,    // DOM element for UI
    autoInitialize: boolean   // Auto-initialize on creation
};

Parameter Methods

  • setDrive(value) - Set drive amount (0-1)
  • setTone(value) - Set tone control (0-1)
  • setMix(value) - Set mix amount (0-1)
  • setOutput(value) - Set output level (0-1)
  • setDistortionType(type) - Set distortion algorithm

Audio Methods

  • connectAudio(input, output) - Connect audio nodes
  • disconnectAudio() - Disconnect audio
  • processAudioData(data) - Process audio buffer
  • processStereoAudioData(left, right) - Process stereo audio

Utility Methods

  • getParameters() - Get current parameters
  • getPresets() - Get available presets
  • loadPreset(preset) - Load a preset
  • reset() - Reset to default state
  • destroy() - Clean up resources

Distortion Types

Soft Clip

  • Description: Tube-like saturation with smooth harmonic generation
  • Best for: Warm, musical distortion
  • Characteristics: Smooth compression, even harmonics

Hard Clip

  • Description: Aggressive clipping for intense distortion
  • Best for: Heavy, aggressive sounds
  • Characteristics: Sharp clipping, rich harmonics

Foldback

  • Description: Wave folding distortion for complex harmonics
  • Best for: Experimental and industrial sounds
  • Characteristics: Complex harmonic content, aliasing effects

Bit Crusher

  • Description: Digital bit reduction for lo-fi effects
  • Best for: Retro and digital distortion
  • Characteristics: Quantization noise, digital artifacts

Wave Folder

  • Description: Complex wave folding for experimental sounds
  • Best for: Modular synth-style distortion
  • Characteristics: Complex modulation, frequency folding

Polynomial

  • Description: Harmonic distortion with mathematical precision
  • Best for: Precise harmonic control
  • Characteristics: Controlled harmonics, mathematical accuracy

Presets

The plugin includes 6 built-in presets:

  1. Tube - Warm tube saturation
  2. Fuzz - Aggressive fuzz distortion
  3. Bit Crush - Digital bit crushing
  4. Fold - Wave folding distortion
  5. Wave - Complex wave folding
  6. Poly - Polynomial distortion

Browser Compatibility

  • Chrome 66+ (AudioWorklet support)
  • Firefox 76+ (AudioWorklet support)
  • Safari 14.1+ (AudioWorklet support)
  • Edge 79+ (AudioWorklet support)

For older browsers, the plugin falls back to ScriptProcessor (deprecated but functional).

Development

Project Structure

NaniStyleDistortion/
├── src/
│   ├── DistortionEngine.js    # Core distortion algorithms
│   ├── AudioProcessor.js      # Web Audio API integration
│   ├── UI.js                  # User interface
│   └── index.js               # Main entry point
├── dist/
│   └── index.js               # Built plugin
├── demo.html                  # Demo page
├── distortion-worklet.js      # AudioWorklet processor
├── package.json               # Dependencies
├── webpack.config.js          # Build configuration
└── README.md                  # This file

Building

# Development build with watch
npm run dev

# Production build
npm run build

# Run tests
npm test

Customization

Adding New Distortion Types

// In DistortionEngine.js
newDistortionType(input, drive) {
    // Your distortion algorithm here
    return processedInput;
}

// Add to switch statement in process() method
case 'newtype':
    processed = this.newDistortionType(processed, this.drive);
    break;

Custom Presets

const customPreset = {
    name: 'Custom',
    drive: 0.5,
    tone: 0.7,
    mix: 0.9,
    output: 0.6,
    type: 'soft'
};

distortion.loadPreset(customPreset);

License

MIT License - see LICENSE file for details.

TODO

  1. Test in a wider browser spectrun js plugin
  2. Complete migration to vst (ableton compatible) plugin (c++)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Acknowledgments

  • Inspired by Nani Distortions plugin
  • Built with Web Audio API
  • Uses modern JavaScript features
  • Designed for professional audio applications

Support

For issues, questions, or feature requests, please open an issue on the repository.


NaniStyle Distortion - Professional distortion processing for the web.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published