Skip to content

32 bit I2S output, F32 FFT256 #8

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

jcj83429
Copy link

@jcj83429 jcj83429 commented Feb 9, 2020

I changed the output_i2s_f32 to set the I2S output to run in 32 bit mode (teensy audio library already does this) and convert F32 directly to I32, avoiding the conversion to I16. This is useful for doing digital volume control with a 24 bit DAC.

I also deleted control_tlv320aic3206, which conflicts with the one already in teensy audio library, and ported the FFT256 to F32. The F32 version of FFT256 is twice as slow as the I16 version, but has better dynamic range.

I tested the I2S output and FFT256 on a teensy 3.6.

This change probably breaks the I2S input. The fix may be as simple as changing dma.TCD->SADDR to (void *)((uint32_t)&I2S0_RDR0 + 2) but I don't have an I2S ADC so I can't test it.

@chipaudette
Copy link
Owner

chipaudette commented Jan 5, 2021

Over on my Tympan_Library (which was shared with this OpenAudio library until I had to focus more on Tympan), I redid the input and output I2S classes to be compatible with both Teensy 3.6 and Teensy 4.x.

When I did this a few months ago, I used the then-current version of the Teensy Audio input_i2s and output_i2s as my model. I added in the adjustable sample rate and the adjustable block size. I then repeated for input_i2s_quad and output_i2s_quad. It all seems to be working for Teensy 4.x and Teensy 3.6.

I don't think that it does 32-bit I2S transfers, but maybe it does? If so, it might be easy and desirable to pull that code back over here to OpenAudio?

Does anyone wanna take a look? It's in the branch "feature_Teensy4_SD" because it both upgrades compatibility to include Teensy4 and it upgrades the SD functionality to work with the latest Greiman-based SdFat included with Teensyduino 1.54 Beta5.

Tympan OutputI2S: https://github.com/Tympan/Tympan_Library/blob/feature_Teensy4_SD/src/output_i2s_f32.cpp
Tympan InputI2S: https://github.com/Tympan/Tympan_Library/blob/feature_Teensy4_SD/src/input_i2s_f32.cpp

Chip

@boblark
Copy link
Collaborator

boblark commented Jan 6, 2021 via email

@jcj83429
Copy link
Author

jcj83429 commented Jan 6, 2021

Over on my Tympan_Library (which was shared with this OpenAudio library until I had to focus more on Tympan), I redid the input and output I2S classes to be compatible with both Teensy 3.6 and Teensy 4.x.

When I did this a few months ago, I used the then-current version of the Teensy Audio input_i2s and output_i2s as my model. I added in the adjustable sample rate and the adjustable block size. I then repeated for input_i2s_quad and output_i2s_quad. It all seems to be working for Teensy 4.x and Teensy 3.6.

I don't think that it does 32-bit I2S transfers, but maybe it does? If so, it might be easy and desirable to pull that code back over here to OpenAudio?

Does anyone wanna take a look? It's in the branch "feature_Teensy4_SD" because it both upgrades compatibility to include Teensy4 and it upgrades the SD functionality to work with the latest Greiman-based SdFat included with Teensyduino 1.54 Beta5.

Tympan OutputI2S: https://github.com/Tympan/Tympan_Library/blob/feature_Teensy4_SD/src/output_i2s_f32.cpp
Tympan InputI2S: https://github.com/Tympan/Tympan_Library/blob/feature_Teensy4_SD/src/input_i2s_f32.cpp

Chip

I looked at the code and it appears to be running the I2S interface in 32 bit mode but the output DMA only writes to the top 16 bits so the bottom 16 bits are always 0, and the input DMA only copies the top 16 bits. This is the same as the base audio library. The changes in my commits from "dma 32 bits at at time to i2s" to "convert directly from f32 to i32" will make the output full 32 bit resolution.

I think porting the Tympan code here would be nice as it's one less divergence with the base audio library.

@boblark
Copy link
Collaborator

boblark commented Jan 6, 2021

Chip, I looked at your links for Tympan In/Out F32. You have been busy! They look good. I tried these with some other Open Audio pieces using 16-bit I2S, T3.6 and T4.0 and saw no problems, consistent with what you are seeing. I ran into no name conflicts and would agree with @jcj83429 to use your Tympan classes with Open Audio. I believe the AudioInputI2S_F32 / AudioOutputI2S_F32 names can be used without OA. We will need to sync the 2 libraries, but that should make sense since the goals are the same. How is that best done? Pull requests on Tympan, maybe?

My comment on needing I16 audio memory is out of date and wrong. Your implementation uses only F32 memory blocks which is smart.

Right now there are no OA I/O except with clobbered names, so I will proceed to get F32 I/O restored with limitations noted in the .h and readme.md.

Incidentally, your get_isOutOfMemory() & flag_out_of_memory are something that I sure could have used at times. It is probably the most important part of an error manager. How do you envision this being used, in general, i.e., outside the Input routine. Bob

IDC-Dragon added a commit to IDC-Dragon/OpenAudio_ArduinoLibrary that referenced this pull request May 15, 2022
…end all available precision.

Basically, I re-did jcj83429's pull request, which got outdated, to current code: chipaudette#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants