/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/spu2-x/src/WavFile.h
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/spu2-x/src/WavFile.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (show annotations) (download)
Sun Dec 26 18:56:19 2010 UTC (9 years, 1 month ago) by william
File MIME type: text/plain
File size: 3328 byte(s)
** merged upstream r4049 (re-integration of GregMiscellaneous branch)
** applied patched to GigTranser.cpp in ZZOgl from r4140 to change 'static int count = 0;' to 'static int path1_count = 0;')
1 /* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
2 * Developed and maintained by the Pcsx2 Development Team.
3 *
4 * The file is based on WavFile.h from SoundTouch library.
5 * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
6 *
7 * SPU2-X is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU Lesser General Public License as published by the Free Software Found-
9 * ation, either version 3 of the License, or (at your option) any later version.
10 *
11 * SPU2-X is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with SPU2-X. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 // Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
20 // shrunken to support only output 16 bits wav files
21
22 #ifndef WAVFILE_H
23 #define WAVFILE_H
24
25 #include <stdio.h>
26
27 #ifndef uint
28 typedef unsigned int uint;
29 #endif
30
31
32 /// WAV audio file 'riff' section header
33 typedef struct
34 {
35 char riff_char[4];
36 int package_len;
37 char wave[4];
38 } WavRiff;
39
40 /// WAV audio file 'format' section header
41 typedef struct
42 {
43 char fmt[4];
44 int format_len;
45 short fixed;
46 short channel_number;
47 int sample_rate;
48 int byte_rate;
49 short byte_per_sample;
50 short bits_per_sample;
51 } WavFormat;
52
53 /// WAV audio file 'data' section header
54 typedef struct
55 {
56 char data_field[4];
57 uint data_len;
58 } WavData;
59
60
61 /// WAV audio file header
62 typedef struct
63 {
64 WavRiff riff;
65 WavFormat format;
66 WavData data;
67 } WavHeader;
68
69
70 /// Class for writing WAV audio files.
71 class WavOutFile
72 {
73 private:
74 /// Pointer to the WAV file
75 FILE *fptr;
76
77 /// WAV file header data.
78 WavHeader header;
79
80 /// Counter of how many bytes have been written to the file so far.
81 int bytesWritten;
82
83 /// Fills in WAV file header information.
84 void fillInHeader(const uint sampleRate, const uint bits, const uint channels);
85
86 /// Finishes the WAV file header by supplementing information of amount of
87 /// data written to file etc
88 void finishHeader();
89
90 /// Writes the WAV file header.
91 void writeHeader();
92
93 public:
94 /// Constructor: Creates a new WAV file. Throws a 'runtime_error' exception
95 /// if file creation fails.
96 WavOutFile(const char *fileName, ///< Filename
97 int sampleRate, ///< Sample rate (e.g. 44100 etc)
98 int bits, ///< Bits per sample (8 or 16 bits)
99 int channels ///< Number of channels (1=mono, 2=stereo)
100 );
101
102 /// Destructor: Finalizes & closes the WAV file.
103 ~WavOutFile();
104
105 /// Write data to WAV file. Throws a 'runtime_error' exception if writing to
106 /// file fails.
107 void write(const short *buffer, ///< Pointer to sample data buffer.
108 int numElems ///< How many array items are to be written to file.
109 );
110
111 };
112
113 #endif

  ViewVC Help
Powered by ViewVC 1.1.22