Skip to content
Browse files

Initial Public Release

  • Loading branch information...
VivekPanyam committed Nov 24, 2015
0 parents commit bd9eb021554834194f00708b9bc0e84864457c4e
Showing with 1,077 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +78 −0
  3. +4 −0 build/examples/test.html
  4. +448 −0 build/examples/test.js
  5. +1 −0 build/kali.min.js
  6. +99 −0 examples/Test.ts
  7. +10 −0 package.json
  8. +277 −0 src/Kali.ts
  9. +121 −0 src/TypedQueue.ts
  10. +19 −0 webpack.config.js
  11. +19 −0 webpack.config.test.js
@@ -0,0 +1 @@
@@ -0,0 +1,78 @@
Kali is used for realtime time-stretching and pitch shifting in Javascript. It can change Tempo and Pitch independently.

From Wikipedia:
> Time stretching is the process of changing the speed or duration of an audio signal without affecting its pitch. Pitch scaling or pitch shifting is the opposite: the process of changing the pitch without affecting the speed. Similar methods can change speed, pitch, or both at once, in a time-varying way.
Kali uses a WSOLA-like algorithm to do high-quality time stretching in the browser

Coming Soon

##Getting Started

Get Kali from the [releases page](

Kali will be published to npm soon.

##Basic Usage
Create a new instance

var kali = new Kali(numChannels);

Set parameters for time stretching. Setting `useQuickSearch` to true will speed up processing at the expense of some quality. By default, it is set to false. The difference is not noticeable in many cases so try setting it to true if you need more performance.

kali.setup(sampleRate, stretchFactor, useQuickSearch);

Feed Kali some data and tell it to process. `dataToInput` should be a Float32Array of interlaced samples.


Read data out into a target array. `targetArray` should be a Float32Array.

var samplesRead = kali.output(targetArray);

Once you're done feeding data, tell Kali to flush its buffers and continue reading data.


That's it! See `Test.ts` in the examples folder for a complete example of usage.


For complete documentation, see [](

By using TypedArrays and views on TypedArrays, Kali operates very efficiently. That said, this is an early release and performance hasn't been optimized as much as possible. Pull requests are welcome!

##Running Examples

- Clone or download this repository
- Put an mp3 file named `test.mp3` in the `build/examples` directory
- Start a server in that directory
- `python -m SimpleHTTPServer`
- Open your browser and navigate to the test page
- e.g. `http://localhost:8000/test.html`

The developer console will show the progress of the file being stretched. Once the stretch is complete, the slowed-down version will begin playing. This example slows down a song by 4% (so a 125 bpm song will be slowed down to 120 bpm).

To change this (or anything else about the example), edit `Test.ts` in the `examples` directory and build as shown below.


npm install

// build examples
webpack --config webpack.config.test.js

// build Kali

// build minified Kali
webpack -p


Kali is based on ideas and code from [SoundTouch]( and [libsox](, both of which are LGPL. Therefore, Kali is also LGPL
@@ -0,0 +1,4 @@
<!-- Put an MP3 file named "test.mp3" in this directory. Start a server and view this page in your browser to listen to a slower version of test.mp3 -->
<script src="test.js"></script>

0 comments on commit bd9eb02

Please sign in to comment.
You can’t perform that action at this time.