go-sound

command module
v0.0.0-...-d2cf180 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2016 License: GPL-3.0 Imports: 18 Imported by: 0

README

go-sound

go-sound is a go library for dealing with sound waves. At the fundamental level, the library models each sound as a channel of [-1, 1] samples that represent the Compression Wave that comprises the sound.
To see it it action, check out demo.go or the examples provided by each file in the sounds package.

A tutorial explaining the basics behind sound wave modelling in code, and how it is implemented in go-sound, is available on my blog: http://padsterprogramming.blogspot.ch/2015/11/sounds-good-part-1.html

Features :
  • A Sound interface, with a BaseSound implementation that makes it simpler to write your own.
  • Sound Math (play notes together to make chords, or in serial to form a melody, ...)
  • Utilities for dealing with sounds (repeat sounds, generate from text, ...)
  • Implementations for various inputs (silence, sinusoidal wave, .wav file, ...)
  • Implementations for various outputs (play via pulse audio, draw to screen, .wav file, ...)
  • Realtime input (via MIDI) - with delay though.
  • Sound -> Spectrogram -> Sound conversion using a Constant Q transform
In progress:
  • MashApp, a golang server and polymer web app for manipulating sounds using the library.
Future plans:
  • Inputs and Outputs integrating with Jack Audio
  • Realtime input from microphone, more efficient from MIDI
  • Effects algorithms (digitial processing like reverb, bandpass ...)
Notes:

This library requires pulse audio installed to play the sounds, libflac for reading/writing flac files, and OpenGL 3.3 / GLFW 3.1 for rendering a soundwave to screen.

Some planned additions are included above, and include effects like those available in Audacity (e.g. rewriting Nyquist, LADSPA plugins in Go), or ones explained here or here. Additionally, some more complex instrument synthesizers could be added, and contributions are welcome.

The example piano .wav C note came from: http://freewavesamples.com/ensoniq-sq-1-dyno-keys-c4

Frequencies of notes are all obtained from: http://www.phy.mtu.edu/~suits/notefreqs.html

For MIDI input, a number of things are required for portmidi:

Overall quite a pain and there's still a noticeable delay in the MIDI input, patches to reduce that are welcome!

Credit to cryptix, cocoonlife, moriyoshi and rakyll for their wavFile, pulseAudio and portmidi implementations respectively, used by go-sound.

Documentation

Overview

Demo usage of the go-sound Sounds library, to play Clair de Lune.

go run spectrogramshift.go --shift=<semitones> <file>

Directories

Path Synopsis
Write a sound to a .wav file Write sounds to audio output via Jack (http://jackaudio.org) Package output it responsible for preparing the sounds for human consumption, whether audio, visual or other means.
Write a sound to a .wav file Write sounds to audio output via Jack (http://jackaudio.org) Package output it responsible for preparing the sounds for human consumption, whether audio, visual or other means.
Package sounds provides the basic types for Sounds within this system, plus multiple implementations of different sounds that can be used.
Package sounds provides the basic types for Sounds within this system, plus multiple implementations of different sounds that can be used.
A circular buffer data type for floating point values.
A circular buffer data type for floating point values.
Renders various data from a channel of [-1, 1] onto screen.
Renders various data from a channel of [-1, 1] onto screen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL