diff options
Diffstat (limited to 'apps/codecs/libgme/nes_namco_apu.c')
-rw-r--r-- | apps/codecs/libgme/nes_namco_apu.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/apps/codecs/libgme/nes_namco_apu.c b/apps/codecs/libgme/nes_namco_apu.c index 0f64d3c84f..34df200bb6 100644 --- a/apps/codecs/libgme/nes_namco_apu.c +++ b/apps/codecs/libgme/nes_namco_apu.c | |||
@@ -68,8 +68,6 @@ void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t nes_end_time ) | |||
68 | struct Blip_Buffer* output = osc->output; | 68 | struct Blip_Buffer* output = osc->output; |
69 | if ( !output ) | 69 | if ( !output ) |
70 | continue; | 70 | continue; |
71 | /* output->set_modified(); */ | ||
72 | Blip_set_modified( output ); | ||
73 | 71 | ||
74 | blip_resampled_time_t time = | 72 | blip_resampled_time_t time = |
75 | Blip_resampled_time( output, this->last_time ) + osc->delay; | 73 | Blip_resampled_time( output, this->last_time ) + osc->delay; |
@@ -85,12 +83,17 @@ void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t nes_end_time ) | |||
85 | if ( !volume ) | 83 | if ( !volume ) |
86 | continue; | 84 | continue; |
87 | 85 | ||
88 | blargg_long freq = (osc_reg [4] & 3) * 0x10000 + osc_reg [2] * 0x100L + osc_reg [0]; | 86 | int freq = (osc_reg [4] & 3) * 0x10000 + osc_reg [2] * 0x100L + osc_reg [0]; |
89 | if ( freq < 64 * active_oscs ) | 87 | if ( freq < 64 * active_oscs ) |
90 | continue; // prevent low frequencies from excessively delaying freq changes | 88 | continue; // prevent low frequencies from excessively delaying freq changes |
89 | |||
90 | int const master_clock_divider = 12; // NES time derived via divider of master clock | ||
91 | int const n106_divider = 45; // N106 then divides master clock by this | ||
92 | int const max_freq = 0x3FFFF; | ||
93 | int const lowest_freq_period = (max_freq + 1) * n106_divider / master_clock_divider; | ||
94 | // divide by 8 to avoid overflow | ||
91 | blip_resampled_time_t period = | 95 | blip_resampled_time_t period = |
92 | /* output->resampled_duration( 983040 ) / freq * active_oscs; */ | 96 | Blip_resampled_duration( output, lowest_freq_period / 8 ) / freq * 8 * active_oscs; |
93 | Blip_resampled_duration( output, 983040 ) / freq * active_oscs; | ||
94 | 97 | ||
95 | int wave_size = 32 - (osc_reg [4] >> 2 & 7) * 4; | 98 | int wave_size = 32 - (osc_reg [4] >> 2 & 7) * 4; |
96 | if ( !wave_size ) | 99 | if ( !wave_size ) |
@@ -99,6 +102,8 @@ void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t nes_end_time ) | |||
99 | int last_amp = osc->last_amp; | 102 | int last_amp = osc->last_amp; |
100 | int wave_pos = osc->wave_pos; | 103 | int wave_pos = osc->wave_pos; |
101 | 104 | ||
105 | Blip_set_modified( output ); | ||
106 | |||
102 | do | 107 | do |
103 | { | 108 | { |
104 | // read wave sample | 109 | // read wave sample |