use IXAudio2 to play sound mix?












1















I write a MFC project . I use IXAudio2 to play wav file.
my code is like this :



pSourceVoice->SubmitSourceBuffer( &buffer );

hr = pSourceVoice->Start( 0 );


but in this way I only can play one sound by a time. It must wait this .wav file play over. I can play the second file. How can I play the file I need and not wait for the first one is over, likes mixing sounds?
How can I achieve this function?










share|improve this question

























  • The Programming Guide explains that.

    – IInspectable
    Nov 21 '18 at 15:56
















1















I write a MFC project . I use IXAudio2 to play wav file.
my code is like this :



pSourceVoice->SubmitSourceBuffer( &buffer );

hr = pSourceVoice->Start( 0 );


but in this way I only can play one sound by a time. It must wait this .wav file play over. I can play the second file. How can I play the file I need and not wait for the first one is over, likes mixing sounds?
How can I achieve this function?










share|improve this question

























  • The Programming Guide explains that.

    – IInspectable
    Nov 21 '18 at 15:56














1












1








1








I write a MFC project . I use IXAudio2 to play wav file.
my code is like this :



pSourceVoice->SubmitSourceBuffer( &buffer );

hr = pSourceVoice->Start( 0 );


but in this way I only can play one sound by a time. It must wait this .wav file play over. I can play the second file. How can I play the file I need and not wait for the first one is over, likes mixing sounds?
How can I achieve this function?










share|improve this question
















I write a MFC project . I use IXAudio2 to play wav file.
my code is like this :



pSourceVoice->SubmitSourceBuffer( &buffer );

hr = pSourceVoice->Start( 0 );


but in this way I only can play one sound by a time. It must wait this .wav file play over. I can play the second file. How can I play the file I need and not wait for the first one is over, likes mixing sounds?
How can I achieve this function?







c++ audio mfc xaudio2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 13:06









DaFois

2,01941419




2,01941419










asked Nov 21 '18 at 12:45









fanrongqifanrongqi

61




61













  • The Programming Guide explains that.

    – IInspectable
    Nov 21 '18 at 15:56



















  • The Programming Guide explains that.

    – IInspectable
    Nov 21 '18 at 15:56

















The Programming Guide explains that.

– IInspectable
Nov 21 '18 at 15:56





The Programming Guide explains that.

– IInspectable
Nov 21 '18 at 15:56












1 Answer
1






active

oldest

votes


















0














You create one IXAudio2SourceVoice for each 'playing, active' sound you want at a time. Typically games will create a few hundred source voices to manage--beyond that the sound mix is typically too muddy to hear anyhow.



Game audio engines have a mix of 'one-shot' voices that just play-on-demand until they complete--at which point that frees up that source voice for use by another one-shot sound--, 'ambients' or 'music' voices that are manipulated as they play, and 3D audio positioned sounds which have to be updated every rendering frame to track the 3D rendering object they are emitted from.



If you submit the same audio data to two distinct IXAudio2SourceVoice instances, then you'll hear it being played twice, mixed together in real-time. Typically you won't start them at precisely the same instant because the result is just a louder version of the one sound. Normally they are started at different times so you get overlapped playback.



See XAudio2 Programming Guide, GitHub, and DirectX Tool Kit for Audio.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412339%2fuse-ixaudio2-to-play-sound-mix%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You create one IXAudio2SourceVoice for each 'playing, active' sound you want at a time. Typically games will create a few hundred source voices to manage--beyond that the sound mix is typically too muddy to hear anyhow.



    Game audio engines have a mix of 'one-shot' voices that just play-on-demand until they complete--at which point that frees up that source voice for use by another one-shot sound--, 'ambients' or 'music' voices that are manipulated as they play, and 3D audio positioned sounds which have to be updated every rendering frame to track the 3D rendering object they are emitted from.



    If you submit the same audio data to two distinct IXAudio2SourceVoice instances, then you'll hear it being played twice, mixed together in real-time. Typically you won't start them at precisely the same instant because the result is just a louder version of the one sound. Normally they are started at different times so you get overlapped playback.



    See XAudio2 Programming Guide, GitHub, and DirectX Tool Kit for Audio.






    share|improve this answer






























      0














      You create one IXAudio2SourceVoice for each 'playing, active' sound you want at a time. Typically games will create a few hundred source voices to manage--beyond that the sound mix is typically too muddy to hear anyhow.



      Game audio engines have a mix of 'one-shot' voices that just play-on-demand until they complete--at which point that frees up that source voice for use by another one-shot sound--, 'ambients' or 'music' voices that are manipulated as they play, and 3D audio positioned sounds which have to be updated every rendering frame to track the 3D rendering object they are emitted from.



      If you submit the same audio data to two distinct IXAudio2SourceVoice instances, then you'll hear it being played twice, mixed together in real-time. Typically you won't start them at precisely the same instant because the result is just a louder version of the one sound. Normally they are started at different times so you get overlapped playback.



      See XAudio2 Programming Guide, GitHub, and DirectX Tool Kit for Audio.






      share|improve this answer




























        0












        0








        0







        You create one IXAudio2SourceVoice for each 'playing, active' sound you want at a time. Typically games will create a few hundred source voices to manage--beyond that the sound mix is typically too muddy to hear anyhow.



        Game audio engines have a mix of 'one-shot' voices that just play-on-demand until they complete--at which point that frees up that source voice for use by another one-shot sound--, 'ambients' or 'music' voices that are manipulated as they play, and 3D audio positioned sounds which have to be updated every rendering frame to track the 3D rendering object they are emitted from.



        If you submit the same audio data to two distinct IXAudio2SourceVoice instances, then you'll hear it being played twice, mixed together in real-time. Typically you won't start them at precisely the same instant because the result is just a louder version of the one sound. Normally they are started at different times so you get overlapped playback.



        See XAudio2 Programming Guide, GitHub, and DirectX Tool Kit for Audio.






        share|improve this answer















        You create one IXAudio2SourceVoice for each 'playing, active' sound you want at a time. Typically games will create a few hundred source voices to manage--beyond that the sound mix is typically too muddy to hear anyhow.



        Game audio engines have a mix of 'one-shot' voices that just play-on-demand until they complete--at which point that frees up that source voice for use by another one-shot sound--, 'ambients' or 'music' voices that are manipulated as they play, and 3D audio positioned sounds which have to be updated every rendering frame to track the 3D rendering object they are emitted from.



        If you submit the same audio data to two distinct IXAudio2SourceVoice instances, then you'll hear it being played twice, mixed together in real-time. Typically you won't start them at precisely the same instant because the result is just a louder version of the one sound. Normally they are started at different times so you get overlapped playback.



        See XAudio2 Programming Guide, GitHub, and DirectX Tool Kit for Audio.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 24 '18 at 5:34

























        answered Nov 24 '18 at 5:28









        Chuck WalbournChuck Walbourn

        20.1k12549




        20.1k12549
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412339%2fuse-ixaudio2-to-play-sound-mix%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith