utils

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedEOF = fmt.Errorf("Unexpected End of File found.")

ErrUnexpectedEOF is returned, when an unexspected end of file is reached.

Functions

func ClearBitU8

func ClearBitU8(n uint8, pos uint8) uint8

ClearBitU8 clears the bit at position pos within n

func IsChannelMessage

func IsChannelMessage(b uint8) bool

IsChannelMessage returns if the given byte is a channel message

func IsStatusByte

func IsStatusByte(b uint8) bool

IsStatusByte returns if the given byte is a status byte

func KeyFromSharpsOrFlats

func KeyFromSharpsOrFlats(sharpsOrFlats int8, mode uint8) uint8

KeyFromSharpsOrFlats Taking a signed number of sharps or flats (positive for sharps, negative for flats) and a mode (0 for major, 1 for minor) decide the key signature.

This is a slightly modified variant of the keySignatureFromSharpsOrFlats function from Joe Wass. See the file music.go for the original.

func MsbLsbSigned

func MsbLsbSigned(n int16) uint16

MsbLsbSigned returns the uint16 for a signed MSB LSB message combination

func MsbLsbUnsigned

func MsbLsbUnsigned(n uint16) uint16

takes a 14bit uint and pads it to 16 bit like in the specs for e.g. pitchbend

func ParsePitchWheelVals

func ParsePitchWheelVals(b1 byte, b2 byte) (relative int16, absolute uint16)

func ParseStatus

func ParseStatus(b byte) (messageType uint8, messageChannel uint8)

ParseStatus parses the status byte and returns type and channel

This is a slightly modified variant of the readStatusByte function from Joe Wass. See the file midi_functions.go for the original.

func ParseTwoUint7

func ParseTwoUint7(b1, b2 byte) (uint8, uint8)

func ParseUint16

func ParseUint16(b1, b2 byte) uint16

ParseUint16 converts 2 bytes to a 16 bit integer This is a slightly modified variant of the parseUint16 function from Joe Wass. See the file midi_functions.go for the original.

func ParseUint7

func ParseUint7(b byte) uint8

func ReadByte

func ReadByte(rd io.Reader) (byte, error)

ReadByte reads a byte from the reader

func ReadNBytes

func ReadNBytes(n int, rd io.Reader) ([]byte, error)

ReadNBytes reads n bytes from the reader

func ReadText

func ReadText(rd io.Reader) (string, error)

func ReadUint16

func ReadUint16(rd io.Reader) (uint16, error)

ReadUint16 reads a 2-byte 16 bit integer from a Reader. It returns the 16-bit value and an error. This is a slightly modified variant of the parseUint16 function from Joe Wass. See the file midi_functions.go for the original.

func ReadUint24

func ReadUint24(rd io.Reader) (uint32, error)

ReadUint24 parse a 3-byte 24 bit integer from a Reader. It returns the 32-bit value and an error. This is a slightly modified variant of the parseUint24 function from Joe Wass. See the file midi_functions.go for the original.

func ReadUint32

func ReadUint32(rd io.Reader) (uint32, error)

ReadUint32 parse a 4-byte 32 bit integer from a Reader. It returns the 32-bit value and an error. This is a slightly modified variant of the parseUint32 function from Joe Wass. See the file midi_functions.go for the original.

func ReadVarLength

func ReadVarLength(reader io.Reader) (uint32, error)

ReadVarLength reads a variable length value from a Reader. It returns the [up to] 32-bit value and an error. This is a slightly modified variant of the parseVarLength function from Joe Wass. See the file midi_functions.go for the original.

func ReadVarLengthData

func ReadVarLengthData(reader io.Reader) ([]byte, error)

ReadVarLengthData reads data that is prefixed by a varLength that tells the length of the data

This is a slightly modified variant of the parseText function from Joe Wass. See the file midi_functions.go for the original.

func VlqDecode

func VlqDecode(source []byte) (num uint32)

Decode decodes a variable length quantity

func VlqEncode

func VlqEncode(n uint32) (out []byte)

Encode encodes the given value as variable length quantity

Types

This section is empty.

Jump to

Keyboard shortcuts

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