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

recordmic

v0.0.9

Published

Record mic input from getUserMedia and web audio

Downloads

31

Readme

#recordmic Members

##recordmic~isAvailable recordmic.isAvailable will be true when recordmic is able to record. In order for recordmic to be able to record the browser must have getUserMedia and AudioContext.

Scope: inner member of recordmic
Type: Boolean
##class: recordmic~recordmic Members

###new recordmic~recordmic(settings, callBack) recordmic can be used to record from the mic in browser via getUserMedia. You can pass in some settings when instantiating the recordmic.

The settings object can contain the following properties:

{
	volume: 1, // this is the volume at which the mic will record by default 
			   // this value is 1
	bufferSize: 2048, // this is the size of the buffer as its recording. 
					  // Default is 2048
	mono: false // whether the mic will record in mono by default this value 
				// is false (it will record in stereo) mono can also be 'left' 
				// or 'right' to define which channel is being used.
	onSampleData: null // this is a callback if you want to access sampledata 
					   // as it's being recorded. You can for instance modify 
					   // data as it's being recorded.
}

Params

  • settings Object - this is is the settings object. See above for possible values which can be passed in.
  • callBack function - this callback will be called once the mic has "initialized" itself and is ready to record

Scope: inner class of recordmic
Returns: recordmic - You can call this as a function or instantiate via new keyword. It will return an instance of recordmic
###recordmic.setRecordVolume(volume) Call this function to set the volume at which the microphoe will record. Usually this value will be between 0 and 1.

Params

  • volume Number - A value between 0 and 1

###recordmic.getRecordVolume() Volume at which we're recording between 0 and 1

Returns: Number - A volume value between 0 and 1
###recordmic.setMono(mono) Will set wether recordmic is recording in mono or not. If you pass in false we'll be recording in stereo. If you pass pass in true then the right channel will be used. You can also pass in the strings 'left' and 'right' to define which channel is used to record when recording in mono.

Params

  • mono String | Boolean - false will mean it's recording in stereo. true means that the right channel's data will be used. 'left' means the left channel will be used and 'right' will mean that the right channel is used.

###recordmic.getMono() This will return wether we're recording in mono. This value can be either a boolean or a string. If true is returned it means we're recording in mono and the right channel is used. If false is returned then we're recording in stereo. If a string is returned and it's value is 'left' then we're recording in mono using the left channel and 'right' for the right channel.

Returns: String | Boolean - value for mono either: true, false, 'right', 'left'
###recordmic.getChannelData() getChannelData will return return both left and right channel data from our recording. If we're recording in mono one of the channels will be null.

The data returned for each channel are Float32Array arrays.

Returns: Object - This object will have two variables 'left' and 'right' which contain the data for each channel.
###recordmic.getMonoData([mono]) This will return mono data for our recording. What is returned is a Float32Array. The mono setting will determine which array will be returned. If mono is set to true then the left channel will be returned over the right.

Params

  • [mono] String - This is optional. either 'left' or 'right' to determine which channel will be returned.

Returns: Float32Array - The sound data for our recording as mono
###recordmic.getStereoData(mono) getStereoData will return both the left and right channel interleaved as a Float32Array.

You can also pass in a value for mono. If you do then one of the channells will be interleaved as stereo data.

So for instance in stereo: [ left_data1, right_data1, left_data2, right_data2, left_data3, right_data3 ]

And if mono is set to 'left': [ left_data1, left_data1, left_data2, left_data2, left_data3, left_data3 ]

Params

  • mono String - If you'd like to get mono data interleaved as stereo data either pass 'left' or 'right'

Returns: Float32Array - Sound data interleaved as a Float32Array.
###recordmic.start() When you call start you begin recording.

###recordmic.stop() Call stop to stop recording.

###recordmic.clear() This will clear any recorded data. This should be called if you're wanting to record multiple clips.

###recordmic.destroy() Calling destroy will stop recording and clear all recorded data.