How do I select the pin number for microphone input in the spresense?

Asked 2 years ago, Updated 2 years ago, 61 views

When I use one microphone to input the voice into the spresense, I can only select the microphone A on the expansion board.

Currently, we assume that microphones A and B have 3.5mm jacks, and microphones C and D have BNC terminals, and that one (or two) terminals are used if necessary.

How do I select the microphone input pin number (A-D)?

I look forward to hearing from you.

spresense

2022-09-29 21:45

2 Answers

The microphone selection is described below in the SDK.

https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_ja.html#_baseband_set_command

SetMicMap0x5e SetMicMapCmplt SetMicMapCmplt Set the order and selection of microphones to use.

The channel map for this microphone is
https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_ja.html#_MIC_CHANNEL_SELECT_MAP

It looks like an 8 byte configuration like here.

typedef structure
{
  /*! \ brief[in]Set Mic mapping
   *
   *   mic_map [ch(0<=ch<AS_MIC_CHANNEL_MAX]corresponding to
   *   each channels, and you can map analog and digitalMics.
   *
   *   0x1—Analog Mic1
   *   0x2—Analog Mic2 
   *   0x3—Analog Mic3
   *   0x4—Analog Mic4
   *   0x5—Digital Mic1
   *   0x6—Digital Mic 2
   *   0x7—Digital Mic 3
   *   0x8—Digital Mic 4
   *   0x9—Digital Mic 5
   *   0xA—Digital Mic 6
   *   0xB —Digital Mic 7
   *   0xC —Digital Mic 8
   *   other:no assing
   *
   */

  uint8_tmic_map [AS_MIC_CHANNEL_MAX]; 

} SetMicMapParam;

If you want to replace the CD with AB, use

AudioCommand command;

  command.header.packet_length = LENGTH_SETMICMAP;
  command.header.command_code=AUDCMD_SETMICMAP;
  command.header.sub_code = 0;

  command.set_mic_map_param.mic_map = {0x1, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0};

  AS_SendAudioCommand(&command);

and

AudioCommand command;

  command.header.packet_length = LENGTH_SETMICMAP;
  command.header.command_code=AUDCMD_SETMICMAP;
  command.header.sub_code = 0;

  command.set_mic_map_param.mic_map = {03,0x4,0x0,0x0,0x0,0x0,0x0};

  AS_SendAudioCommand(&command);

However, if you record with 2ch, the microphone will switch between AB and CD.

Also, in the case of Arduino, it doesn't seem to support changing the microphone order, but
in Audio.h,

err_tAudioClass::set_mic_map (uint8_tmap [AS_MIC_CHANNEL_MAX])
{
  AudioCommand command;

  command.header.packet_length = LENGTH_SETMICMAP;
  command.header.command_code=AUDCMD_SETMICMAP;
  command.header.sub_code = 0;

  memcpy(command.set_mic_map_param.mic_map,map,sizeof(command.set_mic_map_param.mic_map));

  AS_SendAudioCommand(&command);

  AudioResult result;
  AS_ReceiveAudioResult(&result);

  if(result.header.result_code!=AUDRLT_SETMICMAPCMPLT)
    {
      print_err("ERROR: Command(0x%x)fails.Result code(0x%x)Module id(%d)Error code(0x%lx)subcode(0x%lx)\n",
                command.header.command_code, result.header.result_code, result.error_response_param.module_id,
                result.error_response_param.error_code, result.error_response_param.error_sub_code);
      print_dbg("ERROR:%s\n", error_msg [result.error_response_param.error_code]);
      return AUDIOLIB_ECODE_AUDIOCOMAND_ERROR;
    }

  return AUDIOLIB_ECODE_OK;
}

There is a private function called
so if you can call it here,
I think I can change it.


2022-09-29 21:45

In the case of Arduino, using the MediaRecorder class, the microphone mapping can be changed as described in this article.

Here,

uint32_tmic_map=0x56789abc;
CXD56_AUDIO_ECODE error_code=cxd56_audio_set_micmap(mic_map);

uint32_tmic_map=0x21;
CXD56_AUDIO_ECODE error_code=cxd56_audio_set_micmap(mic_map);

Or

uint32_tmic_map=0x43;
CXD56_AUDIO_ECODE error_code=cxd56_audio_set_micmap(mic_map);

Would it be like changing to ?

http://spresense.livedoor.blog/archives/21028830.html


2022-09-29 21:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.