1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
Copyright (C) 2019 Leo Tenenbaum
This file is part of AutoVCV.
AutoVCV is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AutoVCV is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AutoVCV. If not, see <https://www.gnu.org/licenses/>.
*/
package main
import (
"autovcv/autovcv"
"autovcv/vcv"
"fmt"
"os"
"math/rand"
"time"
"flag"
"runtime"
"strings"
)
type versionNumber struct {
plugin string
version string
}
func main() {
modules := flag.Int("modules", 50, "The number of modules to create")
wires := flag.Int("wires", 100, "The maximum number of wires to create between modules")
seed := flag.Int64("seed", time.Now().UTC().UnixNano(), "The seed to use for the random number generator")
outputFile := flag.String("out", "out.vcv", "The name of the output VCV file")
var versions []versionNumber = make([]versionNumber, 0, len(vcv.Versions))
for key, val := range vcv.Versions {
versions = append(versions, versionNumber{key, val})
flag.StringVar(&versions[len(versions)-1].version,
"version-" + strings.ToLower(key), val,
fmt.Sprintf("The version of the %v plugin", key))
}
var defaultDevice string
if runtime.GOOS == "windows" {
defaultDevice = "Speakers (Realtek High Definition Audio)"
} else {
defaultDevice = "default"
}
deviceName := flag.String("device", defaultDevice, "The audio device to use")
flag.Parse()
// Put versions into vcv.Versions
for _, vnum := range versions {
vcv.Versions[vnum.plugin] = vnum.version
}
rand.Seed(*seed)
fmt.Println("Using seed:", *seed)
vcv := autovcv.RandomVCV(*modules, *wires)
file, err := os.Create(*outputFile)
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
err = vcv.Write(file, *deviceName)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Successfully outputted to %v\n", *outputFile)
}
|