EQ Plugin Loading, Activating 7 Chan EQ

Writing software that inputs and/or outputs audio and performs DSP algorithms such as filters, new codecs or audio effects.
Post Reply
RadioHead
User
Posts: 5
Joined: Sat 2021-03-27 13:48

EQ Plugin Loading, Activating 7 Chan EQ

Post by RadioHead »

Hi Guys,

I'm working on a Internetradio Project, similar to Edzelfs, also using a ESP32 and a VS1053 Board.

As the sound is not as good as i expected (SCI_BASS changes already applied, but Mid's / Low's are really poor), so I want to play around with the EQ / DSP plugin.
As I'm using a high tweeter on the left and a low tweeter on the right channel, I also want to apply some filters later on.
As AMP's I use a PAM8610 module, also played around with TPA3118 Amps, also tried out several different speakers, from 2" to 10", fullrange, subs etc.
To connect the VS to the AMP, I'm using 600:600 Transformers.

To communicate with the VS, I'm using this library: https://github.com/baldram/ESP_VS1053_L ... VS1053.cpp

For loading a patch / plugin I'm using this method:

Code: Select all

void VS1053::LoadUserCode(const unsigned short *plugin) {
  int i = 0;

  while (i<sizeof(plugin)/sizeof(plugin[0])) {
    unsigned short addr, n, val;
    addr = plugin[i++];
    n = plugin[i++];
    if (n & 0x8000U) { /* RLE run, replicate n samples */
      n &= 0x7FFF;
      val = plugin[i++];
      while (n--) {
        wram_write(addr, val);
      }
    } else {           /* Copy run, copy n samples */
      while (n--) {
        val = plugin[i++];
        wram_write(addr, val);
      }
    }
  }

  Serial.println("plugin loaded.");
}
Loading the Patch / Plugin works fine, but here my 1st question would be: Can I check, if the patch / plugin has been really applied? if yes, how?

