Author Topic: ESP32-A1S audio dev board  (Read 6200 times)

dschwartz

Re: ESP32-A1S audio dev board
« Reply #20 on: March 11, 2020, 10:40:08 PM »
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"
« Last Edit: March 11, 2020, 10:42:53 PM by dschwartz »
----------------------------------------------------------
Tubes are overrated!!

http://dsmnoisemaker.blogspot.com

potul

Re: ESP32-A1S audio dev board
« Reply #21 on: March 12, 2020, 10:10:04 AM »
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

Re: ESP32-A1S audio dev board
« Reply #22 on: March 12, 2020, 10:18:59 AM »
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

Re: ESP32-A1S audio dev board
« Reply #23 on: March 12, 2020, 04:06:27 PM »
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://dsmnoisemaker.blogspot.com

potul

Re: ESP32-A1S audio dev board
« Reply #24 on: March 12, 2020, 04:37:32 PM »
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

Re: ESP32-A1S audio dev board
« Reply #25 on: March 13, 2020, 01:08:03 AM »
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:

Code: [Select]
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.
« Last Edit: March 13, 2020, 01:36:23 AM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

potul

Re: ESP32-A1S audio dev board
« Reply #26 on: March 13, 2020, 04:04:21 AM »
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:

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

potul

Re: ESP32-A1S audio dev board
« Reply #27 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

dschwartz

Re: ESP32-A1S audio dev board
« Reply #28 on: March 14, 2020, 08:43:23 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://dsmnoisemaker.blogspot.com

Digital Larry

Re: ESP32-A1S audio dev board
« Reply #29 on: March 14, 2020, 10:02:26 AM »
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.

Code: [Select]
case AUDIO_HAL_CODEC_MODE_LINE_IN:
es_mode_t  = AC_MODULE_LINE;
break;

Code: [Select]
    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:

Quote
try 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):

Quote
if 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.
« Last Edit: March 14, 2020, 05:33:08 PM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

pruttelherrie

Re: ESP32-A1S audio dev board
« Reply #30 on: March 14, 2020, 12:50:01 PM »
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

Re: ESP32-A1S audio dev board
« Reply #31 on: March 14, 2020, 04:38:54 PM »
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.

Code: [Select]
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;

Code: [Select]
sudo apt update
sudo apt install faust

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

To start a new project from “Hello World”
Code: [Select]
cp -r $IDF_PATH/examples/get-started/hello_world .
cd hello_world/

Or, just switch to your desired project folder.

Set up configuration
Code: [Select]
make menuconfig
[make code changes]
Code: [Select]
idf.py build
[flash to board]
Code: [Select]
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:
Code: [Select]
/* 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
DSP tinkerer and former transistor twister

dschwartz

Re: ESP32-A1S audio dev board
« Reply #32 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?
----------------------------------------------------------
Tubes are overrated!!

http://dsmnoisemaker.blogspot.com

Digital Larry

Re: ESP32-A1S audio dev board
« Reply #33 on: March 14, 2020, 07:23:41 PM »
You might have to install it from the Microsoft store or something.
Digital Larry
DSP tinkerer and former transistor twister

potul

Re: ESP32-A1S audio dev board
« Reply #34 on: March 15, 2020, 02:11:28 AM »
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

Re: ESP32-A1S audio dev board
« Reply #35 on: March 15, 2020, 02:14:22 AM »
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

Re: ESP32-A1S audio dev board
« Reply #36 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.

 

Digital Larry

Re: ESP32-A1S audio dev board
« Reply #37 on: March 15, 2020, 08:53:21 AM »
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.
« Last Edit: March 15, 2020, 10:27:27 AM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

Digital Larry

Re: ESP32-A1S audio dev board
« Reply #38 on: March 15, 2020, 11:16:32 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
DSP tinkerer and former transistor twister

potul

Re: ESP32-A1S audio dev board
« Reply #39 on: March 15, 2020, 12:38:15 PM »
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




« Last Edit: March 15, 2020, 01:05:35 PM by potul »