Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ releases/
*.bin
logs/
preferences.yaml
.idea
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ slider_mapping:
# set this to true if you want the controls inverted (i.e. top is 0%, bottom is 100%)
invert_sliders: false

# settings for connecting to the arduino board
# settings for connecting to the arduino board using Serial
com_port: COM4
baud_rate: 9600
# settings for connecting to a MIDI device with sliders
midi_dev_name: "Pico"
# Set connection type to either "serial" or "midi"
connection_type: serial

# adjust the amount of signal noise reduction depending on your hardware quality
# supported values are "low" (excellent hardware), "default" (regular hardware) or "high" (bad, noisy hardware)
Expand Down
6 changes: 5 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ slider_mapping:
# set this to true if you want the controls inverted (i.e. top is 0%, bottom is 100%)
invert_sliders: false

# settings for connecting to the arduino board
# settings for connecting to the arduino board using Serial
com_port: COM4
baud_rate: 9600
# settings for connecting to a MIDI device with sliders
midi_dev_name: "Pico"
# Set connection type to either "serial" or "midi"
connection_type: serial

# adjust the amount of signal noise reduction depending on your hardware quality
# supported values are "low" (excellent hardware), "default" (regular hardware) or "high" (bad, noisy hardware)
Expand Down
59 changes: 45 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
module github.com/omriharel/deej

go 1.14
go 1.22.2

toolchain go1.23.5

require (
github.com/fsnotify/fsnotify v1.4.9
github.com/gen2brain/beeep v0.0.0-20200420150314-13046a26d502
github.com/getlantern/ops v0.0.0-20200403153110-8476b16edcd6 // indirect
github.com/getlantern/systray v0.0.0-20200324212034-d3ab4fd25d99
github.com/go-ole/go-ole v1.2.4
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/fsnotify/fsnotify v1.8.0
github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4
github.com/getlantern/systray v1.2.2
github.com/go-ole/go-ole v1.3.0
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4
github.com/jfreymuth/pulse v0.0.0-20200608153616-84b2d752b9d4
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1 // indirect
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4
github.com/jfreymuth/pulse v0.1.1
github.com/lxn/win v0.0.0-20210218163916-a377121e959e
github.com/mitchellh/go-ps v1.0.0
github.com/moutend/go-wca v0.1.2-0.20190422112502-0fa027b3d89a
github.com/spf13/viper v1.7.1
github.com/thoas/go-funk v0.7.0
go.uber.org/zap v1.15.0
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
github.com/spf13/viper v1.19.0
github.com/thoas/go-funk v0.9.3
gitlab.com/gomidi/midi/v2 v2.2.19
go.uber.org/zap v1.27.0
)

require (
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
435 changes: 86 additions & 349 deletions go.sum

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions pkg/deej/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ type CanonicalConfig struct {
SliderMapping *sliderMap

ConnectionInfo struct {
COMPort string
BaudRate int
COMPort string
BaudRate int
MidiDevName string
ConnectionType string
}

InvertSliders bool
Expand Down Expand Up @@ -51,6 +53,8 @@ const (
configKeySliderMapping = "slider_mapping"
configKeyInvertSliders = "invert_sliders"
configKeyCOMPort = "com_port"
configKeyMidiDevName = "midi_dev_name"
configKeyConnectionType = "connection_type"
configKeyBaudRate = "baud_rate"
configKeyNoiseReductionLevel = "noise_reduction"

Expand Down Expand Up @@ -224,6 +228,9 @@ func (cc *CanonicalConfig) populateFromVipers() error {
)

// get the rest of the config fields - viper saves us a lot of effort here
cc.ConnectionInfo.MidiDevName = cc.userConfig.GetString(configKeyMidiDevName)
cc.ConnectionInfo.ConnectionType = cc.userConfig.GetString(configKeyConnectionType)

cc.ConnectionInfo.COMPort = cc.userConfig.GetString(configKeyCOMPort)

cc.ConnectionInfo.BaudRate = cc.userConfig.GetInt(configKeyBaudRate)
Expand Down
16 changes: 16 additions & 0 deletions pkg/deej/deej.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Deej struct {
notifier Notifier
config *CanonicalConfig
serial *SerialIO
midi *MidiIO
sessions *sessionMap

stopChannel chan bool
Expand Down Expand Up @@ -55,6 +56,14 @@ func NewDeej(logger *zap.SugaredLogger, verbose bool) (*Deej, error) {
verbose: verbose,
}

midi, err := NewMidiIO(d, logger)
if err != nil {
logger.Errorw("Failed to create MidiIO", "error", err)
return nil, fmt.Errorf("create new MidiIO: %w", err)
}

d.midi = midi

serial, err := NewSerialIO(d, logger)
if err != nil {
logger.Errorw("Failed to create SerialIO", "error", err)
Expand Down Expand Up @@ -141,6 +150,12 @@ func (d *Deej) run() {
// watch the config file for changes
go d.config.WatchConfigFileChanges()

err := d.midi.Start()
if err != nil {
d.logger.Warnw("Failed to start MIDI I/O", "error", err)
return
}

// connect to the arduino for the first time
go func() {
if err := d.serial.Start(); err != nil {
Expand Down Expand Up @@ -192,6 +207,7 @@ func (d *Deej) stop() error {

d.config.StopWatchingConfigFile()
d.serial.Stop()
d.midi.Stop()

// release the session map
if err := d.sessions.release(); err != nil {
Expand Down
Loading