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 πŸ™

Β© 2025 – Pkg Stats / Ryan Hefner

@mickit/input

v1.0.14

Published

## πŸ“š **Overview** `@mickit/input` is a simple and lightweight library for capturing audio input from the microphone. It provides a simple API to listen to audio chunks, detect silence, and adjust the gain automatically.

Downloads

14

Readme

@mickit/input

πŸ“š Overview

@mickit/input is a simple and lightweight library for capturing audio input from the microphone. It provides a simple API to listen to audio chunks, detect silence, and adjust the gain automatically.

The Audio Chunk is encoded is a simple .

  • Audio Chunk: Int16Array (PCM 16-bit signed integer)

πŸš€ Installation

To install MicInputManager, use npm or yarn:

npm install @mickit/input

or

yarn add @mickit/input

πŸ› οΈ Setup and Initialization

Basic Usage Example

import { MicInputManager, MicInputManagerEvent } from '@mickit/input';

const micManager = new MicInputManager(250, true);

// Start listening to microphone
micManager.listen();

// Event listeners
micManager.on(MicInputManagerEvent.LISTENING, () => {
  console.log('Microphone is listening');
});

micManager.on(MicInputManagerEvent.STOPPED, () => {
  console.log('Microphone has stopped');
});

micManager.on(MicInputManagerEvent.MIC_MUTED, () => {
  console.log('Microphone muted');
});

micManager.on(MicInputManagerEvent.CHUNK, (event) => {
  // event.data is a Int16Array
  console.log('Audio chunk:', event.data);
});

🎧 API Reference

Constructor

constructor(silenceDurationMs?: number, debug?: boolean)
  • sliceDurationMs: Duration of audio chunks in milliseconds (default: 250).
  • debug: Enable debug logs (default: false).

Methods

listen()

Starts listening to the microphone input.

micManager.listen();

stop()

Stops the microphone input.

micManager.stop();

on(event: MicInputManagerEvent, callback: MicKitEventCallback)

Adds an event listener.

micManager.on(MicInputManagerEvent.LISTENING, () => console.log('Listening'));

setMaxGain(maxGain: number)

Sets the maximum gain value.

micManager.setMaxGain(2.0);

setMinGain(minGain: number)

Sets the minimum gain value.

micManager.setMinGain(0.1);

setGain(gain: number)

Manually sets the gain. (if auto gain is enabled this will be changed automatically) If you want to set the gain manually, you should disable auto gain.

micManager.setGain(1.0);

setAutoGain(enabled: boolean)

Enables or disables automatic gain adjustment.

micManager.setAutoGain(true);

setDefaultGain(gain: number)

Sets the default gain value.

micManager.setDefaultGain(1.0);

setSelectedMic(deviceId: string)

Sets the microphone device to use.

micManager.setSelectedMic('default');

getAvailableMicrophones()

Fetches available microphone devices. Returns a promise with an array of MicrophoneDevice.

const mics = await micManager.getAvailableMicrophones();
console.log(mics);

setProcessorThresholds(thresholds: ProcessorThresholds)

Sets the processor thresholds.

micManager.setProcessorThresholds({
  silentThreshold: 0.01,
  tooQuietThreshold: 0.1,
  tooLoudThreshold: 0.9,
  peakThreshold: 0.9,
  clippingPercentage: 0.1, // 10%
});

πŸ“Š Events

| Event | Description | hasRMS | |--------------------------|-----------------|-------------| | LISTENING | Microphone has started listening. | false | | STOPPED | Microphone has stopped. | false | | MIC_MUTED | Microphone was muted. | false | | MIC_UNMUTED | Microphone was unmuted. | false | | MIC_NOT_FOUND | No microphone was found. | false | | MIC_PERMISSION_DENIED | Microphone access was denied. | false | | MIC_DISCONNECTED | Currently used microphone was disconnected. | false | | MIC_LIST_CHANGED | List of available microphones changed. | false | | STREAM_ENDED | Audio stream has ended. | false | | CHUNK | Audio chunk data is available. | true | | TOO_LOUD | Audio input is too loud. | true | | TOO_QUIET | Audio input is too quiet. | true | | SILIENT | Silence detected. | true | | PEAKS | Audio peaks detected. | true | | CLIPPING | Audio clipping detected. | true | | AUDIO_PROCESSING_ERROR | Error during audio processing. | false |

RMS: Root Mean Square Some events have RMS data available in the event object. It can be accessed using event.rms. The RMS value is a number between 0 and 1. It represents the volume level of the audio input.

🐞 Debugging

Enable debug mode

const micManager = new MicInputManager(250, true);

Debug logs will appear in the console prefixed with [DEBUG].

Future Improvements

  • [ ] Other sample rates (Currently fixed at 16000 Hz)
  • [ ] Other Audio encodings (Currently fixed at PCM 16-bit signed integer)
  • [ ] VAD (Voice Activity Detection)
  • [ ] Audio Processing (Noise Reduction, Echo Cancellation, etc.)
  • [ ] Noise Level Detection

πŸ“„ License

This project is licensed under the MIT License.

🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.