Skip to content

Write a simple .wav file (includes a sawtooth example)

License

Notifications You must be signed in to change notification settings

xyproto/simplewav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simplewav

Given a float64[] and a sample rate (like 44100), write the audio to a WAV file.

The example in cmd/sawtooth generates a 1 second long audio file containing a sawtooth wave at 220Hz.

This is only for 16-bit 1-channel WAV files, for now.

Example use

package main

import (
    "time"

    "github.com/xyproto/sawtooth"
    "github.com/xyproto/simplewav"
)

func main() {
    const (
        duration           = 1 * time.Second
        frequency  float64 = 220
        sampleRate         = 44100
    )

    // Generate a sawtooth signal
    wave := sawtooth.GenerateSawtoothParticle(frequency, sampleRate, duration)

    // Write the wave to test.wav
    if err := simplewav.Write(wave, "test.wav", sampleRate); err != nil {
        panic(err)
    }
}

Image representation of the example sawtooth wave

waveform

General info

  • Version: 1.0.0
  • License: BSD-3

About

Write a simple .wav file (includes a sawtooth example)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages