1. mashers

    OP mashers Stubborn ape
    Member

    Joined:
    Jun 10, 2015
    Messages:
    3,837
    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!
     
  2. mashers

    OP mashers Stubborn ape
    Member

    Joined:
    Jun 10, 2015
    Messages:
    3,837
    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.
     
  3. BurningDesire

    BurningDesire GBAtemp Guru
    Member

    Joined:
    Jan 27, 2015
    Messages:
    5,000
    Country:
    United States
    What are you planning you glorious bastered O.O
     
    Deleted User likes this.
  4. Deleted User

    Deleted User Newbie

    Fixed.

    Back on topic, isn't there a mic example in the 3DS devkitpro examples?
     
  5. BurningDesire

    BurningDesire GBAtemp Guru
    Member

    Joined:
    Jan 27, 2015
    Messages:
    5,000
    Country:
    United States
    well screw you too :P

    Yes I think there is.
     
    Deleted User likes this.
  6. mashers

    OP mashers Stubborn ape
    Member

    Joined:
    Jun 10, 2015
    Messages:
    3,837
    Country:
    You'll find out soon enough ;)

    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).
     
    BurningDesire likes this.
  7. machinamentum

    machinamentum GBAtemp Regular
    Member

    Joined:
    Jul 5, 2015
    Messages:
    163
    Country:
    United States
    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)
     
  8. NicEXE

    NicEXE GBAtemp Fan
    Member

    Joined:
    Dec 6, 2009
    Messages:
    411
    Country:
    Cyprus
    IS IT A MILKYTRACKER PORT???

    PS. I USED SHIFT, NOT CAPSLOCK
     
    Deleted User likes this.
  9. hobbledehoy899

    hobbledehoy899 GBAtemp Addict
    Member

    Joined:
    Nov 13, 2015
    Messages:
    2,831
    Country:
    Antarctica
    10/10 well played.
     
  10. NicEXE

    NicEXE GBAtemp Fan
    Member

    Joined:
    Dec 6, 2009
    Messages:
    411
    Country:
    Cyprus
  11. mashers

    OP mashers Stubborn ape
    Member

    Joined:
    Jun 10, 2015
    Messages:
    3,837
    Country:
    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).

    ~ø ^† ^ß~æ†

    PS. I USED ALT, NOT CAPSLOCK :P
     
  12. hippy dave

    hippy dave BBMB
    Member

    Joined:
    Apr 30, 2012
    Messages:
    6,792
    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.
     
  13. chaoszerobillion

    chaoszerobillion Advanced Member
    Newcomer

    Joined:
    Nov 18, 2013
    Messages:
    79
    Country:
    United States
  14. TheCruel

    TheCruel Developer
    Banned

    Joined:
    Dec 6, 2013
    Messages:
    1,350
    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.
     
  15. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!
    Member

    Joined:
    Nov 24, 2014
    Messages:
    3,161
    Country:
    Italy
    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)
     
  16. mashers

    OP mashers Stubborn ape
    Member

    Joined:
    Jun 10, 2015
    Messages:
    3,837
    Country:
    I only need the amplitude at one point. I'm actually trying to detect the user blowing into the microphone.
     
  17. hippy dave

    hippy dave BBMB
    Member

    Joined:
    Apr 30, 2012
    Messages:
    6,792
    Country:
    United Kingdom
  18. NicEXE

    NicEXE GBAtemp Fan
    Member

    Joined:
    Dec 6, 2009
    Messages:
    411
    Country:
    Cyprus
    You crashed my hopes... Here is a sad emoticon :sad:
     
  19. Xenosaiga

    Xenosaiga Time to switch it up
    Member

    Joined:
    Oct 9, 2015
    Messages:
    1,501
    Country:
    United States
    I'm gonna take a shot in the dark and guess you are gonna make grid launcher "hop or spin" like the home menu does.
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - ctrulib, getting, volume