Commit Graph

35 Commits

Author SHA1 Message Date
Glenn Maynard 1bdbe78390 support preloading in 16-bit 2007-02-01 03:42:33 +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 ec1764291d fix RageSoundReader_Preload seek 2007-01-18 10:28:13 +00:00
Glenn Maynard 8ba265a246 fix RageSoundReader_Preload never preloading 2007-01-18 09:51:18 +00:00
Glenn Maynard cc043b3d16 no error here 2006-12-23 07:00:28 +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 5da7b5a8a4 seek fix 2006-11-30 04:59:50 +00:00
Glenn Maynard f41362f7a9 SoundReader -> RageSoundReader 2006-11-30 04:19:51 +00:00
Glenn Maynard 1c3e34d4a4 rate fix 2006-11-30 04:02:32 +00:00
Glenn Maynard c68c60c67a GetNextStreamFrame -> GetNextSourceFrame 2006-11-29 09:15:23 +00:00
Glenn Maynard e3b98efd66 GetNextStreamFrame, GetStreamToSourceRatio implementations 2006-11-29 08:15:22 +00:00
Glenn Maynard ed0ea3f4c6 seek()s return frames, not bytes 2006-11-26 21:54:47 +00:00
Glenn Maynard d5e7260f59 use AutoPtrCopyOnWrite 2006-11-26 18:33:29 +00:00
Glenn Maynard b52c8f9966 style 2006-11-25 22:46:47 +00:00
Glenn Maynard 7a95f5da5b covariant Copy() 2006-10-20 00:01:18 +00:00
Glenn Maynard b01308783e unused headers 2005-12-19 00:42:29 +00:00
Glenn Maynard c3ff27796a add GetReferenceCount 2005-07-18 19:06:32 +00:00
Glenn Maynard c85de593f9 s/SoundReader_Preload/RageSoundReader_Preload/
split RageSoundReader_Preload::PreloadSound
split RageSound::LoadSoundReader
2004-10-24 19:25:21 +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 f9f10e2372 more license updates 2004-05-06 02:40:33 +00:00
Glenn Maynard 6acfd7a22e remove GetOffsetFix 2004-02-20 04:16:12 +00:00
Glenn Maynard 9c1b88cce6 fix minor seek bug 2004-01-22 04:41:56 +00:00
Glenn Maynard 036fd2beb9 Fix: don't chop off the first 26ms of each MP3 (but don't change sync,
either).
2003-10-02 04:56:09 +00:00
Steve Checkoway 8c6ba0f506 Fix compile warnings 2003-08-01 12:12:02 +00:00
Glenn Maynard 111eeef550 use RageSoundReader_Resample
(almost not tied to 44100 ...)
2003-04-23 19:11:59 +00:00
Glenn Maynard a5e6cd2787 Simplify.
Remove preloading; it's not useful.
2003-04-23 18:33:59 +00:00
Glenn Maynard 1bfbc25bbf fix bSoundPreloadAll
(this makes the music wheel very slow; need a better mode, to only allow
streaming one file at a time)
2003-04-07 00:00:46 +00:00
Glenn Maynard 0ae6236f7c Add an option to force preloading. This only preloads sounds
that are loaded in advance, which excludes sample music
and some announcers.

Disable "sound volume".  That's not what that variable is for; setting
it to higher values will result in clipping on a lot of hardware, causing
people to report it as a "bug" (which it's not).  Setting it to lower values
results in lower quality sound.  To do this correctly, we'd need to add
an interface for accessing the real hardware mixer volume, which I
don't really want to do right now ...
2003-03-31 21:21:23 +00:00
Glenn Maynard bbf8067551 remove prebuffering from RageSound; let Preload handle it 2003-03-15 23:55:24 +00:00
Glenn Maynard a990cdcb42 fix prebuf size 2003-03-15 23:28:19 +00:00
Glenn Maynard e767641c67 Modularize preloading with a sound reader, so the !big logic
in RageSound can go away
2003-03-15 23:28:05 +00:00