The "GR-PEACH_Audio_Playback_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

Dependencies:   R_BSP TLV320_RBSP USBHost_custom

Note

For a sample program of with LCD Board,
please refer to GR-PEACH_Audio_Playback_7InchLCD_Sample.

Introduction

The "GR-PEACH_Audio_Playback_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

1. Overview of the Sample Code

1.1 Software Block Diagram

Figure 1.1 shows the software block diagram.

/media/uploads/dkato/audioplayback_figure1_1x.png

1.2 Pin Definitions

Table 1.1 shows the pins that this sample code are to use.

/media/uploads/dkato/audioplayback_table1_1.png

2. Sample Code Operating Environment

This sample code runs in GR-PEACH + the Audio/Camera shield for the GR-PEACH environment. This section explains the functions of the ports that are used by this sample code.

2.1 Operating Environment

Figure 2.1 shows the configuration of the operating environment for running this sample code.

/media/uploads/dkato/audioplayback_figure2_1.png /media/uploads/1050186/figure2_2.png /media/uploads/dkato/audioplayback_figure2_3.png

2.2 List of User Operations

A list of user operations on the command line, TFT touch keys, and switch key that the user can perform for this sample code is shown in. Table 2.1.

/media/uploads/dkato/audioplayback_table2_1x.png

3. Function Outline

The functions of this sample code are summarized in Table 3.1 to Table 3.3.

/media/uploads/dkato/audioplayback_table3_1.png /media/uploads/dkato/audioplayback_table3_2.png /media/uploads/dkato/audioplayback_table3_3.png /media/uploads/dkato/audioplayback_figure3_1.png

3.1 Playback Control

The playback control that the sample code supports include play, pause, stop, skip to next, and skip to previous.

3.2 Trick Play Control

Manipulating "Repeat" alternates between "Repeat mode On" and "Repeat mode Off". The default mode is "Repeat mode On". When the repeat mode is on, the playback of the first song starts after the playback of the last song is finished. When the repeat mode is off, the sample code enters the stopped state after the playback of the last song is finished.

3.3 Acquisition of the Song Information

The information of the song being played is obtained by operating the "Play info" during the playback of the song. Table 3.4 lists the items of information that can be obtained by the "Play info" operation.

/media/uploads/dkato/audioplayback_table3_4.png

3.4 How the Folder Structure is Analyzed

The sample coded analyzes the folder structure in the breadth-first search order. The order in which files are numbered is illustrated in Table 3.5. The sample code does not sort the files by file or folder name.

/media/uploads/dkato/audioplayback_table3_5.png

4.Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Committer:
Osamu Nakamura
Date:
Fri Mar 31 14:00:23 2017 +0900
Revision:
6:df19c3e787ca
Parent:
0:ee40da884cfc
Introduced mbedOS 5 instead of mbedOS 2 (classic)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:ee40da884cfc 1 /* FLAC - Free Lossless Audio Codec
dkato 0:ee40da884cfc 2 * Copyright (C) 2001-2009 Josh Coalson
dkato 0:ee40da884cfc 3 * Copyright (C) 2011-2014 Xiph.Org Foundation
dkato 0:ee40da884cfc 4 *
dkato 0:ee40da884cfc 5 * This file is part the FLAC project. FLAC is comprised of several
dkato 0:ee40da884cfc 6 * components distributed under different licenses. The codec libraries
dkato 0:ee40da884cfc 7 * are distributed under Xiph.Org's BSD-like license (see the file
dkato 0:ee40da884cfc 8 * COPYING.Xiph in this distribution). All other programs, libraries, and
dkato 0:ee40da884cfc 9 * plugins are distributed under the LGPL or GPL (see COPYING.LGPL and
dkato 0:ee40da884cfc 10 * COPYING.GPL). The documentation is distributed under the Gnu FDL (see
dkato 0:ee40da884cfc 11 * COPYING.FDL). Each file in the FLAC distribution contains at the top the
dkato 0:ee40da884cfc 12 * terms under which it may be distributed.
dkato 0:ee40da884cfc 13 *
dkato 0:ee40da884cfc 14 * Since this particular file is relevant to all components of FLAC,
dkato 0:ee40da884cfc 15 * it may be distributed under the Xiph.Org license, which is the least
dkato 0:ee40da884cfc 16 * restrictive of those mentioned above. See the file COPYING.Xiph in this
dkato 0:ee40da884cfc 17 * distribution.
dkato 0:ee40da884cfc 18 */
dkato 0:ee40da884cfc 19
dkato 0:ee40da884cfc 20
dkato 0:ee40da884cfc 21 FLAC is an Open Source lossless audio codec developed by Josh Coalson from 2001
dkato 0:ee40da884cfc 22 to 2009.
dkato 0:ee40da884cfc 23
dkato 0:ee40da884cfc 24 From January 2012 FLAC is being maintained by Erik de Castro Lopo under the
dkato 0:ee40da884cfc 25 auspices of the Xiph.org Foundation.
dkato 0:ee40da884cfc 26
dkato 0:ee40da884cfc 27 FLAC is comprised of
dkato 0:ee40da884cfc 28 * `libFLAC', a library which implements reference encoders and
dkato 0:ee40da884cfc 29 decoders for native FLAC and Ogg FLAC, and a metadata interface
dkato 0:ee40da884cfc 30 * `libFLAC++', a C++ object wrapper library around libFLAC
dkato 0:ee40da884cfc 31 * `flac', a command-line program for encoding and decoding files
dkato 0:ee40da884cfc 32 * `metaflac', a command-line program for viewing and editing FLAC
dkato 0:ee40da884cfc 33 metadata
dkato 0:ee40da884cfc 34 * player plugin for XMMS
dkato 0:ee40da884cfc 35 * user and API documentation
dkato 0:ee40da884cfc 36
dkato 0:ee40da884cfc 37 The libraries (libFLAC, libFLAC++) are
dkato 0:ee40da884cfc 38 licensed under Xiph.org's BSD-like license (see COPYING.Xiph). All other
dkato 0:ee40da884cfc 39 programs and plugins are licensed under the GNU General Public License
dkato 0:ee40da884cfc 40 (see COPYING.GPL). The documentation is licensed under the GNU Free
dkato 0:ee40da884cfc 41 Documentation License (see COPYING.FDL).
dkato 0:ee40da884cfc 42
dkato 0:ee40da884cfc 43
dkato 0:ee40da884cfc 44 ===============================================================================
dkato 0:ee40da884cfc 45 FLAC - 1.3.1 - Contents
dkato 0:ee40da884cfc 46 ===============================================================================
dkato 0:ee40da884cfc 47
dkato 0:ee40da884cfc 48 - Introduction
dkato 0:ee40da884cfc 49 - Prerequisites
dkato 0:ee40da884cfc 50 - Note to embedded developers
dkato 0:ee40da884cfc 51 - Building in a GNU environment
dkato 0:ee40da884cfc 52 - Building with Makefile.lite
dkato 0:ee40da884cfc 53 - Building with MSVC
dkato 0:ee40da884cfc 54 - Building on Mac OS X
dkato 0:ee40da884cfc 55
dkato 0:ee40da884cfc 56
dkato 0:ee40da884cfc 57 ===============================================================================
dkato 0:ee40da884cfc 58 Introduction
dkato 0:ee40da884cfc 59 ===============================================================================
dkato 0:ee40da884cfc 60
dkato 0:ee40da884cfc 61 This is the source release for the FLAC project. See
dkato 0:ee40da884cfc 62
dkato 0:ee40da884cfc 63 doc/html/index.html
dkato 0:ee40da884cfc 64
dkato 0:ee40da884cfc 65 for full documentation.
dkato 0:ee40da884cfc 66
dkato 0:ee40da884cfc 67 A brief description of the directory tree:
dkato 0:ee40da884cfc 68
dkato 0:ee40da884cfc 69 doc/ the HTML documentation
dkato 0:ee40da884cfc 70 examples/ example programs demonstrating the use of libFLAC and libFLAC++
dkato 0:ee40da884cfc 71 include/ public include files for libFLAC and libFLAC++
dkato 0:ee40da884cfc 72 man/ the man pages for `flac' and `metaflac'
dkato 0:ee40da884cfc 73 src/ the source code and private headers
dkato 0:ee40da884cfc 74 test/ the test scripts
dkato 0:ee40da884cfc 75
dkato 0:ee40da884cfc 76 If you have questions about building FLAC that this document does not answer,
dkato 0:ee40da884cfc 77 please submit them at the following tracker so this document can be improved:
dkato 0:ee40da884cfc 78
dkato 0:ee40da884cfc 79 https://sourceforge.net/p/flac/support-requests/
dkato 0:ee40da884cfc 80
dkato 0:ee40da884cfc 81
dkato 0:ee40da884cfc 82 ===============================================================================
dkato 0:ee40da884cfc 83 Prerequisites
dkato 0:ee40da884cfc 84 ===============================================================================
dkato 0:ee40da884cfc 85
dkato 0:ee40da884cfc 86 To build FLAC with support for Ogg FLAC you must have built and installed
dkato 0:ee40da884cfc 87 libogg according to the specific instructions below. You must have
dkato 0:ee40da884cfc 88 libogg 1.1.2 or greater, or there will be seeking problems with Ogg FLAC.
dkato 0:ee40da884cfc 89
dkato 0:ee40da884cfc 90 If you are building on x86 and want the assembly optimizations, you will
dkato 0:ee40da884cfc 91 need to have NASM >= 0.98.30 installed according to the specific instructions
dkato 0:ee40da884cfc 92 below.
dkato 0:ee40da884cfc 93
dkato 0:ee40da884cfc 94
dkato 0:ee40da884cfc 95 ===============================================================================
dkato 0:ee40da884cfc 96 Note to embedded developers
dkato 0:ee40da884cfc 97 ===============================================================================
dkato 0:ee40da884cfc 98
dkato 0:ee40da884cfc 99 libFLAC has grown larger over time as more functionality has been
dkato 0:ee40da884cfc 100 included, but much of it may be unnecessary for a particular embedded
dkato 0:ee40da884cfc 101 implementation. Unused parts may be pruned by some simple editing of
dkato 0:ee40da884cfc 102 configure.ac and src/libFLAC/Makefile.am; the following dependency
dkato 0:ee40da884cfc 103 graph shows which modules may be pruned without breaking things
dkato 0:ee40da884cfc 104 further down:
dkato 0:ee40da884cfc 105
dkato 0:ee40da884cfc 106 metadata.h
dkato 0:ee40da884cfc 107 stream_decoder.h
dkato 0:ee40da884cfc 108 format.h
dkato 0:ee40da884cfc 109
dkato 0:ee40da884cfc 110 stream_encoder.h
dkato 0:ee40da884cfc 111 stream_decoder.h
dkato 0:ee40da884cfc 112 format.h
dkato 0:ee40da884cfc 113
dkato 0:ee40da884cfc 114 stream_decoder.h
dkato 0:ee40da884cfc 115 format.h
dkato 0:ee40da884cfc 116
dkato 0:ee40da884cfc 117 In other words, for pure decoding applications, both the stream encoder
dkato 0:ee40da884cfc 118 and metadata editing interfaces can be safely removed.
dkato 0:ee40da884cfc 119
dkato 0:ee40da884cfc 120 There is a section dedicated to embedded use in the libFLAC API
dkato 0:ee40da884cfc 121 HTML documentation (see doc/html/api/index.html).
dkato 0:ee40da884cfc 122
dkato 0:ee40da884cfc 123 Also, there are several places in the libFLAC code with comments marked
dkato 0:ee40da884cfc 124 with "OPT:" where a #define can be changed to enable code that might be
dkato 0:ee40da884cfc 125 faster on a specific platform. Experimenting with these can yield faster
dkato 0:ee40da884cfc 126 binaries.
dkato 0:ee40da884cfc 127
dkato 0:ee40da884cfc 128
dkato 0:ee40da884cfc 129 ===============================================================================
dkato 0:ee40da884cfc 130 Building in a GNU environment
dkato 0:ee40da884cfc 131 ===============================================================================
dkato 0:ee40da884cfc 132
dkato 0:ee40da884cfc 133 FLAC uses autoconf and libtool for configuring and building.
dkato 0:ee40da884cfc 134 Better documentation for these will be forthcoming, but in
dkato 0:ee40da884cfc 135 general, this should work:
dkato 0:ee40da884cfc 136
dkato 0:ee40da884cfc 137 ./configure && make && make check && make install
dkato 0:ee40da884cfc 138
dkato 0:ee40da884cfc 139 The 'make check' step is optional; omit it to skip all the tests,
dkato 0:ee40da884cfc 140 which can take several hours and use around 70-80 megs of disk space.
dkato 0:ee40da884cfc 141 Even though it will stop with an explicit message on any failure, it
dkato 0:ee40da884cfc 142 does print out a lot of stuff so you might want to capture the output
dkato 0:ee40da884cfc 143 to a file if you're having a problem. Also, don't run 'make check'
dkato 0:ee40da884cfc 144 as root because it confuses some of the tests.
dkato 0:ee40da884cfc 145
dkato 0:ee40da884cfc 146 NOTE: Despite our best efforts it's entirely possible to have
dkato 0:ee40da884cfc 147 problems when using older versions of autoconf, automake, or
dkato 0:ee40da884cfc 148 libtool. If you have the latest versions and still can't get it
dkato 0:ee40da884cfc 149 to work, see the next section on Makefile.lite.
dkato 0:ee40da884cfc 150
dkato 0:ee40da884cfc 151 There are a few FLAC-specific arguments you can give to
dkato 0:ee40da884cfc 152 `configure':
dkato 0:ee40da884cfc 153
dkato 0:ee40da884cfc 154 --enable-debug : Builds everything with debug symbols and some
dkato 0:ee40da884cfc 155 extra (and more verbose) error checking.
dkato 0:ee40da884cfc 156
dkato 0:ee40da884cfc 157 --disable-asm-optimizations : Disables the compilation of the
dkato 0:ee40da884cfc 158 assembly routines. Many routines have assembly versions for
dkato 0:ee40da884cfc 159 speed and `configure' is pretty good about knowing what is
dkato 0:ee40da884cfc 160 supported, but you can use this option to build only from the
dkato 0:ee40da884cfc 161 C sources. May be necessary for building on OS X (Intel).
dkato 0:ee40da884cfc 162
dkato 0:ee40da884cfc 163 --enable-sse : If you are building for an x86 CPU that supports
dkato 0:ee40da884cfc 164 SSE instructions, you can enable some of the faster routines
dkato 0:ee40da884cfc 165 if your operating system also supports SSE instructions. flac
dkato 0:ee40da884cfc 166 can tell if the CPU supports the instructions but currently has
dkato 0:ee40da884cfc 167 no way to test if the OS does, so if it does, you must pass
dkato 0:ee40da884cfc 168 this argument to configure to use the SSE routines. If flac
dkato 0:ee40da884cfc 169 crashes when built with this option you will have to go back and
dkato 0:ee40da884cfc 170 configure without --enable-sse. Note that
dkato 0:ee40da884cfc 171 --disable-asm-optimizations implies --disable-sse.
dkato 0:ee40da884cfc 172
dkato 0:ee40da884cfc 173 --enable-local-xmms-plugin : Installs the FLAC XMMS plugin in
dkato 0:ee40da884cfc 174 $HOME/.xmms/Plugins, instead of the global XMMS plugin area
dkato 0:ee40da884cfc 175 (usually /usr/lib/xmms/Input).
dkato 0:ee40da884cfc 176
dkato 0:ee40da884cfc 177 --with-ogg=
dkato 0:ee40da884cfc 178 --with-xmms-prefix=
dkato 0:ee40da884cfc 179 --with-libiconv-prefix=
dkato 0:ee40da884cfc 180 Use these if you have these packages but configure can't find them.
dkato 0:ee40da884cfc 181
dkato 0:ee40da884cfc 182 If you want to build completely from scratch (i.e. starting with just
dkato 0:ee40da884cfc 183 configure.ac and Makefile.am) you should be able to just run 'autogen.sh'
dkato 0:ee40da884cfc 184 but make sure and read the comments in that file first.
dkato 0:ee40da884cfc 185
dkato 0:ee40da884cfc 186
dkato 0:ee40da884cfc 187 ===============================================================================
dkato 0:ee40da884cfc 188 Building with Makefile.lite
dkato 0:ee40da884cfc 189 ===============================================================================
dkato 0:ee40da884cfc 190
dkato 0:ee40da884cfc 191 There is a more lightweight build system for do-it-yourself-ers.
dkato 0:ee40da884cfc 192 It is also useful if configure isn't working, which may be the
dkato 0:ee40da884cfc 193 case since lately we've had some problems with different versions
dkato 0:ee40da884cfc 194 of automake and libtool. The Makefile.lite system should work
dkato 0:ee40da884cfc 195 on GNU systems with few or no adjustments.
dkato 0:ee40da884cfc 196
dkato 0:ee40da884cfc 197 From the top level just 'make -f Makefile.lite'. You can
dkato 0:ee40da884cfc 198 specify zero or one optional target from 'release', 'debug',
dkato 0:ee40da884cfc 199 'test', or 'clean'. The default is 'release'. There is no
dkato 0:ee40da884cfc 200 'install' target but everything you need will end up in the
dkato 0:ee40da884cfc 201 obj/ directory.
dkato 0:ee40da884cfc 202
dkato 0:ee40da884cfc 203 If you are not on an x86 system or you don't have nasm, you
dkato 0:ee40da884cfc 204 may have to change the DEFINES in src/libFLAC/Makefile.lite. If
dkato 0:ee40da884cfc 205 you don't have nasm, remove -DFLAC__HAS_NASM. If your target is
dkato 0:ee40da884cfc 206 not an x86, change -DFLAC__CPU_IA32 to -DFLAC__CPU_UNKNOWN.
dkato 0:ee40da884cfc 207
dkato 0:ee40da884cfc 208
dkato 0:ee40da884cfc 209 ===============================================================================
dkato 0:ee40da884cfc 210 Building with MSVC
dkato 0:ee40da884cfc 211 ===============================================================================
dkato 0:ee40da884cfc 212
dkato 0:ee40da884cfc 213 There are .vcproj projects and a master FLAC.sln solution to build all
dkato 0:ee40da884cfc 214 the libraries and executables with MSVC 2005 or newer.
dkato 0:ee40da884cfc 215
dkato 0:ee40da884cfc 216 Prerequisite: you must have the Ogg libraries installed as described
dkato 0:ee40da884cfc 217 later.
dkato 0:ee40da884cfc 218
dkato 0:ee40da884cfc 219 Prerequisite: you must have nasm installed, and nasm.exe must be in
dkato 0:ee40da884cfc 220 your PATH, or the path to nasm.exe must be added to the list of
dkato 0:ee40da884cfc 221 directories for executable files in the MSVC global options.
dkato 0:ee40da884cfc 222
dkato 0:ee40da884cfc 223 To build everything, run Visual Studio, do File|Open and open FLAC.sln.
dkato 0:ee40da884cfc 224 From the dropdown in the toolbar, select "Release" instead of "Debug",
dkato 0:ee40da884cfc 225 then do Build|Build Solution.
dkato 0:ee40da884cfc 226
dkato 0:ee40da884cfc 227 This will build all libraries both statically (e.g.
dkato 0:ee40da884cfc 228 objs\release\lib\libFLAC_static.lib) and as DLLs (e.g.
dkato 0:ee40da884cfc 229 objs\release\lib\libFLAC.dll), and it will build all binaries, statically
dkato 0:ee40da884cfc 230 linked (e.g. objs\release\bin\flac.exe).
dkato 0:ee40da884cfc 231
dkato 0:ee40da884cfc 232 Everything will end up in the "objs" directory. DLLs and .exe files
dkato 0:ee40da884cfc 233 are all that are needed and can be copied to an installation area and
dkato 0:ee40da884cfc 234 added to the PATH.
dkato 0:ee40da884cfc 235
dkato 0:ee40da884cfc 236 By default the code is configured with Ogg support. Before building FLAC
dkato 0:ee40da884cfc 237 you will need to get the Ogg source distribution
dkato 0:ee40da884cfc 238 (see http://xiph.org/downloads/), build libogg_static.lib (load
dkato 0:ee40da884cfc 239 win32\libogg_static.sln, change solution configuration to "Release" and
dkato 0:ee40da884cfc 240 code generation to "Multi-threaded (/MT)", then build), copy libogg_static.lib
dkato 0:ee40da884cfc 241 into FLAC's 'objs\release\lib' directory, and copy the entire include\ogg tree
dkato 0:ee40da884cfc 242 into FLAC's 'include' directory (so that there is an 'ogg' directory in FLAC's
dkato 0:ee40da884cfc 243 'include' directory with the files ogg.h, os_types.h and config_types.h).
dkato 0:ee40da884cfc 244
dkato 0:ee40da884cfc 245 If you want to build without Ogg support, instead edit all .vcproj files
dkato 0:ee40da884cfc 246 and remove any "FLAC__HAS_OGG" definitions.
dkato 0:ee40da884cfc 247
dkato 0:ee40da884cfc 248
dkato 0:ee40da884cfc 249 ===============================================================================
dkato 0:ee40da884cfc 250 Building on Mac OS X
dkato 0:ee40da884cfc 251 ===============================================================================
dkato 0:ee40da884cfc 252
dkato 0:ee40da884cfc 253 If you have Fink or a recent version of OS X with the proper autotools,
dkato 0:ee40da884cfc 254 the GNU flow above should work.