gdkchan / SNES.net

SNES emulator written in VB.NET
31 stars 16 forks source link

select sound after rom start make the app crash #1

Open foen opened 7 years ago

foen commented 7 years ago

select sound after rom start make the app crash

gdkchan commented 7 years ago

Can't reproduce the issue, but I can imagine that the issue is DirectSound maybe. It may be one of the following reasons:

The graphics can be rendered using GDI so they don't need DirectX at all, althrough you get some speedup using it on higher resolutions. I plan to switch to something like OpenTK for audio playback at some point, to make the emulator cross-platform.

foen commented 7 years ago

did some more testing and its indeed a LoaderLock got some sound now 👍 awesome project will see if I can help but need to dig up snes documentations. opentk idk its vb.net anyways mabey SharpDX ? can be used in vb.net aswell

gdkchan commented 7 years ago

Thanks. It's always nice to see people wanting to contribute to the project, one of the reasons I stopped working on it was because I was working on it alone and without feedback so it's easy to lose motivation. Anyway OpenTK can be used with vb.net and also does SharpDX. I prefer OpenTK cause it works on Linux with Mono too (and even Android!) I made a Android port of this emulator some time ago, the main issue was speed.

SNES docs: General SNES info: http://problemkaputt.de/fullsnes.txt SNES CPU info (65816): https://wiki.nesdev.com/w/images/7/76/Programmanual.pdf SNES APU info (SPC700, very resumed): https://raw.githubusercontent.com/gilligan/snesdev/master/docs/spc700.txt SNES S-DSP info (actual sound generator, quite detailed): http://www.pcedev.net/docs/brr/apudsp.txt

Those are the docs I used while developing the emulators, and are also the best ones I could find. Just let me know if you want to know the current TODOs.

foen commented 7 years ago

ah yeah current TODOs are nice to know. I never worked with opentk did some work with sharpdx. and liked it. I don't have any android device so I have no idea if it will work with Linux.

gdkchan commented 7 years ago

It doesn't work with linux because DirectX is Microsoft technology and is only available on their products (Windows, Xbox...)

About current TODO:

Those are the core related issues I could remember. GUI also needs a lot of work but my priority is fixing core issues first.

foen commented 7 years ago

thx for the ToDo's cos i only play super Mario worlds and it seems to run with 40 fps on my i7-6700 with only 24% used so it should be possible to run it faster 👍 i start reading the documentation it will take a while before i can do something to make the project beter 👎 i could mabey start on the UI. but your work is awesome !

iam starting to look into the sound system cos i hate the cracky noise. think somethings gos wrong here Dim Sampled As Integer = RingDist(BuffAddr, CurrAddr, Input.Length) cos when i change it to Needed it wont make a cracky noise just repeat the other thing

EDIT After reading for 2 hours i found out its not as easy as i thought it would be haha sounds seems to be tricky to emulate cos its not stable 60 fps. loads to learn

gdkchan commented 7 years ago

Note that a few steps are necessary to make the emulator work on max speed. First go to My Project - Compile, click on Advanced Compile Options button and make sure that both "Remove integer overflow checks" and "Enable optimizations" are checked. Then, make sure you compile it as Release, not Debug (debug is twice as slow). Also, it runs faster when I run it outside of Visual Studio here.

Also yea I remember there was something wrong with sound playback.

foen commented 7 years ago

I will try this out ! and see if it help with the sound aswell. and again nice work !

gdkchan commented 7 years ago

I removed HiRes support since it was one of the things that had considerable impact on speed, and just a few games uses it (created a separate branch with the old Hi-Res code too). Let me know if it is running faster on your end now. Also I recommend using the Direct3D renderer since it is faster than GDI at 2x resolution (at 1x its the same thing here). "Color math bugs (Clock Tower bathroom)" seems to be fixed aswell.

foen commented 7 years ago

after I build your last project on release without changing anything it runs on 60fps stable 👍 sound is not making this cracky noise !

after testing your old build on release it seems to work with the same fps ! only some cracky noise after you complete the first level but prob something that's not implemented did add some youtube video to show what is going on : https://youtu.be/X7eLgVF5Ptk

gdkchan commented 7 years ago

Yea, the buffer seems to get ouf os sync at this point (and the audio gets delayed later). The method I used to sync the audio buffer is not very good and produces this kind of problem after some time. I think I'll try implementing the method I used on my gba emulator later (it doesn't seem to have those sync problems, or at least is not as bad).

If you want working on that it would be a pretty nice improvement, through I think that fixing the current DirectSound based implementation is not worth, because we'll need to switch to something else (SharpDX, SlimDX, or OpenTK... Or maybe theres some other I dont know?)

The SMW sound a bit off too, so I guess theres some bug on the DSP emulation code (or maybe the missing features make that much difference?)

foen commented 7 years ago

After testikg street fighter the sync issue also happen at switch of a level is like the snes dos something at that point the emulator dosnt like

salvadorc17 commented 7 years ago

I got error when selecting directsound option, can play some games but without sound enabled.

gdkchan commented 7 years ago

Which error? See my first post, may be the same error foen got.

foen commented 7 years ago

Prob same crash still trying to get it in sync no huge break tru

salvadorc17 commented 7 years ago

So which managed directx dll does this use, becuase seems all options make this crash to me.