CPP-TOOLBOX
Loading...
Searching...
No Matches
load_sound_file.cpp File Reference
#include "load_sound_file.hpp"
#include <AL/alc.h>
#include <AL/alext.h>
#include <sndfile.h>
#include <cinttypes>
#include <climits>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stdexcept>
#include <string>
#include <sstream>
#include <iostream>

Namespaces

namespace  patch
 

Enumerations

enum  FormatType { Int16 , Float , IMA4 , MSADPCM }
 

Functions

template<typename T>
std::string patch::to_string (const T &n)
 
const char * FormatName (ALenum format)
 
void open_audio_file (const char *filename, SNDFILE **sound_file, SF_INFO *sound_file_info_ptr)
 
enum FormatType determine_format_type (SF_INFO sound_file_info)
 
std::tuple< ALint, ALint > get_byte_and_samples_per_block_alignment (enum FormatType sample_format, const char *filename, SNDFILE *sound_file, SF_INFO sound_file_info)
 
ALenum determine_openal_format (SNDFILE *sound_file, SF_INFO sound_file_info, enum FormatType sample_format)
 
std::tuple< void *, ALsizei > decode_audio_file_into_dynamic_memory (const char *filename, SNDFILE *sound_file, SF_INFO sound_file_info, enum FormatType sample_format, ALenum format, ALint byteblockalign, ALint splblockalign)
 
ALuint load_audio_file_in_dynamic_memory_into_buffer (void *membuf, SNDFILE *sound_file, SF_INFO sound_file_info, ALsizei num_bytes, ALenum format, ALint splblockalign)
 
ALuint load_sound_and_generate_openal_buffer (const char *filename)
 

Variables

std::map< ALenum, const char * > openal_format_enum_to_string
 

Enumeration Type Documentation

◆ FormatType

enum FormatType
Enumerator
Int16 
Float 
IMA4 
MSADPCM 

Function Documentation

◆ decode_audio_file_into_dynamic_memory()

std::tuple< void *, ALsizei > decode_audio_file_into_dynamic_memory ( const char * filename,
SNDFILE * sound_file,
SF_INFO sound_file_info,
enum FormatType sample_format,
ALenum format,
ALint byteblockalign,
ALint splblockalign )

Decode the whole audio file to a buffer

Returns
the pointer to dynamic memory, along with the number of bytes it takes up

◆ determine_format_type()

enum FormatType determine_format_type ( SF_INFO sound_file_info)

◆ determine_openal_format()

ALenum determine_openal_format ( SNDFILE * sound_file,
SF_INFO sound_file_info,
enum FormatType sample_format )

◆ FormatName()

const char * FormatName ( ALenum format)

◆ get_byte_and_samples_per_block_alignment()

std::tuple< ALint, ALint > get_byte_and_samples_per_block_alignment ( enum FormatType sample_format,
const char * filename,
SNDFILE * sound_file,
SF_INFO sound_file_info )

◆ load_audio_file_in_dynamic_memory_into_buffer()

ALuint load_audio_file_in_dynamic_memory_into_buffer ( void * membuf,
SNDFILE * sound_file,
SF_INFO sound_file_info,
ALsizei num_bytes,
ALenum format,
ALint splblockalign )

Buffer the audio data into a new buffer object, then free the data and close the file.

Returns
the identifier to the openal buffer

◆ load_sound_and_generate_openal_buffer()

ALuint load_sound_and_generate_openal_buffer ( const char * filename)

◆ open_audio_file()

void open_audio_file ( const char * filename,
SNDFILE ** sound_file,
SF_INFO * sound_file_info_ptr )

Variable Documentation

◆ openal_format_enum_to_string

std::map<ALenum, const char *> openal_format_enum_to_string