This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Is a good think make my own Sound Engine?

Is a good think make my own Sound Engine?
by on (#235132)
Hello,
I'm reading the tutorial to creating my own Sound Engine ( http://nintendoage.com/forum/messagevie ... adid=23452 ), the problem is that link above to download the source code zip doesn't work anymore. Anyone have a working link o the source code to implement that part of the tutorial? I'm trying to figure out how to create the simplest sound engine to play a loop song and some audio fx.

Thanks!
Re: Nerdy Nights Tutorial Source Code
by on (#235133)
My advice for making a sound engine from scratch...

Don't.

Use an existing one.
Re: Nerdy Nights Tutorial Source Code
by on (#235134)
dougeff wrote:
My advice for making a sound engine from scratch...

Don't.

Use an existing one.


Can you link me one? :D
Re: Nerdy Nights Tutorial Source Code
by on (#235135)
I think this is it, by the way.

https://bitbucket.org/ddribin/nerdy-nig ... at=default

I suggest everyone make a copy of this, for posterity sake.
Re: Nerdy Nights Tutorial Source Code
by on (#235139)
Elaborating a bit on dougeff:s answer, i think it can be good to at least make something that does a simple BEEP, just to get in touch with the area. But writing a music and sfx engine from scratch will take a lot of time. I think it's well worth exploring a couple of the already available drivers.

https://wiki.nesdev.com/w/index.php/Audio_drivers

Once you have tried a few of them out, you'll have a fairly good picture of what the rest of them can do just looking at the specs. Then, if you happen to find yourself in the position where none of these drivers provide some feature that you'd like to have, then that's a good time to either make a fork or roll your own.
Re: Nerdy Nights Tutorial Source Code
by on (#235140)
I can sound some beep on NES, but if there are some pre cooked code or sound engine i'm really intetionate to Use it! :D
Re: Nerdy Nights Tutorial Source Code
by on (#235141)
I made a poll, it looks like most people here use famitracker to famitone2.

viewtopic.php?f=6&t=17812

which you can get from Shiru's website

https://shiru.untergrund.net/code.shtml

http://famitracker.com/downloads.php

The nesmaker people are using ggSound (they don't visit this forum). That is another option.

https://github.com/gradualgames/ggsound
Re: Nerdy Nights Tutorial Source Code
by on (#235143)
Thanks!
Re: Nerdy Nights Tutorial Source Code
by on (#235144)
Famitone2 and GGsound are relatively easy to swap out for each other.

Differences are:
-Famitone2 restricts you to keep any DPCM samples in instrument 0. Not a big difference, really.
-Famitone2 restricts you to 17 songs per project file
-Famitone2 restricts you to a note range of C-1 to D-6, which is often within margins of what you need, though not always.
-Famitone2 can't have loop portions in envelopes - this makes vibratos and glissandos a bit trickier to do, but you can still have them.
-Famitone2 can't do quick duty changes, since the duty envelope is restricted to 1
-GGsound restricts you to select 2 channels for SFX. I think Famitone can use any channel for effects at any time, though i might be wrong.
-GGsound requires you to keep the Bxx effect happening in all channels simultaneously - meaning that the pattern from where you wish to loop needs to be a unique instance on every channel.
-Famitone2 has the pattern cut effect, meaning patterns can be of different lenght. GGsound requires patterns to be of equal lenght.
-GGsound can have up to 256 instruments per project file, but it's hard to harness this capability since famitracker can only let you use 64 per project.
There are probably some audible differences in how both engines cut music to make place for SFX; i haven't compared that carefully.

So you need to balance what features you absolutely want/need just a little bit. With a little planning, you can make your famitracker project fairly agnostic towards what sound driver you'll end up using.

Pently is quite different from a user perspective, so take a good look at what style you prefer the most: pently or ggsound/famiton2-style.
One thing that is nice with pently in is the linear vibrato, meaning vibratos don't get as extremely present just because you're in a high pitch.
In the others, you might want to create different instrument copies for the same type of sound every other octave to compensate for this where needed.

Penguin is for being able to do raster effects without a scanline counter, since it is cycle-consistent.

Muse is for using musetracker instead of famitracker, which i haven't tried and can't say anything useful about.
Re: Nerdy Nights Tutorial Source Code
by on (#235153)
dougeff wrote:
My advice for making a sound engine from scratch...

Don't.

Use an existing one.
My advice is to follow that tutorial if you are interested. It's an excellent tutorial and I didn't only learn how to make my own sound engine, but I learned a lot other things and how to become a better programmer in general. Especially as I was totally clueless how these kinds of things even worked.
Re: Nerdy Nights Tutorial Source Code
by on (#235160)
I can see it from both sides. On one hand, getting an audio engine working correctly can be an incredibly difficult, time consuming, and frustrating chore. I wouldn't blame anybody for deciding to use an existing tool to deal with this task.

On the other hand, there were assembly programming skills that I developed from doing it myself that I don't think I would have gotten anywhere else. The nerdy nights audio tutorials are just great programming tutorials generally. and as an professional musician as well as a programmer, I really wanted understand it well enough to make my own.

I do my own because I get a lot of satisfaction out of making it work. That's pretty much why I program anything. I love putting the pieces together and watching it go. but if you're more into the game design aspect and less the software engineering aspect, then by all means use an existing driver.
Re: Nerdy Nights Tutorial Source Code
by on (#235165)
the first thing i did for the NES was build a sound engine that could play back sounds from an array of data. next i took the time to code a VST that i could use to compose music using Ableton Live.

however it was overly cumbersome to use and when it came time to actually make a game, i ended up using the combination of famitracker and famitone. i strongly strongly suggest you do the same.

it's fantastic practice to write an engine, and it's what i used to teach myself 6502 assembly and get more familiar with the hardware and basics of programming. but there are already mature solutions to this problem, and making an NES game is a fairly complex task already. it might be better practice to work on a scrolling engine or something.
Re: Nerdy Nights Tutorial Source Code
by on (#235170)
The programming part to me is the easiest, I already coded all game engine and game code. I've covered almost all part of Nes Dev ( except for Bank Switching ), so I think I can write my own Sound Engine. BUT, I can't play music, I have no idea how music works, so I decided, for now, to use an engine to speed up a little bit my work. Nerdy Nights tutorial are amazing, I learned a lot from there, but the Music part is really really hard to make working. So I will try some pre cooked code for now! :)
Re: Is a good think make my own Sound Engine?
by on (#235171)
As for making your own engine, I would say no and it a wise choice to use an existing one. To make a proper sound engine, you need to understand how to make music and how it works so it will waste more time than anything else ^^;;; You can do for educational purpose but there is good chance that you won't use it.

The only reason to want to make a custom sound engine now would be because you game have some needs that other sound engine doesn't support, which I think would be very uncommon put possible.
Re: Is a good think make my own Sound Engine?
by on (#235172)
Banshaku wrote:
To make a proper sound engine, you need to understand how to make music and how it works so it will waste more time than anything else ^^;;;


This.

Btw I just downloaded GGSound, I will try it as soon as I can. :)
Re: Is a good think make my own Sound Engine?
by on (#235181)
I would suggest that you do the first few chapters of the tutorial, so that you learn about the NES sound channels and how to control them. This way you aren't completely oblivious to the inner workings.

But for actual practical use, I would suggest using an existing library then. After all, just have a look at FamiTone: Those are more than 1000 lines of code.
And that's his second major version. The first version was much less efficient in ROM size, RAM size and CPU time.

Going through the tutorial first was also a good help for later when I decided that I want a music fadeout in my game. FamiTone doesn't provide runtime changes of the volume, but since I knew how the APU works, I was able to intercept FamiTone's buffer arrays to extract, reduce and reinsert the volume values before the variables are written to the APU.
Re: Is a good think make my own Sound Engine?
by on (#235186)
Yes if you have any interest in the APU at all, it is worth to at least read the basic part of the tutorial.

I was very interested how you could make sound out of the NES as it is maybe a bit harder to grasp than graphics. The tutorial shows how to make quite a capable sound driver and you can upgrade it with new features quite easily. It also gave me the necessary knowledge how to do this for other systems with similar sound chips.

That said, it does take time to get things sorted the first time.


One problem with some sound drivers like Famitone is that you have to use a special tracker program to make stuff with it. As for PPMCK you use MML which is probably easier to understand, but it's more designed for composing chiptune NSFs with than to use as a sound driver in a game. With your own sound driver you can design it to take data much similar to MML, or even design your own MML compiler if you want.
Re: Is a good think make my own Sound Engine?
by on (#235188)
Pokun wrote:
One problem with some sound drivers like Famitone is that you have to use a special tracker program to make stuff with it. As for PPMCK you use MML which is probably easier to understand, but it's more designed for composing chiptune NSFs with than to use as a sound driver in a game. With your own sound driver you can design it to take data much similar to MML, or even design your own MML compiler if you want.

Conversely, based on opinions expressed in the topic "Making MML editing more practical":

One problem with some sound drivers like PPMCK is that you have to use a special MML dialect and compiler to make stuff with it, and beginners may find the edit-compile-run cycle unwieldy. As for FamiTone and GGSound you use a tracker which is probably easier to understand, but the FamiTracker default driver is more designed for composing chiptune NSFs with than to use as a sound driver in a game, and many drivers that take FT exports (such as FamiTone2 and GGSound) cannot handle certain effects, bringing back the edit-compile-run cycle. With your own sound driver you can design it to take data much similar to a tracker, or even design your own tracker if you want.

In theory, just about any driver that works with MML can be made to work with FT exports. It just takes the appropriate converter program.
Re: Is a good think make my own Sound Engine?
by on (#235192)
Pokun wrote:
One problem with some sound drivers like Famitone is that you have to use a special tracker program to make stuff with it.

Isn't FamiTracker the go to program for creating NES music anyway? Is there really any serious alternative, so that the restriction to FamiTracker for FamiTone could be considered a disadvantage?
Re: Is a good think make my own Sound Engine?
by on (#235194)
There used to be thefox's Pornotracker / Musetracker.

And several trackers are multi-platform. deflemask, for example.
Re: Is a good think make my own Sound Engine?
by on (#235197)
There's also bananmos:es nerdtracker 2 - which is even hosted by nesdev, apparently: http://nesdev.com/nt2/ - what a lovely and refreshing site to visit in this time and age!
It has some interesting differences and choices for effects. Not sure how viable it is for homebrew since i don't think that was on the roadmap back then. It is storing volume commands in nibble-sized(!!) words while most other drivers omit having a volume column altogether. Running on DOS(box) is fine, but the absence of select/copy/cut/paste is a bit too masochistic for me.

i like that the site still points to parodius for the forums
Re: Is a good think make my own Sound Engine?
by on (#235209)
O.k., there are other programs. But my focus was:
Is there any serious alternative?
Is there a tracker that has at least half of the popularity of FamiTracker, so that restriction to FamiTracker is an actual disadvantage? Or are these all just niche programs to begin with that nobody really uses anyway?
Re: Is a good think make my own Sound Engine?
by on (#235298)
I'm using Famitone 2, really easy to use and with a lot of features that I need for my game. So, for now I will use it and try to import some goof sfx and music. :P
Re: Is a good think make my own Sound Engine?
by on (#235299)
DRW wrote:
Is there any serious alternative?
Is there a tracker that has at least half of the popularity of FamiTracker


There's 0cc-famitracker which is currently the only maintained fork of famitracker, which improves the UI quite a bit and has done some changes to the driver as well (linear vibratos being one, musician-friendly arpeggios being another - both leading to less instrument copy-clutter which is significant considering you can only share 64 instruments across a project). It has been disregarded in some threads on here as even less homebrew-oriented in the past, but i'm curious as to what exactly makes conversion from 0cc-famitracker less viable than vanilla famitracker. I might be missing something, but you'd still export a subset of the features and the song format.

edit:
The linear vibrato style should make it a better candidate for converting to pently. Other drivers would not be what you hear is what you get in that regard, so there's that.
Re: Is a good think make my own Sound Engine?
by on (#235308)
FrankenGraphics wrote:
There's 0cc-famitracker which is currently the only maintained fork of famitracker

0CC-FT is an improvement on FT, but it's no longer "maintained". HertzDevil went on hiatus, jimbo1qaz took it up, and then jimbo1qaz went on hiatus since October.

FrankenGraphics wrote:
It has been disregarded in some threads on here as even less homebrew-oriented in the past, but i'm curious as to what exactly makes conversion from 0cc-famitracker less viable than vanilla famitracker.

The 0CC-FamiTracker text export includes many of the new features. However, as stated in specs.txt: "Bookmarks and the linear pitch setting are not exported to text files." This means a converter cannot tell a song's time signature, which is stored in bookmarks, nor whether the module was authored with linear pitch turned on. I would link to the feature request that I had filed against HertzDevil's fork to include these, but HertzDevil's bug report forum is in "Maintenance Mode" where only administrators can log in:

This board is in 'Maintenance Mode'." /> Okay faithful users...we're attempting to restore an older backup of the database...news will be posted once we're back!
Re: Is a good think make my own Sound Engine?
by on (#235416)
I'm using famitone2 and NESASM3 without any problems, the music is played well and sound effects are ok. I'm using Famitracker to play some samples but when I try to convert a text file or nsf with famitone tool "text2data" or "nsf2data" it give me ALWAYS some error: Error: effect is too long, Cxx at end of the effect may be missing or Parsing error (row 394,col 10): Note is out of supported range (C-1..D-6). I've no idea how to find some .ftm or .nsf that can convert in sfx or music. This is really frustrating, I can't compose, so I need to find pre cooked samples and use it. So, what's the best way to find a sound fx, music archive that I can use for my game? Famitracker had a lot of samples, but nothing that I can convert to famitone :roll: . There is a way to rip the sound from other game and reuse it?

Thanks a lot for any suggests!
Re: Is a good think make my own Sound Engine?
by on (#235419)
Moderators: Please, delete my post if it's inappropriate!

kikutano, you can get some NSFs from this topic or directly from
MrNorbert1994's site.
To properly open an NSF on Famitracker, use the rainwarrior's NSF importer, save the sound as ftm and open it in a newer version of Famitracker for edition.
Remember that as the famitone documentation states: "Every effect should be finished with silence, and C00 command put to the last row of the effect".
Hope it helps.
Re: Nerdy Nights Tutorial Source Code
by on (#235439)
dougeff wrote:
My advice for making a sound engine from scratch...

Don't.

Use an existing one.

Horrible advice. If your goal is to quickly develop something that "just work" then it's OK but if you're more curious and want to have your own features...
Re: Is a good think make my own Sound Engine?
by on (#235455)
Personally, if I wanted to use other people's code, I'd be coding for a modern platform using libraries. A big part of the fun in coding for the NES is doing everything myself.

If you're more focused on results and want to get your game out more quickly, using other people's code is fine, but don't let anyone dissuade you from doing things yourself just because "it's hard" or "it takes time". Do whatever you think will make the development process more enjoyable to you, and don't hesitate to do things differently if you change your mind along the way.
Re: Is a good think make my own Sound Engine?
by on (#235456)
tokumaru wrote:
Personally, if I wanted to use other people's code, I'd be coding for a modern platform using libraries. A big part of the fun in coding for the NES is doing everything myself.

If you're more focused on results and want to get your game out more quickly, using other people's code is fine, but don't let anyone dissuade you from doing things yourself just because "it's hard" or "it takes time". Do whatever you think will make the development process more enjoyable to you, and don't hesitate to do things differently if you change your mind along the way.


I agree, but as I said before, I prefer to spend the time to develop the gameplay and the graphics, maybe someday I will try to develop my own sound engine. But sometime I prefer to not reinvent the wheel, and the sound programming is not my favorite part when I develop games for work. To be honest, now I use Famitone so I can focus my self on the bank switching.
Re: Is a good think make my own Sound Engine?
by on (#235459)
kikutano wrote:
I'm using famitone2 and NESASM3 without any problems, the music is played well and sound effects are ok. I'm using Famitracker to play some samples but when I try to convert a text file or nsf with famitone tool "text2data" or "nsf2data" it give me ALWAYS some error: Error: effect is too long, Cxx at end of the effect may be missing or Parsing error (row 394,col 10): Note is out of supported range (C-1..D-6). I've no idea how to find some .ftm or .nsf that can convert in sfx or music. This is really frustrating, I can't compose, so I need to find pre cooked samples and use it. So, what's the best way to find a sound fx, music archive that I can use for my game? Famitracker had a lot of samples, but nothing that I can convert to famitone :roll: . There is a way to rip the sound from other game and reuse it?

Thanks a lot for any suggests!


You can find samples of making sound effects and songs in Shiru's Chase source code (and probably others)

https://shiru.untergrund.net/software.shtml

And on my github...

https://github.com/nesdoug/18_Music/tree/master/MUSIC
https://github.com/nesdoug/19_SFX/tree/master/MUSIC

And you can probably find some examples in the MojonTwins github (in ogt folders)

https://github.com/mojontwins?tab=repositories
Re: Is a good think make my own Sound Engine?
by on (#235466)
kikutano wrote:
I agree, but as I said before, I prefer to spend the time to develop the gameplay and the graphics, maybe someday I will try to develop my own sound engine. But sometime I prefer to not reinvent the wheel, and the sound programming is not my favorite part when I develop games for work. To be honest, now I use Famitone so I can focus my self on the bank switching.


Wise choice, like mentioned before ;) There is no right or wrong but more about what are "your" goals. If you want to make a game first to learn the rope, making a sound engine will grind your project to an halt. You can make one later if you feel the need to do so. Keep in mind that making your sound driver will require a way to make music later, which means more things to define too (music format, how can the music be composed etc).

@tokumaru

Yes, it's fun to make your own code but if I would have made my own sound driver and had no editor for the music, there wouldn't have been a complete soundtrack for my project ;) So sometime, it depends of your goal. In his case, he just started nesdev so it's not the most important point to work on now. Once he will be confortable with code, he will be able to decide if making a sound engine is something he wants to do. As for myself, nope, don't want to make one, I want to make games :lol:
Re: Is a good think make my own Sound Engine?
by on (#235579)
Most existing sound engines (famitracker, NT2, etc..) were targetted at playing music and not actually be included in a game which means the following :
  • Poor sound effect support (often not at all)
  • Music format wasteful in ROM
  • Sound engine wasteful in RAM and CPU time
  • Supports features you might never use (such as DPCM), wasting ROM and RAM

I know that thanks to famitone and perhaps other concurrent projects this isn't true anymore, but until recently this was enough reasons to make your own engine.
Re: Is a good think make my own Sound Engine?
by on (#235581)
You are right, a lot of those driver, especially if you take the full fledged famitracker with famitone will be wasteful if you are not careful while composing music and I can confirms it since my current project has more than 100k of it :lol: Since my goal was faithful reproduction of the soundtrack, I didn't mind the size and I'm fine with it (cannot tell more details for now, sorry!).

Still, if you write taking care of the limitation like famitone 2 and are careful about what effect you use, you could make music that would be a lot more smaller then what I have right now. Tracker made music has a tendency to creates more data so you have to be careful. Still, it make it easier to make music to so you have to decide were to make a compromise.
Re: Is a good think make my own Sound Engine?
by on (#235584)
dougeff wrote:
kikutano wrote:
I'm using famitone2 and NESASM3 without any problems, the music is played well and sound effects are ok. I'm using Famitracker to play some samples but when I try to convert a text file or nsf with famitone tool "text2data" or "nsf2data" it give me ALWAYS some error: Error: effect is too long, Cxx at end of the effect may be missing or Parsing error (row 394,col 10): Note is out of supported range (C-1..D-6). I've no idea how to find some .ftm or .nsf that can convert in sfx or music. This is really frustrating, I can't compose, so I need to find pre cooked samples and use it. So, what's the best way to find a sound fx, music archive that I can use for my game? Famitracker had a lot of samples, but nothing that I can convert to famitone :roll: . There is a way to rip the sound from other game and reuse it?

Thanks a lot for any suggests!


You can find samples of making sound effects and songs in Shiru's Chase source code (and probably others)

https://shiru.untergrund.net/software.shtml

And on my github...

https://github.com/nesdoug/18_Music/tree/master/MUSIC
https://github.com/nesdoug/19_SFX/tree/master/MUSIC

And you can probably find some examples in the MojonTwins github (in ogt folders)

https://github.com/mojontwins?tab=repositories


Thanks but I can't convert any of those with famitone2 :/ .
Re: Is a good think make my own Sound Engine?
by on (#235595)
Yes. You can. Maybe you need some coaching.

I'm using Famitracker version 0.4.6 and famitone2 version 1.15.

From my github, the 18_Music repository, in the MUSIC folder,

-TestMusic3.ftm is the famitracker file for the songs.
-in famitracker, open the file and export text
(you can see TestMusic3.txt already exists, this is what you would get)
-then, move that .txt file to the famitone2 folder "tools"...you would type in the command prompt...
>text2data TestMusic3.txt -nesasm

and it will output a "TestMusic3.asm" file

You import that file into your nesasm project.


----------

We can talk about sound effects once you clear this hurdle.
Re: Is a good think make my own Sound Engine?
by on (#235599)
dougeff wrote:
Yes. You can. Maybe you need some coaching.

I'm using Famitracker version 0.4.6 and famitone2 version 1.15.

From my github, the 18_Music repository, in the MUSIC folder,

-TestMusic3.ftm is the famitracker file for the songs.
-in famitracker, open the file and export text
(you can see TestMusic3.txt already exists, this is what you would get)
-then, move that .txt file to the famitone2 folder "tools"...you would type in the command prompt...
>text2data TestMusic3.txt -nesasm

and it will output a "TestMusic3.asm" file

You import that file into your nesasm project.


----------

We can talk about sound effects once you clear this hurdle.


Ok it works! My error was to download the file .ftm with "Save As" button and not with the "Download" button of Githut, for some reason the file was corrupt. Anyway I converted the SoundFx too, thanks!
Re: Is a good think make my own Sound Engine?
by on (#235648)
tepples wrote:
use a tracker which is probably easier to understand
MML aside, I don't agree that a tracker is easier to understand than traditional methods. I have no idea how you translate a piece of sheet music to a tracker. Last time I was fiddling with one I couldn't even input all the required characters with my keyboard. Piece of shit software that required obscure keys.

tokumaru wrote:
A big part of the fun in coding for the NES is doing everything myself.
Yes this is definitely one of the reasons I wanted to learn how to make my own sound routine.

Bregalad wrote:
Most existing sound engines (famitracker, NT2, etc..) were targetted at playing music and not actually be included in a game which means the following :
  • Poor sound effect support (often not at all)
  • Music format wasteful in ROM
  • Sound engine wasteful in RAM and CPU time
  • Supports features you might never use (such as DPCM), wasting ROM and RAM

I know that thanks to famitone and perhaps other concurrent projects this isn't true anymore, but until recently this was enough reasons to make your own engine.
These are other reasons.

I did find an MML-based sound driver that was made for making games called NSD.Lib, but it required cc65 if I remember correctly so I ditched it.