mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
Audio module, simple text rendering
This commit is contained in:
parent
e96fd909ea
commit
1770acbfef
15 changed files with 702 additions and 17 deletions
44
src/audio/audioutil.h
Normal file
44
src/audio/audioutil.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef SRC_AUDIO_AUDIOUTIL_H_
|
||||
#define SRC_AUDIO_AUDIOUTIL_H_
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include <AL/al.h>
|
||||
|
||||
#define alCheck() check_al_errors(__FILE__, __LINE__)
|
||||
|
||||
bool check_al_errors(const std::string& filename, const std::uint_fast32_t line);
|
||||
|
||||
bool load_wav_file_header(std::ifstream& file,
|
||||
std::uint8_t& channels,
|
||||
std::int32_t& sampleRate,
|
||||
std::uint8_t& bitsPerSample,
|
||||
ALsizei& size);
|
||||
|
||||
char* load_wav(const std::string& filename,
|
||||
std::uint8_t& channels,
|
||||
std::int32_t& sampleRate,
|
||||
std::uint8_t& bitsPerSample,
|
||||
ALsizei& size);
|
||||
|
||||
static inline ALenum to_al_format(short channels, short samples){
|
||||
bool stereo = (channels > 1);
|
||||
|
||||
switch (samples) {
|
||||
case 16:
|
||||
if (stereo)
|
||||
return AL_FORMAT_STEREO16;
|
||||
else
|
||||
return AL_FORMAT_MONO16;
|
||||
case 8:
|
||||
if (stereo)
|
||||
return AL_FORMAT_STEREO8;
|
||||
else
|
||||
return AL_FORMAT_MONO8;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SRC_AUDIO_AUDIOUTIL_H_ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue