4 Mic xCORE Array Microphone

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
JordenLuke
Member
Posts: 10
Joined: Fri Aug 11, 2017 6:21 pm
Contact:

4 Mic xCORE Array Microphone

Postby JordenLuke » Fri Aug 11, 2017 7:02 pm

I am new to the xmos architecture. We have project in which we only need to use 4 microphones. We want to take the data from the microphones and output over I2S using TDM. I have been using the phased aligned example (AN00220) as a starting point because the phase alignment is need for our application. What I am having problems with is setting the example up to only read from 4 microphones. I have changed the mic_array_conf.h to match the use of 4 microphones. I then changed the decimator count to 1. I then removed the initialization of the second decimator from the example. Lastly I commented out the second call to the mic_array_dcimate_to_pcm_4ch() function. Anyone know what I could do next?

I am also confused as to what happens with this data that comes. I would like a clearer understanding of how I can then take the decimated aligned data move it over to the I2S controller.
User avatar
andrew
Experienced Member
Posts: 101
Joined: Fri Dec 11, 2009 10:22 am
Contact:

Postby andrew » Thu Aug 17, 2017 8:28 am

Could you copy paste some code here so I can see how you are setting the decimators up? Thanks
JordenLuke
Member
Posts: 10
Joined: Fri Aug 11, 2017 6:21 pm
Contact:

Postby JordenLuke » Wed Aug 30, 2017 4:19 pm

This is code I also chanded the mic_array_conf.h so that it only has 4 mics


// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
#include <platform.h>
#include <xs1.h>
#include <string.h>

#include "mic_array.h"

on tile[0]: in port p_pdm_clk = XS1_PORT_1E;
on tile[0]: in buffered port:32 p_pdm_mics = XS1_PORT_8B;
on tile[0]: in port p_mclk = XS1_PORT_1F;
on tile[0]: clock pdmclk = XS1_CLKBLK_1;

#define DECIMATION_FACTOR 6 //Corresponds to a 16kHz output sample rate
#define DECIMATOR_COUNT 1 //8 channels requires 2 decimators
#define FRAME_BUFFER_COUNT 2 //The minimum of 2 will suffice for this example

#define DECIMATOR_CH_COUNT 4 //Just to be clear

int data[DECIMATOR_COUNT*DECIMATOR_CH_COUNT]
[THIRD_STAGE_COEFS_PER_STAGE*DECIMATION_FACTOR];

void example(streaming chanend c_ds_output[DECIMATOR_COUNT]) {
unsafe{
mic_array_frame_time_domain audio[FRAME_BUFFER_COUNT];

unsigned buffer; //No need to initialize this.
memset(data, 0, DECIMATOR_COUNT*DECIMATOR_CH_COUNT*
THIRD_STAGE_COEFS_PER_STAGE*DECIMATION_FACTOR*sizeof(int));

mic_array_decimator_conf_common_t dcc = {
0, // Frame size log 2 is set to 0, i.e. one sample per channel will be present in each frame
1, // DC offset elimination is turned on
0, // Index bit reversal is off
0, // No windowing function is being applied
DECIMATION_FACTOR,// The decimation factor is set to 6
g_third_stage_div_6_fir, // This corresponds to a 16kHz output hence this coef array is used
0, // Gain compensation is turned off
FIR_COMPENSATOR_DIV_6, // FIR compensation is set to the corresponding coefficients
DECIMATOR_NO_FRAME_OVERLAP, // Frame overlapping is turned off
FRAME_BUFFER_COUNT // The number of buffers in the audio array
};

mic_array_decimator_config_t dc[DECIMATOR_COUNT] = {
{
&dcc,
data[0], // The storage area for the output decimator
{INT_MAX, INT_MAX, INT_MAX, INT_MAX}, // Microphone gain compensation (turned off)
4 // Enabled channel count (currently must be 4)
},
/* {
&dcc,
data[4], // The storage area for the output decimator
{INT_MAX, INT_MAX, INT_MAX, INT_MAX}, // Microphone gain compensation (turned off)
4 // Enabled channel count (currently must be 4)
}*/
};
mic_array_decimator_configure(c_ds_output, DECIMATOR_COUNT, dc);

mic_array_init_time_domain_frame(c_ds_output, DECIMATOR_COUNT, buffer, audio, dc);

while(1){
mic_array_frame_time_domain * current =
mic_array_get_next_time_domain_frame(c_ds_output, DECIMATOR_COUNT, buffer, audio, dc);

}
}
}

