-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working example with go-mpg123 #16
Comments
This sounds like an OK candidate for the Regarding making it work: I recommend checking two things: the currently ignored first return value from |
@dadleyy did you ever fixed the problem? I have the exact same issue right now, using the same packages... |
@gordonklaus been reading your reply a couple of times, but fail to fully understand what you are suggesting. Of course the comment about Would love to get a working setup that gives me clear sound instead of the heavily distorted sound I have now. And just FYI: next to the output being distorted is also seems to be much slower making a woman's voice sound low like a man's voice... |
@svanharmelen On second thought, timing the loop and adding buffering should be unnecessary at this point. The more likely culprit for your distorted audio is the format of the buffer. The values of For example, if |
Not sure how I should go about this... The callback := func(_, out []int16) {
size, err := mp3.Read(audio)
if err != nil {
log.Fatal(err)
}
for i := range audio[:size] {
out[i] = int16(audio[i])
}
} But this doesn't change a thing (which makes sense 😞 ) The file I am working with is mono16 (signed), so |
Yep, Here's how to interpret bytes as 16 bit integers:
|
@gordonklaus was just playing with the So thank you very much for your help! It now works perfectly 😀 I'll create and post back a cleaned up gist that can be used for reference for anyone else dropping by here with a similar question. I do have one more (hopefully) small/simple question... Is there a way to ask the stream if it is still playing, or that it is stopped? I'm not how else I can tell when my function can exit. Thanks!! |
@svanharmelen Great! Glad to help 😄 Typically, you tell the stream to stop when you are done with it; it will not stop on its own. In your example, when mp3.Read returns EOF you would call stream.Stop and signal the main goroutine (via a channel, e.g.) to exit. Or, a simpler way in this case is to do as @dadleyy did and call the synchronous stream.Write method from the main goroutine. |
I'm working on a project where I will be using go-mpg123 (a port of the libmpg123 bindings in golang) but I'm having a hard time getting that library to play nicely with port audio.
I've gotten reasonably far in this gist but the audio playback is really distorted for some reason and I cant figure out what would be the issue.
Has anyone been able to get these two libraries successfully working together, and if so is there anything blatantly wrong with my code example? If I'm able to get something working, would this be a good candidate for the
examples
directory?The text was updated successfully, but these errors were encountered: