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

Cannot switch between multiple audio devices #125

Open
philburk opened this issue Apr 24, 2024 · 3 comments
Open

Cannot switch between multiple audio devices #125

philburk opened this issue Apr 24, 2024 · 3 comments

Comments

@philburk
Copy link
Owner

This was reported by Davide Mauro. Thanks Davide.

On Windows 11, in our application we have multiple interfaces that can be selected, and we can select each interface once, if I say I go from 1 to 2, then back to 1, when I select 1 for the second time I get:

INFO: JSyn synthesis thread in finally code.
java.lang.RuntimeException: AudioInput stop attempted when no line created.
at com.jsyn.devices.javasound.JavaSoundAudioDevice$JavaSoundInputStream.stop(Unknown Source)
at com.jsyn.engine.SynthesisEngine$EngineThread.run(Unknown Source).

The process is stop for the current one, start for the new one.

The same code runs fine on Mac OS.

@philburk philburk changed the title Cannot switch between multiple interfaces Cannot switch between multiple audio devices Apr 24, 2024
@philburk
Copy link
Owner Author

More from Davide:

First time we start with the default:
private final Synthesizer synth = JSyn.createSynthesizer();
this.synth.setRealTime(true);
this.synth.start();

Then, if we want to change the device:
this.synth.stop();
We have a method that gives us a list of devices:
AudioDeviceManager audioManager =
AudioDeviceFactory.createAudioDeviceManager();
int numDevices = audioManager.getDeviceCount();
...

Then once we have the deviceID:
int deviceInputChannels = this.synth.getAudioDeviceManager().getMaxInputChannels(deviceID);
this.synth.start(44100,
deviceID,deviceInputChannels,AudioDeviceManager.USE_DEFAULT_DEVICE, 0);

@philburk
Copy link
Owner Author

There may be an issue with reusing a synth with different numbers of input and output channels.

@Murivan
Copy link

Murivan commented Apr 25, 2024

There may be an issue with reusing a synth with different numbers of input and output channels.

We not currently experiencing the problem BUT we have done a number of changes to both JSyn and jportaudio. This was prompted by another problem that we were experiencing.
Our target platform is Windows, so we were planning on using ASIO drivers. When we included the relevant portaudio implementation and jportaudio bindings we discovered that some audio cards were working and some were not.

Out of the box the application was working fine with an Audient ID 14 MKII and a RME Babyface FS, but not with a MOTU M4 or a Tascam Model 12, and ASIO 4ALL generic drivers.

The reported error is:
WaitForSingleObject() timed out in ReadStream()
java.lang.RuntimeException: Wait timed out
at com.portaudio.BlockingStream.readFloats(Native Method)
at com.portaudio.BlockingStream.read(BlockingStream.java:100)
at com.jsyn.devices.jportaudio.JPortAudioDevice$JPAInputStream.read(JPortAudioDevice.java:233)
at com.jsyn.devices.jportaudio.JPortAudioDevice$JPAInputStream.read(JPortAudioDevice.java:224)
at com.jsyn.engine.SynthesisEngine$EngineThread.run(SynthesisEngine.java:330)
Apr 25, 2024 8:45:04 AM com.jsyn.engine.SynthesisEngine$EngineThread run
INFO: JSyn synthesis thread in finally code.
WaitForSingleObject() timed out in StopStream()

We then modified JPortAudioDevice.java in JSyn from
private static final int FRAMES_PER_BUFFER = 128;
to
private static final int FRAMES_PER_BUFFER = 256;

Recompiling the library made the MOTU M4 (only with a specific set of parameters, screenshot included) and ASIO4ALL (but only with some interfaces, e.g. VB-Cable virtual driver) working, but still no luck with Tascam.
Further increasing the value did not lead to improvements.
image

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