smfimage

package module
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 21 Imported by: 3

README

smfimage

Converts a Standard MIDI File (SMF) file to an image (PNG), based on keys and timing; separated by track.

Go Reference

Status

usable (experimental)

Installation of the CLI tool

 go install github.com/gomidi/smfimage/cmd/smfimage

Usage

Try it online at https://smfimage.herokuapp.com/

The following command creates the file my-midi-file.png reflecting the notes of midi-file.mid

 smfimage my-midi-file.mid

Colors are set based on the interval to the basenote (defaults to "C"). You can pass the base note to the command line via -b.

For more options

 smfimage help

The following color mapping is used

prime/octave  -> yellow
minor second  -> mint
major second  -> orange
minor third   -> sky blue
major third   -> spring green
fourth        -> cyan
tritone       -> lime/chartreuse
fifth         -> royalblue
minor sixth   -> pink
major sixth   -> violett/purple
minor seventh -> magenta
major seventh -> red

If you want to define own mappings, use the library and create a ColorMapper.

Examples

color note mapping

example image

monochrome mode: velocity mapping: quiet (red) <-> loud (yellow)

example image

Documentation

smfimage can also be used as library, see https://pkg.go.dev/gitlab.com/gomidi/smfimage

Documentation

Overview

Package smfimage converts a Standard MIDI File (SMF) to an image (PNG), based on keys and timing; separated by channel.

Index

Constants

View Source
const (
	Prime      Interval = 0
	MinSecond  Interval = 1
	MajSecond  Interval = 2
	MinThird   Interval = 3
	MajThird   Interval = 4
	Fourth     Interval = 5
	Tritone    Interval = 6
	Fifth      Interval = 7
	MinSixth   Interval = 8
	MajSixth   Interval = 9
	MinSeventh Interval = 10
	MajSeventh Interval = 11

	Unison = Prime
	Octave = Prime

	C      Note = 0
	CSharp Note = 1
	D      Note = 2
	DSharp Note = 3
	E      Note = 4
	F      Note = 5
	FSharp Note = 6
	G      Note = 7
	GSharp Note = 8
	A      Note = 9
	ASharp Note = 10
	B      Note = 11

	DFlat  = CSharp
	EFlat  = DSharp
	ESharp = F
	FFlat  = E
	GFlat  = FSharp
	AFlat  = GSharp
	BFlat  = ASharp
	BSharp = C
	CFlat  = B
)
View Source
const VERSION = "0.14.7"

Variables

