https://github.com/xyproto/simplewav
Write a simple .wav file (includes a sawtooth example)
https://github.com/xyproto/simplewav
audio go sawtooth wav
Last synced: 6 months ago
JSON representation
Write a simple .wav file (includes a sawtooth example)
- Host: GitHub
- URL: https://github.com/xyproto/simplewav
- Owner: xyproto
- License: bsd-3-clause
- Created: 2024-03-04T13:11:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-05T10:58:09.000Z (over 1 year ago)
- Last Synced: 2025-03-29T03:02:10.468Z (6 months ago)
- Topics: audio, go, sawtooth, wav
- Language: Go
- Homepage:
- Size: 1010 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```go
package mainimport (
"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

## General info
* Version: 1.0.0
* License: BSD-3