-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add Android audio input support to JSynAndroidAudioDeviceManager #20
Comments
Sorry for the late response and thanks so much for testing out Android mode! I'm not sure what exactly the problem is but can give you some pointers: the only Android-specific class is processing-sound/src/processing/sound/JSynAndroidAudioDeviceManager.java Lines 128 to 138 in bdb59a9
My experience with Android audio is limited, but something parallel to the start() method of the corresponding AndroidAudioOutputStream sub-class should probably work:
Let me know if you need any more help! |
Hi I have the same issue could you please help me how to fix it? |
I found JSyn's Android sample code. It is not encouraging: It says "JSyn audio input not implemented on Android.". |
This should be working with Calsign/processing-sound@d3f973d. The only thing needed is setting the RECORD_AUDIO permission, which the AudioInput example does not currently do. I am looking into this now. |
Created a new, Android-specific "AudioInputAndroid" example with Calsign/processing-sound@96eb20b. I don't know of a way to use one example for both desktop and Android because Android requires requesting the RECORD_AUDIO permission, but desktop does not support Android mode's permission requesting functionality. I think this is complete and will submit a PR pending approval from @kevinstadler. |
Support audio input on Android (implements #20)
This looks fantastic, thank you very much! One question, do you think it would be feasible to include the step of requesting Audio permission in the |
I've looked into this a bit more:
|
@Calsign I have added some code to Do you think the warning message as it is printed right now is meaningful/useful? What currently happens when the user instantiates |
Full library build also available from here now, but not yet pushed to Processing contribution manager: https://github.com/processing/processing-sound/releases/tag/v2.2.0 |
Quick note: It looks like the modified ant build script correctly sets up I don't think the current check is quite right. There are two components to requesting a permission, and they are both required, it is not one or the other: the permission must be specified in the manifest, and it must be granted at runtime by the user - this only has to happen the first time that the app is run, though, assuming that the user accepts the permission. If the permission is not granted in the manifest and the sketch tries to use it (by creating the AudioRecord object), the sketch crashes with a stack trace that is not helpful to the average user. If the permission is granted in the manifest but not at runtime, the sketch crashes with the same message. This happens even if the dialog is presented correctly but the user declines to grant the permission. There is no way to avoid the user needing to specify the permission in the manifest (typically through the permissions selector dialog), I don't think it is possible for the library to add anything to the manifest. For this, I think the best we can do is print a warning telling the user to add the permission. As for runtime permissions - like you said, Processing's I think the issues with runtime permission requests could be remedied if Processing's Android mode included a library callback method for Other libraries, like Ketai, make no attempt to handle permissions for the user of the library. I think it would be nice to hide away this functionality, but it would create a lot of messiness that it is perhaps better to do without. There is a good explanation of how to manage permissions on the Android Processing site that users can be pointed to. I think the best solution would be as follows: Check for permission access in AudioIn and print a warning message if it is not granted, as you have done already. That warning message should say that both the manifest and runtime requests are necessary. If the permission is not granted, in addition to printing the warning, don't initialize the AudioIn (to prevent crash). There are perhaps legitimate cases where the user does not want to grant the microphone permission, but there are still other features of the app that are still usable even with a silenced microphone input. I will go ahead and implement this approach and test thoroughly. @kevinstadler let me know if this sounds reasonable or if there are further changes necessary. |
@kevinstadler I am having difficulty figuring out what to do if the permission is not granted. There should be some way to provide a dummy microphone input for this case, but I am not sure how this should be done. The problem is that it is still crashing, and the warning message is not appearing, perhaps because the warning message is printed too close to the crash. |
Ah yes indeed, I didn't want to force people to re-download all dependencies every time so
Blocking until the user makes a selection sounds ideal to me, could we not just do another call to
Yes that all sounds good to me!
Hmmm, could you post the stack trace that results when the permission is not granted? If we find a way to check that permission has not been granted (either by calling |
I guess the best way to handle this is to just throw our own exception with a descriptive error message. I have implemented this in PR #36. |
That looks good indeed, thank you very much! I'll put the 2.2.0 build up later today, it might take another couple of days before it hits the Processing contribution manager to be available for everyone. |
Hey, this library looks like great work and I'm super excited to see that it is compatible with Android!
I have tried all of the examples in Android mode, and all of them work great with the exception of the AudioInput example. When running the sketch on my device, I get the following stack trace:
I was wondering if this was an Android permissions issue, so I modified the example to request the
RECORD_AUDIO
permission, but I still got the same error message.I don't know how much you intend to support Android mode, but the degree to which things do work is already quite impressive and a significant improvement over the previous lack of sound solutions for Android. In other words, it would be nice for audio input to work on Android, but if Java mode is more of a priority then that is understandable.
@kevinstadler I am willing to look into this issue myself, but I was wondering if you had any insight into what the issue is because you obviously have more experience with this project.
The text was updated successfully, but these errors were encountered: