1

mp3 サウンド ファイルを読み込んで Windows 8 アプリ内から再生するにはどうすればよいですか? 何をしなければならないかを理解するのに十分なチュートリアルが見つかりませんか?

これまでにできたことは次のとおりです。

Sound.h

#pragma once

#include <xaudio2.h>

class Sound
{
    Sound( );
    void Initialize();
    void Play( wchar_t fileName );
private:
    interface IXAudio2* audioEngine;
    interface IXAudio2MasteringVoice* masteringVoice;
    IXAudio2SourceVoice* sourceVoice;
    WAVEFORMATEX* format;
};

サウンド.cpp

#include "pch.h"
#include "Sound.h"

Sound::Sound()
{}

void Sound::Initialize()
{
    // Create the XAudio2 Engine
    UINT32 flags = 0;

    XAudio2Create( &audioEngine, flags );

    // Create the mastering voice
    audioEngine->CreateMasteringVoice(
        &masteringVoice,
        XAUDIO2_DEFAULT_CHANNELS,
        48000
        );

    //
    // Create the source voice
    //
    audioEngine->CreateSourceVoice(
        &sourceVoice,
        format,
        0,
        XAUDIO2_DEFAULT_FREQ_RATIO,
        nullptr,
        nullptr,
        nullptr
        );
}

void Sound::Play( wchar_t fileName )
{
    // To do:
    // Load sound file and play it
}

自分のしたことが正しいかどうかさえわからない…

4

1 に答える 1