svn-id: r48230
This commit is contained in:
Max Horn 2010-03-10 21:03:50 +00:00
parent c97ee14a65
commit 43abd0e019
12 changed files with 37 additions and 40 deletions

View File

@ -31,10 +31,9 @@
namespace Scumm {
Player_MOD::Player_MOD(Audio::Mixer *mixer) {
Player_MOD::Player_MOD(Audio::Mixer *mixer)
: _mixer(mixer), _sampleRate(mixer->getOutputRate()) {
int i;
_mixer = mixer;
_samplerate = _mixer->getOutputRate();
_mixamt = 0;
_mixpos = 0;
@ -69,7 +68,7 @@ void Player_MOD::setMusicVolume(int vol) {
void Player_MOD::setUpdateProc(ModUpdateProc *proc, void *param, int freq) {
_playproc = proc;
_playparam = param;
_mixamt = _samplerate / freq;
_mixamt = _sampleRate / freq;
}
void Player_MOD::clearUpdateProc() {
_playproc = NULL;
@ -185,7 +184,7 @@ void Player_MOD::do_mix(int16 *data, uint len) {
Audio::st_volume_t vol_r = (127 + _channels[i].pan) * _channels[i].vol / 127;
for (uint j = 0; j < dlen; j++) {
// simple linear resample, unbuffered
int delta = (uint32)(_channels[i].freq * 0x10000) / _samplerate;
int delta = (uint32)(_channels[i].freq * 0x10000) / _sampleRate;
uint16 cfrac = ~_channels[i].ctr & 0xFFFF;
if (_channels[i].ctr + delta < 0x10000)
cfrac = delta;

View File

@ -63,7 +63,7 @@ public:
}
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _samplerate; }
int getRate() const { return _sampleRate; }
private:
enum {
@ -86,7 +86,7 @@ private:
uint32 _mixamt;
uint32 _mixpos;
int _samplerate;
const int _sampleRate;
soundChan _channels[MOD_MAXCHANS];

View File

@ -591,10 +591,10 @@ Player_NES::Player_NES(ScummEngine *scumm, Audio::Mixer *mixer) {
int i;
_vm = scumm;
_mixer = mixer;
_sample_rate = _mixer->getOutputRate();
_apu = new APUe::APU(_sample_rate);
_sampleRate = _mixer->getOutputRate();
_apu = new APUe::APU(_sampleRate);
_samples_per_frame = _sample_rate / 60;
_samples_per_frame = _sampleRate / 60;
_current_sample = 0;
for (i = 0; i < NUMSLOTS; i++) {

View File

@ -60,7 +60,7 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return false; }
bool endOfData() const { return false; }
int getRate() const { return _sample_rate; }
int getRate() const { return _sampleRate; }
private:
@ -81,7 +81,7 @@ private:
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
APUe::APU *_apu;
int _sample_rate;
int _sampleRate;
int _samples_per_frame;
int _current_sample;
int _maxvol;

View File

@ -717,14 +717,14 @@ Player_PCE::Player_PCE(ScummEngine *scumm, Audio::Mixer *mixer) {
}
_mixer = mixer;
_sample_rate = _mixer->getOutputRate();
_sampleRate = _mixer->getOutputRate();
_vm = scumm;
_samplesPerPeriod = 2 * (int)(_sample_rate / UPDATE_FREQ);
_samplesPerPeriod = 2 * (int)(_sampleRate / UPDATE_FREQ);
_sampleBuffer = new int16[_samplesPerPeriod];
_sampleBufferCnt = 0;
_psg = new PSG_HuC6280(PSG_CLOCK, _sample_rate);
_psg = new PSG_HuC6280(PSG_CLOCK, _sampleRate);
_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}

View File

@ -89,13 +89,13 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _sample_rate; }
int getRate() const { return _sampleRate; }
private:
ScummEngine *_vm;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
int _sample_rate;
int _sampleRate;
int _maxvol;
private:

View File

@ -1249,7 +1249,7 @@ Player_SID::Player_SID(ScummEngine *scumm, Audio::Mixer *mixer) {
_music_timer = 0;
_mixer = mixer;
_sample_rate = _mixer->getOutputRate();
_sampleRate = _mixer->getOutputRate();
_vm = scumm;
// sound speed is slightly different on NTSC and PAL machines
@ -1314,7 +1314,7 @@ void Player_SID::initSID() {
_sid = new Resid::SID();
_sid->set_sampling_parameters(
timingProps[_videoSystem].clockFreq,
_sample_rate);
_sampleRate);
_sid->enable_filter(true);
_sid->reset();

View File

@ -71,7 +71,7 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return false; }
bool endOfData() const { return false; }
int getRate() const { return _sample_rate; }
int getRate() const { return _sampleRate; }
private:
Resid::SID *_sid;
@ -85,7 +85,7 @@ private:
ScummEngine *_vm;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
int _sample_rate;
int _sampleRate;
int _maxvol;
Common::Mutex _mutex;

View File

@ -42,7 +42,7 @@ Player_V1::Player_V1(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
for (int i = 0; i < 4; ++i)
clear_channel(i);
_mplex_step = (_sample_rate << FIXP_SHIFT) / 1193000;
_mplex_step = (_sampleRate << FIXP_SHIFT) / 1193000;
_next_chunk = _repeat_chunk = 0;
_forced_level = 0;
_random_lsr = 0;

View File

@ -339,7 +339,7 @@ Player_V2::Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr) {
_isV3Game = (scumm->_game.version >= 3);
_vm = scumm;
_mixer = mixer;
_sample_rate = _mixer->getOutputRate();
_sampleRate = _mixer->getOutputRate();
_header_len = (scumm->_game.features & GF_OLD_BUNDLE) ? 4 : 6;
@ -352,7 +352,7 @@ Player_V2::Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr) {
clear_channel(i);
_next_tick = 0;
_tick_len = (_sample_rate << FIXP_SHIFT) / FREQ_HZ;
_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
// Initialize V3 music timer
_music_timer_ctr = _music_timer = 0;
@ -381,11 +381,11 @@ void Player_V2::set_pcjr(bool pcjr) {
if (_pcjr) {
_decay = PCJR_DECAY;
_update_step = (_sample_rate << FIXP_SHIFT) / (111860 * 2);
_update_step = (_sampleRate << FIXP_SHIFT) / (111860 * 2);
_freqs_table = pcjr_freq_table;
} else {
_decay = SPK_DECAY;
_update_step = (_sample_rate << FIXP_SHIFT) / (1193000 * 2);
_update_step = (_sampleRate << FIXP_SHIFT) / (1193000 * 2);
_freqs_table = spk_freq_table;
}
@ -393,7 +393,7 @@ void Player_V2::set_pcjr(bool pcjr) {
* sample rate doubles.
*/
int i;
for (i = 0; (_sample_rate << i) < 30000; i++)
for (i = 0; (_sampleRate << i) < 30000; i++)
_decay = _decay * _decay / 65536;

View File

@ -90,7 +90,7 @@ public:
}
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _sample_rate; }
int getRate() const { return _sampleRate; }
protected:
bool _isV3Game;
@ -101,7 +101,7 @@ protected:
bool _pcjr;
int _header_len;
uint32 _sample_rate;
uint32 _sampleRate;
uint32 _next_tick;
uint32 _tick_len;
unsigned int _update_step;
@ -177,7 +177,7 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _sample_rate; }
int getRate() const { return _sampleRate; }
protected:
@ -289,7 +289,7 @@ protected:
int _header_len;
uint32 _sample_rate;
uint32 _sampleRate;
uint32 _next_tick;
uint32 _tick_len;

View File

@ -30,6 +30,7 @@
#include "sound/mixer.h"
namespace Scumm {
#define FREQ_HZ 236 // Don't change!
#define FIXP_SHIFT 16
@ -55,8 +56,7 @@ namespace Scumm {
#define PROCESS_VIBRATO 5
/* this structure defines a channel */
struct saa1099_channel
{
struct saa1099_channel {
int frequency; /* frequency (0x00..0xff) */
int freq_enable; /* frequency enable */
int noise_enable; /* noise enable */
@ -71,8 +71,7 @@ struct saa1099_channel
};
/* this structure defines a noise channel */
struct saa1099_noise
{
struct saa1099_noise {
/* vars to simulate the noise generator output */
double counter;
double freq;
@ -80,8 +79,7 @@ struct saa1099_noise
};
/* this structure defines a SAA1099 chip */
struct SAA1099
{
struct SAA1099 {
int stream; /* our stream */
int noise_params[2]; /* noise generators parameters */
int env_enable[2]; /* envelope generators enable */
@ -818,7 +816,7 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer) {
_vm = scumm;
_mixer = mixer;
// debug("mixer rate: %d", _mixer->getOutputRate());
_sample_rate = CMS_RATE;
_sampleRate = CMS_RATE;
_header_len = (scumm->_game.features & GF_OLD_BUNDLE) ? 4 : 6;
@ -831,7 +829,7 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer) {
clear_channel(i);
_next_tick = 0;
_tick_len = (_sample_rate << FIXP_SHIFT) / FREQ_HZ;
_tick_len = (_sampleRate << FIXP_SHIFT) / FREQ_HZ;
// Initialize V3 music timer
_music_timer_ctr = _music_timer = 0;
@ -878,7 +876,7 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer) {
_cmsVoices[7].octaveOutput = &(_cmsChips[1].octave[1]);
// inits the CMS Emulator like in the original
g_cmsEmu = new CMSEmulator(_sample_rate);
g_cmsEmu = new CMSEmulator(_sampleRate);
static const byte cmsInitData[13*2] = {
0x1C, 0x02,
0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00,