-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[i2s_audio] Add more options to speakers and microphones #7306
Conversation
Hey there @jesserockz, mind taking a look at this pull request as it has been labeled with an integration ( |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #7306 +/- ##
==========================================
+ Coverage 53.70% 53.96% +0.25%
==========================================
Files 50 50
Lines 9408 9687 +279
Branches 1654 1711 +57
==========================================
+ Hits 5053 5228 +175
- Misses 4056 4128 +72
- Partials 299 331 +32 ☔ View full report in Codecov by Sentry. |
764a85c
to
5e33b1a
Compare
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.
cv.Required(CONF_PDM): cv.boolean, | ||
cv.Optional(CONF_PDM, default=False): cv.boolean, |
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.
In my honest opinion this should be an option for the ADC_TYPE enum like:
internal, standard, PDM
BASE_SCHEMA = i2s_component_schema( | ||
speaker.SPEAKER_SCHEMA, | ||
I2SAudioSpeaker, | ||
default_channel=CONF_MONO, |
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.
My suggestion is to use "CONF_RIGHT" 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.
CONF_MONO is equivalent to the current behavior
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 know, but still i do think it is not necessary
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Now I2S speakers also have the following options that already exist for microphones: * `i2s_mode` (primary/secondary; default: primary) * `use_apll` (true/false, default: false) * `channel` (left/right/mono/stereo, default: mono) * `sample_rate` (default: 16000) * `bits_per_sample` (default: 16bit) Both speakers and microphones also have: * `bits_per_channel` (default: equal to `bits_per_sample`) `channel` has new values: * stereo: input/output data is interpreted as a sequence of (right, left) pairs (this option works for both speakers and microphones); * mono: for speakers, this is the old behavior - each sample from the input is sent to both left and right channels. Also, speakers have an extra option: * `timeout` (default: 100ms) - how long the background tasks should wait before releasing the bus if the buffer is empty.
At high sample rates in stereo mode they overwhelm the queue...
a96c5b8
to
f381fca
Compare
I have rebased this PR after merging #7183. The tests compile but I have not actually looked at the code or reviewed or tested yet. |
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
What does this implement/fix?
Now I2S speakers also have the following options that already exist for microphones:
i2s_mode
(primary/secondary; default: primary)use_apll
(true/false, default: false)channel
(left/right/mono/stereo, default: mono)sample_rate
(default: 16000)bits_per_sample
(default: 16bit)Both speakers and microphones also have:
bits_per_channel
(default: equal tobits_per_sample
)channel
has new values:Also, speakers have an extra option:
timeout
(default: 100ms) - how long the background tasks should wait before releasing the bus if the buffer is empty.The
mode
option of speakers was removed, because it didn't actually do anything.The
pdm
option for microphones is now optional and defaults tofalse
.Types of changes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#4166
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: