ericmckean / game-music-emu

Automatically exported from code.google.com/p/game-music-emu
GNU Lesser General Public License v2.1
0 stars 0 forks source link

NSF music broken in single-precise fpu mode #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. set the fpu precise mode to single-precise (like call D3DCreateDevice
without D3DCREATE_FPU_PRESERVE)
2. play nsf music with gme library
3. you will hear the music broken with a lot of noise

What version of the product are you using? On what operating system?
VC2008 SP1 winxp.  My project is a D3D application.

Please provide any additional information below.
I debug into the gme code , i find some of variables are INF in float,
in the function Blip_Synth_::treble_eq
the fimpulse[] array start fill with INF after index 250~300
and the variable "total" is INF . so the noise's impulses fill with wrong data.

Finally I use _controlfp(_PC_53,_MCW_PC); and it works...

I copy the call stack here (My project is not gmp ,but I take it for exmaple):

>   gmp.exe!Blip_Synth_::treble_eq(const blip_eq_t & eq={...})  行317  C++
    gmp.exe!Blip_Synth<8,1>::treble_eq(const blip_eq_t & eq={...})  行196 +
0x2f 字节 C++
    gmp.exe!Nes_Apu::treble_eq(const blip_eq_t & eq={...})  行45   C++
    gmp.exe!Nsf_Emu::update_eq(const blip_eq_t & eq={...})  行335  C++
    gmp.exe!Classic_Emu::set_equalizer_(const gme_equalizer_t & eq={...}) 
行41 + 0x2c 字节 C++
    gmp.exe!Music_Emu::set_equalizer(const gme_equalizer_t & eq={...})  行95
+ 0x13 字节   C++
    gmp.exe!Nsf_Emu::Nsf_Emu()  行52   C++
    gmp.exe!new_nsf_emu()  行127 + 0x6b 字节 C++
    gmp.exe!gme_new_emu(const gme_type_t_ * type=0x0049dd70, long rate=44100)
 行169 + 0xa 字节    C++
    gmp.exe!gme_open_data(const void * data=0x0011fd98, long size=749,
Music_Emu * * out=0x003f6000, long sample_rate=44100)  行112 + 0xd 字节  C++

Original issue reported on code.google.com by Yuki...@gmail.com on 16 Oct 2009 at 11:56

GoogleCodeExporter commented 9 years ago
I can confirm that using single precision arithmetic on the 387 coprocessor 
causes 
incorrect sound generation (it's easier to see using the gme_player sample 
application since it gives you a waveform)

Applicable gcc compiler flags for Linux are -mpc32 (to enable single-precision 
FPU) 
and -mfpmath=387 (to force the FPU to be used instead of SSE)

I'm not sure the best way to fix it in the code but it seems to me that there 
has to 
be some VC++ compiler flag to use a different floating-point backend than the 
FPU for 
this.

Original comment by michael....@gmail.com on 8 Feb 2010 at 3:55

GoogleCodeExporter commented 9 years ago
Oh wow, sorry for not noticing this bug report a while back. I could have sworn 
I
checked the issues list periodically and never saw anything until just recently.
Anyway, revision 31 sound fix this. Please verify that it does. Arrrrgh.

Original comment by gbla...@gmail.com on 8 Feb 2010 at 2:13