All Projects → jackedgson → crunker

jackedgson / crunker

Licence: MIT license
Simple way to merge or concatenate audio files with the Web Audio API.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to crunker

react-redux-webaudio
An event manager for the Web Audio API, integrated with react-redux.
Stars: ✭ 23 (-88.89%)
Mutual labels:  webaudio-api
X-Piano
Now you can make your own piano!
Stars: ✭ 13 (-93.72%)
Mutual labels:  webaudio-api
step-sequencer
multimeter sequencer using react.js and tone.js
Stars: ✭ 18 (-91.3%)
Mutual labels:  webaudio-api
websynth
Web Synthesizer From Space
Stars: ✭ 16 (-92.27%)
Mutual labels:  webaudio-api
Project14-A-Web-Audio-Editor
🔊 AUDI ✨클라이언트 기반 웹 음성 편집기(audio editor)✨
Stars: ✭ 28 (-86.47%)
Mutual labels:  webaudio-api
concat
🐱 concatenate files
Stars: ✭ 38 (-81.64%)
Mutual labels:  concatenate
web-voice-processor
A library for real-time voice processing in web browsers
Stars: ✭ 69 (-66.67%)
Mutual labels:  webaudio-api
bundle-js
Bundle your inter-dependent Javascript files in the correct order
Stars: ✭ 21 (-89.86%)
Mutual labels:  concatenate
windows-equalizer
Prototype of music equalizer using browser windows and the Web Audio API
Stars: ✭ 48 (-76.81%)
Mutual labels:  webaudio-api
Webamp
Winamp 2 reimplemented for the browser
Stars: ✭ 8,268 (+3894.2%)
Mutual labels:  webaudio-api
Vissonance
A WebGL Audio Visualizer
Stars: ✭ 39 (-81.16%)
Mutual labels:  webaudio-api
PicoAudio.js
A JavaScript library for playing MIDI (Standard MIDI File) on Web.
Stars: ✭ 28 (-86.47%)
Mutual labels:  webaudio-api
ahx-web-player
AHX player web interface
Stars: ✭ 24 (-88.41%)
Mutual labels:  webaudio-api
pitch-shifter-chrome-extension
Chrome extension that pitch shifts videos on a page using web audio
Stars: ✭ 21 (-89.86%)
Mutual labels:  webaudio-api
musicplayer-api
Simple wrapper around Web Audio API providing gapless playback
Stars: ✭ 16 (-92.27%)
Mutual labels:  webaudio-api
webaudio-pitch-tuner
Web Audio API based Pitch Tuner application made with ReactJS.
Stars: ✭ 25 (-87.92%)
Mutual labels:  webaudio-api

Crunker

Experimental, use in production with caution

Simple way to merge, concatenate, play, export and download audio files with the Web Audio API.

  • No dependencies
  • Tiny 2kB gzipped
  • Written in Typescript

View online demos

Installation

yarn add crunker
npm install crunker

Example

let crunker = new Crunker();

crunker
  .fetchAudio('/song.mp3', '/another-song.mp3')
  .then((buffers) => {
    // => [AudioBuffer, AudioBuffer]
    return crunker.mergeAudio(buffers);
  })
  .then((merged) => {
    // => AudioBuffer
    return crunker.export(merged, 'audio/mp3');
  })
  .then((output) => {
    // => {blob, element, url}
    crunker.download(output.blob);
    document.body.append(output.element);
    console.log(output.url);
  })
  .catch((error) => {
    // => Error Message
  });

crunker.notSupported(() => {
  // Handle no browser support
});

Condensed Example

let crunker = new Crunker();

crunker
  .fetchAudio('/voice.mp3', '/background.mp3')
  .then((buffers) => crunker.mergeAudio(buffers))
  .then((merged) => crunker.export(merged, 'audio/mp3'))
  .then((output) => crunker.download(output.blob))
  .catch((error) => {
    throw new Error(error);
  });

Input file Example

let crunker = new Crunker();

const onFileInputChange = async (target) => {
  const buffers = await crunker.fetchAudio(...target.files, '/voice.mp3', '/background.mp3');
};

<input onChange={onFileInputChange(this)} type="file" accept="audio/*" />;

Other Examples

Graphic Representation of Methods

Merge

merge

Concat

concat

Methods

For more detailed API documentation, view the Typescript typings.

new Crunker()

Create a new instance of Crunker. You may optionally provide an object with a sampleRate key, but it will default to the same sample rate as the internal audio context, which is appropriate for your device.

crunker.fetchAudio(songURL, anotherSongURL)

Fetch one or more audio files. Returns: an array of audio buffers in the order they were fetched.

crunker.mergeAudio(arrayOfBuffers);

Merge two or more audio buffers. Returns: a single AudioBuffer object.

crunker.concatAudio(arrayOfBuffers);

Concatenate two or more audio buffers in the order specified. Returns: a single AudioBuffer object.

crunker.padAudio(buffer, padStart, seconds);

Pad the audio with silence, at the beginning, the end, or any specified points through the audio. Returns: a single AudioBuffer object.

crunker.export(buffer, type);

Export an audio buffers with MIME type option. Type: 'audio/mp3', 'audio/wav', 'audio/ogg'. Returns: an object containing the blob object, url, and an audio element object.

crunker.download(blob, filename);

Automatically download an exported audio blob with optional filename. Filename: String not containing the .mp3, .wav, or .ogg file extension. Returns: the HTMLAnchorElement element used to simulate the automatic download.

crunker.play(buffer);

Starts playing the exported audio buffer in the background. Returns: the HTMLAudioElement.

crunker.notSupported(callback);

Execute custom code if Web Audio API is not supported by the users browser. Returns: The callback function.

Properties

For more detailed API documentation, view the Typescript typings.

crunker.context

Access the AudioContext used internally by a given Crunker. Returns: AudioContext.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].