资源简介
mp3 播放器的linux c代码
代码片段和文件信息
/*
* libmad - MPEG audio decoder library
* Copyright (C) 2000-2004 Underbit Technologies Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
*
* $Id: minimad.cv 1.4 2004/01/23 09:41:32 rob Exp $
*/
# include
# include
# include
# include
# include “mad.h“
/*
* This is perhaps the simplest example use of the MAD high-level API.
* Standard input is mapped into memory via mmap() then the high-level API
* is invoked with three callbacks: input output and error. The output
* callback converts MAD‘s high-resolution PCM samples to 16 bits then
* writes them to standard output in little-endian stereo-interleaved
* format.
*/
static int decode(unsigned char const * unsigned long);
int main(int argc char *argv[])
{
struct stat stat;
void *fdm;
if (argc != 1)
return 1;
if (fstat(STDIN_FILENO &stat) == -1 ||
stat.st_size == 0)
return 2;
fdm = mmap(0 stat.st_size PROT_READ MAP_SHARED STDIN_FILENO 0);
if (fdm == MAP_FAILED)
return 3;
decode(fdm stat.st_size);
if (munmap(fdm stat.st_size) == -1)
return 4;
return 0;
}
/*
* This is a private message structure. A generic pointer to this structure
* is passed to each of the callback functions. Put here any data you need
* to access from within the callbacks.
*/
struct buffer {
unsigned char const *start;
unsigned long length;
};
/*
* This is the input callback. The purpose of this callback is to (re)fill
* the stream buffer which is to be decoded. In this example an entire file
* has been mapped into memory so we just call mad_stream_buffer() with the
* address and length of the mapping. When this callback is called a second
* time we are finished decoding.
*/
static
enum mad_flow input(void *data
struct mad_stream *stream)
{
struct buffer *buffer = data;
if (!buffer->length)
return MAD_FLOW_STOP;
mad_stream_buffer(stream buffer->start buffer->length);
buffer->length = 0;
return MAD_FLOW_CONTINUE;
}
/*
* The following utility routine performs simple rounding clipping and
* scaling of MAD‘s high-resolution samples down to 16 bits. It does not
* perform any dithering or noise shaping which would be recommended to
* obtain any exceptional audio quality. It is therefore not recommend
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 139 2012-07-01 00:41 mp3_test\Makefile
文件 61 2012-07-01 00:41 mp3_test\env.sh
文件 27125 2012-07-01 00:41 mp3_test\mad.h
文件 5935 2012-07-01 00:41 mp3_test\minimad.c
文件 1577 2012-07-01 00:41 mp3_test\pcm_play.c
目录 0 2005-05-20 16:20 mp3_test\
- 上一篇:简易电子琴
- 下一篇:2012年数学建模全国一等奖论文
相关资源
- 语音提示音MP3包.rar
- MP3电路原理图SCH格式
- 2层板设计+一个MP3原理图和PCB文件.r
- 嵌入式MP3播放器项目源代码
- 利用qt creator 实现的mp3的功能,有界面
- DSP+MP3+USB+FAT32
- MP3电路图和pcb
- libmp3lame.so
- MP3 播放器调用Api
- stm32f103+Vs1003b例程
- 单片机制作的MP3播放器
- 获取mp3文件的播放时间
- ProcDump32 v1.62绿色汉化正宗中文终极版
- DSP MP3解码代码
- 微软MP3必用补丁WindowsXP-KB915865-v11-x8
- 蚂蚁课堂第二期-第三期免费MP3格式全
- Delphi下用Lame编码器把WAV转成MP3
- web 页播放mp3音频文件
- 基于linux和gtk的mp3播放器
- 基于MSP430制作MP3源程序
- MP3电路设计原理图+PCB
- 网易云音乐缓存转换MP3
- VS1003 DXP集成库
- pcb MP3播放器源文件 protel课程设计
- 纯静音文件,三种格式mp3oggwav,30秒时
- MY1690-12P MP3解码模块应用程序含驱动程
- 基于QT的MP3压缩算法
- 风尚SwishMax4专用MP3 编码器
- QQ微信amr语音批量转mp3
- 基于STM32F103C8T6的手持MP3完整PCB工程文
评论
共有 条评论