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.");
}
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.");
}
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
}
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();
}
Code: Select all
inline void await_data_request() const
{
while ( !digitalRead ( dreq_pin ) )
{
NOP() ; // Very short delay
}
}
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);
}
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
}
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();
}
Hope you have some advise for me.
Thanks and regards!