N163 Multi-Wave Sampling in FamiTracker

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

Moderator: Moderators

lidnariq
Posts: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Fri Jan 22, 2021 4:38 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Sat Jan 23, 2021 11:32 am

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 30 times

lidnariq
Posts: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Sat Jan 23, 2021 2:01 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Sun Jan 24, 2021 11:29 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Tue Jan 26, 2021 10:07 pm

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 21 times

lidnariq
Posts: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Tue Jan 26, 2021 10:15 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Wed Jan 27, 2021 1:09 pm

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: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Wed Jan 27, 2021 1:42 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Thu Feb 18, 2021 9:34 pm

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 7 times
bass step 4.mp3
The source sound
(6.11 KiB) Downloaded 10 times
Bass Test OG.mp3
The line played back on the source sound
(23.22 KiB) Downloaded 10 times

lidnariq
Posts: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Thu Feb 18, 2021 9:53 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Thu Feb 18, 2021 10:31 pm

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: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Mon Mar 01, 2021 5:19 pm

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 5 times
Bass is getting better (128 Normalized).mp3
Wave size 128, normalized
(732.19 KiB) Downloaded 4 times

lidnariq
Posts: 10248
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: N163 Multi-Wave Sampling in FamiTracker

Post by lidnariq » Mon Mar 01, 2021 5:23 pm

Nice!

Really neat to abuse the 163 wavetable as a general-purpose sampler.

TurtwigX
Posts: 16
Joined: Mon Aug 31, 2020 8:11 pm

Re: N163 Multi-Wave Sampling in FamiTracker

Post by TurtwigX » Mon Mar 01, 2021 5:44 pm

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!

Post Reply