Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DevTastisch

Pages: [1]
1
Other Support / Re: parallel pcm audio streams minecraft 1.8.9 problem
« on: March 02, 2020, 01:19:48 PM »
Done, should be in your inbox.

2
Other Support / Re: parallel pcm audio streams minecraft 1.8.9 problem
« on: March 01, 2020, 12:27:13 PM »
okay I noticed something very very weird. I am not sure if I am doing something wrong here or if it is your library.
I created a little dummy project to experiment with the sound system and it looks like this atm:

- Note that it is not the final usecase to play raw pcm files, but little pcm frames after one and another. -
But the problem is the same

Code: [Select]
    File pcmData = ...;
    ScheduledExecutorService executorService = Executors.newScheduledThreadPool(0);

    SoundSystemConfig.addLibrary(LibraryJavaSound.class);
    SoundSystemConfig.setCodec("wav", CodecWav.class);
    SoundSystemConfig.setNumberStreamingChannels(5);
    SoundSystemConfig.setNumberNormalChannels(27);

    SoundSystem mySoundSystem = new SoundSystem();

    mySoundSystem.rawDataStream(
        new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000, 16, 1, 2, 48000, false),
        false,
        "test1",
        0,
        0,
        0,
        SoundSystemConfig.ATTENUATION_ROLLOFF,
        SoundSystemConfig.getDefaultRolloff());

    mySoundSystem.rawDataStream(
        new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000, 16, 1, 2, 48000, false),
        false,
        "test2",
        0,
        0,
        0,
        SoundSystemConfig.ATTENUATION_ROLLOFF,
        SoundSystemConfig.getDefaultRolloff());

    executorService.submit(
        () -> {
          try {
            mySoundSystem.feedRawAudioData("test1", new byte[] {});
            mySoundSystem.feedRawAudioData("test1", Files.toByteArray(pcmData));
            mySoundSystem.play("test1");
          } catch (IOException e) {
            e.printStackTrace();
          }
        });

    executorService.schedule(
        () -> {
          try {
            mySoundSystem.feedRawAudioData("test2", new byte[] {});
            mySoundSystem.feedRawAudioData("test2", Files.toByteArray(pcmData));
            mySoundSystem.play("test2");
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        },
        2,
        TimeUnit.SECONDS);

While doing this, I would expect the file to be played once at the beginning and a second time starting 2 seconds after the first in parallel. But it does not. It does not even cut off the other source, but rather waits until the first is finished until it finally plays the second time. I have also notices the feedRawAudioData method is blocking when trying to play the second sound until the first one has finished.

This behavior is exactly the same I have noticed previously with pcm audio chunks in my voicechat.

Oh and I started debugging if both sources are playing on the same channel: They absolutely don't. They all have their own channel how it should be.
It looks like the whole command queue thread of the sound system is interrupted while playing some audio there.

I really dont think this was done on purpose.

3
Other Support / Re: parallel pcm audio streams minecraft 1.8.9 problem
« on: February 29, 2020, 03:22:56 PM »
Hey,

thanks for your fast reply,
I dont know how many channels I have configured. I didn't change that. So it should be the default.

1) I tried playing streams from the same thread and the same problem occurs exactly the way it does while multithreading.

2) I only experience that behavior while using streaming sources

4
Other Support / parallel pcm audio streams minecraft 1.8.9 problem
« on: February 27, 2020, 04:44:48 AM »
Hey,

I am currently working on an Opus codec based voicechat modification for minecraft 1.8.9.
While preparing an audio stream for a player I do the following:

this.sndSystem.rawDataStream(audioFormat, true, audioSourceName, 0f, 0f, 0f, SoundSystemConfig.ATTENUATION_LINEAR, this.voiceChat.getSurroundRange());


When receiving audio data from another client I try to play it with this:

this.sndSystem.feedRawAudioData(audioSourceName, latencyBuffer.get());
this.sndSystem.play(audioSourceName);

And so far this works like a charm, while the client only receives one single audio stream.
But as soon as I start streaming a second audio from another client, that system fails.

It feels like this method call is synchronized. It is clearly to hear, that one audio chunk from stream1 is played, and then one from stream2 and from there it goes in a loop.

I captured my test. At first you can hear a 100hz sin wave for a few seconds. This sounds very clear.
After that you can hear a 1000hz sin wave. This is very clear too. In the End both sounds are combined.

Both sounds do have different source names and are called from different threads. But it is clear to hear that the streams are not merged or something like that. It is more like a race condition between them who can playback the audio chunk first.

I know minecraft 1.8.9 is quite old and there are probably some library updates since release, but I couldn't find any documentation to that so I thought I ask here for some help.

Pages: [1]