Update to Go 1.20
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
2547c66dea
commit
514a88aec1
18
.drone.yml
18
.drone.yml
|
@ -22,7 +22,7 @@ steps:
|
|||
- mkdir -p resources/samples/
|
||||
- cp -rvf /samples/* resources/samples/
|
||||
- name: test-repo-cgo-full
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
depends_on:
|
||||
- music-samples
|
||||
commands:
|
||||
|
@ -78,7 +78,7 @@ steps:
|
|||
- git clone --depth 1 --branch master https://github.com/mstorsjo/fdk-aac.git && cd fdk-aac && ./autogen.sh && ./configure --prefix /drone/src/build_deps && make -j$(nproc) && make install && cd ..
|
||||
- git clone --depth 1 --branch master https://git.gammaspectra.live/S.O.N.G/alac.git && cd alac && autoreconf -fi && ./configure --prefix /drone/src/build_deps && make && make install && cd ..
|
||||
- name: test-cgo-full
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
depends_on:
|
||||
- music-samples
|
||||
- build-sources
|
||||
|
@ -87,7 +87,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v ./...
|
||||
- name: test-cgo-disable-codecs
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
depends_on:
|
||||
- music-samples
|
||||
- build-sources
|
||||
|
@ -96,7 +96,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v -tags=disable_codec_libfdk_aac,disable_codec_lame,disable_codec_tta,disable_codec_libflac,disable_codec_libvorbis ./...
|
||||
- name: test-cgo-disable-formats
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /drone/src/build_deps
|
||||
|
@ -108,7 +108,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v -tags=disable_format_aac,disable_format_alac,disable_format_mp3,disable_format_opus,disable_format_tta,disable_format_vorbis ./...
|
||||
- name: test-nocgo
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
depends_on:
|
||||
- music-samples
|
||||
commands:
|
||||
|
@ -165,7 +165,7 @@ steps:
|
|||
- git clone --depth 1 --branch master https://github.com/mstorsjo/fdk-aac.git && cd fdk-aac && ./autogen.sh && ./configure --prefix /drone/src/build_deps && make -j$(nproc) && make install && cd ..
|
||||
- git clone --depth 1 --branch master https://git.gammaspectra.live/S.O.N.G/alac.git && cd alac && autoreconf -fi && ./configure --prefix /drone/src/build_deps && make && make install && cd ..
|
||||
- name: test-cgo-full
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /drone/src/build_deps
|
||||
|
@ -177,7 +177,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v ./...
|
||||
- name: test-cgo-disable-codecs
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /drone/src/build_deps
|
||||
|
@ -189,7 +189,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v -tags=disable_codec_libfdk_aac,disable_codec_lame,disable_codec_tta,disable_codec_libflac,disable_codec_libvorbis ./...
|
||||
- name: test-cgo-disable-formats
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /drone/src/build_deps
|
||||
|
@ -201,7 +201,7 @@ steps:
|
|||
- apk add --no-cache git gcc musl-dev pkgconfig
|
||||
- go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -v -tags=disable_format_aac,disable_format_alac,disable_format_mp3,disable_format_opus,disable_format_tta,disable_format_vorbis ./...
|
||||
- name: test-nocgo
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
depends_on:
|
||||
- music-samples
|
||||
commands:
|
||||
|
|
|
@ -69,7 +69,7 @@ Several audio Analyzer hashers are implemented. List of current ones:
|
|||
|
||||
|
||||
## Dependencies
|
||||
### Go >= 1.19
|
||||
### Go >= 1.20
|
||||
|
||||
### [libFLAC](https://gitlab.xiph.org/xiph/flac) (required by [goflac](https://git.gammaspectra.live/S.O.N.G/goflac))
|
||||
```shell
|
||||
|
|
|
@ -79,7 +79,7 @@ func tryDecodeFrame(decoder *fdkaac.AacDecoder) ([]int16, error) {
|
|||
|
||||
if pcm != nil {
|
||||
defer runtime.KeepAlive(pcm)
|
||||
return slices.Clone(unsafe.Slice((*int16)(unsafe.Pointer(&pcm[0])), len(pcm)/2)), nil
|
||||
return slices.Clone(unsafe.Slice((*int16)(unsafe.Pointer(unsafe.SliceData(pcm))), len(pcm)/2)), nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
@ -339,7 +339,7 @@ func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[s
|
|||
|
||||
for len(tempBuffer) >= frameSize {
|
||||
sl := tempBuffer[:frameSize]
|
||||
frameBuffer, err := encoder.Encode(unsafe.Slice((*byte)(unsafe.Pointer(&sl[0])), len(sl)*2))
|
||||
frameBuffer, err := encoder.Encode(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(sl))), len(sl)*2))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -365,7 +365,7 @@ func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[s
|
|||
if len(buffer) > 0 {
|
||||
//pad
|
||||
buffer = append(buffer, make([]int16, frameSize-len(buffer))...)
|
||||
frameBuffer, err := encoder.Encode(unsafe.Slice((*byte)(unsafe.Pointer(&buffer[0])), len(buffer)*2))
|
||||
frameBuffer, err := encoder.Encode(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(buffer))), len(buffer)*2))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -108,24 +108,24 @@ func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[s
|
|||
switch bitsPerSample {
|
||||
case 32:
|
||||
for block := range source.ToInt32(32).GetBlocks() {
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(&block[0])), len(block)*4))
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(block))), len(block)*4))
|
||||
runtime.KeepAlive(block)
|
||||
}
|
||||
case 24:
|
||||
for block := range source.ToInt32(24).GetBlocks() {
|
||||
samples := vector.Int32ToBytes(block, 24)
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(&samples[0])), len(samples)))
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(samples))), len(samples)))
|
||||
runtime.KeepAlive(samples)
|
||||
}
|
||||
case 16:
|
||||
for block := range source.ToInt16().GetBlocks() {
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(&block[0])), len(block)*2))
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(block))), len(block)*2))
|
||||
runtime.KeepAlive(block)
|
||||
}
|
||||
case 8:
|
||||
for block := range source.ToInt32(8).GetBlocks() {
|
||||
samples := vector.Int32ToBytes(block, 8)
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(&samples[0])), len(samples)))
|
||||
encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(samples))), len(samples)))
|
||||
runtime.KeepAlive(samples)
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -43,7 +43,7 @@ func NewAnalyzerChannel(source audio.Source, err error) (audio.Source, AnalyzerC
|
|||
for block := range float32Source.GetBlocks() {
|
||||
//Convert float32 to int32 representation with 32 bit depth, so it hashes the same way
|
||||
buf := make([]int32, len(block))
|
||||
copy(buf, unsafe.Slice((*int32)(unsafe.Pointer(&block[0])), len(block)))
|
||||
copy(buf, unsafe.Slice((*int32)(unsafe.Pointer(unsafe.SliceData(block))), len(block)))
|
||||
runtime.KeepAlive(block)
|
||||
channel <- &AnalyzerPacket{
|
||||
Samples: buf,
|
||||
|
|
|
@ -122,7 +122,7 @@ func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[s
|
|||
}
|
||||
|
||||
for block := range source.ToInt16().GetBlocks() {
|
||||
_, err := encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(&block[0])), len(block)*2))
|
||||
_, err := encoder.Write(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(block))), len(block)*2))
|
||||
runtime.KeepAlive(block)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -150,24 +150,24 @@ func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[s
|
|||
switch bitsPerSample {
|
||||
case 32:
|
||||
for block := range source.ToInt32(32).GetBlocks() {
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(&block[0])), len(block)*4), nil)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(block))), len(block)*4), nil)
|
||||
runtime.KeepAlive(block)
|
||||
}
|
||||
case 24:
|
||||
for block := range source.ToInt32(24).GetBlocks() {
|
||||
samples := vector.Int32ToBytes(block, 24)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(&samples[0])), len(samples)), nil)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(samples))), len(samples)), nil)
|
||||
runtime.KeepAlive(samples)
|
||||
}
|
||||
case 16:
|
||||
for block := range source.ToInt16().GetBlocks() {
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(&block[0])), len(block)*2), nil)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(block))), len(block)*2), nil)
|
||||
runtime.KeepAlive(block)
|
||||
}
|
||||
case 8:
|
||||
for block := range source.ToInt32(8).GetBlocks() {
|
||||
samples := vector.Int32ToBytes(block, 8)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(&samples[0])), len(samples)), nil)
|
||||
encoder.ProcessStream(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(samples))), len(samples)), nil)
|
||||
runtime.KeepAlive(samples)
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -7,14 +7,17 @@ package packetizer
|
|||
#include "flac_crc.h"
|
||||
*/
|
||||
import "C"
|
||||
import "runtime"
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func flacCrc8(data []byte) uint8 {
|
||||
defer runtime.KeepAlive(data)
|
||||
return uint8(C.flac_crc8((*C.uint8_t)(&data[0]), C.size_t(len(data))))
|
||||
return uint8(C.flac_crc8((*C.uint8_t)(unsafe.SliceData(data)), C.size_t(len(data))))
|
||||
}
|
||||
|
||||
func flacCrc16(data []byte) uint16 {
|
||||
defer runtime.KeepAlive(data)
|
||||
return uint16(C.flac_crc16((*C.uint8_t)(&data[0]), C.size_t(len(data))))
|
||||
return uint16(C.flac_crc16((*C.uint8_t)(unsafe.SliceData(data)), C.size_t(len(data))))
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ package packetizer
|
|||
#include "ogg_crc.h"
|
||||
*/
|
||||
import "C"
|
||||
import "runtime"
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func oggCrc32(p []byte) uint32 {
|
||||
defer runtime.KeepAlive(p)
|
||||
return uint32(C.ogg_crc32((*C.uint8_t)(&p[0]), C.size_t(len(p))))
|
||||
return uint32(C.ogg_crc32((*C.uint8_t)(unsafe.SliceData(p)), C.size_t(len(p))))
|
||||
}
|
||||
|
|
|
@ -107,19 +107,19 @@ func Ingest(s Source, buf interface{}, bitDepth int) error {
|
|||
nsamples := len(bufferSlice) / (bitDepth / 8)
|
||||
switch bitDepth {
|
||||
case 32:
|
||||
s.IngestInt32(slices.Clone(unsafe.Slice((*int32)(unsafe.Pointer(&bufferSlice[0])), nsamples)), bitDepth)
|
||||
s.IngestInt32(slices.Clone(unsafe.Slice((*int32)(unsafe.Pointer(unsafe.SliceData(bufferSlice))), nsamples)), bitDepth)
|
||||
runtime.KeepAlive(bufferSlice)
|
||||
return nil
|
||||
case 24:
|
||||
s.IngestInt24(unsafe.Slice((*byte)(unsafe.Pointer(&bufferSlice[0])), nsamples*3), bitDepth)
|
||||
s.IngestInt24(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(bufferSlice))), nsamples*3), bitDepth)
|
||||
runtime.KeepAlive(bufferSlice)
|
||||
return nil
|
||||
case 16:
|
||||
s.IngestInt16(slices.Clone(unsafe.Slice((*int16)(unsafe.Pointer(&bufferSlice[0])), nsamples)), bitDepth)
|
||||
s.IngestInt16(slices.Clone(unsafe.Slice((*int16)(unsafe.Pointer(unsafe.SliceData(bufferSlice))), nsamples)), bitDepth)
|
||||
runtime.KeepAlive(bufferSlice)
|
||||
return nil
|
||||
case 8:
|
||||
s.IngestInt8(unsafe.Slice((*int8)(unsafe.Pointer(&bufferSlice[0])), nsamples), bitDepth)
|
||||
s.IngestInt8(unsafe.Slice((*int8)(unsafe.Pointer(unsafe.SliceData(bufferSlice))), nsamples), bitDepth)
|
||||
runtime.KeepAlive(bufferSlice)
|
||||
return nil
|
||||
default:
|
||||
|
|
6
go.mod
6
go.mod
|
@ -1,6 +1,6 @@
|
|||
module git.gammaspectra.live/S.O.N.G/Kirika
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
git.gammaspectra.live/S.O.N.G/flacgo v0.0.0-20230303065636-594dc137ca25
|
||||
|
@ -14,13 +14,13 @@ require (
|
|||
git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20230128225810-b55589f8c12a
|
||||
git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20230128141646-872fc9482587
|
||||
git.gammaspectra.live/S.O.N.G/voaac-go v0.0.0-20221206094054-e088a49a96bc
|
||||
github.com/Eyevinn/mp4ff v0.34.0
|
||||
github.com/Eyevinn/mp4ff v0.34.1
|
||||
github.com/dh1tw/gosamplerate v0.1.2
|
||||
github.com/icza/bitio v1.1.0
|
||||
github.com/jfreymuth/oggvorbis v1.0.5
|
||||
github.com/sssgun/mp3 v0.0.0-20170810093403-85f2ec632081
|
||||
github.com/viert/go-lame v0.0.0-20201108052322-bb552596b11d
|
||||
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
8
go.sum
8
go.sum
|
@ -20,8 +20,8 @@ git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20230128141646-872fc9482587 h1:yCfo
|
|||
git.gammaspectra.live/S.O.N.G/minimp3 v0.0.0-20230128141646-872fc9482587/go.mod h1:B34pwapfc0f6be6rJYg37xDeFPPB0bSyH0+DYM1lyEE=
|
||||
git.gammaspectra.live/S.O.N.G/voaac-go v0.0.0-20221206094054-e088a49a96bc h1:57tqeyhK5ypviBHumVxdhiphsAX3nJXli6Ni/1+6Jn4=
|
||||
git.gammaspectra.live/S.O.N.G/voaac-go v0.0.0-20221206094054-e088a49a96bc/go.mod h1:y8tX6ZPpGKVO2uso29/q5XW4r8/lTc5QRjPOwDRVMNk=
|
||||
github.com/Eyevinn/mp4ff v0.34.0 h1:C1gywvo5bweBA8fzRl9XpCWBKfiLJXzduG78XkuLiXk=
|
||||
github.com/Eyevinn/mp4ff v0.34.0/go.mod h1:w/6GSa5ghZ1VavzJK6McQ2/flx8mKtcrKDr11SsEweA=
|
||||
github.com/Eyevinn/mp4ff v0.34.1 h1:Jq3gSKjVTt9sajHv1AGEqcdHbG/6y952xGQ2XWLWzc8=
|
||||
github.com/Eyevinn/mp4ff v0.34.1/go.mod h1:w/6GSa5ghZ1VavzJK6McQ2/flx8mKtcrKDr11SsEweA=
|
||||
github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64 h1:LjPYdzoFSAJ5Tr/ElL8kzTJghXgpnOjJVbgd1UvZB1o=
|
||||
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=
|
||||
|
@ -49,8 +49,8 @@ github.com/viert/go-lame v0.0.0-20201108052322-bb552596b11d/go.mod h1:EqTcYM7y4J
|
|||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI=
|
||||
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
|
|
|
@ -30,7 +30,7 @@ func (d *accurateRipDigestV1) Sum(in []byte) []byte {
|
|||
|
||||
func (d *accurateRipDigestV1) Write(p []byte) (n int, err error) {
|
||||
numWords := uintptr(len(p)) * unsafe.Sizeof(p[0]) / unsafe.Sizeof(uint32(0))
|
||||
words := unsafe.Slice((*uint32)(unsafe.Pointer(&p[0])), numWords)
|
||||
words := unsafe.Slice((*uint32)(unsafe.Pointer(unsafe.SliceData(p))), numWords)
|
||||
|
||||
for _, w := range words {
|
||||
//this can wrap
|
||||
|
@ -66,7 +66,7 @@ func (d *accurateRipDigestV2) Sum(in []byte) []byte {
|
|||
|
||||
func (d *accurateRipDigestV2) Write(p []byte) (n int, err error) {
|
||||
numWords := uintptr(len(p)) * unsafe.Sizeof(p[0]) / unsafe.Sizeof(uint32(0))
|
||||
words := unsafe.Slice((*uint32)(unsafe.Pointer(&p[0])), numWords)
|
||||
words := unsafe.Slice((*uint32)(unsafe.Pointer(unsafe.SliceData(p))), numWords)
|
||||
|
||||
for _, w := range words {
|
||||
crcNew := uint64(w) * uint64(d.multiplier)
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
// MultipleChannelsToMonoFloat32 bring any number of channels to mono, equally weighted
|
||||
func MultipleChannelsToMonoFloat32(buffer []float32, channels int) (buf []float32) {
|
||||
buf = make([]float32, len(buffer)/channels)
|
||||
C.audio_multiple_channels_to_mono((*C.float)(&buffer[0]), C.size_t(len(buffer)), (*C.float)(&buf[0]), C.int(channels))
|
||||
C.audio_multiple_channels_to_mono((*C.float)(unsafe.SliceData(buffer)), C.size_t(len(buffer)), (*C.float)(unsafe.SliceData(buf)), C.int(channels))
|
||||
runtime.KeepAlive(buffer)
|
||||
return
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func MultipleChannelsToMonoFloat32(buffer []float32, channels int) (buf []float3
|
|||
// MultipleChannelsToStereoFloat32 bring any number of channels to stereo, using downmix formulas when necessary
|
||||
func MultipleChannelsToStereoFloat32(buffer []float32, channels int) (buf []float32) {
|
||||
buf = make([]float32, (len(buffer)/channels)*2)
|
||||
C.audio_multiple_channels_to_stereo((*C.float)(&buffer[0]), C.size_t(len(buffer)), (*C.float)(&buf[0]), C.int(channels))
|
||||
C.audio_multiple_channels_to_stereo((*C.float)(unsafe.SliceData(buffer)), C.size_t(len(buffer)), (*C.float)(unsafe.SliceData(buf)), C.int(channels))
|
||||
runtime.KeepAlive(buffer)
|
||||
return
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func MultipleChannelsToStereoFloat32(buffer []float32, channels int) (buf []floa
|
|||
// MultipleChannelsToMonoInt32 bring any number of channels to mono, equally weighted
|
||||
func MultipleChannelsToMonoInt32(buffer []int32, channels int) (buf []int32) {
|
||||
buf = make([]int32, len(buffer)/channels)
|
||||
C.audio_multiple_channels_to_mono_int32((*C.int32_t)(&buffer[0]), C.size_t(len(buffer)), (*C.int32_t)(&buf[0]), C.int(channels))
|
||||
C.audio_multiple_channels_to_mono_int32((*C.int32_t)(unsafe.SliceData(buffer)), C.size_t(len(buffer)), (*C.int32_t)(unsafe.SliceData(buf)), C.int(channels))
|
||||
runtime.KeepAlive(buffer)
|
||||
return
|
||||
}
|
||||
|
@ -39,42 +39,42 @@ func MultipleChannelsToMonoInt32(buffer []int32, channels int) (buf []int32) {
|
|||
// MultipleChannelsToStereoInt32 bring any number of channels to stereo, using downmix formulas when necessary
|
||||
func MultipleChannelsToStereoInt32(buffer []int32, channels int) (buf []int32) {
|
||||
buf = make([]int32, (len(buffer)/channels)*2)
|
||||
C.audio_multiple_channels_to_stereo_int32((*C.int32_t)(&buffer[0]), C.size_t(len(buffer)), (*C.int32_t)(&buf[0]), C.int(channels))
|
||||
C.audio_multiple_channels_to_stereo_int32((*C.int32_t)(unsafe.SliceData(buffer)), C.size_t(len(buffer)), (*C.int32_t)(unsafe.SliceData(buf)), C.int(channels))
|
||||
runtime.KeepAlive(buffer)
|
||||
return
|
||||
}
|
||||
|
||||
func Int32ToInt16(data []int32, bitDepth int) (buf []int16) {
|
||||
buf = make([]int16, len(data))
|
||||
C.audio_int32_to_int16((*C.int32_t)(&data[0]), C.size_t(len(data)), (*C.int16_t)(unsafe.Pointer(&buf[0])), C.int(bitDepth))
|
||||
C.audio_int32_to_int16((*C.int32_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int16_t)(unsafe.Pointer(unsafe.SliceData(buf))), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Int16ToInt32(data []int32, bitDepth int) (buf []int16) {
|
||||
buf = make([]int16, len(data))
|
||||
C.audio_int32_to_int16((*C.int32_t)(&data[0]), C.size_t(len(data)), (*C.int16_t)(unsafe.Pointer(&buf[0])), C.int(bitDepth))
|
||||
C.audio_int32_to_int16((*C.int32_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int16_t)(unsafe.Pointer(unsafe.SliceData(buf))), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Int32ToBytes(data []int32, bitDepth int) (buf []byte) {
|
||||
buf = make([]byte, len(data)*(bitDepth/8))
|
||||
C.audio_int32_to_bytes((*C.int32_t)(&data[0]), C.size_t(len(data)), (*C.int8_t)(unsafe.Pointer(&buf[0])), C.int(bitDepth))
|
||||
C.audio_int32_to_bytes((*C.int32_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int8_t)(unsafe.Pointer(unsafe.SliceData(buf))), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func BytesToInt32(data []byte, bitDepth int) (buf []int32) {
|
||||
buf = make([]int32, len(data)/(bitDepth/8))
|
||||
C.audio_bytes_to_int32((*C.int8_t)(unsafe.Pointer(&data[0])), C.size_t(len(data)), (*C.int32_t)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_bytes_to_int32((*C.int8_t)(unsafe.Pointer(unsafe.SliceData(data))), C.size_t(len(data)), (*C.int32_t)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Int32ToFloat32(data []int32, bitDepth int) (buf []float32) {
|
||||
buf = make([]float32, len(data))
|
||||
C.audio_int32_to_float32((*C.int32_t)(&data[0]), C.size_t(len(data)), (*C.float)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_int32_to_float32((*C.int32_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.float)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
@ -82,49 +82,49 @@ func Int32ToFloat32(data []int32, bitDepth int) (buf []float32) {
|
|||
// Int24ToFloat32 special case
|
||||
func Int24ToFloat32(data []byte, bitDepth int) (buf []float32) {
|
||||
buf = make([]float32, len(data)/3)
|
||||
C.audio_int24_to_float32((*C.int8_t)(unsafe.Pointer(&data[0])), C.size_t(len(data)), (*C.float)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_int24_to_float32((*C.int8_t)(unsafe.Pointer(unsafe.SliceData(data))), C.size_t(len(data)), (*C.float)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Int16ToFloat32(data []int16, bitDepth int) (buf []float32) {
|
||||
buf = make([]float32, len(data))
|
||||
C.audio_int16_to_float32((*C.int16_t)(&data[0]), C.size_t(len(data)), (*C.float)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_int16_to_float32((*C.int16_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.float)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Int8ToFloat32(data []int8, bitDepth int) (buf []float32) {
|
||||
buf = make([]float32, len(data))
|
||||
C.audio_int8_to_float32((*C.int8_t)(&data[0]), C.size_t(len(data)), (*C.float)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_int8_to_float32((*C.int8_t)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.float)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Float32ToInt32(data []float32, bitDepth int) (buf []int32) {
|
||||
buf = make([]int32, len(data))
|
||||
C.audio_float32_to_int32((*C.float)(&data[0]), C.size_t(len(data)), (*C.int32_t)(&buf[0]), C.int(bitDepth))
|
||||
C.audio_float32_to_int32((*C.float)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int32_t)(unsafe.SliceData(buf)), C.int(bitDepth))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Float32ToInt24(data []float32) (buf []byte) {
|
||||
buf = make([]byte, len(data)*3)
|
||||
C.audio_float32_to_int24((*C.float)(&data[0]), C.size_t(len(data)), (*C.int8_t)(unsafe.Pointer(&buf[0])))
|
||||
C.audio_float32_to_int24((*C.float)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int8_t)(unsafe.Pointer(unsafe.SliceData(buf))))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Float32ToInt16(data []float32) (buf []int16) {
|
||||
buf = make([]int16, len(data))
|
||||
C.audio_float32_to_int16((*C.float)(&data[0]), C.size_t(len(data)), (*C.int16_t)(&buf[0]))
|
||||
C.audio_float32_to_int16((*C.float)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int16_t)(unsafe.SliceData(buf)))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
||||
func Float32ToInt8(data []float32) (buf []int8) {
|
||||
buf = make([]int8, len(data))
|
||||
C.audio_float32_to_int8((*C.float)(&data[0]), C.size_t(len(data)), (*C.int8_t)(&buf[0]))
|
||||
C.audio_float32_to_int8((*C.float)(unsafe.SliceData(data)), C.size_t(len(data)), (*C.int8_t)(unsafe.SliceData(buf)))
|
||||
runtime.KeepAlive(data)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ func Int32ToBytes(data []int32, bitDepth int) (buf []byte) {
|
|||
}
|
||||
break
|
||||
case 32:
|
||||
buf = slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(&data[0])), len(data)*4))
|
||||
buf = slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(data))), len(data)*4))
|
||||
runtime.KeepAlive(data)
|
||||
break
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ func BytesToInt32(data []byte, bitDepth int) (buf []int32) {
|
|||
}
|
||||
break
|
||||
case 32:
|
||||
buf = slices.Clone(unsafe.Slice((*int32)(unsafe.Pointer(&data[0])), len(data)/4))
|
||||
buf = slices.Clone(unsafe.Slice((*int32)(unsafe.Pointer(unsafe.SliceData(data))), len(data)/4))
|
||||
runtime.KeepAlive(data)
|
||||
break
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ import (
|
|||
|
||||
func Int8ToBytes(data []int8) (buf []byte) {
|
||||
defer runtime.KeepAlive(data)
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(&data[0])), len(data)))
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(data))), len(data)))
|
||||
}
|
||||
|
||||
func Int16ToBytes(data []int16) (buf []byte) {
|
||||
defer runtime.KeepAlive(data)
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(&data[0])), len(data)*2))
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(data))), len(data)*2))
|
||||
}
|
||||
|
||||
func Float32ToBytes(data []float32) (buf []byte) {
|
||||
defer runtime.KeepAlive(data)
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(&data[0])), len(data)*4))
|
||||
return slices.Clone(unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(data))), len(data)*4))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue