esp-idf API examples?

Moderators: mdrjr, odroid

esp-idf API examples?

Unread postby briansm » Mon Jul 09, 2018 10:07 am

Hello again.
Can I ask for more help please? I've migrated my little ZX Spectrum emulator from Arduino-based to the esp-idf framework now, but am struggling again.

Are there are small 'demo' programs using the ODROID library, similar to the small 'hello world' style examples provided with the Arduino library? It is hard to figure out the exact API usage purely from looking at the source of the emulators. I've figured out the graphics side, but help with the format of the audio data going into the I2S bus in odroid_audio.c would be appreciated... at the moment I can only make the emulator make rough clicking noises only, I'm doing something wrong.

I compiled the gnuboy-go emulator but can't get it running, (it needs a ROM file as an argument perhaps?) I was hoping to capture the data being fed to the I2S bus in the audio of a running game to try and figure out the correct format for sound data, but it's a long-winded way of doing it, thought I might ask here first to save some effort. I've got 625 samples of 8-bit mono PCM audio data to play 25 times per second as generated by the emulator, which is wildly different to the 16 bit stereo data coming from the Gameboy.

(I'll get it figured out myself eventually anyway, but any help is appreciated. )

Thanks,
Brian.
briansm
 
Posts: 20
Joined: Wed Jun 27, 2018 3:35 am
languages_spoken: english
ODROIDs: Ordoid GO, Ordoid-W

Re: esp-idf API examples?

Unread postby crashoverride » Mon Jul 09, 2018 11:18 am

For esp-idf, you can use the same APIs all the emulators share:
https://github.com/OtherCrashOverride/go-play/tree/master/odroid-go-common/components/odroid

You can use just the audio component by initializing it:
https://github.com/OtherCrashOverride/go-play/blob/329b31c7833f94b0ac04b825d96f5cf8b51863d2/odroid-go-common/components/odroid/odroid_audio.h#L21
Code: Select all
void odroid_audio_init(int sample_rate);


And submitting your audio data (stereo, 16bit, interleaved frames):
https://github.com/OtherCrashOverride/go-play/blob/329b31c7833f94b0ac04b825d96f5cf8b51863d2/odroid-go-common/components/odroid/odroid_audio.h#L23
Code: Select all
void odroid_audio_submit(short* stereoAudioBuffer, int frameCount);


Alternatively, you can look at the code to see how its done and implement your own solution:
https://github.com/OtherCrashOverride/go-play/blob/master/odroid-go-common/components/odroid/odroid_audio.c
crashoverride
 
Posts: 3709
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1

Re: esp-idf API examples?

Unread postby davidknight247 » Mon Jul 09, 2018 8:01 pm

I’m personally very interested in getting a working spectrum emulator on this device. If you upload your code to github I’ll happily help to get this running. I have previously successfully ported a range of emulators to handhelds but my favourite has always been the speccy!
davidknight247
 
Posts: 18
Joined: Sun Jul 01, 2018 8:35 am
languages_spoken: english
ODROIDs: Odroid go

Re: esp-idf API examples?

Unread postby briansm » Mon Jul 09, 2018 8:43 pm

Got it working now, just had to remove the DC bias from the (unsigned) 8-bit audio data in the buffer (i.e. subtract 128 from each sample) and the sound works fine now, yay. It's not perfect but it works and doesn't slow the emulator down at all, runs at 100% no problem.

Next I will try and get loading and saving snapshots to SD card and some basic keyboard mapping implemented and then I'll put what I've got on github, but not stuck now at least.

David, I can email you a zip or tar.gz of what I have just now if you want to look at it though, it's still messy and full of traces etc but build-able, I'd be too embarrassed to put it on github at this point :)
briansm
 
Posts: 20
Joined: Wed Jun 27, 2018 3:35 am
languages_spoken: english
ODROIDs: Ordoid GO, Ordoid-W

Re: esp-idf API examples?

Unread postby rooted » Tue Jul 10, 2018 1:42 am

Definitely you two should get together and work on it, even if through email until you get the code to a place where you feel comfortable publishing.

Good stuff.
User avatar
rooted
 
Posts: 5177
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)


Return to Arduino Coding Camp

Who is online

Users browsing this forum: No registered users and 2 guests