LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

WAVSET* documentation is terrible.

Root / Programming Questions / [.]

snail_Created:
Can anyone explain to me the intricacies of custom sample audio with the WAVSET* commands (and maybe go into how the mic is handled?) Basically I've been trying to create a custom PCM stream, but it sounds awful even if I try to shove a regular sine wave into it. I just don't get it. Are the values from -128 to 127, or from 0 to 255? Where are the zero-values? What can I do and not do with WAVSETA? What the hell is reference pitch? I'm just frustrated. Someone with good experience help me understand.

I don't have the time ATM for a full explanation, but I use a custom WAV in my game GSi Live. You can look at that if you like.

WAVSET is used to create custom instruments for use in MML. WAVSET instrument,attack,delay,sustain,release,data$,[reference] data$ is a list of hexadecimal numbers from "00" (-1) to "80" (0) to "FF" (1). The number of samples will be a power of 2 between 16 and 512 (32 and 1024 characters) instrument can be between 224 and 255. attack,delay,sustain, and release Affect how the instrument is played in MML. 127,0,127,127 produces no special effects. Triangle wave example: WAVSET 254,127,0,127,127,"00102030405060708090A0B0C0D0E0F0FFF0E0D0C0B0A0908070605040302010" The reference pitch can be ignored usually, But I think it affects the pitch of the sound when played in MML. WAVSETA is the same, but it gets data from an array instead of a string, and supports more samples. (I think the values go from 0 to 255) I haven't used it, but it seems to be meant for playing sounds recorded using the microphone Anyway, the documentation is really good, and I figured it out right away, so IDK what the confusion is about...

I am GUESSING (DISCLAIMER: NOT BASED ON ANYTHING WHATSOEVER) that Reference Pitch means the pitch of your sample. When you play it with MML, you can choose what pitch to play it in, and it will speed up or slow down the sample to match the pitch you want - but first it has to know what pitch the sample source is. So if you record a high-pitched sound, you'd want to set the reference pitch high as well - but you want to be accurate, otherwise there's no point to it. Again, I have no idea what I'm talking about and don't listen to me - but there's a CHANCE that my guess is right. :P

, I have no idea what I'm talking about and don't listen to me - but there's a CHANCE that my guess is right. :P
You are correct. Reference refers to the note of the unadjusted source pitch. This way when someone write MML like "O5C", it knows how much to adjust the sample to match the octave 5 C note.

yay!

...but it sounds awful even if I try to shove a regular sine wave into it. I just don't get it.
Sorry to bump an old thread, but I just tried doing this as well. I put a regular 440 Hz sine wave into the custom instrument and it sounds.... wrong. The pitch is more or less correct, but it's not a pure tone, has some clicky sounds. Has anyone been able to set a clean sounding sin wave into a custom instrument? I'm perplexed.