PreenFM > preenfm2 and preenfm3

Stm32F4Discovery port

(1/14) > >>

norbim1:
Hi,

First of all thank you Xavier for this wonderful project and making it open source.

I've started to port the project to the STM32F4Discovery board, which has a nice audio codec on board. I haven't built the control surface yet, but in the current state I'm able to play notes from USB midi. The board have enough free IO pins left to direct connect the CS buttons and enc-s, so I'll try to eliminate the cs s/p converters too.
To use the onboard I2S audio codec I changed the Systic interrupt to DMA int. Currently I'm using 32 samples long DMA buffer, and it works perfectly. In that way the DMA int is fired only at every 16th sample.
I'm wondering if I can use the full 24 bit resolution of the codec. As far as I see the sample block contains 18 bit normalized uint samples, but I couldn't find where it is normalized. I plan to change the timbre summing at the end of the buildNewSampleBlock(), but I'm sure that it has a better place for it.
Would You mind helping me with the place of the "float to 18 bit" normalizing?

Thank's a lot,
Norbert

pld:
Cool, I've been meaning to look into the DMA/i2s stuff myself :)

IIRC, the way things are calculated is
- the voice calculations produce float values (-1,1) and these are summed per timbre
- Timbre::fxAfterBlock scales the the timbre output from (-n,n) to (-131072,131072) via ratioTimbres and numberOfVoiceInverse to avoid clipping in the final mix
- during the final mixing of the timbre samples in buildNewSampleBlock, the sum is offset from float (-131072,131072) to int (0,2^18) for the DAC

So I guess you mainly have to replace the 131072.f (2^17) constants with 8388609.f (2^23).

Does the codec accept padded 24bit samples (i.e. 32bit), or how does that work with DMA?

norbim1:
Thanks for the info. I found the offset, but didn't found the scale. I'll try it today evening.

Yes, the codec accepts padded 32 bit samples, the 24 bit part has to be justified to the right. Actually the codec accepts 2*16bit words for one stereo side sample, so I need to swap the half words of the 32 bit int when filling the DMA buffer.

norbim1:
It works! Thanks again for the info.

Xavier:


Great project  :)
I'm glad to see open source code is usefull to others.
Did you fork the github project ? Don't forget to share your changes  ;)

And thanks Patrick for the very accurate answers....

Xavier

Navigation

[0] Message Index

[#] Next page

Go to full version