Skip to content
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

24 _bitsPerSample not handled in I2SClass::read() #7107

Closed
1 task done
musteresel opened this issue Aug 10, 2022 · 3 comments
Closed
1 task done

24 _bitsPerSample not handled in I2SClass::read() #7107

musteresel opened this issue Aug 10, 2022 · 3 comments
Assignees
Labels
Area: Peripherals API Relates to peripheral's APIs. Status: In Progress Issue is in progress Status: To be implemented Selected for Development
Milestone

Comments

@musteresel
Copy link

Board

ESP32 NodeMCU

Device Description

Chip on "standard" dev board, doesn't matter for the issue though.

Hardware Configuration

Irrelevant for issue, but: 2 INMP441 I2S Microphones, SCK+WS+SD connected, SD with 100kOhm to GND (according to datasheet), L/R set differently (3V3 and GND) on both Microphones.
(https://invensense.tdk.com/wp-content/uploads/2015/02/INMP441.pdf)

Version

v2.0.4

IDE Name

Arduino

Operating System

Windows 10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

} else {
_give_if_top_call();
return 0; // sample value
}

24 _bitsPerSample are silently NOT read.

Sketch

// in setup
I2S.begin(I2S_PHILIPS_MODE, samplerate, 24);

// in loop
int sample = I2S.read();

Debug Message

None

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@musteresel musteresel added the Status: Awaiting triage Issue is waiting for triage label Aug 10, 2022
@musteresel
Copy link
Author

For reference, this is how read 24 bits per sample (stereo) works atm:

int32_t s24le_to_int32(unsigned char const * const buf)
{
  uint32_t r = (buf[2] << 16) | (buf[1] << 8) | buf[0];
  if (buf[2] & 0x80) r |= 0xFF000000; // extend sign
  return static_cast<int32_t>(r);
}

unsigned char snd[8];
int const stat = I2S.read(snd, 8);
// snd[0], snd[4] ==> discard
// snd[3,2,1] => 24 bit signed little endian
// snd[7,6,5] => 24 bit signed little endian
int32_t const left = s24le_to_int32(snd + 1);
int32_t const right = s24le_to_int32(snd + 5);

So basically you need to read 4 bytes for each sample and channel.

@PilnyTomas
Copy link
Contributor

Hi, 24bps is not officially supported. Reading data as a buffer should return something.

@VojtechBartoska VojtechBartoska added this to the 2.0.6 milestone Oct 5, 2022
@VojtechBartoska VojtechBartoska moved this from Todo to In Progress in Arduino ESP32 Core Project Roadmap Oct 24, 2022
@PilnyTomas PilnyTomas added Status: To be implemented Selected for Development Status: In Progress Issue is in progress and removed Status: Awaiting triage Issue is waiting for triage labels Nov 9, 2022
@PilnyTomas
Copy link
Contributor

Full support will be available when I finish the PR #7117.

Repository owner moved this from In Progress to Done in Arduino ESP32 Core Project Roadmap Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Status: In Progress Issue is in progress Status: To be implemented Selected for Development
Projects
Development

No branches or pull requests

3 participants