Use AV Receiver DAC? #137
-
Hi, I recently got me a(nother) BT Audio Receiver to feed smartphone audio to my aging AV receiver and was annoyed (again) by rare stuttering and generally suboptimal (and I am not an audiophile) audio quality. That reminded me of the BT and I2S capabilities of the ESP32 and google quickly found your great project for me! One question about DACs: you seem to primarily use external low cost (low quality?) DACs, but since my yamaha receiver has plenty of unused coax or optical digital inputs and its own 192kbit/24bit DAC for PCM or MP3, I guess I'm better off using this? Any recommendations on how to configure the ESP for this and how to optically interface with that? I'm thinking about a board like the pcm5102, but with toslink output - or maybe it is as easy as just soldering something like this FCR684208T directly to the relevant ESP pins and that's it? |
Beta Was this translation helpful? Give feedback.
Replies: 41 comments 69 replies
-
My Audio equipment is from the 80s, so I don't have any experience with any optical connections, but my gut feeling is, that it might not be worth the effort and the combination of cheap ESP32 with a cheap DAC gives a good result at low cost with low complexity. Maybe someone else might have more insight. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick answer. And I thought my equipment (200x) is old :D For the 80s I'd need to dig in the attic and would find a receiver that was one of the first affordable ones with toslink cd connection - would still be reusable with this :) Anyways, getting rid of the external DAC would reduce complexity even more, so I hope for others to chime in. And in the end its more for the fun, not for saving money. So I might just try anyways. It looks like the part I linked should be compatible with the 3V levels the ESP provides. In that case: do you think it should work then to set bits_per_sample to 24? Would be pointless though if BT or the ESP can just deliver 16bit. But then, why 32bit DACs? The manual of the receiver indicates that the sample rate should not matter - as long as it isn't more than 96kbit.
|
Beta Was this translation helpful? Give feedback.
-
Somebody pretended that using 32 bits output gives a better quality (even when A2DP delivers only 16). If you don't mind keep me updated about your final result... |
Beta Was this translation helpful? Give feedback.
-
Sure, will keep you updated - but this may take some time... And "pretended" seems to be the correct term for 16->32 bit shift quality improvements. I recently worked with a 24bit ADC so I know the analog voltage levels in the lower 8 bits are extremely miniscule - surely way beyond what I would be able to hear and hard (impossible?) to transmit without distortion over standard audio cables. |
Beta Was this translation helpful? Give feedback.
-
http://www.hy1688.com.tw/SWITCH/DC%20JACK%20HOME/Optical_File/DLT1150A.pdf delivery date: Mar 8 :D |
Beta Was this translation helpful? Give feedback.
-
I was googling the topic how you can create a signal that might be useful for you since you can not use I2S directly and found the following If you volunteer to test I can add this logic to my https://github.com/pschatzmann/arduino-audio-tools library |
Beta Was this translation helpful? Give feedback.
-
no worries! |
Beta Was this translation helpful? Give feedback.
-
I suggest that you try with the following example: |
Beta Was this translation helpful? Give feedback.
-
In the meantime I switched to native esp idf, so compile/config error is unlikely. Symptom was the same. I found i2s_config had .communication_format = I2S_COMM_FORMAT_I2S, I changed it to I2S_COMM_FORMAT_PCM and I2S_COMM_FORMAT_PCM_LONG. Same symptom: will try your example now... |
Beta Was this translation helpful? Give feedback.
-
Some logs before I go :) Loglevel 5, connect phone, play song, pause song. Logets Jun 8 2016 00:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) entry 0x400806a8 maybe it helps... |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I like your idea to use Pulseview... |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Ha! Had the same idea of getting rid of bt for a sine wave - my code looked way more ugly though... I also don't know exactly how spdif should look like, but the aim is no DC, so there need to be evenly distributed up and down phases and iirc at least one level change per bit for automatic frequency detection. Currently the signal is high too long and there are not enough level changes. Also pulseview has a protocol analyzer for spdif and is not yet happy with it. checking the alternative now... EDIT: sorry, I forgot to explicitly set the spdif pin to 27. The output looks much more like it should now. But it is not continuous: EDIT2: maybe it helps: the red light flickers, flickering gets less and less until it vanishes for a short moment, then it starts flickering again. This repeats over and over every ~3s |
Beta Was this translation helpful? Give feedback.
-
Alternative looks good to me in pulseview. Decoder seems happy, too: unfortunately I hear no sound via the digital input of my soundcard - but that could be user config error - I have never used optical input before. Will try to plug it into the av receiver later. EDIT: btw. I had to up the pulseview sampling rate to 24MHz to make the protocol decoder happy! |
Beta Was this translation helpful? Give feedback.
-
Can you check now some increased buffer values improves the output ? build_flags = -DCORE_DEBUG_LEVEL=5 -DUSE_ESP32_I2S=0 -DI2S_BUFFER_COUNT=8 -DI2S_BUFFER_SIZE=256 -DDEFAULT_BUFFER_SIZE=32 If this does not help we need to go for a separate task with an additional buffer |
Beta Was this translation helpful? Give feedback.
-
I added some log entries and see that the local config was not used in my sketches. Could you please do one more test with the settings above. These settings are the same used by amedes. Just change AudioLogger::instance().begin(Serial, AudioLogger::Info); Logging usually has an negative impact on Audio... ps if you remove the pin from the sketch you can define it with -DSPDIF_DATA_PIN=27 |
Beta Was this translation helpful? Give feedback.
-
I am pretty sure that the sine is working. I have a test sketch for this I am more worried about the following I would have expected to see I will look into this tomorrow... |
Beta Was this translation helpful? Give feedback.
-
The error with the wrong size has been corrected. I hope this make a big difference... |
Beta Was this translation helpful? Give feedback.
-
Did you retry with -DDEFAULT_BUFFER_SIZE=1536 double check that the setting is used in the log I was really expecting that the stuttering is coming from the log output. |
Beta Was this translation helpful? Give feedback.
-
Confirmed that -DDEFAULT_BUFFER_SIZE=1536 should give That's strange - a change of the note should give definitely a different tone. |
Beta Was this translation helpful? Give feedback.
-
buffer 512, level warning (no output) |
Beta Was this translation helpful? Give feedback.
-
Are both print screens the same example sine w/o logging ? |
Beta Was this translation helpful? Give feedback.
-
Hm. The line framework-espidf 3.40301.0 (4.3.1) is confusing me. Is it a 3 or 4 release ? To be sure you can print out the following environenvironemntemnt variables in the sketch
|
Beta Was this translation helpful? Give feedback.
-
Can you try the following example: I was comparing the hex output with my current implementation and it is identical! |
Beta Was this translation helpful? Give feedback.
-
If I understand amendes code, it gets a stream of packets of 2ch x 16bit from a2dp and feeds them to spdif_write() which converts them with the bcm table and sends them out to i2s. Your code has a source stream (sine or a2dp), feeds it to a StreamCopy converter (which should do nothing in this case?) and then sends it to SPDIFStream which has its own converter that writes the data to SPDIFStream16Bit2Channels() which finally does the bcm conversion and sends the result to i2s So things can go wrong in 3 places
since you checked 1 and 2 (if I understand you correctly), whats left is i2s config, right? |
Beta Was this translation helpful? Give feedback.
-
Oh, that's good news indeed! A couple of questions:
The fact that USE_ESP32_I2S=0 is working and DDEFAULT_BUFFER_SIZE=32 not - made me to remove all the complexity in the current implementation. So with the latest version USE_ESP32_I2S is not supported any more now. So could you retest with the latest updated version with
|
Beta Was this translation helpful? Give feedback.
-
Cool! Tomorrow I plan to move the AudioSPDIF.h from the experimental directory to the AudioTools directory and add it to the automatically imported files. So you might just need to delete the corresponding #includes from your sketches after my change. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, First of all, thank you very much for your work. My amplifier is equipped both with optical and coaxial digital inputs. I had no optical transmitter so I have tested your code with the coaxial input. I was using a cheap bluetooth receiver from aliexpress that had an annoying buzzing. That buzzing is of course gone, but the sound quality has also highly improved even if my setup is far from being high end. |
Beta Was this translation helpful? Give feedback.
Cool!
Tomorrow I plan to move the AudioSPDIF.h from the experimental directory to the AudioTools directory and add it to the automatically imported files.
So you might just need to delete the corresponding #includes from your sketches after my change.