⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 player_lib.h

📁 MP3 Cyclone的source code 利用FPGGA實現MP3的功能
💻 H
字号:
/***********************************************************************
 *                                                                     *
 * File:     player_lib.h                                              *
 *                                                                     *
 * Purpose:  Contains handy info for our custom MP3 player functions.  *
 *                                                                     *
 * Author:   N. Knight                                                 *
 *           Altera Corporation                                        *
 *           Aug 2005                                                  *
 **********************************************************************/

#ifndef PLAYER_LIB_H
#define PLAYER_LIB_H

#include "alt_types.h"
#include "fs/fat_layer.h"
#include "mad/mad.h"

#define PLAY_AUDIO 1

#define MEASURE_DECODE_PERFORMANCE 1
#define SECS_BETWEEN_MEAS 5

#define SHOW_FIFO_FULLNESS 1

#define FILE_BUFFER_SIZE 4096

/* Button encoding */
#define NO_BUTTON 0
#define PLAY 1
#define PAUSE 2
#define NEXT 8
#define PREVIOUS 4

/* Potential outcomes of pressing a button */
#define DO_NOTHING 0
#define SAME_FILE 0
#define NEW_FILE 1
#define PAUSE 2
#define BAD_BUTTON -1


/* File system error codes */
#define SUCCESS 0
#define NO_FILES_FOUND -1
#define NO_MP3_FILES_FOUND -2
#define NO_FAT_INIT -3

typedef struct mad_decoder mad_decoder_type;

typedef struct
{
  alt_u32 file_count;     // number of files available
  alt_u32 mp3_file_count; // number of files available
  char filename[12];
  alt_u32 file_number;    // what file we're playing
  alt_u32 file_length;
  alt_u32 file_position;
  alt_u32 file_buffer_size;
  char* file_buffer;
  alt_u32 playing;
  FILE_HNDL_PTR fat_file_handle; // FAT
  VOLUME_PTR vol_ptr;
} nios_mp3_file_struct;


/* Function Prototypes */
enum mad_flow NiosIIMP3_Input( void *data, struct mad_stream *stream );
enum mad_flow NiosIIMP3_Output( void *data, struct mad_header const *header, struct mad_pcm *pcm );
enum mad_flow NiosIIMP3_Error( void *data, struct mad_stream *stream, struct mad_frame *frame );
int  NiosIIMP3_Decode( nios_mp3_file_struct *mp3_files );
int  NiosIIMP3_FileInit( nios_mp3_file_struct *mp3_files );
void NiosIIMP3_FillFileBuffer( nios_mp3_file_struct *mp3_files, int file_offset );
int  NiosIIMP3_GetMP3File( nios_mp3_file_struct *mp3_files, int file_number );
int  NiosIIMP3_PlayAudio( struct mad_pcm *pcm );
void NiosIIMP3_ShowSpinner( int active );
int  NiosIIMP3_MeasurePerformance( struct mad_pcm *pcm );
int  NiosIIMP3_CheckButtons( nios_mp3_file_struct *mp3_files );
int  NiosIIMP3_ReadButtons( void );
int  NiosIIMP3_ChangePlayState( nios_mp3_file_struct *mp3_files, alt_u32 buttons );
void NiosIIMP3_DisplayNowPlaying( nios_mp3_file_struct *mp3_files );
inline void NiosIIMP3_NextFile( nios_mp3_file_struct *mp3_files );
inline void NiosIIMP3_PrevFile( nios_mp3_file_struct *mp3_files );
inline int  NiosIIMP3_FileFinished( nios_mp3_file_struct* mp3_files );


#endif /* PLAYER_LIB_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -