Skip to content
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

Buggy interaction with Gtk.jl #105

Open
JeffFessler opened this issue Nov 27, 2021 · 2 comments
Open

Buggy interaction with Gtk.jl #105

JeffFessler opened this issue Nov 27, 2021 · 2 comments

Comments

@JeffFessler
Copy link

The following code works as expected for me in a fresh Julia session if the first line is commented out.

#using Gtk # uncommenting this causes problems with wavplay!?
using WAV: wavplay
S = 8192
x = cos.(2pi*(1:S÷2)*440/S)
y = cos.(2pi*(1:S÷2)*660/S)
wavplay(x, S)
wavplay(y, S)

But uncommenting the first line causes intermittent problems, usually that the first tone x is never played.
I then have to restart Julia and comment out the first line for it to work again.

I am using Julia v1.6.4 with WAV v1.1.1 and Gtk v1.1.9, under MacOS Mojave 10.14.6.

I suspect that the issue is that both Gtk and WAV use a ccall with some type of run loop, like

CFRunLoopRun()

and perhaps those interfere with each other, but I am surprised that merely adding using Gkt without calling any Gtk functions would cause such interference.

I am preparing to teach a course where students make a simply GUI-based synthesizer using Gtk buttons that produce tones when clicked, so I very much hope there is a solution to this.

@dancasimiro
Copy link
Owner

dancasimiro commented Nov 28, 2021

Hi Jeff, thanks for reporting this issue. I suspect that your hunch is correct and the WAV and Gtk code must coordinate how to invoke the core foundation run loop here. Does everything work if you comment out the WAV.jl invocation on line 374 and the "dispose" function call on line 375?

@JeffFessler
Copy link
Author

When I comment out those two lines, in both julia v1.6.4 and v1.7, both tones x and y are played (essentially?) simultaneously rather than sequentially! That is a potentially useful "feature" but is not what I was expecting. But maybe it helps you figure out what to try next?

If I comment out 375, but leave in 374, then it hangs (with GTK).
If I comment out 374 and leave in 375, then I get almost no sound (tiny blip the first time), but it does not hang.

Just to let you know, I have found an alternative for now using PortAudio that seems to play OK with Gtk. See https://github.com/JeffFessler/Sound.jl. So this is no longer urgent, but still it would be useful if wavplay would work with Gtk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants