All Projects → adamstark → Audiofile

adamstark / Audiofile

Licence: gpl-3.0
A simple C++ library for reading and writing audio files.

Projects that are alternatives of or similar to Audiofile

Audio Steganography Algorithms
A Library of Audio Steganography & Watermarking Algorithms
Stars: ✭ 146 (-63.41%)
Mutual labels:  wav, audio
Pcmtowav
🎵PHP实现PCM格式音波文件转WAV格式音频文件
Stars: ✭ 160 (-59.9%)
Mutual labels:  wav, audio
Nwaves
.NET library for 1D signal processing focused specifically on audio processing
Stars: ✭ 151 (-62.16%)
Mutual labels:  wav, audio
Miniaudio
Single file audio playback and capture library written in C.
Stars: ✭ 1,889 (+373.43%)
Mutual labels:  wav, audio
Wavefile
A Ruby gem for reading and writing sound files in Wave format (*.wav)
Stars: ✭ 193 (-51.63%)
Mutual labels:  wav, audio
Mediafile
A unified reader of metadata from audio & video files.
Stars: ✭ 138 (-65.41%)
Mutual labels:  wav, audio
Ni Media
NI Media is a C++ library for reading and writing audio streams.
Stars: ✭ 158 (-60.4%)
Mutual labels:  wav, audio
Xamarin Plugins
Cross-platform Plugins for Xamarin, Xamarin.Forms and Windows
Stars: ✭ 97 (-75.69%)
Mutual labels:  wav, audio
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (-52.13%)
Mutual labels:  wav, audio
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 (-54.89%)
Mutual labels:  wav, audio
Music Metadata Browser
Browser version of music-metadata parser Supporting a wide range of audio and tag formats.
Stars: ✭ 105 (-73.68%)
Mutual labels:  wav, audio
Flacon
Audio File Encoder. Extracts audio tracks from an audio CD image to separate tracks.
Stars: ✭ 252 (-36.84%)
Mutual labels:  wav, audio
Vue Howler
[UNMAINTAINED] A Howler.js mixin for Vue 2 that makes it easy to create custom audio player components
Stars: ✭ 103 (-74.19%)
Mutual labels:  wav, audio
Wav
Battle tested Wav decoder/encoder
Stars: ✭ 139 (-65.16%)
Mutual labels:  wav, audio
Mad Twinnet
The code for the MaD TwinNet. Demo page:
Stars: ✭ 99 (-75.19%)
Mutual labels:  wav, audio
Img Encode
Encode an image to sound and view it as a spectrogram - turn your images into music
Stars: ✭ 157 (-60.65%)
Mutual labels:  wav, audio
Audio
Data manipulation and transformation for audio signal processing, powered by PyTorch
Stars: ✭ 1,262 (+216.29%)
Mutual labels:  wav, audio
Av Converter
[av-converter.com] Audio and Video Converter, and YouTube downloader. Convert to MP3, MP4, AAC, FLAC, AC3, WAV, etc.
Stars: ✭ 97 (-75.69%)
Mutual labels:  wav, audio
Audioplayer
Audio Player for Nextcloud and ownCloud
Stars: ✭ 179 (-55.14%)
Mutual labels:  wav, audio
Recorder
html5 js 录音 mp3 wav ogg webm amr 格式,支持pc和Android、ios部分浏览器、和Hybrid App(提供Android IOS App源码),微信也是支持的,提供H5版语音通话聊天示例 和DTMF编解码
Stars: ✭ 2,891 (+624.56%)
Mutual labels:  wav, audio

AudioFile

Version License Language

A simple header-only C++ library for reading and writing audio files.

Current supported formats:

  • WAV
  • AIFF

Author

AudioFile is written and maintained by Adam Stark.

http://www.adamstark.co.uk

Usage

Create an AudioFile object:

#include "AudioFile.h"

AudioFile<double> audioFile;

Load an audio file:

audioFile.load ("/path/to/my/audiofile.wav");

Get some information about the loaded audio:

int sampleRate = audioFile.getSampleRate();
int bitDepth = audioFile.getBitDepth();

int numSamples = audioFile.getNumSamplesPerChannel();
double lengthInSeconds = audioFile.getLengthInSeconds();

int numChannels = audioFile.getNumChannels();
bool isMono = audioFile.isMono();
bool isStereo = audioFile.isStereo();

// or, just use this quick shortcut to print a summary to the console
audioFile.printSummary();

Access the samples directly:

int channel = 0;
int numSamples = audioFile.getNumSamplesPerChannel();

for (int i = 0; i < numSamples; i++)
{
	double currentSample = audioFile.samples[channel][i];
}

Replace the AudioFile audio buffer with another

// 1. Create an AudioBuffer 
// (BTW, AudioBuffer is just a vector of vectors)

AudioFile<double>::AudioBuffer buffer;

// 2. Set to (e.g.) two channels
buffer.resize (2);

// 3. Set number of samples per channel
buffer[0].resize (100000);
buffer[1].resize (100000);

// 4. do something here to fill the buffer with samples, e.g.

#include <math.h> // somewhere earler (for M_PI and sinf())

// then...

int numChannels = 2;
int numSamplesPerChannel = 100000;
float sampleRate = 44100.f;
float frequency = 440.f;

for (int i = 0; i < numSamplesPerChannel; i++)
{
    float sample = sinf (2. * M_PI * ((float) i / sampleRate) * frequency) ;
    
    for (int channel = 0; channel < numChannels; channel++)
         buffer[channel][i] = sample * 0.5;
}

// 5. Put into the AudioFile object
bool ok = audioFile.setAudioBuffer (buffer);

Resize the audio buffer

// Set both the number of channels and number of samples per channel
audioFile.setAudioBufferSize (numChannels, numSamples);

// Set the number of samples per channel
audioFile.setNumSamplesPerChannel (numSamples);

// Set the number of channels
audioFile.setNumChannels (int numChannels);

Set bit depth and sample rate

audioFile.setBitDepth (24);
audioFile.setSampleRate (44100);

Save the audio file to disk

// Wave file (implicit)
audioFile.save ("path/to/desired/audioFile.wav");

// Wave file (explicit)
audioFile.save ("path/to/desired/audioFile.wav", AudioFileFormat::Wave);

// Aiff file
audioFile.save ("path/to/desired/audioFile.aif", AudioFileFormat::Aiff);

Examples

Please see the examples folder for some examples on library usage.

A Note On Types

AudioFile is a template class and so it can be instantiated using floating point precision:

AudioFile<float> audioFile;

...or double precision:

AudioFile<double> audioFile;

This simply reflects the data type you would like to use to store the underlying audio samples. You can still read or write 8, 16 or 24-bit audio files, regardless of the type that you use (unless your system uses a precision for floats less than your desired bit depth).

I have heard of people using the library with other types, but I have not designed for those cases. Let me know if you are interested in this supporting a specific type more formally.

Error Messages

By default, the library logs error messages to the console to provide information on what has gone wrong (e.g. a file we tried to load didn't exist).

If you prefer not to see these messages, you can disable this error logging behaviour using:

audioFile.shouldLogErrorsToConsole (false);

Versions

1.0.9 - 23rd January 2021
  • Faster loading of audio files
  • Bug fixes
1.0.8 - 18th October 2020
  • CMake support
  • Construct instances with a file path
  • Bug fixes
1.0.7 - 3rd July 2020
  • Support for 32-bit audio files
  • Support for multi-channel audio files
  • Reading/writing of iXML data chunks
1.0.6 - 29th February 2020
  • Made error logging to the console optional
  • Fixed lots of compiler warnings
1.0.5 - 14th October 2019
  • Added include of to better support Visual Studio
1.0.4 - 13th October 2019
  • Changed to a header-only library. Now you can just include AudioFile.h
  • Bug fixes
1.0.3 - 28th October 2018
  • Bug fixes
  • Documentation updates
1.0.2 - 6th June 2017
  • Bug fixes

Contributions

Want to Contribute?

If you would like to submit a pull request for this library, please do! But kindly follow the following simple guidelines...

  • Make the changes as concise as is possible for the change you are proposing
  • Avoid unnecessarily changing a large number of lines - e.g. commits changing the number of spaces in indentations on all lines (and so on)
  • Keep to the code style of this library which is the JUCE Coding Standards

License

Copyright (c) 2017 Adam Stark

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

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].