-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix PDMIn MEMS microphone support #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
closed by mistake. was going to make a cosmetic change but not worth it. |
yaaaaaaaaaaaay@! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a couple minor things.
atmel-samd/Makefile
Outdated
@@ -146,6 +146,10 @@ endif | |||
CFLAGS += -Os -DNDEBUG -flto $(GCC_INLINE_LIMIT) | |||
endif | |||
|
|||
# Do extra optimization for speed on a few files. | |||
# e.g.: | |||
#$(BUILD)/xxx/Something.o: CFLAGS += $(CSUPEROPT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was basically just documenting how to do this, but I'll take it out.
/* 1788, 1631, 1473, 1315, 1161, 1013, 873, 742, */ | ||
/* 622, 514, 418, 334, 262, 201, 150, 108, */ | ||
/* 75, 49, 30, 16, 7, 2, 0, 0 */ | ||
/* }; */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these still in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to stash them somewhere, but I can save them elsewhere.
shared-bindings/audiobusio/PDMIn.c
Outdated
//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 | ||
//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise | ||
//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 | ||
//| :param int microphone_startup_msecs: milliseconds to wait after starting microphone clock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about taking taking float seconds to be consistent with time.sleep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. I considered this and then for some reason thought float might not be available, which is wrong: we depend on float
not done - didn't do float mic time yet |
Ready to re-review. Squash merge if you like due to multiple commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you!
Changes:
PDMIn
object is created, and run it all the time, so the user code doesn't have to wait for microphone startup, which can be 10ms or even 100ms.PDMIn
is first created, based on new optional parametermicrophone_startup_msecs
.record()
returns number of samples actually recorded, so you can see if it's not keeping up.Note: I tried 128x oversampling instead of 64x, but the code cannot keep up at 24kHz or above sampling. 128x would reduce the high-frequency noise by 6db.