LoginLogin
Might make SBS readonly: thread

WAVSETA Limitations With Sound Length

Root / Programming Questions / [.]

randoCreated:
Hey, so I’m trying to experiment with sound design in SmileBASIC (on the 3DS) and I’m actually kind of impressed at what’s possible! I’ve been able to create a very beefy synth bass sound, just by making two low saw waves slightly out of sync with each other. My question lies in creating a sound that changes as it plays. I want a sound that holds a low drone and the upper harmonics in the sound have this kind of “falling” effect. Think of something similar to “BGMPLAY”@285O2G&[G&]”” but instead it’s a sound I want to create with WAVSETA. What I’ve tried is having a general function for the basic shape of the wave (saw) and then I’d run over it with FOR loops adding each sample to an array. The code looks something like this: —— FOR I=0 TO 128 A=F(I,2)’Gets a sample for just a basic saw waveform A=A+0.5*A*SIN(64*((PI()*I)/128))’Emphasize a high harmonic in the sound, there’s like 3 more of these but I don’t want to write them out A=A/4’Reduce amplitude PUSH ARR,A NEXT —— I’d run each FOR loop multiple times, and there’d be multiple FOR loops to emphasize different harmonics. There’s probably a more efficient way to do that, but I just want to create the sound and then probably save it for now. The problem is, WAVSETA seems like it might cut off the end of the array if it reaches a certain number of samples. This keeps my sound from being as long as I want it. Does anyone know any workaround for this?

"FOR I=0 TO 128" iterates 129 times, making your array 129 elements; The way WAVSET/WAVSETA work is that they just repeat the array up until the end of the wave buffer (16384 samples). If the number of elements isn't a clean multiple of 2, the wave gets distorted, at the end of the buffer even truncated making the distortion worse. either replace the FOR with "I=0:WHILE I<128" or change to 128 to 127. It appears that WAVSETA isn't checking the size of the array unlike WAVSET that checks the string's length, hence you get such a result without an error you would get if you used WAVSET.

That’s actually super helpful, thank you! Now I can get the sound to be longer like I wanted, so it’s time for the other hard part of changing the sound to sound right. Thanks for your help!