JSPM

  • Created
  • Published
  • Downloads 77
  • Score
    100M100P100Q52508F

Package Exports

  • audiomix
  • audiomix/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (audiomix) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

audiomix

Native module for mixing multiple audio recordings in Expo React Native (Android).
It allows combining a base track with recordings, handling delays (delayMs), and optional monitoring during playback.


Installation

npm install audiomix

Link native module if needed (RN < 0.60):

react-native link audiomix

For RN 0.60+, autolinking handles it.


Usage

Import

import { audioMix } from 'audiomix';

Method: mixRecordings

audioMix(
  recordings: Array<{ id: string; uri: string; delayMs?: number }>,
  selectedIds: string[],
  baseTrack: string | null,
  monitorPlayback: boolean,
  syncValue: number,
)
  • recordings: List of recording objects. Each must include id and uri. Optional delayMs in ms.
  • selectedIds: Array of IDs from recordings to include in mixing.
  • baseTrack: Path/URI of base audio track (can be null).
  • monitorPlayback: If true, mixes with base track for monitoring.
  • syncValue: Sync adjustment in ms.
  • Returns: Promise resolving with the path of the mixed output .wav file (stored in app cache).

Example

const recordings = [
  { id: '1', uri: '/storage/emulated/0/Music/rec1.wav', delayMs: 120 },
  { id: '2', uri: '/storage/emulated/0/Music/rec2.wav', delayMs: 0 },
];

const selectedIds = ['1'];

const baseTrack = '/storage/emulated/0/Music/base.wav';

audioMix(
  recordings,
  selectedIds,
  baseTrack,
  true,    // monitorPlayback
  0        // syncValue
).then(outputPath => {
  console.log('Mixed audio file:', outputPath);
}).catch(err => {
  console.error('Mixing error:', err);
});

Notes

  • Output file is generated in the app cache directory with name pattern: mixed_output_<timestamp>.wav

  • On error, promise rejects with:

    • MIX_PREP_ERROR: Input or preparation error.
    • MIX_ERROR: Mixing process failed.

License

MIT