Giter Site home page Giter Site logo

korilakkuma / xsound Goto Github PK

View Code? Open in Web Editor NEW
194.0 7.0 16.0 35.34 MB

XSound gives Web Developers Powerful Audio Features Easily !

Home Page: https://xsound.jp

License: MIT License

JavaScript 4.39% CSS 0.44% HTML 0.84% Dockerfile 0.01% TypeScript 94.32%
webaudio webmidi webrtc audio music

xsound's Introduction

XSound - Powerful Audio Features Easily ! -

Node.js CI node-current License: MIT npm jsDelivr

Overview

XSound gives Web Developers Powerful Audio Features Easily !
In concrete, XSound is useful to implement the following features.

  • Create Sound
  • Play the One-Shot Audio
  • Play the Audio
  • Play the Media
  • Streaming (by WebRTC)
  • MIDI (by Web MIDI API)
  • MML (Music Macro Language)
  • Effectors (Compressor / Wah / Equalizer / Tremolo / Phaser / Chorus / Delay / Reverb ... etc)
  • Visualization (Overview in Time Domain / Time Domain / Spectrum)
  • Multi-Track Recording (Create WAVE file)
  • Audio Streaming
  • Visual Audio Sprite

XSound don't depend on other libraries or frameworks (For example, jQuery, React).

Supported Browsers

Supported Browsers are Chrome, Edge, Firefox, Opera and Safari

Getting Started

In case of using as full stack (For example, use oscillator) ...

X('oscillator').setup([true, true, false, false]).ready(2, 5).start([440, 880]).stop();

or, in case of using as module base (For example, use chorus effector) ...

// The instance of `AudioContext`
const context = X.get();

// Create the instance of `Chorus` that is defined by XSound
const chorus = new X.Chorus(context);

const oscillator = context.createOscillator();

// The instance that is defined by XSound has connectors for input and output
oscillator.connect(chorus.INPUT);
chorus.OUTPUT.connect(context.destination);

// Set parameters for chorus
chorus.param({
  time : 0.025,
  depth: 0.5,
  rate : 2.5,
  mix  : 0.5
});

// Activate
chorus.activate();

oscillator.start(0);

XSound enable to using the following classes (Refer to API Documentation for details).

X.Analyser(context: AudioContext);
X.Recorder(context: AudioContext);

// Effectors
X.Autopanner(context: AudioContext);
X.BitCrusher(context: AudioContext);
X.Chorus(context: AudioContext);
X.Compressor(context: AudioContext);
X.Delay(context: AudioContext);
X.Equalizer(context: AudioContext);
X.Filter(context: AudioContext);
X.Flanger(context: AudioContext);
X.Fuzz(context: AudioContext);
X.Listener(context: AudioContext);
X.NoiseGate(context: AudioContext);
X.NoiseSuppressor(context: AudioContext);
X.OverDrive(context: AudioContext);
X.Panner(context: AudioContext);
X.Phaser(context: AudioContext);
X.PitchShifter(context: AudioContext);
X.Preamp(context: AudioContext);
X.Reverb(context: AudioContext);
X.Ringmodulator(context: AudioContext);
X.Stereo(context: AudioContext);
X.Tremolo(context: AudioContext);
X.VocalCanceler(context: AudioContext);
X.Wah(context: AudioContext);

Demo

XSound.app uses this library.

Now, I'm creating website for Web Audio API. Please refer to the following site for understanding API Documentation.

WEB SOUNDER

Installation

$ npm install --save xsound

or,

$ yarn add xsound

Usage

In case of using ES Modules,

import { XSound, X } from 'xsound';

If SSR (Server-Side Rendering), use dynamic imports,

async () => {
  const { XSound, X } = await import('xsound');
};

In case of using CDN,

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/xsound@latest/build/xsound.min.js"></script>

Setup

Use Webpack Dev Server

$ git clone [email protected]:Korilakkuma/XSound.git
$ cd XSound
$ npm install
$ npm run dev
$ open http://localhost:8080/playground/

Use Docker

$ git clone [email protected]:Korilakkuma/XSound.git
$ cd XSound
$ npm install
$ npm run watch
$ docker compose up -d --build
$ open http://localhost:8080/playground/

API Documentation

XSound API Documentation

Playground

XSound Playground (Watch by YouTube).

XSound Playground Screenshot

Migration to v3

Please refer to API Documentation for details.

Case sensitive

// Bad (v2 or earlier)
X('audio').module('panner').param({ coneinnerangle: 240 });

// Good (v3)
X('audio').module('panner').param({ coneInnerAngle: 240 });

Use plain object if parameters setter

// Bad (v2 or earlier)
X('oscillator').get(0).param('type', 'sawtooth');

// Good (v3)
X('oscillator').get(0).param({ type: 'sawtooth' });

Validate parameters on the application side

if ((type === 'sine') || (type === 'square') || (type === 'sawtooth') || (type === 'triangle')) {
  X('oscillator').get(0).param({ type });
}

Migration to v3.1.x or later

If use bundle tool and compress class names such as webpack and terser-webpack-plugin,
must add the following options (because of using inline AudioWorkletProcessor).

