Giter Club home page Giter Club logo

gopus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gopus's Issues

Import Error: build constraints exclude all Go files

Platform: Ubuntu 22.04.3 LTS on WSL 2.0.9.0 (Win 11)
Go Version: go1.21.5 linux/amd64

When trying to import the gopus library I get the following error(s):

error while importing layeh.com/gopus: build constraints exclude all Go files in /home/<myuser>/go/pkg/mod/layeh.com/[email protected]
could not import layeh.com/gopus (no required module provides package "layeh.com/gopus")

Minimal code to recreate:

package main
import "layeh.com/gopus"

Problem decoding opus back to PCM

I've been using your package for encoding opus for a little bit and it works fantastic. I really appreciate you having wrote it :)

I've recently started trying to use it to decode opus back into PCM and I'm running into problems where the result doesn't sound right (very very choppy/skippy sounding).

So I wrote a little test program and published it here : https://github.com/bwmarrin/oencdec

With this test, I'm doing 2 channel audio and it looks like the decoder output is half the size that it should be. The program reads in 1920 int16 values, encodes to opus, then decodes to PCM and the output is only 960 int16 values.

Any change you know what I'm doing wrong or is there possibly a bug in gopus somewhere?

Error to run

root@S1ROZHA:~ # go install BogdanBot/cmd/bot
work/src/BogdanBot/cmd/bot/bot.go:18:2: code in directory /root/work/src/github.com/layeh/gopus expects import "layeh.com/gopus"
root@S1ROZHA:~#

Low audio quality after decode

Hey there, I am using this library and encode and decode my PCM data.
I use malgo to capture and play them back. I use the int16 mode.
I've written two functions that convert []byte to []int16 like so

func bytesToInts16(data []byte) []int16 {
	samples := make([]int16, len(data)/2)
	for i := 0; i < len(data) / 2; i++ {
		samples[i] = int16(binary.LittleEndian.Uint16(data[i*2 : i*2+2]))
	}
	return samples
}

func ints16ToBytes(samples []int16) []byte {
	data := make([]byte, len(samples)*2)
	for i := 0; i < len(samples); i++ {
		binary.LittleEndian.PutUint16(data[i*2 : i*2+2], uint16(samples[i]))
	}
	return data
}

and my onSamples malgo function looks something like this

func onSamples(pOutputSample, pInputSamples []byte, frameCount uint32) {
	buffer := bytesToInts16(pInputSamples)
	data, err := compressPCM(buffer, int(frameCount))
	if err != nil {
		fmt.Println(err)
		return
	}
	decoded, err := decompressOpus(data, int(frameCount))
	if err != nil {
		fmt.Println(err)
		return
	}
	// Convert back to bytes
	decodedBytes := ints16ToBytes(decoded)
	// set them as output
	copy(pOutputSample, decodedBytes)
}

while my encode and decode

func compressPCM(pcm []int16, frameCount int) ([]byte, error) {
	encoder, err := gopus.NewEncoder(48000, 1, gopus.Audio)
	if err != nil {
		return nil, err
	}
	encoded, err := encoder.Encode(pcm, frameCount, 960)
	if err != nil {
		return nil, err
	}
	return encoded, nil
}

func decompressOpus(data []byte, frameCount int) ([]int16, error) {
	decoder, err := gopus.NewDecoder(48000, 1)
	if err != nil {
		return nil, fmt.Errorf("failed to create decoder: %w", err)
	}
	decoded, err := decoder.Decode(data, frameCount, false)
	if err != nil {
		return nil, fmt.Errorf("failed to decode: %w", err)
	}
	return decoded, nil
}

it's a mono channel, 48000Hz samples per second.
The audio quality is just horrible, any ideas what might be wrong?

Compilation fails because config.h can't be found

I'm working on a project using gumble and thus also gopus as a dependency but go build fails whenever I try to import gumble/opus:

