Kinetis USB audio microphone

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Kinetis USB audio microphone

1,219 Views
palmering
Contributor II

Hello,

There is an example of USB Audio Speaker (audio from PC to uC) using Freescale's USB stack but I wonder, instead, if it is possible to do an USB Audio Microphone (audio from uC to PC) with this library.

If someone knows, please let me know.

Thanks,

Pablo

Labels (2)
Tags (2)
3 Replies

837 Views
martynhunt
NXP Employee
NXP Employee

Hi Pablo,

In Freescale's USB stack package, there should also be a USB device app called "audio_generator". This demo sends audio data from the uC device to the host PC, and would be a good place to start developing a USB Microphone application.

Best regards,

Martyn

837 Views
palmering
Contributor II

Hi Martyn,

Thanks, I had not considered it. It seems that they generate audio from samples in memory (audio_data.c). I'd have to replace this with samples of AD converter. I'm going to test this demo soon.

Best reagrds,

Pablo

0 Kudos

837 Views
palmering
Contributor II

Through Martyn´s help I have been able to find the right example for my needs.

Due to size code limitation in my Codewarrior, I generated a sine wave with a digital oscillator instead of a wave table.

I replaced the "USB_Prepare_Data" function with this:

#define WAV_LENGHT 9

#define A=0.05f

#define M_PI  4.0*ATAN(1)

#define FS  44100.0

#define F0  1000.0

#define W0  2*M_PI*F0/FS

#define K1  1.9797349455598831615890608617794f

float Y1=0.035498579489406697256333580400447f;

float Y2=0;

/*

  Y = a*Y1 - Y2

  K1=2*cos(2*PI*f/FS)

  Y1=A*sin(2*PI*f/FS)

  Y2=0

*/

void USB_Prepare_Data(void)

{

    uint_8 k;

    float c;

    if (g_cur_mute[0] == 0)

    {

        // copy data to buffer

          for(k=0;k<WAV_LENGHT;k+=3)

          {

              c = (K1*Y1-Y2);

              long2word( (U24*)&wav_buff[k], (long int)(8388608.0*c));

              Y2 = Y1;

              Y1 = c;

           }

    }

    else

    {

          // copy data to buffer

          for(k=0;k<WAV_LENGHT;k++,audio_position++)

          {

              wav_buff[k] = 0;

          }

    }

}

I used 24bit samples and a sampling rate of 44100Hz, so it was necessary to change the usb_descriptor.c.

Attached U24.C and U24.H are only for data conversion.

It ran O.K. in my board.

Next step is add an AD converter...

Enjoy!