Audio playback stops when filechooser is created


#1

i have a (probably very simple to solve) problem:
i’ve atwo samplers playing default samples and want to assign a new sample to one of them while both are playing. i’ve an open-button creating a FileChooser. as soon as the file chooser is created, the audiocallback repeats the same buffer over and over. (for both samplers)

i had a version of my programm in which it worked, so i am confident that this can work. but i cannot figure out what i changed (and i don’t use svn, but i’ll start using svn today, i promise!).

but anyway would be nice to not WHY this happens (not only what i changed).
so what’s a possible reason for the audiocallback to stop playing new material and instead repeating the prevoius buffer, when the file chooser is opened?

thank’s a lot!

edit: as soon as the FileChoosers browseForFileToOpen () method is called, the audio stumbles.


#2

sounds like you’re doing the audio playback in the UI thread so whenever you open a modal dialog the audio cannot get to the soundcard anymore and the sound card driver starts repeating its nternal buffer.


#3

thanks for the hint.
i have a main component, which holds all the gui stuff and an “audioSystem” object. the audioSystem class derives from audioDeviceIOCallback and does all my audio stuff.
i thought in this case, it would work more or less automatically… :smiley: (this is how i saw it in the juce demo app audioDemo…).
how can i decouple the audio stuff from the ui callback?


#4

i found out, where something is going badly wrong. but i did not figure how and where exactly.
it’s about a bunch of buttons whose state i want to change (in my AudioDeviceIOcallback). i have a pointer to these buttons in my audioSystem class, so i access them there. but debug gave me some assertions about thread safety, and the advice to use a MessageManagerLock.
when i don’t use the MessageManagerLock, i’ve no problem. i didn’t get it yet… but i will :smiley:

edit: okay. i thought about it and i guess, passing a pointer to a gui component and accessing it from the audiocallback is a bad idea. i looked into the documentation and tried using an ActionListener and ActionBroadcaster instead. works. so simply. :slight_smile:
(i’m still unsure if an asyncUpdater would be a better choice? i did not understand the big difference yet, but i’ll simply try out)