after Loading the EQ Plugin I activate it as described in the docu (http://www.vlsi.fi/fileadmin/software/V ... alizer.pdf):

Code: Select all

void VS1053::ActivatePlugin(void) {
    write_register(SCI_AIADDR, 0x34);
    Serial.println("plugin activated.");
}
When I want set the 7 Chan Equalizer

Code: Select all

void VS1053::Set7Chan(const double *dB) 
{// Check that a previous filter update is not going on,
// and wait if necessary.
    do
    {
        write_register(SCI_WRAMADDR, 0x180B);
    } 
    while
        (read_register(SCI_WRAM) & 8);

    // Set new equalizer 
    write_register(SCI_WRAMADDR, 0x1800);
    write_register(SCI_WRAM, (int)(dB[0]*256.0));
    write_register(SCI_WRAM, (int)(dB[1]*256.0));
    write_register(SCI_WRAM, (int)(dB[2]*256.0));
    write_register(SCI_WRAM, 0);
    write_register(SCI_WRAM, (int)(dB[3]*256.0));
    write_register(SCI_WRAM, (int)(dB[4]*256.0));
    write_register(SCI_WRAM, (int)(dB[5]*256.0));
    write_register(SCI_WRAM, 0);
    write_register(SCI_WRAM, (int)(dB[6]*256.0));
    write_register(SCI_WRAM, 0);
    write_register(SCI_WRAM, 0);
    write_register(SCI_WRAM, 8); // Activate filter designer
}
Code is stuck in do while at "write_register(SCI_WRAMADDR, 0x180B);"

As write register method looks like following:

Code: Select all

void VS1053::write_register(uint8_t _reg, uint16_t _value) const {
    control_mode_on();
    SPI.write(2);        // Write operation
    SPI.write(_reg);     // Register to write (0..0xF)
    SPI.write16(_value); // Send 16 bits data
    await_data_request();
    control_mode_off();
}
I assume, that DREQ Pin does not get HIGH.. "await_data_request();"

Code: Select all

    inline void await_data_request() const
    {
      while ( !digitalRead ( dreq_pin ) )
      {
        NOP() ;                                   	// Very short delay
      }
    }
I also tryed, to use either the wram_write /*_read for setting the plugin, or even created method's without waiting on DREQ.
E.g.:

Code: Select all

void VS1053::write_register_no_dreq(uint8_t _reg, uint16_t _value)
{
    control_mode_on();
    SPI.write(2);                                // Write operation
    SPI.write(_reg);                             // Register to write (0..0xF)
    SPI.write16(_value);                         // Send 16 bits data
    // await_data_request();
    control_mode_off();
}

void VS1053::wram_write_no_dreq(uint16_t address, uint16_t data)
{
    write_register_no_dreq(SCI_WRAMADDR, address);
    write_register_no_dreq(SCI_WRAM, data);
}
Filters can be applied with this func (at least, code is ran through)..:

Code: Select all

void VS1053::SetFilter(uint16_t memoryLocation, uint16_t freqHz, double dB, double q, int16_t left, int16_t right)
{
    // Check that a previous filter update is not going on,
    // and wait if necessary.
    do {write_register_no_dreq(SCI_WRAMADDR, 0x1800 + memoryLocation*4 + 3);}
    while (read_register_no_dreq(SCI_WRAM) & 1);
    // Do our filter 
    write_register_no_dreq(SCI_WRAMADDR, 0x1800 + memoryLocation*4);
    write_register_no_dreq(SCI_WRAM, freqHz);
    write_register_no_dreq(SCI_WRAM, (int16_t)(dB*256.0));
    write_register_no_dreq(SCI_WRAM, (uint16_t)( q*256.0));
    write_register_no_dreq(SCI_WRAM, (left?4:0)|(right?2:0)|1); // Left, right, update
}
You can see, I used a "*_no_dreq" function that code wont stuck, but I'm not really sure, if this is fine.
In your example in the docu it's also without waiting on DREQ when I'm not mistaken:

Code: Select all

void WriteSci(u_int16 addr, u_int16 data)
{
AssertSpiChipSelect();
WriteSpiByte(2);// 2 = write,3 = read
WriteSpiByte(addr); // SCI register number
WriteSpiByte(data>>8); // 8 MSb's of data
WriteSpiByte(data&0xff); // 8 LSb's of data
DeassertSpiChipSelect();
}
Already tried hundreds of changes in more than 20 hours of troubleshooting / try and error, but I cannot get it to work.

Hope you have some advise for me.

Thanks and regards!
User avatar
pasi
VLSI Staff
Posts: 1779
Joined: Thu 2010-07-15 16:04

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by pasi »

Are you using vs1053b or vs1063a?

If you're building an internet radio, which IC are you using to play the audio? The 7-Chan EQ app works from analog input to analog output.

What values do you see in SCI_AICTRL0..AICTRL3 after starting the EQ app?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
RadioHead
User
Posts: 5
Joined: Sat 2021-03-27 13:48

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by RadioHead »

Hi,

I'm using a VS1053b and a ESP32.

After activating the plugin, read_register gets stuckt and wont return anything :(

Code: Select all

DEBUG:        REG         Contents   bin   hex
DEBUG:        ----------- ---------------- ----
So when the EQ Plugin is just working with analog input's, I assume that it won't work for me cause I'm sending the data via SPI ?
User avatar
pasi
VLSI Staff
Posts: 1779
Joined: Thu 2010-07-15 16:04

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by pasi »

The EQ application might not raise DREQ after starting through AIADDR, which is why your SCI reads/writes get stuck. Also, if you're sending the data to be decoded through SDI, the EQ application is not at all suitale for you.

See the VS1053b EQ5 plugin from http://www.vlsi.fi/en/support/software/ ... ugins.html .
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
RadioHead
User
Posts: 5
Joined: Sat 2021-03-27 13:48

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by RadioHead »

Hi pasi,

so I'm loading now the eq5 plugin as you suggested.

DREQ is also not raised anymore after loading this plugin, right?

Changed the func to not wait on dreq and I read following:

Code: Select all

plugin activated.
DEBUG:        REG         Contents   bin   hex
DEBUG:        ----------- ---------------- ---
DEBUG:        MODE        0100100000000000 4800
DEBUG:        STATUS      0000000001000000 0040
DEBUG:        BASS        0000000000000000 0000
DEBUG:        CLOCKF      0110000000000000 6000
DEBUG:        DECODE_TIME 0000000000000000 0000
DEBUG:        AUDATA      1010110001000100 AC44
DEBUG:        WRAM        1000101111000000 8BC0
DEBUG:        WRAMADDR    0000000000000111 0007
DEBUG:        HDAT0       0000000000000000 0000
DEBUG:        HDAT1       0000000000000000 0000
DEBUG:        AIADDR      0000101111000000 0BC0
DEBUG:        VOL         0000100100001001 0909
DEBUG:        AICTRL0     0000000000000000 0000
DEBUG:        AICTRL1     0000000000000000 0000
DEBUG:        AICTRL2     0000000000000000 0000
DEBUG:        AICTRL3     0000000000000000 0000
Is the plugin correctly loaded?

Is there some additional code around, how to use this plugin?
The docu is not very large and after a couple of minutes spending with google, didn't find anything...

As I also require some filtering on the channels (left high tweeter, right low tweeter) is the PEQ Plugin even better for my usecase?


----------------------------------- EDIT ----------------------------
I just loaded the PEQ Plugin and activated the filters as described in the docu.

Code: Select all

DEBUG:        REG         Contents   bin   hex
DEBUG:        ----------- ---------------- ---
DEBUG:        MODE        0100100000000000 4800
DEBUG:        STATUS      0000000001000000 0040
DEBUG:        BASS        0000000000000000 0000
DEBUG:        CLOCKF      0110000000000000 6000
DEBUG:        DECODE_TIME 0000000100011110 011E
DEBUG:        AUDATA      1010110001000101 AC45
DEBUG:        WRAM        1001011111010101 97D5
DEBUG:        WRAMADDR    0101100000111111 583F
DEBUG:        HDAT0       1011001001000100 B244
DEBUG:        HDAT1       1111111111111011 FFFB
DEBUG:        AIADDR      0000000000000000 0000
DEBUG:        VOL         0000100100001001 0909
DEBUG:        AICTRL0     0000000000000000 0000
DEBUG:        AICTRL1     0000000000000000 0000
DEBUG:        AICTRL2     0000000000000000 0000
DEBUG:        AICTRL3     0000000000000000 0000
In the docu it's not mentioned, that the PEQ Plugin needs a seperate activation (as the eq application and plugin does??), but "To disable the PEQ plugin write 0 to SCI_AIADDR."
As in AIADDR is 0, is the plugin not activated?

And also these 2 lines from the docu:
"The value of SCI_AICTRL1 gives feedback of the required CPU consumption in 100kHz steps. For example a value of 161 would correspond to 16.1MHz."
"SCI_AICTRL0 returns a non-zero value when there are active filters."

let me assume, that the plugin is not activated?!

Thanks and regards!
RadioHead
User
Posts: 5
Joined: Sat 2021-03-27 13:48

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by RadioHead »

Hi,

just assumed, that writing 0x800 to AIADDR is correct for the PEQ Plugin (vs1053b-peq.plg), right???

Filters are applied after loading the plugin (load the Filters (method from docu), the write_register Method I'm using is also waiting on DREQ (this works), but when I want to read_register (with dreq), then it gets stuck again...)

Code: Select all

player.ActivatePlugin();
  delay(10);
  player.LoadFilters();
  delay(10);
  player.printDetails();

Code: Select all

DEBUG:        REG         Contents   bin   hex
DEBUG:        ----------- ---------------- ---
DEBUG:        MODE        0100100000000000 4800
DEBUG:        STATUS      0000000001000000 0040
DEBUG:        BASS        0000000000000000 0000
DEBUG:        CLOCKF      0110000000000000 6000
DEBUG:        DECODE_TIME 0000000011100101 00E5
DEBUG:        AUDATA      1010110001000101 AC45
DEBUG:        WRAM        0001010101011111 155F
DEBUG:        WRAMADDR    0101100000111111 583F
DEBUG:        HDAT0       1011000001100100 B064
DEBUG:        HDAT1       1111111111111011 FFFB
DEBUG:        AIADDR      0000100000000000 0800
DEBUG:        VOL         0000100100001001 0909
DEBUG:        AICTRL0     0000000000000000 0000
DEBUG:        AICTRL1     0000000000000000 0000
DEBUG:        AICTRL2     0000000000000000 0000
DEBUG:        AICTRL3     0000000000000000 0000
The register Values from above show the values of a current running mp3 stream.
As in the Docu of the PEQ Plugin, I would expect to find some data in AICTRL* ...?

Also at least I cannot hear any differences of the audio with headphones..
These are my filters:

Code: Select all

const short filtersleft[] = {
20, -7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
40, -7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
60, -7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
250, -7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
800, -7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
1200, -7*10, 25, /* 1200Hz, -3.0dB, Q=2.5 */
0, 0, 0 /* end marker */
};
const short filtersright[] = {
20, 7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
40, 7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
60, 7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
250, 7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
800, 7*10, 30, /* 20Hz, -3.0dB, Q=3.0 */
1200, 7*10, 25, /* 1200Hz, -3.0dB, Q=2.5 */
0, 0, 0 /* end marker */
};
RadioHead
User
Posts: 5
Joined: Sat 2021-03-27 13:48

Re: EQ Plugin Loading, Activating 7 Chan EQ

Post by RadioHead »

Hi guys,

has anybody some further advise?
Post Reply