AN_276 Audio Converter

Application Note
AN_276
FT800 Audio File Conversion
Version 1.0
Issue Date: 2014-02-10
This document shows how to change an audio file into the correct format for
the FT800 audio player.
Use of FTDI devices in life support and/or safety applications is entirely at the user’s risk, and the
user agrees to defend, indemnify and hold FTDI harmless from any and all damages, claims, suits
or expense resulting from such use.
Future Technology Devices International Limited (FTDI)
Unit 1, 2 Seaward Place, Glasgow G41 1HH, United Kingdom
Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758
Web Site: http://ftdichip.com
Copyright © 2011 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
Table of Contents
1
Introduction .................................................................................................................................... 2
1.1
Scope ....................................................................................................................................... 2
1.2
Software Required .................................................................................................................. 2
1.3
FT800 Audio Requirements..................................................................................................... 2
2
Working with Audacity.................................................................................................................... 3
3
Working with the FT800 Audio Converter ...................................................................................... 5
4
Configuring FT800 Audio Playback Properties ................................................................................ 6
5
Conclusion ....................................................................................................................................... 7
6
Contact Information........................................................................................................................ 8
Appendix A – References ........................................................................................................................ 9
Document References......................................................................................................................... 9
Acronyms and Abbreviations .............................................................................................................. 9
Appendix B – List of Tables & Figures ................................................................................................... 10
List of Tables ..................................................................................................................................... 10
List of Figures .................................................................................................................................... 10
Appendix C – Revision History .............................................................................................................. 11
Product Page
Document Feedback
1
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
1 Introduction
This applications note documents how to convert audio files (mp3, ogg Vorbis, AIFF) to an FT800
compatible format.
1.1 Scope
This document covers the basic file conversion process and how to access the converted audio files
with the FT800.
1.2 Software Required


Audacity (open source, available for free download)
Aud_Cvt (EVE Audio Converter)
1.3 FT800 Audio Requirements
The FT800 can use the following audio formats for monaural playback:



8 bit signed PCM
8 bit u-Law
4 bit IMA ADPCM
Figure 1.1 shows the audio file conversion flow:
Figure 1.1 File Conversion Flow
Product Page
Document Feedback
2
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
2 Working with Audacity
Start the Audacity tool and open an existing mp3 music file by using the File/Open pull down
menu. In this example, I.Allegro.mp3 is selected.
Table 2.1 Audacity file selection
The mp3 file will be read into Audacity. The file must be converted from stereo to mono by
clicking on the options icon in the margin and selecting “Split Stereo to Mono” in the pull down
menu.
Make a note of the sampling rate, since this will be used in the FT800 application.
Table 2.2 Audacity audio options
Product Page
Document Feedback
3
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
The Audacity screen will look like this after Mono mode is selected:
Table 2.3 Mono mode enabled
In the File pull down menu, select “Export” and save the file as a 16 bit signed PCM wav file:
Table 2.4 Save WAV as 16 bit PCM
Click “OK” on the succeeding pop-up menus. The WAV file is now in the correct 16 bit signed PCM
wav format for the next conversion step.
Product Page
Document Feedback
4
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
3 Working with the FT800 Audio Converter
The FT800 audio conversion utility is aud_cvt. This utility only works with 16 bit PCM coded WAV
files.
Open a command prompt window (DOS window) and change the working directory to the folder
containing the aud_cvt.exe. It is also advisable to copy the file to be converted to this folder.
Command line format:
aud_cvt –i
input_filename –f format <ret>
Output format options:
0 : 8 Bit signed PCM
1 : 8 Bit u-Law
2 : 4 Bit IMA ADPCM
In most cases, 8 Bit u-Law is the target format.
For the I.Allegro WAV file, the command is as follows:
aud_cvt –i I.Allegro.wav –f 1 <ret>
This will create a subdirectory called I_8 Bit uLaw. The target file in this subdirectory will be
I.raw. The sampling rate will also be displayed when aud_cvt runs.
This raw format audio file is now ready for use with the FT800.
Product Page
Document Feedback
5
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
4 Configuring FT800 Audio Playback Properties
Set the sampling rate of the input audio file by using the REG_PLAYBACK_FREQ register. The
sampling rate may change based on the structure of the audio file. Refer to the output from
Audacity or aud_cvt to get the sampling rate.
Ft_Gpu_Hal_Wr32(phost,REG_PLAYBACK_FREQ,44100); //16 bit PCM wav sampling rate 44.1kHz
Set the starting location of audio in GRAM by using the REG_PLAYBACK_START register.
Ft_Gpu_Hal_Wr32(phost,REG_PLAYBACK_START,0);
//begin at start of .raw file
Set the size of the GRAM allocated for audio by using the REG_PLAYBACK_LENGTH register.
Ft_Gpu_Hal_Wr32(phost,REG_PLAYBACK_LENGTH,8192L);
//default is 8192L
In this demo application, the allocated size of GRAM is 8KB.
Set the audio file type to u-Law by using the REG_PLAYBACK _FORMAT register.
Ft_Gpu_Hal_Wr32(phost,REG_PLAYBACK_FORMAT,1);
// default is ULAW_SAMPLES
Set the speaker volume by using the REG_VOL_PB register. Default volume is 100.
Ft_Gpu_Hal_Wr8(phost,REG_VOL_PB,100);
Read in the audio file from the project subdirectory as follows:
afile = fopen("..\\..\\..\\Test\\filename.raw","rb"); //read binary (rb) filename.raw
In this example, the size of the audio file is about 9 MB. The 8KB of GRAM is looped for 9MB audio
by setting the register REG_PLAYBACK_LOOP to 1:
Ft_Gpu_Hal_Wr32(phost,REG_PLAYBACK_LOOP,1);
//default is 1 loop
If the audio file is less than 8KB, set the register REG_PLAYBACK_LOOP to 0.
The 9 MB audio file will be processed by performing multiple read/writes of GRAM memory. The
REG_PLAYBACK_READPTR command keeps track of how much of the audio file has been read.
fseek(afile,0,SEEK_END);
ftsize = ftell(afile);
fseek(afile,0,SEEK_SET);
Load_afile(0,afile);
wp = 512L;
Ft_Gpu_Hal_Wr8(phost,REG_PLAYBACK_PLAY,1);
while(ftsize > 0)
{
rp = Ft_Gpu_Hal_Rd16(phost,REG_PLAYBACK_READPTR);
val = 8191L & (rp-wp);
if (val > 512L)
{
n = min(512L,ftsize);
Load_afile(wp,afile);
wp = (wp +512L) & 8191L;
ftsize-=n;
}
}
Ft_Gpu_Hal_Wr8(phost,REG_VOL_PB,0);
Ft_Gpu_Hal_Wr8(phost,REG_PLAYBACK_PLAY,0);
Product Page
Document Feedback
6
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
5 Conclusion
The conversion procedure described in this application note can be used to create audio files for
playback within the FT800. This expands the audio capability of the FT800 beyond the range of the
in-built polyphonic tones helping to create a rich and feature filled HMI solution.
Product Page
Document Feedback
7
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
6 Contact Information
Head Office – Glasgow, UK
Branch Office – Tigard, Oregon, USA
Future Technology Devices International Limited
Unit 1, 2 Seaward Place, Centurion Business Park
Glasgow G41 1HH
United Kingdom
Tel: +44 (0) 141 429 2777
Fax: +44 (0) 141 429 2758
Future Technology Devices International Limited
(USA)
7130 SW Fir Loop
Tigard, OR 97223-8160
USA
Tel: +1 (503) 547 0988
Fax: +1 (503) 547 0987
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
E-Mail (Sales)
E-Mail (Support)
E-Mail (General Enquiries)
[email protected]
[email protected]
[email protected]
Branch Office – Taipei, Taiwan
Branch Office – Shanghai, China
Future Technology Devices International Limited
(Taiwan)
2F, No. 516, Sec. 1, NeiHu Road
Taipei 114
Taiwan , R.O.C.
Tel: +886 (0) 2 8791 3570
Fax: +886 (0) 2 8791 3576
Future Technology Devices International Limited
(China)
Room 1103, No. 666 West Huaihai Road,
Shanghai, 200052
China
Tel: +86 21 62351596
Fax: +86 21 62351595
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Web Site
http://ftdichip.com
System and equipment manufacturers and designers are responsible to ensure that their systems, and any Future Technology
Devices International Ltd (FTDI) devices incorporated in their systems, meet all applicable safety, regulatory and system-level
performance requirements. All application-related information in this document (including application descriptions, suggested
FTDI devices and other materials) is provided for reference only. While FTDI has taken care to assure it is accurate, this
information is subject to customer confirmation, and FTDI disclaims all liability for system designs and for any applications
assistance provided by FTDI. Use of FTDI devices in life support and/or safety applications is entirely at the user’s risk, and the
user agrees to defend, indemnify and hold harmless FTDI from any and all damages, claims, suits or expense resulting from
such use. This document is subject to change without notice. No freedom to use patents or other intellectual property rights is
implied by the publication of this document. Neither the whole nor any part of the information contained in, or the product
described in this document, may be adapted or reproduced in any material or electronic form without the prior written consent
of the copyright holder. Future Technology Devices International Ltd, Unit 1, 2 Seaward Place, Centurion Business Park,
Glasgow G41 1HH, United Kingdom. Scotland Registered Company Number: SC136640
Product Page
Document Feedback
8
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
Appendix A – References
Document References
Replace this text. List FTDI and external datasheets, application notes, website links and other
documents. Notice the hyperlink in the example.
AN_146 USB Hardware Design Guides for FTDI ICs
AN_267 FT App Player
Acronyms and Abbreviations
Terms
Description
AD-PCM
Adaptive pulse code modulation varies the quantization of the analog
source to improve sound quality and reduce file size.
PCM
u-Law PCM
Product Page
Document Feedback
Pulse Code modulation is used to digitally sample analog signals.
Type of PCM format using a 16-bit signed linear audio sample as input,
outputs an 8 bit sample.
9
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
Appendix B – List of Tables & Figures
List of Tables
Table 2.1 Audacity file selection ............................................................................................ 3
Table 2.2 Audacity audio options........................................................................................... 3
Table 2.3 Mono mode enabled .............................................................................................. 4
Table 2.3 Save WAV as 16 bit PCM ........................................................................................ 4
List of Figures
Figure 1.1 File Conversion Flow............................................................................................. 2
Product Page
Document Feedback
10
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Clearance No.: FTDI# 369
Appendix C – Revision History
Document Title:
AN_276 FT800 Audio File Conversion
Document Reference No.:
FT_000937
Clearance No.:
FTDI# 369
Product Page:
http://www.ftdichip.com/FTProducts.htm
Document Feedback:
Send Feedback
Revision
1.0
Product Page
Document Feedback
Changes
Initial Release
Date
2014-02-10
11
Copyright © 2013 Future Technology Devices International Limited
Application Note
AN_276 FT800 Audio File Conversion
Version 1.0
Document Reference No.: FT_000937
Product Page
Document Feedback
Clearance No.: FTDI# 369
12
Copyright © 2013 Future Technology Devices International Limited