SPMA084 December   2021 TM4C1230C3PM , TM4C1230C3PM , TM4C1230D5PM , TM4C1230D5PM , TM4C1230E6PM , TM4C1230E6PM , TM4C1230H6PM , TM4C1230H6PM , TM4C1231C3PM , TM4C1231C3PM , TM4C1231D5PM , TM4C1231D5PM , TM4C1231D5PZ , TM4C1231D5PZ , TM4C1231E6PM , TM4C1231E6PM , TM4C1231E6PZ , TM4C1231E6PZ , TM4C1231H6PGE , TM4C1231H6PGE , TM4C1231H6PM , TM4C1231H6PM , TM4C1231H6PZ , TM4C1231H6PZ , TM4C1232C3PM , TM4C1232C3PM , TM4C1232D5PM , TM4C1232D5PM , TM4C1232E6PM , TM4C1232E6PM , TM4C1232H6PM , TM4C1232H6PM , TM4C1233C3PM , TM4C1233C3PM , TM4C1233D5PM , TM4C1233D5PM , TM4C1233D5PZ , TM4C1233D5PZ , TM4C1233E6PM , TM4C1233E6PM , TM4C1233E6PZ , TM4C1233E6PZ , TM4C1233H6PGE , TM4C1233H6PGE , TM4C1233H6PM , TM4C1233H6PM , TM4C1233H6PZ , TM4C1233H6PZ , TM4C1236D5PM , TM4C1236D5PM , TM4C1236E6PM , TM4C1236E6PM , TM4C1236H6PM , TM4C1236H6PM , TM4C1237D5PM , TM4C1237D5PM , TM4C1237D5PZ , TM4C1237D5PZ , TM4C1237E6PM , TM4C1237E6PM , TM4C1237E6PZ , TM4C1237E6PZ , TM4C1237H6PGE , TM4C1237H6PGE , TM4C1237H6PM , TM4C1237H6PM , TM4C1237H6PZ , TM4C1237H6PZ , TM4C123AE6PM , TM4C123AE6PM , TM4C123AH6PM , TM4C123AH6PM , TM4C123BE6PM , TM4C123BE6PM , TM4C123BE6PZ , TM4C123BE6PZ , TM4C123BH6PGE , TM4C123BH6PGE , TM4C123BH6PM , TM4C123BH6PM , TM4C123BH6PZ , TM4C123BH6PZ , TM4C123BH6ZRB , TM4C123BH6ZRB , TM4C123FE6PM , TM4C123FE6PM , TM4C123FH6PM , TM4C123FH6PM , TM4C123GE6PM , TM4C123GE6PM , TM4C123GE6PZ , TM4C123GE6PZ , TM4C123GH6PGE , TM4C123GH6PGE , TM4C123GH6PM , TM4C123GH6PM , TM4C123GH6PZ , TM4C123GH6PZ , TM4C123GH6ZRB , TM4C123GH6ZRB , TM4C1290NCPDT , TM4C1290NCPDT , TM4C1290NCZAD , TM4C1290NCZAD , TM4C1292NCPDT , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1297NCZAD , TM4C1297NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129CNCPDT , TM4C129CNCPDT , TM4C129CNCZAD , TM4C129CNCZAD , TM4C129DNCPDT , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD

 

  1.   Trademarks
  2. 1Introduction
  3. 2Pulse Width Modulation (PWM) emulation of a DAC
  4. 3Audio Sampling Rate and Resolution Analysis
    1. 3.1 Using the PWM DAC Method
    2. 3.2 Using Off-Chip DAC
  5. 4Audio File Data Format
    1. 4.1 WAV File Size Calculation
    2. 4.2 Storing WAV Audio on Internal Flash
  6. 5Hardware Setup
    1. 5.1 BOOSTXL-AUDIO BoosterPack Overview
    2. 5.2 Hardware Setup for EK-TM4C1294XL
    3. 5.3 Hardware Setup for EK-TM4C123GXL
    4. 5.4 Hardware Setup for DK-TM4C129x Development Board
  7. 6Application Examples
    1. 6.1 Examples: audio_playback_internal_wavefile_by_PWM_EKTM4C129 and audio_playback_internal_wavefile_by_SPIDAC_EKTM4C129
    2. 6.2 Examples: audio_playback_internal_wavefile_by_PWM_EKTM4C123 and audio_playback_internal_wavefile_by_SPIDAC_EKTM4C123
    3. 6.3 Examples: audio_playback_internal_wavefile_by_PWM and audio_playback_internal_wavefile_by_SPIDAC
    4. 6.4 Examples: audio_playback_with_sdcard_by_PWM and audio_playback_with_sdcard_by_SPIDAC
  8. 7Download and Import the Examples
  9. 8References

WAV File Size Calculation

WAV is an uncompressed audio format based on Pulse Code Modulation (PCM) to digitally represent sampled analog signals. Details of WAV format can be readily found on the internet. Since WAV is an uncompressed format, the file size for a single audio clip can be very large. The required amount of storage can be quickly calculated for a WAV file as follows:

Equation 3. S = SR * (BL / 8) * C * L / 106

Where:

  • S: Storage (in MB)
  • L: Length of audio (in seconds)
  • SR: Sample rate (8 kHz, 16 kHz, 22.05 kHz, 44.1 kHz or 48 kHz)
  • BL: Bit Length (8 or 16)
  • C: Number of audio channels (1 for mono or 2 or stereo)

For a typical CD quality 4-minute song recorded in WAV format, it will take:

Equation 3. S = = 44100 * (16 / 8) * 2 * (4 * 60) / 106 = 42.3MB

This is certainly much larger than MP3 where a same length song may be less than 5MB. Unless the audio is short, it cannot fit into MCU’s internal flash memory. Some of the examples in this application report use short audio clips that will fit into internal flash memory. Other examples store the WAV files on an external SD card for playback. Details of these examples are discussed in later sections.