38 lines
812 B
C++
Executable file
38 lines
812 B
C++
Executable file
#include "audio.hpp"
|
|
|
|
#include <opusfile.h>
|
|
#include <algorithm>
|
|
#include <cstring>
|
|
|
|
#include "file.hpp"
|
|
|
|
constexpr int num_channels = 2;
|
|
constexpr int sample_rate = 48000;
|
|
constexpr int frame_size = 960;
|
|
constexpr int frames_per_buffer = 480;
|
|
|
|
struct AudioFile {
|
|
float gain = 1.0f;
|
|
bool finished = false;
|
|
OggOpusFile* handle = nullptr;
|
|
};
|
|
|
|
std::vector<AudioFile> audio_files;
|
|
|
|
void audio::initialize() {
|
|
// todo: stub
|
|
}
|
|
|
|
void audio::play_file(const prism::path& path, const float gain) {
|
|
auto audio_file = prism::open_file(path);
|
|
if(audio_file == std::nullopt)
|
|
return;
|
|
|
|
audio_file->read_all();
|
|
|
|
AudioFile file;
|
|
file.gain = gain;
|
|
file.handle = op_open_memory(audio_file->cast_data<unsigned char>(), audio_file->size(), nullptr);
|
|
|
|
audio_files.push_back(file);
|
|
}
|