new TerserWebpackPlugin({
  // ... other options
  terserOptions: {
    keep_classnames: /^.*?Processor$/
  }
})

Pickups

License

Released under the MIT license

xsound's People

Contributors

korilakkuma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xsound's Issues

multiple audio streams, how to target and pass to XSound?

Description

two audio elements on one page, how to tell XSound which to warp?
I provided an XSound instatiation for each <audio> component , thinking that XSound would be able to identify which audiotrack was internal. It doesn't appear to work, so now I've tried passing the audioTrack.id to XSound setup, but it doesn't appear to work either. Advise, if you could?
Screen Shot 2021-03-08 at 9 10 56 PM
Screen Shot 2021-03-08 at 9 10 45 PM

What version of XSound are you using?

latest

What OS and Browser are you using?

Mac OS 11.1, latest Chrome

OS

  • Windows
  • Mac
  • Linux
  • iOS
  • Android
  • Others

Browser

  • Chrome
  • Firefox
  • Safari
  • Edge
  • Others

Application URL

Console output

Paste the contents of the browser console here.

thanks so much - your library is great (it works fine with one local audiostream)

Question: Download processed audio without playing track

Sorry if this is a silly question, but I'm trying to download the output from an audio module after applying effects without having to play the whole track. With the recorder module, it seems like I'm only able to record while the track is playing. Is there any way to process the whole track and get a AudioBuffer or something like that with the effects applied?

Also, do have an estimate on when #18 will be implemented?

Super cool library you've made. Currently working on a new tool on devina.io. Would you like me to plug any of your socials etc when it's done?

The `module` method cannot get installed `Effector`

Maybe, it is required that fix to return installed Effector, if have installed effector name in default label.

// ...
public module(moduleName: 'wah'): Wah;
public module(moduleName: string): Effector;
public module(moduleName: ModuleName | string): Module | null {
  switch (moduleName) {
    // ...
    case 'wah':
      return this.wah;
    default:
      if (installed(moduleName)) {
        return installedModule;
      }

      return null;
  }
}

Connect to audio element

Hello,
after messing some period with tuna.js i found this library which look much better,
also there is a very weak support in tuna i left a question more than 2 weeks ago and still didn't got an answer,

your library look better, and there is also "equalizer" in it, in a hope to implement it into my app i hope you can provide me any hint how to connect xsound to an audio element? such as i does with tuna?

please take a look at my code:

///	DEFINE AUDIO CONTEXT | (FOR PRIMARY AUDIO ELEMENT) | ON TIMEOUT.
	let audioContext = new AudioContext() || window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.msAudioContext; 

///	DEFINE AUDIO ELEMENT | PRIMARY AUDIO ELEMENT ("PlayBackAudioElement").
	let audio = document.getElementById("PlayBackAudioElement");

///	ANONYMOUS SOURCE CROSS ORIGIN.
	audio.crossOrigin = "anonymous";

/// DEFINE AUDIO SOURCE AS THE HTML AUDIO ELEMENT.
	let source = audioContext.createMediaElementSource(audio);

///	CREATE TUNA INSTANCE FOR ALL EFFECTS - CONECTED TO THE AUDIO CONTEXT.
var tuna = new Tuna(audioContext);

///	CREATE CONNECTION GAIN.
var TunaConnectionINPUT = audioContext.createGain();
var TunaConnectionOUTPUT = audioContext.createGain();

///	REVERB EFFECT.
var reverb = new tuna.Convolver({
    highCut: 19000,							//	20 to 22050
    lowCut: 200,                         	//	20 to 22050
    dryLevel: 0,                        	//	0 to 1+
    wetLevel: 0.5,							//	0 to 1+
    level: 1,                           	//	0 to 1+, TOTAL OUTPUT FOR WET AND DRY.
    impulse: "TunaAssets/impulse_rev.wav",	//	IMPULSE RESPONSE.
    bypass: 0
});

///	CONNECTION:
/// ****************************************************************************************
///	CONNECT REVERB INPUT TO THE REVERB EFFECT.
	TunaConnectionINPUT.connect(reverb);

///	CONNECT REVERB EFFECT TO THE REVERB OUTPUT (CREATED GAIN OUTPUT).
	reverb.connect(TunaConnectionOUTPUT);

///	CONNECT REVERB EFFECT THE AUDIO SOURCE.
	source.connect(reverb);

///	CONNECT REVERB EFFECT TO THE WEB AUDIO ELEMENT OUTPUT STREAM.
	reverb.connect(audioContext.destination);
/// ****************************************************************************************

i am trying to understand how should i connect xsound that way to my audio context?
thank you!

Use `AudioWorklet` (+ WebAssembly) instead of `AnalyserNode` on `Analyser` class

Because AnalyserNode cannot get data for each channel. Therefore, using AudioWorklet instead of AnalyserNode, Analyser class enable to get dat for each channel. Moreover, Analyser class can get not only amplitude spectrum but also phase spectrum.

For example,

X('audio').module('analyser').domain('time', 0);
X('audio').module('analyser').domain('time', 1);
X('audio').module('analyser').domain('fft', 0);
X('audio').module('analyser').domain('fft', 1);
X('audio').module('analyser').domain('phase', 0);
X('audio').module('analyser').domain('phase', 1);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.