Reduce pointer allocation, update dependencies

This commit is contained in:
DataHoarder 2022-11-09 22:07:50 +01:00
parent d1a52c7bd5
commit 302a06defa
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
6 changed files with 64 additions and 64 deletions

View file

@ -15,7 +15,7 @@ import (
"testing"
)
func runTest(t *testing.T, wg, wgQuery *sync.WaitGroup, strategy *panako.Strategy, resourceId int64, fileName string, callback func(prints []*panako.Fingerprint, queryResults []panako.QueryResult)) {
func runTest(t *testing.T, wg, wgQuery *sync.WaitGroup, strategy *panako.Strategy, resourceId int64, fileName string, callback func(prints []panako.Fingerprint, queryResults []panako.QueryResult)) {
wg.Add(1)
go func() {
var source audio.Source
@ -72,13 +72,13 @@ func TestHibiki(t *testing.T) {
var wg sync.WaitGroup
var wgQuery sync.WaitGroup
runTest(t, &wg, &wgQuery, strategy, 1, "test.flac", func(prints []*panako.Fingerprint, queryResults []panako.QueryResult) {
runTest(t, &wg, &wgQuery, strategy, 1, "test.flac", func(prints []panako.Fingerprint, queryResults []panako.QueryResult) {
for _, result := range queryResults {
log.Printf("result 1 %#v\n", result)
}
})
runTest(t, &wg, &wgQuery, strategy, 0, "test2.flac", func(prints []*panako.Fingerprint, queryResults []panako.QueryResult) {
runTest(t, &wg, &wgQuery, strategy, 0, "test2.flac", func(prints []panako.Fingerprint, queryResults []panako.QueryResult) {
for _, result := range queryResults {
log.Printf("result 2 %#v\n", result)
}
@ -97,19 +97,19 @@ func TestHibiki(t *testing.T) {
log.Printf("print: %x\n", printBuffer.Bytes())
})
runTest(t, &wg, &wgQuery, strategy, 0, "test_radio.flac", func(prints []*panako.Fingerprint, queryResults []panako.QueryResult) {
runTest(t, &wg, &wgQuery, strategy, 0, "test_radio.flac", func(prints []panako.Fingerprint, queryResults []panako.QueryResult) {
for _, result := range queryResults {
log.Printf("result 3 %#v\n", result)
}
})
runTest(t, &wg, &wgQuery, strategy, 0, "negative.flac", func(prints []*panako.Fingerprint, queryResults []panako.QueryResult) {
runTest(t, &wg, &wgQuery, strategy, 0, "negative.flac", func(prints []panako.Fingerprint, queryResults []panako.QueryResult) {
for _, result := range queryResults {
log.Printf("result 4 %#v\n", result)
}
})
runTest(t, &wg, &wgQuery, strategy, 0, "test.mp3", func(prints []*panako.Fingerprint, queryResults []panako.QueryResult) {
runTest(t, &wg, &wgQuery, strategy, 0, "test.mp3", func(prints []panako.Fingerprint, queryResults []panako.QueryResult) {
for _, result := range queryResults {
log.Printf("result 5 %#v\n", result)
}

20
go.mod
View file

@ -3,30 +3,32 @@ module git.gammaspectra.live/S.O.N.G/Hibiki
go 1.18
require (
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220722190929-1d2effea751e
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20220713201545-e92f79a950b7
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221107131937-f56867ca7386
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20221109205443-029e2fe61911
github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64
)
require (
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20220726151057-28f458bc5391 // indirect
git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f // indirect
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61 // indirect
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220910135048-823922bd661a // indirect
git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220721130634-3d5460c48ab6 // indirect
git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 // indirect
git.gammaspectra.live/S.O.N.G/go-vorbis v0.0.0-20220728124510-303b3425eec0 // indirect
git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0 // indirect
git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20221029081019-2dbf75f65b35 // indirect
github.com/aam335/aac-go v0.0.0-20200408070016-52c23bd38988 // indirect
github.com/dh1tw/gosamplerate v0.1.2 // indirect
github.com/edgeware/mp4ff v0.29.0 // indirect
github.com/hajimehoshi/go-mp3 v0.3.3 // indirect
github.com/edgeware/mp4ff v0.30.1 // indirect
github.com/hajimehoshi/go-mp3 v0.3.4 // indirect
github.com/icza/bitio v1.1.0 // indirect
github.com/jfreymuth/oggvorbis v1.0.3 // indirect
github.com/jfreymuth/oggvorbis v1.0.4 // indirect
github.com/jfreymuth/vorbis v1.0.2 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/kvark128/minimp3 v0.0.0-20220408223524-dd428325fce7 // indirect
github.com/mewkiz/flac v1.0.7 // indirect
github.com/mewkiz/pkg v0.0.0-20211102230744-16a6ce8f1b77 // indirect
github.com/mewkiz/pkg v0.0.0-20220820102221-bbbca16e2a6c // indirect
github.com/oov/audio v0.0.0-20171004131523-88a2be6dbe38 // indirect
github.com/viert/go-lame v0.0.0-20201108052322-bb552596b11d // indirect
github.com/youpy/go-riff v0.1.0 // indirect
github.com/zaf/g711 v0.0.0-20220109202201-cf0017bf0359 // indirect
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5 // indirect
)

53
go.sum
View file

@ -1,17 +1,23 @@
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220722190929-1d2effea751e h1:8GIQIKs6JHd/oRUoTM6yZVoANahWoIW2618/QcU0e20=
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220722190929-1d2effea751e/go.mod h1:9ROkNM8G6YhteSgDY5cd8vFr69LhFc9n+fZYaM2WBcM=
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221107131937-f56867ca7386 h1:xcUzR0mQlR8XJQRGhg4m2WV/vu7yk0C4Vva9ozNS058=
git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20221107131937-f56867ca7386/go.mod h1:74/fJ3aKEmFkHuPwL5TvvP/VLTjYy0kimpx6b4VLUgs=
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20220726151057-28f458bc5391 h1:us3yKKsnMe0FZVHRSFZCw113ddiNrZgKf5M5PNr3SQ4=
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20220726151057-28f458bc5391/go.mod h1:ZVHB/7Vrs9xxK1j98+SJ5TRYBc7Q9dIUaNJHEmysZcI=
git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f h1:CxN7zlk5FdAieyRKQSbwBGBsvQ2cDF8JVCODZpzcRkA=
git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f/go.mod h1:f1+h7KOnuM9zcEQp7ri4UaVvgX4m1NFFIXgReIyjGMA=
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61 h1:YufhSTCS59H5CStqokGMb60RnSsqrp+GoZvzmC29wm4=
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61/go.mod h1:pkWt//S9hLVEQaJDPu/cHHPk8vPpo/0+zHy0me4LIP4=
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220910135048-823922bd661a h1:JQaryqLtNZn1jydhVc7CzcAvO8ZNB4jeZ1B5gJbHWUU=
git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220910135048-823922bd661a/go.mod h1:pkWt//S9hLVEQaJDPu/cHHPk8vPpo/0+zHy0me4LIP4=
git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220721130634-3d5460c48ab6 h1:xWv02pzrOrQDtNGgcjDw9ZZvJCAuxLbZ6+h5QVVyqvk=
git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220721130634-3d5460c48ab6/go.mod h1:vkoHSHVM9p6vAUmXAik0gvaLcIfiQYrD6bQqVpOulUk=
git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 h1:ITVVisbHPnUclp3PBkCbXFeBhOCBcOjPdgjJ9wRH3TI=
git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6/go.mod h1:cobkT8u8vq/+ngLy+feKS2M2ZT2HoCec5riA/0Cex3Q=
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20220713201545-e92f79a950b7 h1:eArmPzjU8Mf0f44mqhzeOcpK1OsnARikYymctgU3Ukw=
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20220713201545-e92f79a950b7/go.mod h1:1Z/lAswjpOdysSp/lABpASPPuaaBFIK8L5Fu1SwO37E=
git.gammaspectra.live/S.O.N.G/go-vorbis v0.0.0-20220728124510-303b3425eec0 h1:kZA/fy9BhBgNGjY8OlQbIR4xkq9fmIeRQ+sXZ+m9Ic4=
git.gammaspectra.live/S.O.N.G/go-vorbis v0.0.0-20220728124510-303b3425eec0/go.mod h1:EZl7z0vfpaiu0ykpEkk6dh59XxBgWxAh4QPCCnkhICE=
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20221109205443-029e2fe61911 h1:bJPOGX/H7rbGynuHvxjutnjhG1mTen+nipNt3WHl/L0=
git.gammaspectra.live/S.O.N.G/goborator v0.0.0-20221109205443-029e2fe61911/go.mod h1:1Z/lAswjpOdysSp/lABpASPPuaaBFIK8L5Fu1SwO37E=
git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0 h1:imcnwHUqaAJzws41B8sCSp/sUmVranNjAX205Jr4Jc0=
git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0/go.mod h1:/po1QgOh3xynbvi4sxdY6Iw8m5WPJfGGmry2boZD8fs=
git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20221029081019-2dbf75f65b35 h1:CuJroJbfRxrXtT2+sAOO3EYuOiC0XcF9Nzo/GUOD0PM=
git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20221029081019-2dbf75f65b35/go.mod h1:B34pwapfc0f6be6rJYg37xDeFPPB0bSyH0+DYM1lyEE=
github.com/aam335/aac-go v0.0.0-20200408070016-52c23bd38988 h1:DZeJTINv0mpfBVfDtQz9vWOn/Uwj3IiA9uP5UJnClZE=
github.com/aam335/aac-go v0.0.0-20200408070016-52c23bd38988/go.mod h1:JBA06GZmW2MVVBYRrKuaZ2AFMSDiPmafb/qmF/ATTUM=
github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64 h1:LjPYdzoFSAJ5Tr/ElL8kzTJghXgpnOjJVbgd1UvZB1o=
@ -19,35 +25,26 @@ github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64/go.mod h1:LoCAz
github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
github.com/dh1tw/gosamplerate v0.1.2 h1:oyqtZk67xB9B4l+vIZCZ3F0RYV/z66W58VOah11/ktI=
github.com/dh1tw/gosamplerate v0.1.2/go.mod h1:zooTyHpoR7hE+FLfdE3yjLHb2QA2NpMusNfuaZqEACM=
github.com/edgeware/mp4ff v0.29.0 h1:wRW0ng0+inNGTpy7vCcSHQ7h/V71cQYnnM6woeQCHbw=
github.com/edgeware/mp4ff v0.29.0/go.mod h1:GNUeA6tEFksH2CrjJF2FSGdJolba8yPGmo16qZTXsm8=
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
github.com/edgeware/mp4ff v0.30.1 h1:OV88fQrw8sFPjTCFThsBwubjYPHTdHgb28pSd1y9ozk=
github.com/edgeware/mp4ff v0.30.1/go.mod h1:GNUeA6tEFksH2CrjJF2FSGdJolba8yPGmo16qZTXsm8=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/hajimehoshi/go-mp3 v0.3.3 h1:cWnfRdpye2m9ElSoVqneYRcpt/l3ijttgjMeQh+r+FE=
github.com/hajimehoshi/go-mp3 v0.3.3/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
github.com/icza/bitio v1.1.0 h1:ysX4vtldjdi3Ygai5m1cWy4oLkhWTAi+SyO6HC8L9T0=
github.com/icza/bitio v1.1.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
github.com/jfreymuth/oggvorbis v1.0.3 h1:MLNGGyhOMiVcvea9Dp5+gbs2SAwqwQbtrWnonYa0M0Y=
github.com/jfreymuth/oggvorbis v1.0.3/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
github.com/jfreymuth/oggvorbis v1.0.4 h1:cyJCd0XSoxkKzUPmqM0ZoQJ0h/WbhfyvUR+FTMxQEac=
github.com/jfreymuth/oggvorbis v1.0.4/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE=
github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ=
github.com/jszwec/csvutil v1.5.1/go.mod h1:Rpu7Uu9giO9subDyMCIQfHVDuLrcaC36UA4YcJjGBkg=
github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=
github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4=
github.com/kvark128/minimp3 v0.0.0-20220408223524-dd428325fce7 h1:N9WLIYcr2SEk+bmAMY7gVF7ElF1ZmFaQjJ4bJcSJLxU=
github.com/kvark128/minimp3 v0.0.0-20220408223524-dd428325fce7/go.mod h1:hIq9nAqNcwTySvnFhCe1C8xC/STIr2Fe5vJ52zk1jkE=
github.com/mewkiz/flac v1.0.7 h1:uIXEjnuXqdRaZttmSFM5v5Ukp4U6orrZsnYGGR3yow8=
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2/go.mod h1:3E2FUC/qYUfM8+r9zAwpeHJzqRVVMIYnpzD/clwWxyA=
github.com/mewkiz/pkg v0.0.0-20211102230744-16a6ce8f1b77 h1:DDyKVkTkrFmd9lR84QW3EIfkkoHlurlpgW+DYuAUJn8=
github.com/mewkiz/pkg v0.0.0-20211102230744-16a6ce8f1b77/go.mod h1:J/rDzvIiwiVpv72OEP8aJFxLXjGpUdviIIeqJPLIctA=
github.com/mewkiz/pkg v0.0.0-20220820102221-bbbca16e2a6c h1:6AzCfQNCql3Of8ee1JY6dufssFnBWJYuCVrGcES84AA=
github.com/mewkiz/pkg v0.0.0-20220820102221-bbbca16e2a6c/go.mod h1:J/rDzvIiwiVpv72OEP8aJFxLXjGpUdviIIeqJPLIctA=
github.com/oov/audio v0.0.0-20171004131523-88a2be6dbe38 h1:4Upfs5rLQdx7KwBct3bmPYAhWsDDJdx660gYb7Lv9TQ=
github.com/oov/audio v0.0.0-20171004131523-88a2be6dbe38/go.mod h1:Xj06yMta9R1RSKiHmxL0Bo2TB8wiKVnMgA0KVopHHkk=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@ -58,11 +55,9 @@ github.com/youpy/go-riff v0.1.0/go.mod h1:83nxdDV4Z9RzrTut9losK7ve4hUnxUR8ASSz4B
github.com/youpy/go-wav v0.3.2 h1:NLM8L/7yZ0Bntadw/0h95OyUsen+DQIVf9gay+SUsMU=
github.com/zaf/g711 v0.0.0-20220109202201-cf0017bf0359 h1:P9yeMx2iNJxJqXEwLtMjSwWcD2a0AlFmFByeosMZhLM=
github.com/zaf/g711 v0.0.0-20220109202201-cf0017bf0359/go.mod h1:ySLGJD8AQluMQuu5JDvfJrwsBra+8iX1jFsKS8KfB2I=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5 h1:pug8He0YPdPwDXZN4B/1sJ/8d4YsZqwVZEzg/Xi5w3Y=
golang.org/x/exp v0.0.0-20221109134031-9ce248df8de5/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View file

@ -13,7 +13,7 @@ import (
// by a time and frequency pair, both encoded with an integer. The frequency is defined by
// the bin index in the spectrogram. The time is defined as the index of the block processed.
type Fingerprint struct {
entries [3]*EventPoint
entries [3]EventPoint
hash uint64
modHash uint32
@ -32,15 +32,15 @@ const (
RobustHash
)
func NewFingerprint(p1, p2, p3 *EventPoint) *Fingerprint {
func NewFingerprint(p1, p2, p3 *EventPoint) Fingerprint {
if p2.DeltaTime(p1) < 0 {
log.Panicf("p2.Time < p1.Time : %d < %d", p2.Time, p1.Time)
}
if p3.DeltaTime(p2) < 0 {
log.Panicf("p3.Time < p2.Time : %d < %d", p3.Time, p2.Time)
}
return &Fingerprint{
entries: [3]*EventPoint{p1, p2, p3},
return Fingerprint{
entries: [3]EventPoint{*p1, *p2, *p3},
}
}

View file

@ -18,8 +18,8 @@ type EventPointProcessor struct {
previousMaxMagnitudes map[int][]float32
previousMagnitudes map[int][]float32
eventPoints []*EventPoint
fingerprints []*Fingerprint
eventPoints []EventPoint
fingerprints []Fingerprint
analysisFrameIndex int
maxFilterVertical *cgo.LemireMaxClampedFilter
@ -39,8 +39,8 @@ func NewEventPointProcessor(instance *Instance) (*EventPointProcessor, error) {
analysisFrameIndex: 0,
maxFilterWindowSizeFrequency: instance.PointFilterMaximumFrequencyFilterSize,
maxFilterWindowSizeTime: instance.PointFilterMaximumTimeFilterSize,
eventPoints: make([]*EventPoint, 0, 8196),
fingerprints: make([]*Fingerprint, 0, 8196),
eventPoints: make([]EventPoint, 0, 8196),
fingerprints: make([]Fingerprint, 0, 8196),
}
ob.gaborator = goborator.NewGaborator(
@ -77,11 +77,11 @@ func (e *EventPointProcessor) GetMagnitudes() []float32 {
return e.magnitudes[e.magnitudesIndex]
}
func (e *EventPointProcessor) GetFingerprints() []*Fingerprint {
func (e *EventPointProcessor) GetFingerprints() []Fingerprint {
return e.fingerprints
}
func (e *EventPointProcessor) GetEventPoints() []*EventPoint {
func (e *EventPointProcessor) GetEventPoints() []EventPoint {
return e.eventPoints
}
@ -141,7 +141,7 @@ func (e *EventPointProcessor) processResultChannel(allMagnitudes chan []float32)
frameMagnitudes[frequency+1] + prevFrameMagnitudes[frequency+1] + nextFrameMagnitudes[frequency+1] +
frameMagnitudes[frequency-1] + prevFrameMagnitudes[frequency-1] + nextFrameMagnitudes[frequency-1]
e.eventPoints = append(e.eventPoints, &EventPoint{
e.eventPoints = append(e.eventPoints, EventPoint{
Time: uint32(time),
Frequency: uint32(frequency),
Magnitude: totalMagnitude,
@ -193,10 +193,12 @@ func (e *EventPointProcessor) packEventPointsIntoFingerprints() {
minTimeDistance := int64(e.instance.PointFilterMinimumTimeDistance)
maxTimeDistance := int64(e.instance.PointFilterMaximumTimeDistance)
for i, p1 := range e.eventPoints {
for i := range e.eventPoints {
p1 := &e.eventPoints[i]
index2 := i + 1
for j, p2 := range e.eventPoints[index2:] {
for j := range e.eventPoints[index2:] {
p2 := &e.eventPoints[j]
fDiff := utilities.AbsInt64(int64(p1.Frequency) - int64(p2.Frequency))
tDiff := int64(p2.Time) - int64(p1.Time)
@ -216,7 +218,8 @@ func (e *EventPointProcessor) packEventPointsIntoFingerprints() {
}
index3 := index2 + j + 1
for _, p3 := range e.eventPoints[index3:] {
for k := range e.eventPoints[index3:] {
p3 := &e.eventPoints[k]
fDiff = utilities.AbsInt64(int64(p2.Frequency) - int64(p3.Frequency))
tDiff = int64(p3.Time) - int64(p2.Time)

View file

@ -63,11 +63,11 @@ func (s *Strategy) StoreSource(resourceId ResourceId, source audio.Source) time.
return 0
}
func (s *Strategy) SourceToFingerprints(source audio.Source) []*Fingerprint {
func (s *Strategy) SourceToFingerprints(source audio.Source) []Fingerprint {
return s.BlockChannelToFingerprints(filter.NewFilterChain(source, filter.MonoFilter{}, filter.NewResampleFilter(int(s.instance.SampleRate), s.resampleQuality, s.instance.BlockSize)).ToFloat32().GetBlocks())
}
func (s *Strategy) BlockChannelToFingerprints(channel chan []float32) []*Fingerprint {
func (s *Strategy) BlockChannelToFingerprints(channel chan []float32) []Fingerprint {
eventPointProcessor, err := s.instance.GetEventPointProcessor()
if err != nil {
log.Panic(err)
@ -77,13 +77,13 @@ func (s *Strategy) BlockChannelToFingerprints(channel chan []float32) []*Fingerp
return eventPointProcessor.GetFingerprints()
}
func (s *Strategy) QueryFingerprintsAsync(prints []*Fingerprint, callback func(queryResults []QueryResult)) {
func (s *Strategy) QueryFingerprintsAsync(prints []Fingerprint, callback func(queryResults []QueryResult)) {
go func() {
callback(s.QueryFingerprints(prints))
}()
}
func (s *Strategy) QueryFingerprints(prints []*Fingerprint) []QueryResult {
func (s *Strategy) QueryFingerprints(prints []Fingerprint) []QueryResult {
return s.QueryStoreRecords(getRecordsFromPrints(ResourceId(0), prints, s.instance.HashType))
}
func (s *Strategy) QueryStoreRecords(records []StoreRecord) (queryResults []QueryResult) {
@ -298,7 +298,7 @@ func mostCommonDeltaTforHitList(hitList []*MatchedRecord) int64 {
return mostCommonDeltaT
}
func getRecordsFromPrints(resourceId ResourceId, prints []*Fingerprint, hashType FingerprintHashType) []StoreRecord {
func getRecordsFromPrints(resourceId ResourceId, prints []Fingerprint, hashType FingerprintHashType) []StoreRecord {
records := make([]StoreRecord, 0, len(prints))
for _, p := range prints {
records = append(records, StoreRecord{
@ -311,6 +311,6 @@ func getRecordsFromPrints(resourceId ResourceId, prints []*Fingerprint, hashType
return records
}
func (s *Strategy) StoreFingerprints(resourceId ResourceId, prints []*Fingerprint) {
func (s *Strategy) StoreFingerprints(resourceId ResourceId, prints []Fingerprint) {
s.store.StorePanakoPrints(getRecordsFromPrints(resourceId, prints, s.instance.HashType))
}