-
Notifications
You must be signed in to change notification settings - Fork 15
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
No sound on macOS #145
Comments
Does the audio work in other examples? I suspect the |
Whatever it is, it's not the call to package main
import (
"log"
"os"
"time"
"github.com/gopxl/beep"
"github.com/gopxl/beep/mp3"
"github.com/gopxl/beep/speaker"
)
func main() {
f, err := os.Open("gunshot.mp3")
if err != nil {
log.Fatal(err)
}
streamer, format, err := mp3.Decode(f)
if err != nil {
log.Fatal(err)
}
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/60))
buffer := beep.NewBuffer(format)
buffer.Append(streamer)
streamer.Close()
for {
shot := buffer.Streamer(0, buffer.Len())
speaker.Play(shot)
time.Sleep(1 * time.Second)
}
} I can confirm, however, that at least the tone generator works. |
Hmm, that's going to be a bit hard to debug. Your example works for me. If the tone generator works, that would suggest that the speaker works. If you have no errors, I would assume the mp3 can be read and parsed successfully. And I'm assuming you're using the same I think this is going to be a game of test a lot of stuff to narrow it down. Below are some things to try. But if you can narrow it down further that would be great. Just to confirm, this works? package main
import (
"log"
"time"
"github.com/gopxl/beep"
"github.com/gopxl/beep/generators"
"github.com/gopxl/beep/speaker"
)
func main() {
format := beep.Format{
SampleRate: 44100,
NumChannels: 2,
Precision: 2,
}
sine, err := generators.SineTone(format.SampleRate, 400)
if err != nil {
log.Fatal(err)
}
streamer := beep.Take(format.SampleRate.N(time.Second/2), sine)
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/60))
buffer := beep.NewBuffer(format)
buffer.Append(streamer)
for {
shot := buffer.Streamer(0, buffer.Len())
speaker.Play(shot)
time.Sleep(1 * time.Second)
}
} Could you also check the other functions for errors and check if the buffer is filled. I've also increased the speaker buffer size here. package main
import (
"fmt"
"log"
"os"
"time"
"github.com/gopxl/beep"
"github.com/gopxl/beep/mp3"
"github.com/gopxl/beep/speaker"
)
func main() {
f, err := os.Open("gunshot.mp3")
if err != nil {
log.Fatal(err)
}
streamer, format, err := mp3.Decode(f)
if err != nil {
log.Fatal(err)
}
err = speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/30))
if err != nil {
log.Fatal(err)
}
buffer := beep.NewBuffer(format)
buffer.Append(streamer)
err = streamer.Close()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Buffer size: %d\n", buffer.Len())
for {
shot := buffer.Streamer(0, buffer.Len())
speaker.Play(shot)
time.Sleep(1 * time.Second)
}
} |
Kind of. This first example makes a brief popping sound with perhaps a few millis of the tone before going silent.
This works as intended! |
Can this issue be marked as solved? |
Up to you! I have tested and every other example works fine, but the core of the issue, really, is that I cannot run The tutorial mentions increasing the buffer size if latency is observed, but I think it might be helpful to mention that this could also include no sound whatsoever. I think a comment in the tutorial and a comment in the example file itself might go a long way, but there's probably also room for some heuristics that could attempt to determine the ideal sample rate. The documentation could probably also use a treatment on selecting speaker sample rate for use cases that involve playing more than one sample. I imagine many users will want to use this library as I am attempting to, which is to play one of a few different samples as unique notification sounds. The current documents and examples all involve initializing the speaker with the sample rate of the file being played, which makes complete sense if you're only playing one sound, but I think there's room for docs on selecting a speaker sample rate independent of any of the files as well as how you might select that and how to go about ensuring all of your files play as they're intended. It might even be worth having a func |
This has GOT to be a bug, but just not with I ran into this same issue. I cannot use ANY package to which I import This is useless code, as it doesn't produce any output or fatal error or panics:
Can't even play a tone from the tone-player example in this repo.
I'd expect a failure at the least.... Not just ... nothing. After much time, it seems that the importation of
On an M1 Mac. Link: ebitengine/oto#233 |
Hey, you are very disrespectful in the linked issue and don't seem to help us debug the problem in any meaningful way up untill now. You said to have moved on to using a different project. So I won't be helping you with this further. Goodbye |
Thanks. Yes, I got a bit annoyed and I regret that. As I stated early on
there, I am thankful for the code y’all spent time and energy writing so
people could have it for free. Please don’t mistake the annoyance for not
being thankful. The main reason for my heat tonight was not being heard
after reporting something. The code still hangs for me on loading speaker.
Already moved on though. People just don’t like to be called out, and that
happened on both sides, so nobody was happy. I regret that too. Thanks
again for the note.
…On Sun, Mar 3, 2024 at 3:26 AM Mark Kremer ***@***.***> wrote:
Hey, you are very disrespectful in the linked issue and don't seem to help
us debug the problem in any meaningful way up untill now.
You said to have moved on to using a different project. So I won't be
helping you with this further. Goodbye
—
Reply to this email directly, view it on GitHub
<#145 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF632FIB5XRHY6NXK3CQTLDYWLNFBAVCNFSM6AAAAABCLGCZIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGA4DKMBQGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Came back to this for a few minutes today, to make sure there was actually an issue still there... Seems to be. This file represents a program that produces logs and completes:
But this one runs, never completes, and doesn't log anything:
The importation of
Versions:
Again, I have a workaround, but If I'm seeing it, then other people are. Figured you would like to know. Sorry about being a douche last weekend. |
So the speaker package doesn't really do anything until
Could you try this with the verbose build option to see what it hangs on if it does? |
cd examples/tone-playerRun.
No output.Build.
Build is completed immediately.
No output.Result.Gave each 10 minutes. |
Could you run the following snippets with package main
import (
"fmt"
"github.com/gopxl/beep"
"github.com/gopxl/beep/speaker"
)
func init() {
fmt.Println("init()")
}
func main() {
fmt.Println("main() start")
fmt.Println("speaker.Init()")
err := speaker.Init(beep.SampleRate(41000), 4100)
if err != nil {
panic(err)
}
fmt.Println("main() end")
} package main
import (
"fmt"
_ "github.com/gopxl/beep/speaker"
)
func init() {
fmt.Println("init()")
}
func main() {
fmt.Println("main()")
} package main
import (
"fmt"
_ "github.com/ebitengine/oto/v3"
)
func init() {
fmt.Println("init()")
}
func main() {
fmt.Println("main()")
} package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Printf(
"Hello world from %s/%s\n",
runtime.GOOS,
runtime.GOARCH,
)
} package main
import (
"fmt"
_ "github.com/ebitengine/purego"
_ "github.com/ebitengine/purego/objc"
)
func init() {
fmt.Println("init()")
}
func main() {
fmt.Println("main()")
} package main
import (
"fmt"
_ "github.com/ebitengine/purego/objc"
)
func init() {
fmt.Println("init()")
}
func main() {
fmt.Println("main()")
} |
Since no-one answered and I have the same issue here are my results, running on mac OS Big Sur 11.7.10 on a Intel Macbook Pro Late 2014. TL;DR:Only scenario 4 exits normally, all other ones hang indefinitely and after 5 minutes I did a
2 .
3 .
4 .
5 .
6 .
|
Interesting: when I downgrade all the way to Scenarios 1,2 and 4 do finish, and the first tutorial also works... from |
Thanks for your help!! In Beep v1.2 we've upgraded from Oto <1 to 3. From the output above I think it's save to say that we've narrowed down to be somewhere in I have created an issue in the purego repo (ebitengine/purego#224). It would be great if anyone experiencing this issue could help out there if they have questions. :) |
Found a workaround! TL;DR - manually set purego version to v0.7.0 after
|
Would upping purego's version here fix it? This is actually my first time trying to create an application with Golang, pls forgive me my noobness :) |
You can update a dependency like so EDIT: I was actually able to reproduce the issue with the current beep version #151 does fix it for me. |
Merged 👍 I assume this is fixed now but if anyone still has troubles after updating, don't hesitate to re-open or comment. |
@domingguss maybe I'm a bit too hasty here. Can you confirm that it works now? |
Yes it works with |
OS version: 14.1.1 (Sonoma)
Running the to buffer or not to buffer example does not play any sound when enter is struck. No errors are displayed, it's simply silent.
The text was updated successfully, but these errors were encountered: