What's a (n SPC) sample?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
What's a (n SPC) sample?
by on (#162485)
Possibly dumb question, but...

But what exactly is a sample, in the context of the SPC? Is it just a recording of an instrument (or a simulation thereof)?
What note should it be recorded at? This document here says (under "DSP Voice Register: P)
that you adjust the pitch of the note played via a DSP register, following a formula, but presumably the base pitch of the sample needs to be something
in particular for that to work? The little diagram below (maybe?) implies that it should be recorded at 1000H = 4096Hz (?), but that's awfully high, isn't it?
What about for things like drums or bass? And what if I wanted to sample chords? Do I think of it as having the pitch of the root or...?
Re: What's a (n SPC) sample?
by on (#162489)
The SPC can replay the sample at (almost) any rate. The number that is written to those registers is multiplied by (32000 Hz รท 4096) to get the resulting playback rate.

You can record at any rate and play back at any rate, and they don't have to be the same. (Otherwise you'd need a ludicrous amount of sample memory to store every note if this weren't an option). You should probably record your master material at the highest rate you can, and then resample it to the right rate for the SPC to use later on.
Re: What's a (n SPC) sample?
by on (#162500)
Sorry, I've never found signal processing stuff very intuitive...am I misunderstanding, or are you actually saying that somehow the quality of the output will be better if for my sample I record (say) my guitar playing the highest note on the fretboard (D6) and sample it down to all the other notes? And that, regardless of whether I record myself playing D6 or E5 or G4 for the sample, if I want the SNES to play A4 (440Hz) I always put the same value into that DSP Voice Register P? And that said value would be (based on the formula in that document) 2^12 * 440/32000 = round(56.32)?
Re: What's a (n SPC) sample?
by on (#162502)
If you used your PC to record at 32000Hz
and played A440 on your guitar
and converted it to the SPC's compressed format
and told the SPC to play it back at 32000Hz (rate 4096)
you'd hear the SPC generate A440.

If you instead told the SPC to play it back at 16000Hz (rate 2048)
you'd hear the SPC generate A220.

If you instead told the SPC to play it back at 64000Hz (rate 8192)
you'd hear the SPC generate A880.
Re: What's a (n SPC) sample?
by on (#162511)
Ahhh, got it - I was conflating the frequency of the note played and the sample rate. So rather than record the highest note possible, for the highest quality I should record (at 32kHz) the note closest to whatever actually gets played. That makes way more sense. Thanks!
Re: What's a (n SPC) sample?
by on (#162513)
True. Record in high quality, and then downsample to the frequency you actually want to store in memory. You won't be able to fit more than about 96,000 samples in total across all waves, as BRR uses 4.5 bits per sample, and samples share a 524288-bit RAM with the playback engine, music sequence data, and the echo buffer (if you use one).

On the Super NES, because of how loops work, it's best to resample to a multiple of 16 times the note's fundamental frequency before encoding. For example, if you record a middle C (261.625 Hz), you should resample to a multiple of 4186 Hz.
Re: What's a (n SPC) sample?
by on (#162531)
Watch your tuning, though. Single-cycle loops should be okay, but for longer loops, even a small difference between what you thought the pitch was and what it actually is can accumulate into a click. If you're going to use a long loop, it might be better to loop the sample at the recorded rate first, and then calculate what rate you should convert it to so that the loop will be a multiple of 16 samples long.
Re: What's a (n SPC) sample?
by on (#162536)
If you encode with my BRRtoolsyou can set up parameters to loop correctly and re-sample to desired quality at once (so that there's no need to re-sample twice).