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.
1.2 Pin Definitions
Table 1.1 shows the pins that this sample code are to use.
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.
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.
3. Function Outline
The functions of this sample code are summarized in Table 3.1 to Table 3.3.
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.
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.
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
Revision 2:d9fca8cd7f03, committed 2015-11-05
- Comitter:
- dkato
- Date:
- Thu Nov 05 02:46:24 2015 +0000
- Parent:
- 1:315326ec910b
- Child:
- 3:44c8558c3a83
- Commit message:
- The output frequency was changed to 96kHz. The help command was added.
Changed in this revision
--- a/TLV320_RBSP.lib Tue Oct 20 10:22:12 2015 +0000 +++ b/TLV320_RBSP.lib Thu Nov 05 02:46:24 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Renesas/code/TLV320_RBSP/#db6504d3f914 +http://mbed.org/teams/Renesas/code/TLV320_RBSP/#15487e571d9f
--- a/audio_out/audio_out.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/audio_out/audio_out.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -67,7 +67,7 @@
#define OUTPUT_UPDATE_TRIGGER (1) /* Numerical value of the trigger */
/* to update the output of PCM data */
-#define PCM_BUF_NUM (9u)
+#define PCM_BUF_NUM (DEC_SCUX_READ_NUM)
#define TOTAL_SAMPLE_NUM (SAMPLE_PER_UNIT_MS * DEC_OUTPUT_CHANNEL_NUM)
/*--- Macro definition of TLV320_RBSP ---*/
--- a/decode/decode.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/decode/decode.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -83,7 +83,7 @@
/*--- Macro definition of R_BSP_Scux ---*/
#define SCUX_INT_LEVEL (0x80)
-#define SCUX_READ_NUM (PCM_BUF_NUM)
+#define SCUX_READ_NUM (DEC_SCUX_READ_NUM)
#define SCUX_WRITE_NUM (PCM_BUF_NUM)
/* 4 bytes aligned. No cache memory. */
@@ -393,7 +393,7 @@
/* Sets SCUX config */
conf.src_enable = true;
conf.word_len = SCUX_DATA_LEN_24;
- conf.mode_sync = false;
+ conf.mode_sync = true;
conf.input_rate = p_ctrl->sample_rate;
conf.output_rate = DEC_OUTPUT_SAMPLE_RATE;
conf.select_in_data_ch[0] = SELECT_IN_DATA_CH_0;
--- a/decode/decode.h Tue Oct 20 10:22:12 2015 +0000 +++ b/decode/decode.h Thu Nov 05 02:46:24 2015 +0000 @@ -36,13 +36,14 @@ #define DEC_24BITS_PER_SAMPLE (24u) /* Bit count per sample */ #define DEC_MAX_CHANNEL_NUM (2u) /* Maximum number of channel */ #define DEC_OUTPUT_PADDING_BITS (8u) /* Padding of lower 8 bits */ +#define DEC_SCUX_READ_NUM (9u) /* The number of buffuer for SCUX read */ /* Minimum sampling rate in Hz of input file */ #define DEC_INPUT_MIN_SAMPLE_RATE (SAMPLING_RATE_22050HZ) /* Maximum sampling rate in Hz of input file */ #define DEC_INPUT_MAX_SAMPLE_RATE (SAMPLING_RATE_96000HZ) /* Sampling rate in Hz of audio output */ -#define DEC_OUTPUT_SAMPLE_RATE (SAMPLING_RATE_88200HZ) +#define DEC_OUTPUT_SAMPLE_RATE (SAMPLING_RATE_96000HZ) /* Channel number of audio output */ #define DEC_OUTPUT_CHANNEL_NUM (DEC_MAX_CHANNEL_NUM) /* Bit count per sample of audio output */
--- a/display/disp_term.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/display/disp_term.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -46,6 +46,17 @@
#define MSG_MODE_ON "on"
#define MSG_MODE_OFF "off"
+#define HELP_CMD_NUM (7u)
+
+/* help information */
+#define HELP_INFO_HELP "help : Show help information for commands."
+#define HELP_INFO_NEXT "next : Select the next song."
+#define HELP_INFO_PLAYINFO "playinfo : Show the song information."
+#define HELP_INFO_PLAYPAUSE "playpause : Control playback/pause."
+#define HELP_INFO_PREV "prev : Select the previous song."
+#define HELP_INFO_REPEAT "repeat : Turn on and off the repeat mode."
+#define HELP_INFO_STOP "stop : Stop playback."
+
#define MIN_TO_SEC (60u)
#define HOUR_TO_SEC (3600u)
@@ -53,6 +64,7 @@
static void output_prompt(const dsp_com_ctrl_t * const p_com);
static void output_playinfo(const dsp_com_ctrl_t * const p_com);
+static void output_help_info(void);
static void clear_current_line(void);
static void output_cr(void);
static void output_string(const char_t * const p_str);
@@ -109,6 +121,11 @@
output_string(&p_com->file_name[0]);
output_cr();
break;
+ case DSP_MAILID_HELP: /* Help information */
+ is_update = true;
+ clear_current_line();
+ output_help_info();
+ break;
case DSP_MAILID_CYCLE_IND: /* Cyclic notice */
default: /* Unexpected cases : mail id was illegal. */
is_update = false;
@@ -186,6 +203,31 @@
}
}
+/** Prints the command help informations.
+ *
+ */
+static void output_help_info(void)
+{
+ uint32_t i;
+ struct {
+ const char_t *p_help_info;
+ } static const info_list[HELP_CMD_NUM] = {
+ { HELP_INFO_HELP },
+ { HELP_INFO_NEXT },
+ { HELP_INFO_PLAYINFO },
+ { HELP_INFO_PLAYPAUSE },
+ { HELP_INFO_PREV },
+ { HELP_INFO_REPEAT },
+ { HELP_INFO_STOP }
+ };
+
+ /* Prints the help information in alphabetical order. */
+ for (i = 0u; i < HELP_CMD_NUM; i++) {
+ output_string(info_list[i].p_help_info);
+ output_cr();
+ }
+}
+
/** Clears a cursor line
*
*/
--- a/display/display.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/display/display.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -70,6 +70,11 @@
#define MAIL_FILENAME_STR_START (0) /* Start position of file name string */
#define MAIL_FILENAME_STR_SIZE (64) /* Size of file name string */
+/* mail_id = DSP_MAILID_HELP */
+#define MAIL_HELP_PARAM (0) /* No mail parameter to be used */
+
+#define MAIL_PARAM_NON (0u) /* Value of unused element of mail parameter array */
+
#define BYTE_SHIFT (8u)
#define WORD_SHIFT (16u)
@@ -215,6 +220,17 @@
return ret;
}
+bool dsp_req_help(void)
+{
+ bool ret = false;
+ dsp_mail_t data;
+
+ data.mail_id = DSP_MAILID_HELP;
+ data.param[MAIL_HELP_PARAM] = (uint8_t)MAIL_PARAM_NON;
+ ret = send_mail(&data);
+ return ret;
+}
+
/** initialises the control data of the display module
*
* @param p_ctrl Pointer to control data of display module.
@@ -372,6 +388,9 @@
sizeof(p_ctrl->com.file_name));
p_ctrl->com.file_name[DSP_DISP_STR_MAX_LEN - 1] = '\0';
break;
+ case DSP_MAILID_HELP: /* Help information */
+ ret = true;
+ break;
default:
/* Unexpected cases : mail id was illegal. */
ret = false;
--- a/display/display.h Tue Oct 20 10:22:12 2015 +0000
+++ b/display/display.h Thu Nov 05 02:46:24 2015 +0000
@@ -48,6 +48,7 @@
DSP_MAILID_PLAY_INFO, /* Notifies display thread of playback information. */
DSP_MAILID_PLAY_MODE, /* Notifies display thread of repeat mode. */
DSP_MAILID_FILE_NAME, /* Notifies display thread of file name. */
+ DSP_MAILID_HELP, /* Requests display thread to display help message. */
DSP_MAILID_NUM
} DSP_MAIL_ID;
@@ -202,4 +203,14 @@
*/
bool dsp_notify_input_string(const char_t * const p_str, const bool flag_fin);
+/** Requests the display thread to display help message.
+ *
+ * @returns
+ * Returns true if the API is successful. Returns false if the API fails.
+ * This function fails when:
+ * Failed to secure memory for mailbox communication.
+ * Failed to perform transmit processing for mailbox communication.
+ */
+bool dsp_req_help(void);
+
#endif /* DISPLAY_H */
--- a/key/key_cmd.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/key/key_cmd.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -44,8 +44,9 @@
#define CMD_PREV "PREV" /* Previous track */
#define CMD_PLAYINFO "PLAYINFO" /* Play info */
#define CMD_REPEAT "REPEAT" /* Repeat */
+#define CMD_HELP "HELP" /* Help */
-#define VALID_CMD_NUM (6u)
+#define VALID_CMD_NUM (7u)
#define MAX_CNT_OF_ARG (1u)
@@ -233,7 +234,8 @@
{ CMD_NEXT, SYS_KEYCODE_NEXT },
{ CMD_PREV, SYS_KEYCODE_PREV },
{ CMD_PLAYINFO, SYS_KEYCODE_PLAYINFO },
- { CMD_REPEAT, SYS_KEYCODE_REPEAT }
+ { CMD_REPEAT, SYS_KEYCODE_REPEAT },
+ { CMD_HELP, SYS_KEYCODE_HELP }
};
if (p != NULL) {
--- a/main/system.cpp Tue Oct 20 10:22:12 2015 +0000
+++ b/main/system.cpp Thu Nov 05 02:46:24 2015 +0000
@@ -111,6 +111,7 @@
SYS_EV_KEY_PREV, /* "PREV" key */
SYS_EV_KEY_PLAYINFO, /* "PLAYINFO" key */
SYS_EV_KEY_REPEAT, /* "REPEAT" key */
+ SYS_EV_KEY_HELP, /* "HELP" key */
/* Notification of decoder process */
SYS_EV_DEC_OPEN_COMP, /* Finished the opening process */
SYS_EV_DEC_OPEN_COMP_ERR, /* Finished the opening process (An error occured)*/
@@ -200,6 +201,7 @@
static void print_play_info(const play_info_t * const p_info);
static void print_file_name(const play_info_t * const p_info,
const fid_scan_folder_t * const p_data);
+static void print_help_info(void);
static uint32_t convert_track_id(const uint32_t trk_id);
static bool send_mail(const SYS_MAIL_ID mail_id, const uint32_t param0,
const uint32_t param1, const uint32_t param2);
@@ -341,9 +343,12 @@
case SYS_KEYCODE_PLAYINFO:
ret = SYS_EV_KEY_PLAYINFO;
break;
- case SYS_EV_KEY_REPEAT:
+ case SYS_KEYCODE_REPEAT:
ret = SYS_EV_KEY_REPEAT;
break;
+ case SYS_KEYCODE_HELP:
+ ret = SYS_EV_KEY_HELP;
+ break;
default:
/* Unexpected cases : This is fail-safe processing. */
ret = SYS_EV_NON;
@@ -512,6 +517,8 @@
(void) exe_scan_folder_proc(&p_ctrl->play_info, &p_ctrl->scan_data);
(void) dsp_notify_print_string(PRINT_MSG_USB_CONNECT);
next_stat = SYS_ST_STOP;
+ } else if (event == SYS_EV_KEY_HELP) {
+ print_help_info();
} else {
/* DO NOTHING */
}
@@ -545,6 +552,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_USB_DISCONNECT:
p_ctrl->usb_ctrl.usb_flag_detach = true;
next_stat = SYS_ST_WAIT_USB_CONNECT;
@@ -593,6 +603,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_DEC_OPEN_COMP:
result = is_track_changed(&p_ctrl->play_info);
if (result == true) {
@@ -661,6 +674,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_DEC_OPEN_COMP:
print_play_time(&p_ctrl->play_info);
result = exe_close_proc();
@@ -749,6 +765,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_STAT_STOP:
print_play_time(&p_ctrl->play_info);
result = exe_close_proc();
@@ -816,6 +835,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_DEC_CLOSE_COMP:
exe_end_proc(&p_ctrl->play_info);
if (p_ctrl->usb_ctrl.usb_flag_detach == true) {
@@ -886,6 +908,9 @@
case SYS_EV_KEY_REPEAT:
change_repeat_mode(&p_ctrl->play_info);
break;
+ case SYS_EV_KEY_HELP:
+ print_help_info();
+ break;
case SYS_EV_DEC_CLOSE_COMP:
exe_end_proc(&p_ctrl->play_info);
print_file_name(&p_ctrl->play_info, &p_ctrl->scan_data);
@@ -1227,6 +1252,14 @@
}
}
+/** Prints the command help information
+ *
+ */
+static void print_help_info(void)
+{
+ (void) dsp_req_help();
+}
+
/** Converts the track ID of main thread into the track ID of display thread
*
* @param trk_id Track ID of main thread
--- a/main/system.h Tue Oct 20 10:22:12 2015 +0000
+++ b/main/system.h Thu Nov 05 02:46:24 2015 +0000
@@ -47,6 +47,7 @@
SYS_KEYCODE_PREV, /* Previous track */
SYS_KEYCODE_PLAYINFO, /* Play info */
SYS_KEYCODE_REPEAT, /* Repeat */
+ SYS_KEYCODE_HELP, /* Help */
SYS_KEYCODE_NUM
} SYS_KeyCode;
@@ -73,6 +74,7 @@
* Play previous song : SYS_KEYCODE_PREV
* Show song information : SYS_KEYCODE_PLAYINFO
* Switch repeat mode : SYS_KEYCODE_REPEAT
+ * Show help message: SYS_KEYCODE_HELP
*
* @returns
* Returns true if the API is successful. Returns false if the API fails.
--- a/mbed.bld Tue Oct 20 10:22:12 2015 +0000 +++ b/mbed.bld Thu Nov 05 02:46:24 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file