midi

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CINSystemCommon2   = 0x2
	CINSystemCommon3   = 0x3
	CINSysExStart      = 0x4
	CINSysExEnd1       = 0x5
	CINSysExEnd2       = 0x6
	CINSysExEnd3       = 0x7
	CINNoteOff         = 0x8
	CINNoteOn          = 0x9
	CINPoly            = 0xA
	CINControlChange   = 0xB
	CINProgramChange   = 0xC
	CINChannelPressure = 0xD
	CINPitchBendChange = 0xE
	CINSingleByte      = 0xF
)

From USB-MIDI section 4.1 "Code Index Number (CIN) Classifications"

View Source
const (
	MsgNoteOff           = 0x80
	MsgNoteOn            = 0x90
	MsgPolyAftertouch    = 0xA0
	MsgControlChange     = 0xB0
	MsgProgramChange     = 0xC0
	MsgChannelAftertouch = 0xD0
	MsgPitchBend         = 0xE0
	MsgSysExStart        = 0xF0
	MsgSysExEnd          = 0xF7
)

Standard MIDI channel messages

View Source
const (
	CCModulationWheel       = 0x01
	CCBreathController      = 0x02
	CCFootPedal             = 0x04
	CCPortamentoTime        = 0x05
	CCDataEntry             = 0x06
	CCVolume                = 0x07
	CCBalance               = 0x08
	CCPan                   = 0x0A
	CCExpression            = 0x0B
	CCEffectControl1        = 0x0C
	CCEffectControl2        = 0x0D
	CCGeneralPurpose1       = 0x10
	CCGeneralPurpose2       = 0x11
	CCGeneralPurpose3       = 0x12
	CCGeneralPurpose4       = 0x13
	CCBankSelect            = 0x20
	CCModulationDepthRange  = 0x21
	CCBreathControllerDepth = 0x22
	CCFootPedalDepth        = 0x24
	CCEffectsLevel          = 0x5B
	CCTremeloLevel          = 0x5C
	CCChorusLevel           = 0x5D
	CCCelesteLevel          = 0x5E
	CCPhaserLevel           = 0x5F
	CCDataIncrement         = 0x60
	CCDataDecrement         = 0x61
	CCNRPNLSB               = 0x62
	CCNRPNMSB               = 0x63
	CCRPNLSB                = 0x64
	CCRPNMSB                = 0x65
	CCAllSoundOff           = 0x78
	CCResetAllControllers   = 0x79
	CCAllNotesOff           = 0x7B
	CCChannelVolume         = 0x7F
)

Standard MIDI control change messages

Variables

View Source
var Midi *midi

Functions

func New

func New() *midi

New returns the USB MIDI port. Deprecated, better to just use Port()

func Port

func Port() *midi

Port returns the USB midi port.

Types

type Note

type Note uint8

Note represents a MIDI note number. For example, Note(69) is A4 or 440Hz.

const (
	A0 Note = iota + 21 // 27.5Hz
	AS0
	B0
	C1
	CS1
	D1
	DS1
	E1
	F1
	FS1
	G1
	GS1
	A1 // 55Hz
	AS1
	B1
	C2
	CS2
	D2
	DS2
	E2
	F2
	FS2
	G2
	GS2
	A2 // 110Hz
	AS2
	B2
	C3
	CS3
	D3
	DS3
	E3
	F3
	FS3
	G3
	GS3
	A3 // 220Hz
	AS3
	B3
	C4
	CS4
	D4
	DS4
	E4
	F4
	FS4
	G4
	GS4
	A4 // 440Hz
	AS4
	B4
	C5
	CS5
	D5
	DS5
	E5
	F5
	FS5
	G5
	GS5
	A5 // 880Hz
	AS5
	B5
	C6
	CS6
	D6
	DS6
	E6
	F6
	FS6
	G6
	GS6
	A6 // 1760Hz
	AS6
	B6
	C7
	CS7
	D7
	DS7
	E7
	F7
	FS7
	G7
	GS7
	A7 // 3520Hz
	AS7
	B7
	C8
	CS8
	D8
	DS8
	E8
	F8
	FS8
	G8
	GS8
	A8 // 7040Hz
	AS8
	B8
)

Define all the notes in a format similar to the Tone library in the Arduino IDE.

type RingBuffer

type RingBuffer struct {
	// contains filtered or unexported fields
}

RingBuffer is ring buffer implementation inspired by post at https://www.embeddedrelated.com/showthread/comp.arch.embedded/77084-1.php

func NewRingBuffer

func NewRingBuffer() *RingBuffer

NewRingBuffer returns a new ring buffer.

func (*RingBuffer) Clear

func (rb *RingBuffer) Clear()

Clear resets the head and tail pointer to zero.

func (*RingBuffer) Get

func (rb *RingBuffer) Get() ([]byte, bool)

Get returns a byte from the buffer. If the buffer is empty, the method will return a false as the second value.

func (*RingBuffer) Put

func (rb *RingBuffer) Put(val []byte) bool

Put stores a byte in the buffer. If the buffer is already full, the method will return false.

func (*RingBuffer) Used

func (rb *RingBuffer) Used() uint8

Used returns how many bytes in buffer have been used.

Jump to

Keyboard shortcuts

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