Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bidirectional I2S#9909

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
relic-se wants to merge26 commits intoadafruit:main
base:main
Choose a base branch
Loading
fromrelic-se:i2sin
Draft

Bidirectional I2S#9909

relic-se wants to merge26 commits intoadafruit:mainfromrelic-se:i2sin

Conversation

relic-se
Copy link

@relic-serelic-se commentedDec 23, 2024
edited
Loading

New class,audiobusio.I2S, which can be used to both record and playback audio over a unified I2S bus (single pair of bit clock and word select pins).

Notes:

  • This functionality currently relies on PIO and is only functional on RP2xxx boards. I am not familiar with the architecture of other boards which implement the audiobusio module: Atmel SAMD, Espressif ESP32, or i.MX RT1020. Support for these boards (if possible) would likely have to come in later updates.
  • The interface is mostly synonymous withaudiobusio.I2SOut except that data pin direction needs to be specified in keyword, ie:data_out=..., data_in=....
  • Keyword arguments are available to specify sample_rate, bits_per_sample, channel_count, etc, but are only necessary if utilizing input. Otherwise, the bus will use the parameters of the sample argument. If the bus is bidirectional and a sample is played that does not match the input parameters, a relevant ValueError will be thrown.
  • The audio dma system has been modified to allow bidirectional or input-only operation.
  • Testing has been conducted with a Pimoroni Pico Plus 2, an ICS43434 I2S microphone and a PCM5102A I2S DAC.

Comments:

  • I worry about delays potentially caused by waiting on the input buffer duringaudiobusio_i2s_get_buffer.
  • I'm callingRUN_BACKGROUND_TASKS when using the bus as an input only while waiting for the incoming buffer. When the bus is operating bidirectionally, it waits with a sample-length sleep loop. There is likely a better solution out there.
  • I've created a separateaudiobusio.I2SIn that I was testing with initially. I plan on removing this class before marking the PR as ready.

Todo:

  • Support mono input with stereo output.
  • Fix mismatched buffer sizes.
  • (optional) Addrecord method (or similar) to get current input buffer. Could be useful for monitoring input level.

@relic-se
Copy link
Author

I've located a new bug. When using a buffer size onaudiomixer.Mixer or an audio effect that is less than that ofaudiobusio.I2S, the audio distorts significantly.

importboardimportaudiobusioimportaudiomixercodec=audiobusio.I2S(bit_clock=board.GP0,word_select=board.GP1,data_in=board.GP2,data_out=board.GP3,sample_rate=22050,buffer_size=1024,)mixer=audiomixer.Mixer(voice_count=1,sample_rate=22050,buffer_size=512,)codec.play(mixer)mixer.play(codec)

@gamblor21
Copy link
Member

Was this the PR you were looking at some help to get past some technical hurdles? I think I may have time to help if you wanted me to poke at this as well. I will have to get some hardware that can do I2S input still.

@relic-se
Copy link
Author

Was this the PR you were looking at some help to get past some technical hurdles? I think I may have time to help if you wanted me to poke at this as well. I will have to get some hardware that can do I2S input still.

There have been a couple of changes to audio dma recently. I likely need to revise a lot of this before pushing for a review. I also think the recent changes to garbage collection may improve this feature and was likely why the performance was unacceptable in the first place.

As for compatible hardware, there are a few options:

@ladyada
Copy link
Member

hiya just FYI the WM8960 is totally end of line / disco'd - we're making a breakout for the tlv320aic3100 (& maybe friends) and thats what we should probably target long-term :)

@relic-se
Copy link
Author

hiya just FYI the WM8960 is totally end of line / disco'd - we're making a breakout for the tlv320aic3100 (& maybe friends) and thats what we should probably target long-term :)

@ladyada I agree. Plus, I find the noise level in the output of that IC not ideal. I'm glad to hear y'all are working with that codec. I'll definitely want to try it out.

As for the rest of the family, have you considered the TLV320AIC3104? It adds stereo to the ADC and balanced line output, but loses the speaker amp. That's the one I'm planning to use in the future for my projects.

Thank you for your input! And I'll take another look at this PR soon with that in mind.

@ladyada
Copy link
Member

ladyada commentedMay 5, 2025
edited
Loading

yep TLV320AIC3104 is one of the 'friends' we will check out

relic-se reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@relic-se@gamblor21@ladyada

[8]ページ先頭

©2009-2025 Movatter.jp