Refresh 10.1

This commit is contained in:
n64 2020-06-17 22:14:59 -04:00
parent d43d9b7f20
commit 05c7d7031c
15 changed files with 21279 additions and 4051 deletions

View File

@ -1,3 +1,10 @@
Refresh #10.1
1.) Diff update (#1033)
2.) Fix texture dimensions for exclamation boxes (#1034)
3.) Fix armips compilation on Windows by changing order of inclusion files (#1035)
4.) Embed libaudiofile into the repo as a single file (#1036)
5.) Fix some tools issues found while compiling on MSYS2 (#1037)
Refresh #10
1.) GCC 9 noreturn UB fixes (#961)
2.) List supported binutils variants in README.md (#960)

View File

@ -13,7 +13,7 @@ ALIGNED8 static const u8 exclamation_box_seg8_texture_08012E28[] = {
// 0x08013628
ALIGNED8 static const u8 exclamation_box_seg8_texture_08013628[] = {
#include "actors/exclamation_box/vanish_cap_box_sides.rgba16.inc.c"
#include "actors/exclamation_box/vanish_cap_box_side.rgba16.inc.c"
};
// 0x08014628
@ -33,7 +33,7 @@ ALIGNED8 static const u8 exclamation_box_seg8_texture_08015E28[] = {
// 0x08016628
ALIGNED8 static const u8 exclamation_box_seg8_texture_08016628[] = {
#include "actors/exclamation_box/wing_cap_box_sides.rgba16.inc.c"
#include "actors/exclamation_box/wing_cap_box_side.rgba16.inc.c"
};
// 0x08017628

View File

@ -210,9 +210,9 @@
"actors/exclamation_box/metal_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,83496],"us":[2040320,83496],"eu":[1912288,83496],"sh":[1888800,83496]}],
"actors/exclamation_box/metal_cap_box_side.rgba16.png": [64,32,4096,{"jp":[2032944,85544],"us":[2040320,85544],"eu":[1912288,85544],"sh":[1888800,85544]}],
"actors/exclamation_box/vanish_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,77352],"us":[2040320,77352],"eu":[1912288,77352],"sh":[1888800,77352]}],
"actors/exclamation_box/vanish_cap_box_sides.rgba16.png": [64,32,4096,{"jp":[2032944,79400],"us":[2040320,79400],"eu":[1912288,79400],"sh":[1888800,79400]}],
"actors/exclamation_box/vanish_cap_box_side.rgba16.png": [32,64,4096,{"jp":[2032944,79400],"us":[2040320,79400],"eu":[1912288,79400],"sh":[1888800,79400]}],
"actors/exclamation_box/wing_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,89640],"us":[2040320,89640],"eu":[1912288,89640],"sh":[1888800,89640]}],
"actors/exclamation_box/wing_cap_box_sides.rgba16.png": [64,32,4096,{"jp":[2032944,91688],"us":[2040320,91688],"eu":[1912288,91688],"sh":[1888800,91688]}],
"actors/exclamation_box/wing_cap_box_side.rgba16.png": [32,64,4096,{"jp":[2032944,91688],"us":[2040320,91688],"eu":[1912288,91688],"sh":[1888800,91688]}],
"actors/exclamation_box_outline/exclamation_box_outline.rgba16.png": [32,32,2048,{"jp":[2032944,151912],"us":[2040320,151912],"eu":[1912288,151912],"sh":[1888800,151912]}],
"actors/exclamation_box_outline/exclamation_point.rgba16.png": [16,32,1024,{"jp":[2032944,154240],"us":[2040320,154240],"eu":[1912288,154240],"sh":[1888800,154240]}],
"actors/explosion/explosion_0.rgba16.png": [32,32,2048,{"jp":[2094912,2568],"us":[2102288,2568],"eu":[1974256,2568],"sh":[1950768,2568]}],

286
diff.py
View File

@ -18,16 +18,18 @@ def fail(msg):
sys.exit(1)
MISSING_PREREQUISITES = (
"Missing prerequisite python module {}. "
"Run `python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein` to install prerequisites (python-Levenshtein only needed for --algorithm=levenshtein)."
)
try:
import attr
from colorama import Fore, Style, Back
import ansiwrap
import watchdog
except ModuleNotFoundError as e:
fail(
f"Missing prerequisite python module {e.name}. "
"Run `python3 -m pip install --user colorama ansiwrap attrs watchdog` to install prerequisites."
)
fail(MISSING_PREREQUISITES.format(e.name))
# Prefer to use diff_settings.py from the current working directory
sys.path.insert(0, ".")
@ -121,6 +123,22 @@ parser.add_argument(
default=50,
help="Sets the width of the left and right view column.",
)
parser.add_argument(
"--algorithm",
dest="algorithm",
default="difflib",
choices=["levenshtein", "difflib"],
help="Diff algorithm to use.",
)
parser.add_argument(
"--max-size",
"--max-lines",
dest="max_lines",
type=int,
default=1024,
help="The maximum length of the diff, in lines. Not recommended when -f is used.",
)
# Project-specific flags, e.g. different versions/make arguments.
if hasattr(diff_settings, "add_custom_arguments"):
@ -138,8 +156,8 @@ mapfile = config.get("mapfile", None)
makeflags = config.get("makeflags", [])
source_directories = config.get("source_directories", None)
MAX_FUNCTION_SIZE_LINES = 1024
MAX_FUNCTION_SIZE_BYTES = 1024 * 4
MAX_FUNCTION_SIZE_LINES = args.max_lines
MAX_FUNCTION_SIZE_BYTES = MAX_FUNCTION_SIZE_LINES * 4
COLOR_ROTATION = [
Fore.MAGENTA,
@ -161,6 +179,12 @@ FS_WATCH_EXTENSIONS = [".c", ".h"]
# ==== LOGIC ====
if args.algorithm == "levenshtein":
try:
import Levenshtein
except ModuleNotFoundError as e:
fail(MISSING_PREREQUISITES.format(e.name))
binutils_prefix = None
for binutils_cand in ["mips-linux-gnu-", "mips64-elf-"]:
@ -292,7 +316,7 @@ def dump_objfile():
run_make(objfile)
if not os.path.isfile(objfile):
fail("Not able to find .o file for function.")
fail(f"Not able to find .o file for function: {objfile} is not a file.")
refobjfile = "expected/" + objfile
if not os.path.isfile(refobjfile):
@ -344,28 +368,27 @@ def ansi_ljust(s, width):
re_int = re.compile(r"[0-9]+")
re_comments = re.compile(r"<.*?>")
re_regs = re.compile(r"\b(a[0-3]|t[0-9]|s[0-7]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b")
re_sprel = re.compile(r",([1-9][0-9]*|0x[1-9a-f][0-9a-f]*)\(sp\)")
re_regs = re.compile(r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b")
re_sprel = re.compile(r",([0-9]+|0x[0-9a-f]+)\(sp\)")
re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}")
re_imm = re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)")
forbidden = set(string.ascii_letters + "_")
branch_likely_instructions = set(
[
"beql",
"bnel",
"beqzl",
"bnezl",
"bgezl",
"bgtzl",
"blezl",
"bltzl",
"bc1tl",
"bc1fl",
]
)
branch_instructions = set(
["b", "beq", "bne", "beqz", "bnez", "bgez", "bgtz", "blez", "bltz", "bc1t", "bc1f"]
+ list(branch_likely_instructions)
branch_likely_instructions = {
"beql",
"bnel",
"beqzl",
"bnezl",
"bgezl",
"bgtzl",
"blezl",
"bltzl",
"bc1tl",
"bc1fl",
}
branch_instructions = branch_likely_instructions.union(
{"b", "beq", "bne", "beqz", "bnez", "bgez", "bgtz", "blez", "bltz", "bc1t", "bc1f"}
)
jump_instructions = branch_instructions.union({"jal", "j"})
def hexify_int(row, pat):
@ -420,6 +443,7 @@ def process_reloc(row, prev):
def process(lines):
mnemonics = []
diff_rows = []
rows_with_imms = []
skip_next = False
originals = []
line_nums = []
@ -434,8 +458,9 @@ def process(lines):
continue
if "R_MIPS_" in row:
if diff_rows[-1] != "<delay-slot>":
diff_rows[-1] = process_reloc(row, diff_rows[-1])
# N.B. Don't transform the diff rows, they already ignore immediates
# if diff_rows[-1] != '<delay-slot>':
# diff_rows[-1] = process_reloc(row, rows_with_imms[-1])
originals[-1] = process_reloc(row, originals[-1])
continue
@ -446,7 +471,7 @@ def process(lines):
line_num = tabs[0].strip()
row_parts = row.split("\t", 1)
mnemonic = row_parts[0].strip()
if mnemonic not in branch_instructions:
if mnemonic not in jump_instructions:
row = re.sub(re_int, lambda s: hexify_int(row, s), row)
original = row
if skip_next:
@ -457,11 +482,16 @@ def process(lines):
skip_next = True
row = re.sub(re_regs, "<reg>", row)
row = re.sub(re_sprel, ",addr(sp)", row)
if args.ignore_large_imms:
row = re.sub(re_large_imm, "<imm>", row)
row_with_imm = row
if mnemonic in jump_instructions:
row = row.strip()
row, _ = split_off_branch(row)
row += "<imm>"
else:
row = re.sub(re_imm, "<imm>", row)
# Replace tabs with spaces
mnemonics.append(mnemonic)
rows_with_imms.append(row_with_imm)
diff_rows.append(row)
originals.append(original)
line_nums.append(line_num)
@ -504,12 +534,85 @@ class SymbolColorer:
return f"{color}{t}{Fore.RESET}"
def normalize_large_imms(row):
def maybe_normalize_large_imms(row):
if args.ignore_large_imms:
row = re.sub(re_large_imm, "<imm>", row)
return row
def normalize_imms(row):
return re.sub(re_imm, "<imm>", row)
def normalize_stack(row):
return re.sub(re_sprel, ",addr(sp)", row)
def split_off_branch(line):
parts = line.split(",")
if len(parts) < 2:
parts = line.split(None, 1)
off = len(line) - len(parts[-1])
return line[:off], line[off:]
def color_imms(out1, out2):
g1 = []
g2 = []
re.sub(re_imm, lambda s: g1.append(s.group()), out1)
re.sub(re_imm, lambda s: g2.append(s.group()), out2)
if len(g1) == len(g2):
diffs = [x != y for (x, y) in zip(g1, g2)]
it = iter(diffs)
def maybe_color(s):
return f"{Fore.LIGHTBLUE_EX}{s}{Style.RESET_ALL}" if next(it) else s
out1 = re.sub(re_imm, lambda s: maybe_color(s.group()), out1)
it = iter(diffs)
out2 = re.sub(re_imm, lambda s: maybe_color(s.group()), out2)
return out1, out2
def color_branch_imms(br1, br2):
if br1 != br2:
br1 = f"{Fore.LIGHTBLUE_EX}{br1}{Style.RESET_ALL}"
br2 = f"{Fore.LIGHTBLUE_EX}{br2}{Style.RESET_ALL}"
return br1, br2
def diff_sequences_difflib(seq1, seq2):
differ = difflib.SequenceMatcher(a=seq1, b=seq2, autojunk=False)
return differ.get_opcodes()
def diff_sequences(seq1, seq2):
if (
args.algorithm != "levenshtein"
or len(seq1) * len(seq2) > 4 * 10 ** 8
or len(seq1) + len(seq2) >= 0x110000
):
return diff_sequences_difflib(seq1, seq2)
# The Levenshtein library assumes that we compare strings, not lists. Convert.
# (Per the check above we know we have fewer than 0x110000 unique elements, so chr() works.)
remapping = {}
def remap(seq):
seq = seq[:]
for i in range(len(seq)):
val = remapping.get(seq[i])
if val is None:
val = chr(len(remapping))
remapping[seq[i]] = val
seq[i] = val
return "".join(seq)
seq1 = remap(seq1)
seq2 = remap(seq2)
return Levenshtein.opcodes(seq1, seq2)
def do_diff(basedump, mydump):
asm_lines1 = basedump.split("\n")
asm_lines2 = mydump.split("\n")
@ -545,10 +648,7 @@ def do_diff(basedump, mydump):
btset.add(bt + ":")
sc.color_symbol(bt + ":")
differ: difflib.SequenceMatcher = difflib.SequenceMatcher(
a=mnemonics1, b=mnemonics2, autojunk=False
)
for (tag, i1, i2, j1, j2) in differ.get_opcodes():
for (tag, i1, i2, j1, j2) in diff_sequences(mnemonics1, mnemonics2):
lines1 = asm_lines1[i1:i2]
lines2 = asm_lines2[j1:j2]
@ -572,65 +672,113 @@ def do_diff(basedump, mydump):
original2 = ""
line_num2 = ""
line_color = Fore.RESET
has1 = has2 = True
line_color1 = line_color2 = sym_color = Fore.RESET
line_prefix = " "
if line1 == line2:
if normalize_large_imms(original1) == normalize_large_imms(original2):
out1 = f"{original1}"
out2 = f"{original2}"
if not line1:
has1 = has2 = False
if maybe_normalize_large_imms(original1) == maybe_normalize_large_imms(
original2
):
out1 = original1
out2 = original2
elif line1 == "<delay-slot>":
out1 = f"{Style.DIM}{original1}"
out2 = f"{Style.DIM}{original2}"
else:
line_color = Fore.YELLOW
line_prefix = "r"
out1 = f"{Fore.YELLOW}{original1}{Style.RESET_ALL}"
out2 = f"{Fore.YELLOW}{original2}{Style.RESET_ALL}"
out1 = re.sub(re_regs, lambda s: sc1.color_symbol(s.group()), out1)
out2 = re.sub(re_regs, lambda s: sc2.color_symbol(s.group()), out2)
out1 = re.sub(re_sprel, lambda s: sc3.color_symbol(s.group()), out1)
out2 = re.sub(re_sprel, lambda s: sc4.color_symbol(s.group()), out2)
mnemonic = original1.split()[0]
out1, out2 = original1, original2
branch1 = branch2 = ""
if mnemonic in jump_instructions:
out1, branch1 = split_off_branch(original1)
out2, branch2 = split_off_branch(original2)
branchless1 = out1
branchless2 = out2
out1, out2 = color_imms(out1, out2)
branch1, branch2 = color_branch_imms(branch1, branch2)
out1 += branch1
out2 += branch2
if normalize_imms(branchless1) == normalize_imms(branchless2):
# only imms differences
sym_color = Fore.LIGHTBLUE_EX
line_prefix = "i"
else:
out1 = re.sub(
re_sprel,
lambda s: "," + sc3.color_symbol(s.group()[1:]),
out1,
)
out2 = re.sub(
re_sprel,
lambda s: "," + sc4.color_symbol(s.group()[1:]),
out2,
)
if normalize_stack(branchless1) == normalize_stack(branchless2):
# only stack differences (luckily stack and imm
# differences can't be combined in MIPS, so we
# don't have to think about that case)
sym_color = Fore.YELLOW
line_prefix = "s"
else:
# regs differences and maybe imms as well
out1 = re.sub(
re_regs, lambda s: sc1.color_symbol(s.group()), out1
)
out2 = re.sub(
re_regs, lambda s: sc2.color_symbol(s.group()), out2
)
line_color1 = line_color2 = sym_color = Fore.YELLOW
line_prefix = "r"
elif tag in ["replace", "equal"]:
line_prefix = "|"
line_color = Fore.BLUE
out1 = f"{Fore.BLUE}{original1}{Style.RESET_ALL}"
out2 = f"{Fore.BLUE}{original2}{Style.RESET_ALL}"
line_color1 = Fore.LIGHTBLUE_EX
line_color2 = Fore.LIGHTBLUE_EX
sym_color = Fore.LIGHTBLUE_EX
out1 = original1
out2 = original2
elif tag == "delete":
line_prefix = "<"
line_color = Fore.RED
out1 = f"{Fore.RED}{original1}{Style.RESET_ALL}"
line_color1 = line_color2 = sym_color = Fore.RED
has2 = False
out1 = original1
out2 = ""
elif tag == "insert":
line_prefix = ">"
line_color = Fore.GREEN
line_color1 = line_color2 = sym_color = Fore.GREEN
has1 = False
out1 = ""
out2 = f"{Fore.GREEN}{original2}{Style.RESET_ALL}"
out2 = original2
in_arrow1 = " "
in_arrow2 = " "
out_arrow1 = ""
out_arrow2 = ""
line_num1 = line_num1 if out1 else ""
line_num2 = line_num2 if out2 else ""
line_num1 = line_num1 if has1 else ""
line_num2 = line_num2 if has2 else ""
if args.show_branches and out1:
if sym_color == line_color2:
line_color2 = ""
if args.show_branches and has1:
if line_num1 in bts1:
in_arrow1 = sc5.color_symbol(line_num1, "~>")
in_arrow1 = sc5.color_symbol(line_num1, "~>") + line_color1
if branch_targets1[i1 + k] is not None:
out_arrow1 = " " + sc5.color_symbol(
branch_targets1[i1 + k] + ":", "~>"
)
if args.show_branches and out2:
if args.show_branches and has2:
if line_num2 in bts2:
in_arrow2 = sc6.color_symbol(line_num2, "~>")
in_arrow2 = sc6.color_symbol(line_num2, "~>") + line_color2
if branch_targets2[j1 + k] is not None:
out_arrow2 = " " + sc6.color_symbol(
branch_targets2[j1 + k] + ":", "~>"
)
out1 = f"{line_color}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}"
out2 = f"{line_color}{line_prefix} {line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}"
output.append(format_single_line_diff(out1, out2, args.column_width))
out1 = f"{line_color1}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}"
out2 = f"{line_color2}{line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}"
mid = f"{sym_color}{line_prefix} "
output.append(format_single_line_diff(out1, mid + out2, args.column_width))
return output[args.skip_lines :]
@ -677,7 +825,7 @@ def debounced_fs_watch(targets, outq, debounce_delay):
observer.schedule(event_handler, target, recursive=True)
else:
file_targets.append(target)
target = os.path.dirname(target)
target = os.path.dirname(target) or "."
if target not in observed:
observed.add(target)
observer.schedule(event_handler, target)
@ -800,7 +948,7 @@ def main():
if args.write_asm is not None:
mydump = run_objdump(mycmd)
with open(args.write_asm) as f:
with open(args.write_asm, "w") as f:
f.write(mydump)
print(f"Wrote assembly to {args.write_asm}.")
sys.exit(0)
@ -850,7 +998,9 @@ def main():
ret = run_make(make_target, capture_output=True)
if ret.returncode != 0:
display.update(
ret.stderr.decode() or ret.stdout.decode(), error=True
ret.stderr.decode("utf-8-sig", "replace")
or ret.stdout.decode("utf-8-sig", "replace"),
error=True,
)
continue
mydump = run_objdump(mycmd)

View File

@ -257,7 +257,7 @@ def main():
)
finally:
png_file.close()
remove_file(png_file.name)
os.remove(png_file.name)
else:
with open(asset, "wb") as f:
f.write(input)

View File

@ -9,10 +9,14 @@ ifeq (, $(shell which armips 2> /dev/null))
CXX_PROGRAMS += armips
endif
ifeq ($(OS),Windows_NT)
ARMIPS_FLAGS := -municode
endif
default: all
armips: armips.cpp
$(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti -pipe $^ -o $@ -lpthread
$(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti -pipe $^ -o $@ -lpthread $(ARMIPS_FLAGS)
n64graphics_SOURCES := n64graphics.c utils.c
n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE
@ -33,8 +37,8 @@ aifc_decode_SOURCES := aifc_decode.c
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
tabledesign_CFLAGS := -Wno-uninitialized
tabledesign_LDFLAGS := -laudiofile
tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++ -lm
vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c sdk-tools/adpcm/quant.c sdk-tools/adpcm/util.c sdk-tools/adpcm/vencode.c
vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value
@ -43,10 +47,16 @@ extract_data_for_mio_SOURCES := extract_data_for_mio.c
skyconv_SOURCES := skyconv.c n64graphics.c utils.c
all: $(PROGRAMS) $(CXX_PROGRAMS)
LIBAUDIOFILE := audiofile/libaudiofile.a
$(LIBAUDIOFILE):
@$(MAKE) -C audiofile
all: $(LIBAUDIOFILE) $(PROGRAMS) $(CXX_PROGRAMS)
clean:
$(RM) $(PROGRAMS) $(CXX_PROGRAMS)
$(MAKE) -C audiofile clean
define COMPILE
$(1): $($1_SOURCES)

File diff suppressed because it is too large Load Diff

12
tools/audiofile/Makefile Normal file
View File

@ -0,0 +1,12 @@
CXX := g++
libaudiofile.a: audiofile.o
ar rcs libaudiofile.a audiofile.o
audiofile.o: audiofile.cpp audiofile.h aupvlist.h
$(CXX) -std=c++11 -O2 -I. -c audiofile.cpp
clean:
rm -f audiofile.o libaudiofile.a
.PHONY: clean

15915
tools/audiofile/audiofile.cpp Normal file

File diff suppressed because it is too large Load Diff

612
tools/audiofile/audiofile.h Normal file
View File

@ -0,0 +1,612 @@
/*
Audio File Library
Copyright (C) 1998-2000, 2010-2013 Michael Pruett <michael@68k.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
/*
audiofile.h
This file contains the public interfaces to the Audio File Library.
*/
#ifndef AUDIOFILE_H
#define AUDIOFILE_H
#include <aupvlist.h>
#include <stdint.h>
#include <sys/types.h>
#define LIBAUDIOFILE_MAJOR_VERSION 0
#define LIBAUDIOFILE_MINOR_VERSION 3
#define LIBAUDIOFILE_MICRO_VERSION 6
#ifdef __cplusplus
extern "C" {
#endif
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
#define AFAPI __attribute__((visibility("default")))
#else
#define AFAPI
#endif
typedef struct _AFvirtualfile AFvirtualfile;
typedef struct _AFfilesetup *AFfilesetup;
typedef struct _AFfilehandle *AFfilehandle;
typedef void (*AFerrfunc)(long, const char *);
// Define AFframecount and AFfileoffset as 64-bit signed integers.
#if defined(__FreeBSD__) || \
defined(__DragonFly__) || \
defined(__NetBSD__) || \
defined(__OpenBSD__) || \
defined(__APPLE__) || \
defined(__sgi) || \
(defined(__linux__) && defined(__LP64__))
// BSD and IRIX systems define off_t as a 64-bit signed integer.
// Linux defines off_t as a 64-bit signed integer in LP64 mode.
typedef off_t AFframecount;
typedef off_t AFfileoffset;
#else
// For all other systems, use int64_t.
typedef int64_t AFframecount;
typedef int64_t AFfileoffset;
#endif
#define AF_NULL_FILESETUP ((struct _AFfilesetup *) 0)
#define AF_NULL_FILEHANDLE ((struct _AFfilehandle *) 0)
#define AF_ERR_BASE 3000
enum
{
AF_DEFAULT_TRACK = 1001
};
enum
{
AF_DEFAULT_INST = 2001
};
enum
{
AF_NUM_UNLIMITED = 99999
};
enum
{
AF_BYTEORDER_BIGENDIAN = 501,
AF_BYTEORDER_LITTLEENDIAN = 502
};
enum
{
AF_FILE_UNKNOWN = -1,
AF_FILE_RAWDATA = 0,
AF_FILE_AIFFC = 1,
AF_FILE_AIFF = 2,
AF_FILE_NEXTSND = 3,
AF_FILE_WAVE = 4,
AF_FILE_BICSF = 5,
AF_FILE_IRCAM = AF_FILE_BICSF,
AF_FILE_MPEG1BITSTREAM = 6, /* not implemented */
AF_FILE_SOUNDDESIGNER1 = 7, /* not implemented */
AF_FILE_SOUNDDESIGNER2 = 8, /* not implemented */
AF_FILE_AVR = 9,
AF_FILE_IFF_8SVX = 10,
AF_FILE_SAMPLEVISION = 11,
AF_FILE_VOC = 12,
AF_FILE_NIST_SPHERE = 13,
AF_FILE_SOUNDFONT2 = 14, /* not implemented */
AF_FILE_CAF = 15,
AF_FILE_FLAC = 16
};
enum
{
AF_LOOP_MODE_NOLOOP = 0,
AF_LOOP_MODE_FORW = 1,
AF_LOOP_MODE_FORWBAKW = 2
};
enum
{
AF_SAMPFMT_TWOSCOMP = 401, /* linear two's complement */
AF_SAMPFMT_UNSIGNED = 402, /* unsigned integer */
AF_SAMPFMT_FLOAT = 403, /* 32-bit IEEE floating-point */
AF_SAMPFMT_DOUBLE = 404 /* 64-bit IEEE double-precision floating-point */
};
enum
{
AF_INST_LOOP_OFF = 0, /* no looping */
AF_INST_LOOP_CONTINUOUS = 1, /* loop continuously through decay */
AF_INST_LOOP_SUSTAIN = 3 /* loop during sustain, then continue */
};
enum
{
AF_INST_MIDI_BASENOTE = 301,
AF_INST_NUMCENTS_DETUNE = 302,
AF_INST_MIDI_LONOTE = 303,
AF_INST_MIDI_HINOTE = 304,
AF_INST_MIDI_LOVELOCITY = 305,
AF_INST_MIDI_HIVELOCITY = 306,
AF_INST_NUMDBS_GAIN = 307,
AF_INST_SUSLOOPID = 308, /* loop id for AIFF sustain loop */
AF_INST_RELLOOPID = 309, /* loop id for AIFF release loop */
AF_INST_SAMP_STARTFRAME = 310, /* start sample for this inst */
AF_INST_SAMP_ENDFRAME = 311, /* end sample for this inst */
AF_INST_SAMP_MODE = 312, /* looping mode for this inst */
AF_INST_TRACKID = 313,
AF_INST_NAME = 314, /* name of this inst */
AF_INST_SAMP_RATE = 315, /* sample rate of this inst's sample */
AF_INST_PRESETID = 316, /* ID of preset containing this inst */
AF_INST_PRESET_NAME = 317 /* name of preset containing this inst */
};
enum
{
AF_MISC_UNRECOGNIZED = 0, /* unrecognized data chunk */
AF_MISC_COPY = 201, /* copyright string */
AF_MISC_AUTH = 202, /* author string */
AF_MISC_NAME = 203, /* name string */
AF_MISC_ANNO = 204, /* annotation string */
AF_MISC_APPL = 205, /* application-specific data */
AF_MISC_MIDI = 206, /* MIDI exclusive data */
AF_MISC_PCMMAP = 207, /* PCM mapping information (future use) */
AF_MISC_NeXT = 208, /* misc binary data appended to NeXT header */
AF_MISC_IRCAM_PEAKAMP = 209, /* peak amplitude information */
AF_MISC_IRCAM_COMMENT = 210, /* BICSF text comment */
AF_MISC_COMMENT = 210, /* general text comment */
AF_MISC_ICMT = AF_MISC_COMMENT, /* comments chunk (WAVE format) */
AF_MISC_ICRD = 211, /* creation date (WAVE format) */
AF_MISC_ISFT = 212 /* software name (WAVE format) */
};
enum
{
/* supported compression schemes */
AF_COMPRESSION_UNKNOWN = -1,
AF_COMPRESSION_NONE = 0,
AF_COMPRESSION_G722 = 501,
AF_COMPRESSION_G711_ULAW = 502,
AF_COMPRESSION_G711_ALAW = 503,
/* Apple proprietary AIFF-C compression schemes (not supported) */
AF_COMPRESSION_APPLE_ACE2 = 504,
AF_COMPRESSION_APPLE_ACE8 = 505,
AF_COMPRESSION_APPLE_MAC3 = 506,
AF_COMPRESSION_APPLE_MAC6 = 507,
AF_COMPRESSION_G726 = 517,
AF_COMPRESSION_G728 = 518,
AF_COMPRESSION_DVI_AUDIO = 519,
AF_COMPRESSION_IMA = AF_COMPRESSION_DVI_AUDIO,
AF_COMPRESSION_GSM = 520,
AF_COMPRESSION_FS1016 = 521,
AF_COMPRESSION_DV = 522,
AF_COMPRESSION_MS_ADPCM = 523,
AF_COMPRESSION_FLAC = 530,
AF_COMPRESSION_ALAC = 540
};
/* tokens for afQuery() -- see the man page for instructions */
/* level 1 selectors */
enum
{
AF_QUERYTYPE_INSTPARAM = 500,
AF_QUERYTYPE_FILEFMT = 501,
AF_QUERYTYPE_COMPRESSION = 502,
AF_QUERYTYPE_COMPRESSIONPARAM = 503,
AF_QUERYTYPE_MISC = 504,
AF_QUERYTYPE_INST = 505,
AF_QUERYTYPE_MARK = 506,
AF_QUERYTYPE_LOOP = 507
};
/* level 2 selectors */
enum
{
AF_QUERY_NAME = 600, /* get name (1-3 words) */
AF_QUERY_DESC = 601, /* get description */
AF_QUERY_LABEL = 602, /* get 4- or 5-char label */
AF_QUERY_TYPE = 603, /* get type token */
AF_QUERY_DEFAULT = 604, /* dflt. value for param */
AF_QUERY_ID_COUNT = 605, /* get number of ids avail. */
AF_QUERY_IDS = 606, /* get array of id tokens */
AF_QUERY_IMPLEMENTED = 613, /* boolean */
AF_QUERY_TYPE_COUNT = 607, /* get number of types av. */
AF_QUERY_TYPES = 608, /* get array of types */
AF_QUERY_NATIVE_SAMPFMT = 609, /* for compression */
AF_QUERY_NATIVE_SAMPWIDTH = 610,
AF_QUERY_SQUISHFAC = 611, /* 1.0 means variable */
AF_QUERY_MAX_NUMBER = 612, /* max allowed in file */
AF_QUERY_SUPPORTED = 613 /* insts, loops, etc., supported? */
};
/* level 2 selectors which have sub-selectors */
enum
{
AF_QUERY_TRACKS = 620,
AF_QUERY_CHANNELS = 621,
AF_QUERY_SAMPLE_SIZES = 622,
AF_QUERY_SAMPLE_FORMATS = 623,
AF_QUERY_COMPRESSION_TYPES = 624
};
/* level 3 sub-selectors */
enum
{
AF_QUERY_VALUE_COUNT = 650, /* number of values of the above */
AF_QUERY_VALUES = 651 /* array of those values */
};
/*
Old Audio File Library error codes. These are still returned by the
AFerrorhandler calls, but are not used by the new digital media library
error reporting routines. See the bottom of this file for the new error
tokens.
*/
enum
{
AF_BAD_NOT_IMPLEMENTED = 0, /* not implemented yet */
AF_BAD_FILEHANDLE = 1, /* tried to use invalid filehandle */
AF_BAD_OPEN = 3, /* unix open failed */
AF_BAD_CLOSE = 4, /* unix close failed */
AF_BAD_READ = 5, /* unix read failed */
AF_BAD_WRITE = 6, /* unix write failed */
AF_BAD_LSEEK = 7, /* unix lseek failed */
AF_BAD_NO_FILEHANDLE = 8, /* failed to allocate a filehandle struct */
AF_BAD_ACCMODE = 10, /* unrecognized audio file access mode */
AF_BAD_NOWRITEACC = 11, /* file not open for writing */
AF_BAD_NOREADACC = 12, /* file not open for reading */
AF_BAD_FILEFMT = 13, /* unrecognized audio file format */
AF_BAD_RATE = 14, /* invalid sample rate */
AF_BAD_CHANNELS = 15, /* invalid number of channels*/
AF_BAD_SAMPCNT = 16, /* invalid sample count */
AF_BAD_WIDTH = 17, /* invalid sample width */
AF_BAD_SEEKMODE = 18, /* invalid seek mode */
AF_BAD_NO_LOOPDATA = 19, /* failed to allocate loop struct */
AF_BAD_MALLOC = 20, /* malloc failed somewhere */
AF_BAD_LOOPID = 21,
AF_BAD_SAMPFMT = 22, /* bad sample format */
AF_BAD_FILESETUP = 23, /* bad file setup structure*/
AF_BAD_TRACKID = 24, /* no track corresponding to id */
AF_BAD_NUMTRACKS = 25, /* wrong number of tracks for file format */
AF_BAD_NO_FILESETUP = 26, /* failed to allocate a filesetup struct*/
AF_BAD_LOOPMODE = 27, /* unrecognized loop mode value */
AF_BAD_INSTID = 28, /* invalid instrument id */
AF_BAD_NUMLOOPS = 29, /* bad number of loops */
AF_BAD_NUMMARKS = 30, /* bad number of markers */
AF_BAD_MARKID = 31, /* bad marker id */
AF_BAD_MARKPOS = 32, /* invalid marker position value */
AF_BAD_NUMINSTS = 33, /* invalid number of instruments */
AF_BAD_NOAESDATA = 34,
AF_BAD_MISCID = 35,
AF_BAD_NUMMISC = 36,
AF_BAD_MISCSIZE = 37,
AF_BAD_MISCTYPE = 38,
AF_BAD_MISCSEEK = 39,
AF_BAD_STRLEN = 40, /* invalid string length */
AF_BAD_RATECONV = 45,
AF_BAD_SYNCFILE = 46,
AF_BAD_CODEC_CONFIG = 47, /* improperly configured codec */
AF_BAD_CODEC_STATE = 48, /* invalid codec state: can't recover */
AF_BAD_CODEC_LICENSE = 49, /* no license available for codec */
AF_BAD_CODEC_TYPE = 50, /* unsupported codec type */
AF_BAD_COMPRESSION = AF_BAD_CODEC_CONFIG, /* for back compat */
AF_BAD_COMPTYPE = AF_BAD_CODEC_TYPE, /* for back compat */
AF_BAD_INSTPTYPE = 51, /* invalid instrument parameter type */
AF_BAD_INSTPID = 52, /* invalid instrument parameter id */
AF_BAD_BYTEORDER = 53,
AF_BAD_FILEFMT_PARAM = 54, /* unrecognized file format parameter */
AF_BAD_COMP_PARAM = 55, /* unrecognized compression parameter */
AF_BAD_DATAOFFSET = 56, /* bad data offset */
AF_BAD_FRAMECNT = 57, /* bad frame count */
AF_BAD_QUERYTYPE = 58, /* bad query type */
AF_BAD_QUERY = 59, /* bad argument to afQuery() */
AF_WARNING_CODEC_RATE = 60, /* using 8k instead of codec rate 8012 */
AF_WARNING_RATECVT = 61, /* warning about rate conversion used */
AF_BAD_HEADER = 62, /* failed to parse header */
AF_BAD_FRAME = 63, /* bad frame number */
AF_BAD_LOOPCOUNT = 64, /* bad loop count */
AF_BAD_DMEDIA_CALL = 65, /* error in dmedia subsystem call */
/* AIFF/AIFF-C specific errors when parsing file header */
AF_BAD_AIFF_HEADER = 108, /* failed to parse chunk header */
AF_BAD_AIFF_FORM = 109, /* failed to parse FORM chunk */
AF_BAD_AIFF_SSND = 110, /* failed to parse SSND chunk */
AF_BAD_AIFF_CHUNKID = 111, /* unrecognized AIFF/AIFF-C chunk id */
AF_BAD_AIFF_COMM = 112, /* failed to parse COMM chunk */
AF_BAD_AIFF_INST = 113, /* failed to parse INST chunk */
AF_BAD_AIFF_MARK = 114, /* failed to parse MARK chunk */
AF_BAD_AIFF_SKIP = 115, /* failed to skip unsupported chunk */
AF_BAD_AIFF_LOOPMODE = 116 /* unrecognized loop mode (forw, etc)*/
};
/* new error codes which may be retrieved via dmGetError() */
/* The old error tokens continue to be retrievable via the AFerrorhandler */
/* AF_ERR_BASE is #defined in dmedia/dmedia.h */
enum
{
AF_ERR_NOT_IMPLEMENTED = 0+AF_ERR_BASE, /* not implemented yet */
AF_ERR_BAD_FILEHANDLE = 1+AF_ERR_BASE, /* invalid filehandle */
AF_ERR_BAD_READ = 5+AF_ERR_BASE, /* unix read failed */
AF_ERR_BAD_WRITE = 6+AF_ERR_BASE, /* unix write failed */
AF_ERR_BAD_LSEEK = 7+AF_ERR_BASE, /* unix lseek failed */
AF_ERR_BAD_ACCMODE = 10+AF_ERR_BASE, /* unrecognized audio file access mode */
AF_ERR_NO_WRITEACC = 11+AF_ERR_BASE, /* file not open for writing */
AF_ERR_NO_READACC = 12+AF_ERR_BASE, /* file not open for reading */
AF_ERR_BAD_FILEFMT = 13+AF_ERR_BASE, /* unrecognized audio file format */
AF_ERR_BAD_RATE = 14+AF_ERR_BASE, /* invalid sample rate */
AF_ERR_BAD_CHANNELS = 15+AF_ERR_BASE, /* invalid # channels*/
AF_ERR_BAD_SAMPCNT = 16+AF_ERR_BASE, /* invalid sample count */
AF_ERR_BAD_WIDTH = 17+AF_ERR_BASE, /* invalid sample width */
AF_ERR_BAD_SEEKMODE = 18+AF_ERR_BASE, /* invalid seek mode */
AF_ERR_BAD_LOOPID = 21+AF_ERR_BASE, /* invalid loop id */
AF_ERR_BAD_SAMPFMT = 22+AF_ERR_BASE, /* bad sample format */
AF_ERR_BAD_FILESETUP = 23+AF_ERR_BASE, /* bad file setup structure*/
AF_ERR_BAD_TRACKID = 24+AF_ERR_BASE, /* no track corresponding to id */
AF_ERR_BAD_NUMTRACKS = 25+AF_ERR_BASE, /* wrong number of tracks for file format */
AF_ERR_BAD_LOOPMODE = 27+AF_ERR_BASE, /* unrecognized loop mode symbol */
AF_ERR_BAD_INSTID = 28+AF_ERR_BASE, /* invalid instrument id */
AF_ERR_BAD_NUMLOOPS = 29+AF_ERR_BASE, /* bad number of loops */
AF_ERR_BAD_NUMMARKS = 30+AF_ERR_BASE, /* bad number of markers */
AF_ERR_BAD_MARKID = 31+AF_ERR_BASE, /* bad marker id */
AF_ERR_BAD_MARKPOS = 32+AF_ERR_BASE, /* invalid marker position value */
AF_ERR_BAD_NUMINSTS = 33+AF_ERR_BASE, /* invalid number of instruments */
AF_ERR_BAD_NOAESDATA = 34+AF_ERR_BASE,
AF_ERR_BAD_MISCID = 35+AF_ERR_BASE,
AF_ERR_BAD_NUMMISC = 36+AF_ERR_BASE,
AF_ERR_BAD_MISCSIZE = 37+AF_ERR_BASE,
AF_ERR_BAD_MISCTYPE = 38+AF_ERR_BASE,
AF_ERR_BAD_MISCSEEK = 39+AF_ERR_BASE,
AF_ERR_BAD_STRLEN = 40+AF_ERR_BASE, /* invalid string length */
AF_ERR_BAD_RATECONV = 45+AF_ERR_BASE,
AF_ERR_BAD_SYNCFILE = 46+AF_ERR_BASE,
AF_ERR_BAD_CODEC_CONFIG = 47+AF_ERR_BASE, /* improperly configured codec */
AF_ERR_BAD_CODEC_TYPE = 50+AF_ERR_BASE, /* unsupported codec type */
AF_ERR_BAD_INSTPTYPE = 51+AF_ERR_BASE, /* invalid instrument parameter type */
AF_ERR_BAD_INSTPID = 52+AF_ERR_BASE, /* invalid instrument parameter id */
AF_ERR_BAD_BYTEORDER = 53+AF_ERR_BASE,
AF_ERR_BAD_FILEFMT_PARAM = 54+AF_ERR_BASE, /* unrecognized file format parameter */
AF_ERR_BAD_COMP_PARAM = 55+AF_ERR_BASE, /* unrecognized compression parameter */
AF_ERR_BAD_DATAOFFSET = 56+AF_ERR_BASE, /* bad data offset */
AF_ERR_BAD_FRAMECNT = 57+AF_ERR_BASE, /* bad frame count */
AF_ERR_BAD_QUERYTYPE = 58+AF_ERR_BASE, /* bad query type */
AF_ERR_BAD_QUERY = 59+AF_ERR_BASE, /* bad argument to afQuery() */
AF_ERR_BAD_HEADER = 62+AF_ERR_BASE, /* failed to parse header */
AF_ERR_BAD_FRAME = 63+AF_ERR_BASE, /* bad frame number */
AF_ERR_BAD_LOOPCOUNT = 64+AF_ERR_BASE, /* bad loop count */
/* AIFF/AIFF-C specific errors when parsing file header */
AF_ERR_BAD_AIFF_HEADER = 66+AF_ERR_BASE, /* failed to parse chunk header */
AF_ERR_BAD_AIFF_FORM = 67+AF_ERR_BASE, /* failed to parse FORM chunk */
AF_ERR_BAD_AIFF_SSND = 68+AF_ERR_BASE, /* failed to parse SSND chunk */
AF_ERR_BAD_AIFF_CHUNKID = 69+AF_ERR_BASE, /* unrecognized AIFF/AIFF-C chunk id */
AF_ERR_BAD_AIFF_COMM = 70+AF_ERR_BASE, /* failed to parse COMM chunk */
AF_ERR_BAD_AIFF_INST = 71+AF_ERR_BASE, /* failed to parse INST chunk */
AF_ERR_BAD_AIFF_MARK = 72+AF_ERR_BASE, /* failed to parse MARK chunk */
AF_ERR_BAD_AIFF_SKIP = 73+AF_ERR_BASE, /* failed to skip unsupported chunk */
AF_ERR_BAD_AIFF_LOOPMODE = 74+AF_ERR_BASE /* unrecognized loop mode (forw, etc) */
};
/* global routines */
AFAPI AFerrfunc afSetErrorHandler (AFerrfunc efunc);
/* query routines */
AFAPI AUpvlist afQuery (int querytype, int arg1, int arg2, int arg3, int arg4);
AFAPI long afQueryLong (int querytype, int arg1, int arg2, int arg3, int arg4);
AFAPI double afQueryDouble (int querytype, int arg1, int arg2, int arg3, int arg4);
AFAPI void *afQueryPointer (int querytype, int arg1, int arg2, int arg3, int arg4);
/* basic operations on file handles and file setups */
AFAPI AFfilesetup afNewFileSetup (void);
AFAPI void afFreeFileSetup (AFfilesetup);
AFAPI int afIdentifyFD (int);
AFAPI int afIdentifyNamedFD (int, const char *filename, int *implemented);
AFAPI AFfilehandle afOpenFile (const char *filename, const char *mode,
AFfilesetup setup);
AFAPI AFfilehandle afOpenVirtualFile (AFvirtualfile *vfile, const char *mode,
AFfilesetup setup);
AFAPI AFfilehandle afOpenFD (int fd, const char *mode, AFfilesetup setup);
AFAPI AFfilehandle afOpenNamedFD (int fd, const char *mode, AFfilesetup setup,
const char *filename);
AFAPI void afSaveFilePosition (AFfilehandle file);
AFAPI void afRestoreFilePosition (AFfilehandle file);
AFAPI int afSyncFile (AFfilehandle file);
AFAPI int afCloseFile (AFfilehandle file);
AFAPI void afInitFileFormat (AFfilesetup, int format);
AFAPI int afGetFileFormat (AFfilehandle, int *version);
/* track */
AFAPI void afInitTrackIDs (AFfilesetup, const int *trackids, int trackCount);
AFAPI int afGetTrackIDs (AFfilehandle, int *trackids);
/* track data: reading, writng, seeking, sizing frames */
AFAPI int afReadFrames (AFfilehandle, int track, void *buffer, int frameCount);
AFAPI int afWriteFrames (AFfilehandle, int track, const void *buffer, int frameCount);
AFAPI AFframecount afSeekFrame (AFfilehandle, int track, AFframecount frameoffset);
AFAPI AFframecount afTellFrame (AFfilehandle, int track);
AFAPI AFfileoffset afGetTrackBytes (AFfilehandle, int track);
AFAPI float afGetFrameSize (AFfilehandle, int track, int expand3to4);
AFAPI float afGetVirtualFrameSize (AFfilehandle, int track, int expand3to4);
/* track data: AES data */
/* afInitAESChannelData is obsolete -- use afInitAESChannelDataTo() */
AFAPI void afInitAESChannelData (AFfilesetup, int track); /* obsolete */
AFAPI void afInitAESChannelDataTo (AFfilesetup, int track, int willBeData);
AFAPI int afGetAESChannelData (AFfilehandle, int track, unsigned char buf[24]);
AFAPI void afSetAESChannelData (AFfilehandle, int track, unsigned char buf[24]);
/* track data: byte order */
AFAPI void afInitByteOrder (AFfilesetup, int track, int byteOrder);
AFAPI int afGetByteOrder (AFfilehandle, int track);
AFAPI int afSetVirtualByteOrder (AFfilehandle, int track, int byteOrder);
AFAPI int afGetVirtualByteOrder (AFfilehandle, int track);
/* track data: number of channels */
AFAPI void afInitChannels (AFfilesetup, int track, int nchannels);
AFAPI int afGetChannels (AFfilehandle, int track);
AFAPI int afSetVirtualChannels (AFfilehandle, int track, int channelCount);
AFAPI int afGetVirtualChannels (AFfilehandle, int track);
AFAPI void afSetChannelMatrix (AFfilehandle, int track, double *matrix);
/* track data: sample format and sample width */
AFAPI void afInitSampleFormat (AFfilesetup, int track, int sampleFormat,
int sampleWidth);
AFAPI void afGetSampleFormat (AFfilehandle file, int track, int *sampleFormat,
int *sampleWidth);
AFAPI int afSetVirtualSampleFormat (AFfilehandle, int track,
int sampleFormat, int sampleWidth);
AFAPI void afGetVirtualSampleFormat (AFfilehandle, int track,
int *sampleFormat, int *sampleWidth);
/* track data: sampling rate */
AFAPI void afInitRate (AFfilesetup, int track, double rate);
AFAPI double afGetRate (AFfilehandle, int track);
#if 0
int afSetVirtualRate (AFfilehandle, int track, double rate);
double afGetVirtualRate (AFfilehandle, int track);
#endif
/* track data: compression */
AFAPI void afInitCompression (AFfilesetup, int track, int compression);
#if 0
void afInitCompressionParams (AFfilesetup, int track, int compression
AUpvlist params, int parameterCount);
#endif
AFAPI int afGetCompression (AFfilehandle, int track);
#if 0
void afGetCompressionParams (AFfilehandle, int track, int *compression,
AUpvlist params, int parameterCount);
int afSetVirtualCompression (AFfilesetup, int track, int compression);
void afSetVirtualCompressionParams (AFfilehandle, int track, int compression,
AUpvlist params, int parameterCount);
int afGetVirtualCompression (AFfilesetup, int track, int compression);
void afGetVirtualCompressionParams (AFfilehandle, int track, int *compression,
AUpvlist params, int parameterCount);
#endif
/* track data: pcm mapping */
AFAPI void afInitPCMMapping (AFfilesetup filesetup, int track,
double slope, double intercept, double minClip, double maxClip);
AFAPI void afGetPCMMapping (AFfilehandle file, int track,
double *slope, double *intercept, double *minClip, double *maxClip);
/* NOTE: afSetTrackPCMMapping() is special--it does not set the virtual */
/* format; it changes what the AF thinks the track format is! Be careful. */
AFAPI int afSetTrackPCMMapping (AFfilehandle file, int track,
double slope, double intercept, double minClip, double maxClip);
/* NOTE: afSetVirtualPCMMapping() is different from afSetTrackPCMMapping(): */
/* see comment for afSetTrackPCMMapping(). */
AFAPI int afSetVirtualPCMMapping (AFfilehandle file, int track,
double slope, double intercept, double minClip, double maxClip);
AFAPI void afGetVirtualPCMMapping (AFfilehandle file, int track,
double *slope, double *intercept, double *minClip, double *maxClip);
/* track data: data offset within the file */
/* initialize for raw reading only */
AFAPI void afInitDataOffset(AFfilesetup, int track, AFfileoffset offset);
AFAPI AFfileoffset afGetDataOffset (AFfilehandle, int track);
/* track data: count of frames in file */
AFAPI void afInitFrameCount (AFfilesetup, int track, AFframecount frameCount);
AFAPI AFframecount afGetFrameCount (AFfilehandle file, int track);
/* loop operations */
AFAPI void afInitLoopIDs (AFfilesetup, int instid, const int *ids, int nids);
AFAPI int afGetLoopIDs (AFfilehandle, int instid, int loopids[]);
AFAPI void afSetLoopMode (AFfilehandle, int instid, int loop, int mode);
AFAPI int afGetLoopMode (AFfilehandle, int instid, int loopid);
AFAPI int afSetLoopCount (AFfilehandle, int instid, int loop, int count);
AFAPI int afGetLoopCount (AFfilehandle, int instid, int loopid);
AFAPI void afSetLoopStart (AFfilehandle, int instid, int loopid, int markerid);
AFAPI int afGetLoopStart (AFfilehandle, int instid, int loopid);
AFAPI void afSetLoopEnd (AFfilehandle, int instid, int loopid, int markerid);
AFAPI int afGetLoopEnd (AFfilehandle, int instid, int loopid);
AFAPI int afSetLoopStartFrame (AFfilehandle, int instid, int loop,
AFframecount startFrame);
AFAPI AFframecount afGetLoopStartFrame (AFfilehandle, int instid, int loop);
AFAPI int afSetLoopEndFrame (AFfilehandle, int instid, int loop,
AFframecount startFrame);
AFAPI AFframecount afGetLoopEndFrame (AFfilehandle, int instid, int loop);
AFAPI void afSetLoopTrack (AFfilehandle, int instid, int loopid, int trackid);
AFAPI int afGetLoopTrack (AFfilehandle, int instid, int loopid);
/* marker operations */
AFAPI void afInitMarkIDs (AFfilesetup, int trackid, const int *ids, int nids);
AFAPI int afGetMarkIDs (AFfilehandle file, int trackid, int markids[]);
AFAPI void afSetMarkPosition (AFfilehandle file, int trackid, int markid,
AFframecount markpos);
AFAPI AFframecount afGetMarkPosition (AFfilehandle file, int trackid, int markid);
AFAPI void afInitMarkName (AFfilesetup, int trackid, int marker, const char *name);
AFAPI void afInitMarkComment (AFfilesetup, int trackid, int marker,
const char *comment);
AFAPI char *afGetMarkName (AFfilehandle file, int trackid, int markid);
AFAPI char *afGetMarkComment (AFfilehandle file, int trackid, int markid);
/* instrument operations */
AFAPI void afInitInstIDs (AFfilesetup, const int *ids, int nids);
AFAPI int afGetInstIDs (AFfilehandle file, int *instids);
AFAPI void afGetInstParams (AFfilehandle file, int instid, AUpvlist pvlist,
int nparams);
AFAPI void afSetInstParams (AFfilehandle file, int instid, AUpvlist pvlist,
int nparams);
AFAPI long afGetInstParamLong (AFfilehandle file, int instid, int param);
AFAPI void afSetInstParamLong (AFfilehandle file, int instid, int param, long value);
/* miscellaneous data operations */
AFAPI void afInitMiscIDs (AFfilesetup, const int *ids, int nids);
AFAPI int afGetMiscIDs (AFfilehandle, int *ids);
AFAPI void afInitMiscType (AFfilesetup, int miscellaneousid, int type);
AFAPI int afGetMiscType (AFfilehandle, int miscellaneousid);
AFAPI void afInitMiscSize (AFfilesetup, int miscellaneousid, int size);
AFAPI int afGetMiscSize (AFfilehandle, int miscellaneousid);
AFAPI int afWriteMisc (AFfilehandle, int miscellaneousid, const void *buf, int bytes);
AFAPI int afReadMisc (AFfilehandle, int miscellaneousid, void *buf, int bytes);
AFAPI int afSeekMisc (AFfilehandle, int miscellaneousid, int offset);
#undef AFAPI
#ifdef __cplusplus
}
#endif
#endif /* AUDIOFILE_H */

View File

@ -0,0 +1,68 @@
/*
Audio File Library
Copyright (C) 1998-2000, Michael Pruett <michael@68k.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
/*
aupvlist.h
This file contains the interface to the parameter value list data
structures and routines.
*/
#ifndef AUPVLIST_H
#define AUPVLIST_H
#ifdef __cplusplus
extern "C" {
#endif
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
#define AFAPI __attribute__((visibility("default")))
#else
#define AFAPI
#endif
enum
{
AU_PVTYPE_LONG = 1,
AU_PVTYPE_DOUBLE = 2,
AU_PVTYPE_PTR = 3
};
typedef struct _AUpvlist *AUpvlist;
#define AU_NULL_PVLIST ((struct _AUpvlist *) 0)
AFAPI AUpvlist AUpvnew (int maxItems);
AFAPI int AUpvgetmaxitems (AUpvlist);
AFAPI int AUpvfree (AUpvlist);
AFAPI int AUpvsetparam (AUpvlist, int item, int param);
AFAPI int AUpvsetvaltype (AUpvlist, int item, int type);
AFAPI int AUpvsetval (AUpvlist, int item, void *val);
AFAPI int AUpvgetparam (AUpvlist, int item, int *param);
AFAPI int AUpvgetvaltype (AUpvlist, int item, int *type);
AFAPI int AUpvgetval (AUpvlist, int item, void *val);
#undef AFAPI
#ifdef __cplusplus
}
#endif
#endif /* AUPVLIST_H */

View File

@ -802,9 +802,9 @@ int main(int argc, char *argv[])
if (config.mode == MODE_IMPORT) {
if (config.bin_truncate) {
bin_fp = fopen(config.bin_filename, "w");
bin_fp = fopen(config.bin_filename, "wb");
} else {
bin_fp = fopen(config.bin_filename, "r+");
bin_fp = fopen(config.bin_filename, "r+b");
}
if (!bin_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
@ -854,9 +854,9 @@ int main(int argc, char *argv[])
int pal_length;
if (config.pal_truncate) {
pal_fp = fopen(config.pal_filename, "w");
pal_fp = fopen(config.pal_filename, "wb");
} else {
pal_fp = fopen(config.pal_filename, "r+");
pal_fp = fopen(config.pal_filename, "r+b");
}
if (!pal_fp) {
ERROR("Error opening \"%s\"\n", config.pal_filename);
@ -934,7 +934,7 @@ int main(int argc, char *argv[])
ERROR("Error: must set position width and height for export\n");
return EXIT_FAILURE;
}
bin_fp = fopen(config.bin_filename, "r");
bin_fp = fopen(config.bin_filename, "rb");
if (!bin_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
return -1;
@ -971,7 +971,7 @@ int main(int argc, char *argv[])
INFO("Extracting %s offset 0x%X, pal.offset 0x%0X, pal.format %s\n", format2str(&config.format),
config.bin_offset, config.pal_offset, format2str(&config.pal_format));
pal_fp = fopen(config.pal_filename, "r");
pal_fp = fopen(config.pal_filename, "rb");
if (!pal_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
return EXIT_FAILURE;

View File

@ -0,0 +1,318 @@
diff --git a/libaudiofile/FileHandle.cpp b/libaudiofile/FileHandle.cpp
index 8562d4b..5d6342a 100644
--- a/libaudiofile/FileHandle.cpp
+++ b/libaudiofile/FileHandle.cpp
@@ -74,26 +74,8 @@ _AFfilehandle *_AFfilehandle::create(int fileFormat)
case AF_FILE_AIFF:
case AF_FILE_AIFFC:
return new AIFFFile();
- case AF_FILE_NEXTSND:
- return new NeXTFile();
case AF_FILE_WAVE:
return new WAVEFile();
- case AF_FILE_BICSF:
- return new IRCAMFile();
- case AF_FILE_AVR:
- return new AVRFile();
- case AF_FILE_IFF_8SVX:
- return new IFFFile();
- case AF_FILE_SAMPLEVISION:
- return new SampleVisionFile();
- case AF_FILE_VOC:
- return new VOCFile();
- case AF_FILE_NIST_SPHERE:
- return new NISTFile();
- case AF_FILE_CAF:
- return new CAFFile();
- case AF_FILE_FLAC:
- return new FLACFile();
default:
return NULL;
}
diff --git a/libaudiofile/aupv.c b/libaudiofile/aupv.c
index 64e798b..374838b 100644
--- a/libaudiofile/aupv.c
+++ b/libaudiofile/aupv.c
@@ -47,7 +47,7 @@ AUpvlist AUpvnew (int maxitems)
if (aupvlist == NULL)
return AU_NULL_PVLIST;
- aupvlist->items = calloc(maxitems, sizeof (struct _AUpvitem));
+ aupvlist->items = (struct _AUpvitem *)calloc(maxitems, sizeof (struct _AUpvitem));
assert(aupvlist->items);
if (aupvlist->items == NULL)
diff --git a/libaudiofile/g711.c b/libaudiofile/g711.c
index 8fb2323..1b323ec 100644
--- a/libaudiofile/g711.c
+++ b/libaudiofile/g711.c
@@ -74,8 +74,7 @@ static int search(int val, const short *table, int size)
* John Wiley & Sons, pps 98-111 and 472-476.
*/
unsigned char
-_af_linear2alaw(pcm_val)
- int pcm_val; /* 2's complement (16-bit range) */
+_af_linear2alaw(int pcm_val)
{
int mask;
int seg;
@@ -110,8 +109,7 @@ _af_linear2alaw(pcm_val)
*
*/
int
-_af_alaw2linear(a_val)
- unsigned char a_val;
+_af_alaw2linear(unsigned char a_val)
{
int t;
int seg;
diff --git a/libaudiofile/units.cpp b/libaudiofile/units.cpp
index ffd0a63..51d2dc3 100644
--- a/libaudiofile/units.cpp
+++ b/libaudiofile/units.cpp
@@ -32,24 +32,12 @@
#include "units.h"
#include "AIFF.h"
-#include "AVR.h"
-#include "CAF.h"
-#include "FLACFile.h"
-#include "IFF.h"
-#include "IRCAM.h"
-#include "NeXT.h"
-#include "NIST.h"
#include "Raw.h"
-#include "SampleVision.h"
-#include "VOC.h"
#include "WAVE.h"
#include "compression.h"
-#include "modules/ALAC.h"
-#include "modules/FLAC.h"
#include "modules/G711.h"
-#include "modules/IMA.h"
#include "modules/MSADPCM.h"
#include "modules/PCM.h"
@@ -99,20 +87,6 @@ const Unit _af_units[_AF_NUM_UNITS] =
_AF_AIFF_NUM_INSTPARAMS,
_af_aiff_inst_params
},
- {
- AF_FILE_NEXTSND,
- "NeXT .snd/Sun .au", "NeXT .snd/Sun .au Format", "next",
- true,
- NeXTFile::completeSetup,
- NeXTFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_NEXT_NUM_COMPTYPES,
- _af_next_compression_types,
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, NULL
- },
{
AF_FILE_WAVE,
"MS RIFF WAVE", "Microsoft RIFF WAVE Format", "wave",
@@ -128,144 +102,6 @@ const Unit _af_units[_AF_NUM_UNITS] =
_AF_WAVE_NUM_INSTPARAMS,
_af_wave_inst_params
},
- {
- AF_FILE_IRCAM,
- "BICSF", "Berkeley/IRCAM/CARL Sound Format", "bicsf",
- true,
- IRCAMFile::completeSetup,
- IRCAMFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_IRCAM_NUM_COMPTYPES,
- _af_ircam_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_MPEG1BITSTREAM,
- "MPEG", "MPEG Audio Bitstream", "mpeg",
- false
- },
- {
- AF_FILE_SOUNDDESIGNER1,
- "Sound Designer 1", "Sound Designer 1 File Format", "sd1",
- false
- },
- {
- AF_FILE_SOUNDDESIGNER2,
- "Sound Designer 2", "Sound Designer 2 File Format", "sd2",
- false
- },
- {
- AF_FILE_AVR,
- "AVR", "Audio Visual Research File Format", "avr",
- true,
- AVRFile::completeSetup,
- AVRFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- },
- {
- AF_FILE_IFF_8SVX,
- "IFF/8SVX", "Amiga IFF/8SVX Sound File Format", "iff",
- true,
- IFFFile::completeSetup,
- IFFFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 8,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- },
- {
- AF_FILE_SAMPLEVISION,
- "Sample Vision", "Sample Vision File Format", "smp",
- true,
- SampleVisionFile::completeSetup,
- SampleVisionFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, // number of compression types
- NULL, // compression types
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_VOC,
- "VOC", "Creative Voice File Format", "voc",
- true,
- VOCFile::completeSetup,
- VOCFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_VOC_NUM_COMPTYPES,
- _af_voc_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_NIST_SPHERE,
- "NIST SPHERE", "NIST SPHERE File Format", "nist",
- true,
- NISTFile::completeSetup,
- NISTFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- NULL /* instrument parameters */
- },
- {
- AF_FILE_SOUNDFONT2,
- "SoundFont 2", "SoundFont 2 File Format", "sf2",
- false
- },
- {
- AF_FILE_CAF,
- "CAF", "Core Audio Format", "caf",
- true,
- CAFFile::completeSetup,
- CAFFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_CAF_NUM_COMPTYPES,
- _af_caf_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_FLAC,
- "FLAC", "Free Lossless Audio Codec", "flac",
- true,
- FLACFile::completeSetup,
- FLACFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_FLAC_NUM_COMPTYPES,
- _af_flac_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- }
};
const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
@@ -309,19 +145,6 @@ const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
_af_g711_format_ok,
_AFg711initcompress, _AFg711initdecompress
},
- {
- AF_COMPRESSION_IMA,
- true,
- "ima4", /* label */
- "IMA ADPCM", /* short name */
- "IMA DVI ADPCM",
- 4.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- true, /* needsRebuffer */
- false, /* multiple_of */
- _af_ima_adpcm_format_ok,
- _af_ima_adpcm_init_compress, _af_ima_adpcm_init_decompress
- },
{
AF_COMPRESSION_MS_ADPCM,
true,
@@ -335,34 +158,4 @@ const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
_af_ms_adpcm_format_ok,
_af_ms_adpcm_init_compress, _af_ms_adpcm_init_decompress
},
- {
- AF_COMPRESSION_FLAC,
-#if ENABLE(FLAC)
- true,
-#else
- false,
-#endif
- "flac", // label
- "FLAC", // short name
- "Free Lossless Audio Codec",
- 1.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- false, // needsRebuffer
- false, // multiple_of
- _af_flac_format_ok,
- _af_flac_init_compress, _af_flac_init_decompress
- },
- {
- AF_COMPRESSION_ALAC,
- true,
- "alac", // label
- "ALAC", // short name
- "Apple Lossless Audio Codec",
- 1.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- true, // needsRebuffer
- false, // multiple_of
- _af_alac_format_ok,
- _af_alac_init_compress, _af_alac_init_decompress
- }
};

View File

@ -63,16 +63,6 @@ file_list = [
'Commands/CDirectiveMessage.h',
'Commands/CDirectiveMessage.cpp',
'Commands/CommandSequence.cpp',
'Core/ELF/ElfFile.cpp',
'Core/ELF/ElfRelocator.cpp',
'Core/Assembler.cpp',
'Core/Common.cpp',
'Core/Expression.cpp',
'Core/ExpressionFunctions.cpp',
'Core/FileManager.cpp',
'Core/Misc.cpp',
'Core/SymbolData.cpp',
'Core/SymbolTable.cpp',
'Parser/DirectivesParser.cpp',
'Parser/ExpressionParser.cpp',
'Parser/Parser.cpp',
@ -84,6 +74,16 @@ file_list = [
'Util/Util.cpp',
'Main/CommandLineInterface.h',
'Main/CommandLineInterface.cpp',
'Core/ELF/ElfFile.cpp',
'Core/ELF/ElfRelocator.cpp',
'Core/Assembler.cpp',
'Core/Common.cpp',
'Core/Expression.cpp',
'Core/ExpressionFunctions.cpp',
'Core/FileManager.cpp',
'Core/Misc.cpp',
'Core/SymbolData.cpp',
'Core/SymbolTable.cpp',
'Main/main.cpp',
]

View File

@ -0,0 +1,136 @@
#!/usr/bin/env python
import os
import re
import sys
file_list = [
'Features.h',
'Compiler.h',
'error.h',
'extended.h',
'compression.h',
'aupvinternal.h',
'aupvlist.h',
'audiofile.h',
'afinternal.h',
'byteorder.h',
'AudioFormat.h',
'debug.h',
'util.h',
'units.h',
'UUID.h',
'Shared.h',
'Buffer.h',
'File.h',
'FileHandle.h',
'Instrument.h',
'Track.h',
'Marker.h',
'Setup.h',
'Tag.h',
'PacketTable.h',
'pcm.h',
'g711.h',
'af_vfs.h',
'Raw.h',
'WAVE.h',
'SampleVision.h',
'modules/Module.h',
'modules/ModuleState.h',
'modules/SimpleModule.h',
'modules/FileModule.h',
'modules/RebufferModule.h',
'modules/BlockCodec.h',
'modules/BlockCodec.cpp',
'modules/FileModule.cpp',
'modules/G711.h',
'modules/G711.cpp',
'modules/Module.cpp',
'modules/ModuleState.cpp',
'modules/MSADPCM.h',
'modules/MSADPCM.cpp',
'modules/PCM.h',
'modules/PCM.cpp',
'modules/SimpleModule.cpp',
'modules/RebufferModule.cpp',
'AIFF.h',
'AIFF.cpp',
'AudioFormat.cpp',
'Buffer.cpp',
'File.cpp',
'FileHandle.cpp',
'Instrument.cpp',
'Loop.cpp',
'Marker.cpp',
'Miscellaneous.cpp',
'PacketTable.cpp',
'Raw.cpp',
'Setup.cpp',
'Track.cpp',
'UUID.cpp',
'WAVE.cpp',
'aes.cpp',
'af_vfs.cpp',
'aupv.c',
'compression.cpp',
'data.cpp',
'debug.cpp',
'error.c',
'extended.c',
'format.cpp',
'g711.c',
'openclose.cpp',
'pcm.cpp',
'query.cpp',
'units.cpp',
'util.cpp',
]
file_header = \
"""// libaudiofile b62c902
// https://github.com/mpruett/audiofile
// To simplify compilation, all files have been concatenated into one.
// Support for all formats except WAVE, AIFF(C) and RAW has been stripped out.
"""
prepend_defs = \
"""#define HAVE_UNISTD_H 1
#if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
#endif
#include <stdlib.h>
"""
def banned(line):
return '#pragma once' in line or '#include "' in line or '#include <config.h>' in line
def cat_file(fout, fin_name):
with open(fin_name) as fin:
lines = fin.readlines()
lines = [l.rstrip() for l in lines if not banned(l)]
for l in lines:
fout.write(l + '\n')
fout.write('\n')
def combine_libaudiofile(fout_name, libaudiofile_path):
with open(fout_name, 'w') as fout:
fout.write(file_header + "\n")
fout.write("/*\n")
cat_file(fout, os.path.join(libaudiofile_path, '../COPYING'))
fout.write("*/\n\n")
fout.write(prepend_defs + "\n")
for f in file_list:
fout.write(f"// file: {f}\n")
cat_file(fout, os.path.join(libaudiofile_path, f))
def main():
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help']:
print('Usage: generate_audiofile_cpp.py [output_filename] [libaudiofile_src_dir]')
print('Defaults: [output_filename = "audiofile.cpp"] [libaudiofile_src_dir = "./audiofile/libaudiofile"]')
return
fout_name = sys.argv[1] if len(sys.argv) > 1 else 'audiofile.cpp'
libaudiofile_path = sys.argv[2] if len(sys.argv) > 2 else './audiofile/libaudiofile'
combine_libaudiofile(fout_name, os.path.expanduser(libaudiofile_path))
main()