VS1003B in mode IMA ADPCM

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
Krish
User
Posts: 5
Joined: Mon 2020-01-27 12:14

VS1003B in mode IMA ADPCM

Post by Krish » Mon 2020-01-27 12:40

Hi,

I use VS1003B in mode IMA ADPCM (0x1804). I read data block (256 bytes) and sent by RS485 to second module. I calculate header, adds data but encoder not work. (When I change MODE to 0x1800 I hear a voice). So, I think that problem is with header RIFF.

My question are:
- If I send small blocks of data (256 bytes), how I calculate and complete the HEADER (value: F,S,D,…)? When I substitute n = 1 for the example in the documentation, it doesn't work.
- Must there be a header before each block of data?
- Is there any patch that supports the operation of the system in this configuration?

Regards

User avatar
pasi
VLSI Staff
Posts: 1713
Joined: Thu 2010-07-15 16:04

Re: VS1003B in mode IMA ADPCM

Post by pasi » Tue 2020-01-28 13:41

You only add WAV RIFF (IMA ADPCM) header at the beginning. This allows the decoder to detect the audio format and play the data.

Have you checked the microcontroller examples? http://www.vsdsp-forum.com/phpbb/viewto ... f=11&t=840

SCI_MODE = 0x1804 has the Software reset bit set. This bit is required to start the encoding mode and the software reset bit gets automatically cleared, making SCI_MODE 0x1800. You need to have AICTRL0 set to a suitable value before starting the encoding mode.

During encoding you will hear the converted signal from the outputs so you can monitor the result.

Patches should not be required.

If you are decoding with another vs1003, set the RIFF WAV size fields to 0xffffffff.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Krish
User
Posts: 5
Joined: Mon 2020-01-27 12:14

Re: VS1003B in mode IMA ADPCM

Post by Krish » Wed 2020-01-29 12:48

Hi,
I checked your suggestions but it still doesn't work.
Below I send my header and the function that initiates and writes data to the system.

Code: Select all

const uint8_t Header_IMA_ADPCM[] = {		
  'R' , 'I' , 'F' , 'F' , // Chunk ID (RIFF)
  0x34, 0x01, 0x00, 0x00, // Chunk payload size 		// F0 F1 F2 F3 = 0x0134 (308 bytes)
  'W' , 'A' , 'V' , 'E' , // RIFF resource format type  
  'f' , 'm' , 't' , ' ' , // Chunk ID (fmt )
  0x14, 0x00, 0x00, 0x00, // Chunk payload size (0x14 = 20 bytes)
  0x11, 0x00,             // Format Tag (IMA ADPCM)
  0x01, 0x00,             // Channels (1)
  0x40, 0x1f, 0x00, 0x00, // Sample Rate, 0x1f40 = 8.0kHz
  0xd7, 0x0f, 0x00, 0x00, // Average Bytes Per Second
  0x00, 0x01,             // Data Block Size (256 bytes) 
  0x04, 0x00,             // ADPCM encoded bits per sample (4 bits)
  0x02, 0x00,             // Extra data (2 bytes)
  0xf9, 0x01,             // Samples per Block (505 samples)  
  'f' , 'a' , 'c' , 't' , // Chunk ID (fact)
  0x04, 0x00, 0x00, 0x00, // Chunk payload size
  0xF9, 0x01, 0x00, 0x00,  // Number of Samples 		// S0 S1 S2 S3 = 0x01F9 (505 samples)
  'd' , 'a' , 't' , 'a' , // Chunk ID (data)
  0x00, 0x01, 0x00, 0x00  // Chunk payload size 		// D0 D1 D2 D3 = 0x0100 ( 256 bytes)
};


void VS1003B_Init(void)
{
uint16_t j,tmpValueDATA1;
	
	VS1003_Reset();
	HAL_Delay(100);
	
	VS1003_SCI_WriteReg(SCI_VOL, 0);
	VS1003_SCI_WriteReg(SCI_BASS, 0);		// Bass/treble disable
	VS1003_SCI_WriteReg(SCI_AICTRL0, 12);		// Div -> 12=8kHz, 8=12kHz, 6=16kHz
	VS1003_SCI_WriteReg(SCI_AICTRL1, 512);		// 0=Auto Gain, 1024=Max
	VS1003_SCI_WriteReg(SCI_CLOCKF, 0X4430);	// 2.0 x 12.288 MHz	
	VS1003_SCI_WriteReg(SCI_AUDATA, 0x1F40);
	VS1003_SCI_WriteReg(SCI_MODE, 0x1804);		// IMA_ADPCM, MIC, Differential, No HP_Filter			
	HAL_Delay(100);	
}


