I've been working on my side-scroller now for awhile and I have come to the point where I want to start adding sfx and music. The problem is, I'm not sure how to go about it. MCK is to slow for a game, NT2 won't run correctly on my machine. I would write my own playback code if I knew where to start.
So what's a viable option for music and sound fx for an actual game? How would I go about writing my own playback stuff (doesn't need DMC support beacuse my game runs on a Mapper #0 cart and I want to save memory).
Any input would be greatly appreciated.
NT2 will become usable if it isn't already. Running it with VDMSound works for me, though it's a tad bit inconvenient. I know someone who has ported NT2 to win32, surprisingly. I just tested it the other day and it seems to work fine natively. It looks and runs the same as it used to. It'll be on the NT2 site once he has a version ready. I could ask him to pass you a test copy if you want.
NT2 is pretty effecient with it's RAM and CPU use. The main thing to watch out for though is CPU usage spikes depending on what plays on the first line of a new pattern. Sound effect support can be added pretty easily, I've done it probably the same way Matrixz did in NeSnake 2. Which was changing the sound register writes in NT2's code to write to RAM, then you can overwrite it if you want to play sfx.
There's another tracker here also:
http://2a03.org/forum/viewtopic.php?id=365&p=1
It's new, I haven't taken the time to test it's code yet. If you do, let me know how it looks for game usage.
Quote:
NT2 will become usable if it isn't already. Running it with VDMSound works for me, though it's a tad bit inconvenient. I know someone who has ported NT2 to win32, surprisingly. I just tested it the other day and it seems to work fine natively. It looks and runs the same as it used to. It'll be on the NT2 site once he has a version ready. I could ask him to pass you a test copy if you want.
Yes. I got NT2 working and I got nedplay working. I would like to have the win32 version beacuse I still get odd error messages on exit and some other oddities. So yea, I think I want to try that test copy, and maybe let me know were to find its final version when its done.
Quote:
NT2 is pretty effecient with it's RAM and CPU use. The main thing to watch out for though is CPU usage spikes depending on what plays on the first line of a new pattern. Sound effect support can be added pretty easily, I've done it probably the same way Matrixz did in NeSnake 2. Which was changing the sound register writes in NT2's code to write to RAM, then you can overwrite it if you want to play sfx.
I'm looking at the play back source code. You say I should replace the writes to the $40xx sound registers with writes to my own memory in RAM, then in my own game, I can either write whats been written by the music player, or just write my own sound effects. Sounds good but that's alittle bit of work and I was wondering if the modyfied source for that was laying around anywhere. What's the base address for all of the RAM used by the ned play back program? I'm starting to get alittle confused...
Well... time to start getting used to using NT2. I've never used a tracker like this before.
I just wrote my own sound code several weeks ago. It took me just one day, and it's cool because you can input all feathures you like, and avoid feature you dislike, to prevent wasting RAM and ROM. Typically, I hate the arpeggio effect, and I'll never use it in any of my musics, so I don't need a sound code who can do that. Same goes with DMC support, vibratoes, etc...
To start, you first have do design yourself how to encode music, with 12 different possible notes, and many different possible timelenghts. You can fix yourself if you use the hardware decay for square channels, or if you prefer do volume in software, if you want to use the timer of the triangle channel or if you prefer time it in software, etc, etc....
For the sound effects, I just duplicated all channels exept triangle, and then if the sound effect channel is active, the music channel writes are ignored.
Well, I've started transposing a song to NT2 but I can't fine tune the tempo. The tempo I want is 170 BMP which is in between setting $F02-03. I spaced my notes out to allow for 32nds. Hmm..... Any suggestions?
Bregalad : Maybe I'll butcher the ned player source and take the DMC stuff out. Might save some space. Since this is for a small game, it is not needed. Also, do you type out the raw hex values for your sound code you metioned or do you use some kind of editor.
I did just make my data with .db, if it is that you want to know.
Actually, I dislike NT2 pretty much. It is hard to understand how it works, and it has pretty bad features (well, it has good features for the pitch, but very bad features for the volume, and I think the volume is more important), and had a lot of glitches while saving/loading song, and eventually it plays its own songs badly, and anyway it works very bad under Win2000, like every DOS programm I have that make sounds (it has pop and ckacks). Eventually, if you want to include it in a game it wastes a lot of ROM space, and it can't playback sound effects until you modify the code. Also you're forced to use CA65 if you want to change the code, except if you rewrite the whole code for another assembler, in that case you've better to write your own code.
Well, to do the tempo, myself, I just had running this :
Code:
lda TempoCounter
clc
adc TempoValue
sta TempoCounter
If the carry is set, you have to decrease all the timers for all tracks, the tempo value can be anything but zero, and the tempo ran be ruled with a high precision with this method. It can even be modified by the main code to do effects like Battletoads (where the music sometimes fast up) or Chrono Trigger (where the music sometimes slows down). I'm pretty sure NT2 doesn't use this.
Anonymous wrote:
Well, I've started transposing a song to NT2 but I can't fine tune the tempo. The tempo I want is 170 BMP which is in between setting $F02-03. I spaced my notes out to allow for 32nds. Hmm..... Any suggestions?
At 60 Hz, what you want is 450 / 170 = 2.647 ticks per 32nd note.
This pattern, which you might put out of the way in the DMC or noise channel, will give you 2.5 ticks per 32nd note or 450 / 2.5 = 180 BPM:
Code:
--- -- F02
--- -- F03
--- -- ---
--- -- F02
--- -- ---
--- -- F03
--- -- ---
--- -- F02
--- -- ---
--- -- F03
etc.
This pattern will give you 2.65625 ticks per 32nd note or 169.41 BPM:
Code:
--- -- F02
--- -- F03
--- -- ---
--- -- F02
--- -- F03
--- -- ---
--- -- F02
--- -- F03
--- -- ---
etc.
nice!
is this final version of the port? of will there be more fixes?
but anyway as I said before, nice!
Memblers wrote:
Thanks! Now I can finally get back into NES music.
dXtr wrote:
nice!
is this final version of the port? of will there be more fixes?
but anyway as I said before, nice!
Sounds unbelievable, but there could be. The person who ported it said if there are any requests, to email him (the email address is in NT2.txt in the credits section near the bottom).
Memblers wrote:
Sounds unbelievable, but there could be. The person who ported it said if there are any requests, to email him (the email address is in NT2.txt in the credits section near the bottom).
k. mostly wonderd b/c it semed to ficker/flicker (don't no which word to use
) when drawing the screen (but that can always just be my screen and there by nothing to care about). nothing important anyway.
edit:
tested to run it fullscreen and then everything was ok. so I guess it's only in window mode.
Sorry, I didn't feel like I needed start a new thread. Anyways...
I ended up making my own playback code. You can check out a demo here
http://mbrenaman.com/soundy.zip.
I just have one question. Which sound emulator is the most accurate? Beacuse in some emulators, when I update the period for vibrato notes, the wave form of the note gets reset with every write to the period registers. The NSF Winamp plugin doesn't do this nor Nesten. I haven't tried Nintendulator with the sound on beacuse it runs pretty slow on my machine.
Sounds good.
I don't know which emu is most accurate, but on the real system writing to $4003/$4007 will reset the duty cycle and envelope (likewise for $400B and $400F too).
Looks fairly good, actually it even is more advanced than the write I wrote on myself that is only focused on volume and that doesn't allow pitch effects at all for now (I'll surely do a second version someday).
The music is cool, in Bubbleman style
About the period resed, I think you should avoid re-writing to $4003/$4007 during a note, exept if you want do this to have a grumble effect like Just Breed does. This cause problems for some vibratoes, where the period *should* be resetted anyway because the high 3 bits of frequencey are affected. This cause no problem on the triangle channel, however. (actually, all that stuff make me stay away of vibratoes/slides exept by sweeping hardware for now).
Quote:
Sounds good.
Thanks. You're the first human besides me to hear it.
Quote:
I don't know which emu is most accurate, but on the real system writing to $4003/$4007 will reset the duty cycle and envelope (likewise for $400B and $400F too).
Well, for my vibrato effect I do so. How else could I update the current period. I see other games do the same thing in gnsf but they don't reset the waveform. I must be missing something...
Wow man, yeah, that does sound really good. I like the bass line alot
The whole song has a nice groove to it. Good job!
Quote:
Looks fairly good, actually it even is more advanced than the write I wrote on myself that is only focused on volume and that doesn't allow pitch effects at all for now (I'll surely do a second version someday).
The music is cool, in Bubbleman style
Yea, when I was a kid, I really loved the megaman series music. So you can see I've been watching those tunes in gnsf and kinda adapting the style.
Quote:
About the period resed, I think you should avoid re-writing to $4003/$4007 during a note, exept if you want do this to have a grumble effect like Just Breed does. This cause problems for some vibratoes, where the period *should* be resetted anyway because the high 3 bits of frequencey are affected. This cause no problem on the triangle channel, however. (actually, all that stuff make me stay away of vibratoes/slides exept by sweeping hardware for now).
So should I use the sweep unit to do my pitch changes?
Quote:
Wow man, yeah, that does sound really good. I like the bass line alot The whole song has a nice groove to it. Good job!
Thank you very much. And thank you Bregalad.
Also, I included two songs, if anyone might not have noticed.
Ha, no, I didn't notice that... I missed the whole .nsf itself actually, went straight for the .nes
I noticed there are some sounds that happen when pushing A and B in the .nes file. Are these sounds going to be part of your game?
Quote:
Ha, no, I didn't notice that... I missed the whole .nsf itself actually, went straight for the .nes I noticed there are some sounds that happen when pushing A and B in the .nes file. Are these sounds going to be part of your game?
Kinda, the nes file is a test program for the sound stuff. Pressing A or B makes a test sound, Start resets the music, and Select stops it. The code is setup to play sound effects but only for one channel. That's why I made the test rom to make sure everything worked right, though those specific sounds might not be in my game.
mbrenaman wrote:
Quote:
About the period resed, I think you should avoid re-writing to $4003/$4007 during a note, exept if you want do this to have a grumble effect like Just Breed does. This cause problems for some vibratoes
So should I use the sweep unit to do my pitch changes?
If you write to $4002/$4006 every frame and then write to $4003/$4007 only when necessary, you'll get clicks only around a few pitches, those called A-0, B-0, D-1, F-1, A-1, D-2, A-2, and A-3 in NT2. If you want to make your pitch slides [i]really[i] smooth, try turning on the slide unit only when the period is about to cross a multiple of 256, so that you don't have to write to $4003 except on a new note. It's tricky, but it's probably doable.
tepples wrote:
If you want to make your pitch slides [i]really[i] smooth, try turning on the slide unit only when the period is about to cross a multiple of 256, so that you don't have to write to $4003 except on a new note. It's tricky, but it's probably doable.
See the thread
"Vibrato on square without phase reset" for demo code and a ROM that show exactly how to do this. I might look into modifying Soundy to do this if nobody else does.
blargg wrote:
See the thread
"Vibrato on square without phase reset" for demo code and a ROM that show exactly how to do this. I might look into modifying Soundy to do this if nobody else does.
Yeah, I just remembered that he's got one solution. However, it would work only if you don't use decay unit, sweep units and timelenght counters *at all* in your sound code. This should be okay since you're handling that stuff with software.
The common way to do this is effectively to write to $4002/6 anyway, but to be carefull to write only to $4003/7 if the value is different from the previous ones. This needs more variable, but this can be skipped for triangle and noise channels.
Else, the pitch slides would be okay because you'd write only once to the high frequencey register, and the clicks wouldn't be really noticable, but for vibratoes arround A, the period will *regulary* be reseted, and you'll have very noticable clicks. You can do as blargg says, or else, another fine method is just to xor the frequencey with 1 regulary. You'll be holding only little vibrato dephts, but the period will never be resseted, even with the infamous A2 note, that is $0fe (%000 - %1111'1110) on NTSC, and it definitely can't have depht more than one single step, else it would crunckle.
Quote:
Yea, when I was a kid, I really loved the megaman series music. So you can see I've been watching those tunes in gnsf and kinda adapting the style.
When you was a kid ? I love it right now, personally
Actually, after comparing the two song more seriousely, I think if you would hack Megaman 2 to put your music insted of the original one in Bubbleman stage, nobody would notice it until the final part of the song that is a bit different, exept diehard megaman fans like probably a lot of people in there.
Welp blargg, it seems to work. I've done some more work and added your solution and have uploaded a new version
http://mbrenaman.com/soundy_1_1_0.zip. Works in Nintendulator, hope it'll work on the real thing.
Quote:
When you was a kid ? I love it right now, personally
Actually, after comparing the two song more seriousely, I think if you would hack Megaman 2 to put your music insted of the original one in Bubbleman stage, nobody would notice it until the final part of the song that is a bit different, exept diehard megaman fans like probably a lot of people in there.
I meant that as that was the first time I heard it. I have my own NSF collection that I listen to at my computer. Of course, if anyone here found out I would be the subject of much reticule >ha ha<.
The tunes sound quite similiar indeed though. The difference's are mainly the key (mine - Ab, megaman 2 Bubbleman tune - Eb) and the format of part C. Did I do it on purpose, yes... But it came out more similiar then I expected >hehe<..
Anyways, thanks everyone.
I realized that the new sweep code will prevent sound effects from using the sweep unit. The other limitations aren't a problem for the music driver, but I think this might be since sweeps are very useful for sound effects.
I also found a problem with the NSF, due apparently to the assembler generating bad code (nasty!). I've reported the details privately.
Cool ! This is great if that method was successfull ! I'm gonna to use it someday, and I've now no reason to stay away from vibratoes/slides in the next sound code I'll write. However...
I ask myself why you said #$0f would be written in the sweep units when not wrapping around freq for vibratoes. I understand that the bit 7 should be clear, but scince it's clear the sweep units are totally disabled and have no effect, exept for limited frequency below very small periods (that would be dog whistle or somthing), and bit 3 should be set (down2up sweep) if a frequencey period above $3ff is used (if the 11th bit is set), else the sweep unit will disable the channel when a high period is deteced in up2down mode, even if disabled.
However, writing $08 or $0f shouldn't make any difference, or does it ?
Also, does writing $40 or $c0 to $4017 while clocking the sweep units manyally make any difference ? And when not clocking them, what should it be written to ?
About the sound effects, it's sure the big flaw of this method. All hardware stuff is used to :
- Timelengt conter : Only few games uses it, and it can be done very easily with software, and it can be 100% replaced by software, scince it has a one-frame precision, and scince one APU frame is more or less the same than one PPU frame, it'll have the exact same precision.
- Triangle timer : This timer feathures more precision, (1/4 of an APU frame or am I wrong ?), so it can't be 100% replaced by software. I think a programm that would write every frame a timing value between $1 and $3 in the timer register, the result will be 1/4, 1/2 and 3/4 of a frame (from now I'll cale frame both PPU frame and APU frames, scince I'll consider them to be equivalent), so it can be shorter and make special "buzzy" sound effects. However, I'm not very sure of this.
- Decay unit : This one has sure few precision and I'm sure the software can 100% replace all it's features, with one-frame precision.
- Sweep unit : Here you are where the big problem is. I think the sweep units in slow rates can be easily replaced with software, that allow more precision while sweeping so it's definitely better. But, with very fast value, it's able to refresh the frequencey at 1/2 frame percision, which isn't negligable while doing gruble sound effects and this is probably pretty much needed for a game that would have better SFX than just beeps and bleeps. This allow very fast frequencey variations, and eventually make dynamic and cool effects. I'm very unsure on what would be the best results without using them. Maybe the same precision could be reached if the sound code would be triggered twice per frame : One time with the PPU's NMI, and one time with a frame IRQ. However, scince $4017 is manually clocked, the frame IRQ couldn't work as we wan't it to, so scanline IRQ would be needed.
Any comment/corrections/ideas, blargg ?
I've posted my reply to the thread
"Vibrato on square without phase reset", since your questions are about the technique rather than the Soundy driver.
Well, thanks to blargg, Soundy's been tested on the real NES. I fixed two small bugs and viola
http://mbrenaman.com/soundy_1_1_2.zip
And I suppose that's it. Thank you everyone and I'll thank blargg just one more time.
mbrenaman > don't know if this is an bugg or not.. but if you push the A and B buttons repeatedly really fast you can make the sounds get stuck. it's easiest to do it when the music is off.
Quote:
mbrenaman > don't know if this is an bugg or not.. but if you push the A and B buttons repeatedly really fast you can make the sounds get stuck. it's easiest to do it when the music is off.
Oh man... Sorry about that. Thanks for trying it out. I thought I had fixed it. It should be fixed now plus sounds should also not hang during the transition from music on to music off.
The fixed version is at the same link as above.
EDIT : Darn it, nevermind. I just remembered to try during the transition from music off to on and it screwed up abit.
Ok ok.... sorry about that everyone. I think everything is in order. Same link as above.
Trying for perfection on first releases is inefficient, since this leads to lots of small fixes delivered in a short time frame. As long as what you deliver is usable and clearly maintainable, fixes don't have to be made immediately. Minor bugs are usually acceptable as long as they will be fixed in the next release.
Welp, I hope no more work needs to be done for it, for now, so I can continue with my game. I just wanted to make sure everything was setup perfectly before I started using it in my project. Maybe after I take a break from it I'll put together some documentation on using it.
well my track'n'field fingers didn't make this versions sounds get stuck ^^
so I think you fixed it