• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    JavaScript
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Record your microphone (or any other input) and add effects to it! In your browser.

ATTENTION!

This package is now maintained as a part of the sountility collection. This repository won't be used anymore for this package, but it will still be maintained.

Recordy

Recording for browsers - the easy way

This module abstracts away the logic needed to record audio in your browser. Since it's based on the Chnl module, a lot of effects can be added to the input. For information about this aspect just have a look a the documentation of Chnl. You can treat any Recordy-instance as a Chnl, because Recordy is extending Chnl. To record the input, I'm using a fork of the popular recorder.js library from Matt Diamond, wrecorder, which allows us to record the output of WebAudio-nodes. Big thanks for this awesome work!

Attention: Since the webaudio-effect-unit has reached v.1.1.0, the way how the effects work has changed. Have a look at it's repository for more details. Make sure to do this BEFORE you update. If you have difficulties or questions, just open an issue! I am always glad if I can help. 😄

Installation

The package is hosted on npm. You can consume it with any package manager supporting npm packages.

npm i recordy -S

Usage

Creating an instance

new Recordy(audioCtx)

To create a Recordy-instance, you have to pass exactly one argument to the constructor: an AudioContext object. Now, you can request audio input(have a look at the example for more information).

Getting input

.getInput()

This method needs to be executed before you can start recording. It asynchronously requests audio input. So the return value is a Promise, which returns a boolean value. This value evaluates to true if the request for the microphone/audio-input was successfully and to false if it wasn't.

Start recording

.startRecording()

This method is really self-explanatory. Recody will record until you call the .stopRecording(...) method.

Stop recording

.stopRecording(asAudioObject)

This methods stops a previously started recording. It accepts exactly one parameter: a boolean. If this boolean evaluates to true, this method will return a Promise which returns an Audio-object with the recorded track. Otherwise, it returns a Promise which returns the plain binary data(blob) of the recorded track.

Outputting to the speakers

.toSpeaker(gainValue)

Recordy allows you to directly output the audio-input to the speakers, so you could directly hear the effects you apply etc. The method accepts exactly one parameter: The volume of the output. This can be a number from 0 - 1. If you set a value of 0 it's muted, if you set a value of 1 it's the maximal possible volume. ATTENTION: Due to the lack of support of advanced and latency-free audio protocols like ASIO(...) in the actual browsers, there's a quite high latency between input and output (it's clearly noticeable). Therefore, it's muted by default.

Example

This is a simple example which records an one second long track. The track gets returned as an Audio-object so it can be directly played. Also, the input is directly outputted to the speakers with a gain of 0.4. In addition, some functionality of the Chnl module was applied: The bitcrusher effect was enabled.

const audioCtx = new AudioContext();
const r = new Recordy(audioCtx);

r.getInput()
  .then(val => {
    r.startRecording();

    window.setTimeout(() => {
      r.stopRecording(true)
        .then(audio => {
          audio.play();
        });
    }, 1000);
    r.toSpeaker(0.4);
    r.effects.bitcrusher.enable();
  });

More Repositories

1

sountility

This repository contains many different packages which I created in order to use them in my audio software projects
JavaScript
49
star
2

Chnl

Chnl - one channel, all effects.
JavaScript
42
star
3

soundcycle

A loopstation for musicians. Completely online.
JavaScript
40
star
4

mrnote

Ever wanted your notes to be accesible from everywhere and be able to share them? Say hello to mrnote.
JavaScript
22
star
5

NEAR

Find people NEAR you: A React and node.js based app using location tracking.
JavaScript
20
star
6

-DEPRECATED-AudioLooper

AudioLooper - Loop your tracks with automatic synchronization.
JavaScript
12
star
7

-DEPRECATED-webaudio-effect-unit

Effect unit to add functionality to the WebAudio API. The effect unit lets you enable/disable effects and alter the interior state with custom methods.
JavaScript
4
star
8

scriptify-react-starter

My own starter project for new react projects.
JavaScript
3
star
9

HoloWeb

Holograms on the web, holograms for everyone!
JavaScript
3
star
10

thesoundofus

Connect your Google Photos and Spotify Account, select a photo album and a Spotify playlist, and the web app will create an interactive photo album with music from the time the photo was taken. Intended as a Christmas present.
TypeScript
3
star
11

cantara-playground

:'(
TypeScript
2
star
12

-DEPRECATED-webaudio-effect-units-collection

A bunch of different EffectUnits which can be used right away. They are all based on the webaudio-effect-unit.
JavaScript
2
star
13

-DEPRECATED-AudioChnl

One Audio object, multiple effects. Easy.
JavaScript
1
star
14

hClock

A HoloWeb-App - Making your alarmclock holographic!
JavaScript
1
star
15

nextcloud-music-folder-sync

Syncs your folder structure into NextCloud Music Playlists
JavaScript
1
star