It is currently Sun Dec 17, 2017 8:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Jul 18, 2015 3:14 pm 
Offline
Formerly AlienX
User avatar

Joined: Fri Apr 18, 2014 7:41 am
Posts: 137
Location: Bulgaria
Hey, guys! In my "Changing FCEUX's sound with Lua scripts?" thread, I discussed the idea of FCEUX, playing the games' audio, using sound samples, which will allow for a variety of new sounds. After a few days of hard work, I have finished a Lua script, which will do just that. This is...

THE NES SAMPLE-BASED SOUND SYSTEM

This script uses the proteaAudio sound library by Gerald Franz. It reads the NES's sound data, using FCEUX's sound.get() function and recreates it, using files in the .ogg format. As you might have guessed, this can make NES audio sound like something out of a MIDI device, a Sega Genesis, a SNES, a Commodore 64, whatever.
The sample set, I've made, uses edited MIDI instrument samples and some custom ones too. Both Pulse Wave channels have different instruments for each pulse-width. Here's a list of the different instruments:

Square 1
Duty 0 - Tuba
Duties 1 and 3 - Overdriven Guitar
Duty 2 - Flute

Square 2
Duty 0 - Distortion Guitar
Duties 1 and 3 - String Ensemble
Duty 2 - Rock Organ

The Triangle Wave channel uses a custom sample of a square wave, combined with a triangle wave and some effects added in. The Noise channel uses four different samples for the different notes.

You can make your own sample sets too! If you're interested in this project, then I would like to see what ideas you have for different NES sounds. You can post your sample sets on this thread. When making the samples, however, you must follow certain rules:
All samples' frequencies(not including the noise channel ones) must be set to 440Hz(the frequency of an A-4 note). This is because the script takes the channels' frequency and divides it to 440, to get the pitch values for the samples.
All samples must have a "static" sound. This means, that there cannot be any changes in the volume or pitch. Otherwise, they will clash with the NES's own volume and pitch changes and the audio will be pretty crappy. So, no fade-ins, vibratos, etc. You may use filters and cutoff rate changes, but make sure, that the end of the sample sounds like the beginning. The samples are looped and are not replayed with each note, so if, for example, you have a sample, that starts with low cutoff rate and ends with a high one, the sound will probably be jerky, when being played.

FCEUX USAGE: This script generates the sounds on its own, so if you don't want to hear the original NES Audio, disable the Square 1, Square 2, Triangle and Noise channels in FCEUX's sound settings. DO NOT disable the DPCM channel. As of now, the script cannot recreate the DPCM channel, so it won't play it.
Currently, there's support only for the core 2A03 chip, but you can play games, that use additional sound chips and the Audio will still be fine. I will probably add support for the VRC6, the MMC5, the Sunsoft 5B and the FDS(that one, however will require different one for each game).

There are still some flaws, that I hope you can help me iron out. For instance, if you try to stop or restart the script, FCEUX will crash, so the only way to stop the script is to turn off FCEUX itself. Also, the script cannot yet detect whether emulation is paused or not, so when you pause FCEUX, use the menus or try to load a new game, the sound will be sustained.

Check out this script and, please, tell me what you think. I hope you enjoy using it. :D

*EDIT: Here are some recorded music samples, to showcase what this script can do


Attachments:
NES Sample-based Sound System v0.1.zip [1.29 MiB]
Downloaded 83 times
Music 1.zip [1.52 MiB]
Downloaded 77 times
Music 2.zip [2.31 MiB]
Downloaded 80 times

_________________
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.


Last edited by BioMechanical Dude on Mon Jul 20, 2015 3:47 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 1:30 am 
Offline

Joined: Mon May 30, 2011 9:01 pm
Posts: 179
Very interesting! Do you have any samples that we can listen to? Can it produce something like this?
https://youtu.be/VyUNgNZ1J2k


Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 4:56 am 
Offline
Formerly AlienX
User avatar

Joined: Fri Apr 18, 2014 7:41 am
Posts: 137
Location: Bulgaria
I thought you would just try it out for yourself. All you need to do is to just run it in FCEUX(or any other version, that supports Lua Script) and you're all set, but, OK, I've made some music samples, to showcase what this system can do. All these tracks have been played from NSFs of the games in FCEUX, using this script. They all use the default sample set, I've made, that's included in the package.

As for the "Mega Man III" theme, it's possible, depending on the samples you use. Be aware, that, this a recreation of the theme. The script cannot add any channels or chords, that weren't in the original soundtrack. The tracks still sound very good, though.


Attachments:
Music Samples.rar [3.83 MiB]
Downloaded 137 times

_________________
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.
Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 5:37 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19353
Location: NE Indiana, USA (NTSC)
Why .rar and not .7z?


Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 5:49 am 
Offline

Joined: Mon May 30, 2011 9:01 pm
Posts: 179
I really like the Kick Master one, between 0:17-0:25 you can hear two distinct instruments in your sample, but that distinction is not as clear in the original.


Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 10:19 am 
Offline
Formerly AlienX
User avatar

Joined: Fri Apr 18, 2014 7:41 am
Posts: 137
Location: Bulgaria
tepples wrote:
Why .rar and not .7z?

I don't know, what's the difference?

mkwong98 wrote:
I really like the Kick Master one, between 0:17-0:25 you can hear two distinct instruments in your sample, but that distinction is not as clear in the original.

Yes, that's because the two different channels use different sets of instruments.

Also, is it me or is nobody actually trying this script out? I still don't see why the music recordings were that necessary.

_________________
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.


Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 10:56 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10169
Location: Rio de Janeiro - Brazil
AlienX wrote:
tepples wrote:
Why .rar and not .7z?

I don't know, what's the difference?

AFAIK, .rar is a proprietary format, while .7z is an open standard, and generally provides better compression.


Top
 Profile  
 
PostPosted: Sun Jul 19, 2015 1:41 pm 
Offline
Formerly AlienX
User avatar

Joined: Fri Apr 18, 2014 7:41 am
Posts: 137
Location: Bulgaria
OK, I was going to post the script and the music in .7z files, but then I remembered, .7z is not that widely supported. Some computers or devices won't be able to open this format, unless you have 7-zip, so instead, I'll post them in .zip archives. As far as I know, .zip archives are supported by pretty much every archiving program, whether it's open source or not. So, I hope this made a lot of people happy.


Attachments:
NES Sample-based Sound System v0.1.zip [1.29 MiB]
Downloaded 80 times
Music.zip [3.83 MiB]
Downloaded 63 times

_________________
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.
Top
 Profile  
 
PostPosted: Mon Jul 20, 2015 10:52 am 
Offline

Joined: Mon May 30, 2011 9:01 pm
Posts: 179
I have two suggestions:
1. Make it possible to enable this feature for some channels only.
2. Have game specific samples by having sub folders in the sample folder with names matching the rom name or have the rom name appended to the sample name.

In some games, some of the sound effects are affected by this and sound a bit odd.


Top
 Profile  
 
PostPosted: Mon Jul 20, 2015 3:05 pm 
Offline
Formerly AlienX
User avatar

Joined: Fri Apr 18, 2014 7:41 am
Posts: 137
Location: Bulgaria
mkwong98 wrote:
1. Make it possible to enable this feature for some channels only.

Interesting idea, though, depending on the samples, they might clash with the NES's crunchier Pulse and Triangle waves. For example, I tried playing "Akumajou Densetsu", which uses the VRC6 sound chip. The script does not yet support this chip, so the original VRC6 channels had to be enabled. While it sounded ok, most of the time, the samples could not make good chords with the VRC6's pulse waves, so it was kinda messy. It would be nice to have such a feature though, so I might add it. I just don't see much use for it. :?

mkwong98 wrote:
I have two suggestions:
2. Have game specific samples by having sub folders in the sample folder with names matching the rom name or have the rom name appended to the sample name.

In some games, some of the sound effects are affected by this and sound a bit odd.

If such samples are to be included with the script, the archive might become too large. It is a good idea, however, to add support for this and have the game-specific samples be uploaded somewhere else.
As for the sound effects sounding odd: personally I like the recreated Noise channel sound effects. The different samples added to the Noise channel work to the sound effects' advantage. The Square wave channel ones are different story, though. First of all, they can be a lot louder than the music, but the script replicates the volume changes in the original audio, so it's not a glitch. Yet they don't seem to be that loud, when playing with the original audio. For example: in "Contra" the gun firing sound effects use both the Noise channel and a Square wave channel. In the original, you don't hear the Square wave that much, but with the script it can be even louder than the Noise channel, even if that channel is set to a louder volume level. Sometimes, the Square wave sound effects sound pretty good (they kinda remind me of some of the sound effects in "Super Castlevania IV"), but I noticed some kind of flaw. The script, despite the fact, that it updates the sound every frame, still doesn't handle faster sound effects very well. Imagine a sound effects is an animation, consisting of frames. For some reason, some of the frames here are missing, making fast-changing sound effects much jerkier. I simply cannot explain this. The script handles vibratos in music just fine, so why aren't the sound effects that good? Can someone with better programming and/or sound design knowledge explain this? Is the code not optimized enough and, therefore, misses a frame or two? I would like to know and fix this issue immediately.

Thanks.

_________________
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.


Top
 Profile  
 
PostPosted: Tue Jul 21, 2015 6:39 am 
Offline

Joined: Mon May 30, 2011 9:01 pm
Posts: 179
I think you can try adjust the volume of each channel with the formula here:
http://wiki.nesdev.com/w/index.php/APU_Mixer

And I have one more idea for this script but it is very complicated to implement and I'm not sure if it improves the sound. Have 2 samples for each instrument, one for starting and one for looping which the starting sample should end in the same way as the looping sample. When the script detects a sudden change, it plays the starting sample and if the end of the sample is reached, then it plays the looping sample. I think this will work with string instruments.


Top
 Profile  
 
PostPosted: Tue Jul 21, 2015 6:56 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
If this was my project, I'd include 'pluck detection', where you detect when the game plays a note using a different duty cycle for the first frame.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Tue Jul 21, 2015 7:52 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19353
Location: NE Indiana, USA (NTSC)
For a pluck detection test case, try the "piano"-type sound in my cover of the Geom Cube single-player tune (NSF; Ogg)


Top
 Profile  
 
PostPosted: Wed Jul 22, 2015 1:32 pm 
Offline

Joined: Sun Mar 08, 2015 12:23 pm
Posts: 251
Location: Croatia
Wow! Playing Mario with this sounds like playing Sonic! I love it! Now, if you could make some kind of detection of dynamic duty cycle changes where some instruments keep chainging it like 22102210~ become instruments like some synth leads. I used that in FamiTracker a lot. Also, for VRC6, I used duty cycle changing 0123456776543210~ which sounded like Genesis. You should make something like a txt file with list of duty cycle changes according to which the instrument gets applied. It might have some latency, but I'd like to know how it would sound like.


Top
 Profile  
 
PostPosted: Wed Jul 22, 2015 5:54 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19353
Location: NE Indiana, USA (NTSC)
8bitMicroGuy wrote:
Now, if you could make some kind of detection of dynamic duty cycle changes where some instruments keep chainging it like 22102210~ become instruments like some synth leads.

For a test case, use Gate Oar Dyyyye.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot], krzysiobal and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group