How much CPU time a sound engine uses

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Shiru wrote:tepples, I can modify it if you have certain request - like 'put the file in .. dir'
Common practice under Windows is for a program to create a folder within Application Data and drop stuff in there. The proper way to get the path to Application Data is through SHGetFolderPath. It'll look something like this:

Code: Select all

char appData[MAX_PATH];

// SHGetFolderPath documented at
// http://msdn.microsoft.com/en-us/library/bb762181%28v=vs.85%29.aspx
// It fills appData with the path to the folder.
HRESULT err = SHGetFolderPath(NULL, 
                              CSIDL_APPDATA|CSIDL_FLAG_CREATE, 
                              NULL, 
                              0, 
                              appData);

// Then create a folder inside appData into which your app drops stuff.
Common practice under Linux is to create a folder inside the home directory whose name starts with a period and drop stuff in there.

The source code for Lockjaw demonstrates one way to do this.
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Post by thefox »

http://thefox.aspekt.fi/nintendulator-nsf-timing.zip

Here's a special build of Nintendulator (mappers not included) in case anybody needs it. Open the debugger window to view the NSF init/play cycle counts. Note that the debugger window has to be open before the NSF starts for it to display the init cycles. This can be remedied by pressing RESET in the debugger. Also remember to press RESET always after changing songs (by pressing prev/next).
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

Shiru wrote: Bregalad, low average time is important thing, but peak time is also important, because usually it is few times greater than average, and it could introduce noticeable lag into the gameplay. Battletoads is 482 average vs 472 of your engine, but it has 1820 peak time, which is noticeably lower than 4076, so it has less chances to introduce the lag.
This is true, but I'm pretty sure the max is at the begining when initializing all channels, it should take a lot of time to do that, and then the engine don't do that again until you start the next song. So if it would lag during gameplay it would lag one time which isn't all that bad.

Also I was kind of hironic but happy that the worst average of all of my songs were 10 cycles less than the best engine (which is completely negligible by the way). For smaller songs that didn't use all 4 channels, the average would be lower, the lowest I got was in the 350s.
Useless, lumbering half-wits don't scare us.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

"Initializing all channels" happens whenever the next pattern starts. "Starting the next song" happens during gameplay when the player enters a new area or certain events happen, such as time or oxygen running low or approaching the boss's room.
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

tepples, I know what the MSDN is, etc. Just tell me what exactly you need, not what common practices are. Alternatively, you can do the changes by yourself, the place is /src/machine/nsf.c, line 383.
Post Reply