mkb218 / gosndfile Goto Github PK
View Code? Open in Web Editor NEWGo bindings for libsndfile
License: GNU Lesser General Public License v2.1
Go bindings for libsndfile
License: GNU Lesser General Public License v2.1
I was just trying get started with the library iterating over a file and printing the values. Got very a very odd error message. I have distilled it down to this:
package main
import (
"fmt"
"sndfile"
)
const bufferSize = 1024
func main() {
// The location of a test file shipped with sndfile
inp := "/Users/joe/personal/go/src/sndfile/test/funky.aiff"
var info sndfile.Info
soundFile, err := sndfile.Open(inp, sndfile.Read, &info)
if err != nil {
return
}
defer soundFile.Close()
numRead := int64(-1)
realBufferSize := bufferSize * info.Channels
buffer := make([]float32, realBufferSize)
for numRead != 0 {
numRead, err = soundFile.ReadItems(buffer)
fmt.Println("LOOP")
}
}
When I run this:
$ go run /tmp/breaking.go
LOOP
unexpected fault address 0x3f000000
throw: fault
[signal 0xb code=0x1 addr=0x3f000000 pc=0x8e47]
goroutine 1 [running]:
fmt.(*fmt).padString(0xf84005a048, 0x9ea8c, 0x4, 0x9ea8c)
/usr/local/go/src/pkg/fmt/format.go:138 +0x106
fmt.(*fmt).fmt_s(0xf84005a048, 0x9ea8c, 0x4, 0x61288)
/usr/local/go/src/pkg/fmt/format.go:285 +0x60
fmt.(*pp).fmtString(0xf84005a000, 0x9ea8c, 0xf800000004, 0x76, 0x4, ...)
/usr/local/go/src/pkg/fmt/print.go:533 +0xf1
fmt.(*pp).printField(0xf84005a000, 0x61288, 0xf840030270, 0x76, 0x0, ...)
/usr/local/go/src/pkg/fmt/print.go:776 +0xa9d
fmt.(*pp).doPrint(0xf84005a000, 0x2577f70, 0x100000001, 0x101, 0x106fa0, ...)
/usr/local/go/src/pkg/fmt/print.go:1110 +0x1f5
fmt.Fprintln(0xf84002fbd0, 0xf84003d008, 0x2577f70, 0x100000001, 0xf84003d008, ...)
/usr/local/go/src/pkg/fmt/print.go:279 +0x6c
fmt.Println(0x2577f70, 0x100000001, 0x504f4f4c00000004, 0x0, 0x0, ...)
/usr/local/go/src/pkg/fmt/print.go:289 +0x7b
main.main()
/tmp/breaking.go:32 +0x209
goroutine 2 [syscall]:
created by runtime.main
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:221
exit status 2
There is some kind of problem when fmt.Println is called in the second run of the loop. Mac OS 10.6.8, go1.0.2, libsndfile latest from macports.
I am completely puzzled by this. I can't form a connection between using unsafe C functions and the fmt library. I've had a look at the gosndfile code and can't see anything obviously wrong. The line in question, /usr/local/go/src/pkg/fmt/format.go:138, is this:
f.buf.WriteString(s)
Perhaps there's a per-go-routine allocated buffer that's being overwritten? Perhaps the const text "LOOP" is being scribbled over? I can only guess.
If you remove the fmt.Println the sample runs fine.
libsndfile looks like it has some support for specifying channel maps. Doesn't appear to be documented well.
All operations for which I can create data should be covered by automated tests. This excludes SetLoopInfo, GetEmbeddedFileInfo, and SetVbrQuality. SetRawStartOffset appears to not do anything, so the test is written but inactive.
libsndfile doesn't honor the loop type when using SetInstrument() on an AIFF file.
I successfully compiled under Windows and MSYS2, but under Ubuntu I get this error: "could not determine kind of name for C.uint32_t".
For both I used Go 1.8.
Go env is:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ignazio/Programming/Go-Workspace"
GORACE=""
GOROOT="/home/ignazio/bin/go"
GOTOOLDIR="/home/ignazio/bin/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build419818202=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
Hi,
I'm using libsndfile with OpenAL-Soft.
It required me to create the buffer.
ioutil.ReadFile('path')
?gofix!
I just found these in sndfile.h. What do they do?
SFC_SET_DITHER_ON_WRITE = 0x10A0,
SFC_SET_DITHER_ON_READ = 0x10A1,
SFC_GET_DITHER_INFO_COUNT = 0x10A2,
SFC_GET_DITHER_INFO = 0x10A3,
When I try to go get
this package, I get:
raw.go:3:2: error: #import is a deprecated GCC extension [-Werror=deprecated]
cc1: all warnings being treated as errors
Same if I clone it locally and try to go build
in the sndfile
directory.
If I change "#import" to "#include", go build
then appears to build successfully.
I am running gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
.
Hi ,
Could you help me out on this , or guide me to some how can thanks
I am trying to get a wav file information but Sndfile is unable to read file with special characters in path and file name(查找問題daw.wav) and i am unable to get information in any way , i tried passing file path to Sndfile with diferent encoding to but didnt work , but if i pass this 'C:\Users\Furqan\Desktop\test\DAW\1.wav' it works fine , Thanks is advance
My Code is
# -- coding: UTF-8 --
from scikits.audiolab import Sndfile
from os import walk, path, stat
track1 = r'C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav'
#track2 = r'C:\Users\Furqan\Desktop\test\DAW\1.wav'
try:
track_one_file_obj = Sndfile(track1, 'r')
except:
print('Simple didnt work')
pass
try:
track_one_file_obj = Sndfile(track1.decode('cp1252'), 'r')
except:
print('cp1252 didnt work')
pass
try:
track_one_file_obj = Sndfile(track1.encode('utf-8'), 'r')
print(track_one_file_obj)
except:
print('encode didnt work')
pass
try:
track_one_file_obj = Sndfile(track1.encode('utf8'), 'r')
print(track_one_file_obj)
except:
print('encode didnt work')
pass
try:
track_one_file_obj = Sndfile(track1.decode('utf-8'), 'r')
print(track_one_file_obj)
except:
print('decode didnt work')
pass
Errors from libsndfile don't always end up giving as much detail as possible about the error, especially when the call into the library returns 2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.