首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

libmad学习进阶2----利用libmad将mp3转码成pcm

# include <stdio.h> # include <unistd.h> # include <sys/stat.h> # include <sys/mman.h> # include "mad.h" #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdlib.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. */ #define printf static Get_file_length(char *PATH); static int decode(unsigned char const *, unsigned long); int main(int argc, char *argv[]) { printf("The main is start!\n"); struct stat stat; void *fdm; int fd; //char buffer1[80000]; printf("###The input file is %s ! the arc=%d###\n",argv[1],argc); if (argc == 1) { printf("The argc is wrong!\n"); return 1; } #if 0 if (fstat(STDIN_FILENO, &stat) == -1 || stat.st_size == 0) return 2; #endif fd =open(argv[1],O_RDWR); if(-1==fd) { printf("sorry,The file open is faild!\n"); } else { printf("The file open is sucessed!\n"); } //read(fd,buffer1,sizeof(buffer1)); //printf("%s", buffer1); stat.st_size = Get_file_length(argv[1]); printf("The file size is %d\n",stat.st_size ); printf("The Map is begin!\n"); fdm = mmap(0, stat.st_size, PROT_READ, MAP_SHARED, fd, 0); if (fdm == MAP_FAILED) { printf("mmap is failed\n"); 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

05

AudioToolbox_如何录制PCM格式的数据

先来认识一下头文件 AudioConverter.h: 音频转换接口。定义用于创建和使用音频转换器的接口 AudioFile.h: 定义一个用于读取和写入文件中的音频数据的接口。 AudioFileStream.h: 定义了一个用于解析音频文件流的接口。 AudioFormat.h: 定义用于分配和读取音频文件中的音频格式元数据的接口。 AudioQueue.h: 定义播放和录制音频的接口。 AudioServices.h: 定义三个接口。系统健全的服务让你播放简短的声音和警报。音频硬件服务提供了一个轻量级的接口,用于与音频硬件交互。音频会议服务,让iPhone和iPod触摸应用管理音频会议。 AudioToolbox.h: 顶层包括音频工具箱框架的文件。 AuGraph.h:定义用于创建和使用音频处理图形界面。 ExtendedAudioFile.h: 定义用于将音频数据从文件直接转化为线性PCM接口,反之亦然。

01
领券