npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

psittacus

v0.1.1

Published

psittacus is a simple library to recorder audio in browser

Downloads

2

Readme

Psittacus

Build Status

Instruction

psittacus is a simple library to recorder audio in browser.

Preparation

Before use it, you should known some knowledge of Audio format.

Audio Format

Common audio formats like wav, ogg, pcm, mp3 is a 'container' which means it is used to store codecs and data of audio.

Sample Rate

The rate of capture and playback is called the sample rate.

Bit Depth

The number of bits used to describe each sample is called the bit depth.

Bit Rate

The number of bits transmitted per second is the bit rate.

 bitRate = bitDepth * sampleRate

https://www.presonus.com/learn/technical-articles/sample-rate-and-bit-depth

Channels

Sound Channel refers to the independent audio signal which is collected or playback when the sound is recording or playback in different spatial position. Therefore, the number of channel is the amount of sound source when the sound is recording or the relevant speaker number when it is playback

https://www.gearbest.com/blog/how-to/6-types-of-sound-channels-2896

MediaRecorder VS AudioContext

By default, psittacus use AudioContext as default. This is because. :point_down:

MediaRecorder

  • there’s no bitrate control

  • there’s no sample rate or audio quality control

  • .webm files (with Vorbis/Opus audio and VP8/VP9 video) will have to be converted before they playback on virtually anything else other than the browsers they were recorded in

HTML5’s Media Recorder API in Action on Chrome and Firefox

Audio Information

There is a table made by Remus Negrota.

| name | CHROME 49+ | CHROME 52+ | FIREFOX 30 AND UP | | ----------- | ---------- | ---------- | ----------------- | | Container | webm | webm | webm | | Audio codec | Opus | Opus | Vorbis | | Sample rate | 48kHz | 48kHz | 44.1 kHz |

webm is an open source format that contains video compressed with VP8 or VP9 codecs and audio compressed with Vorbis or Opus codecs. The format is usually used for media content on web pages and it is supported by all the popular web-browser.

AudioContext

Audio context can let user to control the sample rate and bit rate in recording. For compatibility and flexibility, psittacus use ScriptProcessorNode instead AudioWorkletProcessor by default.

Reference

MDN-MediaStreamAudioSourceNode

MDN-AudioContext

Usage

psittacus is an simple library for web recording. You only have to learn six methods: open, start, pause, resume, stop, clear.

Crash Course

ES6

   import Psittacus from 'Psittacus'

   let recorder = new Psittacus();
   recorder.start();

   recorder.stop();

   recorder.export('wav',async (blob)=>{
       const url = URL.createObjectURL(object);

       // Use <audio></audio> to play it.
       audio.src = url;

       // Get binary data of audio
       const binary = await blob.arrayBuffer()
   })

See examples for more details.

API

constructor(config)

Initialize a psittacus instance.

config

{
  method: "AudioContext"
  type: "wav",
  bufferSize: 4096,
  sampleRate: 16000,
}

example:

const recorder = new fast({
    method: "AudioContext",
});

start()

Start Recording.

example:

recorder.start();

stop()

Stop Recording.

example:

recorder.stop(cb)

url is an object url.

pause()

Pause Recording.

example:

recorder.pause();

resume()

Resume Recording.

example:

recorder.resume();

export(audioType, callback)

Export specified format audio.

audioType

'wav'|'pcm'

callback

function(blob). Get a blob object.

example

recorder.export('wav',cb);