N163 Multi-Wave Sampling in FamiTracker

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

Moderator: Moderators

lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

One thing you can do to slightly further improve sound quality: take each 1/60th of a second slice and normalize it, and then use famitracker's volume envelope to compensate the 163's volume for that 1/60th of a second. This will improve sound quality to very approximately µ-law quality instead of just 4-bit.

(In a way, it's recapitulating the original BRR, except that BRR operates on a log-scale volume control every 16 samples, instead of linear volume control every 32-240 samples)
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Hmm, like so? The first loop is the non-normalized instrument, while the second is the normalized sliced instrument
Attachments
Bongotest.ftm
(6.44 KiB) Downloaded 198 times
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

Yeah. You'll notice that the 60Hz buzz is drastically more subtle in the normalized version, because the volume envelope makes that 60Hz buzz follow the intended volume regardless.
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

That's perfect! Thank you and everyone else for all your help on this. Now I know I just have to sample in one 60Hz cycle per N163 wave and normalize it to reduce buzz when I put it all together. I feel much more confident about trying this out with a lot of different instruments. This is great!
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

And now for the followup I thought I'd be able to avoid. So. Looping samples. I'm aware I'll have to get the loop at a multiple rate of 60Hz (so at 14.4kHz 240 samples). This is a sound that I resampled to 14.4kHz, but the loop is from sample 858 to 1205. 347 samples total. Is there a formula I can figure out to make it fit, or will I just have to toy around finding a new loop point that actually fits with what I need it to do?
Attachments
Bass 240.mp3
(4.22 KiB) Downloaded 179 times
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

When using this method, I think you cannot have a loop length that is longer than 240 samples, unless it's an integer multiple of 240 (or whatever block size you're using).

... and unfortunately, FamiTracker doesn't support multiple different wavetable lengths within the same instrument, so I think you'd have to resample the input so that the repeat length is the same as (or an integer multiple of) the block size you're using.
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Right, the loop length was just a result of resampling the input, and nothing else has been changed. I already knew the loop length would have to be a multiple of the wave size (e.g., 240, 480, 720). But I wanted to know if there was a mathematical solution to figure out how I should resample it, or if I just have to fiddle with the sample rate until I get something usable, and potentially finding a new loop point
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

I ... don't know. Right now you've got a loop that's 347÷14400Hz = 24.1ms long, which isn't a multiple of 1/60Hz, and I don't know how to resolve that. Resampling it isn't sufficient, because resampling things won't change the duration of the loop.

You might be able to switch between two instruments in Famitracker with different sample lengths, as long as changing the instrument aligns to a row...?
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Alrighty! So it's been a minute, but that's because I took a break after getting frustrated. But I have made some progress! So, I figured actually the easiest way to get a loop was to make one myself. So I got a bass sample, downsampled it to be 60*64 = 3840 Hz, cut down the file until the samples were a multiple of 64 (1024 in this case), and then got a rough loop to occur on a sample that's a multiple of 64 (768.) Felt kinda like making a SNES sample. Then I loaded it into Audacity, got all the waveforms, and this was my result!

So, I don't think it's all that bad! But I do have questions. For one, the notes are out of tune. Which would be a simple fix in the instrument, but they're not equally out of tune across the octave, so C3 and C4 don't match up. Is that something I can fix in the instrument/wave import? Also, the instrument itself sounds a little rough. Specifically the one treated with normalization. Am I doing the volume envelope properly with that instrument?

This has been a doozy to attempt with little know-how, but I'm getting closer, I can feel it!
Attachments
Bass Test.0cc
The lines played back on the sampled instruments, first without normalization, second with normalization on each wave
(2.86 KiB) Downloaded 166 times
bass step 4.mp3
The source sound
(6.11 KiB) Downloaded 152 times
Bass Test OG.mp3
The line played back on the source sound
(23.22 KiB) Downloaded 153 times
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

You might either be running into imprecision in how 0ccFamiTracker's calculates sample rates for the 163, or maybe just that the 163 fundamentally has a lower precision at lower sample rates. I can't easily tell using the tools I have available to me.
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Thanks for the quick response! Yeah it does seem very much so out of my hands at this point, but I'll keep trying
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Update: I kept trying and it seems the correct answer was the simplest one. I just tried sampling in single cycles at a time, starting with the attack. I did 8 and this is what I came up with. It's pretty convincing as a bass!

I made two versions, one with a wave size of 120, and the other with a wave size of 128 and each cycle normalized
Attachments
Bass is getting better (120).mp3
Wave size 120, not normalized
(732.19 KiB) Downloaded 150 times
Bass is getting better (128 Normalized).mp3
Wave size 128, normalized
(732.19 KiB) Downloaded 150 times
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq »

Nice!

Really neat to abuse the 163 wavetable as a general-purpose sampler.
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Thanks! That's the plan, and now I know how to do it for both melodic and non-periodic samples. Thank you very much for all your help on the subject.
Woohoo!
TurtwigX
Posts: 17
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX »

Only almost a couple years later, I've finally implemented both percussion and melodic instruments. Here's the result!
https://www.youtube.com/watch?v=BHRLyHLRaPw

I'll also throw in the ftm for those who wanna peer at the instruments
Attachments
SMK Mario Circuit.ftm
(25.67 KiB) Downloaded 64 times
Post Reply