Fix: Key detection
This commit is contained in:
parent
fa0b2f104e
commit
8cea1779e4
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -87,6 +88,16 @@ var drumToDirMap = map[DrumType]string{
|
|||||||
HatOpen: "HiHat/Open", EightOhEight: "808", Tom: "Toms", Percussion: "Other",
|
HatOpen: "HiHat/Open", EightOhEight: "808", Tom: "Toms", Percussion: "Other",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
rgxSharpIn, _ = regexp.Compile("[♯#]|major")
|
||||||
|
rgxFlatIn, _ = regexp.Compile("^F|[♭b]")
|
||||||
|
rgxSharpBegin, _ = regexp.Compile("^[♯#]")
|
||||||
|
rgxFlatBegin, _ = regexp.Compile("^[♭b]")
|
||||||
|
rgxSharpishIn, _ = regexp.Compile("(M|maj|major|aug)")
|
||||||
|
rgxFlattishIn, _ = regexp.Compile("([^a-z]|^)(m|min|minor|dim)")
|
||||||
|
mustMatchOne = []*regexp.Regexp{rgxFlatIn, rgxFlatBegin, rgxSharpBegin, rgxSharpIn, rgxFlattishIn, rgxSharpishIn}
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Sample) ParseFilename() {
|
func (s *Sample) ParseFilename() {
|
||||||
atomic.AddInt32(&Backlog, 1)
|
atomic.AddInt32(&Backlog, 1)
|
||||||
defer atomic.AddInt32(&Backlog, -1)
|
defer atomic.AddInt32(&Backlog, -1)
|
||||||
@ -118,13 +129,25 @@ func (s *Sample) ParseFilename() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spl := strings.Split(opiece, "")
|
spl := strings.Split(opiece, "")
|
||||||
if len(spl) < 1 {
|
if len(spl) < 1 || len(spl) > 5 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// if our fragment starts with a known root note, then try to parse the fragment, else dip-set.
|
// if our fragment starts with a known root note, then try to parse the fragment, else dip-set.
|
||||||
switch spl[0] {
|
switch spl[0] {
|
||||||
case "C", "D", "E", "F", "G", "A", "B":
|
case "C", "D", "E", "F", "G", "A", "B":
|
||||||
break
|
if len(spl) < 2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var found = false
|
||||||
|
for _, rgx := range mustMatchOne {
|
||||||
|
if rgx.MatchString(opiece) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user