Commit Graph

86 Commits

Author SHA1 Message Date
Glenn Maynard 052eaa9a5e don't clip or round incoming data prematurely 2007-01-27 08:34:55 +00:00
Glenn Maynard 1bd5513698 Switch to floating-point sound internally.
This allows us to change the volume of sounds in filters ("volume",
"fade" properties) without quantizing the audio prematurely.  Previously,
we had a hack to apply volume changes as a mixing-time step.  This
can be done at any point in the filter chain now.

This also means we only need to worry about clipping at the very
last mixing step, instead of at every place we change sound.

Dithering for 16-bit audio and more intelligent gain control
is possible, as we have full-resolution, unclipped sound at the
mixing phase.

We support high resolution source sounds; both Vorbis and MAD
supply more than 16 bits.

Several filters, such as resampling, are easier to implement as
floats; these no longer need to convert back and forth.

Negatives:
 - More memory use.  The main case of this is in RageSoundReader_Preload,
which will be fixed: we can preload in 16-bit without losing most of the
above.
 - Some extra overhead for accessing more memory.
2007-01-27 07:14:58 +00:00
Glenn Maynard fd4b5f93bb RageSoundReader::Read(char *) -> int16_t *. This was originally
char * based on the idea of supporting more than one sample type.
I don't plan to do that (though I may change the sample type to float
or int32).
2007-01-20 01:10:24 +00:00
Glenn Maynard aa4be6dffb Return 1 from SetPosition(n) on success, 0 on seek past EOF, not
"the position seeked to".  This fixes a special case: SetPosition(n)
returning 0 was EOF except when SetPosition(0).  The returned value
on success was always n, anyway; we never seek to a different position
and return success.
2006-12-21 05:07:49 +00:00
Glenn Maynard 7385c1f4c1 merge SetPosition_Accurate and SetPosition_Fast. Use a property
instead.
2006-12-10 08:59:13 +00:00
Glenn Maynard 0b529a4960 RageSoundReader::Read() returns sound data which may be at a
different rate than the source it's reading from; one second
of returned data may correspond to two seconds in the source
material.

GetStreamToSourceRatio returns the ratio of returned data in
the next Read() call to source data.  This is propagated
upwards in the filter tree, so rate changes by a speed changer
in the middle of the tree will be reflected in the final
GetStreamToSourceRatio().

This means that whenever the ratio changes, Read() stops
returning data; it returns whatever it has, so the caller
has an opportunity to call GetStreamToSourceRatio again
and notice the change.

These semantics can be annoying to implement in some
cases, where only the processing of Read() may notice
a ratio change.  Read() may want to return 0, to say
"something changed, call GetStreamToSourceRatio again",
but 0 means EOF.