$ go build                                        
# github.com/LeoVerto/gumble-pulseaudio/vendor/layeh.com/gopus
vendor/layeh.com/gopus/opus_nonshared.go:9:11: fatal error: opus-1.1.2/config.h: No such file or directory
 // #include "opus-1.1.2/config.h"
           ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

That file definitely exists and my local clone of gopus is up to date.

I'm sorry if this is something trivial, I haven't worked with Go outside of hacking on some mumble related stuff.

Build errors on FreeBSD

I was trying to install matthieugrieger/mumbledj and ran into issues when it tried to install gopus, which is listed in it's dependencies. I installing opus-1.1.2, opus-tools-0.1.9, and go-1.6.2. The C compiler is Clang 3.4.1. I don't know enough about Go to figure out what it's failing on, but here are the last few lines:

/tmp/go-build789578334/github.com/layeh/gopus/_obj/opus_nonshared.cgo2.o: In function `logSum':
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/opus_multistream_encoder.c:212: undefined reference to `floorf'
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/opus_multistream_encoder.c:212: undefined reference to `floorf'
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/opus_multistream_encoder.c:212: undefined reference to `floorf'
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/opus_multistream_encoder.c:212: undefined reference to `floorf'
/tmp/go-build789578334/github.com/layeh/gopus/_obj/opus_nonshared.cgo2.o: In function `surround_analysis':
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/opus_multistream_encoder.c:323: undefined reference to `log'
/tmp/go-build789578334/github.com/layeh/gopus/_obj/opus_nonshared.cgo2.o: In function `FLOAT2INT16':
.vendor/src/github.com/layeh/gopus/opus-1.1.2/celt/float_cast.h:136: undefined reference to `lrintf'
/tmp/go-build789578334/github.com/layeh/gopus/_obj/opus_nonshared.cgo2.o: In function `tansig_approx':
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/mlp.c:88: undefined reference to `floorf'
.vendor/src/github.com/layeh/gopus/opus-1.1.2/src/mlp.c:88: undefined reference to `floorf'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
goop: Command failed with exit status 2
*** Error code 2

The output of pkg-config --cflags opus gives -I/usr/local/include/opus, which should mean that the Opus header files can be found, correct? There is an opus.h in that folder. It seems a lot of the undefined references are to math functions like pow, floor, cos, log, etc. How would I know if the math library is being linked (usually done with a compiler flag of -lm)?

Unable to compile on Windows

I am unable to compile gopus on Windows with Go 1.6.1

$ go version
go version go1.6.1 windows/amd64

Error:

$ go get github.com/layeh/gopus
# github.com/layeh/gopus
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

Error on go get

Go 1.6

$ go get github.com/layeh/gopus
In file included from ../../layeh/gopus/opus_nonshared.go:68:0:
../../layeh/gopus/opus-1.1.2/silk/NLSF2A.c:41:0: warning: "QA" redefined [enabled by default]
 #define QA      16
 ^
In file included from ../../layeh/gopus/opus_nonshared.go:66:0:
../../layeh/gopus/opus-1.1.2/silk/LPC_inv_pred_gain.c:34:0: note: this is the location of the previous definition
 #define QA                          24
 ^
In file included from ../../layeh/gopus/opus-1.1.2/celt/bands.c:41:0,
                 from ../../layeh/gopus/opus_nonshared.go:120:
../../layeh/gopus/opus-1.1.2/celt/mathops.h:83:0: warning: "PI" redefined [enabled by default]
 #define PI 3.141592653f
 ^
In file included from opus-1.1.2/silk/float/main_FLP.h:31:0,
                 from ../../layeh/gopus/opus-1.1.2/silk/enc_API.c:41,
                 from ../../layeh/gopus/opus_nonshared.go:21:
opus-1.1.2/silk/float/SigProc_FLP.h:150:0: note: this is the location of the previous definition
 #define PI              (3.1415926536f)
 ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.