void VS1003B_WriteDataBlock(void)				
{
uint16_t i,j = 0;
uint16_t tmpValueDATA2;
				
	for(i=0; i<60; i++)	DataBlock_Rx[i] = Header_IMA_ADPCM[i];	
				
	for(j=0; j<256; j++)	DataBlock_Rx[j+60] = KodekAudio_Data.Bufor_Rx_Tmp[j+8];		

	for(j=0; j<158; j++)
	{			
		tmpValueDATA2 = ((DataBlock_Rx[2*j] << 8) + DataBlock_Rx[2*j+1]);	
		VS1003_SDI_WriteData_16bit(tmpValueDATA2);	   // write word 16 bit				
	}		
}

I send small blocks of data (256 bytes), add HEADER for each block and write to another VS.
Regards

User avatar
pasi
VLSI Staff
Posts: 1713
Joined: Thu 2010-07-15 16:04

Re: VS1003B in mode IMA ADPCM

Post by pasi » Wed 2020-01-29 14:08

You only encode in one vs1003b and only decode in another?

If the code above is for the vs1003b which decodes the data, why is it starting the encoding mode?

Does VS1003_SDI_WriteData_16bit() check for DREQ?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Krish
User
Posts: 5
Joined: Mon 2020-01-27 12:14

Re: VS1003B in mode IMA ADPCM

Post by Krish » Wed 2020-01-29 15:01

Hi,
It carries out simplex transmission (one transmits at the moment, the rest listens). The sender changes.
When decoder is in MODE 0x1804 and encoder is in MODE 0x1800 – is OK, I hear a voice.
When I change (decoder and encoder) MODE to 0x1804 that not work.
I think the problem might be in the configuration (MODE) or in the header, but I haven't found a solution yet.
Below I send function write data to the system.

Code: Select all

void VS1003_SDI_WriteData_16bit(uint16_t value)
{
uint8_t tmpTxData[2];

	tmpTxData[0] = value>>8;
	tmpTxData[1] = value;

	while(HAL_GPIO_ReadPin(VS_DREQ_GPIO_Port,VS_DREQ_Pin) == GPIO_PIN_RESET) {}  // Sprawdzenie stanu sygnalu DREQ
			
	HAL_GPIO_WritePin(VS_CS_GPIO_Port,VS_CS_Pin,GPIO_PIN_SET);		// XCS = 1
	HAL_GPIO_WritePin(VS_DCS_GPIO_Port,VS_DCS_Pin,GPIO_PIN_RESET);		// XDCS = 0
	HAL_SPI_Transmit(&hspi4, tmpTxData, 2, 100);		
	HAL_GPIO_WritePin(VS_DCS_GPIO_Port,VS_DCS_Pin,GPIO_PIN_SET);		// XDCS = 1		
}
Regards

User avatar
pasi
VLSI Staff
Posts: 1713
Joined: Thu 2010-07-15 16:04

Re: VS1003B in mode IMA ADPCM

Post by pasi » Wed 2020-01-29 15:05

Krish wrote:
Wed 2020-01-29 15:01
When decoder is in MODE 0x1804 and encoder is in MODE 0x1800 – is OK, I hear a voice.
I think you have that backwards. The decoder should have MODE = 0x0800 (newmode, no encode set, no soft reset) (or 0x0804 when you are switching from encoder to decoder), the encoder should have MODE = 0x1804 (encode set, newmode, soft reset to start the encoder).

Do not set SM_ENCODE in the decoder.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Krish
User
Posts: 5
Joined: Mon 2020-01-27 12:14

Re: VS1003B in mode IMA ADPCM

Post by Krish » Wed 2020-01-29 15:58

Hi,

Yes, I had the configuration, only the reverse I wrote in the forum.
I understand that the encoder and decoder can’t be in the same mode (0x1804) and I have to switch modes at the moment. Yes?

Regards

Krish
User
Posts: 5
Joined: Mon 2020-01-27 12:14

Re: VS1003B in mode IMA ADPCM

Post by Krish » Mon 2020-02-03 8:46

Hi,
Thank you for your help.
Regards

Post Reply