Homebrew ctrulib: getting volume from mic

  • Thread starter Thread starter mashers
  • Start date Start date
  • Views Views 2,414
  • Replies Replies 18

mashers

Stubborn ape
Member
Joined
Jun 10, 2015
Messages
3,837
Reaction score
5,181
Trophies
0
Age
42
Location
Kongo Jungle
XP
5,129
Country
Hi everyone

I need to detect the volume of the sound being picked up by the 3DS microphone. I know I can use the functions in mic.h to access the microphone and read data from it, but I can't find a way of measuring the amplitude of what's being sampled. Is there a way?

Thanks in advance!
 
Ok, I've thought some more about this and I think I can use micGetLastSampleOffset() to locate the most recently recorded sample in the recording buffer. Assuming I'm using unsigned 8-bit PCM, I think I can then just read one byte from the buffer starting at the offset to get the data representing the most recently recorded sample. The next problem is how to work out which bits represent the amplitude and which represent the frequency.
 
What are you planning you glorious bastered O.O
You'll find out soon enough ;)

isn't there a mic example in the 3DS devkitpro examples?
There is, but it doesn't seem to work on the latest ctrulib, and in any case it doesn't reveal any information about what was recorded (it just plays it back).
 
  • Like
Reactions: BurningDesire
Ok, I've thought some more about this and I think I can use micGetLastSampleOffset() to locate the most recently recorded sample in the recording buffer. Assuming I'm using unsigned 8-bit PCM, I think I can then just read one byte from the buffer starting at the offset to get the data representing the most recently recorded sample. The next problem is how to work out which bits represent the amplitude and which represent the frequency.
If I remember correctly. The mic example writes PCM16 data into the buffer. You can get the last short from the buffer and that signed value would represent your amplitude at that interval (see http://wiki.multimedia.cx/?title=PCM)
 
If I remember correctly. The mic example writes PCM16 data into the buffer. You can get the last short from the buffer and that signed value would represent your amplitude at that interval (see http://wiki.multimedia.cx/?title=PCM)
Thank you buddy! I'll take a look into that. For now I can't get the example to work at all (it just hangs when recording).

IS IT A MILKYTRACKER PORT???

PS. I USED SHIFT, NOT CAPSLOCK
~ø ^† ^ß~æ†

PS. I USED ALT, NOT CAPSLOCK :p
 
Just reading one sample of audio data would be pretty meaningless, as yes it would be a measurement of the signal's amplitude, but only at that arbitrary point in the sound wave. You'll need to use a bunch of sample data in a row to calculate a usable measurement, a common one is RMS, another one is just to use the peak amplitude by keeping track of whichever was the highest point in the range you looked at.
 
The mic example in ctrulib works, just tried it a few days ago with latest ctrulib and devkitARM.

Unfortunately I couldn't make good use of it since I want to use dsp instead of csnd.
 
The mic example in ctrulib works, just tried it a few days ago with latest ctrulib and devkitARM.

Unfortunately I couldn't make good use of it since I want to use dsp instead of csnd.

I'm quite sure dsp and mic works together (at least on lpp-3ds, but it could be caused by my modification to ndsp wrapper. Normally it uses appcore for dsp channel, i moved it on syscore)
 
Just reading one sample of audio data would be pretty meaningless, as yes it would be a measurement of the signal's amplitude, but only at that arbitrary point in the sound wave. You'll need to use a bunch of sample data in a row to calculate a usable measurement, a common one is RMS, another one is just to use the peak amplitude by keeping track of whichever was the highest point in the range you looked at.
I only need the amplitude at one point. I'm actually trying to detect the user blowing into the microphone.
 

Site & Scene News

Popular threads in this forum