New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

audio-analysis-core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-analysis-core

React Native audio analysis library with waveform extraction and full audio analysis

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Audio Analysis Core

A React Native library for audio analysis with waveform extraction and comprehensive audio feature extraction.

Features

  • Waveform Extraction: Extract waveform data from audio files
  • Full Audio Analysis: Comprehensive audio analysis including spectrum, RMS, zero-crossing rate, and more
  • TypeScript Support: Full TypeScript definitions included
  • Cross-Platform: Works on both iOS and Android

Installation

npm install audio-analysis-core
# or
yarn add audio-analysis-core

iOS Setup

cd ios && pod install && cd ..

Android Setup

No additional setup required for Android.

Usage

Basic Waveform Extraction

import { extractWaveform } from 'audio-analysis-core';

const waveform = await extractWaveform({
  fileUri: 'file://path/to/audio.mp3',
  pointsPerSecond: 50, // points per second
  startTimeMs: 0, // start time in milliseconds
  endTimeMs: 10000, // end time in milliseconds (optional)
  decodingOptions: {
    sampleRate: 44100,
    channels: 1,
    bitDepth: 16
  }
});

console.log(waveform.data); // Array of waveform values
console.log(waveform.duration); // Duration in seconds
console.log(waveform.sampleRate); // Sample rate
console.log(waveform.channels); // Number of channels
console.log(waveform.bitDepth); // Bit depth

Full Audio Analysis

import { analyzeAudio } from 'audio-analysis-core';

const analysis = await analyzeAudio({
  fileUri: 'file://path/to/audio.mp3',
  segmentDurationMs: 100, // duration of each data point in milliseconds
  startTimeMs: 0, // start time in milliseconds
  endTimeMs: 10000, // end time in milliseconds (optional)
  features: {
    energy: true,
    rms: true,
    zcr: true,
    spectralCentroid: true,
    mfcc: false
  },
  decodingOptions: {
    sampleRate: 44100,
    channels: 1,
    bitDepth: 16
  }
});

console.log(analysis.dataPoints); // Array of data points
console.log(analysis.durationMs); // Duration in milliseconds
console.log(analysis.sampleRate); // Sample rate
console.log(analysis.numberOfChannels); // Number of channels

API Reference

extractWaveform(options)

Extract waveform data from an audio file (similar to expo-audio-stream's extractPreview).

Parameters:

  • options.fileUri (string): Path to the audio file
  • options.pointsPerSecond (number, optional): Points per second to extract (default: 50)
  • options.startTimeMs (number, optional): Start time in milliseconds (default: 0)
  • options.endTimeMs (number, optional): End time in milliseconds (default: entire file)
  • options.decodingOptions (DecodingOptions, optional): Decoding configuration

Returns: Promise

analyzeAudio(options)

Perform comprehensive audio analysis (similar to expo-audio-stream's extractAudioAnalysis).

Parameters:

  • options.fileUri (string): Path to the audio file
  • options.segmentDurationMs (number, optional): Duration of each data point in milliseconds (default: 100)
  • options.startTimeMs (number, optional): Start time in milliseconds (default: 0)
  • options.endTimeMs (number, optional): End time in milliseconds (default: entire file)
  • options.features (AudioFeatures, optional): Features to extract
  • options.decodingOptions (DecodingOptions, optional): Decoding configuration

Returns: Promise

Types

interface WaveformData {
  data: number[];
  duration: number;
  sampleRate: number;
  channels: number;
  bitDepth: number;
}

interface AudioFeatures {
  energy?: boolean;
  rms?: boolean;
  zcr?: boolean;
  spectralCentroid?: boolean;
  mfcc?: boolean;
  waveform?: boolean;
  spectrum?: boolean;
}

interface DecodingOptions {
  sampleRate?: number;
  channels?: number;
  bitDepth?: number;
}

interface AudioAnalysisDataPoint {
  amplitude: number;
  rms: number;
  db: number;
  energy?: number;
  zcr?: number;
  spectralCentroid?: number;
  mfcc?: number[];
}

interface AudioAnalysisResult {
  segmentDurationMs: number;
  durationMs: number;
  bitDepth: number;
  samples: number;
  numberOfChannels: number;
  sampleRate: number;
  dataPoints: AudioAnalysisDataPoint[];
}

License

MIT

Keywords

audio

FAQs

Package last updated on 06 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts