# mic2wav

## Description

`mic2wav` is a tool that takes text format recording data obtained by executing Mic Sample Demo mic-2 and converts them into .wav audio files in PCM format.

## How to Use

### Start Command

`% mic2wav TEXTFILE [OUTPUT_DIRECTORY]`

This tool interprets the text data that is written in the file specified in TEXTFILE and outputs the individual data samples as .wav files which are output to the directory specified in OUTPUT_DIRECTORY. OUTPUT_DIRECTORY can be omitted. When omitting it, it will be generated at the same location as the file specified in TEXTFILE.

The file names are numbers generated in ascending order 00000000.wav, 00000001.wav... When there is an existing file with the same name, it is written over.

### Audio Text Data Formats

`mic2wav` interprets the text data based on the following formats.

All formats are interpreted on a per-line basis, with decisions based on the text strings at the head of the row.

Format | Description | Details
--- | --- | ---
$rate=RATE | Specification of Frequency | Sampling frequencies in Hz units are specified in the RATE section as integers. The following values can be accommodated as .wav file PCM formats. 8000 Hz 11025 Hz 16000 Hz 22050 Hz 32000 Hz 44100 Hz With the exception of 44100 Hz, the Mike Sampling Demo mic-2 can record all of these values.
$bits=BITS | Specification of Bit Count | The quantization bit rate is specified in integers in the BITS section. The following values can be accommodated as .wav file PCM formats. 8 bit 16 bit The Mic Sample Demo mic-2 can record all of these values.
$end | Specification of Data Termination | The series of settings and sampling data so far will be output individual .wav files. The output files will be generated automatically according to the rules described above. After being output, the sampling data is all discarded and the system returns to the pre-input analytical state.
||DATA,DATA, ... | Specification of Sampling | Based on the settings, the DATA section is read in as sampling data in unsigned, 16-bit whole numbers. If the quantization bit rate is 8 bits, then the data will be 00 ~ FF, if 16 bits, then 0000 ~FFFF. If the number of digits do not match exactly, they will be simply ignored. The Mic Sample Demo mic-2 will output 16 samples per row. If more than one format appears, the subsequent `$rate` and `$bits` setting changes will be ignored unless data end has been specified using a Send.
# ... | Comment | This is interpreted as an explicit comment row and it reads it and discards it without doing anything.
Other | Illegal Formats | Unrecognizable, illegal formats are read and discarded without doing anything.

Based on the above formats, the text data output by the Mic Sample Demo mic-2 is generated as audio files. For the text, text strings need to be copied from the debug log output window and prepared as arbitrary text files. Additionally, when using the TEG version of IS-NITRO-EMULATOR, a function that writes out the debug log output to a file may be used. For a method of how to specify that, please refer to an easy-to-follow example of a batch file that has been prepared at `build/demos/spi/mic-2/sampling.bat`.

## Location

`$NitroSDK/tools/bin/mic2wav.exe`

## See Also

`Mic Sample Demo mic-2`

## Revision History

08/17/2004 Standardized the notation of IS-NITRO-EMULATOR
06/18/2004 Initial Version