channel

package
v1.23.7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 4 Imported by: 45

Documentation

Overview

Package channel provides MIDI Channel Messages

Index

Constants

View Source
const (
	// PitchReset is the pitch bend value to reset the pitch wheel to zero
	PitchReset = 0

	// PitchLowest is the lowest possible value of the pitch bending
	PitchLowest = -8192

	// PitchHighest is the highest possible value of the pitch bending
	PitchHighest = 8191
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Aftertouch added in v1.7.0

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

Aftertouch represents a MIDI aftertouch message (aka "channel pressure")

func (Aftertouch) Channel added in v1.7.0

func (a Aftertouch) Channel() uint8

Channel returns the channel of the aftertouch message.

func (Aftertouch) Pressure added in v1.7.0

func (a Aftertouch) Pressure() uint8

Pressure returns the pressure of the aftertouch message.

func (Aftertouch) Raw added in v1.7.0

func (a Aftertouch) Raw() []byte

Raw returns the raw bytes of the aftertouch message.

func (Aftertouch) String added in v1.7.0

func (a Aftertouch) String() string

String returns human readable information about the aftertouch message.

type Channel

type Channel uint8

Channel represents a MIDI channel there must not be more than 16 MIDI channels (0-15)

const (
	// MIDI channel 1
	Channel0 Channel = iota

	// MIDI channel 2
	Channel1

	// MIDI channel 3
	Channel2

	// MIDI channel 4
	Channel3

	// MIDI channel 5
	Channel4

	// MIDI channel 6
	Channel5

	// MIDI channel 7
	Channel6

	// MIDI channel 8
	Channel7

	// MIDI channel 9
	Channel8

	// MIDI channel 10
	Channel9

	// MIDI channel 11
	Channel10

	// MIDI channel 12
	Channel11

	// MIDI channel 13
	Channel12

	// MIDI channel 14
	Channel13

	// MIDI channel 15
	Channel14

	// MIDI channel 16
	Channel15
)

func (Channel) Aftertouch added in v1.7.0

func (c Channel) Aftertouch(pressure uint8) Aftertouch

Aftertouch creates an aftertouch message on the channel

func (Channel) Channel

func (c Channel) Channel() uint8

Channel returns the number of the MIDI channel (0-15)

func (Channel) ControlChange

func (c Channel) ControlChange(controller uint8, value uint8) ControlChange

ControlChange creates a control change message on the channel

func (Channel) NoteOff

func (c Channel) NoteOff(key uint8) NoteOff

NoteOff creates a note-off message on the channel for the given key The note-off message is "faked" by a note-on message of velocity 0. This allows saving bandwidth by using running status. If you need a "real" note-off message with velocity, use NoteOffVelocity.

func (Channel) NoteOffVelocity

func (c Channel) NoteOffVelocity(key uint8, velocity uint8) NoteOffVelocity

NoteOffVelocity creates a note-off message with velocity on the channel.

func (Channel) NoteOn

func (c Channel) NoteOn(key uint8, velocity uint8) NoteOn

NoteOn creates a note-on message on the channel

func (Channel) Pitchbend added in v1.7.0

func (c Channel) Pitchbend(value int16) Pitchbend

Pitchbend creates a pitch bend message on the channel

func (Channel) PolyAftertouch added in v1.7.0

func (c Channel) PolyAftertouch(key uint8, pressure uint8) PolyAftertouch

PolyAftertouch creates a polyphonic aftertouch message on the channel

func (Channel) ProgramChange

func (c Channel) ProgramChange(program uint8) ProgramChange

ProgramChange creates a program change message on the channel

type ControlChange

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

ControlChange represents a MIDI control change message

func (ControlChange) Channel

func (c ControlChange) Channel() uint8

Channel returns the MIDI channel of the control change message

func (ControlChange) Controller

func (c ControlChange) Controller() uint8

Controller returns the controller of the control change message

func (ControlChange) Raw

func (c ControlChange) Raw() []byte

Raw returns the raw bytes of the control change message.

func (ControlChange) String

func (c ControlChange) String() string

String returns human readable information about the control change message.

func (ControlChange) Value

func (c ControlChange) Value() uint8

Value returns the value of the control change message

type Message

type Message interface {
	String() string
	Raw() []byte
	Channel() uint8
}

Message represents a channel message

func SetChannel added in v1.7.0

func SetChannel(msg Message, ch uint8) Message

type NoteOff

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

NoteOff represents a note-off message by a note-on message with velocity of 0 (helps for running status). This is the normal way to go. If you need the velocity of a note-off message, use NoteOffVelocity.

func (NoteOff) Channel

func (n NoteOff) Channel() uint8

Channel returns the channel of the note-off message

func (NoteOff) Key

func (n NoteOff) Key() uint8

Key returns the key of the note off message

func (NoteOff) Raw

func (n NoteOff) Raw() []byte

Raw returns the bytes for the noteoff message. To allowing running status, here the bytes for a noteon message (type 9) with velocity = 0 are returned. If you need a "real" noteoff message, call NoteOffPedantic.Raw()

func (NoteOff) String

func (n NoteOff) String() string

String returns human readable information about the note-off message.

type NoteOffVelocity

type NoteOffVelocity struct {
	NoteOff
	// contains filtered or unexported fields
}

NoteOffVelocity is offered as an alternative to NoteOff for a "real" noteoff message (type 8) that has velocity.

func (NoteOffVelocity) Raw

func (n NoteOffVelocity) Raw() []byte

Raw returns the bytes for the noteoff message. Since NoteOff.Raw() returns in fact a noteon message (type 9) with velocity of 0 to allow running status, NoteOffPedantic.Raw() is offered as an alternative to make sure a "real" noteoff message (type 8) is returned.

func (NoteOffVelocity) String

func (n NoteOffVelocity) String() string

String returns human readable information about the note-off message that includes velocity.

func (NoteOffVelocity) Velocity

func (n NoteOffVelocity) Velocity() uint8

Velocity returns the velocity of the note-off message

type NoteOn

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

NoteOn represents a note-on message

func (NoteOn) Channel

func (n NoteOn) Channel() uint8

Channel returns the channel of the note-on message

func (NoteOn) Key

func (n NoteOn) Key() uint8

Key returns the key of the note-on message

func (NoteOn) Raw

func (n NoteOn) Raw() []byte

Raw returns the bytes for the noteon message.

func (NoteOn) String

func (n NoteOn) String() string

String returns human readable information about the note-on message.

func (NoteOn) Velocity

func (n NoteOn) Velocity() uint8

Velocity returns the velocity of the note-on message

type Pitchbend added in v1.7.0

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

Pitchbend represents a pitch bend message (aka "Portamento").

func (Pitchbend) AbsValue added in v1.7.0

func (p Pitchbend) AbsValue() uint16

AbsValue returns the absolute value (14bit) of the pitch bending (unsigned)

func (Pitchbend) Channel added in v1.7.0

func (p Pitchbend) Channel() uint8

Channel returns the MIDI channel (starting with 0)

func (Pitchbend) Raw added in v1.7.0

func (p Pitchbend) Raw() []byte

Raw returns the raw bytes for the message

func (Pitchbend) String added in v1.7.0

func (p Pitchbend) String() string

String represents the MIDI pitch bend message as a string (for debugging)

func (Pitchbend) Value added in v1.7.0

func (p Pitchbend) Value() int16

Value returns the relative value of the pitch bending in relation to the middle (zero) point at 0 (-8191 to 8191)

type PolyAftertouch added in v1.7.0

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

PolyAftertouch represents a MIDI polyphonic aftertouch message (aka "key pressure")

func (PolyAftertouch) Channel added in v1.7.0

func (p PolyAftertouch) Channel() uint8

Channel returns the channel of the polyphonic aftertouch message

func (PolyAftertouch) Key added in v1.7.0

func (p PolyAftertouch) Key() uint8

Key returns the key of the polyphonic aftertouch message

func (PolyAftertouch) Pressure added in v1.7.0

func (p PolyAftertouch) Pressure() uint8

Pressure returns the pressure of the polyphonic aftertouch message

func (PolyAftertouch) Raw added in v1.7.0

func (p PolyAftertouch) Raw() []byte

Raw returns the raw bytes of the polyphonic aftertouch message.

func (PolyAftertouch) String added in v1.7.0

func (p PolyAftertouch) String() string

String returns human readable information about the polyphonic aftertouch message.

type ProgramChange

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

ProgramChange represents a MIDI program change message

func (ProgramChange) Channel

func (p ProgramChange) Channel() uint8

Channel returns the channel of the program change message.

func (ProgramChange) Program

func (p ProgramChange) Program() uint8

Program returns the program of the program change message.

func (ProgramChange) Raw

func (p ProgramChange) Raw() []byte

Raw returns the raw bytes of the program change message.

func (ProgramChange) String

func (p ProgramChange) String() string

String returns human readable information about the program change message.

type Reader

type Reader interface {
	// Read reads a single channel message.
	// It may just be called once per Reader. A second call returns io.EOF
	Read(status, arg1 byte) (Message, error)
}

Reader read a channel message

func NewReader

func NewReader(input io.Reader, options ...ReaderOption) Reader

NewReader returns a reader

type ReaderOption

type ReaderOption func(*reader)

ReaderOption is an option for the channel reader.

func ReadNoteOffVelocity

func ReadNoteOffVelocity() ReaderOption

ReadNoteOffVelocity lets the reader differentiate between "fake" noteoff messages (which are in fact noteon messages (typ 9) with velocity of 0) and "real" noteoff messages (typ 8) with own velocity. The former are returned as NoteOffVelocity messages and keep the given velocity, the later are returned as NoteOff messages without velocity. That means in order to get all noteoff messages, there must be checks for NoteOff and NoteOffVelocity (if this option is set). If this option is not set, both kinds are returned as NoteOff (default).

Jump to

Keyboard shortcuts

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