MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
mgdl-pc-sound.h
1#pragma once
2#include <sndfile.h>
3
4#include <mgdl/mgdl-types.h>
5#include <mgdl/mgdl-sound.h>
6#include <mgdl/mgdl-openal.h>
7
8
9// Work in progress
10
11#include <mgdl/mgdl-music.h>
12#include <vorbis/vorbisfile.h>
13#include <cstring>
14#include <istream>
15#include <fstream>
16#include <iostream>
17
18 // For ogg playback
19 const std::size_t NUM_BUFFERS = 2;
20 const ALsizei READ_SIZE = 4096;
21 const ALsizei BUFFER_SIZE = READ_SIZE * 4;
22
24 {
25 // These buffers are fed to AL in ring sequence
26 ALuint buffers[NUM_BUFFERS];
27
28 // File name is kept in case need to open it again
29 std::string filename;
30 std::ifstream file;
31 FILE* filePointer;
32
33 // Information about the audio
34 std::uint8_t channels;
35 std::int32_t sampleRate;
36 std::uint8_t bitsPerSample;
37
38 // Size in bytes
39 ALsizei size;
40
41 // OpenAL book keeping information
42 ALuint source;
43 ALsizei sizeConsumed = 0;
44 ALenum format;
45
46 // Identifier for the ogg vorbis library
47 OggVorbis_File oggVorbisFile;
48 // What part is being played
49 int oggCurrentSection = 0;
50
51 // Duration (What unit?)
52 std::size_t duration;
53 };
54
55 bool LoadFileStreaming(const char* filename);
56 bool LoadFileNonStreaming(const char* filename, Music* music);
57 void CopyToAL();
58 void Rebuffer();
59 bool LoadAudioDataStreaming(const char* filename);
60 bool LoadAudioDataFilePtr(const char* filename);
61 bool OpenOggCallbacks();
62 bool OpenOggNoCallbacks();
63 bool ReadOggProperties();
64 void SetALSourceToOrigo(Music* music);
65 bool VerifyALSource();
66 std::int32_t ReadOggToPCMBuffer(char* buffer, std::int32_t bufferSize);
67
68
Sound module header.
Library types, macros, defines and enums header.
Definition mgdl-music.h:17
Definition mgdl-pc-sound.h:24