Skip to content

Drum beat is a Go library to handle drum beat patterns

License

Notifications You must be signed in to change notification settings

mattetti/drumbeat

Repository files navigation

drumbeat

Drumbeat is a Go library to create/parse drum beat patterns.

GoDoc Go Report Card Coverage Status Build Status

Example

More information and documentation available at GoDoc.

// define a pattern using text:
patterns := drumbeat.NewFromString(drumbeat.One16, `
	[kick]	{C1}	x.x.......xx...x	x.x.....x......x;
	[snare]	{D1}	....x.......x...	....x.......x...;
	[hihat]	{F#1}	x.x.x.x.x.x.x.x.	x.x.x.x.x.x.x.x.
`)

// convert to MIDI
f, err := os.Create("drumbeat.mid")
if err != nil {
    log.Println("something wrong happened when creating the MIDI file", err)
    os.Exit(1)
}
if err := drumbeat.ToMIDI(f, patterns...); err != nil {
    log.Fatal(err)
}
f.Close()

// generate a PNG visualization
imgf, err := os.Create("drumbeat.png")
if err != nil {
    log.Println("something wrong happened when creating the image file", err)
    os.Exit(1)
}
if err := drumbeat.SaveAsPNG(imgf, patterns); err != nil {
    log.Fatal(err)
}
imgf.Close()

png output

About

Drum beat is a Go library to handle drum beat patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages