-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsamplekind.go
More file actions
44 lines (38 loc) · 817 Bytes
/
Copy pathsamplekind.go
File metadata and controls
44 lines (38 loc) · 817 Bytes
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
package main
import (
"path/filepath"
"strings"
)
type SampleKind string
func detectSampleKind(filename string) SampleKind {
name := strings.ToLower(strings.TrimSuffix(filename, filepath.Ext(filename)))
for _, dt := range cfg.DrumTypes {
for _, token := range dt.Tokens {
if strings.Contains(name, token) {
return SampleKind(dt.Name)
}
}
}
return ""
}
type Pitch int
const (
PitchLow Pitch = iota
PitchMid
PitchHigh
)
func detectPitch(filename string) Pitch {
name := strings.TrimSuffix(filename, filepath.Ext(filename))
tokens := strings.FieldsFunc(strings.ToLower(name), func(r rune) bool {
return r == ' ' || r == '-' || r == '_'
})
for _, t := range tokens {
switch t {
case "low", "lo":
return PitchLow
case "high", "hi":
return PitchHigh
}
}
return PitchMid
}