summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/nes_apu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/nes_apu.c')
-rw-r--r--apps/codecs/libgme/nes_apu.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c
index 7d2814b3d8..630e71f450 100644
--- a/apps/codecs/libgme/nes_apu.c
+++ b/apps/codecs/libgme/nes_apu.c
@@ -39,19 +39,19 @@ void Apu_init( struct Nes_Apu* this )
39 this->oscs [4] = &this->dmc.osc; 39 this->oscs [4] = &this->dmc.osc;
40 40
41 Apu_output( this, NULL ); 41 Apu_output( this, NULL );
42 this->dmc.nonlinear = false;
42 Apu_volume( this, (int)FP_ONE_VOLUME ); 43 Apu_volume( this, (int)FP_ONE_VOLUME );
43 Apu_reset( this, false, 0 ); 44 Apu_reset( this, false, 0 );
44} 45}
45 46
46void Apu_enable_nonlinear( struct Nes_Apu* this, int v ) 47void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd )
47{ 48{
48 this->dmc.nonlinear = true; 49 this->dmc.nonlinear = true;
49 Synth_volume( &this->square_synth, (int)((long long)(1.3 * 0.25751258 / 0.742467605 * 0.25 * FP_ONE_VOLUME) / amp_range * v) ); 50 Synth_volume( &this->square_synth, (int)((long long)(sq * FP_ONE_VOLUME) / amp_range) );
50 51
51 const int tnd = (int)(0.48 / 202 * 0.75 * FP_ONE_VOLUME); 52 Synth_volume( &this->triangle.synth, tnd * 2.752 );
52 Synth_volume( &this->triangle.synth, 3 * tnd ); 53 Synth_volume( &this->noise.synth , tnd * 1.849 );
53 Synth_volume( &this->noise.synth, 2 * tnd ); 54 Synth_volume( &this->dmc.synth , tnd );
54 Synth_volume( &this->dmc.synth, tnd );
55 55
56 this->square1 .osc.last_amp = 0; 56 this->square1 .osc.last_amp = 0;
57 this->square2 .osc.last_amp = 0; 57 this->square2 .osc.last_amp = 0;
@@ -62,11 +62,13 @@ void Apu_enable_nonlinear( struct Nes_Apu* this, int v )
62 62
63void Apu_volume( struct Nes_Apu* this, int v ) 63void Apu_volume( struct Nes_Apu* this, int v )
64{ 64{
65 this->dmc.nonlinear = false; 65 if ( !this->dmc.nonlinear )
66 Synth_volume( &this->square_synth, (int)((long long)(0.1128 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); 66 {
67 Synth_volume( &this->triangle.synth,(int)((long long)(0.12765*FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); 67 Synth_volume( &this->square_synth, (int)((long long)((0.125 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.1128 1.108
68 Synth_volume( &this->noise.synth, (int)((long long)(0.0741 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); 68 Synth_volume( &this->triangle.synth,(int)((long long)((0.150 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.12765 1.175
69 Synth_volume( &this->dmc.synth, (int)((long long)(0.42545*FP_ONE_VOLUME) * v / 127 / FP_ONE_VOLUME) ); 69 Synth_volume( &this->noise.synth, (int)((long long)((0.095 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.0741 1.282
70 Synth_volume( &this->dmc.synth, (int)((long long)((0.450 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / 2048 / FP_ONE_VOLUME) ); // was 0.42545 1.058
71 }
70} 72}
71 73
72void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) 74void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer )