double speaker_sound_device::update_interm_samples_get_filtered_volume(int volume) { double filtered_volume, tempx; /* We may have one or more interm. samples to go */ if (m_interm_sample_index < RATE_MULTIPLIER) { /* First interm. sample may be composed. */ finalize_interm_sample(volume); /* Subsequent interm. samples will be homogeneous. */ while (m_interm_sample_index + 1 < RATE_MULTIPLIER) { init_next_interm_sample(); m_composed_volume[m_composed_sample_index] = volume; } } /* Important: next interm. sample not initialised yet, so that no data is destroyed before filtering... */ filtered_volume = get_filtered_volume(); init_next_interm_sample(); /* Reset counter to next stream sample: */ m_interm_sample_index = 0; /* simple DC blocker filter */ tempx = filtered_volume; filtered_volume = tempx - m_prevx + 0.995 * m_prevy; m_prevx = tempx; m_prevy = filtered_volume; return filtered_volume; }
static double update_interm_samples_get_filtered_volume(speaker_state *sp, int volume) { double filtered_volume; /* We may have one or more interm. samples to go */ if (sp->interm_sample_index < RATE_MULTIPLIER) { /* First interm. sample may be composed. */ finalize_interm_sample(sp, volume); /* Subsequent interm. samples will be homogeneous. */ while (sp->interm_sample_index + 1 < RATE_MULTIPLIER) { init_next_interm_sample(sp); sp->composed_volume[sp->composed_sample_index] = volume; } } /* Important: next interm. sample not initialised yet, so that no data is destroyed before filtering... */ filtered_volume = get_filtered_volume(sp); init_next_interm_sample(sp); /* Reset counter to next stream sample: */ sp->interm_sample_index = 0; return filtered_volume; }
void speaker_sound_device::update_interm_samples(attotime time, int volume) { double fraction; /* We may have completed zero, one or more interm. samples: */ while (time >= m_next_interm_sample_time) { /* First interm. sample may be composed, subsequent samples will be homogeneous. */ /* Treat all the same general way. */ finalize_interm_sample(volume); init_next_interm_sample(); } /* Depending on status above: * a) Add latest fraction to unfinished composed sample * b) The overshooting fraction of time will start a new composed sample */ fraction = make_fraction(time, m_last_update_time, m_interm_sample_period_secfrac); m_composed_volume[m_composed_sample_index] += volume * fraction; m_last_update_time = time; }