DLL to play .NSF using DirectX

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
DLL to play .NSF using DirectX
by on (#100595)
For something my brother is doing, I need a DLL to play .NSF file using DirectX. I don't know much about DirectX so I cannot easily do it by myself. Do you know if such things exists or to make up such things? Functions needed are:
  • Play NTSC music using only 2A03 (no expansions are required, although it is OK to support them; it is also OK to support PAL but this is not required).
  • Command play music and pause music.
  • (Optional, but recommended) Command to poke a value into the emulated RAM.
  • All functions must be accessible using only the Delphi "double" and "string" types (it is OK if functions exist not using these types, but you must be able to access them using wrappers with only these two types, as well).

Another question: Do you know if FamiTracker allows poking a value into RAM to play sound effects, or a way to modify it to do so? My brother is using FamiTracker to write these musics.
Re: DLL to play .NSF using DirectX
by on (#100598)
Why DLL and why Direct X? There is Blargg's Game_Music_Emu library that could help you a lot.

It is possible to hook up any sound effects player to FamiTracker music player, you just need to change the music player to use RAM buffer instead of writing audio registers directly (can't remember if it does it already), and use that buffer to mix sound effects. However, if you need it for a PC game, I don't think you should do this, it is certainly more difficult than just run few NSF players at once.
Re: DLL to play .NSF using DirectX
by on (#100603)
Shiru wrote:
Why DLL and why Direct X? There is Blargg's Game_Music_Emu library that could help you a lot.
That seems to be SDL though, and I don't know how to work DirectX. (I could add the wrappers for Delphi's "double" and "string" types myself though, if I knew how to represent these types in C, which I don't! But I could do it if you told me what it is.)

Quote:
It is possible to hook up any sound effects player to FamiTracker music player, you just need to change the music player to use RAM buffer instead of writing audio registers directly (can't remember if it does it already), and use that buffer to mix sound effects. However, if you need it for a PC game, I don't think you should do this, it is certainly more difficult than just run few NSF players at once.
It is needed for a Windows game (don't say "PC game" since it requires an operating system too and won't run with just the PC BIOS). If poking values into memory doesn't work, he says he wants a function to enable and disable individual channels, instead.
Re: DLL to play .NSF using DirectX
by on (#100606)
Is that sentence about Windows/PC game was really necessary?

You should understand that you basically need two separate things that rarely combined into a single DLL. One is NSF player, code that emulates 2A03 and renders audio stream piece by piece into a memory buffer. It could be GME, or any Winamp NSF plugin. Another is audio streamer, code that takes audio data from memory or file and sends it to the sound card. It is OS or HW dependant part, it could be SDL, DirectX, etc. Usually you don't have this part in a DLL, instead you have it in your main code, then use a library (that could be linked either statically or dynamically) to render audio data into a buffer and the code to play the buffer.
Re: DLL to play .NSF using DirectX
by on (#100607)
Well, it needs to be in a single DLL, because the programs my brother is using requires this. He said he already found one that uses Winamp but he doesn't want to install Winamp or require everyone else who plays the game to install Winamp to be able to play this game.
Re: DLL to play .NSF using DirectX
by on (#100608)
It sounds like he uses Game Maker. In any case, there is no need to install WinAmp to use its plugins. They have simple interface, so you can easily hook them up to your project. However, they of course contains the player part only, not the streamer.
Re: DLL to play .NSF using DirectX
by on (#100612)
NSFPlay is open source: http://code.google.com/p/nsfplay/

All of the stuff needed to emulate and play NSFs is in the xgm project. You can feed its output to whatever audio API you want, and build a wrapper around it to make a DLL.
Re: DLL to play .NSF using DirectX
by on (#100674)
I don't see why using DirectX for the graphics / user input / whatever forces him to use it for audio as well(?). GME combined with a simple library capable of outputting streamed PCM (BASS, FMOD, or even waveOut) should do the trick. If he really wants to use DirectX for the audio parts as well he'll need to look into XAudio2.
Re: DLL to play .NSF using DirectX
by on (#100677)
mic_ wrote:
I don't see why using DirectX for the graphics / user input / whatever forces him to use it for audio as well(?).
O, OK, I didn't know that; I don't know much about DirectX, so I don't know if you need to use DirectX for audio as well.