News:

SMF for DIYStompboxes.com!

Main Menu

ESP32-A1S audio dev board

Started by Digital Larry, March 06, 2020, 08:46:35 AM

Previous topic - Next topic

dschwartz

#20
Yeahhh!
Blinky and hello world running on the board!!
Had some issues defining the COM ports on win 10, but at last!! I'm not a digital virgin anymore!!

Next steps, install ESP ADF, figure out how to work with the codec and make an adc-dac "bypass"
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

potul

great!

In the meantime, I've managed to install Faust in WLS and run faust2ESP32 to generate the files to be added to esp project, but I can't make the whole thing to compile....

I'm getting some linking errors, and I am not sure if I placed all files in the required places. This is getting tricky

potul

Ok, I got it sorted out.... I had to add the Faust cpp files into CMakeLists.txt

So, I successfully compiled my first faust program. But I don't have my board here, so tonight I will try to upload and test.

dschwartz

Now i got stuck again..
Installed ESP-ADF in the same parent directory as ESP-IDF.

Then cloned the GIT files for audio_hal to work with AC101.

I can't build anything..

I don't know where i should be on the command shell, or put the ADF examples files to apply idf.py build...
Should i run them at the root directory? (where IDF and ADF  folders are? it worked for the IDF examples...)

on the "getting started" it says something about setting %ADF_PATH somewhere in some config file..but the instructions are nowhere to be found..
Any help?
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

potul

Good and bad news.

The good ones: I have sucessfully installed ESP-IDF and Faust (not ADF yet)  in Ubuntu under Windows (WSL), and successfully compiled AND FLASHED "hello world" and "blink".
The key to make the flashing work is to set manually the baud rate. So, first locate your COM port, and chmod the corresponding /dev/ttyS* with 666.
Then run (in my case COM10)

idf.py -p /dev/ttyS10 -b 115200 flash

at least it worked for me, and flashed successfully.

The bad news: I couldn't get any faust example to work. It compiled correctly (after some dependencies fix), put after uploading to the board it does nothing. I suspect I didn't initialize the AC101 properly. Will have to test more.

Mat

Digital Larry

#25
Thanks for the tip on specifying the baud rate on the command line.  That worked.

I'm still using WSL on Windows 10.  I got the latest Faust code, did:

make
sudo make install

and while I have access to faust2esp32, I get this when trying to compile the sample program:


gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/main$ !faust
faust2esp32 -lib FaustSawtooth.dsp
ERROR : unable to open file stdfaust.lib
gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/main$


