Files
dl_old/dl/system/dl_audio_loader.h
T
2024-01-03 15:16:54 +08:00

46 lines
778 B
C++

/**
* @file dl_audio_loader.h
* @brief 加载音频文件
*
*
* @version 1.0
* @author lveyou
* @date 22-08-26
*
* @note 支持格式:wav、ogg
*/
#pragma once
#include <string>
#include "memory/dl_buffer.h"
namespace dl
{
class AudioLoader
{
public:
struct PCM
{
int _numChannel;//通道数 1,2 AL_FORMAT_MONO8,AL_FORMAT_STEREO8
int _bitPerSample;//采样数 8,16
Buffer _buf;
size_t _freq;//采样率
};
static bool ReadWav(std::string_view path_name, PCM& pcm);
static bool ReadOgg(std::string_view path_name, PCM& pcm);
static bool ReadFlac(std::string_view path_name, PCM& pcm);
};
//16字节
struct WAVEFormat
{
int16_t audioFormat;
int16_t numChannels;
int32_t sampleRate;
int32_t byteRate;
int16_t blockAlign;
int16_t bitsPerSample;
};
}