mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-26 14:55:39 +00:00
Initial commit
added libraries: opus flac libsndfile updated: libvorbis libogg openal - Everything works as expected for now. Bare in mind libsndfile needed the check for whether or not it could find the xiph libraries removed in order for this to work.
This commit is contained in:
parent
05a083ca6f
commit
a745fc3757
1954 changed files with 431332 additions and 21037 deletions
19
Engine/lib/flac/src/utils/Makefile.am
Normal file
19
Engine/lib/flac/src/utils/Makefile.am
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# FLAC - Free Lossless Audio Codec
|
||||
# Copyright (C) 2001-2009 Josh Coalson
|
||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
||||
#
|
||||
# This file is part the FLAC project. FLAC is comprised of several
|
||||
# components distributed under different licenses. The codec libraries
|
||||
# are distributed under Xiph.Org's BSD-like license (see the file
|
||||
# COPYING.Xiph in this distribution). All other programs, libraries, and
|
||||
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
||||
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
||||
# FLAC distribution contains at the top the terms under which it may be
|
||||
# distributed.
|
||||
#
|
||||
# Since this particular file is relevant to all components of FLAC,
|
||||
# it may be distributed under the Xiph.Org license, which is the least
|
||||
# restrictive of those mentioned above. See the file COPYING.Xiph in this
|
||||
# distribution.
|
||||
|
||||
SUBDIRS = flacdiff flactimer
|
||||
5
Engine/lib/flac/src/utils/flacdiff/CMakeLists.txt
Normal file
5
Engine/lib/flac/src/utils/flacdiff/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
add_executable(flacdiff
|
||||
main.cpp
|
||||
$<$<BOOL:${WIN32}>:../../../include/share/win_utf8_io.h>
|
||||
$<$<BOOL:${WIN32}>:../../share/win_utf8_io/win_utf8_io.c>)
|
||||
target_link_libraries(flacdiff FLAC++)
|
||||
21
Engine/lib/flac/src/utils/flacdiff/Makefile.am
Normal file
21
Engine/lib/flac/src/utils/flacdiff/Makefile.am
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# flacdiff - Displays where two FLAC streams differ
|
||||
# Copyright (C) 2007-2009 Josh Coalson
|
||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
main.cpp
|
||||
230
Engine/lib/flac/src/utils/flacdiff/main.cpp
Normal file
230
Engine/lib/flac/src/utils/flacdiff/main.cpp
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
/* flacdiff - Displays where two FLAC streams differ
|
||||
* Copyright (C) 2007-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "FLAC++/decoder.h"
|
||||
#include "share/compat.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
|
||||
#pragma warning ( disable : 4800 )
|
||||
#endif
|
||||
|
||||
class AutoFILE {
|
||||
protected:
|
||||
::FILE *f_;
|
||||
public:
|
||||
inline AutoFILE(const char *path, const char *mode): f_(::fopen(path, mode)) { }
|
||||
inline virtual ~AutoFILE() { if (f_) (void)::fclose(f_); }
|
||||
|
||||
inline operator bool() const { return 0 != f_; }
|
||||
inline operator const ::FILE *() const { return f_; }
|
||||
inline operator ::FILE *() { return f_; }
|
||||
private:
|
||||
AutoFILE();
|
||||
AutoFILE(const AutoFILE &);
|
||||
void operator=(const AutoFILE &);
|
||||
};
|
||||
|
||||
class Decoder: public FLAC::Decoder::Stream {
|
||||
public:
|
||||
Decoder(AutoFILE &f, FLAC__off_t tgt): tgtpos_((FLAC__uint64)tgt), curpos_(0), go_(true), err_(false), frame_(), f_(f) { memset(&frame_, 0, sizeof(::FLAC__Frame)); }
|
||||
FLAC__uint64 tgtpos_, curpos_;
|
||||
bool go_, err_;
|
||||
::FLAC__Frame frame_;
|
||||
protected:
|
||||
AutoFILE &f_;
|
||||
// from FLAC::Decoder::Stream
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes)
|
||||
{
|
||||
*bytes = fread(buffer, 1, *bytes, f_);
|
||||
if(ferror((FILE*)f_))
|
||||
return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
else if(*bytes == 0 && feof((FILE*)f_))
|
||||
return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
else
|
||||
return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset)
|
||||
{
|
||||
FLAC__off_t off = ftello(f_);
|
||||
if(off < 0)
|
||||
return ::FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
*absolute_byte_offset = off;
|
||||
return ::FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||
}
|
||||
|
||||
virtual bool eof_callback()
|
||||
{
|
||||
return (bool)feof((FILE*)f_);
|
||||
}
|
||||
|
||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const /*buffer*/[])
|
||||
{
|
||||
FLAC__uint64 pos;
|
||||
if(!get_decode_position(&pos)) {
|
||||
go_ = false;
|
||||
err_ = true;
|
||||
return ::FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
if(pos > tgtpos_) {
|
||||
go_ = false;
|
||||
frame_ = *frame;
|
||||
}
|
||||
else
|
||||
curpos_ = pos;
|
||||
return ::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status)
|
||||
{
|
||||
fprintf(stderr, "got error %d:%s\n", status, ::FLAC__StreamDecoderErrorStatusString[status]);
|
||||
go_ = false;
|
||||
err_ = true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool show_diff(AutoFILE &f1, AutoFILE &f2, FLAC__off_t off)
|
||||
{
|
||||
Decoder d1(f1, off), d2(f2, off);
|
||||
if(!d1) {
|
||||
fprintf(stderr, "ERROR: setting up decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1));
|
||||
return false;
|
||||
}
|
||||
if(!d2) {
|
||||
fprintf(stderr, "ERROR: setting up decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2));
|
||||
return false;
|
||||
}
|
||||
::FLAC__StreamDecoderInitStatus is;
|
||||
if((is = d1.init()) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
||||
fprintf(stderr, "ERROR: initializing decoder1, status=%s state=%s\n", FLAC__StreamDecoderInitStatusString[is], d1.get_state().resolved_as_cstring(d1));
|
||||
return false;
|
||||
}
|
||||
if((is = d2.init()) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
||||
fprintf(stderr, "ERROR: initializing decoder2, status=%s state=%s\n", FLAC__StreamDecoderInitStatusString[is], d2.get_state().resolved_as_cstring(d2));
|
||||
return false;
|
||||
}
|
||||
if(!d1.process_until_end_of_metadata()) {
|
||||
fprintf(stderr, "ERROR: skipping metadata in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1));
|
||||
return false;
|
||||
}
|
||||
if(!d2.process_until_end_of_metadata()) {
|
||||
fprintf(stderr, "ERROR: skipping metadata in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2));
|
||||
return false;
|
||||
}
|
||||
while(d1.go_ && d2.go_) {
|
||||
if(!d1.process_single()) {
|
||||
fprintf(stderr, "ERROR: decoding frame in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1));
|
||||
return false;
|
||||
}
|
||||
if(!d2.process_single()) {
|
||||
fprintf(stderr, "ERROR: decoding frame in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(d1.err_) {
|
||||
fprintf(stderr, "ERROR: got err_ in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1));
|
||||
return false;
|
||||
}
|
||||
if(d2.err_) {
|
||||
fprintf(stderr, "ERROR: got err_ in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2));
|
||||
return false;
|
||||
}
|
||||
if(d1.go_ != d2.go_) {
|
||||
fprintf(stderr, "ERROR: d1.go_(%s) != d2.go_(%s)\n", d1.go_?"true":"false", d2.go_?"true":"false");
|
||||
return false;
|
||||
}
|
||||
fprintf(stdout, "pos1 = %" PRIu64 " blocksize=%u sample#%" PRIu64 " frame#%" PRIu64 "\n", d1.curpos_, d1.frame_.header.blocksize, d1.frame_.header.number.sample_number, d1.frame_.header.number.sample_number / d1.frame_.header.blocksize);
|
||||
fprintf(stdout, "pos2 = %" PRIu64 " blocksize=%u sample#%" PRIu64 " frame#%" PRIu64 "\n", d2.curpos_, d2.frame_.header.blocksize, d2.frame_.header.number.sample_number, d2.frame_.header.number.sample_number / d2.frame_.header.blocksize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static FLAC__off_t get_diff_offset(AutoFILE &f1, AutoFILE &f2)
|
||||
{
|
||||
FLAC__off_t off = 0;
|
||||
while(1) {
|
||||
if(feof((FILE*)f1) && feof((FILE*)f2)) {
|
||||
fprintf(stderr, "ERROR: files are identical\n");
|
||||
return -1;
|
||||
}
|
||||
if(feof((FILE*)f1)) {
|
||||
fprintf(stderr, "ERROR: file1 EOF\n");
|
||||
return -1;
|
||||
}
|
||||
if(feof((FILE*)f2)) {
|
||||
fprintf(stderr, "ERROR: file2 EOF\n");
|
||||
return -1;
|
||||
}
|
||||
if(fgetc(f1) != fgetc(f2))
|
||||
return off;
|
||||
off++;
|
||||
}
|
||||
}
|
||||
|
||||
static bool run(const char *fn1, const char *fn2)
|
||||
{
|
||||
FLAC__off_t off;
|
||||
AutoFILE f1(fn1, "rb"), f2(fn2, "rb");
|
||||
|
||||
if(!f1) {
|
||||
flac_fprintf(stderr, "ERROR: opening %s for reading\n", fn1);
|
||||
return false;
|
||||
}
|
||||
if(!f2) {
|
||||
flac_fprintf(stderr, "ERROR: opening %s for reading\n", fn2);
|
||||
return false;
|
||||
}
|
||||
|
||||
if((off = get_diff_offset(f1, f2)) < 0)
|
||||
return false;
|
||||
|
||||
fprintf(stdout, "got diff offset = %" PRId64 "\n", off);
|
||||
|
||||
return show_diff(f1, f2, off);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *usage = "usage: flacdiff flacfile1 flacfile2\n";
|
||||
|
||||
#ifdef _WIN32
|
||||
if (get_utf8_argv(&argc, &argv) != 0) {
|
||||
fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(argc > 1 && 0 == strcmp(argv[1], "-h")) {
|
||||
printf("%s", usage);
|
||||
return 0;
|
||||
}
|
||||
else if(argc != 3) {
|
||||
fprintf(stderr, "%s", usage);
|
||||
return 255;
|
||||
}
|
||||
|
||||
return run(argv[1], argv[2])? 0 : 1;
|
||||
}
|
||||
2
Engine/lib/flac/src/utils/flactimer/CMakeLists.txt
Normal file
2
Engine/lib/flac/src/utils/flactimer/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
add_executable(flactimer main.cpp)
|
||||
target_link_libraries(flactimer FLAC++)
|
||||
21
Engine/lib/flac/src/utils/flactimer/Makefile.am
Normal file
21
Engine/lib/flac/src/utils/flactimer/Makefile.am
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# flactimer - Runs a command and prints timing information
|
||||
# Copyright (C) 2007-2009 Josh Coalson
|
||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
main.cpp
|
||||
175
Engine/lib/flac/src/utils/flactimer/main.cpp
Normal file
175
Engine/lib/flac/src/utils/flactimer/main.cpp
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/* flactimer - Runs a command and prints timing information
|
||||
* Copyright (C) 2007-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include "share/compat.h"
|
||||
#include "share/safe_str.h"
|
||||
|
||||
static inline uint64_t time2nsec(const FILETIME &t)
|
||||
{
|
||||
uint64_t n = t.dwHighDateTime;
|
||||
n <<= 32;
|
||||
n |= (uint64_t)t.dwLowDateTime;
|
||||
return n * 100;
|
||||
}
|
||||
|
||||
static void printtime(FILE *fout, uint64_t nsec, uint64_t total)
|
||||
{
|
||||
uint32_t pct = (uint32_t)(100.0 * ((double)nsec / (double)total));
|
||||
uint64_t msec = nsec / 1000000; nsec -= msec * 1000000;
|
||||
uint64_t sec = msec / 1000; msec -= sec * 1000;
|
||||
uint64_t min = sec / 60; sec -= min * 60;
|
||||
uint64_t hour = min / 60; min -= hour * 60;
|
||||
fprintf(fout, " %5u.%03u = %02u:%02u:%02u.%03u = %3u%%\n",
|
||||
(uint32_t)((hour*60+min)*60+sec),
|
||||
(uint32_t)msec,
|
||||
(uint32_t)hour,
|
||||
(uint32_t)min,
|
||||
(uint32_t)sec,
|
||||
(uint32_t)msec,
|
||||
pct
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *usage = "usage: flactimer [-1 | -2 | -o outputfile] command\n";
|
||||
FILE *fout = stderr;
|
||||
|
||||
if(argc == 1 || (argc > 1 && 0 == strcmp(argv[1], "-h"))) {
|
||||
fprintf(stderr, usage);
|
||||
return 0;
|
||||
}
|
||||
argv++;
|
||||
argc--;
|
||||
if(0 == strcmp(argv[0], "-1") || 0 == strcmp(argv[0], "/1")) {
|
||||
fout = stdout;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if(0 == strcmp(argv[0], "-2") || 0 == strcmp(argv[0], "/2")) {
|
||||
fout = stdout;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if(0 == strcmp(argv[0], "-o")) {
|
||||
if(argc < 2) {
|
||||
fprintf(stderr, usage);
|
||||
return 1;
|
||||
}
|
||||
fout = fopen(argv[1], "w");
|
||||
if(!fout) {
|
||||
fprintf(stderr, "ERROR opening file %s for writing\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
}
|
||||
if(argc <= 0) {
|
||||
fprintf(fout, "ERROR, no command!\n\n");
|
||||
fprintf(fout, usage);
|
||||
fclose(fout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// improvement: double-quote all args
|
||||
int i, n = 0;
|
||||
for(i = 0; i < argc; i++) {
|
||||
if(i > 0)
|
||||
n++;
|
||||
n += strlen(argv[i]);
|
||||
}
|
||||
char *args = (char*)malloc(n+1);
|
||||
if(!args) {
|
||||
fprintf(fout, "ERROR, no memory\n");
|
||||
fclose(fout);
|
||||
return 1;
|
||||
}
|
||||
args[0] = '\0';
|
||||
for(i = 0; i < argc; i++) {
|
||||
if(i > 0)
|
||||
safe_strncat(args, " ", sizeof(args));
|
||||
safe_strncat(args, argv[i], sizeof(args));
|
||||
}
|
||||
|
||||
//fprintf(stderr, "@@@ cmd=[%s] args=[%s]\n", argv[0], args);
|
||||
|
||||
STARTUPINFOA si;
|
||||
GetStartupInfoA(&si);
|
||||
|
||||
DWORD wallclock_msec = GetTickCount();
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
BOOL ok = CreateProcessA(
|
||||
argv[0], // lpApplicationName
|
||||
args, // lpCommandLine
|
||||
NULL, // lpProcessAttributes
|
||||
NULL, // lpThreadAttributes
|
||||
FALSE, // bInheritHandles
|
||||
0, // dwCreationFlags
|
||||
NULL, // lpEnvironment
|
||||
NULL, // lpCurrentDirectory
|
||||
&si, // lpStartupInfo (inherit from this proc?)
|
||||
&pi // lpProcessInformation
|
||||
);
|
||||
|
||||
if(!ok) {
|
||||
fprintf(fout, "ERROR running command\n");
|
||||
free(args); //@@@ ok to free here or have to wait to wait till process is reaped?
|
||||
fclose(fout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//fprintf(stderr, "@@@ waiting...\n");
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
//fprintf(stderr, "@@@ done\n");
|
||||
|
||||
wallclock_msec = GetTickCount() - wallclock_msec;
|
||||
|
||||
FILETIME creation_time;
|
||||
FILETIME exit_time;
|
||||
FILETIME kernel_time;
|
||||
FILETIME user_time;
|
||||
if(!GetProcessTimes(pi.hProcess, &creation_time, &exit_time, &kernel_time, &user_time)) {
|
||||
fprintf(fout, "ERROR getting time info\n");
|
||||
free(args); //@@@ ok to free here or have to wait to wait till process is reaped?
|
||||
fclose(fout);
|
||||
return 1;
|
||||
}
|
||||
uint64_t kernel_nsec = time2nsec(kernel_time);
|
||||
uint64_t user_nsec = time2nsec(user_time);
|
||||
|
||||
fprintf(fout, "Kernel Time = "); printtime(fout, kernel_nsec, (uint64_t)wallclock_msec * 1000000);
|
||||
fprintf(fout, "User Time = "); printtime(fout, user_nsec, (uint64_t)wallclock_msec * 1000000);
|
||||
fprintf(fout, "Process Time = "); printtime(fout, kernel_nsec+user_nsec, (uint64_t)wallclock_msec * 1000000);
|
||||
fprintf(fout, "Global Time = "); printtime(fout, (uint64_t)wallclock_msec * 1000000, (uint64_t)wallclock_msec * 1000000);
|
||||
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
free(args); //@@@ always causes crash, maybe CreateProcess takes ownership?
|
||||
fclose(fout);
|
||||
return 0;
|
||||
}
|
||||
115
Engine/lib/flac/src/utils/loudness/loudness.sci
Normal file
115
Engine/lib/flac/src/utils/loudness/loudness.sci
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
// Equal Loudness Filter
|
||||
//
|
||||
// Adapted from original MATLAB code written by David Robinson
|
||||
//
|
||||
// http://replaygain.hydrogenaudio.org/proposal/equal_loudness.html
|
||||
// http://replaygain.hydrogenaudio.org/proposal/mfiles/equalloudfilt.m
|
||||
|
||||
// *****************************************************************************
|
||||
// Print Filter Coefficients
|
||||
//
|
||||
// This function takes a vector of filter tap settings, and prints
|
||||
// each tap setting from least significant to most significant.
|
||||
|
||||
function c=printcoeff(p)
|
||||
|
||||
c=coeff(p);
|
||||
c=c($:-1:1);
|
||||
|
||||
for ix = 1:1:length(c)
|
||||
if ix > 1
|
||||
printf(" ")
|
||||
end
|
||||
printf("%.14f", c(ix));
|
||||
end
|
||||
|
||||
endfunction
|
||||
|
||||
// *****************************************************************************
|
||||
// Equal Loudness Filter
|
||||
//
|
||||
// This function is adapted from David Robison's original MATLAB code.
|
||||
// Apart from changes to port it to scilab, the other change is to
|
||||
// use a single specification of the frequency points in the 80dB Equal
|
||||
// Loudness curve.
|
||||
//
|
||||
// The original code had different curves for different sampling
|
||||
// frequencies. This code dynamically computes the current data
|
||||
// points to use as determined by the Nyquist frequency.
|
||||
|
||||
function [a1,b1,a2,b2]=equalloudfilt(fs);
|
||||
// Design a filter to match equal loudness curves
|
||||
// 9/7/2001
|
||||
|
||||
[%nargout,%nargin]=argn(0);
|
||||
|
||||
// If the user hasn't specified a sampling frequency, use the CD default
|
||||
if %nargin<1 then
|
||||
fs=44100;
|
||||
end
|
||||
|
||||
// Specify the 80 dB Equal Loudness curve
|
||||
EL80=[0,120;20,113;30,103;40,97;50,93;60,91;70,89;80,87;90,86; ..
|
||||
..
|
||||
100,85;200,78;300,76;400,76;500,76;600,76;700,77;800,78;900,79.5; ..
|
||||
..
|
||||
1000,80;1500,79;2000,77;2500,74;3000,71.5;3700,70;4000,70.5; ..
|
||||
5000,74;6000,79;7000,84;8000,86;9000,86; ..
|
||||
..
|
||||
10000,85;12000,95;15000,110;20000,125;24000,140];
|
||||
|
||||
for ex = 1:1:length(EL80(:,1))
|
||||
if EL80(ex,1) > fs/2
|
||||
EL80 = [ EL80(1:ex-1,:); fs/2, EL80(ex-1,2) ];
|
||||
break
|
||||
elseif EL80(ex,1) == fs/2
|
||||
EL80 = EL80(1:ex,:);
|
||||
break
|
||||
end
|
||||
if ex == length(EL80(:,1))
|
||||
EL80 = [ EL80(1:$, :); fs/2, EL80($,2) ];
|
||||
end
|
||||
end
|
||||
|
||||
// convert frequency and amplitude of the equal loudness curve into format suitable for yulewalk
|
||||
f=EL80(:,1)./(fs/2);
|
||||
m=10.^((70-EL80(:,2))/20);
|
||||
|
||||
// Use a MATLAB utility to design a best bit IIR filter
|
||||
[b1,a1]=yulewalk(10,f,m);
|
||||
|
||||
// Add a 2nd order high pass filter at 150Hz to finish the job
|
||||
hz=iir(2,'hp','butt',[150/fs,0],[1e-3 1e-3]);
|
||||
b2=numer(hz); // b2=b2($:-1:1);
|
||||
a2=denom(hz); // a2=a2($:-1:1);
|
||||
|
||||
endfunction
|
||||
|
||||
// *****************************************************************************
|
||||
// Generate Filter Taps
|
||||
//
|
||||
// Generate the filter taps for each of the desired frequencies.
|
||||
|
||||
format('v', 16);
|
||||
|
||||
freqs = [ 8000 11025 12000 16000 18900 22050 24000 ..
|
||||
28000 32000 36000 37800 44100 48000 ];
|
||||
|
||||
for fx = 1:1:length(freqs)
|
||||
|
||||
printf("\n%d\n", freqs(fx));
|
||||
|
||||
[a1,b1,a2,b2] = equalloudfilt(freqs(fx));
|
||||
|
||||
printf("{ "); bb=printcoeff(b1); printf(" }\n");
|
||||
printf("{ "); aa=printcoeff(a1); printf(" }\n");
|
||||
|
||||
printf("{ "); printcoeff(b2); printf(" }\n");
|
||||
printf("{ "); printcoeff(a2); printf(" }\n");
|
||||
|
||||
// freqz_fwd(bb,aa,1024,freqs(fx));
|
||||
|
||||
end
|
||||
|
||||
|
||||
quit
|
||||
Loading…
Add table
Add a link
Reference in a new issue