~ubuntu-branches/ubuntu/precise/ultrastar-ng/precise

« back to all changes in this revision

Viewing changes to audio/sample.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz, Miriam Ruiz, Mario Bonino, Jon Dowland, Ansgar Burchardt
  • Date: 2008-06-07 16:43:18 UTC
  • mfrom: (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080607164318-4cnzizck1tp8mrwp
Tags: 0.2.1-1
[ Miriam Ruiz ]
* New Upstream Release (Closes: #453132)
* Removed unneeded patches
* Added packages to build deps:
  + libtool
  + portaudio19-dev | portaudio-dev
  + libboost-dev, libboost-thread-dev, libboost-serialization-dev
  + libboost-program-options-dev, libboost-regex-dev
* Moved shared objects to private directory: /usr/lib/ultraster-ng
* Added rpath to binaries to search for shared objects in the private dir
* Uses ultrastar-ng-gstreamer as default, instead of ultrastar-ng-xine,
  since there are significantly less issues with GStreamer.
* Added patch to fix upstream desktop file
* Added -Wl,-as-needed to LDFLAGS
* Replaced fftw3-dev by libfftw3-dev in build dependencies.
* Standards-Version upgraded to 3.7.3

[ Mario Bonino ]
* Fixed data/Makefile.am to install .desktop file and icon

[ Jon Dowland ]
* add Homepage: control field to source stanza
* fix a bashism in debian/rules (Closes: #478634)

[ Ansgar Burchardt ]
* debian/control: Change XS-Vcs-* to Vcs-*
* Remove Homepage semi-field from description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef LIBDA_SAMPLE_HPP_INCLUDED
 
2
#define LIBDA_SAMPLE_HPP_INCLUDED
 
3
 
 
4
/**
 
5
@file sample.hpp Sample format definition and format conversions.
 
6
 
 
7
Header-only, no need to link to LibDA.
 
8
**/
 
9
 
 
10
#include <math.h>
 
11
 
 
12
namespace da {
 
13
        // WARNING: changing this breaks binary compatibility on the library!
 
14
        typedef float sample_t;
 
15
 
 
16
        // The following conversions provide lossless conversions between floats
 
17
        // and integers. Be sure to use only these conversions or otherwise the
 
18
        // conversions may not be lossless, due to different scaling factors being
 
19
        // used by different libraries.
 
20
 
 
21
        // The negative minimum integer value produces sample_t value slightly
 
22
        // more negative than -1.0 but this is necessary in order to prevent
 
23
        // clipping in the float-to-int conversions. Now amplitude 1.0 in floating
 
24
        // point produces -32767 .. 32767 symmetrical non-clipping range in s16.
 
25
        const sample_t max_s16 = 32767.0;
 
26
        const sample_t max_s24 = 8388607.0;
 
27
 
 
28
        static inline sample_t conv_from_s16(int s) { return s / max_s16; }
 
29
        static inline sample_t conv_from_s24(int s) { return s / max_s24; }
 
30
        // The rounding is strictly not necessary, but it greatly improves
 
31
        // the error tolerance if any floating point calculations are done.
 
32
        static inline int conv_to_s16(sample_t s) { return int(roundf(s * max_s16)); }
 
33
        static inline int conv_to_s24(sample_t s) { return int(roundf(s * max_s24)); }
 
34
}
 
35
 
 
36
#endif
 
37