Measurements of the XMOS USB AUDIO 2.0 ref. Card
-
- Member
- Posts: 14
- Joined: Sun Jan 24, 2010 5:53 pm
Its simple enough to generate a 16bit (or 24) wav file in C and to add dither. if it helps I will throw some code together.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Well I have leared to use the <stdio.h> fprintf() , <math.h> double and generation of sin and my own "I2S.h"
So i guess I am able to write something that playes with 24 bit instead, stores the data to an array of 8192 *int32 in RAM, and finally writes it to disc on the host for spectral analasis later in MATLAB !?
Will ask for help if I fail with the C coding.
Why didn't my parent work in a english speaking country when I was 6 yeras old? That way I would have learned english during the time frame the lingvistic part of the brain was open to new info.
So i guess I am able to write something that playes with 24 bit instead, stores the data to an array of 8192 *int32 in RAM, and finally writes it to disc on the host for spectral analasis later in MATLAB !?
Will ask for help if I fail with the C coding.
Why didn't my parent work in a english speaking country when I was 6 yeras old? That way I would have learned english during the time frame the lingvistic part of the brain was open to new info.
Probably not the most confused programmer anymore on the XCORE forum.
-
- Member
- Posts: 14
- Joined: Sun Jan 24, 2010 5:53 pm
-
- Member
- Posts: 14
- Joined: Sun Jan 24, 2010 5:53 pm
Woops, there was a problem with the rounding the sample to a integer that was adding some 3rd harmonic, sample and code fixed now.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Code: Select all
dither = rand() + rand();
Probably not the most confused programmer anymore on the XCORE forum.
-
- Member
- Posts: 14
- Joined: Sun Jan 24, 2010 5:53 pm
That was my intention.lilltroll wrote:Does that row mean that you use dither with a triangular distribution ?Code: Select all
dither = rand() + rand();
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
At least something is working now - but it's several things I'm unsure of.
The "volume" is one.
The little hill over 40 kHz is due to noise shaping.
At least we see much fewer pins in the spectra.
The Code "right now"
MATLAB
The "volume" is one.
The little hill over 40 kHz is due to noise shaping.
At least we see much fewer pins in the spectra.
The Code "right now"
Code: Select all
#define insize 128
#define outsize 8192
void writefile(int DATA[]);
void inittone(int buf[]);
void stream(streaming chanend IN,streaming chanend OUT,int bufout[],int bufin[]){
int k,m;
for(m=0;m<3000;m++){
for(k=0;k<insize;k++){
OUT<:bitrev(bufout[k]);
IN:>bufin[0];
}
}
m=0;
while(m<outsize){
for(k=0;k<insize;k++){
OUT<:bitrev(bufout[k]);
IN:>bufin[m];
m++;
}
}
writefile(bufin);
}
int main(){
streaming chan c_DAC_L,c_DAC_R,c_ADC_L,c_ADC_R; //Used channels
int bufout[insize];
int bufin[outsize];
inittone(bufout);
par
{
stream(c_ADC_L,c_DAC_L,bufout,bufin);
bypass(c_ADC_R,c_DAC_R);
I2S_slave(c_DAC_L,c_DAC_R,c_ADC_L,c_ADC_R);
}
return 0;
}
Code: Select all
#include <math.h>
#include <stdio.h>
#define amp 0x7FFFFFFF
#define insize 128
#define outsize 8192
void writefile(int DATA[])
{
int k,TEMP;
FILE *inFile;
printf("Opening file...\n");
inFile=fopen("UTDATA.txt","w+");
for(k=0;k<outsize;k++)
{
TEMP=DATA[k];
fprintf(inFile,"%d ",TEMP);
}
printf("Closing file...\n");
fclose(inFile);
printf("Entering infinite loop...\n");
while(1);
}
void inittone(int buf[]){
int t;
double arg;
arg=2 * M_PI / insize;
for ( t = 0; t < insize; t ++ )
{
buf[t]=(int)round(amp*sin(t*arg));
}
}
Code: Select all
>> Lp=20*log10(abs(fft(UTDATA)));semilogx(linspace(0,96,4096),Lp(1:end/2)-max(Lp),'linewidth',2);grid on;
>> xlim([1 100])
>> xlabel('Frequency [kHz]')
>> ylim([-120 0])
>> ylabel('Level [dB]')
>> title('First test');
You do not have the required permissions to view the files attached to this post.
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Here is an other way to check the total latency in the system without the need of any external measurement equipment. By using analog feedback from Line-OUT to Line-IN - we will be able to se maxima and minimas at 180*n degrees in the closed loop response.
This is done with at fs=192 kHz.
The delay is ~1/14060 = 71 us.
(USB is not involved here :!: )
This is done with at fs=192 kHz.
The delay is ~1/14060 = 71 us.
(USB is not involved here :!: )
You do not have the required permissions to view the files attached to this post.
Probably not the most confused programmer anymore on the XCORE forum.