Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
flac
Commits
1f228161
Commit
1f228161
authored
Oct 25, 2002
by
Josh Coalson
Browse files
initial import
parent
e7ff8fb7
Changes
7
Hide whitespace changes
Inline
Side-by-side
include/share/gain_analysis.h
0 → 100644
View file @
1f228161
/*
* ReplayGainAnalysis - analyzes input samples and give the recommended dB change
* Copyright (C) 2001 David Robinson and Glen Sawyer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* concept and filter values by David Robinson (David@Robinson.org)
* -- blame him if you think the idea is flawed
* coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA
* -- blame him if you think this runs too slowly, or the coding is otherwise flawed
* minor cosmetic tweaks to integrate with FLAC by Josh Coalson
*
* For an explanation of the concepts and the basic algorithms involved, go to:
* http://www.replaygain.org/
*/
#ifndef GAIN_ANALYSIS_H
#define GAIN_ANALYSIS_H
#if defined(FLAC__NO_DLL) || defined(unix) || defined(__CYGWIN__) || defined(__CYGWIN32__)
#define GAIN_ANALYSIS_API
#else
#ifdef GAIN_ANALYSIS_API_EXPORTS
#define GAIN_ANALYSIS_API _declspec(dllexport)
#else
#define GAIN_ANALYSIS_API _declspec(dllimport)
#define __LIBNAME__ "gain_analysis.lib"
#pragma comment(lib, __LIBNAME__)
#undef __LIBNAME__
#endif
#endif
#include <stddef.h>
#define GAIN_NOT_ENOUGH_SAMPLES -24601
#define GAIN_ANALYSIS_ERROR 0
#define GAIN_ANALYSIS_OK 1
#define INIT_GAIN_ANALYSIS_ERROR 0
#define INIT_GAIN_ANALYSIS_OK 1
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
float
Float_t
;
/* Type used for filtering */
GAIN_ANALYSIS_API
int
InitGainAnalysis
(
long
samplefreq
);
GAIN_ANALYSIS_API
int
AnalyzeSamples
(
const
Float_t
*
left_samples
,
const
Float_t
*
right_samples
,
size_t
num_samples
,
int
num_channels
);
GAIN_ANALYSIS_API
int
ResetSampleFrequency
(
long
samplefreq
);
GAIN_ANALYSIS_API
Float_t
GetTitleGain
(
void
);
GAIN_ANALYSIS_API
Float_t
GetAlbumGain
(
void
);
#ifdef __cplusplus
}
#endif
#endif
/* GAIN_ANALYSIS_H */
include/share/replaygain.h
0 → 100644
View file @
1f228161
/* replaygain - Convenience lib for calculating/storing ReplayGain in FLAC
* Copyright (C) 2002 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* This wraps the gain_analysis lib, which is LGPL. This wrapper
* allows analysis of different input resolutions by automatically
* scaling the input signal
*/
#ifndef FLAC__SHARE__REPLAYGAIN_H
#define FLAC__SHARE__REPLAYGAIN_H
#if defined(FLAC__NO_DLL) || defined(unix) || defined(__CYGWIN__) || defined(__CYGWIN32__)
#define REPLAYGAIN_API
#else
#ifdef REPLAYGAIN_API_EXPORTS
#define REPLAYGAIN_API _declspec(dllexport)
#else
#define REPLAYGAIN_API _declspec(dllimport)
#define __LIBNAME__ "replaygain.lib"
#pragma comment(lib, __LIBNAME__)
#undef __LIBNAME__
#endif
#endif
#include "FLAC/ordinals.h"
#ifdef __cplusplus
extern
"C"
{
#endif
REPLAYGAIN_API
FLAC__bool
FLAC__replaygain_init
(
unsigned
sample_frequency
);
/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */
REPLAYGAIN_API
FLAC__bool
FLAC__replaygain_analyze
(
const
FLAC__int32
*
const
input
[],
FLAC__bool
is_stereo
,
unsigned
bps
,
unsigned
samples
);
REPLAYGAIN_API
float
FLAC__replaygain_get_album_gain
();
REPLAYGAIN_API
float
FLAC__replaygain_get_title_gain
();
#ifdef __cplusplus
}
#endif
#endif
src/share/replaygain/Makefile.am
0 → 100644
View file @
1f228161
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS
=
foreign
INCLUDES
=
-I
$(top_srcdir)
/include
noinst_LIBRARIES
=
libreplaygain.a
libreplaygain_a_SOURCES
=
replaygain.c
EXTRA_DIST
=
\
Makefile.lite
\
Makefile.vc
\
replaygain.dsp
debug
:
$(MAKE)
all
CFLAGS
=
"@DEBUG@"
profile
:
$(MAKE)
all
CFLAGS
=
"@PROFILE@"
src/share/replaygain/Makefile.lite
0 → 100644
View file @
1f228161
#
# GNU makefile
#
topdir
=
../../..
LIB_NAME
=
libreplaygain
INCLUDES
=
-I
$(topdir)
/include
OBJS
=
\
replaygain.o
include
$(topdir)/build/lib.mk
# DO NOT DELETE THIS LINE -- make depend depends on it.
src/share/replaygain/Makefile.vc
0 → 100644
View file @
1f228161
!
include
<win32.mak>
!IFDEF
DEBUG
.c.obj
:
$(cc)
/D
"_LIB"
-DFLAC__NO_DLL
/GX
$(cdebug)
$(cflags)
/I
"..
\.
.
\.
.
\i
nclude"
-DSTRICT
-YX
/Od /D
"_DEBUG"
$<
!else
.c.obj
:
$(cc)
/D
"_LIB"
-DFLAC__NO_DLL
/O2
$(crelease)
$(cflags)
/I
"..
\.
.
\.
.
\i
nclude"
-DSTRICT
-YX
-DNODEBUG
$<
!endif
C_FILES
=
\
replaygain.c
\
OBJS
=
$(C_FILES:.c=.obj)
all
:
replaygain.lib
replaygain.lib
:
$(OBJS)
link.exe
-lib
/nodefaultlib
-out
:../../../obj/lib/
$*
.lib
$(OBJS)
clean
:
-
del
*
.obj
*
.pch
-
del ..
\.
.
\.
.
\o
bj
\l
ib
\r
eplaygain.lib ..
\.
.
\.
.
\o
bj
\l
ib
\r
eplaygain.pdb
src/share/replaygain/replaygain.c
0 → 100644
View file @
1f228161
/* replaygain - Convenience lib for calculating/storing ReplayGain in FLAC
* Copyright (C) 2002 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "share/replaygain.h"
#include "share/gain_analysis.h"
#include "FLAC/assert.h"
#include "FLAC/format.h"
#ifdef local_min
#undef local_min
#endif
#define local_min(a,b) ((a)<(b)?(a):(b))
REPLAYGAIN_API
FLAC__bool
FLAC__replaygain_init
(
unsigned
sample_frequency
)
{
return
InitGainAnalysis
((
long
)
sample_frequency
)
==
INIT_GAIN_ANALYSIS_OK
;
}
REPLAYGAIN_API
FLAC__bool
FLAC__replaygain_analyze
(
const
FLAC__int32
*
const
input
[],
FLAC__bool
is_stereo
,
unsigned
bps
,
unsigned
samples
)
{
static
Float_t
lbuffer
[
4096
],
rbuffer
[
4096
];
static
const
unsigned
nbuffer
=
sizeof
(
lbuffer
)
/
sizeof
(
lbuffer
[
0
]);
unsigned
i
;
FLAC__ASSERT
(
bps
>=
4
&&
bps
<=
32
);
FLAC__ASSERT
(
FLAC__MIN_BITS_PER_SAMPLE
==
4
);
FLAC__ASSERT
(
FLAC__MAX_BITS_PER_SAMPLE
==
32
);
if
(
bps
==
16
)
{
if
(
is_stereo
)
{
while
(
samples
>
0
)
{
const
unsigned
n
=
local_min
(
samples
,
nbuffer
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
lbuffer
[
i
]
=
(
Float_t
)
input
[
0
][
i
];
rbuffer
[
i
]
=
(
Float_t
)
input
[
1
][
i
];
}
samples
-=
n
;
if
(
AnalyzeSamples
(
lbuffer
,
rbuffer
,
n
,
2
)
!=
GAIN_ANALYSIS_OK
)
return
false
;
}
}
else
{
while
(
samples
>
0
)
{
const
unsigned
n
=
local_min
(
samples
,
nbuffer
);
for
(
i
=
0
;
i
<
n
;
i
++
)
lbuffer
[
i
]
=
(
Float_t
)
input
[
0
][
i
];
samples
-=
n
;
if
(
AnalyzeSamples
(
lbuffer
,
0
,
n
,
1
)
!=
GAIN_ANALYSIS_OK
)
return
false
;
}
}
}
else
{
const
double
scale
=
(
(
bps
>
16
)
?
(
double
)
1
.
/
(
double
)(
1u
<<
(
bps
-
16
))
:
(
double
)(
1u
<<
(
16
-
bps
))
);
if
(
is_stereo
)
{
while
(
samples
>
0
)
{
const
unsigned
n
=
local_min
(
samples
,
nbuffer
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
lbuffer
[
i
]
=
(
Float_t
)(
scale
*
(
double
)
input
[
0
][
i
]);
rbuffer
[
i
]
=
(
Float_t
)(
scale
*
(
double
)
input
[
1
][
i
]);
}
samples
-=
n
;
if
(
AnalyzeSamples
(
lbuffer
,
rbuffer
,
n
,
2
)
!=
GAIN_ANALYSIS_OK
)
return
false
;
}
}
else
{
while
(
samples
>
0
)
{
const
unsigned
n
=
local_min
(
samples
,
nbuffer
);
for
(
i
=
0
;
i
<
n
;
i
++
)
lbuffer
[
i
]
=
(
Float_t
)(
scale
*
(
double
)
input
[
0
][
i
]);
samples
-=
n
;
if
(
AnalyzeSamples
(
lbuffer
,
0
,
n
,
1
)
!=
GAIN_ANALYSIS_OK
)
return
false
;
}
}
}
return
true
;
}
REPLAYGAIN_API
float
FLAC__replaygain_get_album_gain
()
{
return
GetAlbumGain
();
}
REPLAYGAIN_API
float
FLAC__replaygain_get_title_gain
()
{
return
GetTitleGain
();
}
src/share/replaygain/replaygain.dsp
0 → 100644
View file @
1f228161
# Microsoft Developer Studio Project File - Name="replaygain" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=replaygain - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "replaygain.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "replaygain.mak" CFG="replaygain - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "replaygain - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "replaygain - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "replaygain"
# PROP Scc_LocalPath "..\..\.."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "replaygain - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\obj\lib"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I ".\include" /I "..\..\..\include" /D "NDEBUG" /D "REPLAYGAIN_API_EXPORTS" /D "_WINDOWS" /D "_WINDLL" /D "WIN32" /D "_USRDLL" /FR /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_USRDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\..\obj\bin/replaygain.dll"
!ELSEIF "$(CFG)" == "replaygain - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\obj\lib"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I ".\include" /I "..\..\..\include" /D "_DEBUG" /D "_CHATTER" /D "REPLAYGAIN_API_EXPORTS" /D "_WINDOWS" /D "_WINDLL" /D "WIN32" /D "_USRDLL" /FR /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_USRDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\..\..\obj\bin/replaygain.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "replaygain - Win32 Release"
# Name "replaygain - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp"
# Begin Source File
SOURCE=.\replaygain.c
# End Source File
# End Group
# Begin Group "Private Header Files"
# PROP Default_Filter ""
# End Group
# Begin Group "Protected Header Files"
# PROP Default_Filter ""
# End Group
# Begin Group "Public Header Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\include\share\replaygain.h
# End Source File
# End Group
# End Target
# End Project
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment