Commit Graph

43 Commits

Author SHA1 Message Date
Glenn Maynard 136eb055b0 typo 2007-02-22 00:52:09 +00:00
Glenn Maynard 0ae8641ce7 reader fixes 2007-02-22 00:51:48 +00:00
Glenn Maynard acc0b14ee1 push file opening upwards, instead of duplicating it in each loader 2007-02-21 10:10:18 +00:00
Glenn Maynard a3a8f39905 support all bit depths up to 32-bit and 32-bit float 2007-02-01 21:38:22 +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 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 cd5f4a6e39 SoundReader_FileReader -> RageSoundReader_FileReader 2006-11-30 04:22:38 +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 7a95f5da5b covariant Copy() 2006-10-20 00:01:18 +00:00
Chris Danford 7f821e8cfc CString -> RString 2006-01-22 01:00:06 +00:00
Chris Danford 48ebc53549 return NULL -> return CString() for clarity and efficiency 2005-09-04 16:55:21 +00:00
Chris Danford e439ae2a96 return "" -> return NULL 2005-09-02 00:14:07 +00:00
Glenn Maynard b6eba6ac8d start eliminating exception use; gcc apparently bloats exceptions to
a degree that makes them not worth it
2004-11-30 08:12:08 +00:00
Glenn Maynard a80025d28f fix PCM WAV seeking 2004-11-01 08:27:26 +00:00
Glenn Maynard 25f83be525 fix warning 2004-10-06 02:04:44 +00:00
Glenn Maynard 90ed4534e0 reimplement WAV reading to reduce licensing exceptions 2004-10-05 22:55:00 +00:00
Chris Danford 03fbb915f3 remove VC6 scoping hacks 2004-09-21 07:53:39 +00:00
Glenn Maynard b481fc465b excessively large commit: use RageSurface 2004-06-14 00:51:00 +00:00
Glenn Maynard dd4bc636f4 cleanups 2004-06-13 20:03:18 +00:00
Glenn Maynard 1efd594730 byte swap update 2004-06-13 07:35:08 +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 fc21403339 convert from SDL to standard types 2004-05-11 20:25:34 +00:00
Glenn Maynard f9f10e2372 more license updates 2004-05-06 02:40:33 +00:00
Glenn Maynard 33c7b4670d better error messages for unsupported WAV types 2004-04-28 01:24:28 +00:00
Glenn Maynard 10a1d7489d get_length_fmt_adpcm fix 2003-12-04 20:33:33 +00:00
Glenn Maynard 162e79ea83 use RageFile 2003-12-04 20:21:08 +00:00
Glenn Maynard d3755f98a5 fix crashes when files fail to open 2003-10-12 03:01:07 +00:00
Glenn Maynard 6376a8f066 remove trace 2003-10-09 00:36:15 +00:00
Glenn Maynard 892ca27777 Change EOF seek behavior: reading after a seek past EOF returns EOF.
Minor Vorbis seek fix.
2003-10-07 04:03:22 +00:00
Glenn Maynard c744d0aabd Lots of ADPCM bug fixes. 2003-10-06 08:02:52 +00:00
Glenn Maynard 9dc7d196af fix RageSoundReader_WAV::get_length_fmt_adpcm 2003-09-25 00:30:15 +00:00
Glenn Maynard 001a627502 Fix error returns. 2003-09-21 00:35:08 +00:00
Glenn Maynard 6c33443944 Simplify. 2003-09-18 21:10:57 +00:00
Glenn Maynard d2a09cef5f Cleanup. More ADPCM fixes. 2003-09-18 20:27:31 +00:00
Glenn Maynard 477402a78c Fix ADPCM GetLength() crash. 2003-09-17 01:42:42 +00:00
Glenn Maynard 7afffaef0e Improve return values for fallbacks. 2003-09-13 06:06:01 +00:00
Glenn Maynard f5d284a4a5 fixes 2003-09-10 22:02:44 +00:00
Glenn Maynard 200177d22a add native WAV decoder 2003-09-10 21:31:40 +00:00