Created
May 7, 2017 22:28
-
-
Save wlcx/09acdca2fd161e0433b39e3e9dc65436 to your computer and use it in GitHub Desktop.
A silly hack that makes a Behringer X32 whiz its faders around over a network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/hypebeast/go-osc/osc" | |
) | |
type x32 struct { | |
client *osc.Client | |
} | |
func NewX32(ip string, port int) *x32 { | |
if port == 0 { | |
port = 10023 | |
} | |
return &x32{ | |
osc.NewClient(ip, port), | |
} | |
} | |
func (x *x32) SetChannel(channel int, value float32) { | |
msg := osc.NewMessage(fmt.Sprintf("/ch/%02d/mix/fader", channel)) | |
msg.Append(value) | |
x.client.Send(msg) | |
} | |
func main() { | |
x := NewX32("192.168.0.75", 0) | |
t := time.NewTicker(time.Millisecond * 20) | |
count := 0.0 | |
up := true | |
for { | |
select { | |
case <-t.C: | |
if up { | |
count += 0.01 | |
} else { | |
count -= 0.01 | |
} | |
if count >= 1 { | |
up = false | |
} | |
if count <= 0 { | |
up = true | |
} | |
for i := 0; i < 8; i++ { | |
x.SetChannel((i*2)+1, float32(count)) | |
x.SetChannel((i*2)+2, 1-float32(count)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment