GGSound: a lightweight sound engine for games

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

Moderator: Moderators

User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

Turns out there wasn't much in the script incompatible with Python 2.x. The only problem (known) was that I was relying on Python 3's default behavior of outputting a float value when you divide one integer by another. The fix was to add .0 in the values in the NTSC and PAL tempo calculations.

Hamtaro---should work in Python 2.x now, let me know if you try it out (re-uploaded the distro in the OP, with description of change in the readme file)
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: GGSound: a lightweight sound engine for games

Post by tepples »

To force Python 3 division behavior in Python 2, include the following future statement at the top of the program, after the shebang line (if present), other comments (if present), and the module docstring (if present), but before any code or other imports:

Code: Select all

from __future__ import division
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

Added support for note cuts to the converter (distro updated in OP). I hadn't used these very much in my compositions until now, now that I'm using them a lot it was pretty cumbersome to have an instrument that acts as a note cut with a silent volume envelope. This is much nicer.
User avatar
Hamtaro126
Posts: 818
Joined: Thu Jan 19, 2006 5:08 pm

Re: GGSound: a lightweight sound engine for games

Post by Hamtaro126 »

Would there be a chance to add more support for the Bxx Loop Command?

For example, If there is a song that starts with a intro, it supposed to use B01, or maybe B02, or so on... but currently only B00 is supported. That would help if it gets added!
AKA SmilyMZX/AtariHacker.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

That's a good idea hamtaro. I'd find this useful as well, I'll consider adding it soon.
alekmaul
Posts: 54
Joined: Tue Apr 24, 2012 12:22 pm
Contact:

Re: GGSound: a lightweight sound engine for games

Post by alekmaul »

Hello, I'm trying to use your GGSound engine with cc65.
Currently, I have one question : is there a way to pause a music, and also to stop it to start it again from the beginning ?
alekmaul
Posts: 54
Joined: Tue Apr 24, 2012 12:22 pm
Contact:

Re: Gradual Games Sound Engine re-release

Post by alekmaul »

GradualGames wrote: Still no arpeggios or DPCM---primarily because I do not intend to use either in my own projects. If you try out GGSound and enjoy its features and ease of use, but would like these features, please post in this thread and I will add them.
.
Yes, that will be a great thing if you add add that to the converter and sound engine.
I'm currently using it with ca65/cc65 and it is really great !
ggf1979
Posts: 3
Joined: Thu Mar 03, 2016 12:11 pm

Re: GGSound: a lightweight sound engine for games

Post by ggf1979 »

This is great! I'm glad you are working on more features. I too would like to get arpeggios (0xx?) and DPCM, please. That would be a boon to the work I've already done on 11 songs for the project we are working on. I'm currently still playing around with everything but noticed that the FT volume lane doesn't work (but I haven't tried Exx yet). Also, pitch, portemento, and tremolo seem to not work, I think it's 1xx,2xx,3xx, and 4xx. Are any of these types of pattern effects possible or would that be too much of a bother? Thank you so much for your work! Please, don't lose interest! :D I'm sorry for asking for so much!
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

Thanks for the interest in GGSound guys. Of the current outstanding feature requests, I can add:

-Using Bxx for allowing song intros to work.
-Pause feature.
-DPCM.
-envelope based arpeggios.

These in addition to the existing feature set would be the max feature set I will allow in GGSound. Going much beyond this would get closer to something like FamiTracker's own NSF driver, and use enough cpu time and rom space it'd not really be a "lightweight" game sound engine any longer. I'll update this thread and the distro once these features are added.
Last edited by GradualGames on Sun Mar 13, 2016 1:56 pm, edited 4 times in total.
alekmaul
Posts: 54
Joined: Tue Apr 24, 2012 12:22 pm
Contact:

Re: GGSound: a lightweight sound engine for games

Post by alekmaul »

Thanks a lot !
That is exactly what I need for my project :D !
Hope you will have success adding these features :)
ggf1979
Posts: 3
Joined: Thu Mar 03, 2016 12:11 pm

Re: GGSound: a lightweight sound engine for games

Post by ggf1979 »

GradualGames wrote:Thanks for the interest in GGSound guys. Of the current outstanding feature requests, I can add:

-Using Bxx for allowing song intros to work.
-Pause feature.
-DPCM.
-envelope based arpeggios.
This much is awesome and I thank you! Is there a limit to how many instruments I can put in a song or limit to how many songs in a single file? These were limitations from Famitone that having a larger full game soundtrack can kinda run into for an effects heavy composer like myself.
GradualGames wrote: These in addition to the existing feature set would be the max feature set I will allow in GGSound. Going much beyond this would get closer to something like FamiTracker's own NSF driver, and use enough cpu time and rom space it'd not really be a "lightweight" game sound engine any longer. I'll update this thread and the distro once these features are added.
Yeah, I thought as much. I'm still kinda groking NES hardware and such but I figured the overhead would be way too much. I was thinking though, perhaps converting channel effects; to something like envelope->macro data or similar; might work rather than trying to make the engine work as hard as the nsf engine would? My NES ASM-fu-jitsu is blue belt at best so I'm just assuming that the macros generated from envelops are used to make the ASM opcodes for the APU effects to work, correct me if I'm wrong. It's probably more work than either of us are interested in but since I'm working on Unity versions in Famitracker as well as multiple retro-console ROM versions of games' soundtracks, it would help me keep all of my notation using famitracker and deflemask in one place and have to tweak less for each system after the Unity version is composed. Again, sorry for suggesting so much and I'm more than willing to do whatever work I need to make things work for me, just looking for the easiest possible solution for my future needs. Thanks again!
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

Yeah, basically the primary problem is you have these miniature state machines running for each stream: square 1, square 2, triangle, noise, and DPCM, every frame. Those state machines handle volume, pitch, duty envelopes and dpcm sound effect priority (just added, not yet released in distro), each of which are simple to execute. If I were to go beyond this and add additional features that could do a "secondary" modification of various settings such as the effects famitracker offers *on top* of instrument envelopes/sequences, we're talking yet more state machines working in concert for every stream. It's certainly doable, but like I said we'd be getting into a more heavy lifting kind of engine at that point. In addition to running these additional state machines there'd have to be some kind of tweening or combination of values going on as well.

It's also conceivable to write a much more sophisticated famitracker text-to-asm converter which could create all possible permutations of each instrument and effects based on usages in your song, but then the data would get huge and I kind of shudder to think of the complexity that would introduce into my script.

I'd be surprised if any other game sound engine goes much beyond basic instrument execution and into effects. I'm sure some do. As for myself, I'm more than satisfied with soundtracks that are good not because they wow you with portatos, arpeggios and other such "shock and awe," but are elegant and beautiful much the way a mozart piano sonata might be. So...after I add the above listed features, GGSound will be feature complete. If you're looking for much higher sophistication musically/effect wise, I'd recommend using FamiTracker's own nsf driver. Not sure how easy it would be to use sound effects with that, however.

Thanks again for the interest guys! Cool thing is, I'd never had a reason to look into DPCM. I still don't think I'm going to be using it in my own games, but it was cool to look into it and finally see how to use it.

*edit* I realized you asked about song and instrument limitations. I believe you can have 128 instruments as those are represented as lists of words using an 8 bit index. Same for songs. 128 of each thing. Envelopes can be 256 bytes long. I don't recall if FamiTracker has any limitations which would prevent taking full advantage of GGSound's limits or if they exceed them. I should probably list these facts next time I update the distro.
ggf1979
Posts: 3
Joined: Thu Mar 03, 2016 12:11 pm

Re: GGSound: a lightweight sound engine for games

Post by ggf1979 »

GradualGames wrote:Yeah, basically the primary problem is you have these miniature state machines running for each stream: square 1, square 2, triangle, noise, and DPCM, every frame. Those state machines handle volume, pitch, duty envelopes and dpcm sound effect priority (just added, not yet released in distro), each of which are simple to execute. If I were to go beyond this and add additional features that could do a "secondary" modification of various settings such as the effects famitracker offers *on top* of instrument envelopes/sequences, we're talking yet more state machines working in concert for every stream. It's certainly doable, but like I said we'd be getting into a more heavy lifting kind of engine at that point. In addition to running these additional state machines there'd have to be some kind of tweening or combination of values going on as well.

It's also conceivable to write a much more sophisticated famitracker text-to-asm converter which could create all possible permutations of each instrument and effects based on usages in your song, but then the data would get huge and I kind of shudder to think of the complexity that would introduce into my script.

I'd be surprised if any other game sound engine goes much beyond basic instrument execution and into effects. I'm sure some do. As for myself, I'm more than satisfied with soundtracks that are good not because they wow you with portatos, arpeggios and other such "shock and awe," but are elegant and beautiful much the way a mozart piano sonata might be. So...after I add the above listed features, GGSound will be feature complete. If you're looking for much higher sophistication musically/effect wise, I'd recommend using FamiTracker's own nsf driver. Not sure how easy it would be to use sound effects with that, however.

Thanks again for the interest guys! Cool thing is, I'd never had a reason to look into DPCM. I still don't think I'm going to be using it in my own games, but it was cool to look into it and finally see how to use it.

*edit* I realized you asked about song and instrument limitations. I believe you can have 128 instruments as those are represented as lists of words using an 8 bit index. Same for songs. 128 of each thing. Envelopes can be 256 bytes long. I don't recall if FamiTracker has any limitations which would prevent taking full advantage of GGSound's limits or if they exceed them. I should probably list these facts next time I update the distro.
Thanks for looking into it all and I'm glad you found the DPCM groking and implementation interesting.

To be of little help, I can't find limits for Famitracker as such and some of the old limitations aren't listed on the Famitracker site FAQ as if they were removed and maybe are irrelevant to the project file, since that isn't NES specific but using whatever file system the OS uses.

http://famitracker.com/wiki/index.php?t ... _Questions

The old instrument limit was 64 and that was listed in the instrument section of the FAQ quite a while back. I think they may have lifted that limit for project files and I think the project files would have pretty vast limits, if any. FTM export not so much but I can't find that on the wiki; as well as actual game and ROM or flashcart usage, it's probably limited by combination of the NES/hardware with any fancy cartridge hardware (or an emulator's implementation of the two), and the sound engine and how it's converter works (something like that). The version of Famitone2 we were using was limited to 64 instruments and 16 songs so you beat that one. Since we are also limited to whatever flashcart hardware we can afford, an .NSF engine is probably not as ideal as a simpler solution like GGSound. :)

Thanks again for everything!
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGSound: a lightweight sound engine for games

Post by GradualGames »

All of the following features have been added to the distro in the OP:

-DPCM (supported for one instrument only---if you have more than one instrument with DPCM sample mappings, the behavior is undefined)
-envelope/macro based arpeggios in your instruments, with loop points
-Bxx instead of just B00. Must be present in all channels. This enables you to use a song intro. Forward skip for intros which are not a full frame long are not yet supported.
-Pause/unpause.

Thanks for the requests guys. DPCM and arpeggios may be disabled with two equates at the top of ggsound.inc, FEATURE_DPCM and FEATURE_ARPEGGIOS. If disabling arpeggios, you must set ARPEGGIOS_ENABLED to False at the top of ft_txt_to_asm.py. I did this because as I said I'm probably not going to use these features myself. Happy to provide them for others though, it was fun to code them up.

GGSound is now considered feature complete and no significant new features are planned. Please continue to use this thread for bug reports, and I will also update periodically with any fixes I come up with or improvements/optimizations.
alekmaul
Posts: 54
Joined: Tue Apr 24, 2012 12:22 pm
Contact:

Re: GGSound: a lightweight sound engine for games

Post by alekmaul »

Thanks YOU for this update !
Will test it soon with shiru C lib
Post Reply