Commit Graph

25 Commits

Author SHA1 Message Date
Steve Checkoway 60f953f3c1 Fix comments. havn't -> haven't. 2008-01-05 11:56:03 +00:00
Glenn Maynard 8c926086ea fix uninitialized (valgrind warning) 2007-07-20 20:30:15 +00:00
Steve Checkoway b0dcd6c57a int -> float. 2007-01-27 13:24:12 +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 01bc9b4040 cleanup/scope 2006-12-27 09:19:50 +00:00
Glenn Maynard b7faf9c22b cleanup 2006-12-27 09:19:24 +00:00
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 ad5b3543a6 don't scale SetPosition; it's in source frames 2006-12-27 09:13:48 +00:00
Glenn Maynard 73ca8f0a1e remove unused 2006-12-27 09:13:47 +00:00
Glenn Maynard 6e3673affb simplify 2006-12-27 09:11:57 +00:00
Glenn Maynard 461658edff simplify 2006-12-27 07:52:25 +00:00
Glenn Maynard 9f577de2e5 exact ratio (no fixed-point granularity) 2006-12-27 07:51:57 +00:00
Glenn Maynard ee2ab2b0bb remove stale cruft 2006-12-27 05:41:29 +00:00
Glenn Maynard 4ad3f023cd fix looping if iFrames == 0 2006-12-26 23:45:43 +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 ffac3acbca fix up infinite loop at EOF 2006-11-30 21:04:51 +00:00
Glenn Maynard bd639a7547 fix bounds assert 2006-11-30 07:26:34 +00:00
Glenn Maynard a92125f391 remove debug 2006-11-30 06:46:46 +00:00
Glenn Maynard f41362f7a9 SoundReader -> RageSoundReader 2006-11-30 04:19:51 +00:00
Glenn Maynard 6c625a50f1 remove noisy 2006-11-30 04:05:34 +00:00
Glenn Maynard 6874d44a2b add speed change filter 2006-11-30 03:59:02 +00:00