2008-03-24 01:10:09 +01:00
|
|
|
// Copyright (c) 2007-2008, Niels Martin Hansen
|
2007-08-22 22:58:53 +02:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2007-08-22 22:58:53 +02:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file audio_provider_pcm.cpp
|
|
|
|
/// @brief PCM WAV and WAV64 audio provider
|
|
|
|
/// @ingroup audio_input
|
|
|
|
///
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2008-07-04 05:06:55 +02:00
|
|
|
#include <assert.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#ifndef __WINDOWS__
|
2008-03-24 01:10:09 +01:00
|
|
|
#include <sys/fcntl.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <sys/mman.h>
|
2008-03-24 01:10:09 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
2007-08-22 22:58:53 +02:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/file.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/log.h>
|
|
|
|
#endif
|
2008-03-24 01:10:09 +01:00
|
|
|
|
2010-06-09 01:21:39 +02:00
|
|
|
#include <libaegisub/log.h>
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "aegisub_endian.h"
|
|
|
|
#include "audio_provider_pcm.h"
|
2010-08-02 09:21:02 +02:00
|
|
|
#include "compat.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "utils.h"
|
2008-03-24 01:10:09 +01:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param filename
|
|
|
|
///
|
2008-03-24 01:10:09 +01:00
|
|
|
PCMAudioProvider::PCMAudioProvider(const wxString &filename)
|
2007-08-22 22:58:53 +02:00
|
|
|
{
|
2010-12-11 17:47:03 +01:00
|
|
|
#ifdef _WIN32
|
2008-03-24 01:10:09 +01:00
|
|
|
file_handle = CreateFile(
|
|
|
|
filename.c_str(),
|
|
|
|
FILE_READ_DATA,
|
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
|
|
|
0,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_RANDOM_ACCESS,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (file_handle == INVALID_HANDLE_VALUE) {
|
2010-08-02 09:21:02 +02:00
|
|
|
throw agi::FileNotFoundError(STD_STR(filename));
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LARGE_INTEGER li_file_size = {0};
|
|
|
|
if (!GetFileSizeEx(file_handle, &li_file_size)) {
|
|
|
|
CloseHandle(file_handle);
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Failed getting file size");
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
file_size = li_file_size.QuadPart;
|
|
|
|
|
|
|
|
file_mapping = CreateFileMapping(
|
|
|
|
file_handle,
|
|
|
|
0,
|
|
|
|
PAGE_READONLY,
|
|
|
|
0, 0,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (file_mapping == 0) {
|
|
|
|
CloseHandle(file_handle);
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Failed creating file mapping");
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
2007-08-22 22:58:53 +02:00
|
|
|
|
2008-03-24 01:10:09 +01:00
|
|
|
current_mapping = 0;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-03-24 03:44:45 +01:00
|
|
|
file_handle = open(filename.mb_str(*wxConvFileName), O_RDONLY);
|
2008-03-24 01:10:09 +01:00
|
|
|
|
|
|
|
if (file_handle == -1) {
|
2010-08-02 09:21:02 +02:00
|
|
|
throw agi::FileNotFoundError(STD_STR(filename));
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
|
2008-07-04 14:34:02 +02:00
|
|
|
struct stat filestats;
|
2009-05-04 21:15:57 +02:00
|
|
|
memset(&filestats, 0, sizeof(filestats));
|
2008-03-24 01:10:09 +01:00
|
|
|
if (fstat(file_handle, &filestats)) {
|
|
|
|
close(file_handle);
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Could not stat file to get size");
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
file_size = filestats.st_size;
|
|
|
|
|
|
|
|
current_mapping = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2008-03-24 01:10:09 +01:00
|
|
|
PCMAudioProvider::~PCMAudioProvider()
|
|
|
|
{
|
2010-12-11 17:47:03 +01:00
|
|
|
#ifdef _WIN32
|
2008-03-24 01:10:09 +01:00
|
|
|
if (current_mapping) {
|
|
|
|
UnmapViewOfFile(current_mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(file_mapping);
|
|
|
|
CloseHandle(file_handle);
|
|
|
|
#else
|
|
|
|
if (current_mapping) {
|
|
|
|
munmap(current_mapping, mapping_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
close(file_handle);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @param range_start
|
|
|
|
/// @param range_length
|
|
|
|
/// @return
|
|
|
|
///
|
2010-12-08 04:36:10 +01:00
|
|
|
char * PCMAudioProvider::EnsureRangeAccessible(int64_t range_start, int64_t range_length) const
|
2008-03-24 01:10:09 +01:00
|
|
|
{
|
|
|
|
if (range_start + range_length > file_size) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioDecodeError("Attempted to map beyond end of file");
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the requested range is already visible
|
2008-07-05 14:50:49 +02:00
|
|
|
if (!current_mapping || range_start < mapping_start || range_start+range_length > mapping_start+(int64_t)mapping_length) {
|
2008-03-24 01:10:09 +01:00
|
|
|
// It's not visible, change the current mapping
|
|
|
|
if (current_mapping) {
|
2010-12-11 17:47:03 +01:00
|
|
|
#ifdef _WIN32
|
2008-03-24 01:10:09 +01:00
|
|
|
UnmapViewOfFile(current_mapping);
|
|
|
|
#else
|
|
|
|
munmap(current_mapping, mapping_length);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Align range start on a 1 MB boundary and go 16 MB back
|
|
|
|
mapping_start = (range_start & ~0xFFFFF) - 0x1000000;
|
|
|
|
if (mapping_start < 0) mapping_start = 0;
|
2009-04-18 17:16:15 +02:00
|
|
|
|
|
|
|
if (sizeof(void*) > 4)
|
|
|
|
// Large address space, use a 2 GB mapping
|
|
|
|
mapping_length = 0x80000000;
|
|
|
|
else
|
|
|
|
// Small (32 bit) address space, use a 256 MB mapping
|
|
|
|
mapping_length = 0x10000000;
|
|
|
|
|
2008-07-04 13:37:45 +02:00
|
|
|
// Make sure to always make a mapping at least as large as the requested range
|
2008-07-04 14:34:02 +02:00
|
|
|
if ((int64_t)mapping_length < range_length) {
|
2008-07-04 13:59:28 +02:00
|
|
|
if (range_length > (int64_t)(~(size_t)0))
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioDecodeError("Requested range larger than max size_t, cannot create view of file");
|
|
|
|
mapping_length = range_length;
|
2008-07-04 13:59:28 +02:00
|
|
|
}
|
2008-07-04 13:37:45 +02:00
|
|
|
// But also make sure we don't try to make a mapping larger than the file
|
2009-04-17 18:34:06 +02:00
|
|
|
if (mapping_start + (int64_t)mapping_length > file_size)
|
2008-07-04 13:37:45 +02:00
|
|
|
mapping_length = (size_t)(file_size - mapping_start);
|
|
|
|
// We already checked that the requested range doesn't extend over the end of the file
|
2008-03-24 01:10:09 +01:00
|
|
|
// Hopefully this should ensure that small files are always mapped in their entirety
|
|
|
|
|
2010-12-11 17:47:03 +01:00
|
|
|
#ifdef _WIN32
|
2008-07-04 13:37:45 +02:00
|
|
|
LARGE_INTEGER mapping_start_li;
|
|
|
|
mapping_start_li.QuadPart = mapping_start;
|
2008-03-24 01:10:09 +01:00
|
|
|
current_mapping = MapViewOfFile(
|
2008-07-04 13:37:45 +02:00
|
|
|
file_mapping, // Mapping handle
|
|
|
|
FILE_MAP_READ, // Access type
|
|
|
|
mapping_start_li.HighPart, // Offset high-part
|
|
|
|
mapping_start_li.LowPart, // Offset low-part
|
|
|
|
mapping_length); // Length of view
|
2008-03-24 01:10:09 +01:00
|
|
|
#else
|
|
|
|
current_mapping = mmap(0, mapping_length, PROT_READ, MAP_PRIVATE, file_handle, mapping_start);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!current_mapping) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioDecodeError("Failed mapping a view of the file");
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-05 14:50:49 +02:00
|
|
|
assert(current_mapping);
|
2008-03-24 01:10:09 +01:00
|
|
|
assert(range_start >= mapping_start);
|
|
|
|
|
2008-07-04 13:37:45 +02:00
|
|
|
// Difference between actual current mapping start and requested range start
|
2008-03-24 01:10:09 +01:00
|
|
|
ptrdiff_t rel_ofs = (ptrdiff_t)(range_start - mapping_start);
|
|
|
|
|
2008-07-04 13:37:45 +02:00
|
|
|
// Calculate a pointer into current mapping for the requested range
|
2008-03-24 01:10:09 +01:00
|
|
|
return ((char*)current_mapping) + rel_ofs;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @param buf
|
|
|
|
/// @param start
|
|
|
|
/// @param count
|
|
|
|
///
|
2010-12-08 04:36:10 +01:00
|
|
|
void PCMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const
|
2008-03-24 01:10:09 +01:00
|
|
|
{
|
2007-08-22 22:58:53 +02:00
|
|
|
// Read blocks from the file
|
|
|
|
size_t index = 0;
|
|
|
|
while (count > 0 && index < index_points.size()) {
|
|
|
|
// Check if this index contains the samples we're looking for
|
2010-12-08 04:36:10 +01:00
|
|
|
const IndexPoint &ip = index_points[index];
|
2007-08-22 22:58:53 +02:00
|
|
|
if (ip.start_sample <= start && ip.start_sample+ip.num_samples > start) {
|
|
|
|
|
|
|
|
// How many samples we can maximum take from this block
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t samples_can_do = ip.num_samples - start + ip.start_sample;
|
2007-08-22 22:58:53 +02:00
|
|
|
if (samples_can_do > count) samples_can_do = count;
|
|
|
|
|
|
|
|
// Read as many samples we can
|
2008-03-24 01:10:09 +01:00
|
|
|
char *src = EnsureRangeAccessible(
|
|
|
|
ip.start_byte + (start - ip.start_sample) * bytes_per_sample * channels,
|
|
|
|
samples_can_do * bytes_per_sample * channels);
|
|
|
|
memcpy(buf, src, samples_can_do * bytes_per_sample * channels);
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
// Update data
|
|
|
|
buf = (char*)buf + samples_can_do * bytes_per_sample * channels;
|
|
|
|
start += samples_can_do;
|
|
|
|
count -= samples_can_do;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we exhausted all sample sections zerofill the rest
|
|
|
|
if (count > 0) {
|
|
|
|
if (bytes_per_sample == 1)
|
|
|
|
// 8 bit formats are usually unsigned with bias 127
|
|
|
|
memset(buf, 127, count*channels);
|
|
|
|
else
|
|
|
|
// While everything else is signed
|
|
|
|
memset(buf, 0, count*bytes_per_sample*channels);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
|
|
|
/// @class RiffWavPCMAudioProvider
|
2010-08-02 08:32:01 +02:00
|
|
|
/// @brief RIFF WAV PCM provider
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
///
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Overview of RIFF WAV: <http://www.sonicspot.com/guide/wavefiles.html>
|
2007-08-22 22:58:53 +02:00
|
|
|
class RiffWavPCMAudioProvider : public PCMAudioProvider {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2007-08-22 22:58:53 +02:00
|
|
|
struct ChunkHeader {
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Always "RIFF"
|
2007-08-22 22:58:53 +02:00
|
|
|
char type[4];
|
2010-08-02 08:32:01 +02:00
|
|
|
/// File size minus sizeof(ChunkHeader) (i.e. 8)
|
2008-07-03 04:22:18 +02:00
|
|
|
uint32_t size;
|
2007-08-22 22:58:53 +02:00
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-08-22 22:58:53 +02:00
|
|
|
struct RIFFChunk {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-08-22 22:58:53 +02:00
|
|
|
ChunkHeader ch;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Always "WAVE"
|
2007-08-22 22:58:53 +02:00
|
|
|
char format[4];
|
|
|
|
};
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-08-22 22:58:53 +02:00
|
|
|
struct fmtChunk {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// compression format used
|
|
|
|
/// We support only PCM (0x1)
|
|
|
|
uint16_t compression;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Number of channels
|
2007-08-22 22:58:53 +02:00
|
|
|
uint16_t channels;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Samples per second
|
2007-08-22 22:58:53 +02:00
|
|
|
uint32_t samplerate;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Bytes per second
|
|
|
|
/// can't always be trusted
|
|
|
|
uint32_t avg_bytes_sec;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Bytes per sample
|
2007-08-22 22:58:53 +02:00
|
|
|
uint16_t block_align;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// Bits per sample that are actually used; rest should be ignored
|
2007-08-22 22:58:53 +02:00
|
|
|
uint16_t significant_bits_sample;
|
|
|
|
// Here was supposed to be some more fields but we don't need them
|
|
|
|
// and just skipping by the size of the struct wouldn't be safe
|
|
|
|
// either way, as the fields can depend on the compression.
|
|
|
|
};
|
|
|
|
|
2011-12-26 23:20:49 +01:00
|
|
|
static bool CheckFourcc(const char (&str1)[4], const char (&str2)[5])
|
2008-07-04 05:06:55 +02:00
|
|
|
{
|
|
|
|
return
|
|
|
|
(str1[0] == str2[0]) &&
|
|
|
|
(str1[1] == str2[1]) &&
|
|
|
|
(str1[2] == str2[2]) &&
|
|
|
|
(str1[3] == str2[3]);
|
|
|
|
}
|
|
|
|
|
2007-08-22 22:58:53 +02:00
|
|
|
public:
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _filename
|
|
|
|
///
|
2007-08-22 22:58:53 +02:00
|
|
|
RiffWavPCMAudioProvider(const wxString &_filename)
|
2008-03-24 01:10:09 +01:00
|
|
|
: PCMAudioProvider(_filename)
|
2007-08-22 22:58:53 +02:00
|
|
|
{
|
|
|
|
filename = _filename;
|
|
|
|
|
|
|
|
// Read header
|
2008-03-24 01:10:09 +01:00
|
|
|
void *filestart = EnsureRangeAccessible(0, sizeof(RIFFChunk));
|
|
|
|
RIFFChunk &header = *(RIFFChunk*)filestart;
|
2007-08-22 22:58:53 +02:00
|
|
|
|
2008-07-04 13:59:28 +02:00
|
|
|
// Check magic values
|
|
|
|
if (!CheckFourcc(header.ch.type, "RIFF"))
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is not a RIFF file");
|
2008-07-04 13:59:28 +02:00
|
|
|
if (!CheckFourcc(header.format, "WAVE"))
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is not a RIFF WAV file");
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
// Count how much more data we can have in the entire file
|
|
|
|
// The first 4 bytes are already eaten by the header.format field
|
2008-07-03 04:22:18 +02:00
|
|
|
uint32_t data_left = Endian::LittleToMachine(header.ch.size) - 4;
|
2007-08-22 22:58:53 +02:00
|
|
|
// How far into the file we have processed.
|
|
|
|
// Must be incremented by the riff chunk size fields.
|
|
|
|
uint32_t filepos = sizeof(header);
|
|
|
|
|
|
|
|
bool got_fmt_header = false;
|
|
|
|
|
|
|
|
// Inherited from AudioProvider
|
|
|
|
num_samples = 0;
|
|
|
|
|
|
|
|
// Continue reading chunks until out of data
|
|
|
|
while (data_left) {
|
2008-03-24 01:10:09 +01:00
|
|
|
ChunkHeader &ch = *(ChunkHeader*)EnsureRangeAccessible(filepos, sizeof(ChunkHeader));
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
// Update counters
|
|
|
|
data_left -= sizeof(ch);
|
|
|
|
filepos += sizeof(ch);
|
|
|
|
|
2008-07-04 05:06:55 +02:00
|
|
|
if (CheckFourcc(ch.type, "fmt ")) {
|
2010-08-02 08:32:01 +02:00
|
|
|
if (got_fmt_header) throw AudioOpenError("Invalid file, multiple 'fmt ' chunks");
|
2007-08-22 22:58:53 +02:00
|
|
|
got_fmt_header = true;
|
|
|
|
|
2008-03-24 01:10:09 +01:00
|
|
|
fmtChunk &fmt = *(fmtChunk*)EnsureRangeAccessible(filepos, sizeof(fmtChunk));
|
2007-08-22 22:58:53 +02:00
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
if (Endian::LittleToMachine(fmt.compression) != 1)
|
|
|
|
throw AudioOpenError("Can't use file, not PCM encoding");
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
// Set stuff inherited from the AudioProvider class
|
2008-07-03 04:22:18 +02:00
|
|
|
sample_rate = Endian::LittleToMachine(fmt.samplerate);
|
|
|
|
channels = Endian::LittleToMachine(fmt.channels);
|
|
|
|
bytes_per_sample = (Endian::LittleToMachine(fmt.significant_bits_sample) + 7) / 8; // round up to nearest whole byte
|
2007-08-22 22:58:53 +02:00
|
|
|
}
|
|
|
|
|
2008-07-04 05:06:55 +02:00
|
|
|
else if (CheckFourcc(ch.type, "data")) {
|
2007-08-22 22:58:53 +02:00
|
|
|
// This won't pick up 'data' chunks inside 'wavl' chunks
|
|
|
|
// since the 'wavl' chunks wrap those.
|
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
if (!got_fmt_header) throw AudioOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.");
|
2008-07-03 04:22:18 +02:00
|
|
|
|
|
|
|
int64_t samples = Endian::LittleToMachine(ch.size) / bytes_per_sample;
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t frames = samples / channels;
|
2007-08-22 22:58:53 +02:00
|
|
|
|
|
|
|
IndexPoint ip;
|
|
|
|
ip.start_sample = num_samples;
|
|
|
|
ip.num_samples = frames;
|
|
|
|
ip.start_byte = filepos;
|
|
|
|
index_points.push_back(ip);
|
|
|
|
|
|
|
|
num_samples += frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Support wavl (wave list) chunks too?
|
|
|
|
|
|
|
|
// Update counters
|
|
|
|
// Make sure they're word aligned
|
2008-07-03 04:22:18 +02:00
|
|
|
data_left -= (Endian::LittleToMachine(ch.size) + 1) & ~1;
|
|
|
|
filepos += (Endian::LittleToMachine(ch.size) + 1) & ~1;
|
2007-08-22 22:58:53 +02:00
|
|
|
}
|
|
|
|
}
|
2009-06-05 01:02:29 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2010-08-02 08:31:38 +02:00
|
|
|
bool AreSamplesNativeEndian() const
|
2009-06-05 01:02:29 +02:00
|
|
|
{
|
|
|
|
// 8 bit samples don't consider endianness
|
|
|
|
if (bytes_per_sample < 2) return true;
|
|
|
|
// Otherwise test whether we're little endian
|
|
|
|
uint32_t testvalue = 0x008800ff;
|
|
|
|
return testvalue == Endian::LittleToMachine(testvalue);
|
|
|
|
}
|
2007-08-22 22:58:53 +02:00
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
static const uint8_t w64GuidRIFF[16] = {
|
|
|
|
// {66666972-912E-11CF-A5D6-28DB04C10000}
|
|
|
|
0x72, 0x69, 0x66, 0x66, 0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
static const uint8_t w64GuidWAVE[16] = {
|
|
|
|
// {65766177-ACF3-11D3-8CD1-00C04F8EDB8A}
|
|
|
|
0x77, 0x61, 0x76, 0x65, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
static const uint8_t w64Guidfmt[16] = {
|
|
|
|
// {20746D66-ACF3-11D3-8CD1-00C04F8EDB8A}
|
|
|
|
0x66, 0x6D, 0x74, 0x20, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
static const uint8_t w64Guiddata[16] = {
|
|
|
|
// {61746164-ACF3-11D3-8CD1-00C04F8EDB8A}
|
|
|
|
0x64, 0x61, 0x74, 0x61, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
|
|
|
/// @class Wave64AudioProvider
|
2010-08-02 08:32:01 +02:00
|
|
|
/// @brief Sony Wave64 audio provider
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
///
|
2010-08-02 08:32:01 +02:00
|
|
|
/// http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf
|
2008-09-11 01:02:40 +02:00
|
|
|
class Wave64AudioProvider : public PCMAudioProvider {
|
|
|
|
// Here's some copy-paste from the FFmpegSource2 code
|
|
|
|
|
2010-08-02 08:32:01 +02:00
|
|
|
/// http://msdn.microsoft.com/en-us/library/dd757720(VS.85).aspx
|
|
|
|
struct WaveFormatEx {
|
|
|
|
uint16_t wFormatTag;
|
|
|
|
uint16_t nChannels;
|
|
|
|
uint32_t nSamplesPerSec;
|
|
|
|
uint32_t nAvgBytesPerSec;
|
|
|
|
uint16_t nBlockAlign;
|
|
|
|
uint16_t wBitsPerSample;
|
|
|
|
uint16_t cbSize;
|
2008-09-11 01:02:40 +02:00
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
struct RiffChunk {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint8_t riff_guid[16];
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint64_t file_size;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint8_t format_guid[16];
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
struct FormatChunk {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint8_t chunk_guid[16];
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint64_t chunk_size;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
WaveFormatEx format;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint8_t padding[6];
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
struct DataChunk {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint8_t chunk_guid[16];
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-09-11 01:02:40 +02:00
|
|
|
uint64_t chunk_size;
|
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @param guid1
|
|
|
|
/// @param guid2
|
|
|
|
/// @return
|
|
|
|
///
|
2008-09-11 01:02:40 +02:00
|
|
|
inline bool CheckGuid(const uint8_t *guid1, const uint8_t *guid2)
|
|
|
|
{
|
|
|
|
return memcmp(guid1, guid2, 16) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _filename
|
|
|
|
///
|
2008-09-11 01:02:40 +02:00
|
|
|
Wave64AudioProvider(const wxString &_filename)
|
2011-12-26 23:20:49 +01:00
|
|
|
: PCMAudioProvider(_filename)
|
2008-09-11 01:02:40 +02:00
|
|
|
{
|
|
|
|
filename = _filename;
|
|
|
|
|
|
|
|
int64_t smallest_possible_file = sizeof(RiffChunk) + sizeof(FormatChunk) + sizeof(DataChunk);
|
|
|
|
|
|
|
|
if (file_size < smallest_possible_file)
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is too small to be a Wave64 file");
|
2008-09-11 01:02:40 +02:00
|
|
|
|
|
|
|
// Read header
|
|
|
|
// This should throw an exception if the mapping fails
|
|
|
|
void *filestart = EnsureRangeAccessible(0, sizeof(RiffChunk));
|
|
|
|
assert(filestart);
|
|
|
|
RiffChunk &header = *(RiffChunk*)filestart;
|
|
|
|
|
|
|
|
// Check magic values
|
|
|
|
if (!CheckGuid(header.riff_guid, w64GuidRIFF))
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is not a Wave64 RIFF file");
|
2008-09-11 01:02:40 +02:00
|
|
|
if (!CheckGuid(header.format_guid, w64GuidWAVE))
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is not a Wave64 WAVE file");
|
2008-09-11 01:02:40 +02:00
|
|
|
|
|
|
|
// Count how much more data we can have in the entire file
|
|
|
|
uint64_t data_left = Endian::LittleToMachine(header.file_size) - sizeof(RiffChunk);
|
|
|
|
// How far into the file we have processed.
|
|
|
|
// Must be incremented by the riff chunk size fields.
|
|
|
|
uint64_t filepos = sizeof(header);
|
|
|
|
|
|
|
|
bool got_fmt_header = false;
|
|
|
|
|
|
|
|
// Inherited from AudioProvider
|
|
|
|
num_samples = 0;
|
|
|
|
|
|
|
|
// Continue reading chunks until out of data
|
|
|
|
while (data_left) {
|
|
|
|
uint8_t *chunk_guid = (uint8_t*)EnsureRangeAccessible(filepos, 16);
|
|
|
|
uint64_t chunk_size = Endian::LittleToMachine(*(uint64_t*)EnsureRangeAccessible(filepos+16, sizeof(uint64_t)));
|
|
|
|
|
|
|
|
if (CheckGuid(chunk_guid, w64Guidfmt)) {
|
|
|
|
if (got_fmt_header)
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Bad file, found more than one 'fmt' chunk");
|
2008-09-11 01:02:40 +02:00
|
|
|
|
|
|
|
FormatChunk &fmt = *(FormatChunk*)EnsureRangeAccessible(filepos, sizeof(FormatChunk));
|
|
|
|
got_fmt_header = true;
|
|
|
|
|
|
|
|
if (Endian::LittleToMachine(fmt.format.wFormatTag) == 3)
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("File is IEEE 32 bit float format which isn't supported. Bug the developers if this matters.");
|
2008-09-11 01:02:40 +02:00
|
|
|
if (Endian::LittleToMachine(fmt.format.wFormatTag) != 1)
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Can't use file, not PCM encoding");
|
2008-09-11 01:02:40 +02:00
|
|
|
|
|
|
|
// Set stuff inherited from the AudioProvider class
|
|
|
|
sample_rate = Endian::LittleToMachine(fmt.format.nSamplesPerSec);
|
|
|
|
channels = Endian::LittleToMachine(fmt.format.nChannels);
|
|
|
|
bytes_per_sample = (Endian::LittleToMachine(fmt.format.wBitsPerSample) + 7) / 8; // round up to nearest whole byte
|
|
|
|
}
|
|
|
|
else if (CheckGuid(chunk_guid, w64Guiddata)) {
|
|
|
|
if (!got_fmt_header)
|
2010-08-02 08:32:01 +02:00
|
|
|
throw AudioOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.");
|
2008-09-11 01:02:40 +02:00
|
|
|
|
|
|
|
int64_t samples = chunk_size / bytes_per_sample;
|
|
|
|
int64_t frames = samples / channels;
|
|
|
|
|
|
|
|
IndexPoint ip;
|
|
|
|
ip.start_sample = num_samples;
|
|
|
|
ip.num_samples = frames;
|
|
|
|
ip.start_byte = filepos;
|
|
|
|
index_points.push_back(ip);
|
|
|
|
|
|
|
|
num_samples += frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update counters
|
|
|
|
// Make sure they're 64 bit aligned
|
|
|
|
data_left -= (chunk_size + 7) & ~7;
|
|
|
|
filepos += (chunk_size + 7) & ~7;
|
|
|
|
}
|
|
|
|
}
|
2009-06-05 01:02:29 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2010-08-02 08:31:38 +02:00
|
|
|
bool AreSamplesNativeEndian() const
|
2009-06-05 01:02:29 +02:00
|
|
|
{
|
|
|
|
// 8 bit samples don't consider endianness
|
|
|
|
if (bytes_per_sample < 2) return true;
|
|
|
|
// Otherwise test whether we're little endian
|
|
|
|
uint32_t testvalue = 0x008800ff;
|
|
|
|
return testvalue == Endian::LittleToMachine(testvalue);
|
|
|
|
}
|
2008-09-11 01:02:40 +02:00
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief DOCME
|
|
|
|
/// @param filename
|
|
|
|
///
|
2007-08-22 22:58:53 +02:00
|
|
|
AudioProvider *CreatePCMAudioProvider(const wxString &filename)
|
|
|
|
{
|
2010-08-02 08:32:01 +02:00
|
|
|
std::string msg;
|
2008-03-24 01:10:09 +01:00
|
|
|
try {
|
2010-08-02 08:32:01 +02:00
|
|
|
return new RiffWavPCMAudioProvider(filename);
|
2008-03-24 01:10:09 +01:00
|
|
|
}
|
2010-08-02 08:32:01 +02:00
|
|
|
catch (AudioOpenError const& err) {
|
|
|
|
msg = "RIFF PCM WAV audio provider: " + err.GetMessage();
|
2008-07-04 13:59:28 +02:00
|
|
|
}
|
2008-09-11 01:02:40 +02:00
|
|
|
try {
|
2010-08-02 08:32:01 +02:00
|
|
|
return new Wave64AudioProvider(filename);
|
2008-09-11 01:02:40 +02:00
|
|
|
}
|
2010-08-02 08:32:01 +02:00
|
|
|
catch (AudioOpenError const& err) {
|
|
|
|
msg += "\nWave64 audio provider: " + err.GetMessage();
|
|
|
|
throw AudioOpenError(msg);
|
2008-09-11 01:02:40 +02:00
|
|
|
}
|
2007-08-22 22:58:53 +02:00
|
|
|
}
|