mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-12 15:31:09 +00:00
Moves the LFSR to the LowFrequencyOscillator.
Possibly I should come up with a better name for that?
This commit is contained in:
parent
a5d1941d28
commit
cd2ab70a58
@ -26,3 +26,7 @@ void LowFrequencyOscillator::update() {
|
||||
// Vibrato is relatively simple: it's just three bits from the counter.
|
||||
vibrato = (counter >> 10) & 7;
|
||||
}
|
||||
|
||||
void LowFrequencyOscillator::update_lfsr() {
|
||||
lfsr = noise_source_.next();
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
#ifndef LowFrequencyOscillator_hpp
|
||||
#define LowFrequencyOscillator_hpp
|
||||
|
||||
#include "../../../Numeric/LFSR.hpp"
|
||||
|
||||
namespace Yamaha {
|
||||
namespace OPL {
|
||||
|
||||
@ -21,14 +23,26 @@ class LowFrequencyOscillator {
|
||||
public:
|
||||
/// Current attenuation due to tremolo / amplitude modulation, between 0 and 26.
|
||||
int tremolo = 0;
|
||||
|
||||
/// A number between 0 and 7 indicating the current vibrato offset; this should be combined by operators
|
||||
/// with their frequency number to get the actual vibrato.
|
||||
int vibrato = 0;
|
||||
|
||||
/// A counter of the number of operator update cycles (i.e. input clock / 72) since an arbitrary time.
|
||||
int counter = 0;
|
||||
|
||||
/// Updates the oscillator outputs
|
||||
/// Describes the current output of the LFSR; will be either 0 or 1.
|
||||
int lfsr = 0;
|
||||
|
||||
/// Updates the oscillator outputs. Should be called at the (input clock/72) rate.
|
||||
void update();
|
||||
|
||||
/// Updartes the LFSR output. Should be called at the input clock rate.
|
||||
void update_lfsr();
|
||||
|
||||
private:
|
||||
// This is the correct LSFR per forums.submarine.org.uk.
|
||||
Numeric::LFSR<int, 0x800302> noise_source_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ void OPLL::get_samples(std::size_t number_of_samples, std::int16_t *target) {
|
||||
|
||||
while(number_of_samples--) {
|
||||
if(!audio_offset_) update_all_chanels();
|
||||
if(!(audio_offset_&3)) oscillator_.update_lfsr();
|
||||
|
||||
*target = int16_t(output_levels_[audio_offset_ / channel_output_period]);
|
||||
++target;
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "../../Outputs/Speaker/Implementation/SampleSource.hpp"
|
||||
#include "../../Concurrency/AsyncTaskQueue.hpp"
|
||||
#include "../../Numeric/LFSR.hpp"
|
||||
|
||||
#include "Implementation/Channel.hpp"
|
||||
#include "Implementation/Operator.hpp"
|
||||
@ -60,9 +59,6 @@ struct OPL2: public OPLBase<OPL2> {
|
||||
Operator operators_[18];
|
||||
Channel channels_[9];
|
||||
|
||||
// This is the correct LSFR per forums.submarine.org.uk.
|
||||
Numeric::LFSR<uint32_t, 0x800302> noise_source_;
|
||||
|
||||
// Synchronous properties, valid only on the emulation thread.
|
||||
uint8_t timers_[2] = {0, 0};
|
||||
uint8_t timer_control_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user