Add RageSoundReader::END_OF_FILE.  0 is now no
longer a special case; it means "there's more data, I
just didn't return any this time".  This is functionally
equivalent to errno EINTR.
2006-12-10 07:08:17 +00:00
Glenn Maynard 3859d3b7bc implement GetNumChannels to simplify (if mono, send mono sound,
not stereo)
2006-12-10 04:20:22 +00:00
Glenn Maynard 25e67dd4dc RageSoundReader::Read(buf, unsigned bytes) -> (buf, int frames);
return value in frames, not bytes
2006-12-10 03:56:36 +00:00
Glenn Maynard 18d44445e3 unindent 2006-12-09 20:01:41 +00:00
Glenn Maynard aebfd2af2e fix uninitialized 2006-12-09 20:01:13 +00:00
Glenn Maynard 130012f3b2 toc was too inaccurate for precise seeking; this was obscured by the earlier seek bug. 2006-12-09 19:55:26 +00:00
Glenn Maynard 6333bb5952 100000 is correct (ms * percent = 1000 * 100); 100 is just masking a bug somewhere else ... 2006-12-09 09:23:32 +00:00
Glenn Maynard ba58784e68 if not synthing, the buffer may have data used. mad->Timer is the time of the beginning of this MP3 frame; make sure the "skip data in the buffer" logic always works by putting the buffer back to the beginning of the MP3 frame 2006-12-09 08:48:28 +00:00
Glenn Maynard 1ba68d8469 fix seeking with SetPosition_hard if the position lies in the first MP3 frame 2006-12-09 08:43:59 +00:00
Glenn Maynard c82cf0be7a synth_output always clears outpos 2006-12-09 08:42:19 +00:00
Glenn Maynard d24f70800d length is in ms 2006-12-09 08:26:08 +00:00
Glenn Maynard ca67a9cb7c change SetPosition_Accurate and SetPosition_Fast to take and return frames 2006-12-09 06:35:09 +00:00
Glenn Maynard c1da32160b fix RageSoundReader_MP3::GetNextSourceFrame
fix lurking mad->Timer bug after seek
2006-12-01 11:08:28 +00:00
Glenn Maynard cd5f4a6e39 SoundReader_FileReader -> RageSoundReader_FileReader 2006-11-30 04:22:38 +00:00
Glenn Maynard 0bd9c4e032 mad->Timer is the beginning of the frame; advance by outpos to find the current source frame 2006-11-29 20:56:32 +00:00
Glenn Maynard c68c60c67a GetNextStreamFrame -> GetNextSourceFrame 2006-11-29 09:15:23 +00:00
Glenn Maynard 0f9e6c9153 GetNextStreamFrame implementations 2006-11-29 07:40:19 +00:00
Glenn Maynard 43a9f7b451 simplify 2006-10-20 09:35:38 +00:00
Glenn Maynard 7a95f5da5b covariant Copy() 2006-10-20 00:01:18 +00:00
Glenn Maynard 2b9f484548 spacing (only) 2006-02-14 11:30:53 +00:00
Chris Danford 7f821e8cfc CString -> RString 2006-01-22 01:00:06 +00:00
Renaud Lepage 61b1c66f53 Defines problems for Xbox. 2005-08-23 02:29:13 +00:00
Ben Anderson 58f0d45465 Add comments to confusing #if block; use _WINDOWS and _MSC_VER properly (fixes MinGW compilation) 2005-06-26 03:51:38 +00:00
Thad Ward 5949e5bc90 (this is possibly going to annoy some people, but..)
put all (obvious) MSVC lines in #if defined(_MSC_VER) blocks, primarilly
to allow alternative win32 compilers to be used.
2005-05-11 04:43:54 +00:00
Glenn Maynard 7085d480ec Remove RageFile::Rewind() calls. The original notion was that rewinding is
often simpler than seeking; that some drivers may only support rewinding;
and that, if supported, rewinding should never fail.  However, there's really
no reason for it to be a separate API call.
2004-12-09 08:59:24 +00:00
Glenn Maynard 6756ca25bc fix error check and sync regression 2004-10-06 18:08:04 +00:00
Glenn Maynard 66931a2e22 Yuck: fix MP3 sync compatibility with DWI for certain mildly corrupt MP3s.
This used to work; I just noticed that it broke at some point, though I'm
not sure when.  Most of these changes is just reordering code.
2004-10-05 18:44:07 +00:00
Chris Danford 03fbb915f3 remove VC6 scoping hacks 2004-09-21 07:53:39 +00:00
Glenn Maynard dd4bc636f4 cleanups 2004-06-13 20:03:18 +00:00
Glenn Maynard 276adb5ecd update deprecated names
file failing to open is a fatal error
2004-05-21 21:03:38 +00:00
Glenn Maynard 7c56df3fd7 types 2004-05-11 20:50:08 +00:00
Glenn Maynard f9f10e2372 more license updates 2004-05-06 02:40:33 +00:00
Steve Checkoway 20a8bab45c Clean up includes. 2004-04-05 05:22:32 +00:00
Glenn Maynard 4989388a21 typo 2004-04-01 21:56:58 +00:00
Glenn Maynard d0ce109c61 typos 2004-03-30 22:25:28 +00:00
Glenn Maynard 896ce3f103 make sure the last frame of MP3s is decoded 2004-03-28 05:10:26 +00:00
Glenn Maynard 3134e40091 sample music sync fix 2004-03-01 06:40:40 +00:00
Glenn Maynard 93768c249a update MAD 2004-02-18 04:36:30 +00:00
Glenn Maynard 47530d2117 Remove OffsetFix
Read Info tags
Mimic BASS decoding peculiarities
2004-01-24 20:00:41 +00:00
Glenn Maynard 7fe3268d1a disable OffsetFix: it's broken, might remove it entirely 2004-01-22 04:23:17 +00:00
Glenn Maynard a21d12abf2 fix editor sync regression caused by the sample music seek fix 2004-01-11 09:57:36 +00:00
Glenn Maynard 7237f1012e simplify 2004-01-11 09:40:07 +00:00
Glenn Maynard 6dfceeb3f4 seek fix: header_bytes was zero 2003-12-13 20:28:27 +00:00
Glenn Maynard 4da0aa95bf fix error output 2003-12-07 05:58:13 +00:00
Glenn Maynard 5c2eb8acfe use RageFile 2003-12-04 20:06:27 +00:00