Homebrew ctrulib: getting volume from mic

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
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!
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
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.
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
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

machinamentum

Well-Known Member
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
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)
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
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
 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,883
Trophies
2
XP
29,271
Country
United Kingdom
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.
 

TheCruel

Developer
Banned
Joined
Dec 6, 2013
Messages
1,350
Trophies
2
XP
3,131
Country
United States
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.
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
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)
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,074
Country
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

General chit-chat
Help Users
    Mondooooo @ Mondooooo: im fucking motivated