midi2scsynth

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 6 Imported by: 0

README

midi2scsynth

Converts MIDI data to OSC messages for the supercollider synth and sends them on the fly

Status

usable, early stages. Only MIDI on/off messages are currently supported.

Documentation

see http://godoc.org/github.com/gomidi/midi2scsynth

Installation

go get -u -d github.com/gomidi/midi2scsynth/cmd/midi2scsynth

Usage

use

midi2scsynth list

to get a list of available MIDI in ports.

and

midi2scsynth -i=3 -s='theremin'

to use the MIDI data of port 3 to trigger synths of the synthdef "theremin". For this to work, the scsynth must have been started on localhost and listening on port 57110 (default), other addresses can be set via -a flag. Also this example expects that the scsynth has been given a synthdef for 'theremin', e.g.

SynthDef(\theremin, {
	arg gate=1, freq, amp;
	var osc, env;
	env = EnvGen.ar( envelope:Env.asr(releaseTime:0.05), gate: gate, doneAction: 2 );
	osc = SinOsc.ar( freq );
	Out.ar(0, osc*env*amp*0.2);
}).add;

for further options:

midi2scsynth help

Usage as a library

example code

package main

import (
	"fmt"
	"os"
	"os/signal"

	"github.com/gomidi/connect"
	"github.com/gomidi/midi2scsynth"
	"github.com/gomidi/rtmididrv"
)

var sigchan = make(chan os.Signal, 10)

func main() {
	err := run()
	if err != nil {
		fmt.Fprintf(os.Stderr, "ERROR: %v", err)
	}
}

func run() error {
	m := midi2scsynth.New("theremin")
	drv, err := rtmididrv.New()
	if err != nil {
		return err
	}
	in, err := connect.OpenIn(drv, 10, "")
	if err != nil {
		return err
	}

	err = m.Listen(in)
	if err != nil {
		return err
	}

	// listen for ctrl+c
	go signal.Notify(sigchan, os.Interrupt)

	// interrupt has happend
	<-sigchan

	fmt.Fprint(os.Stdout, "\ninterrupted...")

	return m.Close()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener interface {
	Listen(midi.In) error
	Close() error
}

func New

func New(synthdef string, options ...Option) Listener

type Option

type Option func(*listener)

func Channel

func Channel(ch uint8) Option

func SCAddress

func SCAddress(addr string) Option

func SCConnection

func SCConnection(wr io.WriteCloser) Option

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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