kick

package module
v0.0.0-...-f4bdbdc Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 11 Imported by: 0

README

Kick

This is a Go package together with a command line utility for generating kick drum audio samples.

Note that the project is a bit experimental, a work in progress and that the generated samples aren't quite right, yet.

This project is now archived and synth is a continuation of it.

Contents

  • A Go package for generating kick drum samples with a wide variety of parameters.
  • A command-line utility for generating kick drum samples (cmd/kick).

Requirements

  • go for building the executables.
  • mpv or ffmpeg for playing the generated samples, when using cmd/kick.

Installation

go install github.com/xyproto/kick/cmd/kick@latest

Usage

Command-line Utility

Generate a kick drum inspired by the Roland TR-808 drum machine:

kick --808 -o kick808.wav

You can customize various parameters like the waveform, attack, decay, and more:

kick --waveform 0 --attack 0.005 --decay 0.3 --release 0.2 --drive 0.4 --o custom_kick.wav

Available drum machine styles:

  • --606 for 606-style kicks.
  • --707 for 707-style kicks.
  • --808 for 808-style kicks.
  • --909 for 909-style kicks.
  • --linn for LinnDrum-style kicks.
  • --experimental for unique and experimental sounds.
  • --deephouse for deep house kicks.

Audio Samples

A few generated samples can be found in the samples/ directory. They include both .wav and .mp4 formats to showcase the sounds in GitHub's README.

General info

  • License: MIT
  • Version: 1.8.1

Documentation

Index

Constants

View Source
const (
	WaveSine = iota
	WaveTriangle
	WaveSawtooth
	WaveSquare
	WaveNoiseWhite
	WaveNoisePink
	WaveNoiseBrown
)
View Source
const (
	NoiseNone = iota
	NoiseWhite
	NoisePink
	NoiseBrown
)

Variables

This section is empty.

Functions

func PlayWav

func PlayWav(filePath string) error

PlayWav plays a WAV file using mpv or ffmpeg

func PlayWaveform

func PlayWaveform(wave []int, sampleRate int) error

PlayWaveform writes the waveform to a temporary .wav file and plays it using mpv or ffmpeg

Types

type Settings

type Settings struct {
	StartFreq                  float64
	EndFreq                    float64
	SampleRate                 int
	Duration                   float64
	WaveformType               int
	Attack                     float64
	Decay                      float64
	Sustain                    float64
	Release                    float64
	Drive                      float64
	FilterCutoff               float64
	FilterResonance            float64
	Sweep                      float64
	PitchDecay                 float64
	NoiseType                  int
	NoiseAmount                float64
	Output                     io.WriteSeeker
	NumOscillators             int
	OscillatorLevels           []float64
	SaturatorAmount            float64
	FilterBands                []float64
	BitDepth                   int
	FadeDuration               float64
	SmoothFrequencyTransitions bool
}

func CopySettings

func CopySettings(cfg *Settings) *Settings

CopySettings creates a deep copy of a Settings struct

func New606

func New606(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

func New707

func New707(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

func New808

func New808(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

func New909

func New909(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

func NewDeepHouse

func NewDeepHouse(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

NewDeepHouse creates a kick drum perfect for Deep House music

func NewExperimental

func NewExperimental(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

NewExperimental with more extreme parameters for a truly experimental sound

func NewLinnDrum

func NewLinnDrum(sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

NewLinnDrum emulates the LinnDrum bass drum, known for its punchy and iconic sound

func NewRandom

func NewRandom() *Settings

Generate random kick settings

func NewSettings

func NewSettings(startFreq, endFreq float64, sampleRate int, duration float64, bitDepth int, output io.WriteSeeker) (*Settings, error)

func (*Settings) Color

func (cfg *Settings) Color() color.RGBA

Color returns a color that very approximately represents the current kick config

func (*Settings) GenerateKick

func (cfg *Settings) GenerateKick() error

func (*Settings) GenerateKickInMemory

func (cfg *Settings) GenerateKickInMemory() ([]int, error)

GenerateKickInMemory generates the kick waveform and returns it as a slice of integers.

func (*Settings) Play

func (cfg *Settings) Play() error

Play generates a kick and plays it directly using mpv or ffmpeg

func (*Settings) SaveTo

func (cfg *Settings) SaveTo(directory string) (string, error)

SaveTo saves the generated kick to a specified directory, avoiding filename collisions

Directories

Path Synopsis
cmd
kick command

Jump to

Keyboard shortcuts

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