Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12686 Discussions

What data type the sound data from WM8731L Codec..

Altera_Forum
Honored Contributor II
2,280 Views

Hi all, 

 

I am trying to retrieve the sound data that is captured by WM8731L Codec on DE2 Board...  

 

I am refering the DE2 Karaok-machine Demonstration program. 

I noticed there are several output pin which seems like sound data to me... I am blur with which pin is actually representing the sound data... 

 

AUD_ADCDAT (Pin A4) or I2C_SDAT (Pin B6) ? Or others? 

 

And how can i convert the sound data from the pin to a numeric value that represent the sound data for every single sampled sound data? 

 

 

Many thanks.
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
589 Views

AUD_ADCDAT is the audio data. 

The audio interface of WM8731 is IIS, which have these pins: 

BCK, bit clock. 

LRCK, also called WCK, every cycle of this sig indicates a sample of audio data contains left and right ch, probable low for left and high for right. 

DACDATA, serial data for playback synchronized by BCK. 

ADCDATA, serial data for record synchronized by BCK. 

Detailed format is differ with different configuration, which can be configured via IIC ports. You must refer to WM8731's datasheet.
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

Thank you for your replies. I have read the datasheet WM8731.  

 

The AUD_ADCDAT is the audio data... but may i know the result is it a numeric value? I am still blur with how can i get the sound data as in using wavread function in MATLAB. 

 

Like if i m sampling at 8000Hz, i will have 8000 samples. How can i allocate this 8000 samples for FFT analysis? 

 

Please advise again. I am totally a newbie. I would like to learn. 

 

Many Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

Analyse in MATLAB? That's really a problem, you can transmit the data to your PC by using uart, usb, eth, or hostonly filesystem. If you need a realtime analysing, I suggest you analysing them in fpga by fft megacore. 

 

May be you can use hostonly filesystem. Data from AUD_ADCDATA are signed raw data, write a .wav file on hostonly fs filled with these data in wav file format, then read the file in MATLAB by wavread.
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

 

--- Quote Start ---  

Like if i m sampling at 8000Hz, i will have 8000 samples. How can i allocate this 8000 samples for FFT analysis? 

--- Quote End ---  

 

 

The most simple way is to store them in FPGA internal RAM. Once having the data there, you can transfer them to the PC with a Quartus tool, the In-System-Memory Editor, if the RAM has been generated with a respective interface. 

 

To make the codec sample the audio stream, you have to modify the setup from the demonstration projects, and decode the serial data stream into parallel data. As far as I'm aware of, the demonstration projects don't yet use the ADC function of the codec.But it's basically easy, similar to converting parallel to serial data as in the SD-card audio application, but the other way around.
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

 

--- Quote Start ---  

you can transmit the data to your PC by using uart, usb, eth, or hostonly filesystem. 

--- Quote End ---  

 

 

sorry, 

hostonly filesystem => Host-Based File System (altera_hostfs).
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

 

--- Quote Start ---  

The most simple way is to store them in FPGA internal RAM. Once having the data there, you can transfer them to the PC with a Quartus tool, the In-System-Memory Editor, if the RAM has been generated with a respective interface. 

 

To make the codec sample the audio stream, you have to modify the setup from the demonstration projects, and decode the serial data stream into parallel data. As far as I'm aware of, the demonstration projects don't yet use the ADC function of the codec.But it's basically easy, similar to converting parallel to serial data as in the SD-card audio application, but the other way around. 

--- Quote End ---  

 

 

Hi Thank you for your reply. Actually i am trying to work out my algorithm on the FPGA and analyse the audio data that i have sampled with that algorithm. Not transfer to MATLAB, sorry that i conveyed my message wrongly in previous post. 

 

 

But I have couples of question regarding to the coding to sample the audio signal with WM8731L codec. 

 

I have gone through the WM8731L datasheet and noticed that the ADCDAT is the pin that output the digital audio data signal. But may i know  

 

1) how can i configure the code to sample the audio data at 8000 Hz with 16 bit data?  

 

2) how can i store them to FPGA internal ram? Is it something like below? 

 

reg [23:0]audio_Data; 

reg index = 1; 

input ADCCAT; 

 

always @(posedge CLOCK ) begin 

if (index<8001) begin 

audio_Data[index] = ADCCAT; 

index = index + 1; 

if (index==8001) begin 

index=1; 

end 

end 

end 

 

Then how can i link this to the In-System-Memory Editor? Do i need that if i wanna retrieve the data? 

 

3) How can i work out FFT on the audio that i have retrieved? I have to write a FFT function? or Does quartus II already as built in FFT block? 

 

I am very sory that i asked many stupid question. But i really wish to learn how can i analyze my audio signal that i captured from mic by writing my algorithm to FPGA.  

 

Actually, at the same time, I have completed my simulation with MATLAB's Simulink. Now wish to work out the same thing on Altera DE2 FPGA. 

 

Many thanks again.
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

 

--- Quote Start ---  

sorry, 

hostonly filesystem => Host-Based File System (altera_hostfs). 

--- Quote End ---  

 

 

Thank you for your reply... 

 

Then may i know with this method i can send my result to PC?  

If i wish to display the result that i have calculated with FPGA, then how can i transfer my result to PC and then display it on GUI? 

 

What platform is the best for me to develope a VB? Can i use MATLAB GUIDE? 

 

Many Thanks :)
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

 

--- Quote Start ---  

1) how can i configure the code to sample the audio data at 8000 Hz with 16 bit data?  

--- Quote End ---  

 

The WM8731 control registers have to be set accordingly. 

 

--- Quote Start ---  

2) how can i store them to FPGA internal ram? Is it something like below? 

--- Quote End ---  

 

You would want to store 16-Bit samples to the ram, so the first step is deserializing the data stream, as I already mentioned. Internal RAM can be most easily set up by the MegaWizard Plug-In Manager, category Memory Compiler, 1- or 2-port RAM. In case of a 1-port RAM, you have the option to create an interface for the In-System Memory Content Editor, which allows you to transfer data from and to the RAM through JTAG interface. It's connecting the second RAM port to a virtual JTAG instance. 

 

--- Quote Start ---  

3) How can i work out FFT on the audio that i have retrieved? 

--- Quote End ---  

 

Altera has a FFT core, but it's not free. If you don't have a Quartus subscription license, you are restricted to an evaluation mode of the core. 

 

Unfortunately, there's no ready-to-use demonstration code for sound acquisition, as far as I'm aware of. The control register handling through I2C interface can be copied from other codec demonstrations, but they are far from being instructive in my opinion.
0 Kudos
Reply