coremidi

package module
v0.0.0-...-d16028a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 7 Imported by: 2

README

go-coremidi

A Go library to use MIDI on Mac

Installation

go get github.com/youpy/go-coremidi

Synopsis

Monitor MIDI Messages
package main

import (
	"fmt"

	"github.com/youpy/go-coremidi"
)

func main() {
	client, err := coremidi.NewClient("a client")
	if err != nil {
		fmt.Println(err)
		return
	}

	port, err := coremidi.NewInputPort(
		client,
		"test",
		func(source coremidi.Source, packet coremidi.Packet) {
			fmt.Printf(
				"device: %v, manufacturer: %v, source: %v, data: %v\n",
				source.Entity().Device().Name(),
				source.Manufacturer(),
				source.Name(),
				packet.Data,
			)
			return
		},
	)
	if err != nil {
		fmt.Println(err)
		return
	}

	sources, err := coremidi.AllSources()
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, source := range sources {
		func(source coremidi.Source) {
			port.Connect(source)
		}(source)
	}

	ch := make(chan int)
	<-ch
}

Documents

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(name string) (client Client, err error)

type Destination

type Destination struct {
	*Object
	// contains filtered or unexported fields
}

func AllDestinations

func AllDestinations() (destinations []Destination, err error)

func NewDestination

func NewDestination(client Client, name string, readProc func(packet Packet)) (destination Destination, err error)

func (Destination) Dispose

func (dest Destination) Dispose()

type Device

type Device struct {
	*Object
	// contains filtered or unexported fields
}

func AllDevices

func AllDevices() (devices []Device, err error)

func (Device) Entities

func (device Device) Entities() (entities []Entity, err error)

type Entity

type Entity struct {
	*Object
	// contains filtered or unexported fields
}

func (Entity) Destinations

func (entity Entity) Destinations() (destinations []Destination, err error)

func (Entity) Device

func (entity Entity) Device() (device Device)

func (Entity) Sources

func (entity Entity) Sources() (sources []Source, err error)

type InputPort

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

func NewInputPort

func NewInputPort(client Client, name string, readProc ReadProc) (inputPort InputPort, err error)

func (InputPort) Connect

func (port InputPort) Connect(source Source) (portConnection, error)

type Object

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

func (Object) Manufacturer

func (object Object) Manufacturer() string

func (Object) Name

func (object Object) Name() string

type OutputPort

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

func NewOutputPort

func NewOutputPort(client Client, name string) (outputPort OutputPort, err error)

type Packet

type Packet struct {
	Data      []byte
	TimeStamp uint64
}

func NewPacket

func NewPacket(data []byte, timeStamp uint64) Packet

func (*Packet) Received

func (packet *Packet) Received(source *Source) (err error)

func (*Packet) Send

func (packet *Packet) Send(port *OutputPort, destination *Destination) (err error)

type ReadProc

type ReadProc func(source Source, packet Packet)

type Source

type Source struct {
	*Object
	// contains filtered or unexported fields
}

func AllSources

func AllSources() (sources []Source, err error)

func NewSource

func NewSource(client Client, name string) (source Source, err error)

func (*Source) Entity

func (source *Source) Entity() (entity Entity)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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