Commit Graph

52 Commits

Author SHA1 Message Date
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 00f371fa7c remove IsStreamingFromDisk 2006-12-23 07:15:32 +00:00
Glenn Maynard 32bf31638f fix RageSoundReader_Chain::SetPosition(0) 2006-12-22 08:12:57 +00:00
Glenn Maynard 3a1d1e129f use RetriedRead 2006-12-22 06:14:20 +00:00
Glenn Maynard a7d3a539ee fixup (still unused) code 2006-12-22 06:06:57 +00:00
Glenn Maynard 4516298901 simplify EOF handling 2006-12-22 06:01:49 +00:00
Glenn Maynard 3554fdeac0 copy error: break, not continue 2006-12-22 05:59:23 +00:00
Glenn Maynard cd74aab240 stay synched through partial blocks 2006-12-22 05:58:19 +00:00
Glenn Maynard 3d6811191b simplify 2006-12-22 05:54:23 +00:00
Glenn Maynard 4d6829e7bc simplify 2006-12-22 05:51:36 +00:00
Glenn Maynard 3127f812dd cleanup; handle different numbers of channels 2006-12-22 05:36:50 +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 893e9d9e53 units are samples, not bytes 2006-12-12 02:47:35 +00:00
Glenn Maynard ef5c5e20c1 SetPosition 2006-12-10 09:01:05 +00:00
Glenn Maynard ecbbe89f1a Read() update 2006-12-10 07:17:58 +00:00
Glenn Maynard 2f1782d892 merge Read and ReadBlock 2006-12-10 05:41:41 +00:00
Glenn Maynard 04b2933af6 simplify and correct. If Read (and ReadBlock) doesn't return as much data as requested, it may be because the rate is changing. 2006-12-10 05:32:03 +00:00
Glenn Maynard 9a55b8d28a remove unused 2006-12-10 05:18:33 +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 84c5c0a865 Simplify RSR_Chain. Allow passing in sound readers directly.
If all sounds have one channel and nothing pans, keep one channel.
Use RSR_Pan.
2006-12-09 22:40:39 +00:00
Glenn Maynard 381fc45cfd fix RageSoundReader_Chain::GetNextSourceFrame 2006-12-09 22:10:17 +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 a272414497 cosmetic: remove indentation 2006-12-09 03:51:46 +00:00
Glenn Maynard f1b5f9b53b simplify 2006-12-09 03:51:32 +00:00
Glenn Maynard 81b3232453 simplify iFrames 2006-12-09 03:50:06 +00:00
Glenn Maynard 6fa2581a58 comment 2006-12-09 03:45:49 +00:00
Glenn Maynard f2ae34e517 cleanup 2006-12-09 03:44:36 +00:00
Glenn Maynard 0e72d6d08c cosmetic 2006-12-09 03:40:55 +00:00
Glenn Maynard cd5f4a6e39 SoundReader_FileReader -> RageSoundReader_FileReader 2006-11-30 04:22:38 +00:00
Glenn Maynard f41362f7a9 SoundReader -> RageSoundReader 2006-11-30 04:19:51 +00:00
Glenn Maynard 630c84d0c1 SetProperty 2006-11-30 02:52:41 +00:00
Glenn Maynard 8542b7d190 GetNextStreamFrame -> GetNextSourceFrame 2006-11-29 21:52:31 +00:00
Glenn Maynard e3b98efd66 GetNextStreamFrame, GetStreamToSourceRatio implementations 2006-11-29 08:15:22 +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 20b8bbecf0 RageSoundReader_Resample_Good 2006-11-29 02:25:20 +00:00
Glenn Maynard 3e11c3ca8e create RageSoundReader_Resample_Good directly 2006-11-29 02:20:42 +00:00
Glenn Maynard 7a95f5da5b covariant Copy() 2006-10-20 00:01:18 +00:00
Glenn Maynard e206261b80 ARRAYSIZE -> ARRAYLEN 2006-09-13 03:11:38 +00:00
Steve Checkoway a07e194cf1 Revert. Fixes Linux build. 2006-07-18 05:51:37 +00:00
Jason Felds 366c3440d4 Fix VC8 macro redef warning. (more to come) 2006-07-18 03:56:37 +00:00
Glenn Maynard 9c4d7606cf ToLower -> MakeLower 2006-03-01 00:39:32 +00:00
Chris Danford 7f821e8cfc CString -> RString 2006-01-22 01:00:06 +00:00
Chris Danford bb6592a4e7 use float.h and limit.h constants instead of arbitrary large numbers 2005-03-25 20:01:51 +00:00
Glenn Maynard 33d92faeb1 fix reading mono sounds in a stereo chain 2004-11-02 07:38:24 +00:00
Glenn Maynard 638a5fd89d fix assertion failure 2004-11-01 07:47:38 +00:00
Glenn Maynard f0ec9ebbd6 fix assertion failure 2004-11-01 06:46:46 +00:00
Glenn Maynard c21d4c2756 simplify a bit, optimize 2004-10-28 05:10:47 +00:00
Glenn Maynard 206ce1aa0b stop going to lengths to avoid copying sounds in the BGM; copying
needs to be fast, anyway
2004-10-26 19:10:57 +00:00
Steve Checkoway 9582577d84 Fix warnings. 2004-10-25 03:44:28 +00:00