To record sounds with the 3DS MIC, you need to have something similar to the following code:
VAR MICDAT%[0]
XON MIC
?"RECORDING IN 3";:WAIT 60:?" 2";:WAIT 60:?" 1":WAIT 60:?"RECORDING..."
MICSTART 0,0,2
WAIT 120
MICSAVE MICDAT%
?"DONE RECORDING"
WAVSETA 224,127,127,127,127,MICDAT%,78
BEEP 224
WAIT 120
XOFF MIC
This code simply records 2 seconds and plays it back. Let's go through this code line by line.
The first line (
VAR MICDAT%[0]) creates a new integer array called MICDAT to store sound data in.
The second line (
XON MIC) enables the 3DS MIC. Using MIC commands while the MIC is not enabled will result in an error.
The third line just gives you a simple countdown so you can get ready for a whopping 2 seconds of recording time. (You can record for longer, but that will be explained soon)
The fourth line starts recording for 2 seconds. The first 2 parameters shouldn't be changed because they are the only ones that work with WAVSETA (afaik, please correct me if I'm wrong)
The fifth line waits for 2 seconds. 60 frames = 1 second in SmileBASIC, so I just doubled it.
The sixth line saves the data to the integer array you created earlier.
The seventh line notifies the user that the recording is over.
The eighth line is where it gets complex. The first parameter can be anything from 224-255 and it's what you use to play the sound (either as a BEEP or a MML instrument). The next four parameters shouldn't be messed with (they control attack, decay, sustain, and release. just make sure your sound decays. if it doesn't,
BGMSTOP -1 or
SNDSTOP). The next parameter is just the array that WAVSETA will pull from. The final parameter shouldn't be messed with also (it controls the pitch that SmileBASIC will use to play your sound).
The ninth line plays the sound and the tenth line waits for it to finish.
The eleventh line disables the MIC.
Record for more than 2 seconds
To record for more than 2 seconds, change MICSTART's third parameter to up to 32 seconds. WAVSETA won't react very well, however and it will probably distort your sound. In order to avoid this, you can use WAVSETA's optional parameter. It controls what part of the array WAVSETA will use. 8180 = 1 second, so just do something similar to this, which will record 4 seconds:
WAVSETA 224,127,127,127,127,MICDAT%,78, 0,16359
WAVSET 224,127,127,127,127,MICDAT%,78,16360,32719
(Code untested. Comment if you have a better way or if the code causes an error.)
Then, you just have to
BEEP 224, wait for it to end, then
BEEP 225.
Recommended Programs
WAV Recorder By SamKitsune - It's a really good application and library for playing sounds so you don't have to go through the pain of WAVSETA's confusing syntax.
Hope this tutorial helped!
or actually worked...