Audio Output

FroggestSpirit
Posts: 9
Joined: Wed Jul 05, 2017 2:55 am

Audio Output

Postby FroggestSpirit » Fri Jul 21, 2017 3:11 pm

Hi, I'm currently porting my code of "gameboyNano" to ESP32. This is basically a program that emulates the Pokemon Crystal music format, and streams it using the PWM pin. I was able to get the arduino running it at around 8Khz or so, although now I have it running on my ESP32, and it's still around 8Khz give or take. My goal is to bump up the quality significantly. I have a timer running on there for the output Khz, and from that, it calls the song routine ~60hz, and the gameboy's sound system code ~512hz. I want to try and disable some unneeded processes, like bluetooth, and wifi, as when I change the timer to run too fast, it crashes. I'm using the arduino IDE for this, and am also wondering how to find some good values for the PWM (or how to use DAC). I tried optimizing this too to use bit shifts instead of floats, and to minimize my use of division mathmatics.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Audio Output

Postby ESP_Sprite » Fri Jul 21, 2017 3:47 pm

You can use the I2S driver from esp-idf; that makes the I2S peripheral handle all the timing and allows you to just push (blocks of) audio samples into it which then come out of the DAC or an attached I2S codec. Pretty sure the ESP32 can do what you want pretty easily, by the way: with an ESP32 at 160MHz I can emulate an entire GameBoy full-speed, including video.

FroggestSpirit
Posts: 9
Joined: Wed Jul 05, 2017 2:55 am

Re: Audio Output

Postby FroggestSpirit » Fri Jul 21, 2017 4:50 pm

ESP_Sprite wrote:You can use the I2S driver from esp-idf; that makes the I2S peripheral handle all the timing and allows you to just push (blocks of) audio samples into it which then come out of the DAC or an attached I2S codec. Pretty sure the ESP32 can do what you want pretty easily, by the way: with an ESP32 at 160MHz I can emulate an entire GameBoy full-speed, including video.
Youre the one who made that gameboy? Seeing that was a big push for me to get the ESP32, Is there any chance you'd release the source?

Is there a way to do the I2S in the arduino library? I had a portion of the code written in ASM for the arduino one to optimize it, but I re-wrote it in C for the ESP (though it shouldn't have made much of a difference).
That being said, I think 8-bit audio output (like DAC) would be fine considering it's gameboy audio.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Audio Output

Postby ESP_Sprite » Sat Jul 22, 2017 2:14 am

Yes, there is, unfortunately because of reasons it will take a while. I'm not too up-to-date with Arduino, but from what I know there's no I2S interface there yet. You may want to see if you can use the ESP-IDF driver from Arduino: docs are here http://esp-idf.readthedocs.io/en/latest ... s/i2s.html and I think there's an example in ESP-IDF as well; furthermore you may want to take a look at https://github.com/espressif/esp32-nese ... eo_audio.c around line 80 and 105.

Who is online

Users browsing this forum: No registered users and 119 guests