int main(){
par{
on tile[0]:{
configure_clock_src_divide(pdmclk, p_mclk, 4);
configure_port_clock_output(p_pdm_clk, pdmclk);
configure_in_port(p_pdm_mics, pdmclk);
start_clock(pdmclk);

streaming chan c_pdm_to_dec[DECIMATOR_COUNT];
streaming chan c_ds_output[DECIMATOR_COUNT];

par{
mic_array_pdm_rx(p_pdm_mics, c_pdm_to_dec[0], c_pdm_to_dec[0]);
mic_array_decimate_to_pcm_4ch(c_pdm_to_dec[0], c_ds_output[0], MIC_ARRAY_NO_INTERNAL_CHANS);
//mic_array_decimate_to_pcm_4ch(c_pdm_to_dec[1], c_ds_output[1], MIC_ARRAY_NO_INTERNAL_CHANS);
example(c_ds_output);
}
}
}
return 0;
}
User avatar
andrew
Experienced Member
Posts: 101
Joined: Fri Dec 11, 2009 10:22 am
Contact:

Postby andrew » Wed Aug 30, 2017 6:42 pm

change:
mic_array_pdm_rx(p_pdm_mics, c_pdm_to_dec[0], c_pdm_to_dec[0]);
to
mic_array_pdm_rx(p_pdm_mics, c_pdm_to_dec[0], null);
User avatar
andrew
Experienced Member
Posts: 101
Joined: Fri Dec 11, 2009 10:22 am
Contact:

Postby andrew » Wed Aug 30, 2017 6:45 pm

As you are only using 4 channels the other 4 need to be set to null for it to operate in 4ch mode.
JordenLuke
Member
Posts: 10
Joined: Fri Aug 11, 2017 6:21 pm
Contact:

Postby JordenLuke » Wed Aug 30, 2017 9:56 pm

I changed that then got these errrors in the build. Did I miss changing something else some where?
User avatar
andrew
Experienced Member
Posts: 101
Joined: Fri Dec 11, 2009 10:22 am
Contact:

Postby andrew » Thu Aug 31, 2017 8:50 am

What errors where they?
JordenLuke
Member
Posts: 10
Joined: Fri Aug 11, 2017 6:21 pm
Contact:

Postby JordenLuke » Thu Aug 31, 2017 9:00 pm

Sorry I thought I pasted them in. Here they are.
xmake CONFIG=Default all
Checking build modules
Using build modules: lib_mic_array(3.0.1) lib_xassert(3.0.0) lib_logging(2.1.0) lib_dsp(3.1.0)
Analyzing app_phase_aligned_example.xc
Propagating analysis
Creating dependencies for app_phase_aligned_example.xc
Compiling app_phase_aligned_example.xc
Creating app_phase_aligned_example.xe
C:/Users/jluke/workspace/lib_mic_array/src/decimator_interface.xc: Error: Type of symbol _Smic_array_init_time_domain_frame_0 has mismatch with previous definition:
C:/Users/jluke/workspace/lib_mic_array/src/decimator_interface.xc: Error: found: void _Smic_array_init_time_domain_frame_0(streaming chanend[], unsigned int &, struct { signed long long alignment; signed long data[1][8]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[2]; }[], struct { struct { unsigned int frame_size_log2; signed int apply_dc_offset_removal; signed int index_bit_reversal; signed int *unsafe windowing_function; unsigned int output_decimation_factor; const signed int *unsafe coefs; signed int apply_mic_gain_compensation; signed int fir_gain_compensation; enum { DECIMATOR_HALF_FRAME_OVERLAP=1, DECIMATOR_NO_FRAME_OVERLAP=0 } buffering_type; unsigned int number_of_frame_buffers; } *unsafe dcc; signed int *unsafe data; signed int mic_gain_compensation[4]; unsigned int channel_count; }[])
../src/app_phase_aligned_example.xc: Error: previous: void _Smic_array_init_time_domain_frame_0(streaming chanend[], unsigned int &, struct { signed long long alignment; signed long data[1][4]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[1]; }[], struct { struct { unsigned int frame_size_log2; signed int apply_dc_offset_removal; signed int index_bit_reversal; signed int *unsafe windowing_function; unsigned int output_decimation_factor; const signed int *unsafe coefs; signed int apply_mic_gain_compensation; signed int fir_gain_compensation; enum { DECIMATOR_HALF_FRAME_OVERLAP=1, DECIMATOR_NO_FRAME_OVERLAP=0 } buffering_type; unsigned int number_of_frame_buffers; } *unsafe dcc; signed int *unsafe data; signed int mic_gain_compensation[4]; unsigned int channel_count; }[])
C:/Users/jluke/workspace/lib_mic_array/src/decimator_interface.xc: Error: Type of symbol _Smic_array_get_next_time_domain_frame_0 has mismatch with previous definition:
C:/Users/jluke/workspace/lib_mic_array/src/decimator_interface.xc: Error: found: struct { signed long long alignment; signed long data[1][8]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[2]; } *alias _Smic_array_get_next_time_domain_frame_0(streaming chanend[], unsigned int &, struct { signed long long alignment; signed long data[1][8]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[2]; } *alias , struct { struct { unsigned int frame_size_log2; signed int apply_dc_offset_removal; signed int index_bit_reversal; signed int *unsafe windowing_function; unsigned int output_decimation_factor; const signed int *unsafe coefs; signed int apply_mic_gain_compensation; signed int fir_gain_compensation; enum { DECIMATOR_HALF_FRAME_OVERLAP=1, DECIMATOR_NO_FRAME_OVERLAP=0 } buffering_type; unsigned int number_of_frame_buffers; } *unsafe dcc; signed int *unsafe data; signed int mic_gain_compensation[4]; unsigned int channel_count; }[])
../src/app_phase_aligned_example.xc: Error: previous: struct { signed long long alignment; signed long data[1][4]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[1]; } *alias _Smic_array_get_next_time_domain_frame_0(streaming chanend[], unsigned int &, struct { signed long long alignment; signed long data[1][4]; struct { unsigned int sig_bits[4]; unsigned int frame_number; unsigned int x; } metadata[1]; } *alias , struct { struct { unsigned int frame_size_log2; signed int apply_dc_offset_removal; signed int index_bit_reversal; signed int *unsafe windowing_function; unsigned int output_decimation_factor; const signed int *unsafe coefs; signed int apply_mic_gain_compensation; signed int fir_gain_compensation; enum { DECIMATOR_HALF_FRAME_OVERLAP=1, DECIMATOR_NO_FRAME_OVERLAP=0 } buffering_type; unsigned int number_of_frame_buffers; } *unsafe dcc; signed int *unsafe data; signed int mic_gain_compensation[4]; unsigned int channel_count; }[])
xmake[1]: *** [bin//app_phase_aligned_example.xe] Error 1
xmake: *** [bin//app_phase_aligned_example.xe] Error 2
User avatar
andrew
Experienced Member
Posts: 101
Joined: Fri Dec 11, 2009 10:22 am
Contact:

Postby andrew » Fri Sep 01, 2017 8:33 am

Try doing a clean then rebuilding. This error seems a bit odd.
JordenLuke
Member
Posts: 10
Joined: Fri Aug 11, 2017 6:21 pm
Contact:

Postby JordenLuke » Fri Sep 01, 2017 4:22 pm

That fixed it. Thanks for your help!

Return to “Applications”

Who is online

Users browsing this forum: No registered users and 4 guests