View Source
var (
	ColorYellow          = color.RGBA{255, 255, 0, 255} // yellow
	ColorElectricLime    = color.RGBA{201, 255, 0, 255} // yellow-green
	ColorSpringBud       = color.RGBA{148, 255, 0, 255} // light green
	ColorHarlequin       = color.RGBA{81, 255, 0, 255}  // green
	ColorMalachite       = color.RGBA{0, 232, 83, 255}  // dark green
	ColorCaribbeanGreen  = color.RGBA{0, 206, 133, 255} // turkis
	ColorRobinsEggBlue   = color.RGBA{0, 196, 190, 255} // blue-green
	ColorDeepSkyBlue     = color.RGBA{0, 173, 236, 255} // sky blue
	ColorDodgerBlue      = color.RGBA{0, 130, 255, 255} // light blue
	ColorNavyBlue        = color.RGBA{0, 83, 255, 255}  // deep blue
	ColorBlue            = color.RGBA{0, 57, 255, 255}  // blue
	ColorDarkBlue        = color.RGBA{0, 0, 255, 255}   // dark blue
	ColorIndigoBlue      = color.RGBA{90, 0, 252, 255}  // indigo blue
	ColorElectricIndigo  = color.RGBA{105, 0, 210, 255} // indigo
	ColorDarkViolet      = color.RGBA{153, 0, 202, 255} // violet
	ColorDeepMagenta     = color.RGBA{201, 0, 195, 255} // magenta
	ColorRazzmatazz      = color.RGBA{247, 0, 117, 255} // pink
	ColorRed             = color.RGBA{255, 0, 0, 255}   // red
	ColorOrangeRed       = color.RGBA{255, 60, 0, 255}  // orange red
	ColorSafetyOrange    = color.RGBA{255, 106, 0, 255} // orange
	ColorDarkOrange      = color.RGBA{255, 149, 0, 255} // dark orange
	ColorSelectiveYellow = color.RGBA{255, 176, 0, 255} // yellow-orange
	ColorTangerineYellow = color.RGBA{255, 202, 0, 255} // dark yellow
	ColorGoldenYellow    = color.RGBA{255, 227, 0, 255} // deep yellow

	//                                                                             names according to https://www.htmlcsscolor.com
	PrimeColor = ColorYellow //                               C  hellgelb 255 255   0   ffff00 Yellow
	//                                                               201 255   0   c9ff00 Electric Lime
	MinSecondColor = ColorSpringBud //                          C# hellgrün 148 255   0   94ff00 Spring Bud
	//                                                                81 255   0   51ff00 Harlequin
	MajSecondColor = ColorMalachite //                             D  dunkelgrün 0 232  83   00e853 Malachite
	//                                                                 0 206 133   00ce85 Caribbean Green
	MinThirdColor = ColorRobinsEggBlue // oliv                         D#  türkis    0 196 190   00c4be Robin's Egg Blue
	//                                                                 0 173 236   00adec Deep Sky Blue
	MajThirdColor = ColorDodgerBlue // türkis                E hellblau    0 130 255   0082ff Dodger Blue
	//                                                                 0  83 255   0053ff Navy Blue
	FourthColor = ColorBlue // activ red                       F dunkelblau  0  57 255   0039ff Blue
	//                                                                 0   0 255   0000ff Blue
	TritoneColor = ColorIndigoBlue //                               F# violet    90   0 252   5a00fc Electric Indigo
	//                                                               105   0 210   6900d2 Electric Indigo
	FifthColor = ColorDarkViolet // activ blue                   G  purple   153   0 202   9900ca Dark Violet
	//                                                               201   0 195   c900c3 Deep Magenta
	MinSixthColor = ColorRazzmatazz // burgunder rot-brown       G#  pink    247   0 117   f70075 Razzmatazz
	//                                                               255   0   0   ff0000 Red
	MajSixthColor = ColorOrangeRed //                            A      rot  255  60   0   ff3c00 Orange Red
	//                                                               255 106   0   ff6a00 Safety Orange
	MinSeventhColor = ColorDarkOrange // dark/deep blue        A#  orange  255 149   0   ff9500 Dark Orange
	//                                                               255 176   0   ffb000 Selective Yellow
	MajSeventhColor = ColorTangerineYellow //                         H dunkelgelb255 202   0   ffca00 Tangerine Yellow
	//                                                               255 227   0   ffe300 golden yellow
	//                                                   C hellgelb  255 255   0   ffff00 yellow
	/*
		PrimeColor      = color.RGBA{255, 255, 0, 255}   // yellow prime/oktave (c)
		MinSecondColor  = color.RGBA{189, 252, 201, 255} // mint kl. sekunde (des)
		MajSecondColor  = color.RGBA{255, 165, 0, 255}   // orange gr sekunde    (d)
		MinThirdColor   = color.RGBA{135, 206, 255, 255} // sky blue kl terz (es)
		MajThirdColor   = color.RGBA{0, 205, 102, 255}   // spring green große terz    (e)
		FourthColor     = color.RGBA{0, 245, 255, 255}   // cyan/türkis, quarte (f)
		TritoneColor    = color.RGBA{127, 255, 0, 255}   // lime/chartreuse tritonus (ges)
		FifthColor      = color.RGBA{72, 118, 255, 255}  // royalblue quinte       (g)
		MinSixthColor   = color.RGBA{255, 192, 203, 255} // pink kl. sexte (as)
		MajSixthColor   = color.RGBA{155, 48, 255, 255}  // violett/purple gr sexte      (a)
		MinSeventhColor = color.RGBA{255, 0, 255, 255}   // magenta kl. septe (b)
		MajSeventhColor = color.RGBA{255, 0, 0, 255}     // red gr sept       (h)
	*/
	LightGrey = color.RGBA{187, 187, 187, 255}
	DarkGrey  = color.RGBA{120, 120, 120, 255}
)
View Source
var RainbowColors colorMapper = map[Interval]color.Color{
	Prime:      PrimeColor,
	MinSecond:  MinSecondColor,
	MajSecond:  MajSecondColor,
	MinThird:   MinThirdColor,
	MajThird:   MajThirdColor,
	Fourth:     FourthColor,
	Tritone:    TritoneColor,
	Fifth:      FifthColor,
	MinSixth:   MinSixthColor,
	MajSixth:   MajSixthColor,
	MinSeventh: MinSeventhColor,
	MajSeventh: MajSeventhColor,
}

Functions

func New

func New(input io.Reader, options ...Option) (im *smfimage, trackNames []string, err error)

func NoteToNumber added in v0.8.0

func NoteToNumber(name string) int

func SMF2PNG

func SMF2PNG(inFile string, outFile string, options ...Option) (trackNames []string, err error)

if outfile is "", no outfile is written (just the tracknames are returned)

Types

type ColorMapper

type ColorMapper interface {
	Map(i Interval) color.Color
}

ColorMapper maps an interval (counted from basenote) to a color

type Interval

type Interval byte

type Note

type Note byte

type Option

type Option func(*smfimage)

func Background

func Background(name string) Option

func BaseNote

func BaseNote(n Note) Option

BaseNote sets the reference/base note smfimage.C , smfimage.CSharp etc.

func BeatsInGrid

func BeatsInGrid() Option

func Colors

func Colors(cm ColorMapper) Option

func Curve

func Curve() Option

func Height

func Height(height int) Option

Height of 32thnote in pixel (default = 4)

func Monochrome

func Monochrome() Option

func NoBackground

func NoBackground() Option

func NoBarLines

func NoBarLines() Option

func Overview added in v0.8.0

func Overview() Option

func SingleBar

func SingleBar() Option

func SkipTracks

func SkipTracks(tracks ...int) Option

func TrackBorder

func TrackBorder(border int) Option

TrackBorder in pixel (default = 2)

func TrackOrder

func TrackOrder(order ...int) Option

func Verbose added in v0.14.4

func Verbose() Option

func Width

func Width(width int) Option

Width of 32thnote in pixel (default = 4)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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