Documentation ¶
Overview ¶
Package linnstrument provides a library that helps developing applications for the LinnStrument (http://www.rogerlinndesign.com).
The LinnStrument comes in two flavors, LinnStrument200 and the LinnStrument128 with 200 and 128 playable led pads. This library supports both via the Device interface.
In addition to the playable led pads, both devices have a "control column" on the left where 8 led pads are located that won't play MIDI notes, but are used by the factory firmware to allow to control its settings.
This library allows to set all available colors[1] and receive pressing and releasing events for both control pads and playable pads. Whenever the row and column of a led pad is send or returned, the column 0 denotes the control pads and the columns >= 1 the playable pads. The row however starts from top to bottom where top is 0 and bottom is 7.[3]
The LinnStrument allows to get pressing and releasing events for both control pads by switching to the "user firmware mode"[3] where most of the factory firmware functionality is off. This mode allows the developer to control the LinnStrument without interfering of the factory firmware. Only the "Global Setting" control pad keeps its behavior, allowing the user to switch between user firmware mode and factory firmware mode while pressing UPDATE OS for 0.5 sec. It is also possible to set the firmware mode by sending a MIDI message to the device. To achieve this, UserFirmwareMode can be used. The user firmware mode is set implicitely when the StartListening method is called and unset when the device is closed.
[1] See http://www.rogerlinndesign.com/ls-global-settings.html in section "Note Lights On/Off" for details about the underlying technique.
[2] This is the reverse of the underlying MIDI where the rows are counted from bottom to top, but we found it more convenient and helpful especially when using the library to trigger clips for Bitwig Studio and Reaper/Playtime.
[3] See https://github.com/rogerlinndesign/linnstrument-firmware/blob/master/user_firmware_mode.txt for details about firmware modes.
Index ¶
- Variables
- func DataDecimation(rateMS uint8) midi.Message
- func Greeter(d Device) error
- func Marquee(m Device, s string, dur time.Duration, textcolor, bgcolor Color) (err error)
- func Print(m Device, s string, textcolor, bgcolor Color) (err error)
- func SetRune(rn rune, l string)
- type Color
- type ColorWriter
- type Device
- type Error
- type Errors
- type Listener
- type Row
- type UserFirmwareMode
Constants ¶
This section is empty.
Variables ¶
var ( // RecommendedSleepDur is the recommended time to sleep between color setting calls to the LinnStrument RecommendedSleepDur = time.Microsecond * 150 )
Functions ¶
func DataDecimation ¶
the value corresponds to the number of milliseconds between data updates (minimum 12 ms in low power mode)
func Marquee ¶
Marquee displays the given string in a marquee-like manner on the device (from right to left).
func Print ¶
Print prints the given string to the device. If the string is too long, anything too long is not printed
func SetRune ¶
SetRune adds or replaces a representation of the given rune to allow "printing" of the rune on the LinnStrument. This repesentations are used by the functions Print, Greeting and Marquee to display text on the LinnStrument. The representation string must have 8 lines of same length, where each line may only contain either the '_' (underscore) or '#' (hash) character. The line length may vary from one rune representation to another. For the ASCII alphanumerical and punktuation runes there are predefined representations.
Types ¶
type Color ¶
type Color uint8
Color is a possible color of a Linnstrument pad.
const ( ColorAsNoteLights Color = 0 // as set in Note Lights settings ColorRed Color = 1 ColorYellow Color = 2 ColorGreen Color = 3 ColorCyan Color = 4 ColorBlue Color = 5 ColorMagenta Color = 6 ColorOff Color = 7 ColorWhite Color = 8 ColorOrange Color = 9 ColorLime Color = 10 ColorPink Color = 11 )
func (Color) Pad ¶
func (c Color) Pad(row, column uint8) ColorWriter
Pad returns a ColorWriter for the pad at position row, column
type ColorWriter ¶ added in v0.5.1
ColorWriter can be used to write the coloring to an io.Writer or to a midi.Writer
type Device ¶
type Device interface { // SetXData enables/disables sending of X-axis data for the given row SetXData(row uint8, enable bool) error // SetYData enables/disables sending of Y-axis data for the given row SetYData(row uint8, enable bool) error // SetZData enables/disables sending of Z-axis data for the given row SetZData(row uint8, enable bool) error // SetSlide enables/disables sending of slide data for the given row SetSlide(row uint8, enable bool) error // SetDataDecimation sets the data decimation SetDataDecimation(rateMS uint8) error // SetUserFirmwareMode sets the User Firmware mode (false: disable, true: enable) SetUserFirmwareMode(on bool) error // SetColor sets the pad at the given row and column to the given color. // Note that the first column (0) is the control pads on the left. // The rows are counted from top to bottom. SetColor(row, column uint8, color Color) error // SetColorAll sets all but the control pads to the given color. It has // reasonable sleeping time between the MIDI transmission to not // overload the LinnStrument. SetColorAll(color Color) // Cols returns the number of cols for the LinnStrument including // the control pads. Is 17 for the LinnStrument128 and 26 for the LinnStrument200. Cols() uint8 // Rows returns the number of rows. Should always be 8. Rows() uint8 // NumButtons returns the total number of buttons/pads, including the // control pads. NumButtons() uint8 // String returns the name of the LinnStrument. String() string // StartListening starts the user firmware mode and listens on the pad presses of the LinnStrument // and calls the given function for each press and release of a pad. // If velocity is 0, the key was released, otherwise pressed with the given velocity. // Note that the rows count from top to bottom and the col starts with the control pads on the left. StartListening(Listener) // Close closes the connection of the LinnStrument and returns to the factory // firmware. Close() error }
Device is a common interface for both the LinnStrument128 and the LinnStrument200.
func Find128 ¶
Find128 tries to find a LinnStrument on a MIDI port by looking for the string "LinnStrument" in the port name which would be only there, if the LinnStrument is connected via USB. The first port that is found is opened and a device is returned that would be appropriate for a LinnStrument128
func Find200 ¶
Find200 tries to find a LinnStrument on a MIDI port by looking for the string "LinnStrument" in the port name which would be only there, if the LinnStrument is connected via USB. The first port that is found is opened and a device is returned that would be appropriate for a LinnStrument200
type Listener ¶
type Listener interface { // OnTouch is called, when a pad has been touched OnTouch(row, col, velocity uint8) // OnXDataMSB is called, when the MSB part of x-axis data was received (only when X-data was enabled on the device) OnXDataMSB(row, col uint8, globalMSB uint8) // OnXDataLSB is called, when the LSB part of x-axis data was received (only when X-data was enabled on the device) OnXDataLSB(row, col uint8, globalLSB uint8) // OnYData is called, when y-axis data was received (only when y-data was enabled on the device) OnYData(row, col, val uint8) // OnZData is called, when z-axis data was received (only when z-data was enabled on the device) OnZData(row, col, val uint8) // OnSlideTransition is called, when a slide transition message was received (only when slide mode was enabled on the device) OnSlideTransition(row, col uint8) // OnUserFirmwareMode is called, when user firmware mode was enabled/disabled on the device // restoreColors function can be called to set the colors according to the last state that was set via SetColor calls. OnUserFirmwareMode(on bool, restoreColors func()) }
Listener listens for messages received from the LinnStrument
type Row ¶
type Row uint8 // Row starts counting from 0 (top) to 7 (bottom)
func (Row) XData ¶
XData returns a midi message that enableds/disables the sending of the X-axis data for the row
type UserFirmwareMode ¶
type UserFirmwareMode bool
UserFirmwareMode allows to set (true) or unset (false) the user firmware mode.
func (UserFirmwareMode) ScanReader ¶
func (f UserFirmwareMode) ScanReader(rd *reader.Reader, callback func(userFirmwareState bool))
ScanReader provides a comfortable way to scan the given reader.Reader for firmware mode messages and calls the given callback, if any such message came in. If the user firmware mode is activated userFirmwareState is true, if the factory firmware mode is activated, userFirmwareState is false. Please keep in mind, that this overrides the Msg.Channel.ControlChange.NRPN.LSB handler. If you need to combine with your custom NRPN LSB handler, set it on the reader before passing the reader to this function. Then for any non firmware mode related NRPN LSB your custom handler will be called. The NRPN MSB handler however is not affected at all, since the MSB value is not significant for the firmware mode message.