
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
miniaudio_node
Advanced tools
High-performance native audio playback for Node.js and Bun. Built with Rust and the powerful rodio audio engine.
High-performance native audio playback for Bun/Node.js. Built with Rust and the powerful rodio audio engine.
createAudioPlayer and quickPlay utilities# Install via Bun (recommended)
bun add miniaudio_node
# Install via npm
npm install miniaudio_node
# Install via yarn
yarn add miniaudio_node
# Install via pnpm
pnpm add miniaudio_node
import { AudioPlayer, initializeAudio } from 'miniaudio_node'
// Initialize audio system
console.log(initializeAudio()) // "Audio system initialized"
// Create audio player
const player = new AudioPlayer()
// Load and play audio file
player.loadFile('path/to/your/music.mp3')
player.play()
// Control playback
setTimeout(() => {
player.setVolume(0.7) // Set volume to 70%
console.log('🎵 Playing at 70% volume')
}, 2000)
setTimeout(() => {
player.pause()
console.log('⏸️ Paused')
}, 5000)
setTimeout(() => {
player.play()
console.log('▶️ Resumed')
}, 7000)
setTimeout(() => {
player.stop()
console.log('⏹️ Stopped')
}, 10000)
import { AudioPlayer } from 'miniaudio_node'
// Load audio from buffer data (e.g., from fetch API or file reading)
const player = new AudioPlayer()
// Example: Load from buffer (minimal WAV file data)
const wavBuffer = [
0x52, 0x49, 0x46, 0x46, // "RIFF"
0x24, 0x00, 0x00, 0x00, // File size - 8
0x57, 0x41, 0x56, 0x45, // "WAVE"
0x66, 0x6D, 0x74, 0x20, // "fmt "
0x10, 0x00, 0x00, 0x00, // Format chunk size
0x01, 0x00, // Audio format (PCM)
0x01, 0x00, // Number of channels
0x44, 0xAC, 0x00, 0x00, // Sample rate (44100)
0x88, 0x58, 0x01, 0x00, // Byte rate
0x02, 0x00, // Block align
0x10, 0x00, // Bits per sample
0x64, 0x61, 0x74, 0x61, // "data"
0x04, 0x00, 0x00, 0x00, // Data chunk size
0x00, 0x00, 0x00, 0x00 // 4 bytes of silence
]
player.loadBuffer(wavBuffer)
player.play()
// Load from base64 encoded audio
const player2 = new AudioPlayer()
const base64Audio = 'UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAAA'
player2.loadBase64(base64Audio)
player2.play()
import { AudioPlayer } from 'miniaudio_node'
// Example: Loading audio from fetch API
async function loadAudioFromUrl(url: string) {
const response = await fetch(url)
const arrayBuffer = await response.arrayBuffer()
const audioData = Array.from(new Uint8Array(arrayBuffer))
const player = new AudioPlayer()
player.loadBuffer(audioData)
player.play()
}
// Example: Loading from file input
function handleFileInput(event: Event) {
const file = (event.target as HTMLInputElement).files?.[0]
if (!file) return
const reader = new FileReader()
reader.onload = (e) => {
const arrayBuffer = e.target?.result as ArrayBuffer
const audioData = Array.from(new Uint8Array(arrayBuffer))
const player = new AudioPlayer()
player.loadBuffer(audioData)
player.play()
}
reader.readAsArrayBuffer(file)
}
import { createAudioPlayer, quickPlay, getAudioMetadata } from 'miniaudio_node'
// Create player with configuration
const player = createAudioPlayer({ volume: 0.8, autoPlay: false })
// Quick play with options
const player2 = quickPlay('path/to/audio.mp3', {
volume: 0.7,
autoPlay: true
})
// Get audio metadata
const metadata = getAudioMetadata('music.mp3')
console.log('Duration:', metadata.duration)
console.log('Title:', metadata.title)
import {
AudioPlayer,
createAudioPlayer,
quickPlay,
getAudioMetadata,
type AudioPlayerConfig,
type AudioDeviceInfo,
type AudioMetadata,
type PlaybackState
} from 'miniaudio_node'
// Create player with options
const config: AudioPlayerConfig = {
volume: 0.6,
autoPlay: false
}
const player = createAudioPlayer(config)
// Get device information
const devices: AudioDeviceInfo[] = player.getDevices()
console.log('Available devices:', devices)
// Type-safe operations
player.loadFile('audio.mp3')
player.play()
console.log(`Volume: ${player.getVolume()}`)
console.log(`Playing: ${player.isPlaying()}`)
console.log(`State: ${player.getState()}`)
const player = new AudioPlayer()
| Method | Description | Parameters | Returns |
|---|---|---|---|
loadFile(filePath) | Load audio file for playback | string - Path to audio file | void |
loadBuffer(audioData) | Load audio from buffer data | number[] - Audio buffer data | void |
loadBase64(base64Data) | Load audio from base64 string | string - Base64 encoded audio | void |
play() | Start or resume playback | none | void |
pause() | Pause current playback | none | void |
stop() | Stop playback and clear queue | none | void |
setVolume(volume) | Set volume level | number - 0.0 to 1.0 | void |
getVolume() | Get current volume | none | number |
isPlaying() | Check if playing | none | boolean |
getDevices() | Get audio devices | none | AudioDeviceInfo[] |
getDuration() | Get audio duration | none | number |
getCurrentTime() | Get playback position | none | number |
getState() | Get current playback state | none | PlaybackState |
getCurrentFile() | Get loaded file path | none | string | null |
// Initialize audio system
initializeAudio(): string
// Get supported formats
getSupportedFormats(): string[]
// Create pre-configured player
createAudioPlayer(config?: AudioPlayerConfig): AudioPlayer
// Quick play function
quickPlay(filePath: string, config?: AudioPlayerConfig): AudioPlayer
// Check format support
isFormatSupported(format: string): boolean
// Get audio metadata
getAudioMetadata(filePath: string): AudioMetadata
// Get audio system info
getAudioInfo(): string
interface AudioPlayerConfig {
volume?: number
autoPlay?: boolean
}
interface AudioDeviceInfo {
id: string
name: string
isDefault: boolean
}
interface AudioMetadata {
duration: number
title?: string | null
artist?: string | null
album?: string | null
}
enum PlaybackState {
Stopped = 0,
Loaded = 1,
Playing = 2,
Paused = 3
}
| Format | Extensions | Status |
|---|---|---|
| WAV | .wav | ✅ Full Support |
| MP3 | .mp3 | ✅ Full Support |
| FLAC | .flac | ✅ Full Support |
| OGG | .ogg | ✅ Full Support |
Windows:
bun install --global windows-build-toolsmacOS:
xcode-select --installLinux:
sudo apt-get install libasound2-dev (Ubuntu/Debian)# Clone repository
git clone https://github.com/nglmercer/miniaudio-node.git
cd miniaudio-node
# Install dependencies
bun install
# Build native module
bun run build
# Run tests
bun test
| Script | Description |
|---|---|
bun build | Build native Rust module |
bun test | Run all tests |
bun clean | Clean build artifacts |
bun dev | Build and test |
bun lint | Run ESLint |
bun format | Format code with Prettier |
# Run all tests
bun test
# Run tests in watch mode
bun test --watch
# Run tests with coverage
bun test --coverage
# Run specific test files
bun test tests/unit/audio-player.test.ts
bun test tests/integration/playback.test.ts
The test suite includes:
| Metric | Value |
|---|---|
| Startup Time | <50ms |
| Memory Usage | ~2MB baseline |
| CPU Overhead | <1% during playback |
| Latency | <10ms (platform dependent) |
| Supported Sample Rates | 8kHz - 192kHz |
Compared to other Node.js audio libraries:
| Library | CPU Usage | Memory | Startup | Formats | Bun Support |
|---|---|---|---|---|---|
| miniaudio_node | ~0.8% | ~2MB | 45ms | 4+ | ✅ |
| node-speaker | ~1.2% | ~3MB | 60ms | 1 | ❌ |
| web-audio-api | ~2.1% | ~5MB | 80ms | 3 | ⚠️ |
| node-lame | ~1.5% | ~4MB | 70ms | 1 | ❌ |
This project uses GitHub Actions for fully automated releases:
# Create a new version
npm version patch # or minor/major
# Push the tag (triggers automatic release)
git push --tags
The workflow will:
Each release includes:
import { AudioPlayer } from 'miniaudio_node'
try {
const player = new AudioPlayer()
player.loadFile('audio.mp3')
player.play()
} catch (error) {
if (error.message.includes('does not exist')) {
console.error('Audio file not found:', error.message)
} else if (error.message.includes('Volume must be between 0.0 and 1.0')) {
console.error('Invalid volume value:', error.message)
} else if (error.message.includes('Player not initialized')) {
console.error('Player not ready:', error.message)
} else {
console.error('Audio error:', error.message)
}
}
import { AudioPlayer } from 'miniaudio_node'
const player = new AudioPlayer()
const devices = player.getDevices()
// Find default device
const defaultDevice = devices.find(device => device.isDefault)
console.log('Default device:', defaultDevice)
// List all available devices
devices.forEach(device => {
console.log(`Device: ${device.name} (ID: ${device.id})`)
})
We welcome contributions! Please follow our guidelines:
git checkout -b feature/amazing-featurebun testbun run build# Clone your fork
git clone https://github.com/YOUR_USERNAME/miniaudio-node.git
cd miniaudio-node
# Install dependencies
bun install
# Make changes
# ...
# Run tests
bun test
# Build for testing
bun run build
# Check code style
bun run lint
bun run format
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
High-performance native audio playback for Node.js and Bun. Built with Rust and the powerful rodio audio engine.
We found that miniaudio_node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.