Commit Graph

42 Commits

Author SHA1 Message Date
Glenn Maynard 3551367fe4 These attempt to flush buffers and go back to reading directly if ratios
are set back to 1.  They don't work; the speed shift buffer won't line up
perfectly for all channels, and the resampler would need to be lined up
with the window and lerped.  Make these only read directly if the buffers
are empty, so these filters are cheap if their ratios are never used.  Fixes
clicks when moving the ratio around 1.0.
2006-12-27 09:19:02 +00:00
Glenn Maynard 76832cad3b add GetRate 2006-12-27 07:38:11 +00:00
Glenn Maynard 49b3473f65 fix ASSERT( iGotFrames <= iFrames ) 2006-12-26 23:29:11 +00:00
Glenn Maynard e090c7b115 no need to manually propagate error messages 2006-12-23 06:55:21 +00:00
Glenn Maynard 71be488f42 make RageSoundReader_Resample_Good a RageSoundReader_Filter 2006-12-23 06:38:42 +00:00
Glenn Maynard 53b4dc4b7c fix GetNextSourceFrame < 0 2006-12-22 08:16:17 +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 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 ca67a9cb7c change SetPosition_Accurate and SetPosition_Fast to take and return frames 2006-12-09 06:35:09 +00:00
Glenn Maynard 48b84f8191 fix up resampling when no rate changing 2006-11-30 21:05:41 +00:00
Glenn Maynard ce89886873 optimize the 1:1 case 2006-11-30 07:23:56 +00:00
Glenn Maynard a5b5bf69a8 only SetDownFactor when it changes 2006-11-30 04:41:25 +00:00
Glenn Maynard 5988256883 fix iDownFactor 2006-11-30 04:40:24 +00:00
Glenn Maynard 9e261cca19 support dynamic rate changing 2006-11-30 03:57:09 +00:00
Glenn Maynard d19d8bd8d9 fix copy 2006-11-29 22:13:22 +00:00
Glenn Maynard 14c8d02e9e GetNextSourceFrame, GetStreamToSourceRatio 2006-11-29 21:47:23 +00:00
Glenn Maynard 1146c57dc8 specify source and dest sample rate in the ctor; they don't change 2006-11-29 02:45:40 +00:00
Glenn Maynard 7c56fe71dd copy with a copy ctor 2006-11-29 02:38:56 +00:00
Glenn Maynard aed9a361a0 fix 0 iFilterIncrement causing infinite loop 2006-11-28 22:05:59 +00:00
Glenn Maynard 8ccb1a83d8 allow modifying the downsampling ratio on the fly 2006-11-28 21:51:24 +00:00
Glenn Maynard 0060777091 pass iUpFactor to State ctor, not PolyphaseFilter 2006-11-28 21:43:33 +00:00
Glenn Maynard 7ec7d42bd7 split out GetCutoffFrequency 2006-11-28 21:40:39 +00:00
Glenn Maynard df61847f17 store m_iUpFactor 2006-11-28 21:39:23 +00:00
Glenn Maynard 00cc972d30 pass a ratio to RageSoundResampler_Polyphase, not sample rates 2006-11-28 21:37:12 +00:00
Glenn Maynard c7436c81fd GetPolyphaseFilter -> MakePolyphaseFilter 2006-11-28 21:33:31 +00:00
Glenn Maynard bdffe5713e split out PolyphaseFilterCache::GetPolyphaseFilter 2006-11-28 21:32:07 +00:00
Glenn Maynard e2fb30cb87 fix resampler leak 2006-11-27 20:32:54 +00:00
Glenn Maynard da024345f3 cleanup 2006-10-27 05:53:23 +00:00
Glenn Maynard 7a95f5da5b covariant Copy() 2006-10-20 00:01:18 +00:00
Chris Danford 130554e42a fix VC6 compile 2006-02-15 03:53:04 +00:00
Glenn Maynard 5d64dff234 Rewritten sound resampler.
This eliminates the (optional) libresample dependency, which will clean up
building and eliminate the goofy 5k DLL.  It's also faster.

This doesn't implement "HighQuality".  That would involve changing L from
8 to 16.  I might implement that in the future, but it sounds decent to me.  (It's
a little tricky, since PolyphaseFilter::RunPolyphaseFilter needs L to be
a constant for speed.)
2006-02-13 04:50:28 +00:00
Renaud Lepage 1b124c16a5 Someone had made ifdefs that were confusing if compiling for Xbox. The conflictual situations have been resolved. 2005-05-30 23:43:37 +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 27243e074c working on variable channel count support (to allow preloading mono samples
in half memory, and to avoid redundant resampling in mono files)
2004-07-24 01:22:10 +00:00
Glenn Maynard 3119833bae types 2004-05-11 21:08:13 +00:00
Glenn Maynard f9f10e2372 more license updates 2004-05-06 02:40:33 +00:00
Glenn Maynard 5e05b951d5 upgrade to libresample 0.1.3 2004-01-08 03:12:11 +00:00
Chris Danford 47def7d3dc xbox updates 2003-11-13 00:39:36 +00:00
Glenn Maynard c9a265d5f8 MP3 GetLength is const now, so we can clean this up, too. 2003-09-25 00:43:10 +00:00
Glenn Maynard 6954e0facf Move the linear resampler to RageSoundReader_Resample_Fast.
Add RageSoundReader_Resample_Good, using libresample.
2003-09-24 22:31:34 +00:00