ofxPd icon indicating copy to clipboard operation
ofxPd copied to clipboard

background audio on android and back button issue

Open jyg opened this issue 3 years ago • 9 comments

Hi, I succeeded in building the pdExample of ofxPd (OF 11.0) with Android Studio 4.1.2. Is it possible to get the sound non interrupted when I want to switch to another application, by allowing background audio ? At the moment, when I press the 'Recent' button, the sound stops and android says that the pdExample does not respond. What did I miss ? Thanks

jyg avatar Mar 03 '21 10:03 jyg

I have no idea as I have not developed for Android. Probably ask @cuinjune or @cerupcat who have.

danomatika avatar Mar 03 '21 15:03 danomatika

Hi, I succeeded in building the pdExample of ofxPd (OF 11.0) with Android Studio 4.1.2.

Hi, sorry for bothering you with my question but did you have any issues with the C compiler? I'm using the same OF and AS version but I cannot build while using ofxPd

Thanks

mnlvqz avatar Mar 10 '21 00:03 mnlvqz

Apologies, I'm super bogged down with work right now.

Unfortunately, I've been using a pretty hacked-up version of OF/Libpd for Android since I've had a lot of Android audio issues (that still aren't quite stable).

I don't have anything that's easily shareable right now. Ultimately, I decided to not use OpenFrameworks AudioStreams since they had issues with things like background audio being choppy and went with using Oboe (https://github.com/google/oboe) which involved changing OFs build system as well (since Oboe's minimum requirements weren't supported by OF). 

That isn't to say the latest OF wouldn't work though. I'm on a fairly old version.

cerupcat avatar Mar 10 '21 01:03 cerupcat

@mnlvqz

Hi, sorry for bothering you with my question but did you have any issues with the C compiler? I'm using the same OF and AS version but I cannot build while using ofxPd

Hi, I had to modify some #include lines in libpd and pd sources, specifying relative paths more explicitly so that the compiler could find the resources.

jyg avatar Mar 10 '21 10:03 jyg

@cerupcat Thanks for your answer. Indeed, the use of ofSoundStreamSetup is problematic. I have to try the solution proposed here, but even with nb of inputs = 0, the app sounds glitchy when pressing home button

jyg avatar Mar 10 '21 10:03 jyg

I'd suggest checking on the main OF repo for an issue on ofSoundStream & Android as this is a general issue with OF and less ofxPd which only uses ofSoundStream.

Another approach is to use something like Oboe directly without bothering with ofSoundStream, then I don't think there is a need for any hacking if you are only using Oboe + libpd. The ofxPd wrapper itself doesn't use ofSoundStream except via the audio sample callbacks, but you can call those yourself via another audio API.

danomatika avatar Mar 10 '21 10:03 danomatika

@danomatika Thanks for your suggestion. I'll try to use another audio API. I need to use OF and ofxPd, since I want to include a pd external in my project, and as I'm a beginner with Java / Android.

jyg avatar Mar 11 '21 12:03 jyg

the use of ofSoundStreamSetup is problematic. I have to try the solution proposed here, but even with nb of inputs = 0, the app sounds glitchy when pressing home button

Home button issue solved : by following the solution proposed here (editing the manifest.xml file) AND by adding a line of code in ofApp.c, inside ofApp::setup() function : ofxAndroidRequestPermission(OFX_ANDROID_PERMISSION_RECORD_AUDIO); ofSoundStream works fine.

jyg avatar Mar 18 '21 09:03 jyg

Ok cool. Feel free to make a small PR adding info about this to the readme, perhaps in an Android-specific section.

danomatika avatar Mar 18 '21 09:03 danomatika

Closing for now.

danomatika avatar Nov 05 '22 01:11 danomatika