mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 16:35:16 +01:00
74f3ee4caf
The following fixes are backported from the Snes9x master branch: - Release msu data and audio streams on exit, use unzClose when closing - Fix MSU-1 channel swap on loop - Ensure all MSU-1 reads are stereo channel aligned - Clean up S9xMSU1Generate code - Fix MSU1 swapping. - Fix casting on MSU1 volume - Get rid of "Unable to find msu file" console spam
61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
/* Simple resampler based on bsnes's ruby audio library */
|
|
|
|
#ifndef __RESAMPLER_H
|
|
#define __RESAMPLER_H
|
|
|
|
#include "ring_buffer.h"
|
|
|
|
class Resampler : public ring_buffer
|
|
{
|
|
public:
|
|
virtual void clear (void) = 0;
|
|
virtual void time_ratio (double) = 0;
|
|
virtual void read (short *, int) = 0;
|
|
virtual int avail (void) = 0;
|
|
|
|
Resampler (int num_samples) : ring_buffer (num_samples << 1)
|
|
{
|
|
}
|
|
|
|
virtual ~Resampler ()
|
|
{
|
|
}
|
|
|
|
inline bool
|
|
push (short *src, int num_samples)
|
|
{
|
|
if (max_write () < num_samples)
|
|
return false;
|
|
|
|
!num_samples || ring_buffer::push ((unsigned char *) src, num_samples << 1);
|
|
|
|
return true;
|
|
}
|
|
|
|
inline int
|
|
space_empty (void)
|
|
{
|
|
return buffer_size - size;
|
|
}
|
|
|
|
inline int
|
|
space_filled (void)
|
|
{
|
|
return size;
|
|
}
|
|
|
|
inline int
|
|
max_write (void)
|
|
{
|
|
return space_empty () >> 1;
|
|
}
|
|
|
|
inline void
|
|
resize (int num_samples)
|
|
{
|
|
ring_buffer::resize (num_samples << 1);
|
|
}
|
|
};
|
|
|
|
#endif /* __RESAMPLER_H */
|