检查pcm的音量javaJDA

问题描述

我想检查PCM的音量。 这就是我获取PCM的方式。

@Override
public void handleUserAudio (UserAudio userAudio)
{
    byte[] data = userAudio.getAudioData(1.0f); // volume at 100% = 1.0 (50% = 0.5 / 55% = 0.55)
    queue.add(data);
    System.out.println(data);       
}

输出为:

[B@5a8c2df4
[B@7165b3b9
[B@14b88168

UserAudio类:

public class UserAudio
{
    protected User user;
    protected short[] audioData;

    public UserAudio(@Nonnull User user,@Nonnull short[] audioData)
    {
        this.user = user;
        this.audioData = audioData;
    }

    /**
     * The {@link net.dv8tion.jda.api.entities.User User} that provided the audio data.
     *
     * @return Never-null {@link net.dv8tion.jda.api.entities.User User} object.
     */
    @Nonnull
    public User getUser()
    {
        return user;
    }

    /**
     * Provides 20 Milliseconds of combined audio data in 48KHz 16bit stereo signed BigEndian PCM.
     * <br>Format defined by: {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#OUTPUT_FORMAT AudioReceiveHandler.OUTPUT_FORMAT}.
     * <p>
     * The output volume of the data can be modified by the provided {@code `volume`} parameter. {@code `1.0`} is considered to be 100% volume.
     * <br>Going above {@code `1.0`} can increase the volume further,but you run the risk of audio distortion.
     *
     * @param  volume
     *         Value used to modify the "volume" of the returned audio data. 1.0 is normal volume.
     *
     * @return Never-null byte array of PCM data defined by {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#OUTPUT_FORMAT AudioReceiveHandler.OUTPUT_FORMAT}
     */
    @Nonnull
    public byte[] getAudioData(double volume)
    {
        return OpusPacket.getAudioData(audioData,volume);
    }
}

所以我想这个“ [B @ 5a8c2df4”是一个PCM。我想检查一下: 伪代码

if (volume==on full blast) {
    sendUserMessage("You are too loud!")
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)