nomlib
Loading...
Searching...
No Matches
SoundFile.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014, 2015, 2016 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_AUDIO_SOUND_FILE_HPP
30#define NOMLIB_AUDIO_SOUND_FILE_HPP
31
32#include <string>
33
34#include "export.hpp"
35#include "nomlib/config.hpp"
36
37#define BUFFERLENGTH 65536 // 64KB // Part 2
38
39namespace nom {
40namespace audio {
41
42// This enumeration is filled in by libsndfile
43enum NOM_EXPORT AudioTags
44{
45 SOUND_TAG_UNDEFINED = 0,
46 SOUND_TAG_TITLE,
47 SOUND_TAG_COPYRIGHT,
48 SOUND_TAG_SOFTWARE,
49 SOUND_TAG_ARTIST,
50 SOUND_TAG_COMMENT,
51 SOUND_TAG_DATE,
52 SOUND_TAG_ALBUM,
53 SOUND_TAG_LICENSE,
54 SOUND_TAG_TRACK_NUMBER,
55 SOUND_TAG_GENRE,
56};
57
58// This enumeration is filled in by libsndfile
59enum NOM_EXPORT AudioFormat
60{
61 AUDIO_FORMAT_UNKNOWN = 0,
62
64 AUDIO_FORMAT_S8,
65
67 AUDIO_FORMAT_U8,
68
70 AUDIO_FORMAT_S16,
71
73 AUDIO_FORMAT_S24,
74
76 AUDIO_FORMAT_S32,
77
79 AUDIO_FORMAT_R32,
80
82 AUDIO_FORMAT_R64,
83};
84
85#if 0
86enum AudioChannels
87{
88 // Mono
89 ONE_CHANNELS = 1,
90 TWO_CHANNELS,
91 FOUR_CHANNELS,
92 FIVE_CHANNELS,
93 SIX_CHANNELS,
94 SEVEN_CHANNELS
95};
96#endif
97
98// This struct is filled in by libsndfile
99// TODO(JEFF): Rename struct to SoundFile?
100struct NOM_EXPORT SoundInfo
101{
105 nom::size_type frame_count = 0;
106
108 int64 sample_count = 0;
109
111 uint32 sample_rate = 0;
112
115
117 real32 duration = 0.0f;
118
120 nom::int64 total_bytes = 0;
121
123 uint32 channel_format = 0;
124
126 int byte_rate = -1;
127
129 int bitrate = -1;
130
131 bool seekable = false;
132
133 // TODO(JEFF): Rename struct to SoundFileMetadata and relocate outside of the main
134 // struct?
135 struct Metadata
136 {
137 const char* title = "\0";
138 const char* copyright = "\0";
139 const char* software = "\0";
140 const char* artist = "\0";
141 const char* comment = "\0";
142 const char* date = "\0";
143 const char* album = "\0";
144 const char* license = "\0";
145 const char* track_number = "\0";
146 const char* genre = "\0";
147 };
148
149 Metadata tags;
150};
151
152} // namespace audio
153} // namespace nom
154
155#endif // NOMLIB_AUDIO_SOUND_FILE_HPP defined
nom::int64 total_bytes
The total number of bytes represented by the audio samples.
int bitrate
Filled in by sndfile.
int channel_count
The number of audio channels.
real32 duration
The total time, in seconds, of the audio samples.
nom::size_type frame_count
The total number of frames.
int64 sample_count
The total number of samples.
int byte_rate
Filled in by sndfile.
uint32 sample_rate
The number of samples per second.