This is a really basic issue and I know I had Faust running under WSL on my laptop.  Not sure where stdfaust.lib lives (couldn't find it) or how to point to it.

OK I did

sudo apt install faust

and it's there now.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

Good to see we are progressing collectively.

Today I was able to get the first sound out of it, using Faust.

The key was to get the initialization of the AC101 done properly. I followed the instructions of
https://faust.grame.fr/doc/tutorials/#dsp-on-the-esp32-with-faust
To get the Faust "hello sawtooth"
But I changed all the codec includes to point to AC101.h, and then in the main program I initialized the codec like this:


        AC101 ac101;
        while (not ac101.begin())
        {
                printf("Failed!\n");
                vTaskDelay(1000/portTICK_PERIOD_MS);
        }
        printf("Success!\n");
        ac101.SetVolumeSpeaker(32);
        ac101.SetVolumeHeadphone(32);

potul

I'm stuck now.....

I can't make a simple audio passthrough, I don't get any sound coming from the input. It must be something related to the codec configuration, I guess...

The lack of documentation around these basics is killing me... it's just shooting in the dark.

Mat

dschwartz

Quote from: potul on March 14, 2020, 03:02:01 AM
I'm stuck now.....

I can't make a simple audio passthrough, I don't get any sound coming from the input. It must be something related to the codec configuration, I guess...

The lack of documentation around these basics is killing me... it's just shooting in the dark.

Mat
Unless you can read chinese ! lOL
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

Digital Larry

#29
Take a look at this, apparently "donny681" has come up with an ESP32-A1S specific version of the ADF?  Can't say I've tried it.

https://esp32.com/viewtopic.php?t=8105

I'll also inquire on the Faust Slack channel.  They did after all advertise support for this dang thing.  I also purchased a LyraT board.  All of these have different codecs and some are supported by Espressif drectly and some not.  The A1S is not an Espressif board as you've no doubt figured out.

======
Update - since this is a bleeding edge project, I suggest you get on the Faust User's mailing list

https://sourceforge.net/projects/faudiostream/lists/faudiostream-users

and then request access to the Slack channel.  I just asked over there and within a few minutes got a suggestion to look at:

https://github.com/phkehl/esp32-a1s-audio_hal

Specifically, it looks like:

https://github.com/phkehl/esp32-a1s-audio_hal/blob/master/driver/ac101.c

has some calls which might work, e.g.


case AUDIO_HAL_CODEC_MODE_LINE_IN:
es_mode_t  = AC_MODULE_LINE;
break;



    if (mode == AC_MODULE_LINE) {
res |= AC101_Write_Reg(0x51, 0x0408);
res |= AC101_Write_Reg(0x40, 0x8000);
res |= AC101_Write_Reg(0x50, 0x3bc0);
    }


etc.

Yet more info from the Faust Slack channel:

Quotetry using the flag -ac101 when calling faust2esp32.  This will create an AC101.cpp/h file pair which defaults to line in/out.
and not only that but (from the guy who wrote the driver):

Quoteif you run ac101.begin() the codec gets initialized for line-in and line-out at 48000 sample rate. to use the mic inputs you'll need to enable these and optionally set their gain in the appropriate register and unmute them in the adc mixer register.

the driver that"s included in faust is located here. https://github.com/thopman/AC101
if you find any issues or have any improvements you can let me know on github.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

pruttelherrie

My A1S is still on its way from China, but in the meantime I found this AC101 library for pure Arduino (no ADF) as I understand it: https://github.com/Yveaux/AC101

It contains the initialisation for the codec.

Digital Larry

OK, I've achieved sawtooth synth nirvana so far.  It takes real careful following of the instructions here:

https://faust.grame.fr/doc/tutorials/index.html#dsp-on-the-esp32-with-faust

because you have to jump around between directories, and move files around a little.

Also you need to edit the CMakeLists.txt in the code folder as follows, which is not in the instructions.


gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/faustexample/hello_world$ cat main/CMakeLists.txt
idf_component_register(SRCS "main.cpp" "AC101.cpp" "FaustSawtooth.cpp"
                    INCLUDE_DIRS "")
gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/faustexample/hello_world$


So, here are the instructions for creating this on Windows 10 Subsystem for Linux (WSL), assuming you already followed the directions at Espressif to install the ESP-IDF.  I don't think ESP-ADF is used in this context.

To install Faust;

sudo apt update
sudo apt install faust


When you open the Ubuntu window, in order to set environment variables:
cd ESP32-A1S/
cd esp-idf/
. ./export.sh


To start a new project from "Hello World"
cp -r $IDF_PATH/examples/get-started/hello_world .
cd hello_world/


Or, just switch to your desired project folder.

Set up configuration
make menuconfig

[make code changes]
idf.py build

[flash to board]
idf.py -p /dev/ttyS4 -b 115200 flash

At this point you can follow the Faust tutorial to create the Faust dsp file and then compile it to create a ZIP with C++ classes.

Be sure to use the -ac101 option with faust2esp32.

Here's my final main.cpp:

/* Hello World Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include "AC101.h"
#include "FaustSawtooth.h"

extern "C" {
    void app_main(void);
}

void app_main(void)
{
    AC101 AC101;
    AC101.begin();
    int SR = 48000;
    int BS = 8;
    FaustSawtooth faustSawtooth(SR,BS);
    faustSawtooth.start();

    while(1) {
        faustSawtooth.setParamValue("freq",rand()%(2000-50 + 1) + 50);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}


Eventually I will make this into an end to end tutorial about using this with Ubuntu and Windows Ubuntu.

Let me know if I left anything out and I'll clarify.

DL


Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

dschwartz

Awesome!
I thought i had to install Ubuntu. Is WSL enough?
It is included in windows 10 isn't it?
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

Digital Larry

You might have to install it from the Microsoft store or something.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

Quote from: Digital Larry on March 14, 2020, 04:38:54 PM
OK, I've achieved sawtooth synth nirvana so far. 

so we are at the same point now...

I have seen your hints on how to get the input to work... I will give them a try. Some of them I already did without luck, but there are some new things to try. Will keep you posted on the results.

potul

Quote from: dschwartz on March 14, 2020, 06:38:20 PM
Awesome!
I thought i had to install Ubuntu. Is WSL enough?
It is included in windows 10 isn't it?

you first enable WSL from the control panel in windows, and after rebooting you have to get Ubuntu from the Windows Store.


potul

No success so far with the audio input. What I just realized is that I get an initialization error of the I2C driver... I wonder if this is related.


Digital Larry

#37
I've just been messing with a couple of oscillators and trying to add a phaser or flanger to it.  Reverb didn't work.  Echo didn't work.  Had some weird behavior and errors on the console monitor.  Part of it might be somewhat vague documentation of the Faust libraries, and some of it might be the fact that Faust support for this particular platform is pretty fresh. 

One of the developers did tell me that the http control interface isn't there, and OSC is not yet integrated.  I did get an invitation to work on the OSC stuff.  Having a little board with no obvious way to get a UI out of it sets me back farther than using the FV-1, so I'm not entirely sure what I feel like doing at this point.

Anyone riding along who wonders if "we're there yet", I'd have to say, "Dad has to pull over and ask for directions".

:icon_lol: :icon_question:

DL

[update] I was getting a warning that the configured flash size (2048 MB) didn't match the detected size (4096MB).  I ran "make menuconfig" and updated the flash size to 4096 MB and am not having the watchdog reset any more.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

Digital Larry

Quote from: potul on March 15, 2020, 03:29:52 AM
No success so far with the audio input. What I just realized is that I get an initialization error of the I2C driver... I wonder if this is related.
Where are you seeing that?
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

#39
at the moment begin() is called, it returns an error in the console... and the board initialization is not finished and returns a "true" (should be false).
Even with this, the sawtooth example works.... But that's the only thing I could make work using faust. I'm also getting watchdog issues, I will try the memory configuration, as I also see this warning message.

So, it gives this message as soon as InitI2C() gets called.

E (337) i2c: i2c driver install error