libsox bindings for go

gosox

"SoX − Sound eXchange, the Swiss Army knife of audio manipulation"

Go bindings for the libsox sound library

Description

libsox is a library of sound sample file format readers/writers and sound effects processors. It is mainly developed for use by SoX but is useful for any sound application.

SoX reads and writes audio files in most popular formats and can optionally apply effects to them. It can combine multiple input sources, synthesise audio, and, on many systems, act as a general purpose audio player or a multi-track audio recorder. It also has limited ability to split the input into multiple output files.

Owner
Kristoffer Grönlund
I like making things. Mainly codes, noises, pixels and houses.
Kristoffer Grönlund
Comments
  • In-Memory operations issue

    In-Memory operations issue

    Hi. I'm trying to concatenate two .wav files and keep the result in memory only. I'm using Memstream and writing to it using OpenMemstreamWrite. The concatenation process follows example4 of this repo.

    When I write the result to a file for testing, it has the correct, increased file size, but the play duration remains at the length of the first file written into the stream.

    The same issue arises with any EffectsChain, that would usually change the duration of the audio.

    The reason seems to be the .wav header, that needs to be rewritten after finalising the concatenation or effects chain flow.

    Running "sox --ignore-length file.wav file_fixed.wav", fixes the file.

    Any idea how to work around this and get the header rewritten inside the Memstream without writing any files to disk?

    Thanks

  • Error when open many files

    Error when open many files

    
    
    func ExtractorSoxFaster(filename string) (map[string]string, error) {
    
    	if !sox.Init() {
    		return nil, errors.New("Failed to initialize SoX")
    	}
    	defer sox.Quit()
    
    	in := sox.OpenRead(filename) //error here 
    	if in == nil {
    		return nil, errors.New("Failed to open input file")
    	}
    	defer in.Release()
    
    // more here...
    }
    
    
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x7fbe145f6900 pc=0x7fbe145f6900]
    
    runtime stack:
    runtime.throw(0x8d0ecf, 0x2a)
    	/usr/local/go/src/runtime/panic.go:596 +0x95
    runtime.sigpanic()
    	/usr/local/go/src/runtime/signal_unix.go:274 +0x2db
    
    goroutine 89 [syscall, locked to thread]:
    runtime.cgocall(0x7d9610, 0xc420159450, 0x1)
    	/usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc420159420 sp=0xc4201593e0
    app.com/utils/vendor/github.com/krig/go-sox._Cfunc_sox_open_read(0x7fbdf80059b0, 0x0, 0x0, 0x0, 0x0)
    	app.com/utils/vendor/github.com/krig/go-sox/_obj/_cgo_gotypes.go:791 +0x4e fp=0xc420159450 sp=0xc420159420
    app.com/utils/vendor/github.com/krig/go-sox.OpenRead(0xc420281680, 0x32, 0x8bf4f3)
    	/srv/go/src/app.com/utils/vendor/github.com/krig/go-sox/sox.go:352 +0x8d fp=0xc420159498 sp=0xc420159450
    app.com/utils/modules/scripts/waveform.ExtractorSoxFaster(0xc420281680, 0x32, 0x0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/modules/scripts/waveform/extractor.go:165 +0x110 fp=0xc4201595b8 sp=0xc420159498
    app.com/utils/modules/extractor.GetSongWaveform(0xc420422a60, 0x17, 0x0, 0x0, 0xc420367050, 0x6, 0xc4202815c0, 0x31, 0xc420281600, 0x37, ...)
    	/srv/go/src/app.com/utils/modules/extractor/waveform.go:11 +0x70 fp=0xc420159668 sp=0xc4201595b8
    app.com/utils/commands.SongWaveformUpdate(0xc420124568, 0x6, 0x0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/commands/song.go:545 +0x3e5 fp=0xc4201598c0 sp=0xc420159668
    main.main.func1(0xc420124568, 0x6, 0x0, 0x0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/cmd/job/main.go:45 +0x287 fp=0xc420159960 sp=0xc4201598c0
    runtime.call64(0xc420132630, 0x8fd148, 0xc420242270, 0x1000000030)
    	/usr/local/go/src/runtime/asm_amd64.s:515 +0x48 fp=0xc4201599b0 sp=0xc420159960
    reflect.Value.call(0x839cc0, 0x8fd148, 0x13, 0x8bf553, 0x4, 0xc4201f6b00, 0x1, 0x1, 0xc420493d68, 0xc420493d60, ...)
    	/usr/local/go/src/reflect/value.go:434 +0x91f fp=0xc420159cf8 sp=0xc4201599b0
    reflect.Value.Call(0x839cc0, 0x8fd148, 0x13, 0xc4201f6b00, 0x1, 0x1, 0x0, 0x0, 0xc420014180)
    	/usr/local/go/src/reflect/value.go:302 +0xa4 fp=0xc420159d60 sp=0xc420159cf8
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1.TryCall(0x839cc0, 0x8fd148, 0x13, 0xc4201f6b00, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:249 +0xf1 fp=0xc420159db8 sp=0xc420159d60
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Process(0xc42011a3c0, 0xc42008ee70, 0x105, 0x83ee40)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:91 +0x42c fp=0xc420159eb0 sp=0xc420159db8
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consumeOne(0xc42009f900, 0xc420114360, 0x105, 0x105, 0xcefa40, 0xc42011a3c0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:219 +0x1af fp=0xc420159f60 sp=0xc420159eb0
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume.func2(0xc42009f900, 0xc420114360, 0x105, 0x105, 0xcefa40, 0xc42011a3c0, 0x0, 0xc42006eba0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:248 +0x61 fp=0xc420159fa0 sp=0xc420159f60
    runtime.goexit()
    	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420159fa8 sp=0xc420159fa0
    created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:253 +0x233
    
    goroutine 1 [chan receive]:
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch(0xc42011a3c0, 0xc42011a3c0, 0xc42004bf48)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:50 +0x654
    main.main()
    	/srv/go/src/app.com/utils/cmd/job/main.go:238 +0xa4a
    
    goroutine 17 [syscall, locked to thread]:
    runtime.goexit()
    	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1
    
    goroutine 5 [select]:
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume(0xc42009f900, 0xc42006eb40, 0xcefa40, 0xc42011a3c0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:237 +0x2da
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming(0xc42009f900, 0x8bf723, 0x4, 0xcefa40, 0xc42011a3c0, 0x0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:142 +0x28a
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch.func1(0xcf70a0, 0xc42009f900, 0xc42011a3c0, 0xc42006e960)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:39 +0x74
    created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:48 +0x612
    
    goroutine 6 [IO wait]:
    net.runtime_pollWait(0x7fbe1f5ad158, 0x72, 0x6)
    	/usr/local/go/src/runtime/netpoll.go:164 +0x59
    net.(*pollDesc).wait(0xc420013568, 0x72, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
    net.(*pollDesc).waitRead(0xc420013568, 0xc42011f000, 0x1000)
    	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
    net.(*netFD).Read(0xc420013500, 0xc42011f000, 0x1000, 0x1000, 0x0, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
    net.(*conn).Read(0xc42000e0a8, 0xc42011f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/net.go:181 +0x70
    bufio.(*Reader).fill(0xc42006ec00)
    	/usr/local/go/src/bufio/bufio.go:97 +0x117
    bufio.(*Reader).ReadSlice(0xc42006ec00, 0xa, 0xc420047bd0, 0x0, 0x8fd220, 0xc420047be0, 0xc420047bd0)
    	/usr/local/go/src/bufio/bufio.go:338 +0xbb
    app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).readLine(0xc42009fa40, 0x0, 0x2c, 0x8bf171, 0x0, 0x0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:341 +0x49
    app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).readReply(0xc42009fa40, 0x0, 0x0, 0xc4201f68e0, 0x2)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:414 +0x43
    app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).Do(0xc42009fa40, 0x8bf91d, 0x5, 0xc4201f68e0, 0x2, 0x2, 0x822260, 0xc4201244c0, 0xc420047f70, 0xc4201244c0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:562 +0x11f
    app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*pooledConnection).Do(0xc42011a5e0, 0x8bf91d, 0x5, 0xc4201f68e0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/pool.go:369 +0xa3
    app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming.func1(0xc42009f900, 0xc42006eb40)
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:96 +0x2b6
    created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming
    	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:140 +0x258
    
    goroutine 12 [IO wait]:
    net.runtime_pollWait(0x7fbe1f5ace58, 0x72, 0xa)
    	/usr/local/go/src/runtime/netpoll.go:164 +0x59
    net.(*pollDesc).wait(0xc420142688, 0x72, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
    net.(*pollDesc).waitRead(0xc420142688, 0xc420118c00, 0x400)
    	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
    net.(*netFD).Read(0xc420142620, 0xc420118c00, 0x400, 0x400, 0x0, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
    net.(*conn).Read(0xc42000e0b8, 0xc420118c00, 0x400, 0x400, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/net.go:181 +0x70
    crypto/tls.(*block).readFromUntil(0xc420117830, 0x7fbe1f5ad2d8, 0xc42000e0b8, 0x5, 0xc42000e0b8, 0x46b200)
    	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
    crypto/tls.(*Conn).readRecord(0xc420099180, 0x8fdd17, 0xc4200992a0, 0x42abc6)
    	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
    crypto/tls.(*Conn).Read(0xc420099180, 0xc42044e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
    bufio.(*Reader).Read(0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0xc42019ec60, 0xc42019ec60, 0x413292)
    	/usr/local/go/src/bufio/bufio.go:213 +0x312
    io.ReadAtLeast(0xceeb40, 0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0x9, 0xc420389920, 0xc42019ed00, 0x8bfa00)
    	/usr/local/go/src/io/io.go:307 +0xa9
    io.ReadFull(0xceeb40, 0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0xc420367001, 0xc420367000, 0x0)
    	/usr/local/go/src/io/io.go:325 +0x58
    net/http.http2readFrameHeader(0xc4200706b8, 0x9, 0x9, 0xceeb40, 0xc42006e8a0, 0x0, 0xc400000000, 0xc420597400, 0x10a)
    	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
    net/http.(*http2Framer).ReadFrame(0xc420070680, 0xc420213a70, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
    net/http.(*http2clientConnReadLoop).run(0xc42019efb0, 0x8fd3b0, 0xc420480fb0)
    	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
    net/http.(*http2ClientConn).readLoop(0xc420001ba0)
    	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
    created by net/http.(*http2Transport).newClientConn
    	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728
    
    goroutine 47 [IO wait]:
    net.runtime_pollWait(0x7fbe1f5acd98, 0x72, 0xb)
    	/usr/local/go/src/runtime/netpoll.go:164 +0x59
    net.(*pollDesc).wait(0xc4202fe308, 0x72, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
    net.(*pollDesc).waitRead(0xc4202fe308, 0xc4201ee000, 0x800)
    	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
    net.(*netFD).Read(0xc4202fe2a0, 0xc4201ee000, 0x800, 0x800, 0x0, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
    net.(*conn).Read(0xc42013c008, 0xc4201ee000, 0x800, 0x800, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/net.go:181 +0x70
    crypto/tls.(*block).readFromUntil(0xc4201160c0, 0x7fbe1f5ad2d8, 0xc42013c008, 0x5, 0xc42013c008, 0x46b203)
    	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
    crypto/tls.(*Conn).readRecord(0xc4202ca000, 0x8fdd17, 0xc4202ca120, 0x42abc6)
    	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
    crypto/tls.(*Conn).Read(0xc4202ca000, 0xc420416000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
    bufio.(*Reader).Read(0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0x40e062, 0x8c1948, 0x8c1736)
    	/usr/local/go/src/bufio/bufio.go:213 +0x312
    io.ReadAtLeast(0xceeb40, 0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0x9, 0xc42006fa40, 0xc420038d00, 0x8bfa00)
    	/usr/local/go/src/io/io.go:307 +0xa9
    io.ReadFull(0xceeb40, 0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0xc420349001, 0xc420349010, 0x0)
    	/usr/local/go/src/io/io.go:325 +0x58
    net/http.http2readFrameHeader(0xc42013e2a8, 0x9, 0x9, 0xceeb40, 0xc420388c60, 0x0, 0xc400000000, 0xc42012ec80, 0x3ee)
    	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
    net/http.(*http2Framer).ReadFrame(0xc42013e270, 0xc4201f33e0, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
    net/http.(*http2clientConnReadLoop).run(0xc420038fb0, 0x8fd3b0, 0xc42047dfb0)
    	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
    net/http.(*http2ClientConn).readLoop(0xc4202b04e0)
    	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
    created by net/http.(*http2Transport).newClientConn
    	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728
    
    goroutine 87 [IO wait]:
    net.runtime_pollWait(0x7fbe1f5accd8, 0x72, 0xc)
    	/usr/local/go/src/runtime/netpoll.go:164 +0x59
    net.(*pollDesc).wait(0xc4202fe848, 0x72, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
    net.(*pollDesc).waitRead(0xc4202fe848, 0xc42044b000, 0x1000)
    	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
    net.(*netFD).Read(0xc4202fe7e0, 0xc42044b000, 0x1000, 0x1000, 0x0, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
    net.(*conn).Read(0xc42013c088, 0xc42044b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/net.go:181 +0x70
    crypto/tls.(*block).readFromUntil(0xc420017e60, 0x7fbe1f5ad2d8, 0xc42013c088, 0x5, 0xc42013c088, 0xc420063040)
    	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
    crypto/tls.(*Conn).readRecord(0xc42020ce00, 0x8fdd17, 0xc42020cf20, 0xc420019368)
    	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
    crypto/tls.(*Conn).Read(0xc42020ce00, 0xc4204d3000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
    bufio.(*Reader).Read(0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x0, 0x0, 0x100000000000000)
    	/usr/local/go/src/bufio/bufio.go:213 +0x312
    io.ReadAtLeast(0xceeb40, 0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x9, 0x42abc6, 0x1000, 0x11)
    	/usr/local/go/src/io/io.go:307 +0xa9
    io.ReadFull(0xceeb40, 0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x3, 0xc420019350, 0xc420019300)
    	/usr/local/go/src/io/io.go:325 +0x58
    net/http.http2readFrameHeader(0xc42013eed8, 0x9, 0x9, 0xceeb40, 0xc420389ce0, 0x0, 0x0, 0x8fddc0, 0xc42048dda8)
    	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
    net/http.(*http2Framer).ReadFrame(0xc42013eea0, 0xc4204d0ee0, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
    net/http.(*http2clientConnReadLoop).run(0xc42048dfb0, 0x8fd3b0, 0xc42047dfb0)
    	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
    net/http.(*http2ClientConn).readLoop(0xc4202b1ba0)
    	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
    created by net/http.(*http2Transport).newClientConn
    	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728
    
    goroutine 72 [IO wait]:
    net.runtime_pollWait(0x7fbe1f5ad218, 0x72, 0x4)
    	/usr/local/go/src/runtime/netpoll.go:164 +0x59
    net.(*pollDesc).wait(0xc4202fe458, 0x72, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
    net.(*pollDesc).waitRead(0xc4202fe458, 0xc420109000, 0x800)
    	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
    net.(*netFD).Read(0xc4202fe3f0, 0xc420109000, 0x800, 0x800, 0x0, 0xcf0e80, 0xced520)
    	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
    net.(*conn).Read(0xc42000e160, 0xc420109000, 0x800, 0x800, 0x0, 0x0, 0x0)
    	/usr/local/go/src/net/net.go:181 +0x70
    crypto/tls.(*block).readFromUntil(0xc4201f20c0, 0x7fbe1f5ad2d8, 0xc42000e160, 0x5, 0xc42000e160, 0x28)
    	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
    crypto/tls.(*Conn).readRecord(0xc420098380, 0x8fdd17, 0xc4200984a0, 0x4537b0)
    	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
    crypto/tls.(*Conn).Read(0xc420098380, 0xc4201d0000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
    net/http.(*persistConn).Read(0xc42012b0e0, 0xc4201d0000, 0x1000, 0x1000, 0x5, 0x451a80, 0xc42014b080)
    	/usr/local/go/src/net/http/transport.go:1316 +0x14b
    bufio.(*Reader).fill(0xc42014af00)
    	/usr/local/go/src/bufio/bufio.go:97 +0x117
    bufio.(*Reader).Peek(0xc42014af00, 0x1, 0xc42019cbe5, 0xc4201df201, 0x4, 0xc42014af60, 0x0)
    	/usr/local/go/src/bufio/bufio.go:129 +0x67
    net/http.(*persistConn).readLoop(0xc42012b0e0)
    	/usr/local/go/src/net/http/transport.go:1474 +0x196
    created by net/http.(*Transport).dialConn
    	/usr/local/go/src/net/http/transport.go:1117 +0xa35
    
    goroutine 73 [select]:
    net/http.(*persistConn).writeLoop(0xc42012b0e0)
    	/usr/local/go/src/net/http/transport.go:1704 +0x43a
    created by net/http.(*Transport).dialConn
    	/usr/local/go/src/net/http/transport.go:1118 +0xa5a
    
    goroutine 101 [runnable]:
    net/http.(*http2clientStream).awaitRequestCancel(0xc420597400, 0xc42006c500)
    	/usr/local/go/src/net/http/h2_bundle.go:5576
    created by net/http.(*http2clientConnReadLoop).handleResponse
    	/usr/local/go/src/net/http/h2_bundle.go:6811 +0x6f7
    
    
  • Changing Sample Rate

    Changing Sample Rate

    Hey there. Thanks for working on this - great tool. I'm wondering if there's an easy way to downconvert sample rate of a file. In command line sox, I would just do:

    sox in.wav -r 16000 out.wav

    I can set the rate on the input and the output, but it seems to just slow the audio down, rather than cutting/interpolating samples.

    Thanks!

  • Add conditional cgo linking directives for mac and linux

    Add conditional cgo linking directives for mac and linux

    Currently, when compiling sox-go in OSX, it fails because pkg-config is not found on that platform. With this change, conditional linking directives are added that are platform specific. For OSX, a brew install sox is needed for the directives provided to work and link correctly.

  • Remove git-sox submodule

    Remove git-sox submodule

    Commit c7881d081d9534bc22951173c93e6a4dc484ddea (Merging of #5) accidentally introduced an empty, unconfigured git-sox submodule which causes all kinds of trouble for me when building on nixos.

    This PR removes the submodule, as it is empty and serves no purpose anyway.

  • Add OpenRead0 function accepting signal info, encoding info and file type parameters

    Add OpenRead0 function accepting signal info, encoding info and file type parameters

    For one of my projects, I need to be able to provide the file type when calling OpenRead, as the filename of the file to be read does not contain an extension.

    This PR adds an OpenRead0 function allowing to set all parameters of sox_open_read.

  • gofmt

    gofmt

    Just ran

    gofmt -w .
    

    on the project root. That's all.

    https://blog.golang.org/go-fmt-your-code


    I made this PR with a project going on over at https://github.com/rotblauer/gofmt-att, and it's definitely a work in progress. So if I got something wrong, or this is annoying at all, please file an issue over there and we'll sort it out.

  • Is go-sox thread safe

    Is go-sox thread safe

    I tried to use the go-sox in multiple threads access that it is for multiple HTTP streaming audio convert, but when I start the second thread, it will crash as below shows

    main: effects_i_dsp.c:168: init_fft_cache: Assertion `lsx_fft_br == ((void *)0)' failed. INFO[0018] call: --> ACCEPT 16777232
    SIGABRT: abort PC=0x7f7dc0a02277 m=7 sigcode=18446744073709551610 signal arrived during cgo execution

    goroutine 31 [syscall, locked to thread]: runtime.cgocall(0x8bc0f0, 0xc42002b700, 0x0) /usr/local/go/src/runtime/cgocall.go:132 +0xe4 fp=0xc42002b6d0 sp=0xc42002b690 pc=0x412bd4 github.com/krig/go-sox._Cfunc_sox_init(0x0) github.com/krig/go-sox/_obj/_cgo_gotypes.go:713 +0x49 fp=0xc42002b700 sp=0xc42002b6d0 pc=0x73aff9 github.com/krig/go-sox.Init(0x0) /root/work/src/github.com/krig/go-sox/sox.go:134 +0x22 fp=0xc42002b718 sp=0xc42002b700 pc=0x73b982 git.xxxxtech.com/xxxxcloud/dataprocessor.(*Dataprocessor).NewProducer.func1(0xc42014a600, 0xc420143360, 0xc420135890) /root/work/src/git.xxxxtech.com/xxxxcloud/dataprocessor/dprocessor.go:46 +0x34 fp=0xc42002b7c8 sp=0xc42002b718 pc=0x7414e4 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42002b7d0 sp=0xc42002b7c8 pc=0x46df21 created by git.xxxxtech.com/xxxxcloud/dataprocessor.(*Dataprocessor).NewProducer /root/work/src/git.xxxxtech.com/xxxxcloud/dataprocessor/dprocessor.go:45 +0xa0

    goroutine 1 [semacquire]: sync.runtime_Semacquire(0xc4201440fc) /usr/local/go/src/runtime/sema.go:56 +0x39 sync.(*WaitGroup).Wait(0xc4201440f0) /usr/local/go/src/sync/waitgroup.go:131 +0x72 main.run(0xc420196000) /root/work/src/git.xxxxtech.com/xxxxcloud/main/main.go:162 +0x7e6 github.com/urfave/cli.HandleAction(0x90e680, 0x9ef578, 0xc420196000, 0xc4201541e0, 0x0) /root/work/src/github.com/urfave/cli/app.go:503 +0x7c github.com/urfave/cli.(*App).Run(0xc420190000, 0xc420010090, 0x3, 0x3, 0x0, 0x0) /root/work/src/github.com/urfave/cli/app.go:268 +0x653 main.main() /root/work/src/git.xxxxtech.com/xxxxcloud/main/main.go:70 +0x72e

    goroutine 5 [syscall]: os/signal.signal_recv(0x0) /usr/local/go/src/runtime/sigqueue.go:131 +0xa6 os/signal.loop() /usr/local/go/src/os/signal/signal_unix.go:22 +0x22 created by os/signal.init.0 /usr/local/go/src/os/signal/signal_unix.go:28 +0x41

    goroutine 8 [chan receive]: git.xxxxtech.com/xxxxcloud/eventsprocessor.(*g_System).Exit.func1(0xc420154300, 0xc420132820) /root/work/src/git.xxxxtech.com/xxxxcloud/eventsprocessor/eprocessor.go:61 +0x4b created by git.xxxxtech.com/xxxxcloud/eventsprocessor.(*g_System).Exit /root/work/src/git.xxxxtech.com/xxxxcloud/eventsprocessor/eprocessor.go:60 +0xe9

    goroutine 18 [chan receive]: gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun(0xc420154240) /root/work/src/gopkg.in/natefinch/lumberjack.v2/lumberjack.go:379 +0x58 created by gopkg.in/natefinch/lumberjack%2ev2.(*Logger).mill.func1 /root/work/src/gopkg.in/natefinch/lumberjack.v2/lumberjack.go:390 +0x7e

    goroutine 19 [chan receive]: database/sql.(*DB).connectionOpener(0xc42019e000) /usr/local/go/src/database/sql/sql.go:871 +0x53 created by database/sql.Open /usr/local/go/src/database/sql/sql.go:609 +0x1ee

    goroutine 7 [IO wait]: internal/poll.runtime_pollWait(0x7f7dc20e9f70, 0x72, 0xffffffffffffffff) /usr/local/go/src/runtime/netpoll.go:173 +0x57 internal/poll.(*pollDesc).wait(0xc42011e118, 0x72, 0xc420040c00, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae internal/poll.(*pollDesc).waitRead(0xc42011e118, 0xffffffffffffff00, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d internal/poll.(*FD).Accept(0xc42011e100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_unix.go:334 +0x1e2 net.(*netFD).accept(0xc42011e100, 0x7f7dc2145000, 0x0, 0x9eff00) /usr/local/go/src/net/fd_unix.go:238 +0x42 net.(*TCPListener).accept(0xc42000e148, 0xc420040e78, 0x422358, 0x30) /usr/local/go/src/net/tcpsock_posix.go:136 +0x2e net.(*TCPListener).AcceptTCP(0xc42000e148, 0xc4201b8210, 0xc4201b8210, 0x930700) /usr/local/go/src/net/tcpsock.go:234 +0x49 net/http.tcpKeepAliveListener.Accept(0xc42000e148, 0xc4200140a0, 0x930700, 0xe5b6d0, 0x9aea40) /usr/local/go/src/net/http/server.go:3120 +0x2f net/http.(*Server).Serve(0xc4200752b0, 0xe734e0, 0xc42000e148, 0x0, 0x0) /usr/local/go/src/net/http/server.go:2695 +0x1b2 net/http.(*Server).ListenAndServe(0xc4200752b0, 0xc420060300, 0x0) /usr/local/go/src/net/http/server.go:2636 +0xa9 created by git.xxxxtech.com/xxxxcloud/api.Run /root/work/src/git.xxxxtech.com/xxxxcloud/api/api.go:22 +0x11b

    goroutine 21 [chan receive]: git.xxxxtech.com/xxxxcloud/api.Run(0xc4201429c0) /root/work/src/git.xxxxtech.com/xxxxcloud/api/api.go:26 +0x155 created by main.run /root/work/src/git.xxxxtech.com/xxxxcloud/main/main.go:144 +0x6af

    goroutine 22 [select, locked to thread]: runtime.gopark(0x9efdd8, 0x0, 0x9c1f36, 0x6, 0x18, 0x1) /usr/local/go/src/runtime/proc.go:277 +0x12c runtime.selectgo(0xc42003af50, 0xc42014a1e0) /usr/local/go/src/runtime/select.go:395 +0x1138 runtime.ensureSigM.func1() /usr/local/go/src/runtime/signal_unix.go:511 +0x220 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1

    goroutine 9 [runnable, locked to thread]: git.xxxxtech.com/hmp/grandprix-go._Cfunc_PKX_SYSTEM_WaitOnEvent(0xffffffff, 0xc4201888a0, 0xc400000000) git.xxxxtech.com/hmp/grandprix-go/_obj/_cgo_gotypes.go:2612 +0x4d git.xxxxtech.com/hmp/grandprix-go.systemWaitOnEvent(0xc4ffffffff, 0xc420053bc8, 0x2, 0x2) /root/work/src/git.xxxxtech.com/hmp/grandprix-go/system_hmp.go:63 +0x47 git.xxxxtech.com/hmp/grandprix-go.SystemWaitOnEvent(0xc4ffffffff, 0x2, 0x2, 0xc420144b28) /root/work/src/git.xxxxtech.com/hmp/grandprix-go/system.go:22 +0x29 git.xxxxtech.com/xxxxcloud/eventsprocessor.(*g_System).EventProcess(0xc420132820) /root/work/src/git.xxxxtech.com/xxxxcloud/eventsprocessor/eprocessor.go:88 +0x60 main.run.func1(0xc4201440f0, 0xc420132820) /root/work/src/git.xxxxtech.com/xxxxcloud/main/main.go:160 +0x51 created by main.run /root/work/src/git.xxxxtech.com/xxxxcloud/main/main.go:158 +0x7d5

    goroutine 23 [select]: net/http.(*persistConn).readLoop(0xc4200a3680) /usr/local/go/src/net/http/transport.go:1654 +0x7a7 created by net/http.(*Transport).dialConn /usr/local/go/src/net/http/transport.go:1186 +0xa2e

    goroutine 16 [select]: git.xxxxtech.com/xxxxcloud/rbuffer.NewEQ.func1(0xc4200e1820) /root/work/src/git.xxxxtech.com/xxxxcloud/rbuffer/eq.go:30 +0x444 created by git.xxxxtech.com/xxxxcloud/rbuffer.NewEQ /root/work/src/git.xxxxtech.com/xxxxcloud/rbuffer/eq.go:25 +0x157

    goroutine 24 [select]: net/http.(*persistConn).writeLoop(0xc4200a3680) /usr/local/go/src/net/http/transport.go:1759 +0x165 created by net/http.(*Transport).dialConn /usr/local/go/src/net/http/transport.go:1187 +0xa53

    goroutine 34 [IO wait]: internal/poll.runtime_pollWait(0x7f7dc20e9df0, 0x72, 0x0) /usr/local/go/src/runtime/netpoll.go:173 +0x57 internal/poll.(*pollDesc).wait(0xc42011e618, 0x72, 0xffffffffffffff00, 0xe6fce0, 0xe6b240) /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae internal/poll.(*pollDesc).waitRead(0xc42011e618, 0xc4201e9b00, 0x6101, 0x6101) /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d internal/poll.(*FD).Read(0xc42011e600, 0xc4201e9bff, 0x6101, 0x6101, 0x0, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_unix.go:125 +0x18a net.(*netFD).Read(0xc42011e600, 0xc4201e9bff, 0x6101, 0x6101, 0x1bff, 0x0, 0x0) /usr/local/go/src/net/fd_unix.go:202 +0x52 net.(*conn).Read(0xc4201400b0, 0xc4201e9bff, 0x6101, 0x6101, 0x0, 0x0, 0x0) /usr/local/go/src/net/net.go:176 +0x6d net/http.(*persistConn).Read(0xc4200a3680, 0xc4201e9bff, 0x6101, 0x6101, 0x43bb78, 0x0, 0x0) /usr/local/go/src/net/http/transport.go:1391 +0x140 bufio.(*Reader).Read(0xc420154540, 0xc4201e9bff, 0x6101, 0x6101, 0x43b4b9, 0xc400000008, 0xc4201ba780) /usr/local/go/src/bufio/bufio.go:199 +0x1a3 net/http.(*body).readLocked(0xc4201ba980, 0xc4201e9bff, 0x6101, 0x6101, 0x1bff, 0x0, 0x0) /usr/local/go/src/net/http/transfer.go:779 +0x67 net/http.(*body).Read(0xc4201ba980, 0xc4201e9bff, 0x6101, 0x6101, 0x0, 0x0, 0x0) /usr/local/go/src/net/http/transfer.go:771 +0xea net/http.(*bodyEOFSignal).Read(0xc4201ba9c0, 0xc4201e9bff, 0x6101, 0x6101, 0x0, 0x0, 0x0) /usr/local/go/src/net/http/transport.go:2124 +0xe9 io.ReadAtLeast(0xe6dfa0, 0xc4201ba9c0, 0xc4201e8000, 0x7d00, 0x7d00, 0x7d00, 0x947ec0, 0x7f7d70000800, 0xe6dfa0) /usr/local/go/src/io/io.go:309 +0x86 io.ReadFull(0xe6dfa0, 0xc4201ba9c0, 0xc4201e8000, 0x7d00, 0x7d00, 0xc4201e1de0, 0x469fe0, 0xc4201c8780) /usr/local/go/src/io/io.go:327 +0x58 git.xxxxtech.com/xxxxcloud/dataprocessor.(*Dataprocessor).Read(0xc4201b9170, 0x0, 0x0, 0x0) /root/work/src/git.xxxxtech.com/xxxxcloud/dataprocessor/dprocessor.go:76 +0xc9 git.xxxxtech.com/xxxxcloud/dataprocessor.(*Dataprocessor).NewProducer.func1(0xc42001c7e0, 0xc4200e1820, 0xc4201b9170) /root/work/src/git.xxxxtech.com/xxxxcloud/dataprocessor/dprocessor.go:66 +0x76 created by git.xxxxtech.com/xxxxcloud/dataprocessor.(*Dataprocessor).NewProducer /root/work/src/git.xxxxtech.com/xxxxcloud/dataprocessor/dprocessor.go:45 +0xa0

    goroutine 35 [select]: net/http.(*persistConn).readLoop(0xc4201505a0) /usr/local/go/src/net/http/transport.go:1654 +0x7a7 created by net/http.(*Transport).dialConn /usr/local/go/src/net/http/transport.go:1186 +0xa2e

    goroutine 30 [select]: git.xxxxtech.com/xxxxcloud/rbuffer.NewEQ.func1(0xc420143360) /root/work/src/git.xxxxtech.com/xxxxcloud/rbuffer/eq.go:30 +0x444 created by git.xxxxtech.com/xxxxcloud/rbuffer.NewEQ /root/work/src/git.xxxxtech.com/xxxxcloud/rbuffer/eq.go:25 +0x157

    goroutine 36 [select]: net/http.(*persistConn).writeLoop(0xc4201505a0) /usr/local/go/src/net/http/transport.go:1759 +0x165 created by net/http.(*Transport).dialConn /usr/local/go/src/net/http/transport.go:1187 +0xa53

    rax 0x0 rbx 0x7f7dc2193000 rcx 0xffffffffffffffff rdx 0x6 rdi 0x10aa rsi 0x10be rbp 0x7f7dc0b56580 rsp 0x7f7da526eb58 r8 0x0 r9 0x7f7d8c00b250 r10 0x8 r11 0x206 r12 0x7f7dc0e0e64c r13 0x7f7dc0e0eaf0 r14 0x1 r15 0x0 rip 0x7f7dc0a02277 rflags 0x206 cs 0x33 fs 0x0 gs 0x0 [root@localhost main]#

  • Playing progress example?

    Playing progress example?

    I'd like to see a clean example of playing an audio file and during playback printing out the progress of the playback (as in how many seconds, samples have been played, or position, or any useful indicator really).

    I can't seem to figure out a simple solution based on the existing samples and reading the libsox documentation is painful enough that it's prohibitive for me to contribute this go-sox code myself.

  • segmentation violation after received incorrect file

    segmentation violation after received incorrect file

    Hi! I got an error fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x7ff4e39978c0 pc=0x7ff4e39978c0] when I gave go-sox libarry non-audio file. When I send incorrect file for the fist time it returns "formats: no handler for file extension `jpg'" but for the second time it's crashed with error https://gist.github.com/akaroot/bd040d722bd2fd2bb5e42c80bb35243c#file-error-log

    After fisrt incorrect file I can send audio files and averythind works, but on second image file I always got crashed.

    Code example: https://gist.github.com/akaroot/bd040d722bd2fd2bb5e42c80bb35243c#file-main-go GO version: 1.9.4, 1.10 OS: Ubuntu 16.04 x64

  • How to convert GSM to MP3 using sox

    How to convert GSM to MP3 using sox

    Hi. After i'd tried this code to convert GSM to MP3, It was converted successfully but when i tried to play, there's no content. i cannot directly convert it to wav due to the error of the audio file: WAV:RIFF Header not found sox -t gsm -r 8000 -c 1 -e signed-integer 003533-dialer-Feb-01-2017-16-00-17-PM.WAV -t wav -e signed-integer 0017.wav

    file 0017.wav 0017.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8000 Hz sample output. sox 0017.wav -n stat Samples read: 0 Length (seconds): 0.000000 Scaled by: 2147483647.0 Maximum amplitude: 0.000000 Minimum amplitude: 0.000000 Midline amplitude: 0.000000 Mean norm: -nan Mean amplitude: -nan RMS amplitude: -nan Maximum delta: 0.000000 Minimum delta: 0.000000 Mean delta: -0.000000 RMS delta: -0.000000 Rough frequency: -2147483648 Probably text, not sound

    image

  • Play 2 files stimulatingly

    Play 2 files stimulatingly

    Hi, I tried played the second file while the first file was playing but failed, the second file can only be play when being triggered after the first file finished playing. Is there any solution for this?

    Thanks so much!

  • rtp stream exploitation

    rtp stream exploitation

    Hello, I need to analyze rtp streams (pcmu, pcma) and I would like to use this package. I saw "OpenMemRead" use "C.sox_open_mem_read" with default nil encodinginfo_t and nil signalinfo_t parameters. Is there a way to read and exploit a pcm file or stream ? (There is no setter for fmt.cFormat). Thanks in advance.

Related tags
Go bindings for libportmidi

portmidi Want to output to an MIDI device or listen your MIDI device as an input? This package contains Go bindings for PortMidi. libportmidi (v. 217)

Dec 25, 2022
Golang bindings for libmediainfo

mediainfo Golang binding for libmediainfo Duration, Bitrate, Codec, Streams and a lot of other meta-information about media files can be extracted thr

Nov 16, 2022
Go bindings for the PortAudio audio I/O library

portaudio This package provides an interface to the PortAudio audio I/O library. See the package documentation for details. To build this package you

Jan 1, 2023
Go bindings for libportmidi

portmidi Want to output to an MIDI device or listen your MIDI device as an input? This package contains Go bindings for PortMidi. libportmidi (v. 217)

Dec 25, 2022
Golang bindings for the Telegram Bot API

Golang bindings for the Telegram Bot API All methods are fairly self explanatory, and reading the godoc page should explain everything. If something i

Jan 6, 2023
OpenSSL bindings for Go

OpenSSL bindings for Go Please see http://godoc.org/github.com/spacemonkeygo/openssl for more info License Copyright (C) 2017. See AUTHORS. Licensed u

Dec 29, 2022
Golang bindings for libxlsxwriter for writing XLSX files
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Nov 18, 2022
Go bindings for ForestDB

goforestdb Go bindings for ForestDB Building Obtain and build forestdb: https://github.com/couchbaselabs/forestdb (run make install to install the lib

Sep 26, 2022
Go bindings for GLib type system.

Go bindings for GLib type system. This package is designed for building bindings to C libraries based on GLib type system (like GTK, GStreamer, and ot

Aug 13, 2019
Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files.
Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files.

tabby Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files. screenshot: depend

Nov 16, 2022
Duktape JavaScript engine bindings for Go

Duktape bindings for Go(Golang) Duktape is a thin, embeddable javascript engine. Most of the api is implemented. The exceptions are listed here. Usage

Jan 6, 2023
PHP bindings for the Go programming language (Golang)

PHP bindings for Go This package implements support for executing PHP scripts, exporting Go variables for use in PHP contexts, attaching Go method rec

Jan 1, 2023
naive go bindings to the CPython C-API

go-python Naive go bindings towards the C-API of CPython-2. this package provides a go package named "python" under which most of the PyXYZ functions

Jan 5, 2023
Go bindings for Lua C API - in progress

Go Bindings for the lua C API Simplest way to install: # go get github.com/aarzilli/golua/lua You can then try to run the examples: $ cd golua/_examp

Dec 28, 2022
Go bindings for libmagic to detect MIME types

magicmime magicmime is a Go package which allows you to discover a file's mimetype by looking for magic numbers in its content. It could be used as a

Nov 9, 2022
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

raylib-go Golang bindings for raylib, a simple and easy-to-use library to enjoy videogames programming. Requirements Ubuntu X11 apt-get install libgl1

Dec 28, 2022
Go bindings for the Cartographic Projections Library PROJ.4

The Go package proj provides a limited interface to the Cartographic Projections Library PROJ. For PROJ version 5 and beyond, see also: https://github

Nov 10, 2022
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

Jan 8, 2023
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

Dec 25, 2022
Go bindings for OpenGL (generated via glow)

gl This repository holds Go bindings to various OpenGL versions. They are auto-generated using Glow. Features: Go functions that mirror the C specific

Dec 12, 2022