Skip to content
WAV file loader/emitter.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
waved
README.md
UNLICENSE.txt
dub.json

README.md

What's this?

wave-d is a tiny library to load/save WAV audio files.

Licenses

See UNLICENSE.txt

Usage

import std.stdio;
import waved;

void main()
{
    // Loads a WAV file in memory
    Sound input = decodeWAV("my_wav_file.wav");
    writefln("channels = %s", input.channels);
    writefln("samplerate = %s", input.sampleRate);
    writefln("samples = %s", input.samples.length);

    // Only keep the first channel (left)
    input = input.makeMono(); 

    // Multiply the left channel by 2 in-place
    foreach(i; 0..input.lengthInFrames)
        input.sample(0, i) *= 2.0f;

    // Duplicate the left channel, saves a two channels WAV file out of it
    float[][] channels = [input.channel(0), input.channel(0)];
    Sound(input.sampleRate, channels).encodeWAV("amplified-2x.wav");
}
You can’t perform that action at this time.