kcat/openal-soft

When I set the position of the source, the sound strength doesn't change at all

wzhengsen opened this issue · 2 comments

The out put:

[ALSOFT] (II) Initialized backend "wasapi"
[ALSOFT] (II) Added "wasapi" for playback
[ALSOFT] (II) Added "wasapi" for capture
[ALSOFT] (II) Opening default playback device
[ALSOFT] (II) Got device "扬声器 (Realtek(R) Audio)", "{63A35909-983C-47D5-81DF-7838583AE7BD}", "{0.0.0.00000000}.{63a35909-983c-47d5-81df-7838583ae7bd}"
[ALSOFT] (II) Got device "耳机 (xx 的 Buds2)", "{68359639-0BC8-4BAF-AAAB-0671D3D38C88}", "{0.0.0.00000000}.{68359639-0bc8-4baf-aaab-0671d3d38c88}"
[ALSOFT] (II) Got device "Microphone Array (适用于数字麦克风的英特尔® 智音技术)", "{29BE8950-B9A7-4814-ACBB-5BAEE252CA74}", "{0.0.1.00000000}.{29be8950-b9a7-4814-acbb-5baee252ca74}"
[ALSOFT] (II) Got device "耳机 (xx 的 Buds2)", "{7C4C7EF9-0892-4AD2-8C74-86749D843A4E}", "{0.0.1.00000000}.{7c4c7ef9-0892-4ad2-8c74-86749d843a4e}"
[ALSOFT] (II) Starting message loop
[ALSOFT] (II) Got message "Open Device" (0x0000, this=00000186C99FFFF0, param="")
[ALSOFT] (II) Created device 00000186C9C597B0, "OpenAL Soft on 耳机 (xx 的 Buds2)"
[ALSOFT] (II) Pre-reset: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Got message "Reset Device" (0x0001, this=00000186C99FFFF0, param="")
[ALSOFT] (II) Device mix format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 48000
    AvgBytesPerSec = 384000
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Requesting playback format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 48000
    AvgBytesPerSec = 384000
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Post-reset: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Searching D:\Repos\xx\build\Test\Debug\*.mhr
[ALSOFT] (II) Searching C:\Users\xx\AppData\Roaming\openal\hrtf\*.mhr
[ALSOFT] (II) Searching C:\ProgramData\openal\hrtf\*.mhr
[ALSOFT] (II) Adding built-in entry "!1_Built-In HRTF"
[ALSOFT] (II) Loading !1_Built-In HRTF...
[ALSOFT] (II) Detected data set format v3
[ALSOFT] (II) Loaded HRTF Built-In HRTF for sample rate 48000hz, 64-sample filter
[ALSOFT] (II) 1st order + Full HRTF rendering enabled, using "Built-In HRTF"
[ALSOFT] (II) Channel config, Main: 4, Real: 2
[ALSOFT] (II) Allocating 6 channels, 24576 bytes
[ALSOFT] (II) Min delay: 7.75, max delay: 32.50, FIR length: 64
[ALSOFT] (II) New max delay: 24.75, FIR length: 89
[ALSOFT] (II) Max sources: 256 (255 + 1), effect slots: 64, sends: 2
[ALSOFT] (II) Dithering disabled
[ALSOFT] (II) Output limiter disabled
[ALSOFT] (II) Fixed device latency: 0ns
[ALSOFT] (II) Got message "Start Device" (0x0002, this=00000186C99FFFF0, param="")
[ALSOFT] (II) Post-start: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Increasing allocated voices to 256
[ALSOFT] (II) Created context 00000186D206F830
[ALSOFT] (II) Increasing allocated voice properties to 32

A snippet from my code:

::ALfloat ori[] = {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f};
::alListener3f(AL_POSITION, 0.f, 0.f, 0.f);
::alListenerfv(AL_ORIENTATION, ori);

::ALuint buffer = GetMyMp3Buffer(); //No details are provided, but it does get a buffer

::ALuint source = AL_NONE;
::alGenSources(1, &source);
::alSourcei(source, AL_BUFFER, buffer);

// No matter what value I set the position to, 
// the strength of the sound from my headphones is the same on both sides without any change.
::alSource3f(source, AL_POSITION, 3.f, 0.f, 0.f); 

::alSourcePlay(source);

::ALint state = AL_INITIAL;
while (true) {
    ::alGetSourcei(source, AL_SOURCE_STATE, &state);
    if (state == AL_STOPPED) {
        break;
    }
    std::this_thread::sleep_for(20ms);
}

I am a beginner to OpenAL and would be very grateful for your help.
Am I missing some important details?

Make sure the buffer contains mono samples, or use an extension.

@bibendovsky Yes, it works correctly with the extension, thanks.