All Projects → mackron → Miniaudio

mackron / Miniaudio

Licence: other
Single file audio playback and capture library written in C.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Miniaudio

Libnyquist
🎤 Cross platform C++11 library for decoding audio (mp3, wav, ogg, opus, flac, etc)
Stars: ✭ 311 (-83.54%)
Mutual labels:  wav, audio, mp3, flac, audio-library
Atldotnet
Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
Stars: ✭ 180 (-90.47%)
Mutual labels:  wav, audio, mp3, flac
Ni Media
NI Media is a C++ library for reading and writing audio streams.
Stars: ✭ 158 (-91.64%)
Mutual labels:  wav, audio, mp3, flac
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (-89.89%)
Mutual labels:  wav, audio, mp3, flac
Music Metadata
Stream and file based music metadata parser for node. Supporting a wide range of audio and tag formats.
Stars: ✭ 455 (-75.91%)
Mutual labels:  wav, audio, mp3, flac
Audio Steganography Algorithms
A Library of Audio Steganography & Watermarking Algorithms
Stars: ✭ 146 (-92.27%)
Mutual labels:  wav, audio, mp3, flac
Mediafile
A unified reader of metadata from audio & video files.
Stars: ✭ 138 (-92.69%)
Mutual labels:  wav, audio, mp3, flac
Av Converter
[av-converter.com] Audio and Video Converter, and YouTube downloader. Convert to MP3, MP4, AAC, FLAC, AC3, WAV, etc.
Stars: ✭ 97 (-94.87%)
Mutual labels:  wav, audio, mp3, flac
uos
United Open-libraries of Sound. United procedures for open-source audio libraries. For FPC/Lazarus/fpGUI/MSEgui.
Stars: ✭ 112 (-94.07%)
Mutual labels:  mp3, wav, flac, recording
Recorder
html5 js 录音 mp3 wav ogg webm amr 格式,支持pc和Android、ios部分浏览器、和Hybrid App(提供Android IOS App源码),微信也是支持的,提供H5版语音通话聊天示例 和DTMF编解码
Stars: ✭ 2,891 (+53.04%)
Mutual labels:  recording, wav, audio, mp3
Audioplayer
Audio Player for Nextcloud and ownCloud
Stars: ✭ 179 (-90.52%)
Mutual labels:  wav, audio, mp3, flac
Music Metadata Browser
Browser version of music-metadata parser Supporting a wide range of audio and tag formats.
Stars: ✭ 105 (-94.44%)
Mutual labels:  wav, audio, mp3, flac
Flacon
Audio File Encoder. Extracts audio tracks from an audio CD image to separate tracks.
Stars: ✭ 252 (-86.66%)
Mutual labels:  wav, audio, mp3, flac
audio-metadata
A library for reading and, in the future, writing audio metadata. https://audio-metadata.readthedocs.io/
Stars: ✭ 41 (-97.83%)
Mutual labels:  mp3, wav, flac, vorbis
flutter audio desktop
[WIP] An 🎵 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.
Stars: ✭ 42 (-97.78%)
Mutual labels:  mp3, wav, flac, audio-library
Recordmp3js
Record MP3 files directly from the browser using JS and HTML
Stars: ✭ 413 (-78.14%)
Mutual labels:  recording, audio, mp3
Recorder
html5 js 浏览器 web端录音
Stars: ✭ 429 (-77.29%)
Mutual labels:  wav, audio, mp3
Axiom
An FFmpeg GUI for Windows
Stars: ✭ 560 (-70.35%)
Mutual labels:  audio, mp3, flac
Howler.js
Javascript audio library for the modern web.
Stars: ✭ 19,425 (+928.32%)
Mutual labels:  audio, playback, audio-library
Freac
The fre:ac audio converter project
Stars: ✭ 518 (-72.58%)
Mutual labels:  audio, mp3, flac

miniaudio

A single file library for audio playback and capture.

discord twitter

Examples - Documentation - Supported Platforms - Backends - Major Features - Building - Unofficial Bindings

Examples

This example shows how to decode and play a sound using the low level API.

#define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h"

#include <stdio.h>

void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
{
    ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
    if (pDecoder == NULL) {
        return;
    }

    ma_decoder_read_pcm_frames(pDecoder, pOutput, frameCount);

    (void)pInput;
}

int main(int argc, char** argv)
{
    ma_result result;
    ma_decoder decoder;
    ma_device_config deviceConfig;
    ma_device device;

    if (argc < 2) {
        printf("No input file.\n");
        return -1;
    }

    result = ma_decoder_init_file(argv[1], NULL, &decoder);
    if (result != MA_SUCCESS) {
        return -2;
    }

    deviceConfig = ma_device_config_init(ma_device_type_playback);
    deviceConfig.playback.format   = decoder.outputFormat;
    deviceConfig.playback.channels = decoder.outputChannels;
    deviceConfig.sampleRate        = decoder.outputSampleRate;
    deviceConfig.dataCallback      = data_callback;
    deviceConfig.pUserData         = &decoder;

    if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
        printf("Failed to open playback device.\n");
        ma_decoder_uninit(&decoder);
        return -3;
    }

    if (ma_device_start(&device) != MA_SUCCESS) {
        printf("Failed to start playback device.\n");
        ma_device_uninit(&device);
        ma_decoder_uninit(&decoder);
        return -4;
    }

    printf("Press Enter to quit...");
    getchar();

    ma_device_uninit(&device);
    ma_decoder_uninit(&decoder);

    return 0;
}

This example shows one way to play a sound using the high level API.

#define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h"

#include <stdio.h>

int main(int argc, char** argv)
{
    ma_result result;
    ma_engine engine;

    if (argc < 2) {
        printf("No input file.");
        return -1;
    }

    result = ma_engine_init(NULL, &engine);
    if (result != MA_SUCCESS) {
        printf("Failed to initialize audio engine.");
        return -1;
    }

    ma_engine_play_sound(&engine, argv[1], NULL);

    printf("Press Enter to quit...");
    getchar();

    ma_engine_uninit(&engine);

    return 0;
}

More examples can be found in the examples folder or online here: https://miniaud.io/docs/examples/

Documentation

Online documentation can be found here: https://miniaud.io/docs/

Documentation can also be found at the top of miniaudio.h which is always the most up-to-date and authoritive source of information on how to use miniaudio. All other documentation is generated from this in-code documentation.

Supported Platforms

  • Windows (XP+), UWP
  • macOS, iOS
  • Linux
  • BSD
  • Android
  • Raspberry Pi
  • Emscripten / HTML5

Backends

  • WASAPI
  • DirectSound
  • WinMM
  • Core Audio (Apple)
  • ALSA
  • PulseAudio
  • JACK
  • sndio (OpenBSD)
  • audio(4) (NetBSD and OpenBSD)
  • OSS (FreeBSD)
  • AAudio (Android 8.0+)
  • OpenSL|ES (Android only)
  • Web Audio (Emscripten)
  • Null (Silence)
  • Custom

Major Features

  • Your choice of either public domain or MIT No Attribution.
  • Entirely contained within a single file for easy integration into your source tree.
  • No external dependencies except for the C standard library and backend libraries.
  • Written in C and compilable as C++, enabling miniaudio to work on almost all compilers.
  • Supports all major desktop and mobile platforms, with multiple backends for maximum compatibility.
  • A low level API with direct access to the raw audio data.
  • A high level API with sound management and effects, including 3D spatialization.
  • Supports playback, capture, full-duplex and loopback (WASAPI only).
  • Device enumeration for connecting to specific devices, not just defaults.
  • Connect to multiple devices at once.
  • Shared and exclusive mode on supported backends.
  • Resource management for loading and streaming sounds.
  • A node graph system for advanced mixing and effect processing.
  • Data conversion (sample format conversion, channel conversion and resampling).
  • Filters.
    • Biquads
    • Low-pass (first, second and high order)
    • High-pass (first, second and high order)
    • Band-pass (second and high order)
  • Effects.
    • Delay/Echo
    • Spatializer
    • Stereo Pan
  • Waveform generation (sine, square, triangle, sawtooth).
  • Noise generation (white, pink, Brownian).
  • Decoding
    • WAV
    • FLAC
    • MP3
    • Vorbis via stb_vorbis (not built in - must be included separately).
    • Custom
  • Encoding
    • WAV

Refer to the Programming Manual for a more complete description of available features in miniaudio.

Building

Do the following in one source file:

#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"

Then just compile. There's no need to install any dependencies. On Windows and macOS there's no need to link to anything. On Linux just link to -lpthread, -lm and -ldl. On BSD just link to -lpthread and -lm. On iOS you need to compile as Objective-C.

If you prefer separate .h and .c files, you can find a split version of miniaudio in the extras/miniaudio_split folder. From here you can use miniaudio as a traditional .c and .h library - just add miniaudio.c to your source tree like any other source file and include miniaudio.h like a normal header. If you prefer compiling as a single translation unit (AKA unity builds), you can just #include the .c file in your main source file:

#include "miniaudio.c"

Note that the split version is auto-generated using a tool and is based on the main file in the root directory. If you want to contribute, please make the change in the main file.

Vorbis Decoding

Vorbis decoding is enabled via stb_vorbis. To use it, you need to include the header section of stb_vorbis before the implementation of miniaudio. You can enable Vorbis by doing the following:

#define STB_VORBIS_HEADER_ONLY
#include "extras/stb_vorbis.c"    /* Enables Vorbis decoding. */

#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"

/* stb_vorbis implementation must come after the implementation of miniaudio. */
#undef STB_VORBIS_HEADER_ONLY
#include "extras/stb_vorbis.c"

Unofficial Bindings

The projects below offer bindings for other languages which you may be interested in. Note that these are unofficial and are not maintained as part of this repository. If you encounter a binding-specific bug, please post a bug report to the specific project. If you've written your own bindings let me know and I'll consider adding it to this list.

Language Project
Go malgo
Python pyminiaudio
Rust miniaudio-rs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].