VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae::core::SourceLoader Struct Reference

#include <vae_source_loader.hpp>

Collaboration diagram for vae::core::SourceLoader:

Public Member Functions

Result load (Source &s, const char *path)
 Loads a wav file for the resource. More...
 

Detailed Description

Definition at line 17 of file vae_source_loader.hpp.

Member Function Documentation

◆ load()

Result vae::core::SourceLoader::load ( Source s,
const char *  path 
)
inline

Loads a wav file for the resource.

Parameters
s
path
Returns
Result

Definition at line 24 of file vae_source_loader.hpp.

24 {
25 String joinedPath;
26 const char* data = s.path.c_str();
27 Size length = 0;
28 if (!s.raw) {
29 joinedPath = path;
30 joinedPath.append(s.path);
31 data = joinedPath.c_str();
32 #ifdef VAE_NO_STDIO
33 fs::File file(data);
34 length = file.size();
35 joinedPath.reserve(length);
36 if (!file.readAll(joinedPath.data())) { return Result::FileOpenError; }
37 data = joinedPath.data();
38 #endif
39 } else {
40 length = s.path.size();
41 }
42
43 if (!s.stream) {
44 if (s.format == Source::Format::wav) {
45 #ifdef VAE_NO_WAV
47 #else
48 VAE_PROFILER_SCOPE_NAMED("Load wav")
49 bool success = tklb::wave::load<Sample, AudioBuffer>(data, s.signal, length);
50 return success ? Result::Success : Result::GenericFailure;
51 #endif
52 } else if (s.format == Source::Format::ogg) {
53 VAE_PROFILER_SCOPE_NAMED("Load ogg")
54 auto result = tklb::ogg::load<Sample, AudioBuffer>(data, s.signal, length);
55 return result ? Result::Success : Result::GenericFailure;
56 }
57 return Result::GenericFailure; // what format is this?
58 }
59 // TODO STREAM
60 return Result::GenericFailure;
61 }
Using template interfaces isn't an option so this simply defines a default Convolver type.
Definition: TAllocator.hpp:15
tklb::AudioBufferTpl< Sample, tklb::HeapBuffer< Sample, tklb::DEFAULT_ALIGNMENT, memory::AllocatorAudio< unsigned char > > > AudioBuffer
Buffer type to hold all the audio data meant for playback.
Definition: vae_types.hpp:70
unsigned int Size
How the elements are addressed in the heapbuffer.
Definition: vae.hpp:33
float Sample
Default sample types used where ever possible, changing this means the engine needs to be recompiled,...
Definition: vae.hpp:32
Result
Return Types for most engine functions.
Definition: vae.hpp:73
@ FileOpenError
File system could not load file.
@ GenericFailure
:(
HeapBuffer< char > String
Definition: string.cpp:4
@ ogg
Uses stb_vorbis to decode oggs.
@ wav
Uses dr_wav to decode wavs.
Result load(Source &s, const char *path)
Loads a wav file for the resource.
#define VAE_PROFILER_SCOPE_NAMED(name)
Profiles a scope and names it.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: