├── .gitattributes ├── .gitignore ├── .gitmodules ├── 3rdparty └── libmad │ ├── CHANGES │ ├── COPYING │ ├── COPYRIGHT │ ├── CREDITS │ ├── D.dat │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── TODO │ ├── VERSION │ ├── aclocal.m4 │ ├── bit.c │ ├── bit.h │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── decoder.c │ ├── decoder.h │ ├── depcomp │ ├── fixed.c │ ├── fixed.h │ ├── frame.c │ ├── frame.h │ ├── global.h │ ├── huffman.c │ ├── huffman.h │ ├── imdct_l_arm.S │ ├── imdct_s.dat │ ├── install-sh │ ├── layer12.c │ ├── layer12.h │ ├── layer3.c │ ├── layer3.h │ ├── libmad.list.in │ ├── ltmain.sh │ ├── mad.h │ ├── mad.h.sed │ ├── minimad.c │ ├── missing │ ├── mkinstalldirs │ ├── msvc++ │ ├── Makefile.am │ ├── Makefile.in │ ├── config.h │ ├── libmad.dsp │ └── mad.h │ ├── qc_table.dat │ ├── rq_table.dat │ ├── sf_table.dat │ ├── stream.c │ ├── stream.h │ ├── synth.c │ ├── synth.h │ ├── timer.c │ ├── timer.h │ ├── version.c │ └── version.h ├── LICENSE ├── Makefile ├── README.md ├── configs ├── alttp_albw.json ├── alttp_arranged.json ├── chrono_symphony.json ├── mmx_guitar_playthrough.json ├── schema └── super_mario_odyssey.json ├── msupcm++.sln └── msupcm++ ├── AudioBase.cpp ├── AudioBase.h ├── AudioSubChannel.cpp ├── AudioSubChannel.h ├── AudioSubTrack.cpp ├── AudioSubTrack.h ├── AudioTrack.cpp ├── AudioTrack.h ├── AudioTrackList.cpp ├── AudioTrackList.h ├── AudioTrackListBuilder.cpp ├── AudioTrackListBuilder.h ├── GlobalConfig.cpp ├── GlobalConfig.h ├── Makefile ├── SoxWrapper.cpp ├── SoxWrapper.h ├── TrackParser.hpp ├── getopt.c ├── getopt.h ├── msupcm++.vcxproj ├── msupcm++.vcxproj.filters ├── msupcm.cpp ├── sox_main.c ├── sox_main.h ├── utf8.cpp └── utf8.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | 65 | ############################################################################### 66 | # ensure proper line endings for *nix-specific scripts 67 | # 68 | ############################################################################### 69 | *.am eol=lf 70 | *.in eol=lf 71 | *.sh eol=lf 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | #*_i.c 48 | *_p.c 49 | #*_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.o 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | 144 | # TODO: Un-comment the next line if you do not want to checkin 145 | # your web deploy settings because they may include unencrypted 146 | # passwords 147 | #*.pubxml 148 | *.publishproj 149 | 150 | # NuGet Packages 151 | *.nupkg 152 | # The packages folder can be ignored because of Package Restore 153 | **/packages/* 154 | # except build/, which is used as an MSBuild target. 155 | !**/packages/build/ 156 | # Uncomment if necessary however generally it will be regenerated when needed 157 | #!**/packages/repositories.config 158 | # NuGet v3's project.json files produces more ignoreable files 159 | *.nuget.props 160 | *.nuget.targets 161 | 162 | # Microsoft Azure Build Output 163 | csx/ 164 | *.build.csdef 165 | 166 | # Microsoft Azure Emulator 167 | ecf/ 168 | rcf/ 169 | 170 | # Microsoft Azure ApplicationInsights config file 171 | ApplicationInsights.config 172 | 173 | # Windows Store app package directory 174 | AppPackages/ 175 | BundleArtifacts/ 176 | 177 | # Visual Studio cache files 178 | # files ending in .cache can be ignored 179 | *.[Cc]ache 180 | # but keep track of directories ending in .cache 181 | !*.[Cc]ache/ 182 | 183 | # Others 184 | ClientBin/ 185 | [Ss]tyle[Cc]op.* 186 | ~$* 187 | *~ 188 | *.dbmdl 189 | *.dbproj.schemaview 190 | *.pfx 191 | *.publishsettings 192 | node_modules/ 193 | orleans.codegen.cs 194 | 195 | # RIA/Silverlight projects 196 | Generated_Code/ 197 | 198 | # Backup & report files from converting an old project file 199 | # to a newer Visual Studio version. Backup files are not needed, 200 | # because we have git ;-) 201 | _UpgradeReport_Files/ 202 | Backup*/ 203 | UpgradeLog*.XML 204 | UpgradeLog*.htm 205 | 206 | # SQL Server files 207 | *.mdf 208 | *.ldf 209 | 210 | # Business Intelligence projects 211 | *.rdl.data 212 | *.bim.layout 213 | *.bim_*.settings 214 | 215 | # Microsoft Fakes 216 | FakesAssemblies/ 217 | 218 | # GhostDoc plugin setting file 219 | *.GhostDoc.xml 220 | 221 | # Node.js Tools for Visual Studio 222 | .ntvs_analysis.dat 223 | 224 | # Visual Studio 6 build log 225 | *.plg 226 | 227 | # Visual Studio 6 workspace options file 228 | *.opt 229 | 230 | # Visual Studio LightSwitch build output 231 | **/*.HTMLClient/GeneratedArtifacts 232 | **/*.DesktopClient/GeneratedArtifacts 233 | **/*.DesktopClient/ModelManifest.xml 234 | **/*.Server/GeneratedArtifacts 235 | **/*.Server/ModelManifest.xml 236 | _Pvt_Extensions 237 | 238 | # LightSwitch generated files 239 | GeneratedArtifacts/ 240 | ModelManifest.xml 241 | 242 | # Paket dependency manager 243 | .paket/paket.exe 244 | 245 | # FAKE - F# Make 246 | .fake/ 247 | 248 | # Linux binary 249 | msupcm 250 | 251 | # Test files 252 | tracks.json 253 | tracks/ 254 | *.flac 255 | *.mp3 256 | *.ogg 257 | *.pcm 258 | *.wav 259 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rdparty/flac"] 2 | path = 3rdparty/flac 3 | url = https://github.com/xiph/flac.git 4 | [submodule "3rdparty/libogg"] 5 | path = 3rdparty/libogg 6 | url = https://github.com/xiph/ogg.git 7 | [submodule "3rdparty/libvorbis"] 8 | path = 3rdparty/libvorbis 9 | url = https://github.com/xiph/vorbis.git 10 | [submodule "3rdparty/json"] 11 | path = 3rdparty/json 12 | url = https://github.com/nlohmann/json.git 13 | [submodule "3rdparty/sox"] 14 | path = 3rdparty/sox 15 | url = https://github.com/qwertymodo/sox.git 16 | -------------------------------------------------------------------------------- /3rdparty/libmad/COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | libmad - MPEG audio decoder library 3 | Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | If you would like to negotiate alternate licensing terms, you may do 20 | so by contacting: Underbit Technologies, Inc. 21 | 22 | -------------------------------------------------------------------------------- /3rdparty/libmad/CREDITS: -------------------------------------------------------------------------------- 1 | 2 | libmad - MPEG audio decoder library 3 | Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | 5 | $Id: CREDITS,v 1.5 2004/02/17 02:02:03 rob Exp $ 6 | 7 | =============================================================================== 8 | 9 | AUTHOR 10 | 11 | Except where otherwise noted, all code was authored by: 12 | 13 | Robert Leslie 14 | 15 | CONTRIBUTORS 16 | 17 | Significant contributions have been incorporated with thanks to: 18 | 19 | Anonymous 20 | 2002/03/15: frame.c 21 | - Reported problem with use of reserved emphasis value. 22 | 2003/08/31: layer12.c 23 | - Suggested support for certain disallowed bitrate/mode 24 | combinations. 25 | 26 | Niek Albers 27 | 2003/04/21: layer3.c 28 | - Reported runtime uninitialized use of `ptr' in designating 29 | ancillary bits after a decoding error. 30 | 31 | Christian Biere 32 | 2003/02/01: frame.c 33 | - Reported assertion failure in layer3.c due to an 34 | invalid/unsupported Layer III free format bitrate. 35 | 36 | David Blythe 37 | 2001/01/30: fixed.h 38 | - Provided initial PowerPC fixed-point assembly. 39 | 40 | Simon Burge 41 | 2000/09/20: imdct_l_arm.S 42 | - Suggested patch for a.out compatibility. 43 | 44 | Brian Cameron 45 | 2003/07/02: huffman.c 46 | - Suggested changes for improved portability. 47 | 48 | Joshua Haberman 49 | 2001/08/10: decoder.c, huffman.c 50 | - Suggested portability fixes. 51 | 52 | Timothy King 53 | 2002/05/04: sf_table.dat, layer12.c 54 | - Reported problem with use of (missing) scalefactor index 63. 55 | 56 | Felix von Leitner 57 | 2003/01/21: fixed.h 58 | - Suggested Intel scaling alternative for possible speedup. 59 | 60 | Andre McCurdy 61 | 2000/08/10: imdct_l_arm.S 62 | - ARM optimized assembly replacement for III_imdct_l(). 63 | 2000/09/15: imdct_l_arm.S 64 | - Applied Nicolas Pitre's rounding optimisation in all remaining 65 | places. 66 | 2001/02/10: layer3.c 67 | - Inspiration for Huffman decoding and requantization rewrite, and 68 | other miscellany. 69 | 2001/03/24: imdct_l_arm.S 70 | - Corrected PIC unsafe code. 71 | 2002/02/16: fixed.h 72 | - Discovered bug in ARM version of mad_f_scale64(). 73 | 74 | Haruhiko OGASAWARA 75 | 2001/01/28: layer3.c 76 | - Reported discrepancy in alias reduction for mixed short blocks. 77 | 78 | Brett Paterson 79 | 2001/10/28: global.h 80 | - Reported missing et al. under MS Embedded Visual C. 81 | 82 | Sean 'Shaleh' Perry 83 | 2000/04/04: fixed.h 84 | - Suggested use of size-dependent typedefs. 85 | 2001/10/22: config.guess, config.sub 86 | - Keep up to date for proper Debian packaging. 87 | 88 | Bertrand Petit 89 | 2001/11/05: synth.h 90 | - Suggested PCM channel enumeration constants. 91 | 2001/11/05: stream.h 92 | - Suggested MAD_ERROR_NONE enumeration constant. 93 | 2001/11/05: stream.c 94 | - Suggested mad_stream_errorstr() function. 95 | 96 | Nicolas Pitre 97 | 2000/09/09: fixed.h 98 | - Parameterized all scaling for correct use of all multiplication 99 | methods within mad_synth_frame(). 100 | - Rewrote the FPM_ARM version of mad_f_mul() so we have 64-bit 101 | multiplication result, rounding and scaling with 3 instructions. 102 | 2000/09/09: imdct_l_arm.S 103 | - Optimized rounding + scaling operations. 104 | 2000/09/17: synth.c 105 | - Changed D[] run-time shifts to compile-time. 106 | - Modified synthesis for better multiply/accumulate code output. 107 | 2001/08/11: fixed.h, synth.c 108 | - Suggested 64-bit FPM negation and negative term factorization 109 | during synthesis. 110 | 2001/08/11: fixed.h 111 | - Suggested unrounded behavior for FPM_DEFAULT when OPT_SPEED. 112 | 2001/11/19: fixed.c 113 | - Suggested computation of any resampling ratio. 114 | 115 | =============================================================================== 116 | 117 | -------------------------------------------------------------------------------- /3rdparty/libmad/INSTALL: -------------------------------------------------------------------------------- 1 | Basic Installation 2 | ================== 3 | 4 | These are generic installation instructions. 5 | 6 | The `configure' shell script attempts to guess correct values for 7 | various system-dependent variables used during compilation. It uses 8 | those values to create a `Makefile' in each directory of the package. 9 | It may also create one or more `.h' files containing system-dependent 10 | definitions. Finally, it creates a shell script `config.status' that 11 | you can run in the future to recreate the current configuration, a file 12 | `config.cache' that saves the results of its tests to speed up 13 | reconfiguring, and a file `config.log' containing compiler output 14 | (useful mainly for debugging `configure'). 15 | 16 | If you need to do unusual things to compile the package, please try 17 | to figure out how `configure' could check whether to do them, and mail 18 | diffs or instructions to the address given in the `README' so they can 19 | be considered for the next release. If at some point `config.cache' 20 | contains results you don't want to keep, you may remove or edit it. 21 | 22 | The file `configure.in' is used to create `configure' by a program 23 | called `autoconf'. You only need `configure.in' if you want to change 24 | it or regenerate `configure' using a newer version of `autoconf'. 25 | 26 | The simplest way to compile this package is: 27 | 28 | 1. `cd' to the directory containing the package's source code and type 29 | `./configure' to configure the package for your system. If you're 30 | using `csh' on an old version of System V, you might need to type 31 | `sh ./configure' instead to prevent `csh' from trying to execute 32 | `configure' itself. 33 | 34 | Running `configure' takes awhile. While running, it prints some 35 | messages telling which features it is checking for. 36 | 37 | 2. Type `make' to compile the package. 38 | 39 | 3. Optionally, type `make check' to run any self-tests that come with 40 | the package. 41 | 42 | 4. Type `make install' to install the programs and any data files and 43 | documentation. 44 | 45 | 5. You can remove the program binaries and object files from the 46 | source code directory by typing `make clean'. To also remove the 47 | files that `configure' created (so you can compile the package for 48 | a different kind of computer), type `make distclean'. There is 49 | also a `make maintainer-clean' target, but that is intended mainly 50 | for the package's developers. If you use it, you may have to get 51 | all sorts of other programs in order to regenerate files that came 52 | with the distribution. 53 | 54 | Compilers and Options 55 | ===================== 56 | 57 | Some systems require unusual options for compilation or linking that 58 | the `configure' script does not know about. You can give `configure' 59 | initial values for variables by setting them in the environment. Using 60 | a Bourne-compatible shell, you can do that on the command line like 61 | this: 62 | CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure 63 | 64 | Or on systems that have the `env' program, you can do it like this: 65 | env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 66 | 67 | Compiling For Multiple Architectures 68 | ==================================== 69 | 70 | You can compile the package for more than one kind of computer at the 71 | same time, by placing the object files for each architecture in their 72 | own directory. To do this, you must use a version of `make' that 73 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 74 | directory where you want the object files and executables to go and run 75 | the `configure' script. `configure' automatically checks for the 76 | source code in the directory that `configure' is in and in `..'. 77 | 78 | If you have to use a `make' that does not supports the `VPATH' 79 | variable, you have to compile the package for one architecture at a time 80 | in the source code directory. After you have installed the package for 81 | one architecture, use `make distclean' before reconfiguring for another 82 | architecture. 83 | 84 | Installation Names 85 | ================== 86 | 87 | By default, `make install' will install the package's files in 88 | `/usr/local/bin', `/usr/local/man', etc. You can specify an 89 | installation prefix other than `/usr/local' by giving `configure' the 90 | option `--prefix=PATH'. 91 | 92 | You can specify separate installation prefixes for 93 | architecture-specific files and architecture-independent files. If you 94 | give `configure' the option `--exec-prefix=PATH', the package will use 95 | PATH as the prefix for installing programs and libraries. 96 | Documentation and other data files will still use the regular prefix. 97 | 98 | In addition, if you use an unusual directory layout you can give 99 | options like `--bindir=PATH' to specify different values for particular 100 | kinds of files. Run `configure --help' for a list of the directories 101 | you can set and what kinds of files go in them. 102 | 103 | If the package supports it, you can cause programs to be installed 104 | with an extra prefix or suffix on their names by giving `configure' the 105 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 106 | 107 | Optional Features 108 | ================= 109 | 110 | Some packages pay attention to `--enable-FEATURE' options to 111 | `configure', where FEATURE indicates an optional part of the package. 112 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 113 | is something like `gnu-as' or `x' (for the X Window System). The 114 | `README' should mention any `--enable-' and `--with-' options that the 115 | package recognizes. 116 | 117 | For packages that use the X Window System, `configure' can usually 118 | find the X include and library files automatically, but if it doesn't, 119 | you can use the `configure' options `--x-includes=DIR' and 120 | `--x-libraries=DIR' to specify their locations. 121 | 122 | Specifying the System Type 123 | ========================== 124 | 125 | There may be some features `configure' can not figure out 126 | automatically, but needs to determine by the type of host the package 127 | will run on. Usually `configure' can figure that out, but if it prints 128 | a message saying it can not guess the host type, give it the 129 | `--host=TYPE' option. TYPE can either be a short name for the system 130 | type, such as `sun4', or a canonical name with three fields: 131 | CPU-COMPANY-SYSTEM 132 | 133 | See the file `config.sub' for the possible values of each field. If 134 | `config.sub' isn't included in this package, then this package doesn't 135 | need to know the host type. 136 | 137 | If you are building compiler tools for cross-compiling, you can also 138 | use the `--target=TYPE' option to select the type of system they will 139 | produce code for and the `--build=TYPE' option to select the type of 140 | system on which you are compiling the package. 141 | 142 | Sharing Defaults 143 | ================ 144 | 145 | If you want to set default values for `configure' scripts to share, 146 | you can create a site shell script called `config.site' that gives 147 | default values for variables like `CC', `cache_file', and `prefix'. 148 | `configure' looks for `PREFIX/share/config.site' if it exists, then 149 | `PREFIX/etc/config.site' if it exists. Or, you can set the 150 | `CONFIG_SITE' environment variable to the location of the site script. 151 | A warning: not all `configure' scripts look for a site script. 152 | 153 | Operation Controls 154 | ================== 155 | 156 | `configure' recognizes the following options to control how it 157 | operates. 158 | 159 | `--cache-file=FILE' 160 | Use and save the results of the tests in FILE instead of 161 | `./config.cache'. Set FILE to `/dev/null' to disable caching, for 162 | debugging `configure'. 163 | 164 | `--help' 165 | Print a summary of the options to `configure', and exit. 166 | 167 | `--quiet' 168 | `--silent' 169 | `-q' 170 | Do not print messages saying which checks are being made. To 171 | suppress all normal output, redirect it to `/dev/null' (any error 172 | messages will still be shown). 173 | 174 | `--srcdir=DIR' 175 | Look for the package's source code in directory DIR. Usually 176 | `configure' can determine that directory automatically. 177 | 178 | `--version' 179 | Print the version of Autoconf used to generate the `configure' 180 | script, and exit. 181 | 182 | `configure' also accepts some other, not widely useful, options. 183 | 184 | -------------------------------------------------------------------------------- /3rdparty/libmad/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## libmad - MPEG audio decoder library 3 | ## Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | ## 5 | ## This program is free software; you can redistribute it and/or modify 6 | ## it under the terms of the GNU General Public License as published by 7 | ## the Free Software Foundation; either version 2 of the License, or 8 | ## (at your option) any later version. 9 | ## 10 | ## This program is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ## GNU General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU General Public License 16 | ## along with this program; if not, write to the Free Software 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | ## 19 | ## $Id: Makefile.am,v 1.23 2004/02/17 02:02:03 rob Exp $ 20 | ## 21 | 22 | ## Process this file with automake to produce Makefile.in 23 | 24 | SUBDIRS = 25 | DIST_SUBDIRS = msvc++ 26 | 27 | lib_LTLIBRARIES = libmad.la 28 | include_HEADERS = mad.h 29 | 30 | EXTRA_PROGRAMS = minimad 31 | 32 | minimad_SOURCES = minimad.c 33 | minimad_INCLUDES = 34 | minimad_LDADD = libmad.la 35 | 36 | EXTRA_DIST = mad.h.sed \ 37 | CHANGES COPYRIGHT CREDITS README TODO VERSION 38 | 39 | exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \ 40 | synth.h decoder.h 41 | 42 | headers = $(exported_headers) \ 43 | global.h layer12.h layer3.h huffman.h 44 | 45 | data_includes = D.dat imdct_s.dat qc_table.dat rq_table.dat \ 46 | sf_table.dat 47 | 48 | libmad_la_SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c \ 49 | synth.c decoder.c layer12.c layer3.c huffman.c \ 50 | $(headers) $(data_includes) 51 | 52 | EXTRA_libmad_la_SOURCES = imdct_l_arm.S #synth_mmx.S 53 | 54 | libmad_la_DEPENDENCIES = @ASO_OBJS@ 55 | libmad_la_LIBADD = @ASO_OBJS@ 56 | 57 | INCLUDES = $(FPM) $(ASO) 58 | 59 | BUILT_SOURCES = mad.h 60 | CLEANFILES = mad.h 61 | 62 | ## From the libtool documentation on library versioning: 63 | ## 64 | ## CURRENT 65 | ## The most recent interface number that this library implements. 66 | ## 67 | ## REVISION 68 | ## The implementation number of the CURRENT interface. 69 | ## 70 | ## AGE 71 | ## The difference between the newest and oldest interfaces that this 72 | ## library implements. In other words, the library implements all the 73 | ## interface numbers in the range from number `CURRENT - AGE' to 74 | ## `CURRENT'. 75 | ## 76 | ## If two libraries have identical CURRENT and AGE numbers, then the 77 | ## dynamic linker chooses the library with the greater REVISION number. 78 | ## 79 | ## 1. Start with version information of `0:0:0' for each libtool library. 80 | ## 81 | ## 2. Update the version information only immediately before a public 82 | ## release of your software. More frequent updates are unnecessary, 83 | ## and only guarantee that the current interface number gets larger 84 | ## faster. 85 | ## 86 | ## 3. If the library source code has changed at all since the last 87 | ## update, then increment REVISION (`C:R:A' becomes `C:r+1:A'). 88 | ## 89 | ## 4. If any interfaces have been added, removed, or changed since the 90 | ## last update, increment CURRENT, and set REVISION to 0. 91 | ## 92 | ## 5. If any interfaces have been added since the last public release, 93 | ## then increment AGE. 94 | ## 95 | ## 6. If any interfaces have been removed since the last public release, 96 | ## then set AGE to 0. 97 | 98 | version_current = 2 99 | version_revision = 1 100 | version_age = 2 101 | 102 | version_info = $(version_current):$(version_revision):$(version_age) 103 | 104 | libmad_la_LDFLAGS = -version-info $(version_info) 105 | 106 | mad.h: config.status config.h Makefile.am \ 107 | $(srcdir)/COPYRIGHT $(srcdir)/mad.h.sed $(exported_headers) 108 | (sed -e '1s|.*|/*|' -e '1b' -e '$$s|.*| */|' -e '$$b' \ 109 | -e 's/^.*/ *&/' $(srcdir)/COPYRIGHT; echo; \ 110 | echo "# ifdef __cplusplus"; \ 111 | echo 'extern "C" {'; \ 112 | echo "# endif"; echo; \ 113 | if [ ".$(FPM)" != "." ]; then \ 114 | echo ".$(FPM)" | sed -e 's|^\.-D|# define |'; echo; \ 115 | fi; \ 116 | sed -ne 's/^# *define *\(HAVE_.*_ASM\).*/# define \1/p' \ 117 | config.h; echo; \ 118 | sed -ne 's/^# *define *OPT_\(SPEED\|ACCURACY\).*/# define OPT_\1/p' \ 119 | config.h; echo; \ 120 | sed -ne 's/^# *define *\(SIZEOF_.*\)/# define \1/p' \ 121 | config.h; echo; \ 122 | for header in $(exported_headers); do \ 123 | echo; \ 124 | sed -n -f $(srcdir)/mad.h.sed $(srcdir)/$$header; \ 125 | done; echo; \ 126 | echo "# ifdef __cplusplus"; \ 127 | echo '}'; \ 128 | echo "# endif") >$@ 129 | 130 | libtool: $(LIBTOOL_DEPS) 131 | $(SHELL) ./config.status --recheck 132 | 133 | .c.s: 134 | $(COMPILE) -S $< 135 | 136 | again: 137 | $(MAKE) clean 138 | $(MAKE) 139 | 140 | .PHONY: again 141 | -------------------------------------------------------------------------------- /3rdparty/libmad/TODO: -------------------------------------------------------------------------------- 1 | 2 | libmad - MPEG audio decoder library 3 | Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | 5 | $Id: TODO,v 1.3 2004/02/05 09:02:39 rob Exp $ 6 | 7 | =============================================================================== 8 | 9 | libmad: 10 | - more API layers (buffering, PCM samples, dithering, etc.) 11 | - x86 performance optimization compiler flags 12 | - function documentation, general docs 13 | - finish async API 14 | - parse system streams? 15 | - MPEG-2 MC, AAC? 16 | - logarithmic multiplication? 17 | - multiple frame decoding for better locality of reference? 18 | - frame serial numbers, Layer III frame continuity checks 19 | 20 | fixed.h: 21 | - experiment with FPM_INTEL: 22 | 23 | # if 1 24 | # define mad_f_scale64(hi, lo) \ 25 | ({ mad_fixed_t __result; \ 26 | asm ("shrl %3,%1\n\t" \ 27 | "shll %4,%2\n\t" \ 28 | "orl %2,%1" \ 29 | : "=rm" (__result) \ 30 | : "0" (lo), "r" (hi), \ 31 | "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ 32 | : "cc"); \ 33 | __result; \ 34 | }) 35 | # else 36 | # define mad_f_scale64(hi, lo) \ 37 | ({ mad_fixed64hi_t __hi_; \ 38 | mad_fixed64lo_t __lo_; \ 39 | mad_fixed_t __result; \ 40 | asm ("sall %2,%1" \ 41 | : "=r" (__hi_) \ 42 | : "0" (hi), "I" (32 - MAD_F_SCALEBITS) \ 43 | : "cc"); \ 44 | asm ("shrl %2,%1" \ 45 | : "=r" (__lo_) \ 46 | : "0" (lo), "I" (MAD_F_SCALEBITS) \ 47 | : "cc"); \ 48 | asm ("orl %1,%2" \ 49 | : "=rm" (__result) \ 50 | : "r" (__hi_), "0" (__lo_) \ 51 | : "cc"); \ 52 | __result; \ 53 | }) 54 | # endif 55 | 56 | libmad Layer I: 57 | - check frame length sanity 58 | 59 | libmad Layer II: 60 | - check frame length sanity 61 | 62 | libmad Layer III: 63 | - circular buffer 64 | - optimize zero_part from Huffman decoding throughout 65 | - MPEG 2.5 8000 Hz sf bands? mixed blocks? 66 | - stereo->mono conversion optimization? 67 | - enable frame-at-a-time decoding 68 | - improve portability of huffman.c 69 | 70 | -------------------------------------------------------------------------------- /3rdparty/libmad/VERSION: -------------------------------------------------------------------------------- 1 | 0.15.1b 2 | configure.ac:24 3 | version.h:25-28 4 | msvc++/config.h:99,105,120 5 | msvc++/mad.h:41-44 6 | 7 | Makefile.am:98-100 8 | -------------------------------------------------------------------------------- /3rdparty/libmad/bit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | # endif 25 | 26 | # include "global.h" 27 | 28 | # ifdef HAVE_LIMITS_H 29 | # include 30 | # else 31 | # define CHAR_BIT 8 32 | # endif 33 | 34 | # include "bit.h" 35 | 36 | /* 37 | * This is the lookup table for computing the CRC-check word. 38 | * As described in section 2.4.3.1 and depicted in Figure A.9 39 | * of ISO/IEC 11172-3, the generator polynomial is: 40 | * 41 | * G(X) = X^16 + X^15 + X^2 + 1 42 | */ 43 | static 44 | unsigned short const crc_table[256] = { 45 | 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 46 | 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 47 | 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, 48 | 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, 49 | 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, 50 | 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, 51 | 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, 52 | 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, 53 | 54 | 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, 55 | 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, 56 | 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1, 57 | 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, 58 | 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151, 59 | 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162, 60 | 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, 61 | 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, 62 | 63 | 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312, 64 | 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321, 65 | 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, 66 | 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, 67 | 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1, 68 | 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2, 69 | 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, 70 | 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381, 71 | 72 | 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291, 73 | 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, 74 | 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, 75 | 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1, 76 | 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252, 77 | 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, 78 | 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, 79 | 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 80 | }; 81 | 82 | # define CRC_POLY 0x8005 83 | 84 | /* 85 | * NAME: bit->init() 86 | * DESCRIPTION: initialize bit pointer struct 87 | */ 88 | void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) 89 | { 90 | bitptr->byte = byte; 91 | bitptr->cache = 0; 92 | bitptr->left = CHAR_BIT; 93 | } 94 | 95 | /* 96 | * NAME: bit->length() 97 | * DESCRIPTION: return number of bits between start and end points 98 | */ 99 | unsigned int mad_bit_length(struct mad_bitptr const *begin, 100 | struct mad_bitptr const *end) 101 | { 102 | return begin->left + 103 | CHAR_BIT * (end->byte - (begin->byte + 1)) + (CHAR_BIT - end->left); 104 | } 105 | 106 | /* 107 | * NAME: bit->nextbyte() 108 | * DESCRIPTION: return pointer to next unprocessed byte 109 | */ 110 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) 111 | { 112 | return bitptr->left == CHAR_BIT ? bitptr->byte : bitptr->byte + 1; 113 | } 114 | 115 | /* 116 | * NAME: bit->skip() 117 | * DESCRIPTION: advance bit pointer 118 | */ 119 | void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) 120 | { 121 | bitptr->byte += len / CHAR_BIT; 122 | bitptr->left -= len % CHAR_BIT; 123 | 124 | if (bitptr->left > CHAR_BIT) { 125 | bitptr->byte++; 126 | bitptr->left += CHAR_BIT; 127 | } 128 | 129 | if (bitptr->left < CHAR_BIT) 130 | bitptr->cache = *bitptr->byte; 131 | } 132 | 133 | /* 134 | * NAME: bit->read() 135 | * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value 136 | */ 137 | unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) 138 | { 139 | register unsigned long value; 140 | 141 | if (bitptr->left == CHAR_BIT) 142 | bitptr->cache = *bitptr->byte; 143 | 144 | if (len < bitptr->left) { 145 | value = (bitptr->cache & ((1 << bitptr->left) - 1)) >> 146 | (bitptr->left - len); 147 | bitptr->left -= len; 148 | 149 | return value; 150 | } 151 | 152 | /* remaining bits in current byte */ 153 | 154 | value = bitptr->cache & ((1 << bitptr->left) - 1); 155 | len -= bitptr->left; 156 | 157 | bitptr->byte++; 158 | bitptr->left = CHAR_BIT; 159 | 160 | /* more bytes */ 161 | 162 | while (len >= CHAR_BIT) { 163 | value = (value << CHAR_BIT) | *bitptr->byte++; 164 | len -= CHAR_BIT; 165 | } 166 | 167 | if (len > 0) { 168 | bitptr->cache = *bitptr->byte; 169 | 170 | value = (value << len) | (bitptr->cache >> (CHAR_BIT - len)); 171 | bitptr->left -= len; 172 | } 173 | 174 | return value; 175 | } 176 | 177 | # if 0 178 | /* 179 | * NAME: bit->write() 180 | * DESCRIPTION: write an arbitrary number of bits 181 | */ 182 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, 183 | unsigned long value) 184 | { 185 | unsigned char *ptr; 186 | 187 | ptr = (unsigned char *) bitptr->byte; 188 | 189 | /* ... */ 190 | } 191 | # endif 192 | 193 | /* 194 | * NAME: bit->crc() 195 | * DESCRIPTION: compute CRC-check word 196 | */ 197 | unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, 198 | unsigned short init) 199 | { 200 | register unsigned int crc; 201 | 202 | for (crc = init; len >= 32; len -= 32) { 203 | register unsigned long data; 204 | 205 | data = mad_bit_read(&bitptr, 32); 206 | 207 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff]; 208 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff]; 209 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff]; 210 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff]; 211 | } 212 | 213 | switch (len / 8) { 214 | case 3: crc = (crc << 8) ^ 215 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 216 | case 2: crc = (crc << 8) ^ 217 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 218 | case 1: crc = (crc << 8) ^ 219 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 220 | 221 | len %= 8; 222 | 223 | case 0: break; 224 | } 225 | 226 | while (len--) { 227 | register unsigned int msb; 228 | 229 | msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15); 230 | 231 | crc <<= 1; 232 | if (msb & 1) 233 | crc ^= CRC_POLY; 234 | } 235 | 236 | return crc & 0xffff; 237 | } 238 | -------------------------------------------------------------------------------- /3rdparty/libmad/bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_BIT_H 23 | # define LIBMAD_BIT_H 24 | 25 | struct mad_bitptr { 26 | unsigned char const *byte; 27 | unsigned short cache; 28 | unsigned short left; 29 | }; 30 | 31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); 32 | 33 | # define mad_bit_finish(bitptr) /* nothing */ 34 | 35 | unsigned int mad_bit_length(struct mad_bitptr const *, 36 | struct mad_bitptr const *); 37 | 38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left) 39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); 40 | 41 | void mad_bit_skip(struct mad_bitptr *, unsigned int); 42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); 43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); 44 | 45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); 46 | 47 | # endif 48 | -------------------------------------------------------------------------------- /3rdparty/libmad/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to enable diagnostic debugging support. */ 4 | #undef DEBUG 5 | 6 | /* Define to enable experimental code. */ 7 | #undef EXPERIMENTAL 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_ASSERT_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_DLFCN_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_ERRNO_H 17 | 18 | /* Define to 1 if you have the `fcntl' function. */ 19 | #undef HAVE_FCNTL 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_FCNTL_H 23 | 24 | /* Define to 1 if you have the `fork' function. */ 25 | #undef HAVE_FORK 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_INTTYPES_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_LIMITS_H 32 | 33 | /* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */ 34 | #undef HAVE_MADD16_ASM 35 | 36 | /* Define if your MIPS CPU supports a 2-operand MADD instruction. */ 37 | #undef HAVE_MADD_ASM 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_MEMORY_H 41 | 42 | /* Define to 1 if you have the `pipe' function. */ 43 | #undef HAVE_PIPE 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_STDINT_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_STDLIB_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_STRINGS_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_STRING_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_SYS_STAT_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_SYS_TYPES_H 62 | 63 | /* Define to 1 if you have that is POSIX.1 compatible. */ 64 | #undef HAVE_SYS_WAIT_H 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #undef HAVE_UNISTD_H 68 | 69 | /* Define to 1 if you have the `waitpid' function. */ 70 | #undef HAVE_WAITPID 71 | 72 | /* Define to disable debugging assertions. */ 73 | #undef NDEBUG 74 | 75 | /* Define to optimize for accuracy over speed. */ 76 | #undef OPT_ACCURACY 77 | 78 | /* Define to optimize for speed over accuracy. */ 79 | #undef OPT_SPEED 80 | 81 | /* Define to enable a fast subband synthesis approximation optimization. */ 82 | #undef OPT_SSO 83 | 84 | /* Define to influence a strict interpretation of the ISO/IEC standards, even 85 | if this is in opposition with best accepted practices. */ 86 | #undef OPT_STRICT 87 | 88 | /* Name of package */ 89 | #undef PACKAGE 90 | 91 | /* Define to the address where bug reports for this package should be sent. */ 92 | #undef PACKAGE_BUGREPORT 93 | 94 | /* Define to the full name of this package. */ 95 | #undef PACKAGE_NAME 96 | 97 | /* Define to the full name and version of this package. */ 98 | #undef PACKAGE_STRING 99 | 100 | /* Define to the one symbol short name of this package. */ 101 | #undef PACKAGE_TARNAME 102 | 103 | /* Define to the version of this package. */ 104 | #undef PACKAGE_VERSION 105 | 106 | /* The size of a `int', as computed by sizeof. */ 107 | #undef SIZEOF_INT 108 | 109 | /* The size of a `long', as computed by sizeof. */ 110 | #undef SIZEOF_LONG 111 | 112 | /* The size of a `long long', as computed by sizeof. */ 113 | #undef SIZEOF_LONG_LONG 114 | 115 | /* Define to 1 if you have the ANSI C header files. */ 116 | #undef STDC_HEADERS 117 | 118 | /* Version number of package */ 119 | #undef VERSION 120 | 121 | /* Define to 1 if your processor stores words with the most significant byte 122 | first (like Motorola and SPARC, unlike Intel and VAX). */ 123 | #undef WORDS_BIGENDIAN 124 | 125 | /* Define to empty if `const' does not conform to ANSI C. */ 126 | #undef const 127 | 128 | /* Define to `__inline__' or `__inline' if that's what the C compiler 129 | calls it, or to nothing if 'inline' is not supported under any name. */ 130 | #ifndef __cplusplus 131 | #undef inline 132 | #endif 133 | 134 | /* Define to `int' if does not define. */ 135 | #undef pid_t 136 | -------------------------------------------------------------------------------- /3rdparty/libmad/decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_DECODER_H 23 | # define LIBMAD_DECODER_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | # include "synth.h" 28 | 29 | enum mad_decoder_mode { 30 | MAD_DECODER_MODE_SYNC = 0, 31 | MAD_DECODER_MODE_ASYNC 32 | }; 33 | 34 | enum mad_flow { 35 | MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ 36 | MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ 37 | MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ 38 | MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ 39 | }; 40 | 41 | struct mad_decoder { 42 | enum mad_decoder_mode mode; 43 | 44 | int options; 45 | 46 | struct { 47 | long pid; 48 | int in; 49 | int out; 50 | } async; 51 | 52 | struct { 53 | struct mad_stream stream; 54 | struct mad_frame frame; 55 | struct mad_synth synth; 56 | } *sync; 57 | 58 | void *cb_data; 59 | 60 | enum mad_flow (*input_func)(void *, struct mad_stream *); 61 | enum mad_flow (*header_func)(void *, struct mad_header const *); 62 | enum mad_flow (*filter_func)(void *, 63 | struct mad_stream const *, struct mad_frame *); 64 | enum mad_flow (*output_func)(void *, 65 | struct mad_header const *, struct mad_pcm *); 66 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); 67 | enum mad_flow (*message_func)(void *, void *, unsigned int *); 68 | }; 69 | 70 | void mad_decoder_init(struct mad_decoder *, void *, 71 | enum mad_flow (*)(void *, struct mad_stream *), 72 | enum mad_flow (*)(void *, struct mad_header const *), 73 | enum mad_flow (*)(void *, 74 | struct mad_stream const *, 75 | struct mad_frame *), 76 | enum mad_flow (*)(void *, 77 | struct mad_header const *, 78 | struct mad_pcm *), 79 | enum mad_flow (*)(void *, 80 | struct mad_stream *, 81 | struct mad_frame *), 82 | enum mad_flow (*)(void *, void *, unsigned int *)); 83 | int mad_decoder_finish(struct mad_decoder *); 84 | 85 | # define mad_decoder_options(decoder, opts) \ 86 | ((void) ((decoder)->options = (opts))) 87 | 88 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); 89 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); 90 | 91 | # endif 92 | -------------------------------------------------------------------------------- /3rdparty/libmad/fixed.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | # endif 25 | 26 | # include "global.h" 27 | 28 | # include "fixed.h" 29 | 30 | /* 31 | * NAME: fixed->abs() 32 | * DESCRIPTION: return absolute value of a fixed-point number 33 | */ 34 | mad_fixed_t mad_f_abs(mad_fixed_t x) 35 | { 36 | return x < 0 ? -x : x; 37 | } 38 | 39 | /* 40 | * NAME: fixed->div() 41 | * DESCRIPTION: perform division using fixed-point math 42 | */ 43 | mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y) 44 | { 45 | mad_fixed_t q, r; 46 | unsigned int bits; 47 | 48 | q = mad_f_abs(x / y); 49 | 50 | if (x < 0) { 51 | x = -x; 52 | y = -y; 53 | } 54 | 55 | r = x % y; 56 | 57 | if (y < 0) { 58 | x = -x; 59 | y = -y; 60 | } 61 | 62 | if (q > mad_f_intpart(MAD_F_MAX) && 63 | !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0))) 64 | return 0; 65 | 66 | for (bits = MAD_F_FRACBITS; bits && r; --bits) { 67 | q <<= 1, r <<= 1; 68 | if (r >= y) 69 | r -= y, ++q; 70 | } 71 | 72 | /* round */ 73 | if (2 * r >= y) 74 | ++q; 75 | 76 | /* fix sign */ 77 | if ((x < 0) != (y < 0)) 78 | q = -q; 79 | 80 | return q << bits; 81 | } 82 | -------------------------------------------------------------------------------- /3rdparty/libmad/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_FRAME_H 23 | # define LIBMAD_FRAME_H 24 | 25 | # include "fixed.h" 26 | # include "timer.h" 27 | # include "stream.h" 28 | 29 | enum mad_layer { 30 | MAD_LAYER_I = 1, /* Layer I */ 31 | MAD_LAYER_II = 2, /* Layer II */ 32 | MAD_LAYER_III = 3 /* Layer III */ 33 | }; 34 | 35 | enum mad_mode { 36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ 37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ 38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ 39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ 40 | }; 41 | 42 | enum mad_emphasis { 43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ 44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ 45 | MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ 46 | MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ 47 | }; 48 | 49 | struct mad_header { 50 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ 51 | enum mad_mode mode; /* channel mode (see above) */ 52 | int mode_extension; /* additional mode info */ 53 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ 54 | 55 | unsigned long bitrate; /* stream bitrate (bps) */ 56 | unsigned int samplerate; /* sampling frequency (Hz) */ 57 | 58 | unsigned short crc_check; /* frame CRC accumulator */ 59 | unsigned short crc_target; /* final target CRC checksum */ 60 | 61 | int flags; /* flags (see below) */ 62 | int private_bits; /* private bits (see below) */ 63 | 64 | mad_timer_t duration; /* audio playing time of frame */ 65 | }; 66 | 67 | struct mad_frame { 68 | struct mad_header header; /* MPEG audio header */ 69 | 70 | int options; /* decoding options (from stream) */ 71 | 72 | mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ 73 | mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ 74 | }; 75 | 76 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) 77 | # define MAD_NSBSAMPLES(header) \ 78 | ((header)->layer == MAD_LAYER_I ? 12 : \ 79 | (((header)->layer == MAD_LAYER_III && \ 80 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 81 | 82 | enum { 83 | MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ 84 | MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ 85 | 86 | MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ 87 | MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ 88 | MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ 89 | MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ 90 | 91 | MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ 92 | MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ 93 | MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ 94 | 95 | MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ 96 | MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ 97 | MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ 98 | }; 99 | 100 | enum { 101 | MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ 102 | MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ 103 | }; 104 | 105 | void mad_header_init(struct mad_header *); 106 | 107 | # define mad_header_finish(header) /* nothing */ 108 | 109 | int mad_header_decode(struct mad_header *, struct mad_stream *); 110 | 111 | void mad_frame_init(struct mad_frame *); 112 | void mad_frame_finish(struct mad_frame *); 113 | 114 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); 115 | 116 | void mad_frame_mute(struct mad_frame *); 117 | 118 | # endif 119 | -------------------------------------------------------------------------------- /3rdparty/libmad/global.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_GLOBAL_H 23 | # define LIBMAD_GLOBAL_H 24 | 25 | /* conditional debugging */ 26 | 27 | # if defined(DEBUG) && defined(NDEBUG) 28 | # error "cannot define both DEBUG and NDEBUG" 29 | # endif 30 | 31 | # if defined(DEBUG) 32 | # include 33 | # endif 34 | 35 | /* conditional features */ 36 | 37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY) 38 | # error "cannot optimize for both speed and accuracy" 39 | # endif 40 | 41 | # if defined(OPT_SPEED) && !defined(OPT_SSO) 42 | # define OPT_SSO 43 | # endif 44 | 45 | # if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ 46 | defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) 47 | # define USE_ASYNC 48 | # endif 49 | 50 | # if !defined(HAVE_ASSERT_H) 51 | # if defined(NDEBUG) 52 | # define assert(x) /* nothing */ 53 | # else 54 | # define assert(x) do { if (!(x)) abort(); } while (0) 55 | # endif 56 | # endif 57 | 58 | # endif 59 | -------------------------------------------------------------------------------- /3rdparty/libmad/huffman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_HUFFMAN_H 23 | # define LIBMAD_HUFFMAN_H 24 | 25 | union huffquad { 26 | struct { 27 | unsigned short final : 1; 28 | unsigned short bits : 3; 29 | unsigned short offset : 12; 30 | } ptr; 31 | struct { 32 | unsigned short final : 1; 33 | unsigned short hlen : 3; 34 | unsigned short v : 1; 35 | unsigned short w : 1; 36 | unsigned short x : 1; 37 | unsigned short y : 1; 38 | } value; 39 | unsigned short final : 1; 40 | }; 41 | 42 | union huffpair { 43 | struct { 44 | unsigned short final : 1; 45 | unsigned short bits : 3; 46 | unsigned short offset : 12; 47 | } ptr; 48 | struct { 49 | unsigned short final : 1; 50 | unsigned short hlen : 3; 51 | unsigned short x : 4; 52 | unsigned short y : 4; 53 | } value; 54 | unsigned short final : 1; 55 | }; 56 | 57 | struct hufftable { 58 | union huffpair const *table; 59 | unsigned short linbits; 60 | unsigned short startbits; 61 | }; 62 | 63 | extern union huffquad const *const mad_huff_quad_table[2]; 64 | extern struct hufftable const mad_huff_pair_table[32]; 65 | 66 | # endif 67 | -------------------------------------------------------------------------------- /3rdparty/libmad/imdct_s.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, 23 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 24 | -MAD_F(0x0216a2a2) /* -0.130526192 */, 25 | MAD_F(0x0fdcf549) /* 0.991444861 */, 26 | -MAD_F(0x061f78aa) /* -0.382683432 */, 27 | -MAD_F(0x0cb19346) /* -0.793353340 */ }, 28 | 29 | /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, 30 | MAD_F(0x061f78aa) /* 0.382683432 */, 31 | MAD_F(0x0fdcf549) /* 0.991444861 */, 32 | MAD_F(0x0216a2a2) /* 0.130526192 */, 33 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 34 | -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, 35 | 36 | /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, 37 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 38 | MAD_F(0x0ec835e8) /* 0.923879533 */, 39 | -MAD_F(0x061f78aa) /* -0.382683432 */, 40 | -MAD_F(0x061f78aa) /* -0.382683432 */, 41 | MAD_F(0x0ec835e8) /* 0.923879533 */ }, 42 | 43 | /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, 44 | -MAD_F(0x061f78aa) /* -0.382683432 */, 45 | MAD_F(0x061f78aa) /* 0.382683432 */, 46 | MAD_F(0x0ec835e8) /* 0.923879533 */, 47 | MAD_F(0x0ec835e8) /* 0.923879533 */, 48 | MAD_F(0x061f78aa) /* 0.382683432 */ }, 49 | 50 | /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, 51 | -MAD_F(0x061f78aa) /* -0.382683432 */, 52 | MAD_F(0x09bd7ca0) /* 0.608761429 */, 53 | -MAD_F(0x0cb19346) /* -0.793353340 */, 54 | MAD_F(0x0ec835e8) /* 0.923879533 */, 55 | -MAD_F(0x0fdcf549) /* -0.991444861 */ }, 56 | 57 | /* 8 */ { -MAD_F(0x0fdcf549) /* -0.991444861 */, 58 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 59 | -MAD_F(0x0cb19346) /* -0.793353340 */, 60 | -MAD_F(0x09bd7ca0) /* -0.608761429 */, 61 | -MAD_F(0x061f78aa) /* -0.382683432 */, 62 | -MAD_F(0x0216a2a2) /* -0.130526192 */ } 63 | -------------------------------------------------------------------------------- /3rdparty/libmad/install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd=$cpprog 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd=$stripprog 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "$0: no input file specified" >&2 110 | exit 1 111 | else 112 | : 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d "$dst" ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=$mkdirprog 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f "$src" ] || [ -d "$src" ] 132 | then 133 | : 134 | else 135 | echo "$0: $src does not exist" >&2 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "$0: no destination specified" >&2 142 | exit 1 143 | else 144 | : 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d "$dst" ] 151 | then 152 | dst=$dst/`basename "$src"` 153 | else 154 | : 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-$defaultIFS}" 169 | 170 | oIFS=$IFS 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS=$oIFS 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp=$pathcomp$1 180 | shift 181 | 182 | if [ ! -d "$pathcomp" ] ; 183 | then 184 | $mkdirprog "$pathcomp" 185 | else 186 | : 187 | fi 188 | 189 | pathcomp=$pathcomp/ 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd "$dst" && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename "$dst"` 208 | else 209 | dstfile=`basename "$dst" $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename "$dst"` 218 | else 219 | : 220 | fi 221 | 222 | # Make a couple of temp file names in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | rmtmp=$dstdir/#rm.$$# 226 | 227 | # Trap to clean up temp files at exit. 228 | 229 | trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 230 | trap '(exit $?); exit' 1 2 13 15 231 | 232 | # Move or copy the file name to the temp name 233 | 234 | $doit $instcmd "$src" "$dsttmp" && 235 | 236 | # and set any options; do chmod last to preserve setuid bits 237 | 238 | # If any of these fail, we abort the whole thing. If we want to 239 | # ignore errors from any of these, just make sure not to ignore 240 | # errors from the above "$doit $instcmd $src $dsttmp" command. 241 | 242 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && 243 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && 244 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && 245 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && 246 | 247 | # Now remove or move aside any old file at destination location. We try this 248 | # two ways since rm can't unlink itself on some systems and the destination 249 | # file might be busy for other reasons. In this case, the final cleanup 250 | # might fail but the new file should still install successfully. 251 | 252 | { 253 | if [ -f "$dstdir/$dstfile" ] 254 | then 255 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || 256 | $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || 257 | { 258 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 259 | (exit 1); exit 260 | } 261 | else 262 | : 263 | fi 264 | } && 265 | 266 | # Now rename the file to the real destination. 267 | 268 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 269 | 270 | fi && 271 | 272 | # The final little trick to "correctly" pass the exit status to the exit trap. 273 | 274 | { 275 | (exit 0); exit 276 | } 277 | -------------------------------------------------------------------------------- /3rdparty/libmad/layer12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_LAYER12_H 23 | # define LIBMAD_LAYER12_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | 28 | int mad_layer_I(struct mad_stream *, struct mad_frame *); 29 | int mad_layer_II(struct mad_stream *, struct mad_frame *); 30 | 31 | # endif 32 | -------------------------------------------------------------------------------- /3rdparty/libmad/layer3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_LAYER3_H 23 | # define LIBMAD_LAYER3_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | 28 | int mad_layer_III(struct mad_stream *, struct mad_frame *); 29 | 30 | # endif 31 | -------------------------------------------------------------------------------- /3rdparty/libmad/libmad.list.in: -------------------------------------------------------------------------------- 1 | # @configure_input@ 2 | 3 | # Directories... 4 | $prefix=@prefix@ 5 | $exec_prefix=@exec_prefix@ 6 | $srcdir=@srcdir@ 7 | 8 | # Product information 9 | %product @PACKAGE@ 10 | %copyright GPL 11 | %vendor Underbit Technologies, Inc. 12 | %license @srcdir@/COPYING 13 | %readme @srcdir@/README 14 | %description libmad is an MPEG audio decoder library. 15 | %version @VERSION@ 16 | %packager Giuseppe "Cowo" Corbelli 17 | 18 | %system all 19 | f 0755 root root @libdir@/libmad.la .libs/libmad.lai 20 | f 0644 root root @libdir@/libmad.a .libs/libmad.a 21 | f 0644 root root @includedir@/mad.h mad.h 22 | -------------------------------------------------------------------------------- /3rdparty/libmad/mad.h.sed: -------------------------------------------------------------------------------- 1 | # 2 | # libmad - MPEG audio decoder library 3 | # Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | # 19 | # $Id: mad.h.sed,v 1.9 2004/01/23 09:41:32 rob Exp $ 20 | # 21 | 22 | /^\/\*$/{ 23 | N 24 | s/ \* libmad - /&/ 25 | t copy 26 | b next 27 | : copy 28 | g 29 | n 30 | s|^ \* \$\(Id: .*\) \$$|/* \1 */|p 31 | /^ \*\/$/d 32 | b copy 33 | } 34 | /^# *include "/d 35 | : next 36 | p 37 | -------------------------------------------------------------------------------- /3rdparty/libmad/minimad.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: minimad.c,v 1.4 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # include 23 | # include 24 | # include 25 | # include 26 | 27 | # include "mad.h" 28 | 29 | /* 30 | * This is perhaps the simplest example use of the MAD high-level API. 31 | * Standard input is mapped into memory via mmap(), then the high-level API 32 | * is invoked with three callbacks: input, output, and error. The output 33 | * callback converts MAD's high-resolution PCM samples to 16 bits, then 34 | * writes them to standard output in little-endian, stereo-interleaved 35 | * format. 36 | */ 37 | 38 | static int decode(unsigned char const *, unsigned long); 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | struct stat stat; 43 | void *fdm; 44 | 45 | if (argc != 1) 46 | return 1; 47 | 48 | if (fstat(STDIN_FILENO, &stat) == -1 || 49 | stat.st_size == 0) 50 | return 2; 51 | 52 | fdm = mmap(0, stat.st_size, PROT_READ, MAP_SHARED, STDIN_FILENO, 0); 53 | if (fdm == MAP_FAILED) 54 | return 3; 55 | 56 | decode(fdm, stat.st_size); 57 | 58 | if (munmap(fdm, stat.st_size) == -1) 59 | return 4; 60 | 61 | return 0; 62 | } 63 | 64 | /* 65 | * This is a private message structure. A generic pointer to this structure 66 | * is passed to each of the callback functions. Put here any data you need 67 | * to access from within the callbacks. 68 | */ 69 | 70 | struct buffer { 71 | unsigned char const *start; 72 | unsigned long length; 73 | }; 74 | 75 | /* 76 | * This is the input callback. The purpose of this callback is to (re)fill 77 | * the stream buffer which is to be decoded. In this example, an entire file 78 | * has been mapped into memory, so we just call mad_stream_buffer() with the 79 | * address and length of the mapping. When this callback is called a second 80 | * time, we are finished decoding. 81 | */ 82 | 83 | static 84 | enum mad_flow input(void *data, 85 | struct mad_stream *stream) 86 | { 87 | struct buffer *buffer = data; 88 | 89 | if (!buffer->length) 90 | return MAD_FLOW_STOP; 91 | 92 | mad_stream_buffer(stream, buffer->start, buffer->length); 93 | 94 | buffer->length = 0; 95 | 96 | return MAD_FLOW_CONTINUE; 97 | } 98 | 99 | /* 100 | * The following utility routine performs simple rounding, clipping, and 101 | * scaling of MAD's high-resolution samples down to 16 bits. It does not 102 | * perform any dithering or noise shaping, which would be recommended to 103 | * obtain any exceptional audio quality. It is therefore not recommended to 104 | * use this routine if high-quality output is desired. 105 | */ 106 | 107 | static inline 108 | signed int scale(mad_fixed_t sample) 109 | { 110 | /* round */ 111 | sample += (1L << (MAD_F_FRACBITS - 16)); 112 | 113 | /* clip */ 114 | if (sample >= MAD_F_ONE) 115 | sample = MAD_F_ONE - 1; 116 | else if (sample < -MAD_F_ONE) 117 | sample = -MAD_F_ONE; 118 | 119 | /* quantize */ 120 | return sample >> (MAD_F_FRACBITS + 1 - 16); 121 | } 122 | 123 | /* 124 | * This is the output callback function. It is called after each frame of 125 | * MPEG audio data has been completely decoded. The purpose of this callback 126 | * is to output (or play) the decoded PCM audio. 127 | */ 128 | 129 | static 130 | enum mad_flow output(void *data, 131 | struct mad_header const *header, 132 | struct mad_pcm *pcm) 133 | { 134 | unsigned int nchannels, nsamples; 135 | mad_fixed_t const *left_ch, *right_ch; 136 | 137 | /* pcm->samplerate contains the sampling frequency */ 138 | 139 | nchannels = pcm->channels; 140 | nsamples = pcm->length; 141 | left_ch = pcm->samples[0]; 142 | right_ch = pcm->samples[1]; 143 | 144 | while (nsamples--) { 145 | signed int sample; 146 | 147 | /* output sample(s) in 16-bit signed little-endian PCM */ 148 | 149 | sample = scale(*left_ch++); 150 | putchar((sample >> 0) & 0xff); 151 | putchar((sample >> 8) & 0xff); 152 | 153 | if (nchannels == 2) { 154 | sample = scale(*right_ch++); 155 | putchar((sample >> 0) & 0xff); 156 | putchar((sample >> 8) & 0xff); 157 | } 158 | } 159 | 160 | return MAD_FLOW_CONTINUE; 161 | } 162 | 163 | /* 164 | * This is the error callback function. It is called whenever a decoding 165 | * error occurs. The error is indicated by stream->error; the list of 166 | * possible MAD_ERROR_* errors can be found in the mad.h (or stream.h) 167 | * header file. 168 | */ 169 | 170 | static 171 | enum mad_flow error(void *data, 172 | struct mad_stream *stream, 173 | struct mad_frame *frame) 174 | { 175 | struct buffer *buffer = data; 176 | 177 | fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %u\n", 178 | stream->error, mad_stream_errorstr(stream), 179 | stream->this_frame - buffer->start); 180 | 181 | /* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */ 182 | 183 | return MAD_FLOW_CONTINUE; 184 | } 185 | 186 | /* 187 | * This is the function called by main() above to perform all the decoding. 188 | * It instantiates a decoder object and configures it with the input, 189 | * output, and error callback functions above. A single call to 190 | * mad_decoder_run() continues until a callback function returns 191 | * MAD_FLOW_STOP (to stop decoding) or MAD_FLOW_BREAK (to stop decoding and 192 | * signal an error). 193 | */ 194 | 195 | static 196 | int decode(unsigned char const *start, unsigned long length) 197 | { 198 | struct buffer buffer; 199 | struct mad_decoder decoder; 200 | int result; 201 | 202 | /* initialize our private message structure */ 203 | 204 | buffer.start = start; 205 | buffer.length = length; 206 | 207 | /* configure input, output, and error functions */ 208 | 209 | mad_decoder_init(&decoder, &buffer, 210 | input, 0 /* header */, 0 /* filter */, output, 211 | error, 0 /* message */); 212 | 213 | /* start decoding */ 214 | 215 | result = mad_decoder_run(&decoder, MAD_DECODER_MODE_SYNC); 216 | 217 | /* release the decoder */ 218 | 219 | mad_decoder_finish(&decoder); 220 | 221 | return result; 222 | } 223 | -------------------------------------------------------------------------------- /3rdparty/libmad/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case $1 in 16 | -h | --help | --h*) # -h for help 17 | echo "$usage" 1>&2 18 | exit 0 19 | ;; 20 | -m) # -m PERM arg 21 | shift 22 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 23 | dirmode=$1 24 | shift 25 | ;; 26 | --) # stop option processing 27 | shift 28 | break 29 | ;; 30 | -*) # unknown option 31 | echo "$usage" 1>&2 32 | exit 1 33 | ;; 34 | *) # first non-opt arg 35 | break 36 | ;; 37 | esac 38 | done 39 | 40 | for file 41 | do 42 | if test -d "$file"; then 43 | shift 44 | else 45 | break 46 | fi 47 | done 48 | 49 | case $# in 50 | 0) exit 0 ;; 51 | esac 52 | 53 | case $dirmode in 54 | '') 55 | if mkdir -p -- . 2>/dev/null; then 56 | echo "mkdir -p -- $*" 57 | exec mkdir -p -- "$@" 58 | fi 59 | ;; 60 | *) 61 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 62 | echo "mkdir -m $dirmode -p -- $*" 63 | exec mkdir -m "$dirmode" -p -- "$@" 64 | fi 65 | ;; 66 | esac 67 | 68 | for file 69 | do 70 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 71 | shift 72 | 73 | pathcomp= 74 | for d 75 | do 76 | pathcomp="$pathcomp$d" 77 | case $pathcomp in 78 | -*) pathcomp=./$pathcomp ;; 79 | esac 80 | 81 | if test ! -d "$pathcomp"; then 82 | echo "mkdir $pathcomp" 83 | 84 | mkdir "$pathcomp" || lasterr=$? 85 | 86 | if test ! -d "$pathcomp"; then 87 | errstatus=$lasterr 88 | else 89 | if test ! -z "$dirmode"; then 90 | echo "chmod $dirmode $pathcomp" 91 | lasterr="" 92 | chmod "$dirmode" "$pathcomp" || lasterr=$? 93 | 94 | if test ! -z "$lasterr"; then 95 | errstatus=$lasterr 96 | fi 97 | fi 98 | fi 99 | fi 100 | 101 | pathcomp="$pathcomp/" 102 | done 103 | done 104 | 105 | exit $errstatus 106 | 107 | # Local Variables: 108 | # mode: shell-script 109 | # sh-indentation: 2 110 | # End: 111 | # mkinstalldirs ends here 112 | -------------------------------------------------------------------------------- /3rdparty/libmad/msvc++/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## libmad - MPEG audio decoder library 3 | ## Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | ## 5 | ## This program is free software; you can redistribute it and/or modify 6 | ## it under the terms of the GNU General Public License as published by 7 | ## the Free Software Foundation; either version 2 of the License, or 8 | ## (at your option) any later version. 9 | ## 10 | ## This program is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ## GNU General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU General Public License 16 | ## along with this program; if not, write to the Free Software 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | ## 19 | ## $Id: Makefile.am,v 1.3 2004/01/23 09:41:33 rob Exp $ 20 | ## 21 | 22 | ## Process this file with automake to produce Makefile.in 23 | 24 | EXTRA_DIST = mad.h config.h libmad.dsp 25 | -------------------------------------------------------------------------------- /3rdparty/libmad/msvc++/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to enable diagnostic debugging support. */ 5 | /* #undef DEBUG */ 6 | 7 | /* Define to enable experimental code. */ 8 | /* #undef EXPERIMENTAL */ 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_ASSERT_H 1 12 | 13 | /* Define to 1 if you have the header file. */ 14 | /* #undef HAVE_DLFCN_H */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_ERRNO_H 1 18 | 19 | /* Define to 1 if you have the `fcntl' function. */ 20 | /* #undef HAVE_FCNTL */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_FCNTL_H 1 24 | 25 | /* Define to 1 if you have the `fork' function. */ 26 | /* #undef HAVE_FORK */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_INTTYPES_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_LIMITS_H 1 33 | 34 | /* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */ 35 | /* #undef HAVE_MADD16_ASM */ 36 | 37 | /* Define if your MIPS CPU supports a 2-operand MADD instruction. */ 38 | /* #undef HAVE_MADD_ASM */ 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_MEMORY_H 1 42 | 43 | /* Define to 1 if you have the `pipe' function. */ 44 | /* #undef HAVE_PIPE */ 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_STDINT_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_STDLIB_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_STRINGS_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_STRING_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_SYS_STAT_H 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_SYS_TYPES_H 1 63 | 64 | /* Define to 1 if you have that is POSIX.1 compatible. */ 65 | /* #undef HAVE_SYS_WAIT_H */ 66 | 67 | /* Define to 1 if you have the header file. */ 68 | /* #undef HAVE_UNISTD_H */ 69 | 70 | /* Define to 1 if you have the `waitpid' function. */ 71 | /* #undef HAVE_WAITPID */ 72 | 73 | /* Define to disable debugging assertions. */ 74 | /* #undef NDEBUG */ 75 | 76 | /* Define to optimize for accuracy over speed. */ 77 | /* #undef OPT_ACCURACY */ 78 | 79 | /* Define to optimize for speed over accuracy. */ 80 | /* #undef OPT_SPEED */ 81 | 82 | /* Define to enable a fast subband synthesis approximation optimization. */ 83 | /* #undef OPT_SSO */ 84 | 85 | /* Define to influence a strict interpretation of the ISO/IEC standards, even 86 | if this is in opposition with best accepted practices. */ 87 | /* #undef OPT_STRICT */ 88 | 89 | /* Name of package */ 90 | #define PACKAGE "libmad" 91 | 92 | /* Define to the address where bug reports for this package should be sent. */ 93 | #define PACKAGE_BUGREPORT "support@underbit.com" 94 | 95 | /* Define to the full name of this package. */ 96 | #define PACKAGE_NAME "MPEG Audio Decoder" 97 | 98 | /* Define to the full name and version of this package. */ 99 | #define PACKAGE_STRING "MPEG Audio Decoder 0.15.1b" 100 | 101 | /* Define to the one symbol short name of this package. */ 102 | #define PACKAGE_TARNAME "libmad" 103 | 104 | /* Define to the version of this package. */ 105 | #define PACKAGE_VERSION "0.15.1b" 106 | 107 | /* The size of a `int', as computed by sizeof. */ 108 | #define SIZEOF_INT 4 109 | 110 | /* The size of a `long', as computed by sizeof. */ 111 | #define SIZEOF_LONG 4 112 | 113 | /* The size of a `long long', as computed by sizeof. */ 114 | #define SIZEOF_LONG_LONG 8 115 | 116 | /* Define to 1 if you have the ANSI C header files. */ 117 | #define STDC_HEADERS 1 118 | 119 | /* Version number of package */ 120 | #define VERSION "0.15.1b" 121 | 122 | /* Define to empty if `const' does not conform to ANSI C. */ 123 | /* #undef const */ 124 | 125 | /* Define as `__inline' if that's what the C compiler calls it, or to nothing 126 | if it is not supported. */ 127 | #define inline __inline 128 | 129 | /* Define to `int' if does not define. */ 130 | /* #undef pid_t */ 131 | -------------------------------------------------------------------------------- /3rdparty/libmad/msvc++/libmad.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libmad" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libmad - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libmad.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libmad.mak" CFG="libmad - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libmad - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libmad - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libmad - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /GX /O2 /I "." /D "NDEBUG" /D "FPM_INTEL" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /D "ASO_ZEROCHECK" /FD /c 45 | # SUBTRACT CPP /YX 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LIB32=link.exe -lib 52 | # ADD BASE LIB32 /nologo 53 | # ADD LIB32 /nologo 54 | 55 | !ELSEIF "$(CFG)" == "libmad - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "Debug" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Target_Dir "" 67 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD CPP /nologo /Gm /GX /ZI /Od /I "." /D "FPM_DEFAULT" /D "_LIB" /D "HAVE_CONFIG_H" /D "ASO_ZEROCHECK" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "DEBUG" /FD /GZ /c 69 | # SUBTRACT CPP /YX 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LIB32=link.exe -lib 76 | # ADD BASE LIB32 /nologo 77 | # ADD LIB32 /nologo 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "libmad - Win32 Release" 84 | # Name "libmad - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "c" 88 | # Begin Source File 89 | 90 | SOURCE=..\bit.c 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=..\decoder.c 95 | # End Source File 96 | # Begin Source File 97 | 98 | SOURCE=..\fixed.c 99 | # End Source File 100 | # Begin Source File 101 | 102 | SOURCE=..\frame.c 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\huffman.c 107 | # End Source File 108 | # Begin Source File 109 | 110 | SOURCE=..\layer12.c 111 | # End Source File 112 | # Begin Source File 113 | 114 | SOURCE=..\layer3.c 115 | # End Source File 116 | # Begin Source File 117 | 118 | SOURCE=..\stream.c 119 | # End Source File 120 | # Begin Source File 121 | 122 | SOURCE=..\synth.c 123 | # End Source File 124 | # Begin Source File 125 | 126 | SOURCE=..\timer.c 127 | # End Source File 128 | # Begin Source File 129 | 130 | SOURCE=..\version.c 131 | # End Source File 132 | # End Group 133 | # Begin Group "Header Files" 134 | 135 | # PROP Default_Filter "h" 136 | # Begin Source File 137 | 138 | SOURCE=..\bit.h 139 | # End Source File 140 | # Begin Source File 141 | 142 | SOURCE=.\config.h 143 | # End Source File 144 | # Begin Source File 145 | 146 | SOURCE=..\decoder.h 147 | # End Source File 148 | # Begin Source File 149 | 150 | SOURCE=..\fixed.h 151 | # End Source File 152 | # Begin Source File 153 | 154 | SOURCE=..\frame.h 155 | # End Source File 156 | # Begin Source File 157 | 158 | SOURCE=..\global.h 159 | # End Source File 160 | # Begin Source File 161 | 162 | SOURCE=..\huffman.h 163 | # End Source File 164 | # Begin Source File 165 | 166 | SOURCE=..\layer12.h 167 | # End Source File 168 | # Begin Source File 169 | 170 | SOURCE=..\layer3.h 171 | # End Source File 172 | # Begin Source File 173 | 174 | SOURCE=..\stream.h 175 | # End Source File 176 | # Begin Source File 177 | 178 | SOURCE=..\synth.h 179 | # End Source File 180 | # Begin Source File 181 | 182 | SOURCE=..\timer.h 183 | # End Source File 184 | # Begin Source File 185 | 186 | SOURCE=..\version.h 187 | # End Source File 188 | # End Group 189 | # Begin Group "Data Files" 190 | 191 | # PROP Default_Filter "dat" 192 | # Begin Source File 193 | 194 | SOURCE=..\D.dat 195 | # End Source File 196 | # Begin Source File 197 | 198 | SOURCE=..\imdct_s.dat 199 | # End Source File 200 | # Begin Source File 201 | 202 | SOURCE=..\qc_table.dat 203 | # End Source File 204 | # Begin Source File 205 | 206 | SOURCE=..\rq_table.dat 207 | # End Source File 208 | # Begin Source File 209 | 210 | SOURCE=..\sf_table.dat 211 | # End Source File 212 | # End Group 213 | # End Target 214 | # End Project 215 | -------------------------------------------------------------------------------- /3rdparty/libmad/qc_table.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: qc_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | /* 23 | * These are the Layer II classes of quantization. 24 | * The table is derived from Table B.4 of ISO/IEC 11172-3. 25 | */ 26 | 27 | { 3, 2, 5, 28 | MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, 29 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 30 | { 5, 3, 7, 31 | MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, 32 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 33 | { 7, 0, 3, 34 | MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, 35 | MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, 36 | { 9, 4, 10, 37 | MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, 38 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 39 | { 15, 0, 4, 40 | MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, 41 | MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, 42 | { 31, 0, 5, 43 | MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, 44 | MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, 45 | { 63, 0, 6, 46 | MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, 47 | MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, 48 | { 127, 0, 7, 49 | MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, 50 | MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, 51 | { 255, 0, 8, 52 | MAD_F(0x10101010) /* 1.00392156863 => 1.00392156839, e 0.00000000024 */, 53 | MAD_F(0x00200000) /* 0.00781250000 => 0.00781250000, e 0.00000000000 */ }, 54 | { 511, 0, 9, 55 | MAD_F(0x10080402) /* 1.00195694716 => 1.00195694715, e 0.00000000001 */, 56 | MAD_F(0x00100000) /* 0.00390625000 => 0.00390625000, e 0.00000000000 */ }, 57 | { 1023, 0, 10, 58 | MAD_F(0x10040100) /* 1.00097751711 => 1.00097751617, e 0.00000000094 */, 59 | MAD_F(0x00080000) /* 0.00195312500 => 0.00195312500, e 0.00000000000 */ }, 60 | { 2047, 0, 11, 61 | MAD_F(0x10020040) /* 1.00048851979 => 1.00048851967, e 0.00000000012 */, 62 | MAD_F(0x00040000) /* 0.00097656250 => 0.00097656250, e 0.00000000000 */ }, 63 | { 4095, 0, 12, 64 | MAD_F(0x10010010) /* 1.00024420024 => 1.00024420023, e 0.00000000001 */, 65 | MAD_F(0x00020000) /* 0.00048828125 => 0.00048828125, e 0.00000000000 */ }, 66 | { 8191, 0, 13, 67 | MAD_F(0x10008004) /* 1.00012208522 => 1.00012208521, e 0.00000000001 */, 68 | MAD_F(0x00010000) /* 0.00024414063 => 0.00024414062, e 0.00000000000 */ }, 69 | { 16383, 0, 14, 70 | MAD_F(0x10004001) /* 1.00006103888 => 1.00006103888, e -0.00000000000 */, 71 | MAD_F(0x00008000) /* 0.00012207031 => 0.00012207031, e -0.00000000000 */ }, 72 | { 32767, 0, 15, 73 | MAD_F(0x10002000) /* 1.00003051851 => 1.00003051758, e 0.00000000093 */, 74 | MAD_F(0x00004000) /* 0.00006103516 => 0.00006103516, e 0.00000000000 */ }, 75 | { 65535, 0, 16, 76 | MAD_F(0x10001000) /* 1.00001525902 => 1.00001525879, e 0.00000000023 */, 77 | MAD_F(0x00002000) /* 0.00003051758 => 0.00003051758, e 0.00000000000 */ } 78 | -------------------------------------------------------------------------------- /3rdparty/libmad/sf_table.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: sf_table.dat,v 1.7 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | /* 23 | * These are the scalefactor values for Layer I and Layer II. 24 | * The values are from Table B.1 of ISO/IEC 11172-3. 25 | * 26 | * There is some error introduced by the 32-bit fixed-point representation; 27 | * the amount of error is shown. For 16-bit PCM output, this shouldn't be 28 | * too much of a problem. 29 | * 30 | * Strictly speaking, Table B.1 has only 63 entries (0-62), thus a strict 31 | * interpretation of ISO/IEC 11172-3 would suggest that a scalefactor index of 32 | * 63 is invalid. However, for better compatibility with current practices, we 33 | * add a 64th entry. 34 | */ 35 | 36 | MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */ 37 | MAD_F(0x1965fea5), /* 1.587401051968 => 1.587401051074, e 0.000000000894 */ 38 | MAD_F(0x1428a2fa), /* 1.259921049895 => 1.259921051562, e -0.000000001667 */ 39 | MAD_F(0x10000000), /* 1.000000000000 => 1.000000000000, e 0.000000000000 */ 40 | MAD_F(0x0cb2ff53), /* 0.793700525984 => 0.793700527400, e -0.000000001416 */ 41 | MAD_F(0x0a14517d), /* 0.629960524947 => 0.629960525781, e -0.000000000833 */ 42 | MAD_F(0x08000000), /* 0.500000000000 => 0.500000000000, e 0.000000000000 */ 43 | MAD_F(0x06597fa9), /* 0.396850262992 => 0.396850261837, e 0.000000001155 */ 44 | 45 | MAD_F(0x050a28be), /* 0.314980262474 => 0.314980261028, e 0.000000001446 */ 46 | MAD_F(0x04000000), /* 0.250000000000 => 0.250000000000, e 0.000000000000 */ 47 | MAD_F(0x032cbfd5), /* 0.198425131496 => 0.198425132781, e -0.000000001285 */ 48 | MAD_F(0x0285145f), /* 0.157490131237 => 0.157490130514, e 0.000000000723 */ 49 | MAD_F(0x02000000), /* 0.125000000000 => 0.125000000000, e 0.000000000000 */ 50 | MAD_F(0x01965fea), /* 0.099212565748 => 0.099212564528, e 0.000000001220 */ 51 | MAD_F(0x01428a30), /* 0.078745065618 => 0.078745067120, e -0.000000001501 */ 52 | MAD_F(0x01000000), /* 0.062500000000 => 0.062500000000, e 0.000000000000 */ 53 | 54 | MAD_F(0x00cb2ff5), /* 0.049606282874 => 0.049606282264, e 0.000000000610 */ 55 | MAD_F(0x00a14518), /* 0.039372532809 => 0.039372533560, e -0.000000000751 */ 56 | MAD_F(0x00800000), /* 0.031250000000 => 0.031250000000, e 0.000000000000 */ 57 | MAD_F(0x006597fb), /* 0.024803141437 => 0.024803142995, e -0.000000001558 */ 58 | MAD_F(0x0050a28c), /* 0.019686266405 => 0.019686266780, e -0.000000000375 */ 59 | MAD_F(0x00400000), /* 0.015625000000 => 0.015625000000, e 0.000000000000 */ 60 | MAD_F(0x0032cbfd), /* 0.012401570719 => 0.012401569635, e 0.000000001084 */ 61 | MAD_F(0x00285146), /* 0.009843133202 => 0.009843133390, e -0.000000000188 */ 62 | 63 | MAD_F(0x00200000), /* 0.007812500000 => 0.007812500000, e 0.000000000000 */ 64 | MAD_F(0x001965ff), /* 0.006200785359 => 0.006200786680, e -0.000000001321 */ 65 | MAD_F(0x001428a3), /* 0.004921566601 => 0.004921566695, e -0.000000000094 */ 66 | MAD_F(0x00100000), /* 0.003906250000 => 0.003906250000, e 0.000000000000 */ 67 | MAD_F(0x000cb2ff), /* 0.003100392680 => 0.003100391477, e 0.000000001202 */ 68 | MAD_F(0x000a1451), /* 0.002460783301 => 0.002460781485, e 0.000000001816 */ 69 | MAD_F(0x00080000), /* 0.001953125000 => 0.001953125000, e 0.000000000000 */ 70 | MAD_F(0x00065980), /* 0.001550196340 => 0.001550197601, e -0.000000001262 */ 71 | 72 | MAD_F(0x00050a29), /* 0.001230391650 => 0.001230392605, e -0.000000000955 */ 73 | MAD_F(0x00040000), /* 0.000976562500 => 0.000976562500, e 0.000000000000 */ 74 | MAD_F(0x00032cc0), /* 0.000775098170 => 0.000775098801, e -0.000000000631 */ 75 | MAD_F(0x00028514), /* 0.000615195825 => 0.000615194440, e 0.000000001385 */ 76 | MAD_F(0x00020000), /* 0.000488281250 => 0.000488281250, e 0.000000000000 */ 77 | MAD_F(0x00019660), /* 0.000387549085 => 0.000387549400, e -0.000000000315 */ 78 | MAD_F(0x0001428a), /* 0.000307597913 => 0.000307597220, e 0.000000000693 */ 79 | MAD_F(0x00010000), /* 0.000244140625 => 0.000244140625, e 0.000000000000 */ 80 | 81 | MAD_F(0x0000cb30), /* 0.000193774542 => 0.000193774700, e -0.000000000158 */ 82 | MAD_F(0x0000a145), /* 0.000153798956 => 0.000153798610, e 0.000000000346 */ 83 | MAD_F(0x00008000), /* 0.000122070313 => 0.000122070313, e 0.000000000000 */ 84 | MAD_F(0x00006598), /* 0.000096887271 => 0.000096887350, e -0.000000000079 */ 85 | MAD_F(0x000050a3), /* 0.000076899478 => 0.000076901168, e -0.000000001689 */ 86 | MAD_F(0x00004000), /* 0.000061035156 => 0.000061035156, e 0.000000000000 */ 87 | MAD_F(0x000032cc), /* 0.000048443636 => 0.000048443675, e -0.000000000039 */ 88 | MAD_F(0x00002851), /* 0.000038449739 => 0.000038448721, e 0.000000001018 */ 89 | 90 | MAD_F(0x00002000), /* 0.000030517578 => 0.000030517578, e 0.000000000000 */ 91 | MAD_F(0x00001966), /* 0.000024221818 => 0.000024221838, e -0.000000000020 */ 92 | MAD_F(0x00001429), /* 0.000019224870 => 0.000019226223, e -0.000000001354 */ 93 | MAD_F(0x00001000), /* 0.000015258789 => 0.000015258789, e -0.000000000000 */ 94 | MAD_F(0x00000cb3), /* 0.000012110909 => 0.000012110919, e -0.000000000010 */ 95 | MAD_F(0x00000a14), /* 0.000009612435 => 0.000009611249, e 0.000000001186 */ 96 | MAD_F(0x00000800), /* 0.000007629395 => 0.000007629395, e -0.000000000000 */ 97 | MAD_F(0x00000659), /* 0.000006055454 => 0.000006053597, e 0.000000001858 */ 98 | 99 | MAD_F(0x0000050a), /* 0.000004806217 => 0.000004805624, e 0.000000000593 */ 100 | MAD_F(0x00000400), /* 0.000003814697 => 0.000003814697, e 0.000000000000 */ 101 | MAD_F(0x0000032d), /* 0.000003027727 => 0.000003028661, e -0.000000000934 */ 102 | MAD_F(0x00000285), /* 0.000002403109 => 0.000002402812, e 0.000000000296 */ 103 | MAD_F(0x00000200), /* 0.000001907349 => 0.000001907349, e -0.000000000000 */ 104 | MAD_F(0x00000196), /* 0.000001513864 => 0.000001512468, e 0.000000001396 */ 105 | MAD_F(0x00000143), /* 0.000001201554 => 0.000001203269, e -0.000000001714 */ 106 | MAD_F(0x00000000) /* this compatibility entry is not part of Table B.1 */ 107 | -------------------------------------------------------------------------------- /3rdparty/libmad/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $ 20 | */ 21 | 22 | # ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | # endif 25 | 26 | # include "global.h" 27 | 28 | # include 29 | 30 | # include "bit.h" 31 | # include "stream.h" 32 | 33 | /* 34 | * NAME: stream->init() 35 | * DESCRIPTION: initialize stream struct 36 | */ 37 | void mad_stream_init(struct mad_stream *stream) 38 | { 39 | stream->buffer = 0; 40 | stream->bufend = 0; 41 | stream->skiplen = 0; 42 | 43 | stream->sync = 0; 44 | stream->freerate = 0; 45 | 46 | stream->this_frame = 0; 47 | stream->next_frame = 0; 48 | mad_bit_init(&stream->ptr, 0); 49 | 50 | mad_bit_init(&stream->anc_ptr, 0); 51 | stream->anc_bitlen = 0; 52 | 53 | stream->main_data = 0; 54 | stream->md_len = 0; 55 | 56 | stream->options = 0; 57 | stream->error = MAD_ERROR_NONE; 58 | } 59 | 60 | /* 61 | * NAME: stream->finish() 62 | * DESCRIPTION: deallocate any dynamic memory associated with stream 63 | */ 64 | void mad_stream_finish(struct mad_stream *stream) 65 | { 66 | if (stream->main_data) { 67 | free(stream->main_data); 68 | stream->main_data = 0; 69 | } 70 | 71 | mad_bit_finish(&stream->anc_ptr); 72 | mad_bit_finish(&stream->ptr); 73 | } 74 | 75 | /* 76 | * NAME: stream->buffer() 77 | * DESCRIPTION: set stream buffer pointers 78 | */ 79 | void mad_stream_buffer(struct mad_stream *stream, 80 | unsigned char const *buffer, unsigned long length) 81 | { 82 | stream->buffer = buffer; 83 | stream->bufend = buffer + length; 84 | 85 | stream->this_frame = buffer; 86 | stream->next_frame = buffer; 87 | 88 | stream->sync = 1; 89 | 90 | mad_bit_init(&stream->ptr, buffer); 91 | } 92 | 93 | /* 94 | * NAME: stream->skip() 95 | * DESCRIPTION: arrange to skip bytes before the next frame 96 | */ 97 | void mad_stream_skip(struct mad_stream *stream, unsigned long length) 98 | { 99 | stream->skiplen += length; 100 | } 101 | 102 | /* 103 | * NAME: stream->sync() 104 | * DESCRIPTION: locate the next stream sync word 105 | */ 106 | int mad_stream_sync(struct mad_stream *stream) 107 | { 108 | register unsigned char const *ptr, *end; 109 | 110 | ptr = mad_bit_nextbyte(&stream->ptr); 111 | end = stream->bufend; 112 | 113 | while (ptr < end - 1 && 114 | !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) 115 | ++ptr; 116 | 117 | if (end - ptr < MAD_BUFFER_GUARD) 118 | return -1; 119 | 120 | mad_bit_init(&stream->ptr, ptr); 121 | 122 | return 0; 123 | } 124 | 125 | /* 126 | * NAME: stream->errorstr() 127 | * DESCRIPTION: return a string description of the current error condition 128 | */ 129 | char const *mad_stream_errorstr(struct mad_stream const *stream) 130 | { 131 | switch (stream->error) { 132 | case MAD_ERROR_NONE: return "no error"; 133 | 134 | case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; 135 | case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; 136 | 137 | case MAD_ERROR_NOMEM: return "not enough memory"; 138 | 139 | case MAD_ERROR_LOSTSYNC: return "lost synchronization"; 140 | case MAD_ERROR_BADLAYER: return "reserved header layer value"; 141 | case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; 142 | case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; 143 | case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; 144 | 145 | case MAD_ERROR_BADCRC: return "CRC check failed"; 146 | case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; 147 | case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; 148 | case MAD_ERROR_BADMODE: return "bad bitrate/mode combination"; 149 | case MAD_ERROR_BADFRAMELEN: return "bad frame length"; 150 | case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; 151 | case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; 152 | case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; 153 | case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; 154 | case MAD_ERROR_BADPART3LEN: return "bad audio data length"; 155 | case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; 156 | case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; 157 | case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; 158 | } 159 | 160 | return 0; 161 | } 162 | -------------------------------------------------------------------------------- /3rdparty/libmad/stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_STREAM_H 23 | # define LIBMAD_STREAM_H 24 | 25 | # include "bit.h" 26 | 27 | # define MAD_BUFFER_GUARD 8 28 | # define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) 29 | 30 | enum mad_error { 31 | MAD_ERROR_NONE = 0x0000, /* no error */ 32 | 33 | MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ 34 | MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ 35 | 36 | MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ 37 | 38 | MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ 39 | MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ 40 | MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ 41 | MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ 42 | MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ 43 | 44 | MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ 45 | MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ 46 | MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ 47 | MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ 48 | MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ 49 | MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ 50 | MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ 51 | MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ 52 | MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ 53 | MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ 54 | MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ 55 | MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ 56 | MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ 57 | }; 58 | 59 | # define MAD_RECOVERABLE(error) ((error) & 0xff00) 60 | 61 | struct mad_stream { 62 | unsigned char const *buffer; /* input bitstream buffer */ 63 | unsigned char const *bufend; /* end of buffer */ 64 | unsigned long skiplen; /* bytes to skip before next frame */ 65 | 66 | int sync; /* stream sync found */ 67 | unsigned long freerate; /* free bitrate (fixed) */ 68 | 69 | unsigned char const *this_frame; /* start of current frame */ 70 | unsigned char const *next_frame; /* start of next frame */ 71 | struct mad_bitptr ptr; /* current processing bit pointer */ 72 | 73 | struct mad_bitptr anc_ptr; /* ancillary bits pointer */ 74 | unsigned int anc_bitlen; /* number of ancillary bits */ 75 | 76 | unsigned char (*main_data)[MAD_BUFFER_MDLEN]; 77 | /* Layer III main_data() */ 78 | unsigned int md_len; /* bytes in main_data */ 79 | 80 | int options; /* decoding options (see below) */ 81 | enum mad_error error; /* error code (see above) */ 82 | }; 83 | 84 | enum { 85 | MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ 86 | MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ 87 | # if 0 /* not yet implemented */ 88 | MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ 89 | MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ 90 | MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ 91 | # endif 92 | }; 93 | 94 | void mad_stream_init(struct mad_stream *); 95 | void mad_stream_finish(struct mad_stream *); 96 | 97 | # define mad_stream_options(stream, opts) \ 98 | ((void) ((stream)->options = (opts))) 99 | 100 | void mad_stream_buffer(struct mad_stream *, 101 | unsigned char const *, unsigned long); 102 | void mad_stream_skip(struct mad_stream *, unsigned long); 103 | 104 | int mad_stream_sync(struct mad_stream *); 105 | 106 | char const *mad_stream_errorstr(struct mad_stream const *); 107 | 108 | # endif 109 | -------------------------------------------------------------------------------- /3rdparty/libmad/synth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_SYNTH_H 23 | # define LIBMAD_SYNTH_H 24 | 25 | # include "fixed.h" 26 | # include "frame.h" 27 | 28 | struct mad_pcm { 29 | unsigned int samplerate; /* sampling frequency (Hz) */ 30 | unsigned short channels; /* number of channels */ 31 | unsigned short length; /* number of samples per channel */ 32 | mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ 33 | }; 34 | 35 | struct mad_synth { 36 | mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ 37 | /* [ch][eo][peo][s][v] */ 38 | 39 | unsigned int phase; /* current processing phase */ 40 | 41 | struct mad_pcm pcm; /* PCM output */ 42 | }; 43 | 44 | /* single channel PCM selector */ 45 | enum { 46 | MAD_PCM_CHANNEL_SINGLE = 0 47 | }; 48 | 49 | /* dual channel PCM selector */ 50 | enum { 51 | MAD_PCM_CHANNEL_DUAL_1 = 0, 52 | MAD_PCM_CHANNEL_DUAL_2 = 1 53 | }; 54 | 55 | /* stereo PCM selector */ 56 | enum { 57 | MAD_PCM_CHANNEL_STEREO_LEFT = 0, 58 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1 59 | }; 60 | 61 | void mad_synth_init(struct mad_synth *); 62 | 63 | # define mad_synth_finish(synth) /* nothing */ 64 | 65 | void mad_synth_mute(struct mad_synth *); 66 | 67 | void mad_synth_frame(struct mad_synth *, struct mad_frame const *); 68 | 69 | # endif 70 | -------------------------------------------------------------------------------- /3rdparty/libmad/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_TIMER_H 23 | # define LIBMAD_TIMER_H 24 | 25 | typedef struct { 26 | signed long seconds; /* whole seconds */ 27 | unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ 28 | } mad_timer_t; 29 | 30 | extern mad_timer_t const mad_timer_zero; 31 | 32 | # define MAD_TIMER_RESOLUTION 352800000UL 33 | 34 | enum mad_units { 35 | MAD_UNITS_HOURS = -2, 36 | MAD_UNITS_MINUTES = -1, 37 | MAD_UNITS_SECONDS = 0, 38 | 39 | /* metric units */ 40 | 41 | MAD_UNITS_DECISECONDS = 10, 42 | MAD_UNITS_CENTISECONDS = 100, 43 | MAD_UNITS_MILLISECONDS = 1000, 44 | 45 | /* audio sample units */ 46 | 47 | MAD_UNITS_8000_HZ = 8000, 48 | MAD_UNITS_11025_HZ = 11025, 49 | MAD_UNITS_12000_HZ = 12000, 50 | 51 | MAD_UNITS_16000_HZ = 16000, 52 | MAD_UNITS_22050_HZ = 22050, 53 | MAD_UNITS_24000_HZ = 24000, 54 | 55 | MAD_UNITS_32000_HZ = 32000, 56 | MAD_UNITS_44100_HZ = 44100, 57 | MAD_UNITS_48000_HZ = 48000, 58 | 59 | /* video frame/field units */ 60 | 61 | MAD_UNITS_24_FPS = 24, 62 | MAD_UNITS_25_FPS = 25, 63 | MAD_UNITS_30_FPS = 30, 64 | MAD_UNITS_48_FPS = 48, 65 | MAD_UNITS_50_FPS = 50, 66 | MAD_UNITS_60_FPS = 60, 67 | 68 | /* CD audio frames */ 69 | 70 | MAD_UNITS_75_FPS = 75, 71 | 72 | /* video drop-frame units */ 73 | 74 | MAD_UNITS_23_976_FPS = -24, 75 | MAD_UNITS_24_975_FPS = -25, 76 | MAD_UNITS_29_97_FPS = -30, 77 | MAD_UNITS_47_952_FPS = -48, 78 | MAD_UNITS_49_95_FPS = -50, 79 | MAD_UNITS_59_94_FPS = -60 80 | }; 81 | 82 | # define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) 83 | 84 | int mad_timer_compare(mad_timer_t, mad_timer_t); 85 | 86 | # define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) 87 | 88 | void mad_timer_negate(mad_timer_t *); 89 | mad_timer_t mad_timer_abs(mad_timer_t); 90 | 91 | void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); 92 | void mad_timer_add(mad_timer_t *, mad_timer_t); 93 | void mad_timer_multiply(mad_timer_t *, signed long); 94 | 95 | signed long mad_timer_count(mad_timer_t, enum mad_units); 96 | unsigned long mad_timer_fraction(mad_timer_t, unsigned long); 97 | void mad_timer_string(mad_timer_t, char *, char const *, 98 | enum mad_units, enum mad_units, unsigned long); 99 | 100 | # endif 101 | -------------------------------------------------------------------------------- /3rdparty/libmad/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | # endif 25 | 26 | # include "global.h" 27 | 28 | # include "version.h" 29 | 30 | char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION; 31 | char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; 32 | char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; 33 | 34 | char const mad_build[] = "" 35 | # if defined(DEBUG) 36 | "DEBUG " 37 | # elif defined(NDEBUG) 38 | "NDEBUG " 39 | # endif 40 | 41 | # if defined(EXPERIMENTAL) 42 | "EXPERIMENTAL " 43 | # endif 44 | 45 | # if defined(FPM_64BIT) 46 | "FPM_64BIT " 47 | # elif defined(FPM_INTEL) 48 | "FPM_INTEL " 49 | # elif defined(FPM_ARM) 50 | "FPM_ARM " 51 | # elif defined(FPM_MIPS) 52 | "FPM_MIPS " 53 | # elif defined(FPM_SPARC) 54 | "FPM_SPARC " 55 | # elif defined(FPM_PPC) 56 | "FPM_PPC " 57 | # elif defined(FPM_DEFAULT) 58 | "FPM_DEFAULT " 59 | # endif 60 | 61 | # if defined(ASO_IMDCT) 62 | "ASO_IMDCT " 63 | # endif 64 | # if defined(ASO_INTERLEAVE1) 65 | "ASO_INTERLEAVE1 " 66 | # endif 67 | # if defined(ASO_INTERLEAVE2) 68 | "ASO_INTERLEAVE2 " 69 | # endif 70 | # if defined(ASO_ZEROCHECK) 71 | "ASO_ZEROCHECK " 72 | # endif 73 | 74 | # if defined(OPT_SPEED) 75 | "OPT_SPEED " 76 | # elif defined(OPT_ACCURACY) 77 | "OPT_ACCURACY " 78 | # endif 79 | 80 | # if defined(OPT_SSO) 81 | "OPT_SSO " 82 | # endif 83 | 84 | # if defined(OPT_DCTO) /* never defined here */ 85 | "OPT_DCTO " 86 | # endif 87 | 88 | # if defined(OPT_STRICT) 89 | "OPT_STRICT " 90 | # endif 91 | ; 92 | -------------------------------------------------------------------------------- /3rdparty/libmad/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_VERSION_H 23 | # define LIBMAD_VERSION_H 24 | 25 | # define MAD_VERSION_MAJOR 0 26 | # define MAD_VERSION_MINOR 15 27 | # define MAD_VERSION_PATCH 1 28 | # define MAD_VERSION_EXTRA " (beta)" 29 | 30 | # define MAD_VERSION_STRINGIZE(str) #str 31 | # define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) 32 | 33 | # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ 34 | MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ 35 | MAD_VERSION_STRING(MAD_VERSION_PATCH) \ 36 | MAD_VERSION_EXTRA 37 | 38 | # define MAD_PUBLISHYEAR "2000-2004" 39 | # define MAD_AUTHOR "Underbit Technologies, Inc." 40 | # define MAD_EMAIL "info@underbit.com" 41 | 42 | extern char const mad_version[]; 43 | extern char const mad_copyright[]; 44 | extern char const mad_author[]; 45 | extern char const mad_build[]; 46 | 47 | # endif 48 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | 3 | all: libsox msupcm++/msupcm 4 | 5 | FORCE: 6 | 7 | clean: FORCE 8 | $(MAKE) -C 3rdparty/sox -s clean 9 | $(MAKE) -C msupcm++ clean 10 | 11 | 3rdparty/sox/configure: 3rdparty/sox/Makefile.am 12 | autoreconf -i 3rdparty/sox 13 | 14 | 3rdparty/sox/Makefile: 3rdparty/sox/configure 15 | cd 3rdparty/sox && ./configure --without-png --without-gsm --without-lpc10 --without-id3tag --without-wavpack --disable-shared --enable-static 16 | 17 | 3rdparty/sox/soxconfig.h: 3rdparty/sox/Makefile 18 | $(MAKE) -C 3rdparty/sox -s 19 | 20 | 3rdparty/sox/src/.libs/libsox.a: 3rdparty/sox/Makefile 21 | $(MAKE) -C 3rdparty/sox -s 22 | 23 | libsox: 3rdparty/sox/src/.libs/libsox.a 3rdparty/sox/soxconfig.h 24 | 25 | msupcm++/msupcm: libsox msupcm++/msupcm.cpp 26 | $(MAKE) -C msupcm++ -s 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # msupcm++ 2 | 3 | A native libSox implementation of the msupcm tool 4 | 5 | ## Usage 6 | 7 | ``` 8 | msupcm tracks.json 9 | ``` 10 | 11 | See included [configs](configs/) for tracks.json examples 12 | 13 | ### CLI Usage 14 | 15 | [TODO] 16 | 17 | ## Building 18 | 19 | ### Dependencies 20 | 21 | After checking out the main repository, you will need to also check out all of the dependencies, which are linked as submodules. 22 | 23 | ``` 24 | cd 25 | git submodule update --init --recursive 26 | ``` 27 | 28 | ### Windows 29 | 30 | After the dependencies have been checked out, simply open the msupcm++.sln file in Visual Studio (2019 or later) and build the solution. 31 | 32 | ### Linux 33 | 34 | First, start by installing all necessary build tools 35 | 36 | ``` 37 | sudo apt install build-essential autoconf libtool 38 | ``` 39 | 40 | and dependency system dev packages 41 | 42 | ``` 43 | sudo apt install libao-dev libasound-dev libmad0-dev libmp3lame-dev libopusfile-dev libpulse-dev libsndfile1-dev libsndio-dev 44 | ``` 45 | 46 | then simply run 47 | 48 | ``` 49 | make 50 | ``` 51 | 52 | from the top-level repo directory. -------------------------------------------------------------------------------- /configs/alttp_albw.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/qwertymodo/msupcmplusplus/master/configs/schema#", 3 | "game": "The Legend of Zelda: A Link to the Past", 4 | "pack": "The Legend of Zelda: A Link Between Worlds OST", 5 | "url": "http://forums.ffshrine.org/showthread.php?t=172599", 6 | "normalization": -21, 7 | "output_prefix": "alttp_msu", 8 | "sample_rate": 32728, 9 | "tracks": [ 10 | { 11 | "track_number": 1, 12 | "title": "Title ~ Link to the Past", 13 | "file": "Title Screen.flac", 14 | "trim_end": 821344, 15 | "loop": 670293 16 | }, 17 | { 18 | "track_number": 2, 19 | "title": "Hyrule Field", 20 | "file": "Hyrule Overworld #1.flac", 21 | "trim_end": 2158298, 22 | "loop": 254178 23 | }, 24 | { 25 | "track_number": 5, 26 | "title": "Forest of Mystery", 27 | "file": "Lost Woods.flac", 28 | "trim_end": 1327515, 29 | "loop": 60 30 | }, 31 | { 32 | "track_number": 7, 33 | "title": "Kakariko Village", 34 | "file": "Kakariko Village.flac", 35 | "trim_end": 3786972, 36 | "loop": 262868 37 | }, 38 | { 39 | "track_number": 9, 40 | "title": "Dark Golden Land", 41 | "file": "Lorule Overworld #3 (All Sages Saved).flac", 42 | "trim_end": 2400958, 43 | "loop": 7693 44 | }, 45 | { 46 | "track_number": 10, 47 | "title": "Unsealing the Master Sword", 48 | "file": "You Got The Master Sword!.flac", 49 | "trim_end": 403950, 50 | "fade_out": 15000 51 | }, 52 | { 53 | "track_number": 11, 54 | "title": "Beginning of the Journey", 55 | "file": "File Select.flac", 56 | "trim_end": 1668973, 57 | "loop": 98029 58 | }, 59 | { 60 | "track_number": 12, 61 | "title": "Soldiers of Kakariko Village", 62 | "file": "Crisis at the Sanctuary.flac", 63 | "trim_end": 288621, 64 | "loop": 92116 65 | }, 66 | { 67 | "track_number": 13, 68 | "title": "Black Mist", 69 | "file": "Death Mountain.flac", 70 | "trim_end": 2077561, 71 | "loop": 85249 72 | }, 73 | { 74 | "track_number": 14, 75 | "title": "Guessing Game House", 76 | "file": "Treasure Chest Minigame.flac", 77 | "trim_end": 688367, 78 | "loop": 59781 79 | }, 80 | { 81 | "track_number": 16, 82 | "title": "Majestic Castle", 83 | "file": "Hyrule Castle Infiltration.flac", 84 | "trim_end": 5280490, 85 | "loop": 2832876 86 | }, 87 | { 88 | "track_number": 17, 89 | "title": "Lost Ancient Ruins", 90 | "file": "Hyrulian Dungeons.flac", 91 | "trim_end": 3943903, 92 | "loop": 1718438 93 | }, 94 | { 95 | "track_number": 18, 96 | "title": "Dank Dungeons", 97 | "file": "Cave.flac", 98 | "trim_end": 834711, 99 | "loop": 49067 100 | }, 101 | { 102 | "track_number": 19, 103 | "title": "Great Victory!", 104 | "file": "Hyrulian Boss Defeated!.flac", 105 | "trim_end": 128800, 106 | "fade_out": 15000 107 | }, 108 | { 109 | "track_number": 20, 110 | "title": "Safety in the Sanctuary", 111 | "file": "Sanctuary (Church).flac", 112 | "trim_end": 3674289, 113 | "loop": 1601757 114 | }, 115 | { 116 | "track_number": 21, 117 | "title": "Anger of the Guardians", 118 | "file": "Hyrulian Boss Battle.flac", 119 | "trim_end": 1359840, 120 | "loop": 661643 121 | }, 122 | { 123 | "track_number": 23, 124 | "title": "Fortune Teller", 125 | "file": "Fortune Teller's House.flac", 126 | "trim_end": 631450, 127 | "loop": 3355 128 | }, 129 | { 130 | "track_number": 24, 131 | "title": "Dank Dungeons", 132 | "file": "Cave.flac", 133 | "trim_end": 834711, 134 | "loop": 49067 135 | }, 136 | { 137 | "track_number": 27, 138 | "title": "The Goddess Appears", 139 | "file": "Fairy's Fountain.flac", 140 | "trim_end": 1040368, 141 | "loop": 254803 142 | }, 143 | { 144 | "track_number": 33, 145 | "title": "Epilogue - Beautiful Hyrule", 146 | "file": "Staff Roll.flac" 147 | } 148 | ] 149 | } -------------------------------------------------------------------------------- /configs/mmx_guitar_playthrough.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/qwertymodo/msupcmplusplus/master/configs/schema#", 3 | "game": "Mega Man X", 4 | "pack": "Mega Man X Guitar Playthrough", 5 | "artist": "Krzysztof Słowikowski", 6 | "url": "http://www.mediafire.com/?gb61j7qiwkadu2w", 7 | "normalization": -21, 8 | "output_prefix": "mmx_msu", 9 | "tracks": [ 10 | { 11 | "track_number": 1, 12 | "title": "Opening Stage", 13 | "file": "03 - Opening Stage.wav", 14 | "trim_end": 2131156, 15 | "loop": 83170 16 | }, 17 | { 18 | "track_number": 2, 19 | "title": "Sting Chameleon", 20 | "file": "16 - Sting Chameleon.wav", 21 | "trim_end": 1657338, 22 | "loop": 31062 23 | }, 24 | { 25 | "track_number": 3, 26 | "title": "Launch Octopus", 27 | "file": "14 - Launch Octopus.wav", 28 | "trim_end": 2343136, 29 | "loop": 39033 30 | }, 31 | { 32 | "track_number": 4, 33 | "title": "Armored Armadillo", 34 | "file": "13 - Armored Armadillo.wav", 35 | "trim_end": 2584829, 36 | "loop": 42292 37 | }, 38 | { 39 | "track_number": 5, 40 | "title": "Flame Mammoth", 41 | "file": "10 - Flame Mammoth.wav", 42 | "trim_end": 3316882, 43 | "loop": 803438 44 | }, 45 | { 46 | "track_number": 6, 47 | "title": "Boomer Kuwanger", 48 | "file": "15 - Boomer Kuwanger.wav", 49 | "trim_end": 3301981, 50 | "loop": 383580 51 | }, 52 | { 53 | "track_number": 7, 54 | "title": "Chill Penguin", 55 | "file": "11 - Chill Penguin.wav", 56 | "trim_end": 2422248, 57 | "loop": 858824 58 | }, 59 | { 60 | "track_number": 8, 61 | "title": "Spark Mandrill", 62 | "file": "12 - Spark Mandrill.wav", 63 | "trim_end": 2516190, 64 | "loop": 142988 65 | }, 66 | { 67 | "track_number": 9, 68 | "title": "Storm Eagle", 69 | "file": "17 - Storm Eagle.wav", 70 | "trim_end": 1803764, 71 | "loop": 312928 72 | }, 73 | { 74 | "track_number": 10, 75 | "title": "Sigma Stage 1", 76 | "file": "23 - Sigma Stage 1.wav", 77 | "trim_end": 3684187, 78 | "loop": 1305869 79 | }, 80 | { 81 | "track_number": 11, 82 | "title": "Sigma Stage 2", 83 | "file": "24 - Sigma Stage 2.wav", 84 | "trim_end": 3116507, 85 | "loop": 166680 86 | }, 87 | { 88 | "track_number": 12, 89 | "title": "Sigma Stage 3", 90 | "file": "25 - Sigma Stage 3.wav", 91 | "trim_end": 2588753, 92 | "loop": 376698 93 | }, 94 | { 95 | "track_number": 13, 96 | "title": "Sigma Stage 4", 97 | "file": "26 - Sigma Stage 4.wav", 98 | "trim_end": 1118965, 99 | "loop": 241100 100 | }, 101 | { 102 | "track_number": 14, 103 | "title": "Boss", 104 | "file": "19 - Boss.wav", 105 | "trim_end": 1535918, 106 | "loop": 180626 107 | }, 108 | { 109 | "track_number": 15, 110 | "title": "Title", 111 | "file": "01 - Title.wav" 112 | }, 113 | { 114 | "track_number": 16, 115 | "title": "Stage Select (Mavericks)", 116 | "file": "08 - Stage Select (Mavericks).wav", 117 | "trim_end": 1253424, 118 | "loop": 147504 119 | }, 120 | { 121 | "track_number": 17, 122 | "title": "Stage Clear", 123 | "file": "20 - Stage Clear.wav" 124 | }, 125 | { 126 | "track_number": 18, 127 | "title": "Stage Start", 128 | "file": "09 - Stage Start.wav" 129 | }, 130 | { 131 | "track_number": 19, 132 | "title": "Vile (intro)", 133 | "file": "04 - Vile (intro).wav", 134 | "trim_end": 498474, 135 | "loop": 104688 136 | }, 137 | { 138 | "track_number": 20, 139 | "title": "Vile", 140 | "file": "05 - Vile.wav", 141 | "trim_end": 1324164, 142 | "loop": 7565 143 | }, 144 | { 145 | "track_number": 21, 146 | "title": "Zero", 147 | "file": "06 - Zero.wav", 148 | "trim_end": 961360, 149 | "loop": 325918 150 | }, 151 | { 152 | "track_number": 22, 153 | "title": "Variable X", 154 | "file": "07 - Variable X.wav", 155 | "trim_end": 1663196, 156 | "loop": 346318 157 | }, 158 | { 159 | "track_number": 23, 160 | "title": "Get a Weapon", 161 | "file": "21 - Get a Weapon.wav", 162 | "trim_end": 836214, 163 | "loop": 507127 164 | }, 165 | { 166 | "track_number": 24, 167 | "title": "Password", 168 | "file": "02 - Password.wav", 169 | "trim_end": 1765666, 170 | "loop": 8786 171 | }, 172 | { 173 | "track_number": 25, 174 | "title": "Stage Select (Σ)", 175 | "file": "22 - Stage Select (Σ).wav", 176 | "trim_end": 869688, 177 | "loop": 101869 178 | }, 179 | { 180 | "track_number": 26, 181 | "title": "Sigma Battle 1", 182 | "file": "27 - Sigma Battle 1.wav", 183 | "trim_end": 1630499, 184 | "loop": 4209 185 | }, 186 | { 187 | "track_number": 27, 188 | "title": "Sigma Battle 2", 189 | "file": "29 - Sigma Battle 2.wav", 190 | "trim_end": 2539865, 191 | "loop": 5161 192 | }, 193 | { 194 | "track_number": 28, 195 | "title": "Ending", 196 | "file": "31 - Ending.wav" 197 | }, 198 | { 199 | "track_number": 29, 200 | "title": "Cast Roll", 201 | "file": "32 - Cast Roll.wav", 202 | "trim_end": 3047658, 203 | "loop": 835746 204 | }, 205 | { 206 | "track_number": 30, 207 | "title": "Boss (Intro)", 208 | "file": "18 - Boss (Intro).wav", 209 | "trim_end": 499677, 210 | "loop": 170595 211 | }, 212 | { 213 | "track_number": 31, 214 | "title": "Sigma Rebirth", 215 | "file": "28 - Sigma Rebirth.wav" 216 | }, 217 | { 218 | "track_number": 32, 219 | "title": "Staff Roll", 220 | "file": "33 - Staff Roll.wav", 221 | "trim_end": 2292169, 222 | "loop": 36689 223 | }, 224 | { 225 | "track_number": 33, 226 | "title": "Dr Light", 227 | "file": "30 - Dr Light.wav", 228 | "trim_end": 799964, 229 | "loop": 92447 230 | } 231 | ] 232 | } -------------------------------------------------------------------------------- /configs/super_mario_odyssey.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/qwertymodo/msupcmplusplus/master/configs/schema#", 3 | "game": "Super Mario Odyssey", 4 | "url": "http://bmf.rustedlogic.net/smw/smo_msu1.rar", 5 | "normalization": -24, 6 | "output_prefix": "smo_msu1", 7 | "tracks": [ 8 | { 9 | "track_number": 0, 10 | "file": "smo_msu1-0.wav" 11 | }, 12 | { 13 | "track_number": 1, 14 | "file": "smo_msu1-1.wav", 15 | "use_option": 2, 16 | "options": [ 17 | { 18 | "option": 1, 19 | "trim_start": 0 20 | }, 21 | { 22 | "option": 2, 23 | "trim_end": 3824400, 24 | "loop": 606884 25 | } 26 | ] 27 | }, 28 | { 29 | "track_number": 3, 30 | "file": "smo_msu1-3.wav", 31 | "use_option": 2, 32 | "options": [ 33 | { 34 | "option": 1, 35 | "loop": 0 36 | }, 37 | { 38 | "option": 2, 39 | "trim_end": 331343, 40 | "loop": 585 41 | } 42 | ] 43 | }, 44 | { 45 | "track_number": 4, 46 | "file": "smo_msu1-4.wav", 47 | "trim_end": 2067252, 48 | "loop": 82701 49 | }, 50 | { 51 | "track_number": 6, 52 | "file": "smo_msu1-6.wav", 53 | "sub_tracks": [ 54 | { 55 | "loop": 5701 56 | }, 57 | { 58 | "trim_start": 174935, 59 | "trim_end": 186225 60 | } 61 | ] 62 | }, 63 | { 64 | "track_number": 7, 65 | "file": "smo_msu1-7.wav", 66 | "loop": 361442 67 | } 68 | ] 69 | } -------------------------------------------------------------------------------- /msupcm++.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msupcm++", "msupcm++\msupcm++.vcxproj", "{7A51C6A5-6FDC-4293-97A1-57A53E1BFE36}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {F17BE535-C7E8-4930-A6FD-32498D73A533} = {F17BE535-C7E8-4930-A6FD-32498D73A533} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibSoX", "3rdparty\sox\msvc14\LibSoX.vcxproj", "{F17BE535-C7E8-4930-A6FD-32498D73A533}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0} = {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0} 14 | {B7A8AD9A-0D07-4453-B2DE-FEABD9546263} = {B7A8AD9A-0D07-4453-B2DE-FEABD9546263} 15 | {C5C229AC-316D-42CB-9CA3-329619618972} = {C5C229AC-316D-42CB-9CA3-329619618972} 16 | {524A24CD-0973-4733-8EB9-F419DC6F9997} = {524A24CD-0973-4733-8EB9-F419DC6F9997} 17 | EndProjectSection 18 | EndProject 19 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibFlac", "3rdparty\sox\msvc14\LibFlac.vcxproj", "{38203D05-AF71-4FF2-A183-A7D9CB8D2AE0}" 20 | EndProject 21 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibMad", "3rdparty\sox\msvc14\LibMad.vcxproj", "{B7A8AD9A-0D07-4453-B2DE-FEABD9546263}" 22 | EndProject 23 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOgg", "3rdparty\sox\msvc14\LibOgg.vcxproj", "{C5C229AC-316D-42CB-9CA3-329619618972}" 24 | EndProject 25 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibVorbis", "3rdparty\sox\msvc14\LibVorbis.vcxproj", "{524A24CD-0973-4733-8EB9-F419DC6F9997}" 26 | EndProject 27 | Global 28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 29 | Debug|x86 = Debug|x86 30 | Release|x86 = Release|x86 31 | EndGlobalSection 32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 33 | {7A51C6A5-6FDC-4293-97A1-57A53E1BFE36}.Debug|x86.ActiveCfg = Debug|Win32 34 | {7A51C6A5-6FDC-4293-97A1-57A53E1BFE36}.Debug|x86.Build.0 = Debug|Win32 35 | {7A51C6A5-6FDC-4293-97A1-57A53E1BFE36}.Release|x86.ActiveCfg = Release|Win32 36 | {7A51C6A5-6FDC-4293-97A1-57A53E1BFE36}.Release|x86.Build.0 = Release|Win32 37 | {F17BE535-C7E8-4930-A6FD-32498D73A533}.Debug|x86.ActiveCfg = Debug|Win32 38 | {F17BE535-C7E8-4930-A6FD-32498D73A533}.Debug|x86.Build.0 = Debug|Win32 39 | {F17BE535-C7E8-4930-A6FD-32498D73A533}.Release|x86.ActiveCfg = Release|Win32 40 | {F17BE535-C7E8-4930-A6FD-32498D73A533}.Release|x86.Build.0 = Release|Win32 41 | {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0}.Debug|x86.ActiveCfg = Debug|Win32 42 | {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0}.Debug|x86.Build.0 = Debug|Win32 43 | {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0}.Release|x86.ActiveCfg = Release|Win32 44 | {38203D05-AF71-4FF2-A183-A7D9CB8D2AE0}.Release|x86.Build.0 = Release|Win32 45 | {B7A8AD9A-0D07-4453-B2DE-FEABD9546263}.Debug|x86.ActiveCfg = Debug|Win32 46 | {B7A8AD9A-0D07-4453-B2DE-FEABD9546263}.Debug|x86.Build.0 = Debug|Win32 47 | {B7A8AD9A-0D07-4453-B2DE-FEABD9546263}.Release|x86.ActiveCfg = Release|Win32 48 | {B7A8AD9A-0D07-4453-B2DE-FEABD9546263}.Release|x86.Build.0 = Release|Win32 49 | {C5C229AC-316D-42CB-9CA3-329619618972}.Debug|x86.ActiveCfg = Debug|Win32 50 | {C5C229AC-316D-42CB-9CA3-329619618972}.Debug|x86.Build.0 = Debug|Win32 51 | {C5C229AC-316D-42CB-9CA3-329619618972}.Release|x86.ActiveCfg = Release|Win32 52 | {C5C229AC-316D-42CB-9CA3-329619618972}.Release|x86.Build.0 = Release|Win32 53 | {524A24CD-0973-4733-8EB9-F419DC6F9997}.Debug|x86.ActiveCfg = Debug|Win32 54 | {524A24CD-0973-4733-8EB9-F419DC6F9997}.Debug|x86.Build.0 = Debug|Win32 55 | {524A24CD-0973-4733-8EB9-F419DC6F9997}.Release|x86.ActiveCfg = Release|Win32 56 | {524A24CD-0973-4733-8EB9-F419DC6F9997}.Release|x86.Build.0 = Release|Win32 57 | EndGlobalSection 58 | GlobalSection(SolutionProperties) = preSolution 59 | HideSolutionNode = FALSE 60 | EndGlobalSection 61 | EndGlobal 62 | -------------------------------------------------------------------------------- /msupcm++/AudioBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef WIN32 5 | #define fstring_t wstring 6 | #else 7 | #define fstring_t string 8 | #endif 9 | 10 | namespace msu 11 | { 12 | class AudioBase 13 | { 14 | public: 15 | AudioBase(); 16 | AudioBase(std::fstring_t in); 17 | AudioBase(std::fstring_t in, std::fstring_t out); 18 | AudioBase(int argc, char** argv); 19 | AudioBase(const AudioBase& a); 20 | ~AudioBase(); 21 | 22 | AudioBase& operator=(const AudioBase& a); 23 | 24 | virtual void clear(); 25 | 26 | virtual void render(); 27 | 28 | const std::fstring_t& inFile() const; 29 | std::fstring_t& inFile(); 30 | 31 | const std::fstring_t& outFile() const; 32 | std::fstring_t& outFile(); 33 | 34 | int loop() const; 35 | int& loop(); 36 | 37 | int trimStart() const; 38 | int& trimStart(); 39 | 40 | int trimEnd() const; 41 | int& trimEnd(); 42 | 43 | int fadeIn() const; 44 | int& fadeIn(); 45 | 46 | int fadeOut() const; 47 | int& fadeOut(); 48 | 49 | int crossFade() const; 50 | int& crossFade(); 51 | 52 | int padStart() const; 53 | int& padStart(); 54 | 55 | int padEnd() const; 56 | int& padEnd(); 57 | 58 | double tempo() const; 59 | double& tempo(); 60 | 61 | double normalization() const; 62 | double& normalization(); 63 | 64 | bool compression() const; 65 | bool& compression(); 66 | 67 | protected: 68 | std::fstring_t m_infile; 69 | std::fstring_t m_outfile; 70 | int m_loop; 71 | int m_trim_start; 72 | int m_trim_end; 73 | int m_start_offset; 74 | int m_fade_in; 75 | int m_fade_out; 76 | int m_cross_fade; 77 | int m_pad_start; 78 | int m_pad_end; 79 | double m_tempo; 80 | double m_normalization; 81 | bool m_compression; 82 | char m_dither_type; 83 | }; 84 | } 85 | -------------------------------------------------------------------------------- /msupcm++/AudioSubChannel.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioSubChannel.h" 2 | #include "AudioSubTrack.h" 3 | #include "GlobalConfig.h" 4 | #include "SoxWrapper.h" 5 | #include "utf8.h" 6 | 7 | #include 8 | 9 | #ifdef WIN32 10 | #define CONCAT(x, y) x##y 11 | #define WSTR_L(x) CONCAT(L, x) 12 | #else 13 | #define WSTR_L(x) x 14 | #define wchar_t char 15 | #endif 16 | 17 | using namespace msu; 18 | 19 | AudioSubChannel::AudioSubChannel() : 20 | AudioBase() 21 | { 22 | m_sub_tracks = 0; 23 | m_num_sub_tracks = 0; 24 | } 25 | 26 | 27 | AudioSubChannel::AudioSubChannel(std::fstring_t in) : AudioBase(in) 28 | { 29 | m_sub_tracks = 0; 30 | m_num_sub_tracks = 0; 31 | } 32 | 33 | 34 | AudioSubChannel::AudioSubChannel(std::fstring_t in, std::fstring_t out) : AudioBase(in, out) 35 | { 36 | m_sub_tracks = 0; 37 | m_num_sub_tracks = 0; 38 | } 39 | 40 | 41 | AudioSubChannel::AudioSubChannel(int argc, char** argv) : AudioBase(argc, argv), 42 | m_sub_tracks(0), m_num_sub_tracks(0) 43 | { 44 | wchar_t** _argv = new wchar_t*[argc + 1]; 45 | _argv[0] = WSTR_L("AudioSubChannel"); 46 | int _argc = 1; 47 | 48 | for (auto i = 0; i < argc; ++i) 49 | { 50 | if (argv[i][0] == '[') 51 | { 52 | int s_argc = 0; 53 | char** s_argv = new char*[argc]; 54 | s_argv[s_argc] = new char[strlen(argv[i])]{ 0 }; 55 | 56 | if (argv[i][strlen(argv[i]) - 1] == ']') 57 | { 58 | strncpy(s_argv[s_argc++], argv[i] + 1, strlen(argv[i]) - 2); 59 | } 60 | 61 | else 62 | { 63 | strcpy(s_argv[s_argc++], argv[i++] + 1); 64 | for (int depth = 1; i < argc; ++i) 65 | { 66 | s_argv[s_argc] = new char[strlen(argv[i])]{ 0 }; 67 | 68 | if (argv[i][strlen(argv[i]) - 1] == ']') 69 | --depth; 70 | 71 | if (depth == 0) 72 | { 73 | strncpy(s_argv[s_argc++], argv[i], strlen(argv[i]) - 1); 74 | break; 75 | } 76 | 77 | else 78 | strcpy(s_argv[s_argc++], argv[i]); 79 | 80 | if (argv[i][0] == '[') 81 | ++depth; 82 | } 83 | } 84 | 85 | addSubTrack(new AudioSubTrack(s_argc, s_argv)); 86 | } 87 | } 88 | 89 | for (auto i = 1; i < _argc; ++i) 90 | delete _argv[i]; 91 | delete[] _argv; 92 | } 93 | 94 | 95 | AudioSubChannel::AudioSubChannel(const AudioSubChannel& a) : AudioBase(a) 96 | { 97 | m_sub_tracks = 0; 98 | m_num_sub_tracks = 0; 99 | *this = a; 100 | } 101 | 102 | 103 | AudioSubChannel::~AudioSubChannel() 104 | { 105 | clear(); 106 | } 107 | 108 | 109 | void AudioSubChannel::clear() 110 | { 111 | if (m_sub_tracks) 112 | delete[] dynamic_cast(m_sub_tracks); 113 | 114 | m_sub_tracks = 0; 115 | m_num_sub_tracks = 0; 116 | } 117 | 118 | 119 | AudioSubChannel& AudioSubChannel::operator=(const AudioSubChannel& a) 120 | { 121 | clear(); 122 | AudioBase::operator=(a); 123 | 124 | m_num_sub_tracks = a.m_num_sub_tracks; 125 | if (m_num_sub_tracks) 126 | { 127 | AudioSubTrack* s = new AudioSubTrack[m_num_sub_tracks]; 128 | for (auto i = 0; i < m_num_sub_tracks; ++i) 129 | { 130 | s[i] = dynamic_cast(a.m_sub_tracks)[i]; 131 | } 132 | 133 | if (m_sub_tracks) 134 | { 135 | delete[] m_sub_tracks; 136 | } 137 | 138 | m_sub_tracks = s; 139 | } 140 | else 141 | { 142 | m_sub_tracks = 0; 143 | } 144 | 145 | return *this; 146 | } 147 | 148 | 149 | AudioSubChannel& AudioSubChannel::operator=(const AudioBase& a) 150 | { 151 | this->~AudioSubChannel(); 152 | AudioBase::operator=(a); 153 | return *this; 154 | } 155 | 156 | 157 | AudioBase* AudioSubChannel::subTracks() const 158 | { 159 | return m_sub_tracks; 160 | } 161 | 162 | 163 | int AudioSubChannel::numSubTracks() const 164 | { 165 | return m_num_sub_tracks; 166 | } 167 | 168 | 169 | void AudioSubChannel::addSubTrack(AudioBase* a) 170 | { 171 | AudioSubTrack* s = new AudioSubTrack[m_num_sub_tracks + 1]; 172 | for (auto i = 0; i < m_num_sub_tracks; ++i) 173 | { 174 | s[i] = dynamic_cast(m_sub_tracks)[i]; 175 | } 176 | s[m_num_sub_tracks++] = *dynamic_cast(a); 177 | 178 | if (m_sub_tracks) 179 | { 180 | delete[] dynamic_cast(m_sub_tracks); 181 | } 182 | 183 | m_sub_tracks = s; 184 | } 185 | 186 | 187 | void AudioSubChannel::render() 188 | { 189 | SoxWrapper* sox = SoxWrapperFactory::getInstance(); 190 | 191 | if (m_num_sub_tracks) 192 | { 193 | size_t sub_loop = 0; 194 | for (auto i = 0; i < m_num_sub_tracks; ++i) 195 | { 196 | AudioSubTrack* p = &dynamic_cast(m_sub_tracks)[i]; 197 | if (p->inFile().empty()) 198 | p->inFile() = inFile(); 199 | 200 | // Read existing loop point from PCM inputs if one isn't explicitly specified 201 | if (p->inFile().substr(p->inFile().length() - 4).compare(WSTR_L(".pcm")) == 0 && p->loop() == 0) 202 | { 203 | #ifdef WIN32 204 | std::ifstream infile(utf8_to_wstring.to_bytes(p->inFile()).c_str(), std::ios::in | std::ios::binary); 205 | #else 206 | std::ifstream infile(p->inFile().c_str(), std::ios::in | std::ios::binary); 207 | #endif 208 | if (infile.is_open()) 209 | { 210 | char signature[4]; 211 | infile.read(signature, 4); // Verify file signature 212 | if (strncmp(signature, "MSU1", 4) == 0) 213 | { 214 | infile.read((char*)&p->loop(), sizeof(p->loop())); 215 | } 216 | } 217 | infile.close(); 218 | } 219 | 220 | size_t loop = p->loop(); 221 | if (p->trimStart() > p->loop()) 222 | p->loop() = p->trimStart(); 223 | 224 | #ifdef WIN32 225 | p->outFile() = m_outfile.substr(0, m_outfile.find_last_of(WSTR_L("."))).append(WSTR_L("_str")).append(std::to_wstring(i)).append(WSTR_L(".wav")); 226 | #else 227 | p->outFile() = m_outfile.substr(0, m_outfile.find_last_of(WSTR_L("."))).append(WSTR_L("_str")).append(std::to_string(i)).append(WSTR_L(".wav")); 228 | #endif 229 | p->render(); 230 | if (!m_loop) 231 | { 232 | if (loop) 233 | { 234 | m_loop = sub_loop + ((loop - p->trimStart() + p->padStart()) * 44100.0 / sox->inputRate() / sox->tempo()); 235 | } 236 | else 237 | { 238 | sub_loop += sox->length(); 239 | } 240 | } 241 | } 242 | 243 | if (sox->init(dynamic_cast(m_sub_tracks)[0].outFile(), m_outfile)) 244 | { 245 | if (m_loop && m_trim_start > m_loop) 246 | { 247 | m_start_offset = m_trim_start - m_loop; 248 | m_trim_start = m_loop; 249 | } 250 | 251 | for (auto i = 1; i < m_num_sub_tracks; ++i) 252 | { 253 | sox->addInput(dynamic_cast(m_sub_tracks)[i].outFile()); 254 | } 255 | sox->combine(sox_concatenate); 256 | if (m_compression) 257 | sox->compress(); 258 | if (sox->crossFade(m_loop, m_trim_end, m_cross_fade)) 259 | m_trim_end = 0; 260 | sox->trim(m_trim_start, m_trim_end); 261 | sox->normalize(m_normalization); 262 | sox->fade(m_fade_in, m_fade_out); 263 | sox->tempo(m_tempo); 264 | sox->loop(m_trim_start + m_start_offset, m_loop); 265 | sox->pad(m_pad_start, m_pad_end); 266 | sox->dither(m_dither_type); 267 | sox->finalize(); 268 | } 269 | 270 | for (auto i = 0; i < m_num_sub_tracks; ++i) 271 | { 272 | if (!config.keep_temps()) 273 | #ifdef WIN32 274 | remove(utf8_to_wstring.to_bytes(dynamic_cast(m_sub_tracks)[i].outFile()).c_str()); 275 | #else 276 | remove(dynamic_cast(m_sub_tracks)[i].outFile().c_str()); 277 | #endif 278 | } 279 | } 280 | else 281 | { 282 | AudioBase::render(); 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /msupcm++/AudioSubChannel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AudioBase.h" 3 | #include "AudioSubTrack.h" 4 | 5 | /** 6 | * An AudioSubChannel is a type of AudioBase which will be mixed with other 7 | * AudioSubChannels to form the final track. AudioSubChannels may contain 0 or 8 | * more AudioSubTracks. 9 | */ 10 | 11 | namespace msu 12 | { 13 | class AudioSubChannel : public virtual AudioBase 14 | { 15 | public: 16 | AudioSubChannel(); 17 | AudioSubChannel(std::fstring_t in); 18 | AudioSubChannel(std::fstring_t in, std::fstring_t out); 19 | AudioSubChannel(int argc, char** argv); 20 | AudioSubChannel(const AudioSubChannel& a); 21 | ~AudioSubChannel(); 22 | 23 | AudioSubChannel& operator=(const AudioSubChannel& a); 24 | AudioSubChannel& operator=(const AudioBase& a); 25 | 26 | virtual void clear() override; 27 | 28 | virtual void render() override; 29 | 30 | AudioBase* subTracks() const; 31 | int numSubTracks() const; 32 | 33 | void addSubTrack(AudioBase* a); 34 | 35 | protected: 36 | AudioBase* m_sub_tracks; 37 | int m_num_sub_tracks; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /msupcm++/AudioSubTrack.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioSubTrack.h" 2 | #include "AudioSubChannel.h" 3 | #include "GlobalConfig.h" 4 | #include "SoxWrapper.h" 5 | #include "utf8.h" 6 | 7 | #include 8 | 9 | #ifdef WIN32 10 | #define CONCAT(x, y) x##y 11 | #define WSTR_L(x) CONCAT(L, x) 12 | #else 13 | #define WSTR_L(x) x 14 | #define wchar_t char 15 | #endif 16 | 17 | using namespace msu; 18 | 19 | AudioSubTrack::AudioSubTrack() : AudioBase() 20 | { 21 | m_sub_channels = 0; 22 | m_num_sub_channels = 0; 23 | } 24 | 25 | 26 | AudioSubTrack::AudioSubTrack(std::fstring_t in) : AudioBase(in) 27 | { 28 | m_sub_channels = 0; 29 | m_num_sub_channels = 0; 30 | } 31 | 32 | 33 | AudioSubTrack::AudioSubTrack(std::fstring_t in, std::fstring_t out) : AudioBase(in, out) 34 | { 35 | m_sub_channels = 0; 36 | m_num_sub_channels = 0; 37 | } 38 | 39 | 40 | AudioSubTrack::AudioSubTrack(int argc, char** argv) : AudioBase(argc, argv), 41 | m_sub_channels(0), m_num_sub_channels(0) 42 | { 43 | wchar_t** _argv = new wchar_t*[argc + 1]; 44 | _argv[0] = WSTR_L("AudioSubTrack"); 45 | int _argc = 1; 46 | 47 | for (auto i = 0; i < argc; ++i) 48 | { 49 | if (argv[i][0] == '(') 50 | { 51 | int s_argc = 0; 52 | char** s_argv = new char*[argc]; 53 | s_argv[s_argc] = new char[strlen(argv[i])]{ 0 }; 54 | 55 | if (argv[i][strlen(argv[i]) - 1] == ')') 56 | { 57 | strncpy(s_argv[s_argc++], argv[i] + 1, strlen(argv[i]) - 2); 58 | } 59 | 60 | else 61 | { 62 | strcpy(s_argv[s_argc++], argv[i++] + 1); 63 | for (int depth = 1; i < argc; ++i) 64 | { 65 | s_argv[s_argc] = new char[strlen(argv[i])]{ 0 }; 66 | 67 | if (argv[i][strlen(argv[i]) - 1] == ')') 68 | --depth; 69 | 70 | if (depth == 0) 71 | { 72 | strncpy(s_argv[s_argc++], argv[i], strlen(argv[i]) - 1); 73 | break; 74 | } 75 | 76 | else 77 | strcpy(s_argv[s_argc++], argv[i]); 78 | 79 | if (argv[i][0] == '(') 80 | ++depth; 81 | } 82 | } 83 | 84 | addSubChannel(new AudioSubChannel(s_argc, s_argv)); 85 | } 86 | } 87 | 88 | for (auto i = 1; i < _argc; ++i) 89 | delete _argv[i]; 90 | delete[] _argv; 91 | } 92 | 93 | 94 | AudioSubTrack::AudioSubTrack(const AudioSubTrack& a) : AudioBase(a) 95 | { 96 | m_sub_channels = 0; 97 | m_num_sub_channels = 0; 98 | *this = a; 99 | } 100 | 101 | 102 | AudioSubTrack::~AudioSubTrack() 103 | { 104 | clear(); 105 | } 106 | 107 | 108 | AudioSubTrack& AudioSubTrack::operator=(const AudioSubTrack& a) 109 | { 110 | clear(); 111 | AudioBase::operator=(a); 112 | 113 | m_num_sub_channels = a.m_num_sub_channels; 114 | if (m_num_sub_channels) 115 | { 116 | AudioSubChannel* s = new AudioSubChannel[m_num_sub_channels]; 117 | for (auto i = 0; i < m_num_sub_channels; ++i) 118 | { 119 | s[i] = dynamic_cast(a.m_sub_channels)[i]; 120 | } 121 | 122 | if (m_sub_channels) 123 | { 124 | delete[] m_sub_channels; 125 | } 126 | 127 | m_sub_channels = s; 128 | } 129 | else 130 | { 131 | m_sub_channels = 0; 132 | } 133 | 134 | return *this; 135 | } 136 | 137 | 138 | AudioSubTrack& AudioSubTrack::operator=(const AudioBase& a) 139 | { 140 | this->~AudioSubTrack(); 141 | AudioBase::operator=(a); 142 | return *this; 143 | } 144 | 145 | 146 | void AudioSubTrack::clear() 147 | { 148 | if (m_sub_channels) 149 | delete[] dynamic_cast(m_sub_channels); 150 | 151 | m_sub_channels = 0; 152 | m_num_sub_channels = 0; 153 | } 154 | 155 | 156 | AudioBase* AudioSubTrack::subChannels() const 157 | { 158 | return m_sub_channels; 159 | } 160 | 161 | 162 | int AudioSubTrack::numSubChannels() const 163 | { 164 | return m_num_sub_channels; 165 | } 166 | 167 | 168 | void AudioSubTrack::addSubChannel(AudioBase* a) 169 | { 170 | AudioSubChannel* s = new AudioSubChannel[m_num_sub_channels + 1]; 171 | for (auto i = 0; i < m_num_sub_channels; ++i) 172 | { 173 | s[i] = dynamic_cast(m_sub_channels)[i]; 174 | } 175 | s[m_num_sub_channels++] = *dynamic_cast(a); 176 | 177 | if (m_sub_channels) 178 | { 179 | delete[] dynamic_cast(m_sub_channels); 180 | } 181 | 182 | m_sub_channels = s; 183 | } 184 | 185 | 186 | void AudioSubTrack::render() 187 | { 188 | SoxWrapper* sox = SoxWrapperFactory::getInstance(); 189 | 190 | if (m_num_sub_channels) 191 | { 192 | for (auto i = 0; i < m_num_sub_channels; ++i) 193 | { 194 | AudioSubChannel* p = &dynamic_cast(m_sub_channels)[i]; 195 | if (p->inFile().empty()) 196 | p->inFile() = inFile(); 197 | 198 | // Read existing loop point from PCM inputs if one isn't explicitly specified 199 | if (p->inFile().substr(p->inFile().length() - 4).compare(WSTR_L(".pcm")) == 0 && p->loop() == 0) 200 | { 201 | #ifdef WIN32 202 | std::ifstream infile(utf8_to_wstring.to_bytes(p->inFile()).c_str(), std::ios::in | std::ios::binary); 203 | #else 204 | std::ifstream infile(p->inFile().c_str(), std::ios::in | std::ios::binary); 205 | #endif 206 | if (infile.is_open()) 207 | { 208 | char signature[4]; 209 | infile.read(signature, 4); // Verify file signature 210 | if (strncmp(signature, "MSU1", 4) == 0) 211 | { 212 | infile.read((char*)&p->loop(), sizeof(p->loop())); 213 | } 214 | } 215 | infile.close(); 216 | } 217 | 218 | size_t loop = p->loop(); 219 | if(p->trimStart() > p->loop()) 220 | p->loop() = p->trimStart(); 221 | 222 | if (m_loop && !p->loop()) 223 | p->loop() = m_loop + p->trimStart(); 224 | 225 | #ifdef WIN32 226 | p->outFile() = m_outfile.substr(0, m_outfile.find_last_of(WSTR_L("."))).append(WSTR_L("_sch")).append(std::to_wstring(i)).append(WSTR_L(".wav")); 227 | #else 228 | p->outFile() = m_outfile.substr(0, m_outfile.find_last_of(WSTR_L("."))).append(WSTR_L("_sch")).append(std::to_string(i)).append(WSTR_L(".wav")); 229 | #endif 230 | p->render(); 231 | if (!m_loop) 232 | { 233 | if (loop) 234 | { 235 | m_loop = ((loop - p->trimStart() + p->padStart()) * 44100.0 / sox->inputRate() / sox->tempo()); 236 | } 237 | } 238 | } 239 | 240 | if (sox->init(dynamic_cast(m_sub_channels)[0].outFile(), m_outfile)) 241 | { 242 | if (m_loop && m_trim_start > m_loop) 243 | { 244 | m_start_offset = m_trim_start - m_loop; 245 | m_trim_start = m_loop; 246 | } 247 | 248 | for (auto i = 1; i < m_num_sub_channels; ++i) 249 | { 250 | sox->addInput(dynamic_cast(m_sub_channels)[i].outFile()); 251 | } 252 | sox->combine(sox_mix); 253 | if (m_compression) 254 | sox->compress(); 255 | if (sox->crossFade(m_loop, m_trim_end, m_cross_fade)) 256 | m_trim_end = 0; 257 | sox->trim(m_trim_start, m_trim_end); 258 | sox->normalize(m_normalization); 259 | sox->fade(m_fade_in, m_fade_out); 260 | sox->tempo(m_tempo); 261 | sox->loop(m_trim_start + m_start_offset, m_loop); 262 | sox->pad(m_pad_start, m_pad_end); 263 | sox->dither(m_dither_type); 264 | sox->finalize(); 265 | } 266 | 267 | if (!config.keep_temps()) 268 | { 269 | for (auto i = 0; i < m_num_sub_channels; ++i) 270 | { 271 | #ifdef WIN32 272 | remove(utf8_to_wstring.to_bytes(dynamic_cast(m_sub_channels)[i].outFile()).c_str()); 273 | #else 274 | remove(dynamic_cast(m_sub_channels)[i].outFile().c_str()); 275 | #endif 276 | } 277 | } 278 | } 279 | else 280 | { 281 | AudioBase::render(); 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /msupcm++/AudioSubTrack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AudioBase.h" 3 | #include "AudioSubChannel.h" 4 | 5 | /** 6 | * An AudioSubTrack is a type of AudioBase which will be concatenated with 7 | * other AudioSubTracks to form the final track. AudioSubTracks may contain 8 | * 0 or more AudioChannels. 9 | */ 10 | 11 | namespace msu 12 | { 13 | class AudioSubTrack : public virtual AudioBase 14 | { 15 | public: 16 | AudioSubTrack(); 17 | AudioSubTrack(std::fstring_t in); 18 | AudioSubTrack(std::fstring_t in, std::fstring_t out); 19 | AudioSubTrack(int argc, char** argv); 20 | AudioSubTrack(const AudioSubTrack& a); 21 | ~AudioSubTrack(); 22 | 23 | AudioSubTrack& operator=(const AudioSubTrack& a); 24 | AudioSubTrack& operator=(const AudioBase& a); 25 | 26 | virtual void clear() override; 27 | 28 | virtual void render() override; 29 | 30 | AudioBase* subChannels() const; 31 | int numSubChannels() const; 32 | 33 | void addSubChannel(AudioBase* a); 34 | 35 | protected: 36 | AudioBase* m_sub_channels; 37 | int m_num_sub_channels; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /msupcm++/AudioTrack.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioTrack.h" 2 | #include "GlobalConfig.h" 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace msu; 8 | 9 | AudioTrack::AudioTrack(): AudioBase() 10 | { 11 | m_track_number = 0; 12 | m_title.clear(); 13 | } 14 | 15 | 16 | AudioTrack::AudioTrack(std::fstring_t in): AudioBase(in) 17 | { 18 | m_track_number = 0; 19 | m_title.clear(); 20 | } 21 | 22 | 23 | AudioTrack::AudioTrack(std::fstring_t in, std::fstring_t out): AudioBase(in, out) 24 | { 25 | m_track_number = 0; 26 | m_title.clear(); 27 | } 28 | 29 | 30 | AudioTrack::AudioTrack(int argc, char** argv) : AudioBase() 31 | { 32 | m_track_number = 0; 33 | m_title.clear(); 34 | 35 | for (int i = 0; i < argc; ++i) 36 | { 37 | if (argv[i][0] == '[') 38 | { 39 | *this = AudioSubChannel(argc, argv); 40 | return; 41 | } 42 | 43 | else if (argv[i][0] == '(') 44 | { 45 | *this = AudioSubTrack(argc, argv); 46 | return; 47 | } 48 | } 49 | 50 | *this = AudioBase(argc, argv); 51 | } 52 | 53 | 54 | AudioTrack::AudioTrack(const AudioTrack& a) 55 | { 56 | m_track_number = 0; 57 | m_title.clear(); 58 | *this = a; 59 | } 60 | 61 | 62 | AudioTrack::~AudioTrack() 63 | { 64 | 65 | } 66 | 67 | 68 | AudioTrack& AudioTrack::operator=(const AudioTrack& a) 69 | { 70 | clear(); 71 | if (a.m_num_sub_channels) 72 | { 73 | AudioSubTrack::operator=(a); 74 | } 75 | else if (a.m_num_sub_tracks) 76 | { 77 | AudioSubChannel::operator=(a); 78 | } 79 | else 80 | { 81 | AudioBase::operator=(a); 82 | } 83 | 84 | 85 | m_track_number = a.m_track_number; 86 | m_title = a.m_title; 87 | 88 | return *this; 89 | } 90 | 91 | 92 | AudioTrack& AudioTrack::operator=(const AudioSubChannel& a) 93 | { 94 | clear(); 95 | AudioSubChannel::operator=(a); 96 | 97 | return *this; 98 | } 99 | 100 | 101 | AudioTrack& AudioTrack::operator=(const AudioSubTrack& a) 102 | { 103 | clear(); 104 | AudioSubTrack::operator=(a); 105 | 106 | return *this; 107 | } 108 | 109 | 110 | AudioTrack& AudioTrack::operator=(const AudioBase& a) 111 | { 112 | AudioBase::clear(); 113 | AudioBase::operator=(a); 114 | 115 | return *this; 116 | } 117 | 118 | 119 | void AudioTrack::clear() 120 | { 121 | AudioSubChannel::clear(); 122 | AudioSubTrack::clear(); 123 | 124 | m_track_number = 0; 125 | m_title.clear(); 126 | } 127 | 128 | 129 | void AudioTrack::render() 130 | { 131 | if (config.verbosity() > 0 && (!inFile().empty() || m_num_sub_channels > 0 || m_num_sub_tracks > 0)) 132 | { 133 | std::wcout << L"Track " << m_track_number; 134 | 135 | if (!m_title.empty()) 136 | std::wcout << L": " << m_title; 137 | 138 | std::wcout << std::endl; 139 | } 140 | 141 | if (config.dither()) 142 | m_dither_type = 's'; 143 | 144 | assert(m_num_sub_tracks == 0 || m_num_sub_channels == 0); 145 | if (m_num_sub_tracks) 146 | { 147 | AudioSubChannel::render(); 148 | } 149 | else if (m_num_sub_channels) 150 | { 151 | AudioSubTrack::render(); 152 | } 153 | else 154 | { 155 | AudioBase::render(); 156 | } 157 | } 158 | 159 | 160 | int AudioTrack::trackNumber() const 161 | { 162 | return m_track_number; 163 | } 164 | 165 | 166 | int& AudioTrack::trackNumber() 167 | { 168 | return m_track_number; 169 | } 170 | 171 | 172 | const std::wstring& AudioTrack::title() const 173 | { 174 | return m_title; 175 | } 176 | 177 | 178 | std::wstring& AudioTrack::title() 179 | { 180 | return m_title; 181 | } 182 | -------------------------------------------------------------------------------- /msupcm++/AudioTrack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AudioBase.h" 3 | #include "AudioSubChannel.h" 4 | #include "AudioSubTrack.h" 5 | 6 | /** 7 | * An AudioTrack is the main AudioBase type. Each output track corresponds 8 | * to a single AudioTrack obsject. An AudioTrack may contain one or more 9 | * AudioChannels or AudioSubTracks, but it should not directly contain both, 10 | * however either one is fully nestable. 11 | */ 12 | 13 | namespace msu 14 | { 15 | class AudioTrack : public AudioSubChannel, public AudioSubTrack 16 | { 17 | public: 18 | AudioTrack(); 19 | AudioTrack(std::fstring_t in); 20 | AudioTrack(std::fstring_t in, std::fstring_t out); 21 | AudioTrack(int argc, char** argv); 22 | AudioTrack(const AudioTrack& a); 23 | ~AudioTrack(); 24 | 25 | AudioTrack& operator=(const AudioTrack& a); 26 | AudioTrack& operator=(const AudioSubChannel& a); 27 | AudioTrack& operator=(const AudioSubTrack& a); 28 | AudioTrack& operator=(const AudioBase& a); 29 | 30 | virtual void clear(); 31 | 32 | virtual void render() final; 33 | 34 | int trackNumber() const; 35 | int& trackNumber(); 36 | 37 | const std::wstring& title() const; 38 | std::wstring& title(); 39 | 40 | protected: 41 | int m_track_number; 42 | std::wstring m_title; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /msupcm++/AudioTrackList.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioTrackList.h" 2 | #include "GlobalConfig.h" 3 | #include 4 | 5 | using namespace msu; 6 | 7 | AudioTrackList::AudioTrackList() 8 | { 9 | 10 | } 11 | 12 | 13 | AudioTrackList::~AudioTrackList() 14 | { 15 | 16 | } 17 | 18 | 19 | void AudioTrackList::render() 20 | { 21 | if (config.verbosity() > 0) 22 | { 23 | std::wcout << L"MSU-1 Audio Conversion Tool" << std::endl; 24 | 25 | if (!config.game().empty()) 26 | std::wcout << L"Game: " << config.game() << std::endl; 27 | 28 | if (!config.pack().empty()) 29 | std::wcout << L"Pack: " << config.pack() << std::endl; 30 | 31 | if (!config.artist().empty()) 32 | std::wcout << L"Artist: " << config.artist() << std::endl; 33 | 34 | if (!config.url().empty()) 35 | std::wcout << config.url() << std::endl; 36 | 37 | std::wcout << std::endl; 38 | } 39 | 40 | for (AudioTrack track : m_tracks) 41 | { 42 | if ((track.trackNumber() >= config.first_track()) && 43 | (config.last_track() < 0 || track.trackNumber() <= config.last_track())) 44 | { 45 | track.render(); 46 | } 47 | } 48 | } 49 | 50 | 51 | const std::vector& AudioTrackList::tracks() const 52 | { 53 | return m_tracks; 54 | } 55 | 56 | 57 | std::vector& AudioTrackList::tracks() 58 | { 59 | return m_tracks; 60 | } 61 | -------------------------------------------------------------------------------- /msupcm++/AudioTrackList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AudioTrack.h" 3 | #include "GlobalConfig.h" 4 | #include 5 | #include 6 | 7 | namespace msu 8 | { 9 | class AudioTrackList 10 | { 11 | public: 12 | AudioTrackList(); 13 | ~AudioTrackList(); 14 | 15 | void render(); 16 | 17 | const std::vector& tracks() const; 18 | std::vector& tracks(); 19 | 20 | private: 21 | std::vector m_tracks; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /msupcm++/AudioTrackListBuilder.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioTrackListBuilder.h" 2 | #include "GlobalConfig.h" 3 | #include "TrackParser.hpp" 4 | #include "utf8.h" 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace msu; 10 | 11 | AudioTrackListBuilder::AudioTrackListBuilder(std::wstring config) 12 | { 13 | std::ifstream ifs(utf8_to_wstring.to_bytes(config).c_str()); 14 | if (ifs.is_open()) 15 | { 16 | json j; 17 | try 18 | { 19 | ifs >> j; 20 | } 21 | catch (const std::exception& e) 22 | { 23 | std::wcout << e.what() << std::endl; 24 | exit(1); 25 | } 26 | 27 | m_list = j; 28 | } 29 | } 30 | 31 | 32 | const AudioTrackList& AudioTrackListBuilder::get() const 33 | { 34 | return m_list; 35 | } 36 | 37 | 38 | AudioTrackList& AudioTrackListBuilder::get() 39 | { 40 | return m_list; 41 | } 42 | -------------------------------------------------------------------------------- /msupcm++/AudioTrackListBuilder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AudioTrackList.h" 3 | #include 4 | 5 | namespace msu 6 | { 7 | class AudioTrackListBuilder 8 | { 9 | public: 10 | AudioTrackListBuilder(std::wstring config = L"tracks.json"); 11 | 12 | const AudioTrackList& get() const; 13 | AudioTrackList& get(); 14 | 15 | private: 16 | AudioTrackList m_list; 17 | }; 18 | } -------------------------------------------------------------------------------- /msupcm++/GlobalConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "GlobalConfig.h" 2 | 3 | using namespace msu; 4 | 5 | #ifdef WIN32 6 | #define CONCAT(x, y) x##y 7 | #define WSTR_L(x) CONCAT(L, x) 8 | #else 9 | #define WSTR_L(x) x 10 | #endif 11 | 12 | std::wstring GlobalConfig::m_game = L""; 13 | std::wstring GlobalConfig::m_pack = L""; 14 | std::wstring GlobalConfig::m_artist = L""; 15 | std::wstring GlobalConfig::m_url = L""; 16 | std::fstring_t GlobalConfig::m_output_prefix = WSTR_L(""); 17 | double GlobalConfig::m_normalization = 0.0; 18 | bool GlobalConfig::m_dither = true; 19 | unsigned int GlobalConfig::m_verbosity = 2; 20 | bool GlobalConfig::m_keep_temps = false; 21 | int GlobalConfig::m_first_track = -1; 22 | int GlobalConfig::m_last_track = -1; 23 | 24 | std::wstring& GlobalConfig::game() 25 | { 26 | return m_game; 27 | } 28 | 29 | 30 | std::wstring& GlobalConfig::pack() 31 | { 32 | return m_pack; 33 | } 34 | 35 | 36 | std::wstring& GlobalConfig::artist() 37 | { 38 | return m_artist; 39 | } 40 | 41 | 42 | std::wstring& GlobalConfig::url() 43 | { 44 | return m_url; 45 | } 46 | 47 | 48 | std::fstring_t& GlobalConfig::output_prefix() 49 | { 50 | return m_output_prefix; 51 | } 52 | 53 | 54 | double& GlobalConfig::normalization() 55 | { 56 | return m_normalization; 57 | } 58 | 59 | 60 | bool& GlobalConfig::dither() 61 | { 62 | return m_dither; 63 | } 64 | 65 | 66 | unsigned int& GlobalConfig::verbosity() 67 | { 68 | return m_verbosity; 69 | } 70 | 71 | 72 | bool& GlobalConfig::keep_temps() 73 | { 74 | return m_keep_temps; 75 | } 76 | 77 | 78 | int& GlobalConfig::first_track() 79 | { 80 | return m_first_track; 81 | } 82 | 83 | 84 | 85 | int& GlobalConfig::last_track() 86 | { 87 | return m_last_track; 88 | } 89 | -------------------------------------------------------------------------------- /msupcm++/GlobalConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef WIN32 5 | #define fstring_t wstring 6 | #else 7 | #define fstring_t string 8 | #endif 9 | 10 | namespace msu 11 | { 12 | static class GlobalConfig 13 | { 14 | public: 15 | static std::wstring& game(); 16 | static std::wstring& pack(); 17 | static std::wstring& artist(); 18 | static std::wstring& url(); 19 | static std::fstring_t& output_prefix(); 20 | static double& normalization(); 21 | static bool& dither(); 22 | static unsigned int& verbosity(); 23 | static bool& keep_temps(); 24 | static int& first_track(); 25 | static int& last_track(); 26 | 27 | private: 28 | static std::wstring m_game; 29 | static std::wstring m_pack; 30 | static std::wstring m_artist; 31 | static std::wstring m_url; 32 | static std::fstring_t m_output_prefix; 33 | static double m_normalization; 34 | static bool m_dither; 35 | static unsigned int m_verbosity; 36 | static bool m_keep_temps; 37 | static int m_first_track; 38 | static int m_last_track; 39 | } config; 40 | } 41 | -------------------------------------------------------------------------------- /msupcm++/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CCFLAGS = 3 | 4 | CXX = g++ 5 | CXXFLAGS = -std=gnu++11 6 | 7 | LD = g++ 8 | 9 | INC = -I ../3rdparty/json/src -I ../3rdparty/sox/src 10 | LIBS = ../3rdparty/sox/src/.libs/libsox.a 11 | 12 | TARGET = msupcm 13 | 14 | SOURCES := $(wildcard *.cpp) sox_main.c 15 | OBJECTS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES))) 16 | LIBS += -lsndio -lsndfile -lao -lasound -lgomp -lltdl -lmad -lmp3lame -lpulse-simple -lpulse -lvorbis -lvorbisenc -lvorbisfile -logg -lopus -lopusfile -lFLAC -lz 17 | 18 | .PHONY: all 19 | 20 | all: $(TARGET) 21 | 22 | FORCE: 23 | 24 | clean: FORCE 25 | rm -f *.o $(TARGET) 26 | 27 | .c.o: 28 | $(CC) $(CCFLAGS) $(INC) -c $? -o $@ 29 | 30 | .cpp.o: 31 | $(CXX) $(CXXFLAGS) $(INC) -c $? -o $@ 32 | 33 | $(TARGET): $(OBJECTS) 34 | $(LD) -o $(TARGET) $(OBJECTS) $(LIBS) 35 | -------------------------------------------------------------------------------- /msupcm++/SoxWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sox_main.h" 3 | #include 4 | #include 5 | 6 | #ifdef WIN32 7 | #define fstring_t wstring 8 | #else 9 | #define fstring_t string 10 | #endif 11 | 12 | namespace msu 13 | { 14 | class SoxWrapper 15 | { 16 | public: 17 | SoxWrapper(); 18 | ~SoxWrapper(); 19 | 20 | bool init(std::fstring_t in, std::fstring_t out); 21 | bool addInput(std::fstring_t name); 22 | bool combine(sox_combine_method method); 23 | bool trim(size_t start, size_t end = 0); 24 | bool fade(size_t in, size_t out = 0, char type = 't'); 25 | bool pad(size_t start, size_t end = 0); 26 | bool tempo(double tempo); 27 | bool loop(size_t start, size_t loop); 28 | bool crossFade(size_t loop, size_t end, size_t length, double ratio = 0.5); 29 | bool normalize(double level); 30 | bool compress(); 31 | bool dither(char type = 's'); 32 | bool finalize(); 33 | bool clear(); 34 | 35 | double tempo(); 36 | size_t length(); 37 | sox_rate_t inputRate(); 38 | 39 | private: 40 | bool addOutput(std::fstring_t name); 41 | bool addEffect(std::string name, int argc, char** argv); 42 | std::fstring_t getTempFile(std::fstring_t ext); 43 | 44 | bool m_initialized; 45 | bool m_finalized; 46 | int m_temp_counter; 47 | double m_tempo; 48 | size_t m_loop; 49 | size_t m_length; 50 | sox_rate_t m_input_rate; 51 | 52 | std::fstring_t m_output; 53 | }; 54 | 55 | class SoxWrapperFactory 56 | { 57 | public: 58 | ~SoxWrapperFactory() { delete m_instance; } 59 | static SoxWrapper* getInstance() 60 | { 61 | if (!m_instance) 62 | m_instance = new SoxWrapper(); 63 | 64 | return m_instance; 65 | } 66 | 67 | private: 68 | SoxWrapperFactory(); 69 | static SoxWrapper *m_instance; 70 | }; 71 | } -------------------------------------------------------------------------------- /msupcm++/TrackParser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "json.hpp" 3 | #include "utf8.h" 4 | #include "AudioTrackList.h" 5 | #include "GlobalConfig.h" 6 | #include 7 | #include 8 | #include 9 | 10 | using nlohmann::json; 11 | 12 | namespace msu { 13 | 14 | void to_json(json& j, const AudioBase& a) 15 | { 16 | j = json{ 17 | { "file", a.inFile() }, 18 | { "output", a.outFile() }, 19 | { "trim_start", a.trimStart() }, 20 | { "trim_end", a.trimEnd() }, 21 | { "loop", a.loop() }, 22 | { "fade_in", a.fadeIn() }, 23 | { "fade_out", a.fadeIn() }, 24 | { "cross_fade", a.fadeIn() }, 25 | { "pad_start", a.padStart() }, 26 | { "pad_end", a.padEnd() }, 27 | { "tempo", a.tempo() }, 28 | { "normalization", a.normalization() }, 29 | { "compression", a.compression() } 30 | }; 31 | } 32 | 33 | 34 | void to_json(json& j, const AudioSubChannel& a) 35 | { 36 | to_json(j, (const AudioBase&)(a)); 37 | 38 | for (auto i = 0; i < a.numSubTracks(); ++i) 39 | { 40 | json subtrack; 41 | to_json(subtrack, a.subTracks()[i]); 42 | 43 | j["sub_tracks"].push_back(subtrack); 44 | } 45 | } 46 | 47 | 48 | void to_json(json &j, const AudioSubTrack& a) 49 | { 50 | to_json(j, (const AudioBase&)(a)); 51 | 52 | for (auto i = 0; i < a.numSubChannels(); ++i) 53 | { 54 | json channel; 55 | to_json(channel, a.subChannels()[i]); 56 | 57 | j["sub_channels"].push_back(channel); 58 | } 59 | } 60 | 61 | 62 | void to_json(json &j, const AudioTrack& a) 63 | { 64 | if (a.numSubChannels() > 0) 65 | { 66 | to_json(j, (const AudioSubTrack&)(a)); 67 | } 68 | else if (a.numSubTracks() > 0) 69 | { 70 | to_json(j, (const AudioSubChannel&)(a)); 71 | } 72 | else 73 | { 74 | to_json(j, (const AudioBase&)(a)); 75 | } 76 | 77 | j["track_number"] = a.trackNumber(); 78 | j["title"] = a.title(); 79 | } 80 | 81 | 82 | void to_json(json &j, const AudioTrackList& a) 83 | { 84 | j = json{ 85 | { "game", config.game() }, 86 | { "pack", config.pack() }, 87 | { "artist", config.artist() }, 88 | { "url", config.url() }, 89 | { "output_prefix", config.output_prefix() }, 90 | { "normalization", config.normalization() }, 91 | { "dither", config.dither() }, 92 | { "verbosity", config.verbosity() }, 93 | { "keep_temps", config.keep_temps() }, 94 | { "first_track", config.first_track() }, 95 | { "last_track", config.last_track() } 96 | }; 97 | 98 | for (auto i = a.tracks().begin(); i != a.tracks().end(); ++i) 99 | { 100 | json track; 101 | to_json(track, *i); 102 | j["tracks"].push_back(track); 103 | } 104 | } 105 | 106 | 107 | void from_json(const json& j, AudioBase& a) 108 | { 109 | if (j.find("file") != j.end()) 110 | #ifdef WIN32 111 | a.inFile() = utf8_to_wstring.from_bytes(j["file"].get().c_str()); 112 | #else 113 | a.inFile() = j["file"].get(); 114 | #endif 115 | 116 | if (j.find("output") != j.end()) 117 | #ifdef WIN32 118 | a.outFile() = utf8_to_wstring.from_bytes(j["output"].get().c_str()); 119 | #else 120 | a.outFile() = j["output"].get(); 121 | #endif 122 | 123 | if (j.find("trim_start") != j.end()) 124 | a.trimStart() = j["trim_start"].get(); 125 | 126 | if (j.find("trim_end") != j.end()) 127 | a.trimEnd() = j["trim_end"].get(); 128 | 129 | if (j.find("loop") != j.end()) 130 | a.loop() = j["loop"].get(); 131 | 132 | if (j.find("fade_in") != j.end()) 133 | a.fadeIn() = j["fade_in"].get(); 134 | 135 | if (j.find("fade_out") != j.end()) 136 | a.fadeOut() = j["fade_out"].get(); 137 | 138 | if (j.find("cross_fade") != j.end()) 139 | a.crossFade() = j["cross_fade"].get(); 140 | 141 | if (j.find("pad_start") != j.end()) 142 | a.padStart() = j["pad_start"].get(); 143 | 144 | if (j.find("pad_end") != j.end()) 145 | a.padEnd() = j["pad_end"].get(); 146 | 147 | if (j.find("tempo") != j.end()) 148 | a.tempo() = j["tempo"].get(); 149 | 150 | if (j.find("normalization") != j.end()) 151 | a.normalization() = j["normalization"].get(); 152 | 153 | if (j.find("compression") != j.end()) 154 | a.compression() = j["compression"].get(); 155 | } 156 | 157 | 158 | class Option { 159 | public: 160 | Option() {} 161 | const int& option() const { return m_option; } 162 | int& option() { return m_option; } 163 | 164 | private: 165 | int m_option; 166 | }; 167 | 168 | 169 | void from_json(const json& j, Option& o) 170 | { 171 | if (j.find("option") != j.end()) 172 | o.option() = j["option"].get(); 173 | } 174 | 175 | 176 | void from_json(const json& j, AudioSubChannel& a) 177 | { 178 | from_json(j, (AudioBase&)(a)); 179 | 180 | if (j.find("sub_tracks") != j.end()) 181 | { 182 | for (auto i = j["sub_tracks"].begin(); i != j["sub_tracks"].end(); ++i) 183 | { 184 | AudioSubTrack s = *i; 185 | 186 | if (s.inFile().empty()) 187 | s.inFile() = a.inFile(); 188 | 189 | a.addSubTrack(&s); 190 | } 191 | } 192 | 193 | if (j.find("use_option") != j.end() && j.find("options") != j.end()) 194 | { 195 | int opt = j["use_option"].get(); 196 | 197 | for (auto i = j["options"].begin(); i != j["options"].end(); ++i) 198 | { 199 | if (Option(*i).option() == opt) 200 | { 201 | from_json(*i, a); 202 | break; 203 | } 204 | } 205 | } 206 | } 207 | 208 | 209 | void from_json(const json& j, AudioSubTrack& a) 210 | { 211 | from_json(j, (AudioBase&)(a)); 212 | 213 | if (j.find("sub_channels") != j.end()) 214 | { 215 | for (auto i = j["sub_channels"].begin(); i != j["sub_channels"].end(); ++i) 216 | { 217 | AudioSubChannel s = *i; 218 | 219 | if (s.inFile().empty()) 220 | s.inFile() = a.inFile(); 221 | 222 | a.addSubChannel(&s); 223 | } 224 | } 225 | 226 | if (j.find("use_option") != j.end() && j.find("options") != j.end()) 227 | { 228 | int opt = j["use_option"].get(); 229 | 230 | for (auto i = j["options"].begin(); i != j["options"].end(); ++i) 231 | { 232 | if (Option(*i).option() == opt) 233 | { 234 | from_json(*i, a); 235 | break; 236 | } 237 | } 238 | } 239 | } 240 | 241 | 242 | void from_json(const json& j, AudioTrack& a) 243 | { 244 | if (j.find("sub_channels") != j.end()) 245 | { 246 | from_json(j, (AudioSubTrack&)(a)); 247 | } 248 | else if (j.find("sub_tracks") != j.end()) 249 | { 250 | from_json(j, (AudioSubChannel&)(a)); 251 | } 252 | else 253 | { 254 | from_json(j, (AudioBase&)(a)); 255 | } 256 | 257 | if (j.find("track_number") != j.end()) 258 | a.trackNumber() = j["track_number"].get(); 259 | 260 | if (j.find("title") != j.end()) 261 | a.title() = utf8_to_wstring.from_bytes(j["title"].get().c_str()); 262 | 263 | if (a.outFile().empty()) 264 | #ifdef WIN32 265 | a.outFile() = config.output_prefix() + L"-" + std::to_wstring(a.trackNumber()) + L".pcm"; 266 | #else 267 | a.outFile() = config.output_prefix() + "-" + std::to_string(a.trackNumber()) + ".pcm"; 268 | #endif 269 | 270 | if (a.normalization() == 0.0) 271 | a.normalization() = config.normalization(); 272 | 273 | if (j.find("use_option") != j.end() && j.find("options") != j.end()) 274 | { 275 | int opt = j["use_option"].get(); 276 | 277 | for (auto i = j["options"].begin(); i != j["options"].end(); ++i) 278 | { 279 | if (Option(*i).option() == opt) 280 | { 281 | from_json(*i, a); 282 | break; 283 | } 284 | } 285 | } 286 | } 287 | 288 | 289 | void from_json(const json& j, AudioTrackList& a) 290 | { 291 | if (j.find("game") != j.end()) 292 | config.game() = utf8_to_wstring.from_bytes(j["game"].get().c_str()); 293 | 294 | if (j.find("pack") != j.end()) 295 | config.pack() = utf8_to_wstring.from_bytes(j["pack"].get().c_str()); 296 | 297 | if (j.find("artist") != j.end()) 298 | config.artist() = utf8_to_wstring.from_bytes(j["artist"].get().c_str()); 299 | 300 | if (j.find("url") != j.end()) 301 | config.url() = utf8_to_wstring.from_bytes(j["url"].get().c_str()); 302 | 303 | if (j.find("output_prefix") != j.end()) 304 | { 305 | #ifdef WIN32 306 | config.output_prefix() = utf8_to_wstring.from_bytes(j["output_prefix"].get().c_str()); 307 | #else 308 | config.output_prefix() = j["output_prefix"].get(); 309 | #endif 310 | } 311 | else 312 | { 313 | #ifdef WIN32 314 | config.output_prefix() = L"track"; 315 | #else 316 | config.output_prefix() = "track"; 317 | #endif 318 | } 319 | 320 | if (j.find("normalization") != j.end()) 321 | config.normalization() = j["normalization"].get(); 322 | 323 | if (j.find("dither") != j.end()) 324 | config.dither() = j["dither"].get(); 325 | 326 | if (j.find("verbosity") != j.end()) 327 | config.verbosity() = j["verbosity"].get(); 328 | 329 | if (j.find("keep_temps") != j.end()) 330 | config.keep_temps() = j["keep_temps"].get(); 331 | 332 | if (j.find("first_track") != j.end()) 333 | config.first_track() = j["first_track"].get(); 334 | 335 | if (j.find("last_track") != j.end()) 336 | config.last_track() = j["last_track"].get(); 337 | 338 | if (j.find("tracks") != j.end()) 339 | { 340 | for (auto i = j["tracks"].begin(); i != j["tracks"].end(); ++i) 341 | { 342 | a.tracks().push_back(*i); 343 | } 344 | } 345 | } 346 | } 347 | -------------------------------------------------------------------------------- /msupcm++/getopt.h: -------------------------------------------------------------------------------- 1 | /* Getopt for Microsoft C 2 | This code is a modification of the Free Software Foundation, Inc. 3 | Getopt library for parsing command line argument the purpose was 4 | to provide a Microsoft Visual C friendly derivative. This code 5 | provides functionality for both Unicode and Multibyte builds. 6 | 7 | Date: 02/03/2011 - Ludvik Jerabek - Initial Release 8 | Version: 1.0 9 | Comment: Supports getopt, getopt_long, and getopt_long_only 10 | and POSIXLY_CORRECT environment flag 11 | License: LGPL 12 | 13 | Revisions: 14 | 15 | 02/03/2011 - Ludvik Jerabek - Initial Release 16 | 02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4 17 | 07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs 18 | 08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception 19 | 08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB 20 | 02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file 21 | 08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi 22 | 10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features 23 | 06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable 24 | 25 | **DISCLAIMER** 26 | THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 27 | EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 29 | PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE 30 | EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT 31 | APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY 32 | DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY 33 | USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST 34 | PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON 35 | YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE 36 | EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 37 | */ 38 | #ifndef __GETOPT_H_ 39 | #define __GETOPT_H_ 40 | 41 | #ifdef _GETOPT_API 42 | #undef _GETOPT_API 43 | #endif 44 | 45 | #if defined(EXPORTS_GETOPT) && defined(STATIC_GETOPT) 46 | #error "The preprocessor definitions of EXPORTS_GETOPT and STATIC_GETOPT can only be used individually" 47 | #elif defined(STATIC_GETOPT) 48 | #pragma message("Warning static builds of getopt violate the Lesser GNU Public License") 49 | #define _GETOPT_API 50 | #elif defined(EXPORTS_GETOPT) 51 | #pragma message("Exporting getopt library") 52 | #define _GETOPT_API __declspec(dllexport) 53 | #else 54 | #pragma message("Importing getopt library") 55 | #define _GETOPT_API __declspec(dllimport) 56 | #endif 57 | 58 | // Change behavior for C\C++ 59 | #ifdef __cplusplus 60 | #define _BEGIN_EXTERN_C extern "C" { 61 | #define _END_EXTERN_C } 62 | #define _GETOPT_THROW throw() 63 | #else 64 | #define _BEGIN_EXTERN_C 65 | #define _END_EXTERN_C 66 | #define _GETOPT_THROW 67 | #endif 68 | 69 | // Standard GNU options 70 | #define null_argument 0 /*Argument Null*/ 71 | #define no_argument 0 /*Argument Switch Only*/ 72 | #define required_argument 1 /*Argument Required*/ 73 | #define optional_argument 2 /*Argument Optional*/ 74 | 75 | // Shorter Options 76 | #define ARG_NULL 0 /*Argument Null*/ 77 | #define ARG_NONE 0 /*Argument Switch Only*/ 78 | #define ARG_REQ 1 /*Argument Required*/ 79 | #define ARG_OPT 2 /*Argument Optional*/ 80 | 81 | #include 82 | #include 83 | 84 | _BEGIN_EXTERN_C 85 | 86 | extern _GETOPT_API int optind; 87 | extern _GETOPT_API int opterr; 88 | extern _GETOPT_API int optopt; 89 | 90 | // Ansi 91 | struct option_a 92 | { 93 | const char* name; 94 | int has_arg; 95 | int *flag; 96 | int val; 97 | }; 98 | extern _GETOPT_API char *optarg_a; 99 | extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW; 100 | extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; 101 | extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; 102 | 103 | // Unicode 104 | struct option_w 105 | { 106 | const wchar_t* name; 107 | int has_arg; 108 | int *flag; 109 | int val; 110 | }; 111 | extern _GETOPT_API wchar_t *optarg_w; 112 | extern _GETOPT_API int getopt_w(int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW; 113 | extern _GETOPT_API int getopt_long_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; 114 | extern _GETOPT_API int getopt_long_only_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; 115 | 116 | _END_EXTERN_C 117 | 118 | #undef _BEGIN_EXTERN_C 119 | #undef _END_EXTERN_C 120 | #undef _GETOPT_THROW 121 | #undef _GETOPT_API 122 | 123 | #ifdef _UNICODE 124 | #define getopt getopt_w 125 | #define getopt_long getopt_long_w 126 | #define getopt_long_only getopt_long_only_w 127 | #define option option_w 128 | #define optarg optarg_w 129 | #else 130 | #define getopt getopt_a 131 | #define getopt_long getopt_long_a 132 | #define getopt_long_only getopt_long_only_a 133 | #define option option_a 134 | #define optarg optarg_a 135 | #endif 136 | #endif // __GETOPT_H_ 137 | -------------------------------------------------------------------------------- /msupcm++/msupcm++.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {7A51C6A5-6FDC-4293-97A1-57A53E1BFE36} 15 | Win32Proj 16 | msupcm 17 | 10.0.17134.0 18 | 19 | 20 | 21 | Application 22 | true 23 | v141 24 | Unicode 25 | 26 | 27 | Application 28 | false 29 | v141 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | msupcm 48 | 49 | 50 | false 51 | msupcm 52 | 53 | 54 | 55 | 56 | 57 | Level3 58 | Disabled 59 | WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 60 | MultiThreadedDebug 61 | ..\3rdparty\json\src;..\3rdparty\sox\src;..\3rdparty\sox\msvc14\SoX;%(AdditionalIncludeDirectories) 62 | Fast 63 | 64 | 65 | Console 66 | true 67 | winmm.lib;%(AdditionalDependencies) 68 | 69 | 70 | 71 | 72 | Level3 73 | 74 | 75 | MaxSpeed 76 | true 77 | true 78 | WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 79 | MultiThreaded 80 | ..\3rdparty\json\src;..\3rdparty\sox\src;..\3rdparty\sox\msvc14\SoX;%(AdditionalIncludeDirectories) 81 | Fast 82 | 83 | 84 | Console 85 | true 86 | true 87 | true 88 | winmm.lib;%(AdditionalDependencies) 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | {f17be535-c7e8-4930-a6fd-32498d73a533} 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /msupcm++/msupcm++.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | -------------------------------------------------------------------------------- /msupcm++/msupcm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "AudioTrackListBuilder.h" 6 | #include "sox_main.h" 7 | #include "utf8.h" 8 | 9 | #define VERSION_NUMBER "1.0 RC3" 10 | 11 | using namespace msu; 12 | 13 | void usage() 14 | { 15 | std::wcout << L"msupcm v" << VERSION_NUMBER << std::endl << std::endl; 16 | std::wcout << L"Usage:" << std::endl; 17 | std::wcout << L"msupcm [tracks.json]" << std::endl; 18 | std::wcout << L"msupcm -s [sox args]" << std::endl; 19 | std::wcout << L"msupcm -v" << std::endl; 20 | std::wcout << L"msupcm ?" << std::endl; 21 | } 22 | 23 | int main(int argc, char * argv[]) 24 | { 25 | int wargc; 26 | char** wargv; 27 | int exit_code = 0; 28 | 29 | #ifdef _WIN32 30 | lsx_init_console(); 31 | lsx_init_commandline_arguments(&wargc, &wargv); 32 | #else 33 | wargv = argv; 34 | wargc = argc; 35 | 36 | std::setlocale(LC_ALL, ""); 37 | #endif 38 | 39 | AudioTrackList tracklist; 40 | 41 | switch (argc) 42 | { 43 | case 1: 44 | case 3: 45 | tracklist = AudioTrackListBuilder(L"tracks.json").get(); 46 | if (argc > 2 && std::wstring(utf8_to_wstring.from_bytes(wargv[1])).compare(L"-k") == 0) 47 | { 48 | wchar_t* tok; 49 | wchar_t* wbuf; 50 | std::wstring arg = std::wstring(utf8_to_wstring.from_bytes(wargv[2])); 51 | 52 | tok = wcstok(const_cast(arg.c_str()), L":", &wbuf); 53 | if (tok != L"") 54 | { 55 | config.first_track() = wcstol(tok, nullptr, 10); 56 | 57 | tok = wcstok(nullptr, L":", &wbuf); 58 | if (tok != nullptr && tok != L"") 59 | config.last_track() = wcstol(tok, nullptr, 10); 60 | 61 | else 62 | config.last_track() = config.first_track(); 63 | } 64 | } 65 | tracklist.render(); 66 | break; 67 | 68 | case 2: 69 | case 4: 70 | if (std::wstring(utf8_to_wstring.from_bytes(wargv[argc-1])).compare(L"-v") == 0) 71 | { 72 | std::wcout << L"msupcm v" << VERSION_NUMBER << std::endl; 73 | break; 74 | } 75 | 76 | else if (std::wstring(utf8_to_wstring.from_bytes(wargv[argc-1])).compare(L"?") == 0) 77 | { 78 | usage(); 79 | break; 80 | } 81 | 82 | else if (std::wstring(utf8_to_wstring.from_bytes(wargv[argc-1])).find_last_of(L".") != std::wstring::npos && 83 | std::wstring(utf8_to_wstring.from_bytes(wargv[argc-1])).substr( \ 84 | std::wstring(utf8_to_wstring.from_bytes(wargv[argc-1])).find_last_of(L".")).compare(L".json") == 0) 85 | { 86 | tracklist = AudioTrackListBuilder(utf8_to_wstring.from_bytes(wargv[argc-1])).get(); 87 | if (argc > 2 && std::wstring(utf8_to_wstring.from_bytes(wargv[1])).compare(L"-k") == 0) 88 | { 89 | wchar_t* tok; 90 | wchar_t* wbuf; 91 | std::wstring arg = std::wstring(utf8_to_wstring.from_bytes(wargv[2])); 92 | 93 | tok = wcstok(const_cast(arg.c_str()), L":", &wbuf); 94 | if (tok != L"") 95 | { 96 | config.first_track() = wcstol(tok, nullptr, 10); 97 | 98 | tok = wcstok(nullptr, L":", &wbuf); 99 | if (tok != nullptr && tok != L"") 100 | config.last_track() = wcstol(tok, nullptr, 10); 101 | 102 | else 103 | config.last_track() = config.first_track(); 104 | } 105 | } 106 | 107 | tracklist.render(); 108 | } 109 | 110 | else 111 | { 112 | usage(); 113 | exit_code = 1; 114 | break; 115 | } 116 | 117 | break; 118 | 119 | default: 120 | if (std::string(argv[1]).compare("-s") == 0) 121 | { 122 | #ifdef _WIN32 123 | wargv[1] = utf16_to_utf8(L"sox"); 124 | #else 125 | int len = strlen(utf8_to_wstring.to_bytes(L"sox").c_str()); 126 | wargv[1] = (char*) malloc(len + 1); 127 | strncpy(wargv[1], utf8_to_wstring.to_bytes(L"sox").c_str(), len); 128 | #endif 129 | --wargc; 130 | 131 | exit_code = soxmain(wargc, wargv + 1); 132 | break; 133 | } 134 | 135 | config.verbosity() = 0; 136 | AudioTrack(wargc - 1, wargv + 1).render(); 137 | break; 138 | } 139 | 140 | #ifdef _WIN32 141 | lsx_uninit_console(); 142 | lsx_free_commandline_arguments(&wargc, &wargv); 143 | #endif 144 | 145 | return exit_code; 146 | } 147 | -------------------------------------------------------------------------------- /msupcm++/sox_main.h: -------------------------------------------------------------------------------- 1 | #ifndef SOX_MAIN_H 2 | #define SOX_MAIN_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include "sox.h" 8 | #include "util.h" 9 | #ifndef WIN32 10 | #undef min 11 | #undef max 12 | #endif 13 | #include "unicode_support.h" 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef HAVE_GETTIMEOFDAY 19 | #define TIME_FRAC 1e6 20 | #else 21 | #define timeval timeb 22 | #define gettimeofday(a,b) ftime(a) 23 | #define tv_sec time 24 | #define tv_usec millitm 25 | #define TIME_FRAC 1e3 26 | #endif 27 | 28 | extern lsx_getopt_t optstate; 29 | 30 | /* argv[0] options */ 31 | 32 | extern char const * myname; 33 | typedef enum _sox_mode { sox_sox, sox_play, sox_rec, sox_soxi } _sox_mode; 34 | extern _sox_mode sox_mode; 35 | 36 | 37 | /* gopts */ 38 | 39 | typedef enum sox_combine_method { 40 | sox_sequence, sox_concatenate, sox_mix, sox_mix_power, 41 | sox_merge, sox_multiply, sox_default 42 | } sox_combine_method; 43 | extern sox_combine_method combine_method; 44 | typedef enum { sox_single, sox_multiple } sox_output_method; 45 | extern sox_output_method output_method; 46 | #define is_serial(m) ((m) <= sox_concatenate) 47 | #define is_parallel(m) (!is_serial(m)) 48 | extern sox_bool no_clobber; 49 | extern sox_bool interactive; 50 | extern sox_bool uservolume; 51 | typedef enum { RG_off, RG_track, RG_album, RG_default } rg_mode; 52 | extern lsx_enum_item const rg_modes[]; 53 | extern rg_mode replay_gain_mode; 54 | extern sox_option_t show_progress; 55 | 56 | 57 | /* Input & output files */ 58 | 59 | typedef struct { 60 | char * filename; 61 | 62 | /* fopts */ 63 | char const * filetype; 64 | sox_signalinfo_t signal; 65 | sox_encodinginfo_t encoding; 66 | double volume; 67 | double replay_gain; 68 | sox_oob_t oob; 69 | sox_bool no_glob; 70 | 71 | sox_format_t * ft; /* libSoX file descriptor */ 72 | uint64_t volume_clips; 73 | rg_mode replay_gain_mode; 74 | } file_t; 75 | 76 | extern file_t * * files; /* Array tracking input and output files */ 77 | #define ofile files[file_count - 1] 78 | extern size_t file_count; 79 | extern size_t input_count; 80 | extern size_t output_count; 81 | 82 | /* Effects */ 83 | 84 | /* We parse effects into a temporary effects table and then place into 85 | * the real effects chain. This allows scanning all effects to give 86 | * hints to what input effect options should be as well as determining 87 | * when mixer or resample effects need to be auto-inserted as well. 88 | */ 89 | extern sox_effect_t **user_efftab; 90 | extern size_t user_efftab_size; 91 | extern sox_effects_chain_t *effects_chain; 92 | extern sox_effect_t *save_output_eff; 93 | 94 | typedef struct user_effargs_t { char *name; int argc; char **argv; size_t argv_size; } user_effargs_t; 95 | extern user_effargs_t **user_effargs; 96 | extern size_t *user_effargs_size; /* array: size of user_effargs for each chain */ 97 | /* Size of memory structures related to effects arguments (user_effargs[i], 98 | * user_effargs[i][j].argv) to be extended in steps of EFFARGS_STEP */ 99 | #define EFFARGS_STEP 8 100 | extern size_t *nuser_effects; /* array: number of effects in each chain */ 101 | extern size_t current_eff_chain; 102 | extern size_t eff_chain_count; 103 | extern sox_bool very_first_effchain; 104 | /* Indicates that not only the first effects chain is in effect (hrm), but 105 | also that it has never been restarted. Only then we may use the 106 | optimize_trim() hack. */ 107 | extern char *effects_filename; 108 | extern char * play_rate_arg; 109 | extern char *norm_level; 110 | 111 | /* Flowing */ 112 | 113 | extern sox_signalinfo_t combiner_signal; 114 | extern sox_signalinfo_t ofile_signal_options; 115 | extern sox_encodinginfo_t combiner_encoding; 116 | extern sox_encodinginfo_t ofile_encoding_options; 117 | extern uint64_t mixing_clips; 118 | extern size_t current_input; 119 | extern uint64_t input_wide_samples; 120 | extern uint64_t read_wide_samples; 121 | extern uint64_t output_samples; 122 | extern sox_bool input_eof; 123 | extern sox_bool output_eof; 124 | extern sox_bool user_abort; 125 | extern sox_bool user_skip; 126 | extern sox_bool user_restart_eff; 127 | extern int success; 128 | extern int cleanup_called; 129 | extern sox_sample_t omax[2]; 130 | extern sox_sample_t omin[2]; 131 | 132 | #ifdef HAVE_TERMIOS_H 133 | #include 134 | extern struct termios original_termios; 135 | extern sox_bool original_termios_saved; 136 | #endif 137 | 138 | extern sox_bool stdin_is_a_tty; 139 | extern sox_bool is_player; 140 | extern sox_bool is_guarded; 141 | extern sox_bool do_guarded_norm; 142 | extern sox_bool no_dither; 143 | extern sox_bool reported_sox_opts; 144 | 145 | extern struct timeval load_timeofday; 146 | 147 | /* The input combiner: contains one sample buffer per input file, but only 148 | * needed if is_parallel(combine_method) */ 149 | typedef struct { 150 | sox_sample_t * * ibuf; 151 | size_t * ilen; 152 | } input_combiner_t; 153 | 154 | #define MIN_HEADROOM 6. 155 | extern double min_headroom; 156 | 157 | enum { 158 | encoding_signed_integer, encoding_unsigned_integer, encoding_floating_point, 159 | encoding_ms_adpcm, encoding_ima_adpcm, encoding_oki_adpcm, 160 | encoding_gsm_full_rate, encoding_u_law, encoding_a_law 161 | }; 162 | 163 | extern lsx_enum_item const encodings[]; 164 | 165 | typedef enum { 166 | Full, Type, Rate, Channels, Samples, Duration, Duration_secs, 167 | Bits, Bitrate, Precision, Encoding, Annotation 168 | } soxi_t; 169 | 170 | extern char const * const getoptstr; 171 | 172 | extern double soxi_total; 173 | extern size_t soxi_file_count; 174 | 175 | 176 | void add_eff_chain(void); 177 | int add_effect(sox_effects_chain_t * chain, sox_effect_t * effp, sox_signalinfo_t * in, sox_signalinfo_t const * out, int * guard); 178 | void add_effects(sox_effects_chain_t *chain); 179 | int add_file(file_t const * const opts, char const * const filename); 180 | void adjust_volume(int delta); 181 | int advance_eff_chain(void); 182 | void atexit_cleanup(void); 183 | void auto_effect(sox_effects_chain_t *chain, char const *name, int argc, char *argv[], sox_signalinfo_t *signal, int * guard); 184 | //void auto_effect(sox_effects_chain_t *, char const *, int, char **, sox_signalinfo_t *, int *); 185 | void balance_input(sox_sample_t * buf, size_t ws, file_t * f); 186 | void calculate_combiner_signal_parameters(void); 187 | void calculate_output_signal_parameters(void); 188 | sox_bool can_segue(size_t i); 189 | void cleanup(void); 190 | sox_bool cmp_comment_text(char const * c1, char const * c2); 191 | int combiner_drain(sox_effect_t *effp, sox_sample_t * obuf, size_t * osamp); 192 | int combiner_start(sox_effect_t *effp); 193 | int combiner_stop(sox_effect_t *effp); 194 | void create_user_effects(void); 195 | void delete_eff_chains(void); 196 | char const * device_name(char const * const type); 197 | void display_file_info(sox_format_t * ft, file_t * f, sox_bool full); 198 | void display_SoX_version(FILE * file); 199 | void display_status(sox_bool all_done); 200 | void display_supported_effects(void); 201 | void display_supported_formats(void); 202 | int enum_option(char const * arg, int option_index, lsx_enum_item const * items); 203 | char *fndup_with_count(const char *filename, size_t count); 204 | void free_eff_chain(void); 205 | char * headroom(void); 206 | void init_file(file_t * f); 207 | sox_effect_handler_t const * input_combiner_effect_fn(void); 208 | sox_bool is_pseudo_effect(const char *s); 209 | #ifdef HAVE_TERMIOS_H 210 | int kbhit(void); 211 | #endif 212 | void open_output_file(void); 213 | int opt_index(int val); 214 | void optimize_trim(void); 215 | int ostart(sox_effect_t *effp); 216 | sox_effect_handler_t const * output_effect_fn(void); 217 | int output_flow(sox_effect_t *effp, sox_sample_t const * ibuf, sox_sample_t * obuf, size_t * isamp, size_t * osamp); 218 | void output_message(unsigned level, const char *filename, const char *fmt, va_list ap); 219 | sox_bool overwrite_permitted(char const * filename); 220 | void parse_effects(int argc, char ** argv); 221 | char parse_gopts_and_fopts(file_t * f); 222 | void parse_options_and_filenames(int argc, char **argv); 223 | void play_file_info(sox_format_t * ft, file_t * f, sox_bool full); 224 | int process(void); 225 | void progress_to_next_input_file(file_t * f, sox_effect_t * effp); 226 | void read_comment_file(sox_comments_t * comments, char const * const filename); 227 | void read_user_effects(char const *filename); 228 | void report_file_info(file_t * f); 229 | void set_combiner_and_output_encoding_parameters(void); 230 | char const * set_default_device(file_t * f); 231 | void set_replay_gain(sox_comments_t comments, file_t * f); 232 | void sigint(int s); 233 | sox_bool since(struct timeval * then, double secs, sox_bool always_reset); 234 | char const * size_and_bitrate(sox_format_t * ft, char const * * text); 235 | size_t sox_read_wide(sox_format_t * ft, sox_sample_t * buf, size_t max); 236 | int soxi(int argc, char * const * argv); 237 | void soxi_usage(int return_code); 238 | int soxi1(soxi_t const * type, char const * filename); 239 | int soxmain(int argc, char **argv); 240 | char const * str_time(double seconds); 241 | int strcmp_p(const void *p1, const void *p2); 242 | char * * strtoargv(char * s, int * argc); 243 | uint64_t total_clips(void); 244 | char const * try_device(char const * name); 245 | int update_status(sox_bool all_done, void * client_data); 246 | void usage(char const * message); 247 | void usage_effect(char const * name); 248 | void usage_format(char const * name); 249 | void usage_format1(sox_format_handler_t const * f); 250 | char const * vu(unsigned channel); 251 | 252 | #ifdef __cplusplus 253 | } 254 | #endif // __cplusplus 255 | #endif // SOX_MAIN_H -------------------------------------------------------------------------------- /msupcm++/utf8.cpp: -------------------------------------------------------------------------------- 1 | #include "utf8.h" 2 | 3 | std::wstring_convert> utf8_to_wstring; 4 | 5 | #ifdef _WIN32 6 | #include 7 | 8 | char *utf16_to_utf8(const wchar_t *input) 9 | { 10 | char *Buffer; 11 | int BuffSize = 0, Result = 0; 12 | 13 | BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL); 14 | Buffer = (char*)malloc(sizeof(char) * BuffSize); 15 | if (Buffer) 16 | { 17 | Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL); 18 | } 19 | 20 | return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL; 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /msupcm++/utf8.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern std::wstring_convert> utf8_to_wstring; 6 | 7 | #ifdef _WIN32 8 | char *utf16_to_utf8(const wchar_t *input); 9 | #else 10 | #define utf16_to_utf8(input) 11 | #endif --------------------------------------------------------------------------------