Hey everyone,
this is my first GameHero post release. As I already mentioned, I programmed a simple Midi-Player that plays all of the music in my game. I cleaned up the code and removed all of the game logics. Whats left is the basic midi player and some debug output. The zip file includes a binary as well as the complete source code.
The Midi-Player is pretty close to what HorvatM did with his Soviet Union 2011 sound engine, even though our projects are totally unrelated. Actually, our projects are that similar, that I was able to copy most of his introduction text to my project. However, there are major differences in how we handle timing of notes. It basically comes down to this:
– If you want to have sounds in your game you should go with the Soviet Union 2011 sound engine
– If you want to play music in the background you may want to use the GameHero Midi Player
The Midi2VB converter (which is going to be released soon) supports both projects, so the choice is yours.
Even tough both projects look similar, they work together very well. I attached a version of the SU Sound Engine that is able to play sounds as usual but also can use the GameHero MidiPlayer to play music in the background. Therefore, I basically changed nothing in both of our codes. I only used channel 5 for the Midi-Player to avoid interferences.
If someone finds time (not me) it would be a good idea to combine the strength of both systems.
Cheers
thunder
Ohhh… and I am not used to program c so don’t wonder if my code sometimes looks strange (damn pointers).
Attachments:
thunderstruck wrote:
I still need to fix the channel selection though. The SUSE dynamically picks a free channel while the Midi-Player assigns a channel to a specific track. Shouldn’t be to complicated to fix this.
The SU Sound Engine is now fully integrated into the Midi-Player. They seem to work great together. However, the timing of the SU sound engine is still done using the “wait for the next frame” method while the Midi-Player uses interrupts. This means that sound effects may slow down when the VB has some heavy stuff to do while the music isn’t influenced.
I could of course do the timing for the sound effects using interrupts as well. The only problem is that I change the interrupt interval to the bar length of the respective song when I load a new song. So, I guess I will leave it as it is for now.
The next thing to do is to integrate the Midi-Player into Fishbone. This shouldn’t be to complicated.
I have just been listening to Johann Sebastian Bach on my Virtual Boy…
VBmills wrote:
Sounds like your making progress.
Not really. Classical music is just easy to convert. Sounds good though.
I went through the code of my music engine lately and tried to optimize everything a little bit. There was a problem with the fading. I knew I was doing something wrong there so I checked/fixed everything. I did some other small improvements as well. I also optimized the Midi-Converter a little bit but more on a UI level.
I think implementation wise this is the best I can do. Everything else is fine-tuning by using the right waveforms, volumes, octaves and so on.
I tested everything by converting NES music to midi files and then converting the midi files to my VB format. Sounds simple but it is a pretty tedious process and I had to spent $100 on a tool I needed.
I attached a zip file with 3 demos to this post. I think the Zelda music comes pretty close to the original. The StarWars music (I thought Greg might need it) is a little bit off but the source material wasn’t that great either. The SMB3 music also is a little bit of. The notes and timing seem to be right but the some of the notes seem to be too high (or too loud?).
As I said before: I could come closer to the originals by fine-tuning the single tracks. However, that is a tedious job. Also, I’m not really good a listing to music and identifying single notes and stuff.
Well, let me know what you think.
Attachments:
OK as much as a giant leap forward this is. And it is a giant leap for all homebrewers. So I will give you that. However I do think we should all look at the second step. I for one would like someone to study waveforms and make instruments I’m not too sure which instrument you have when you play your midi converter. But I dare say whatever it is I think you’ve mastered it, as far as I can tell. But I think we can go further. I want to hear drums on the VB I want to hear trumpets too. I want to see as many virtual instruments as possible. Hey I may be way off I’m no musician and I’m not a programmer either but that’s the way I see it.
morintari wrote:
OK as much as a giant leap forward this is. And it is a giant leap for all homebrewers. So I will give you that. However I do think we should all look at the second step. I for one would like someone to study waveforms and make instruments I’m not too sure which instrument you have when you play your midi converter. But I dare say whatever it is I think you’ve mastered it, as far as I can tell. But I think we can go further. I want to hear drums on the VB I want to hear trumpets too. I want to see as many virtual instruments as possible. Hey I may be way off I’m no musician and I’m not a programmer either but that’s the way I see it.
I don’t think it is that much of a big leap. Just some optimization since the last release. Personally, I don’t know anything about music. I don’t know how to play instruments nor am I willing to learn. However, writing waveforms for the VB is quite easy. Just figure out what you want, bring it to the VB format and add it to the voices.h file. If you are willing to invest time into you can learn it for sure. I’m still using the instruments that DanB published back in the days.
thunderstruck wrote:
…
Well, let me know what you think.
Sounds great, thunderstruck! Especially the Zelda tracks; very nice…
How do we get our grubby little hands on the updated files? Also, what about the converted MIDIs so we can compare (and maybe get an idea of what the input needs to be)?
RunnerPack wrote:
thunderstruck wrote:
…
Well, let me know what you think.
Sounds great, thunderstruck! Especially the Zelda tracks; very nice…
How do we get our grubby little hands on the updated files? Also, what about the converted MIDIs so we can compare (and maybe get an idea of what the input needs to be)?
Thank you. I will publish all of the sources as soon as the Midi Converter is done. There are still some features missing there (like replay). I don’t know if Kr155e would like me to uploads tons of Midis to this site. I will describe the conversion process in detail though. However, if you use Notation Composer (http://www.notation.com/NotationComposer.php) you will be able to bring your Midi into a convertible format. Just don’t do crazy stuff like playing multiple notes at the same time on one track.
Sounds good to me! 🙂
I hope we don’t have to use that particular (and quite expensive) editor, though… There are many free, open-source ones that are quite usable. Many of them are hosted on SourceForge.
RunnerPack wrote:
Sounds good to me! 🙂I hope we don’t have to use that particular (and quite expensive) editor, though… There are many free, open-source ones that are quite usable. Many of them are hosted on SourceForge.
Most midis and midi tools should just work fine. You can try by using the converter I published. There are only a few that are not supported by the library I use. Importing and exporting them with notation composer fixes this.
Returned to the forums for a bit only to find this! Impressive work, great job so far! (Especially since I hear from some people how annoying MIDI files are constructed. :P)
I’m noticing the notes are (almost?) always an entire octave too high. This seems to go for all instruments, so the Zelda and SMB3 tunes all sound much too high-pitched.
As for the percussion, it might be a good idea to convert those into white noise percussion. Currently the percussion track seems to play regular notes, instead.
DaVince wrote:
Returned to the forums for a bit only to find this! Impressive work, great job so far! (Especially since I hear from some people how annoying MIDI files are constructed. :P)I’m noticing the notes are (almost?) always an entire octave too high. This seems to go for all instruments, so the Zelda and SMB3 tunes all sound much too high-pitched.
As for the percussion, it might be a good idea to convert those into white noise percussion. Currently the percussion track seems to play regular notes, instead.
Thank you. Those comments are more then welcome. I was thinking about adding an octave fix again. Ben told me that the music might be an octave off before. Not sure how to do a white noise percussion. Would that be a different kind of waveform? How should that one look like?
White noise is actually used a LOT in old consoles for percussion, especially on the Game Boy. It usually consists of short bursts of white noise, accompanied by a quick fade. You can generate white noise with the noise channel; any random noise that channel makes will do fine. If you can set a noise frequency, even better (to distinguish between lower and higher percussion-type sounds).
Attached are some WAV samples of NES and Gameboy white noise percussion. Perhaps they can help.
Also included: a Kick and Tom sound which are actually constructed of square waves that lower their notes and fade out quickly. This also creates percussion-like sounds.
Speaking of using other noises… Have you experimented trying to give different MIDI instruments different sounds? I’d imagine that setting a MIDI channel to bass and then having an appropriate bass-like sound coming from the player could work really well for the general sound.
Attachments:
DaVince wrote:
White noise is actually used a LOT in old consoles for percussion, especially on the Game Boy. It usually consists of short bursts of white noise, accompanied by a quick fade. You can generate white noise with the noise channel; any random noise that channel makes will do fine. If you can set a noise frequency, even better (to distinguish between lower and higher percussion-type sounds).Attached are some WAV samples of NES and Gameboy white noise percussion. Perhaps they can help.
Also included: a Kick and Tom sound which are actually constructed of square waves that lower their notes and fade out quickly. This also creates percussion-like sounds.
Speaking of using other noises… Have you experimented trying to give different MIDI instruments different sounds? I’d imagine that setting a MIDI channel to bass and then having an appropriate bass-like sound coming from the player could work really well for the general sound.
Never used the noise channel on the VB but I will definitely try it out. Thanks for all the samples.
I actually use different waveforms for different instruments. The music in the sample uses squares for everything though. It is really hard for me to compare the original music and my results.
Oh, okay. I was wondering since the NES Zelda music uses some sine waves for its bass tones (that channel that goes up an entire octave like C1-G1-C2 in the intro theme, for example). But in your example that instrument plays as a square wave indeed. Compare: https://www.youtube.com/watch?v=uyMKWJ5e1kg I also think the main melody is done with a triangle wave? Or perhaps a mix of triangle and square wave, since that melody is playing on two channels, after all.
It also has to be noted that that main tune uses one of those tiny white noise bits for its percussion! So now you’ve got a nice reference of what a hi-hat approximately should sound like.
I also suggest you just keep the original tunes handy in case you want to do a quick comparison. 😉
Edit: I suppose another observation here is that in Mednafen your tune is a bit too slow compared to the original one! Is this because of the input MIDI or is something going on with how the timing is read?
DaVince wrote:
Oh, okay. I was wondering since the NES Zelda music uses some sine waves for its bass tones (that channel that goes up an entire octave like C1-G1-C2 in the intro theme, for example). But in your example that instrument plays as a square wave indeed. Compare: https://www.youtube.com/watch?v=uyMKWJ5e1kg I also think the main melody is done with a triangle wave? Or perhaps a mix of triangle and square wave, since that melody is playing on two channels, after all.It also has to be noted that that main tune uses one of those tiny white noise bits for its percussion! So now you’ve got a nice reference of what a hi-hat approximately should sound like.
I also suggest you just keep the original tunes handy in case you want to do a quick comparison. 😉
Edit: I suppose another observation here is that in Mednafen your tune is a bit too slow compared to the original one! Is this because of the input MIDI or is something going on with how the timing is read?
What I do is I take a nsf file and convert it into a midi file. I use a program from someone else for that as you basically need a NES emulator to read those files. The result does not contain the proper instruments anymore though. So I can only guess what was originally used.
My converter allows me to play the Midi as well as the converted VB track with the click of a button. However, it is really hard for me to compare music. I never played an instrument (other then then my GuitarHero guitar).
I’m not sure about the timing. Maybe there is something lost in the nsf->midi->vb conversion. Maybe my player is not accurate enough. Maybe it is just mednafen. Did you try it on hardware?
No, unfortunately, I can’t test it on hardware… I’m basically a VB fan without a VB. ^^’
I’m sure the NSF->MIDI conversion has some kind of standard in what instrument channels it picks. Perhaps you could base it off that? I suppose if you’re having trouble differentiating the sound of specific tones though, that might be very difficult indeed. Perhaps I can help determine what type of tone what instrument should be if you share the MIDIs you’re using?
DaVince wrote:
No, unfortunately, I can’t test it on hardware… I’m basically a VB fan without a VB. ^^’I’m sure the NSF->MIDI conversion has some kind of standard in what instrument channels it picks. Perhaps you could base it off that? I suppose if you’re having trouble differentiating the sound of specific tones though, that might be very difficult indeed. Perhaps I can help determine what type of tone what instrument should be if you share the MIDIs you’re using?
It seems to either pick squares or piano as an instrument. I just checked some of the NES specs. I might be wrong but for me it sounds like you can only choose between square and triangle waveforms or use the noise channel.
I attached the nsf file as well as the midi I used for the Zelda track. I might have some free time on the weekend to try out some of your suggestions.