You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnsupportedOperationException: Cannot create AudioRecord in Android mode #37
Since doing the recent SDK update in Processing for Android:
The Sound Library is no longer functioning in Android mode. I get this error:
java.lang.UnsupportedOperationException: Cannot create AudioRecord
at android.media.AudioRecord$Builder.build(AudioRecord.java:626)
at processing.sound.JSynAndroidAudioDeviceManager$AndroidAudioInputStream.start(Unknown Source:66)
at com.jsyn.engine.SynthesisEngine$EngineThread.run(Unknown Source:29)
I installed Processing 3 on 2 windows 10 PCs and a windows 7 PC and received the same error.
As a test I tried the “SimplePlayback” Processing 3 Sound example.
It worked in JAVA mode; giving this INFO:
Jun 11, 2019 12:32:42 PM com.jsyn.devices.javasound.JavaSoundAudioDevice
INFO: JSyn: default output latency set to 80 msec for Windows 10
Here is the sketch, slightly modified:
import processing.sound.*;
SoundFile soundfile;
void setup() {
//fullScreen();
size(640, 360);
background(255);
soundfile = new SoundFile(this, “vibraphon.aiff”);
println(“SFSampleRate= " + soundfile.sampleRate() + " Hz”);
println(“SFSamples= " + soundfile.frames() + " samples”);
println(“SFDuration= " + soundfile.duration() + " seconds”);
soundfile.loop();
}
void draw() {
float playbackSpeed = map(mouseY, 0, width, 0.25, 4.0);
soundfile.rate(playbackSpeed);
float panning = map(mouseX, 0, width, -1.0, 1.0);
soundfile.pan(panning);
}
void mouseDragged(){
float amplitude = map(mouseY, 0, height, 0.2, 1.0);
soundfile.amp(amplitude);
}
I should mention that other than no sound, in Android mode, the apps work fine. I've been using the Sound library for months in Android mode with no issues until my recent use of the SDK Updater in Processing for Android.
Can you help me?
@markcosmic thanks for reporting! Could you please call Sound.list() from one of your Android sketches and post the output here?
@Calsign any idea what's going on there? I've got a hunch that either the device doesn't support capturing audio at all (hence the UnsupportedOperationException), or maybe the chosen device simply doesn't have any input ports, in which case AndroidAudioInputStream.start() shouldn't try to instantiate the AudioRecord (if someone attempted to create an AudioIn down the line an appropriate error message should be thrown in that case).
Thanks for getting back to me. The error this thread now refers to is interesting because the sketch I listed in my original thread only uses playback. I get the same error if I change “import processing.sound.*” to “import processing.sound.SoundFile”. I am not setting up to audio record, nor am I trying to. I’m just trying to get the playback function to work as it did before I used the SDK updater. In using Sound.list(), the emulator reports:
max input 1
max output 1
Along with the mentioned error
@markcosmic yeah I can see that, I'll have a look. I'm also a bit confused why you're still getting the INFO: JSyn: default output latency set to 80 msec for Windows 10 message though, that one should've been removed some versions ago. Can you tell me what version of Processing, Android Mode as well as the Sound library you are running?
@markcosmic this issue should be fixed with Sound library version 2.2.1, which will become available from the contribution manager in the next couple of days. In the meantime you could already download the new version from here: https://github.com/processing/processing-sound/releases/download/v2.2.1/sound.zip
Simply extract the zip into your Processing/libraries/ folder (on MacOS this is usually in your Documents), replacing the sound folder that's already there. Please let me know if you manage to test the new version, and if it fixes your problem! @Calsign the new version also adds support for selecting the Android audio input device from within the sketch. In the process I changed the default device from MIC to DEFAULT, please let me know if this breaks anything for your sketches!
Ok, been testing the new update 2.2.1. In Java Mode I still get this INFO message:
Jun 24, 2019 3:22:06 PM com.jsyn.devices.javasound.JavaSoundAudioDevice
INFO: JSyn: default output latency set to 80 msec for Windows 10
In Android Mode the sketch doesn't load quickly or smoothly. Using the above listed sketch "SimplePlayBack", the sound starts before the app is visible on the device emulator. When I click the stop button in the Processing IDE the sound keeps playing. The sound stop when I quit the emulator. If I try to run the sketch in Java mode while the sketch is still playing sound from Android Mode, sound resumes when I quit the sketch from Java Mode. Java Mode stops the sound correctly when I stop the sketch. The sound keeps playing in Android Mode even when I start a different sketch in the emulator.
Does it just not load smoothly or is it also not playing back smoothly? Either way if this is limited to the Android device emulator then there's probably nothing that can be done on the sound library side. Have you tried running the sketch on an actual Android device?
It's true that playback currently does not stop when the sketch is backgrounded on Android (or stopped from the Processing IDE). When running on an actual device the sound only stops when the app is killed on the device itself. If we want to implement the default behaviour to be pausing the playback while the sketch is backgrounded, the appropriate code will have to go here:
I'm a bit confused why the sound keeps playing on the emulator though when the sketch is stopped since dispose() seems to be implemented correctly. @codeanticode do you know more about how these callback functions are invoked differently on the device emulator in comparison to an actual Android system?
I don't know that the callback functions are invoked differently on the device emulator in comparison to an actual Android device, but they act the same. The sound playback did not pause when the sketch was backgrounded on the Android device I tested on. The sound only stopped when the app was killed on the device. Same as the emulator
I honestly don't think the issue is with the Processing Sound library. It seemed to be working fine until the latest Android SDK update. I believe the issue is in the SDK and Google needs to fix it. It's this simple...
Sound Working... Android SDK update... Sound Not working...
Activity
kevinstadler commentedon Jun 19, 2019
@markcosmic thanks for reporting! Could you please call
Sound.list()from one of your Android sketches and post the output here?@Calsign any idea what's going on there? I've got a hunch that either the device doesn't support capturing audio at all (hence the
UnsupportedOperationException), or maybe the chosen device simply doesn't have any input ports, in which caseAndroidAudioInputStream.start()shouldn't try to instantiate theAudioRecord(if someone attempted to create anAudioIndown the line an appropriate error message should be thrown in that case).[-]android mode issue[/-][+]UnsupportedOperationException: Cannot create AudioRecord in Android mode[/+]markcosmic commentedon Jun 19, 2019
Thanks for getting back to me. The error this thread now refers to is interesting because the sketch I listed in my original thread only uses playback. I get the same error if I change “import processing.sound.*” to “import processing.sound.SoundFile”. I am not setting up to audio record, nor am I trying to. I’m just trying to get the playback function to work as it did before I used the SDK updater. In using Sound.list(), the emulator reports:
max input 1
max output 1
Along with the mentioned error
kevinstadler commentedon Jun 20, 2019
@markcosmic yeah I can see that, I'll have a look. I'm also a bit confused why you're still getting the
INFO: JSyn: default output latency set to 80 msec for Windows 10message though, that one should've been removed some versions ago. Can you tell me what version of Processing, Android Mode as well as the Sound library you are running?markcosmic commentedon Jun 20, 2019
I'm using:
Processing 3.5.3
Android Mode 4.0.4
Sound 2.2.0
kevinstadler commentedon Jun 23, 2019
@markcosmic this issue should be fixed with Sound library version 2.2.1, which will become available from the contribution manager in the next couple of days. In the meantime you could already download the new version from here: https://github.com/processing/processing-sound/releases/download/v2.2.1/sound.zip
Simply extract the zip into your
Processing/libraries/folder (on MacOS this is usually in yourDocuments), replacing thesoundfolder that's already there. Please let me know if you manage to test the new version, and if it fixes your problem!@Calsign the new version also adds support for selecting the Android audio input device from within the sketch. In the process I changed the default device from
MICtoDEFAULT, please let me know if this breaks anything for your sketches!markcosmic commentedon Jun 23, 2019
Thank you
markcosmic commentedon Jun 24, 2019
Ok, been testing the new update 2.2.1. In Java Mode I still get this INFO message:
Jun 24, 2019 3:22:06 PM com.jsyn.devices.javasound.JavaSoundAudioDevice
INFO: JSyn: default output latency set to 80 msec for Windows 10
In Android Mode the sketch doesn't load quickly or smoothly. Using the above listed sketch "SimplePlayBack", the sound starts before the app is visible on the device emulator. When I click the stop button in the Processing IDE the sound keeps playing. The sound stop when I quit the emulator. If I try to run the sketch in Java mode while the sketch is still playing sound from Android Mode, sound resumes when I quit the sketch from Java Mode. Java Mode stops the sound correctly when I stop the sketch. The sound keeps playing in Android Mode even when I start a different sketch in the emulator.
kevinstadler commentedon Jun 25, 2019
Does it just not load smoothly or is it also not playing back smoothly? Either way if this is limited to the Android device emulator then there's probably nothing that can be done on the sound library side. Have you tried running the sketch on an actual Android device?
It's true that playback currently does not stop when the sketch is backgrounded on Android (or stopped from the Processing IDE). When running on an actual device the sound only stops when the app is killed on the device itself. If we want to implement the default behaviour to be pausing the playback while the sketch is backgrounded, the appropriate code will have to go here:
processing-sound/src/processing/sound/Engine.java
Lines 240 to 253 in 919be00
I'm a bit confused why the sound keeps playing on the emulator though when the sketch is stopped since
dispose()seems to be implemented correctly. @codeanticode do you know more about how these callback functions are invoked differently on the device emulator in comparison to an actual Android system?markcosmic commentedon Jun 26, 2019
I don't know that the callback functions are invoked differently on the device emulator in comparison to an actual Android device, but they act the same. The sound playback did not pause when the sketch was backgrounded on the Android device I tested on. The sound only stopped when the app was killed on the device. Same as the emulator
markcosmic commentedon Jun 26, 2019
I honestly don't think the issue is with the Processing Sound library. It seemed to be working fine until the latest Android SDK update. I believe the issue is in the SDK and Google needs to fix it. It's this simple...
Sound Working... Android SDK update... Sound Not working...