3
\$\begingroup\$

I am looking for a solution to encode the data from a MEMS microphone to AAC LC. I have a small microcontroller that is very low power but that lacks the RAM required for encoding so I am looking for simplest possible solution.

Are there any MEMS microphone that can natively provide a AAC stream?

Or are there any chip that can do this with low price (preferably <$2, volume 1000), low number of pins and small footprint?

Any ideas o. How to solve the problem would be appreciated.

I also wonder how I can normalize the volume level of the microphone. Is this done natively by digital MEMS microphoned?

EDIT: Would adding a PSRAM over SPI etc solve the problem or would I need to rewrite the entire AAC lib to make this work? It is not possible to memory map additional RAM in the chip I use.

\$\endgroup\$

2 Answers 2

7
\$\begingroup\$

I have a small microcontroller that is very low power but that lacks the RAM required for encoding so I am looking for simplest possible solution.

Get a better microcontroller; that's really all.

Are there any MEMS microphone that can natively provide a AAC stream?

No.

Or are there any chip that can do this with low price, low number of pins and small footprint?

Microcontrollers :) Note that I'm not saying you need to replace your ultra-low-power microcontroller! But the external ASIC you're looking for is really just a computer powerful enough to run the codec you want – and that might well mean that when needed, you power a second microcontroller.

Let me do a bit of quick estimates in my head: from my DRM / DAB+ days, I remember that the fdk-aac AAC-LC works on 40 ms chunks of 16bit samples at 8 kS/s (assuming you're aiming for speech). So, that's 640 B of samples you need to hold per chunk.

Then, we need to do a MDCT, so I'll throw in another 4 kB of RAM for that (we'll hold coefficients in RAM, probably), apply a psychoacoustic model and quantize, another 8 kB, then need to do the entropy coding, 8 kB more.

So, in total, we're talking 32 kB to 64 kB of RAM necessary. Falls nicely into the midrange Cortex-M range!

I also wonder how I can normalize the volume level of the microphone. Is this done natively by digital MEMS microphoned?

Some microphones have adaptive gain control. You'll find out in the datasheet.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Presumably a Cortex-M can also run better codecs like Opus, so a firmware upgrade could let you switch over in future. (some random opinions I found on Reddit are that an M7 definitely can, and probably an M4: reddit.com/r/embedded/comments/5dz8kg/…) \$\endgroup\$ Jan 29 at 4:40
  • \$\begingroup\$ @PeterCordes you probably wouldn't want to implement all of OPUS on an M4, but only the application specific part relevant to your use case, but yeah. But I think if OP is asking for specifically AAC-LC, then there's probably compatibility involved \$\endgroup\$ Jan 29 at 8:34
  • 1
    \$\begingroup\$ Yeah, I assumed they had a reason for AAC, presumably compatibility with something, that's why I said "in future", not "they should do that instead now". \$\endgroup\$ Jan 29 at 8:47
  • 1
    \$\begingroup\$ @www.jensolsson.se yeah, while fdk-aac in all its fixed-point glory is certainly meant to run on devices such as yours, I don't think you specifically want to put the memory for codec purposes into external, non-mapped RAM. Your application sounds really interesting! My guess is that you could do something like taking the memory that is used by some task that is not run while the codec runs, put it on external memory, and fetch it back afterwards; paging (not to disk as your PC when it swaps, but to external memory)! That of course comes with interesting constraints, like you needing to \$\endgroup\$ Jan 30 at 11:20
  • 1
    \$\begingroup\$ @PeterCordes re: encumbered implementations: yeah, that used to be terrible about fdk-aac, but the encumberment was mostly that you still needed to buy a license to sell devices doing AAC; with these patents lapsed, that restriction has become meaningless. \$\endgroup\$ Jan 30 at 11:27
4
\$\begingroup\$

with low price

One of the STM32 family will almost certainly see you right. They go from about $2 up to, well, a lot more! What you call "low price" is going to be specific to your application though - it'll be different depending on if it's high-end scientific equipment, cheap consumer electronics, or disposable greetings cards with a recorded message.

Level adjustment in software is the way to go - it doesn't need extra components and it's well within the capabilities of most devices. If it's going to be automatic then you could best do this this too with a soft-knee compressor, make-up gain, and a limiter at the end. The problem though is that you need to start with enough ADC resolution for the application. If it's a greeting card recording, 16-bit is more than enough, and you might even get away with a 12-bit ADC. That'll reduce to 8-bit or less after level adjustment, but you don't really need super quality for that application. If it's a serious recording though, you want at least 16-bit resolution after level adjustment, so 24-bit ADCs are the standard for audio recording equipment.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ AAC doesn't do lossless, so we can probably rule out "high-end scientific equipment" in this specific case. But yeah, there's still a range from one-off to mass-market. \$\endgroup\$ Jan 29 at 8:49
  • \$\begingroup\$ I realize that low cost was a bit vague, I will update my question. My main microcontroller is around $5 and adding audio is a small additional feature so it need to be in line with this. \$\endgroup\$ Jan 30 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.